hgbook

annotate po/zh.po @ 667:3b33dd6aba87

Merge with http://hg.serpentine.com/mercurial/book
author Dongsheng Song <songdongsheng@live.cn>
date Thu Apr 02 09:24:36 2009 +0800 (2009-04-02)
parents 53f179393f5c
children 55e2953f82d6
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@667 44 "POT-Creation-Date: 2009-04-02 09:21+0800\n"
dongsheng@660 45 "PO-Revision-Date: 2009-03-31 10:12+0800\n"
dongsheng@627 46 "Last-Translator: \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@667 68 msgstr ""
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>
songdongsheng@658 92 #: ../en/appA-cmdref.xml:5
dongsheng@627 93 msgid "Command reference"
dongsheng@627 94 msgstr "命令参考"
dongsheng@627 95
dongsheng@627 96 #. type: Content of: <book><appendix><para>
songdongsheng@658 97 #: ../en/appA-cmdref.xml:7
dongsheng@627 98 msgid ""
dongsheng@627 99 "\\cmdref{add}{add files at the next commit} \\optref{add}{I}{include} \\optref"
dongsheng@627 100 "{add}{X}{exclude} \\optref{add}{n}{dry-run}"
dongsheng@627 101 msgstr ""
dongsheng@627 102
dongsheng@627 103 #. type: Content of: <book><appendix><para>
songdongsheng@658 104 #: ../en/appA-cmdref.xml:12
dongsheng@627 105 msgid "\\cmdref{diff}{print changes in history or working directory}"
dongsheng@627 106 msgstr ""
dongsheng@627 107
dongsheng@627 108 #. type: Content of: <book><appendix><para>
songdongsheng@658 109 #: ../en/appA-cmdref.xml:14
dongsheng@627 110 msgid ""
dongsheng@627 111 "Show differences between revisions for the specified files or directories, "
dongsheng@627 112 "using the unified diff format. For a description of the unified diff format, "
songdongsheng@658 113 "see <xref linkend=\"sec:mq:patch\"/>."
dongsheng@627 114 msgstr ""
dongsheng@627 115
dongsheng@627 116 #. type: Content of: <book><appendix><para>
songdongsheng@658 117 #: ../en/appA-cmdref.xml:18
dongsheng@627 118 msgid ""
dongsheng@627 119 "By default, this command does not print diffs for files that Mercurial "
dongsheng@627 120 "considers to contain binary data. To control this behaviour, see the <option "
dongsheng@627 121 "role=\"hg-opt-diff\">-a</option> and <option role=\"hg-opt-diff\">--git</"
dongsheng@627 122 "option> options."
dongsheng@627 123 msgstr ""
dongsheng@627 124
dongsheng@627 125 #. type: Content of: <book><appendix><sect2><title>
songdongsheng@658 126 #: ../en/appA-cmdref.xml:23
dongsheng@627 127 msgid "Options"
dongsheng@627 128 msgstr "选项"
dongsheng@627 129
dongsheng@627 130 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 131 #: ../en/appA-cmdref.xml:25
dongsheng@627 132 msgid "\\loptref{diff}{nodates}"
dongsheng@627 133 msgstr ""
dongsheng@627 134
dongsheng@627 135 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 136 #: ../en/appA-cmdref.xml:27
dongsheng@627 137 msgid "Omit date and time information when printing diff headers."
dongsheng@627 138 msgstr ""
dongsheng@627 139
dongsheng@627 140 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 141 #: ../en/appA-cmdref.xml:29
dongsheng@627 142 msgid "\\optref{diff}{B}{ignore-blank-lines}"
dongsheng@627 143 msgstr ""
dongsheng@627 144
dongsheng@627 145 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 146 #: ../en/appA-cmdref.xml:31
dongsheng@627 147 msgid ""
dongsheng@627 148 "Do not print changes that only insert or delete blank lines. A line that "
dongsheng@627 149 "contains only whitespace is not considered blank."
dongsheng@627 150 msgstr ""
dongsheng@627 151
dongsheng@627 152 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 153 #: ../en/appA-cmdref.xml:35
dongsheng@627 154 msgid "\\optref{diff}{I}{include}"
dongsheng@627 155 msgstr ""
dongsheng@627 156
dongsheng@627 157 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 158 #: ../en/appA-cmdref.xml:38
dongsheng@627 159 msgid "Include files and directories whose names match the given patterns."
dongsheng@627 160 msgstr ""
dongsheng@627 161
dongsheng@627 162 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 163 #: ../en/appA-cmdref.xml:41
dongsheng@627 164 msgid "\\optref{diff}{X}{exclude}"
dongsheng@627 165 msgstr ""
dongsheng@627 166
dongsheng@627 167 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 168 #: ../en/appA-cmdref.xml:44
dongsheng@627 169 msgid "Exclude files and directories whose names match the given patterns."
dongsheng@627 170 msgstr ""
dongsheng@627 171
dongsheng@627 172 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 173 #: ../en/appA-cmdref.xml:47
dongsheng@627 174 msgid "\\optref{diff}{a}{text}"
dongsheng@627 175 msgstr ""
dongsheng@627 176
dongsheng@627 177 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 178 #: ../en/appA-cmdref.xml:50
dongsheng@627 179 msgid ""
dongsheng@627 180 "If this option is not specified, <command role=\"hg-cmd\">hg diff</command> "
dongsheng@627 181 "will refuse to print diffs for files that it detects as binary. Specifying "
dongsheng@627 182 "<option role=\"hg-opt-diff\">-a</option> forces <command role=\"hg-cmd\">hg "
dongsheng@627 183 "diff</command> to treat all files as text, and generate diffs for all of them."
dongsheng@627 184 msgstr ""
dongsheng@627 185
dongsheng@627 186 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 187 #: ../en/appA-cmdref.xml:56
dongsheng@627 188 msgid ""
dongsheng@627 189 "This option is useful for files that are <quote>mostly text</quote> but have "
dongsheng@627 190 "a few embedded NUL characters. If you use it on files that contain a lot of "
dongsheng@627 191 "binary data, its output will be incomprehensible."
dongsheng@627 192 msgstr ""
dongsheng@627 193
dongsheng@627 194 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 195 #: ../en/appA-cmdref.xml:61
dongsheng@627 196 msgid "\\optref{diff}{b}{ignore-space-change}"
dongsheng@627 197 msgstr ""
dongsheng@627 198
dongsheng@627 199 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 200 #: ../en/appA-cmdref.xml:64
dongsheng@627 201 msgid ""
dongsheng@627 202 "Do not print a line if the only change to that line is in the amount of white "
dongsheng@627 203 "space it contains."
dongsheng@627 204 msgstr ""
dongsheng@627 205
dongsheng@627 206 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 207 #: ../en/appA-cmdref.xml:68
dongsheng@627 208 msgid "\\optref{diff}{g}{git}"
dongsheng@627 209 msgstr ""
dongsheng@627 210
dongsheng@627 211 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 212 #: ../en/appA-cmdref.xml:71
dongsheng@627 213 msgid ""
dongsheng@627 214 "Print <command>git</command>-compatible diffs. XXX reference a format "
dongsheng@627 215 "description."
dongsheng@627 216 msgstr ""
dongsheng@627 217
dongsheng@627 218 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 219 #: ../en/appA-cmdref.xml:75
dongsheng@627 220 msgid "\\optref{diff}{p}{show-function}"
dongsheng@627 221 msgstr ""
dongsheng@627 222
dongsheng@627 223 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 224 #: ../en/appA-cmdref.xml:78
dongsheng@627 225 msgid ""
dongsheng@627 226 "Display the name of the enclosing function in a hunk header, using a simple "
dongsheng@627 227 "heuristic. This functionality is enabled by default, so the <option role="
dongsheng@627 228 "\"hg-opt-diff\">-p</option> option has no effect unless you change the value "
dongsheng@627 229 "of the <envar role=\"rc-item-diff\">showfunc</envar> config item, as in the "
dongsheng@627 230 "following example."
dongsheng@627 231 msgstr ""
dongsheng@627 232
dongsheng@627 233 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 234 #: ../en/appA-cmdref.xml:85
dongsheng@627 235 msgid "\\optref{diff}{r}{rev}"
dongsheng@627 236 msgstr ""
dongsheng@627 237
dongsheng@627 238 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 239 #: ../en/appA-cmdref.xml:88
dongsheng@627 240 msgid ""
dongsheng@627 241 "Specify one or more revisions to compare. The <command role=\"hg-cmd\">hg "
dongsheng@627 242 "diff</command> command accepts up to two <option role=\"hg-opt-diff\">-r</"
dongsheng@627 243 "option> options to specify the revisions to compare."
dongsheng@627 244 msgstr ""
dongsheng@627 245
dongsheng@627 246 #. type: Content of: <book><appendix><sect2><orderedlist><listitem><para>
songdongsheng@658 247 #: ../en/appA-cmdref.xml:94
dongsheng@627 248 msgid ""
dongsheng@627 249 "Display the differences between the parent revision of the working directory "
dongsheng@627 250 "and the working directory."
dongsheng@627 251 msgstr ""
dongsheng@627 252
dongsheng@627 253 #. type: Content of: <book><appendix><sect2><orderedlist><listitem><para>
songdongsheng@658 254 #: ../en/appA-cmdref.xml:98
dongsheng@627 255 msgid ""
dongsheng@627 256 "Display the differences between the specified changeset and the working "
dongsheng@627 257 "directory."
dongsheng@627 258 msgstr ""
dongsheng@627 259
dongsheng@627 260 #. type: Content of: <book><appendix><sect2><orderedlist><listitem><para>
songdongsheng@658 261 #: ../en/appA-cmdref.xml:102
dongsheng@627 262 msgid "Display the differences between the two specified changesets."
dongsheng@627 263 msgstr ""
dongsheng@627 264
dongsheng@627 265 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 266 #: ../en/appA-cmdref.xml:106
dongsheng@627 267 msgid ""
dongsheng@627 268 "You can specify two revisions using either two <option role=\"hg-opt-diff\">-"
dongsheng@627 269 "r</option> options or revision range notation. For example, the two revision "
dongsheng@627 270 "specifications below are equivalent."
dongsheng@627 271 msgstr ""
dongsheng@627 272
dongsheng@627 273 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 274 #: ../en/appA-cmdref.xml:113
dongsheng@627 275 msgid ""
dongsheng@627 276 "When you provide two revisions, Mercurial treats the order of those revisions "
dongsheng@627 277 "as significant. Thus, <command role=\"hg-cmd\">hg diff -r10:20</command> "
dongsheng@627 278 "will produce a diff that will transform files from their contents as of "
dongsheng@627 279 "revision 10 to their contents as of revision 20, while <command role=\"hg-cmd"
dongsheng@627 280 "\">hg diff -r20:10</command> means the opposite: the diff that will transform "
dongsheng@627 281 "files from their revision 20 contents to their revision 10 contents. You "
dongsheng@627 282 "cannot reverse the ordering in this way if you are diffing against the "
dongsheng@627 283 "working directory."
dongsheng@627 284 msgstr ""
dongsheng@627 285
dongsheng@627 286 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 287 #: ../en/appA-cmdref.xml:123
dongsheng@627 288 msgid "\\optref{diff}{w}{ignore-all-space}"
dongsheng@627 289 msgstr ""
dongsheng@627 290
dongsheng@627 291 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 292 #: ../en/appA-cmdref.xml:126
dongsheng@627 293 msgid "\\cmdref{version}{print version and copyright information}"
dongsheng@627 294 msgstr ""
dongsheng@627 295
dongsheng@627 296 #. type: Content of: <book><appendix><sect2><para>
songdongsheng@658 297 #: ../en/appA-cmdref.xml:129
dongsheng@627 298 msgid ""
dongsheng@627 299 "This command displays the version of Mercurial you are running, and its "
dongsheng@627 300 "copyright license. There are four kinds of version string that you may see."
dongsheng@627 301 msgstr ""
dongsheng@627 302
dongsheng@627 303 #. type: Content of: <book><appendix><sect2><itemizedlist><listitem><para>
songdongsheng@658 304 #: ../en/appA-cmdref.xml:134
dongsheng@627 305 msgid ""
dongsheng@627 306 "The string <quote><literal>unknown</literal></quote>. This version of "
dongsheng@627 307 "Mercurial was not built in a Mercurial repository, and cannot determine its "
dongsheng@627 308 "own version."
dongsheng@627 309 msgstr ""
dongsheng@627 310
dongsheng@627 311 #. type: Content of: <book><appendix><sect2><itemizedlist><listitem><para>
songdongsheng@658 312 #: ../en/appA-cmdref.xml:139
dongsheng@627 313 msgid ""
dongsheng@627 314 "A short numeric string, such as <quote><literal>1.1</literal></quote>. This "
dongsheng@627 315 "is a build of a revision of Mercurial that was identified by a specific tag "
dongsheng@627 316 "in the repository where it was built. (This doesn't necessarily mean that "
dongsheng@627 317 "you're running an official release; someone else could have added that tag to "
dongsheng@627 318 "any revision in the repository where they built Mercurial.)"
dongsheng@627 319 msgstr ""
dongsheng@627 320
dongsheng@627 321 #. type: Content of: <book><appendix><sect2><itemizedlist><listitem><para>
songdongsheng@658 322 #: ../en/appA-cmdref.xml:147
dongsheng@627 323 msgid ""
dongsheng@627 324 "A hexadecimal string, such as <quote><literal>875489e31abe</literal></"
dongsheng@627 325 "quote>. This is a build of the given revision of Mercurial."
dongsheng@627 326 msgstr ""
dongsheng@627 327
dongsheng@627 328 #. type: Content of: <book><appendix><sect2><itemizedlist><listitem><para>
songdongsheng@658 329 #: ../en/appA-cmdref.xml:151
dongsheng@627 330 msgid ""
dongsheng@627 331 "A hexadecimal string followed by a date, such as <quote><literal>875489e31abe"
dongsheng@627 332 "+20070205</literal></quote>. This is a build of the given revision of "
dongsheng@627 333 "Mercurial, where the build repository contained some local changes that had "
dongsheng@627 334 "not been committed."
dongsheng@627 335 msgstr ""
dongsheng@627 336
dongsheng@627 337 #. type: Content of: <book><appendix><sect2><title>
songdongsheng@658 338 #: ../en/appA-cmdref.xml:160
dongsheng@627 339 msgid "Tips and tricks"
dongsheng@627 340 msgstr ""
dongsheng@627 341
dongsheng@627 342 #. type: Content of: <book><appendix><sect2><sect3><title>
songdongsheng@658 343 #: ../en/appA-cmdref.xml:163
dongsheng@627 344 msgid ""
dongsheng@627 345 "Why do the results of <command role=\"hg-cmd\">hg diff</command> and <command "
dongsheng@627 346 "role=\"hg-cmd\">hg status</command> differ?"
dongsheng@627 347 msgstr ""
dongsheng@627 348 "为什么 <command role=\"hg-cmd\">hg diff</command> 与 <command role=\"hg-cmd"
dongsheng@627 349 "\">hg status</command> 的结果不同 ?"
dongsheng@627 350
dongsheng@627 351 #. type: Content of: <book><appendix><sect2><sect3><para>
songdongsheng@658 352 #: ../en/appA-cmdref.xml:165
dongsheng@627 353 msgid ""
dongsheng@627 354 "When you run the <command role=\"hg-cmd\">hg status</command> command, you'll "
dongsheng@627 355 "see a list of files that Mercurial will record changes for the next time you "
dongsheng@627 356 "perform a commit. If you run the <command role=\"hg-cmd\">hg diff</command> "
dongsheng@627 357 "command, you may notice that it prints diffs for only a <emphasis>subset</"
dongsheng@627 358 "emphasis> of the files that <command role=\"hg-cmd\">hg status</command> "
dongsheng@627 359 "listed. There are two possible reasons for this."
dongsheng@627 360 msgstr ""
dongsheng@627 361
dongsheng@627 362 #. type: Content of: <book><appendix><sect2><sect3><para>
songdongsheng@658 363 #: ../en/appA-cmdref.xml:172
dongsheng@627 364 msgid ""
dongsheng@627 365 "The first is that <command role=\"hg-cmd\">hg status</command> prints some "
dongsheng@627 366 "kinds of modifications that <command role=\"hg-cmd\">hg diff</command> "
dongsheng@627 367 "doesn't normally display. The <command role=\"hg-cmd\">hg diff</command> "
dongsheng@627 368 "command normally outputs unified diffs, which don't have the ability to "
dongsheng@627 369 "represent some changes that Mercurial can track. Most notably, traditional "
dongsheng@627 370 "diffs can't represent a change in whether or not a file is executable, but "
dongsheng@627 371 "Mercurial records this information."
dongsheng@627 372 msgstr ""
dongsheng@627 373
dongsheng@627 374 #. type: Content of: <book><appendix><sect2><sect3><para>
songdongsheng@658 375 #: ../en/appA-cmdref.xml:180
dongsheng@627 376 msgid ""
dongsheng@627 377 "If you use the <option role=\"hg-opt-diff\">--git</option> option to <command "
dongsheng@627 378 "role=\"hg-cmd\">hg diff</command>, it will display <command>git</command>-"
dongsheng@627 379 "compatible diffs that <emphasis>can</emphasis> display this extra information."
dongsheng@627 380 msgstr ""
dongsheng@627 381
dongsheng@627 382 #. type: Content of: <book><appendix><sect2><sect3><para>
songdongsheng@658 383 #: ../en/appA-cmdref.xml:185
dongsheng@627 384 msgid ""
dongsheng@627 385 "The second possible reason that <command role=\"hg-cmd\">hg diff</command> "
dongsheng@627 386 "might be printing diffs for a subset of the files displayed by <command role="
dongsheng@627 387 "\"hg-cmd\">hg status</command> is that if you invoke it without any "
dongsheng@627 388 "arguments, <command role=\"hg-cmd\">hg diff</command> prints diffs against "
dongsheng@627 389 "the first parent of the working directory. If you have run <command role="
dongsheng@627 390 "\"hg-cmd\">hg merge</command> to merge two changesets, but you haven't yet "
dongsheng@627 391 "committed the results of the merge, your working directory has two parents "
dongsheng@627 392 "(use <command role=\"hg-cmd\">hg parents</command> to see them). While "
dongsheng@627 393 "<command role=\"hg-cmd\">hg status</command> prints modifications relative to "
dongsheng@627 394 "<emphasis>both</emphasis> parents after an uncommitted merge, <command role="
dongsheng@627 395 "\"hg-cmd\">hg diff</command> still operates relative only to the first "
dongsheng@627 396 "parent. You can get it to print diffs relative to the second parent by "
dongsheng@627 397 "specifying that parent with the <option role=\"hg-opt-diff\">-r</option> "
dongsheng@627 398 "option. There is no way to print diffs relative to both parents."
dongsheng@627 399 msgstr ""
dongsheng@627 400
dongsheng@627 401 #. type: Content of: <book><appendix><sect2><sect3><title>
songdongsheng@658 402 #: ../en/appA-cmdref.xml:201
dongsheng@627 403 msgid "Generating safe binary diffs"
dongsheng@627 404 msgstr "生成安全的二进制差异"
dongsheng@627 405
dongsheng@627 406 #. type: Content of: <book><appendix><sect2><sect3><para>
songdongsheng@658 407 #: ../en/appA-cmdref.xml:203
dongsheng@627 408 msgid ""
dongsheng@627 409 "If you use the <option role=\"hg-opt-diff\">-a</option> option to force "
dongsheng@627 410 "Mercurial to print diffs of files that are either <quote>mostly text</quote> "
dongsheng@627 411 "or contain lots of binary data, those diffs cannot subsequently be applied by "
dongsheng@627 412 "either Mercurial's <command role=\"hg-cmd\">hg import</command> command or "
dongsheng@627 413 "the system's <command>patch</command> command."
dongsheng@627 414 msgstr ""
dongsheng@627 415
dongsheng@627 416 #. type: Content of: <book><appendix><sect2><sect3><para>
songdongsheng@658 417 #: ../en/appA-cmdref.xml:210
dongsheng@627 418 msgid ""
dongsheng@627 419 "If you want to generate a diff of a binary file that is safe to use as input "
dongsheng@627 420 "for <command role=\"hg-cmd\">hg import</command>, use the <command role=\"hg-"
dongsheng@627 421 "cmd\">hg diff</command>{--git} option when you generate the patch. The "
dongsheng@627 422 "system <command>patch</command> command cannot handle binary patches at all."
dongsheng@627 423 msgstr ""
dongsheng@627 424
dongsheng@627 425 #. type: Content of: <book><appendix><title>
dongsheng@627 426 #: ../en/appB-mq-ref.xml:5
dongsheng@627 427 msgid "Mercurial Queues reference"
dongsheng@627 428 msgstr "Mercurial 队列参考"
dongsheng@627 429
dongsheng@627 430 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 431 #: ../en/appB-mq-ref.xml:8
dongsheng@627 432 msgid "MQ command reference"
dongsheng@627 433 msgstr "MQ 命令参考"
dongsheng@627 434
dongsheng@627 435 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 436 #: ../en/appB-mq-ref.xml:10
dongsheng@627 437 msgid ""
dongsheng@627 438 "For an overview of the commands provided by MQ, use the command <command role="
dongsheng@627 439 "\"hg-cmd\">hg help mq</command>."
dongsheng@627 440 msgstr ""
dongsheng@627 441
dongsheng@627 442 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@627 443 #: ../en/appB-mq-ref.xml:14
songdongsheng@667 444 #, fuzzy
dongsheng@661 445 msgid "<command role=\"hg-ext-mq\">qapplied</command>—print applied patches"
dongsheng@661 446 msgstr "<command role=\"hg-ext-mq\">qapplied</command>—显示已应用的补丁"
dongsheng@627 447
dongsheng@627 448 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 449 #: ../en/appB-mq-ref.xml:17
dongsheng@627 450 msgid ""
dongsheng@627 451 "The <command role=\"hg-ext-mq\">qapplied</command> command prints the current "
dongsheng@627 452 "stack of applied patches. Patches are printed in oldest-to-newest order, so "
dongsheng@627 453 "the last patch in the list is the <quote>top</quote> patch."
dongsheng@627 454 msgstr ""
dongsheng@627 455
dongsheng@627 456 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@627 457 #: ../en/appB-mq-ref.xml:24
songdongsheng@667 458 #, fuzzy
dongsheng@627 459 msgid ""
dongsheng@661 460 "<command role=\"hg-ext-mq\">qcommit</command>—commit changes in the queue "
dongsheng@661 461 "repository"
dongsheng@661 462 msgstr "<command role=\"hg-ext-mq\">qcommit</command>—提交队列中的修改"
dongsheng@627 463
dongsheng@627 464 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 465 #: ../en/appB-mq-ref.xml:27
dongsheng@627 466 msgid ""
dongsheng@627 467 "The <command role=\"hg-ext-mq\">qcommit</command> command commits any "
dongsheng@627 468 "outstanding changes in the <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 469 "patches</filename> repository. This command only works if the <filename role="
dongsheng@627 470 "\"special\" class=\"directory\">.hg/patches</filename> directory is a "
dongsheng@627 471 "repository, i.e. you created the directory using <command role=\"hg-cmd\">hg "
dongsheng@627 472 "qinit <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option></command> or ran "
dongsheng@627 473 "<command role=\"hg-cmd\">hg init</command> in the directory after running "
dongsheng@627 474 "<command role=\"hg-ext-mq\">qinit</command>."
dongsheng@627 475 msgstr ""
dongsheng@627 476
dongsheng@627 477 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@627 478 #: ../en/appB-mq-ref.xml:39
dongsheng@627 479 msgid ""
dongsheng@627 480 "This command is shorthand for <command role=\"hg-cmd\">hg commit --cwd .hg/"
dongsheng@627 481 "patches</command>."
dongsheng@627 482 msgstr ""
dongsheng@627 483
dongsheng@650 484 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 485 #: ../en/appB-mq-ref.xml:43
songdongsheng@667 486 #, fuzzy
dongsheng@650 487 msgid ""
dongsheng@661 488 "<command role=\"hg-ext-mq\">qdelete</command>—delete a patch from the "
dongsheng@653 489 "<filename role=\"special\">series</filename> file"
dongsheng@653 490 msgstr ""
dongsheng@661 491 "<command role=\"hg-ext-mq\">qdelete</command>—从文件 <filename role=\"special"
dongsheng@661 492 "\">series</filename> 中删除补丁"
dongsheng@650 493
dongsheng@627 494 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 495 #: ../en/appB-mq-ref.xml:48
dongsheng@627 496 msgid ""
dongsheng@627 497 "The <command role=\"hg-ext-mq\">qdelete</command> command removes the entry "
dongsheng@627 498 "for a patch from the <filename role=\"special\">series</filename> file in the "
dongsheng@627 499 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 500 "directory. It does not pop the patch if the patch is already applied. By "
dongsheng@627 501 "default, it does not delete the patch file; use the <option role=\"hg-ext-mq-"
dongsheng@627 502 "cmd-qdel-opt\">-f</option> option to do that."
dongsheng@627 503 msgstr ""
dongsheng@627 504
dongsheng@627 505 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 506 #: ../en/appB-mq-ref.xml:57 ../en/appB-mq-ref.xml:99 ../en/appB-mq-ref.xml:157
dongsheng@650 507 #: ../en/appB-mq-ref.xml:197 ../en/appB-mq-ref.xml:264
dongsheng@650 508 #: ../en/appB-mq-ref.xml:335 ../en/appB-mq-ref.xml:404
dongsheng@650 509 #: ../en/appB-mq-ref.xml:497
dongsheng@627 510 msgid "Options:"
dongsheng@627 511 msgstr ""
dongsheng@627 512
dongsheng@627 513 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 514 #: ../en/appB-mq-ref.xml:59
dongsheng@627 515 msgid ""
dongsheng@627 516 "<option role=\"hg-ext-mq-cmd-qdel-opt\">-f</option>: Delete the patch file."
dongsheng@627 517 msgstr ""
dongsheng@627 518
dongsheng@627 519 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 520 #: ../en/appB-mq-ref.xml:66
songdongsheng@667 521 #, fuzzy
dongsheng@627 522 msgid ""
dongsheng@661 523 "<command role=\"hg-ext-mq\">qdiff</command>—print a diff of the topmost "
dongsheng@661 524 "applied patch"
dongsheng@661 525 msgstr "<command role=\"hg-ext-mq\">qdiff</command>—显示最新应用补丁的差异"
dongsheng@627 526
dongsheng@627 527 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 528 #: ../en/appB-mq-ref.xml:69
dongsheng@627 529 msgid ""
dongsheng@627 530 "The <command role=\"hg-ext-mq\">qdiff</command> command prints a diff of the "
dongsheng@627 531 "topmost applied patch. It is equivalent to <command role=\"hg-cmd\">hg diff -"
dongsheng@627 532 "r-2:-1</command>."
dongsheng@627 533 msgstr ""
dongsheng@627 534
dongsheng@627 535 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 536 #: ../en/appB-mq-ref.xml:75
songdongsheng@667 537 #, fuzzy
dongsheng@627 538 msgid ""
dongsheng@661 539 "<command role=\"hg-ext-mq\">qfold</command>—merge (<quote>fold</quote>) "
dongsheng@661 540 "several patches into one"
dongsheng@661 541 msgstr ""
dongsheng@661 542 "<command role=\"hg-ext-mq\">qfold</command>—将多个补丁合并(<quote>折叠</"
dongsheng@661 543 "quote>)成一个"
dongsheng@627 544
dongsheng@627 545 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 546 #: ../en/appB-mq-ref.xml:78
dongsheng@627 547 msgid ""
dongsheng@627 548 "The <command role=\"hg-ext-mq\">qfold</command> command merges multiple "
dongsheng@627 549 "patches into the topmost applied patch, so that the topmost applied patch "
dongsheng@627 550 "makes the union of all of the changes in the patches in question."
dongsheng@627 551 msgstr ""
dongsheng@627 552
dongsheng@627 553 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 554 #: ../en/appB-mq-ref.xml:83
dongsheng@627 555 msgid ""
dongsheng@627 556 "The patches to fold must not be applied; <command role=\"hg-ext-mq\">qfold</"
dongsheng@627 557 "command> will exit with an error if any is. The order in which patches are "
dongsheng@627 558 "folded is significant; <command role=\"hg-cmd\">hg qfold a b</command> means "
dongsheng@627 559 "<quote>apply the current topmost patch, followed by <literal>a</literal>, "
dongsheng@627 560 "followed by <literal>b</literal></quote>."
dongsheng@627 561 msgstr ""
dongsheng@627 562
dongsheng@627 563 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 564 #: ../en/appB-mq-ref.xml:91
dongsheng@627 565 msgid ""
dongsheng@627 566 "The comments from the folded patches are appended to the comments of the "
dongsheng@627 567 "destination patch, with each block of comments separated by three asterisk "
dongsheng@627 568 "(<quote><literal>*</literal></quote>) characters. Use the <option role=\"hg-"
dongsheng@627 569 "ext-mq-cmd-qfold-opt\">-e</option> option to edit the commit message for the "
dongsheng@627 570 "combined patch/changeset after the folding has completed."
dongsheng@627 571 msgstr ""
dongsheng@627 572
dongsheng@627 573 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 574 #: ../en/appB-mq-ref.xml:101
dongsheng@627 575 msgid ""
dongsheng@627 576 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-e</option>: Edit the commit message "
dongsheng@627 577 "and patch description for the newly folded patch."
dongsheng@627 578 msgstr ""
dongsheng@627 579
dongsheng@627 580 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 581 #: ../en/appB-mq-ref.xml:106
dongsheng@627 582 msgid ""
dongsheng@627 583 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-l</option>: Use the contents of the "
dongsheng@627 584 "given file as the new commit message and patch description for the folded "
dongsheng@627 585 "patch."
dongsheng@627 586 msgstr ""
dongsheng@627 587
dongsheng@627 588 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 589 #: ../en/appB-mq-ref.xml:111
dongsheng@627 590 msgid ""
dongsheng@627 591 "<option role=\"hg-ext-mq-cmd-qfold-opt\">-m</option>: Use the given text as "
dongsheng@627 592 "the new commit message and patch description for the folded patch."
dongsheng@627 593 msgstr ""
dongsheng@627 594
dongsheng@627 595 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 596 #: ../en/appB-mq-ref.xml:119
songdongsheng@667 597 #, fuzzy
dongsheng@627 598 msgid ""
dongsheng@661 599 "<command role=\"hg-ext-mq\">qheader</command>—display the header/description "
dongsheng@661 600 "of a patch"
dongsheng@661 601 msgstr "<command role=\"hg-ext-mq\">qheader</command>—显示补丁头部描述"
dongsheng@627 602
dongsheng@627 603 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 604 #: ../en/appB-mq-ref.xml:123
dongsheng@627 605 msgid ""
dongsheng@627 606 "The <command role=\"hg-ext-mq\">qheader</command> command prints the header, "
dongsheng@627 607 "or description, of a patch. By default, it prints the header of the topmost "
dongsheng@627 608 "applied patch. Given an argument, it prints the header of the named patch."
dongsheng@627 609 msgstr ""
dongsheng@627 610
dongsheng@627 611 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 612 #: ../en/appB-mq-ref.xml:130
songdongsheng@667 613 #, fuzzy
dongsheng@627 614 msgid ""
dongsheng@661 615 "<command role=\"hg-ext-mq\">qimport</command>—import a third-party patch into "
dongsheng@661 616 "the queue"
dongsheng@661 617 msgstr "<command role=\"hg-ext-mq\">qimport</command>—将第三方补丁导入队列"
dongsheng@627 618
dongsheng@627 619 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 620 #: ../en/appB-mq-ref.xml:133
dongsheng@627 621 msgid ""
dongsheng@627 622 "The <command role=\"hg-ext-mq\">qimport</command> command adds an entry for "
dongsheng@627 623 "an external patch to the <filename role=\"special\">series</filename> file, "
dongsheng@627 624 "and copies the patch into the <filename role=\"special\" class=\"directory\">."
dongsheng@627 625 "hg/patches</filename> directory. It adds the entry immediately after the "
dongsheng@627 626 "topmost applied patch, but does not push the patch."
dongsheng@627 627 msgstr ""
dongsheng@627 628
dongsheng@627 629 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 630 #: ../en/appB-mq-ref.xml:141
dongsheng@627 631 msgid ""
dongsheng@627 632 "If the <filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 633 "directory is a repository, <command role=\"hg-ext-mq\">qimport</command> "
dongsheng@627 634 "automatically does an <command role=\"hg-cmd\">hg add</command> of the "
dongsheng@627 635 "imported patch."
dongsheng@627 636 msgstr ""
dongsheng@627 637
dongsheng@627 638 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 639 #: ../en/appB-mq-ref.xml:149
songdongsheng@667 640 #, fuzzy
dongsheng@627 641 msgid ""
dongsheng@661 642 "<command role=\"hg-ext-mq\">qinit</command>—prepare a repository to work with "
dongsheng@661 643 "MQ"
dongsheng@661 644 msgstr "<command role=\"hg-ext-mq\">qinit</command>—为使用 MQ 配置版本库"
dongsheng@627 645
dongsheng@627 646 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 647 #: ../en/appB-mq-ref.xml:152
dongsheng@627 648 msgid ""
dongsheng@627 649 "The <command role=\"hg-ext-mq\">qinit</command> command prepares a repository "
dongsheng@627 650 "to work with MQ. It creates a directory called <filename role=\"special\" "
dongsheng@627 651 "class=\"directory\">.hg/patches</filename>."
dongsheng@627 652 msgstr ""
dongsheng@627 653
dongsheng@627 654 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 655 #: ../en/appB-mq-ref.xml:159
dongsheng@627 656 msgid ""
dongsheng@627 657 "<option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option>: Create <filename role="
dongsheng@627 658 "\"special\" class=\"directory\">.hg/patches</filename> as a repository in its "
dongsheng@627 659 "own right. Also creates a <filename role=\"special\">.hgignore</filename> "
dongsheng@627 660 "file that will ignore the <filename role=\"special\">status</filename> file."
dongsheng@627 661 msgstr ""
dongsheng@627 662
dongsheng@627 663 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 664 #: ../en/appB-mq-ref.xml:169
dongsheng@627 665 msgid ""
dongsheng@627 666 "When the <filename role=\"special\" class=\"directory\">.hg/patches</"
dongsheng@627 667 "filename> directory is a repository, the <command role=\"hg-ext-mq\">qimport</"
dongsheng@627 668 "command> and <command role=\"hg-ext-mq\">qnew</command> commands "
dongsheng@627 669 "automatically <command role=\"hg-cmd\">hg add</command> new patches."
dongsheng@627 670 msgstr ""
dongsheng@627 671
dongsheng@627 672 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 673 #: ../en/appB-mq-ref.xml:178
songdongsheng@667 674 #, fuzzy
dongsheng@661 675 msgid "<command role=\"hg-ext-mq\">qnew</command>—create a new patch"
dongsheng@661 676 msgstr "<command role=\"hg-ext-mq\">qnew</command>—创建新补丁"
dongsheng@627 677
dongsheng@627 678 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 679 #: ../en/appB-mq-ref.xml:181
dongsheng@627 680 msgid ""
dongsheng@627 681 "The <command role=\"hg-ext-mq\">qnew</command> command creates a new patch. "
dongsheng@627 682 "It takes one mandatory argument, the name to use for the patch file. The "
dongsheng@627 683 "newly created patch is created empty by default. It is added to the "
dongsheng@627 684 "<filename role=\"special\">series</filename> file after the current topmost "
dongsheng@627 685 "applied patch, and is immediately pushed on top of that patch."
dongsheng@627 686 msgstr ""
dongsheng@627 687
dongsheng@627 688 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 689 #: ../en/appB-mq-ref.xml:189
dongsheng@627 690 msgid ""
dongsheng@627 691 "If <command role=\"hg-ext-mq\">qnew</command> finds modified files in the "
dongsheng@627 692 "working directory, it will refuse to create a new patch unless the <option "
dongsheng@627 693 "role=\"hg-ext-mq-cmd-qnew-opt\">-f</option> option is used (see below). This "
dongsheng@627 694 "behaviour allows you to <command role=\"hg-ext-mq\">qrefresh</command> your "
dongsheng@627 695 "topmost applied patch before you apply a new patch on top of it."
dongsheng@627 696 msgstr ""
dongsheng@627 697
dongsheng@627 698 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 699 #: ../en/appB-mq-ref.xml:199
dongsheng@627 700 msgid ""
dongsheng@627 701 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-f</option>: Create a new patch if "
dongsheng@627 702 "the contents of the working directory are modified. Any outstanding "
dongsheng@627 703 "modifications are added to the newly created patch, so after this command "
dongsheng@627 704 "completes, the working directory will no longer be modified."
dongsheng@627 705 msgstr ""
dongsheng@627 706
dongsheng@627 707 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 708 #: ../en/appB-mq-ref.xml:206
dongsheng@627 709 msgid ""
dongsheng@627 710 "<option role=\"hg-ext-mq-cmd-qnew-opt\">-m</option>: Use the given text as "
dongsheng@627 711 "the commit message. This text will be stored at the beginning of the patch "
dongsheng@627 712 "file, before the patch data."
dongsheng@627 713 msgstr ""
dongsheng@627 714
dongsheng@627 715 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 716 #: ../en/appB-mq-ref.xml:215
songdongsheng@667 717 #, fuzzy
dongsheng@627 718 msgid ""
dongsheng@661 719 "<command role=\"hg-ext-mq\">qnext</command>—print the name of the next patch"
dongsheng@661 720 msgstr "<command role=\"hg-ext-mq\">qnext</command>—显示下个补丁的名称"
dongsheng@627 721
dongsheng@627 722 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 723 #: ../en/appB-mq-ref.xml:218
dongsheng@627 724 msgid ""
dongsheng@627 725 "The <command role=\"hg-ext-mq\">qnext</command> command prints the name name "
dongsheng@627 726 "of the next patch in the <filename role=\"special\">series</filename> file "
dongsheng@627 727 "after the topmost applied patch. This patch will become the topmost applied "
dongsheng@627 728 "patch if you run <command role=\"hg-ext-mq\">qpush</command>."
dongsheng@627 729 msgstr ""
dongsheng@627 730
dongsheng@627 731 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 732 #: ../en/appB-mq-ref.xml:227
songdongsheng@667 733 #, fuzzy
dongsheng@661 734 msgid "<command role=\"hg-ext-mq\">qpop</command>—pop patches off the stack"
dongsheng@661 735 msgstr "<command role=\"hg-ext-mq\">qpop</command>—删除堆栈顶部的补丁"
dongsheng@627 736
dongsheng@627 737 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 738 #: ../en/appB-mq-ref.xml:230
dongsheng@627 739 msgid ""
dongsheng@627 740 "The <command role=\"hg-ext-mq\">qpop</command> command removes applied "
dongsheng@627 741 "patches from the top of the stack of applied patches. By default, it removes "
dongsheng@627 742 "only one patch."
dongsheng@627 743 msgstr ""
dongsheng@627 744
dongsheng@627 745 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 746 #: ../en/appB-mq-ref.xml:234
dongsheng@627 747 msgid ""
dongsheng@627 748 "This command removes the changesets that represent the popped patches from "
dongsheng@627 749 "the repository, and updates the working directory to undo the effects of the "
dongsheng@627 750 "patches."
dongsheng@627 751 msgstr ""
dongsheng@627 752
dongsheng@627 753 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 754 #: ../en/appB-mq-ref.xml:238
dongsheng@627 755 msgid ""
dongsheng@627 756 "This command takes an optional argument, which it uses as the name or index "
dongsheng@627 757 "of the patch to pop to. If given a name, it will pop patches until the named "
dongsheng@627 758 "patch is the topmost applied patch. If given a number, <command role=\"hg-"
dongsheng@627 759 "ext-mq\">qpop</command> treats the number as an index into the entries in the "
dongsheng@627 760 "series file, counting from zero (empty lines and lines containing only "
dongsheng@627 761 "comments do not count). It pops patches until the patch identified by the "
dongsheng@627 762 "given index is the topmost applied patch."
dongsheng@627 763 msgstr ""
dongsheng@627 764
dongsheng@627 765 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 766 #: ../en/appB-mq-ref.xml:248
dongsheng@627 767 msgid ""
dongsheng@627 768 "The <command role=\"hg-ext-mq\">qpop</command> command does not read or write "
dongsheng@627 769 "patches or the <filename role=\"special\">series</filename> file. It is thus "
dongsheng@627 770 "safe to <command role=\"hg-ext-mq\">qpop</command> a patch that you have "
dongsheng@627 771 "removed from the <filename role=\"special\">series</filename> file, or a "
dongsheng@627 772 "patch that you have renamed or deleted entirely. In the latter two cases, "
dongsheng@627 773 "use the name of the patch as it was when you applied it."
dongsheng@627 774 msgstr ""
dongsheng@627 775
dongsheng@627 776 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 777 #: ../en/appB-mq-ref.xml:257
dongsheng@627 778 msgid ""
dongsheng@627 779 "By default, the <command role=\"hg-ext-mq\">qpop</command> command will not "
dongsheng@627 780 "pop any patches if the working directory has been modified. You can override "
dongsheng@627 781 "this behaviour using the <option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option> "
dongsheng@627 782 "option, which reverts all modifications in the working directory."
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:266
dongsheng@627 787 msgid ""
dongsheng@627 788 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-a</option>: Pop all applied "
dongsheng@627 789 "patches. This returns the repository to its state before you applied any "
dongsheng@627 790 "patches."
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:271
dongsheng@627 795 msgid ""
dongsheng@627 796 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-f</option>: Forcibly revert any "
dongsheng@627 797 "modifications to the working directory when popping."
dongsheng@627 798 msgstr ""
dongsheng@627 799
dongsheng@627 800 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 801 #: ../en/appB-mq-ref.xml:276
dongsheng@627 802 msgid ""
dongsheng@627 803 "<option role=\"hg-ext-mq-cmd-qpop-opt\">-n</option>: Pop a patch from the "
dongsheng@627 804 "named queue."
dongsheng@627 805 msgstr ""
dongsheng@627 806
dongsheng@627 807 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 808 #: ../en/appB-mq-ref.xml:281
dongsheng@627 809 msgid ""
dongsheng@627 810 "The <command role=\"hg-ext-mq\">qpop</command> command removes one line from "
dongsheng@627 811 "the end of the <filename role=\"special\">status</filename> file for each "
dongsheng@627 812 "patch that it pops."
dongsheng@627 813 msgstr ""
dongsheng@627 814
dongsheng@627 815 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 816 #: ../en/appB-mq-ref.xml:288
songdongsheng@667 817 #, fuzzy
dongsheng@627 818 msgid ""
dongsheng@661 819 "<command role=\"hg-ext-mq\">qprev</command>—print the name of the previous "
dongsheng@661 820 "patch"
dongsheng@661 821 msgstr "<command role=\"hg-ext-mq\">qprev</command>—显示上个补丁的名称"
dongsheng@627 822
dongsheng@627 823 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 824 #: ../en/appB-mq-ref.xml:291
dongsheng@627 825 msgid ""
dongsheng@627 826 "The <command role=\"hg-ext-mq\">qprev</command> command prints the name of "
dongsheng@627 827 "the patch in the <filename role=\"special\">series</filename> file that comes "
dongsheng@627 828 "before the topmost applied patch. This will become the topmost applied patch "
dongsheng@627 829 "if you run <command role=\"hg-ext-mq\">qpop</command>."
dongsheng@627 830 msgstr ""
dongsheng@627 831
dongsheng@627 832 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 833 #: ../en/appB-mq-ref.xml:300
songdongsheng@667 834 #, fuzzy
dongsheng@661 835 msgid "<command role=\"hg-ext-mq\">qpush</command>—push patches onto the stack"
dongsheng@661 836 msgstr "<command role=\"hg-ext-mq\">qpush</command>—增加补丁到堆栈"
dongsheng@627 837
dongsheng@627 838 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 839 #: ../en/appB-mq-ref.xml:303
dongsheng@627 840 msgid ""
dongsheng@627 841 "The <command role=\"hg-ext-mq\">qpush</command> command adds patches onto the "
dongsheng@627 842 "applied stack. By default, it adds only one patch."
dongsheng@627 843 msgstr ""
dongsheng@627 844
dongsheng@627 845 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 846 #: ../en/appB-mq-ref.xml:307
dongsheng@627 847 msgid ""
dongsheng@627 848 "This command creates a new changeset to represent each applied patch, and "
dongsheng@627 849 "updates the working directory to apply the effects of the patches."
dongsheng@627 850 msgstr ""
dongsheng@627 851
dongsheng@627 852 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 853 #: ../en/appB-mq-ref.xml:311
dongsheng@627 854 msgid "The default data used when creating a changeset are as follows:"
dongsheng@627 855 msgstr ""
dongsheng@627 856
dongsheng@627 857 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 858 #: ../en/appB-mq-ref.xml:314
dongsheng@627 859 msgid ""
dongsheng@627 860 "The commit date and time zone are the current date and time zone. Because "
dongsheng@627 861 "these data are used to compute the identity of a changeset, this means that "
dongsheng@627 862 "if you <command role=\"hg-ext-mq\">qpop</command> a patch and <command role="
dongsheng@627 863 "\"hg-ext-mq\">qpush</command> it again, the changeset that you push will have "
dongsheng@627 864 "a different identity than the changeset you popped."
dongsheng@627 865 msgstr ""
dongsheng@627 866
dongsheng@627 867 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 868 #: ../en/appB-mq-ref.xml:322
dongsheng@627 869 msgid ""
dongsheng@627 870 "The author is the same as the default used by the <command role=\"hg-cmd\">hg "
dongsheng@627 871 "commit</command> command."
dongsheng@627 872 msgstr ""
dongsheng@627 873
dongsheng@627 874 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 875 #: ../en/appB-mq-ref.xml:326
dongsheng@627 876 msgid ""
dongsheng@627 877 "The commit message is any text from the patch file that comes before the "
dongsheng@627 878 "first diff header. If there is no such text, a default commit message is "
dongsheng@627 879 "used that identifies the name of the patch."
dongsheng@627 880 msgstr ""
dongsheng@627 881
dongsheng@627 882 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 883 #: ../en/appB-mq-ref.xml:331
dongsheng@627 884 msgid ""
dongsheng@627 885 "If a patch contains a Mercurial patch header (XXX add link), the information "
dongsheng@627 886 "in the patch header overrides these defaults."
dongsheng@627 887 msgstr ""
dongsheng@627 888
dongsheng@627 889 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 890 #: ../en/appB-mq-ref.xml:337
dongsheng@627 891 msgid ""
dongsheng@627 892 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-a</option>: Push all unapplied "
dongsheng@627 893 "patches from the <filename role=\"special\">series</filename> file until "
dongsheng@627 894 "there are none left to push."
dongsheng@627 895 msgstr ""
dongsheng@627 896
dongsheng@627 897 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 898 #: ../en/appB-mq-ref.xml:343
dongsheng@627 899 msgid ""
dongsheng@627 900 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-l</option>: Add the name of the "
dongsheng@627 901 "patch to the end of the commit message."
dongsheng@627 902 msgstr ""
dongsheng@627 903
dongsheng@627 904 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 905 #: ../en/appB-mq-ref.xml:347
dongsheng@627 906 msgid ""
dongsheng@627 907 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-m</option>: If a patch fails to "
dongsheng@627 908 "apply cleanly, use the entry for the patch in another saved queue to compute "
dongsheng@627 909 "the parameters for a three-way merge, and perform a three-way merge using the "
dongsheng@627 910 "normal Mercurial merge machinery. Use the resolution of the merge as the new "
dongsheng@627 911 "patch content."
dongsheng@627 912 msgstr ""
dongsheng@627 913
dongsheng@627 914 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 915 #: ../en/appB-mq-ref.xml:355
dongsheng@627 916 msgid ""
dongsheng@627 917 "<option role=\"hg-ext-mq-cmd-qpush-opt\">-n</option>: Use the named queue if "
dongsheng@627 918 "merging while pushing."
dongsheng@627 919 msgstr ""
dongsheng@627 920
dongsheng@627 921 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 922 #: ../en/appB-mq-ref.xml:360
dongsheng@627 923 msgid ""
dongsheng@627 924 "The <command role=\"hg-ext-mq\">qpush</command> command reads, but does not "
dongsheng@627 925 "modify, the <filename role=\"special\">series</filename> file. It appends "
dongsheng@627 926 "one line to the <command role=\"hg-cmd\">hg status</command> file for each "
dongsheng@627 927 "patch that it pushes."
dongsheng@627 928 msgstr ""
dongsheng@627 929
dongsheng@627 930 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 931 #: ../en/appB-mq-ref.xml:368
songdongsheng@667 932 #, fuzzy
dongsheng@627 933 msgid ""
dongsheng@661 934 "<command role=\"hg-ext-mq\">qrefresh</command>—update the topmost applied "
dongsheng@661 935 "patch"
dongsheng@661 936 msgstr "<command role=\"hg-ext-mq\">qrefresh</command>—更新最新的补丁"
dongsheng@627 937
dongsheng@627 938 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 939 #: ../en/appB-mq-ref.xml:372
dongsheng@627 940 msgid ""
dongsheng@627 941 "The <command role=\"hg-ext-mq\">qrefresh</command> command updates the "
dongsheng@627 942 "topmost applied patch. It modifies the patch, removes the old changeset that "
dongsheng@627 943 "represented the patch, and creates a new changeset to represent the modified "
dongsheng@627 944 "patch."
dongsheng@627 945 msgstr ""
dongsheng@627 946
dongsheng@627 947 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 948 #: ../en/appB-mq-ref.xml:378
dongsheng@627 949 msgid ""
dongsheng@627 950 "The <command role=\"hg-ext-mq\">qrefresh</command> command looks for the "
dongsheng@627 951 "following modifications:"
dongsheng@627 952 msgstr ""
dongsheng@627 953
dongsheng@627 954 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 955 #: ../en/appB-mq-ref.xml:381
dongsheng@627 956 msgid ""
dongsheng@627 957 "Changes to the commit message, i.e. the text before the first diff header in "
dongsheng@627 958 "the patch file, are reflected in the new changeset that represents the patch."
dongsheng@627 959 msgstr ""
dongsheng@627 960
dongsheng@627 961 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 962 #: ../en/appB-mq-ref.xml:386
dongsheng@627 963 msgid ""
dongsheng@627 964 "Modifications to tracked files in the working directory are added to the "
dongsheng@627 965 "patch."
dongsheng@627 966 msgstr ""
dongsheng@627 967
dongsheng@627 968 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 969 #: ../en/appB-mq-ref.xml:389
dongsheng@627 970 msgid ""
dongsheng@627 971 "Changes to the files tracked using <command role=\"hg-cmd\">hg add</command>, "
dongsheng@627 972 "<command role=\"hg-cmd\">hg copy</command>, <command role=\"hg-cmd\">hg "
dongsheng@627 973 "remove</command>, or <command role=\"hg-cmd\">hg rename</command>. Added "
dongsheng@627 974 "files and copy and rename destinations are added to the patch, while removed "
dongsheng@627 975 "files and rename sources are removed."
dongsheng@627 976 msgstr ""
dongsheng@627 977
dongsheng@627 978 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 979 #: ../en/appB-mq-ref.xml:398
dongsheng@627 980 msgid ""
dongsheng@627 981 "Even if <command role=\"hg-ext-mq\">qrefresh</command> detects no changes, it "
dongsheng@627 982 "still recreates the changeset that represents the patch. This causes the "
dongsheng@627 983 "identity of the changeset to differ from the previous changeset that "
dongsheng@627 984 "identified the patch."
dongsheng@627 985 msgstr ""
dongsheng@627 986
dongsheng@627 987 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 988 #: ../en/appB-mq-ref.xml:406
dongsheng@627 989 msgid ""
dongsheng@627 990 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-e</option>: Modify the commit "
dongsheng@627 991 "and patch description, using the preferred text editor."
dongsheng@627 992 msgstr ""
dongsheng@627 993
dongsheng@627 994 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 995 #: ../en/appB-mq-ref.xml:411
dongsheng@627 996 msgid ""
dongsheng@627 997 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-m</option>: Modify the commit "
dongsheng@627 998 "message and patch description, using the given text."
dongsheng@627 999 msgstr ""
dongsheng@627 1000
dongsheng@627 1001 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 1002 #: ../en/appB-mq-ref.xml:416
dongsheng@627 1003 msgid ""
dongsheng@627 1004 "<option role=\"hg-ext-mq-cmd-qrefresh-opt\">-l</option>: Modify the commit "
dongsheng@627 1005 "message and patch description, using text from the given file."
dongsheng@627 1006 msgstr ""
dongsheng@627 1007
dongsheng@627 1008 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1009 #: ../en/appB-mq-ref.xml:424
songdongsheng@667 1010 #, fuzzy
dongsheng@661 1011 msgid "<command role=\"hg-ext-mq\">qrename</command>—rename a patch"
dongsheng@661 1012 msgstr "<command role=\"hg-ext-mq\">qrename</command>—改名补丁"
dongsheng@627 1013
dongsheng@627 1014 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1015 #: ../en/appB-mq-ref.xml:427
dongsheng@627 1016 msgid ""
dongsheng@627 1017 "The <command role=\"hg-ext-mq\">qrename</command> command renames a patch, "
dongsheng@627 1018 "and changes the entry for the patch in the <filename role=\"special\">series</"
dongsheng@627 1019 "filename> file."
dongsheng@627 1020 msgstr ""
dongsheng@627 1021
dongsheng@627 1022 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1023 #: ../en/appB-mq-ref.xml:431
dongsheng@627 1024 msgid ""
dongsheng@627 1025 "With a single argument, <command role=\"hg-ext-mq\">qrename</command> renames "
dongsheng@627 1026 "the topmost applied patch. With two arguments, it renames its first argument "
dongsheng@627 1027 "to its second."
dongsheng@627 1028 msgstr ""
dongsheng@627 1029
dongsheng@627 1030 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1031 #: ../en/appB-mq-ref.xml:438
songdongsheng@667 1032 #, fuzzy
dongsheng@661 1033 msgid "<command role=\"hg-ext-mq\">qrestore</command>—restore saved queue state"
dongsheng@661 1034 msgstr "<command role=\"hg-ext-mq\">qrestore</command>—恢复保存的队列"
dongsheng@627 1035
dongsheng@627 1036 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1037 #: ../en/appB-mq-ref.xml:442
dongsheng@627 1038 msgid "XXX No idea what this does."
dongsheng@627 1039 msgstr ""
dongsheng@627 1040
dongsheng@627 1041 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1042 #: ../en/appB-mq-ref.xml:446
songdongsheng@667 1043 #, fuzzy
dongsheng@661 1044 msgid "<command role=\"hg-ext-mq\">qsave</command>—save current queue state"
dongsheng@661 1045 msgstr "<command role=\"hg-ext-mq\">qsave</command>—保存当前的队列状态"
dongsheng@627 1046
dongsheng@627 1047 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1048 #: ../en/appB-mq-ref.xml:449
dongsheng@627 1049 msgid "XXX Likewise."
dongsheng@627 1050 msgstr ""
dongsheng@627 1051
dongsheng@627 1052 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1053 #: ../en/appB-mq-ref.xml:453
songdongsheng@667 1054 #, fuzzy
dongsheng@627 1055 msgid ""
dongsheng@661 1056 "<command role=\"hg-ext-mq\">qseries</command>—print the entire patch series"
dongsheng@661 1057 msgstr "<command role=\"hg-ext-mq\">qseries</command>—显示补丁序列"
dongsheng@627 1058
dongsheng@627 1059 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1060 #: ../en/appB-mq-ref.xml:456
dongsheng@627 1061 msgid ""
dongsheng@627 1062 "The <command role=\"hg-ext-mq\">qseries</command> command prints the entire "
dongsheng@627 1063 "patch series from the <filename role=\"special\">series</filename> file. It "
dongsheng@627 1064 "prints only patch names, not empty lines or comments. It prints in order "
dongsheng@627 1065 "from first to be applied to last."
dongsheng@627 1066 msgstr ""
dongsheng@627 1067
dongsheng@627 1068 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1069 #: ../en/appB-mq-ref.xml:464
songdongsheng@667 1070 #, fuzzy
dongsheng@627 1071 msgid ""
dongsheng@661 1072 "<command role=\"hg-ext-mq\">qtop</command>—print the name of the current patch"
dongsheng@661 1073 msgstr "<command role=\"hg-ext-mq\">qtop</command>—显示当前补丁的名称"
dongsheng@627 1074
dongsheng@627 1075 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1076 #: ../en/appB-mq-ref.xml:467
dongsheng@627 1077 msgid ""
dongsheng@627 1078 "The <command role=\"hg-ext-mq\">qtop</command> prints the name of the topmost "
dongsheng@627 1079 "currently applied patch."
dongsheng@627 1080 msgstr ""
dongsheng@627 1081
dongsheng@627 1082 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1083 #: ../en/appB-mq-ref.xml:472
songdongsheng@667 1084 #, fuzzy
dongsheng@627 1085 msgid ""
dongsheng@661 1086 "<command role=\"hg-ext-mq\">qunapplied</command>—print patches not yet applied"
dongsheng@661 1087 msgstr "<command role=\"hg-ext-mq\">qunapplied</command>—显示尚未应用的补丁"
dongsheng@627 1088
dongsheng@627 1089 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1090 #: ../en/appB-mq-ref.xml:476
dongsheng@627 1091 msgid ""
dongsheng@627 1092 "The <command role=\"hg-ext-mq\">qunapplied</command> command prints the names "
dongsheng@627 1093 "of patches from the <filename role=\"special\">series</filename> file that "
dongsheng@627 1094 "are not yet applied. It prints them in order from the next patch that will "
dongsheng@627 1095 "be pushed to the last."
dongsheng@627 1096 msgstr ""
dongsheng@627 1097
dongsheng@627 1098 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1099 #: ../en/appB-mq-ref.xml:484
songdongsheng@667 1100 #, fuzzy
dongsheng@627 1101 msgid ""
dongsheng@661 1102 "<command role=\"hg-cmd\">hg strip</command>—remove a revision and descendants"
dongsheng@661 1103 msgstr "<command role=\"hg-cmd\">hg strip</command>—删除一个版本及其后继"
dongsheng@627 1104
dongsheng@627 1105 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1106 #: ../en/appB-mq-ref.xml:487
dongsheng@627 1107 msgid ""
dongsheng@627 1108 "The <command role=\"hg-cmd\">hg strip</command> command removes a revision, "
dongsheng@627 1109 "and all of its descendants, from the repository. It undoes the effects of "
dongsheng@627 1110 "the removed revisions from the repository, and updates the working directory "
dongsheng@627 1111 "to the first parent of the removed revision."
dongsheng@627 1112 msgstr ""
dongsheng@627 1113
dongsheng@627 1114 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1115 #: ../en/appB-mq-ref.xml:493
dongsheng@627 1116 msgid ""
dongsheng@627 1117 "The <command role=\"hg-cmd\">hg strip</command> command saves a backup of the "
dongsheng@627 1118 "removed changesets in a bundle, so that they can be reapplied if removed in "
dongsheng@627 1119 "error."
dongsheng@627 1120 msgstr ""
dongsheng@627 1121
dongsheng@627 1122 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 1123 #: ../en/appB-mq-ref.xml:499
dongsheng@627 1124 msgid ""
dongsheng@627 1125 "<option role=\"hg-opt-strip\">-b</option>: Save unrelated changesets that are "
dongsheng@627 1126 "intermixed with the stripped changesets in the backup bundle."
dongsheng@627 1127 msgstr ""
dongsheng@627 1128
dongsheng@627 1129 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 1130 #: ../en/appB-mq-ref.xml:503
dongsheng@627 1131 msgid ""
dongsheng@627 1132 "<option role=\"hg-opt-strip\">-f</option>: If a branch has multiple heads, "
dongsheng@627 1133 "remove all heads. XXX This should be renamed, and use <literal>-f</literal> "
dongsheng@627 1134 "to strip revs when there are pending changes."
dongsheng@627 1135 msgstr ""
dongsheng@627 1136
dongsheng@627 1137 #. type: Content of: <book><appendix><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 1138 #: ../en/appB-mq-ref.xml:508
dongsheng@627 1139 msgid "<option role=\"hg-opt-strip\">-n</option>: Do not save a backup bundle."
dongsheng@627 1140 msgstr ""
dongsheng@627 1141
dongsheng@627 1142 #. type: Content of: <book><appendix><sect1><title>
dongsheng@650 1143 #: ../en/appB-mq-ref.xml:515
dongsheng@627 1144 msgid "MQ file reference"
dongsheng@627 1145 msgstr "MQ 文件参考"
dongsheng@627 1146
dongsheng@627 1147 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1148 #: ../en/appB-mq-ref.xml:518
dongsheng@627 1149 msgid "The <filename role=\"special\">series</filename> file"
dongsheng@627 1150 msgstr "<filename role=\"special\">序列</filename>文件"
dongsheng@627 1151
dongsheng@627 1152 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1153 #: ../en/appB-mq-ref.xml:521
dongsheng@627 1154 msgid ""
dongsheng@627 1155 "The <filename role=\"special\">series</filename> file contains a list of the "
dongsheng@627 1156 "names of all patches that MQ can apply. It is represented as a list of "
dongsheng@627 1157 "names, with one name saved per line. Leading and trailing white space in "
dongsheng@627 1158 "each line are ignored."
dongsheng@627 1159 msgstr ""
dongsheng@627 1160
dongsheng@627 1161 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1162 #: ../en/appB-mq-ref.xml:527
dongsheng@627 1163 msgid ""
dongsheng@627 1164 "Lines may contain comments. A comment begins with the <quote><literal>#</"
dongsheng@627 1165 "literal></quote> character, and extends to the end of the line. Empty lines, "
dongsheng@627 1166 "and lines that contain only comments, are ignored."
dongsheng@627 1167 msgstr ""
dongsheng@627 1168
dongsheng@627 1169 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1170 #: ../en/appB-mq-ref.xml:532
dongsheng@627 1171 msgid ""
dongsheng@627 1172 "You will often need to edit the <filename role=\"special\">series</filename> "
dongsheng@627 1173 "file by hand, hence the support for comments and empty lines noted above. "
dongsheng@627 1174 "For example, you can comment out a patch temporarily, and <command role=\"hg-"
dongsheng@627 1175 "ext-mq\">qpush</command> will skip over that patch when applying patches. "
dongsheng@627 1176 "You can also change the order in which patches are applied by reordering "
dongsheng@627 1177 "their entries in the <filename role=\"special\">series</filename> file."
dongsheng@627 1178 msgstr ""
dongsheng@627 1179
dongsheng@627 1180 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1181 #: ../en/appB-mq-ref.xml:541
dongsheng@627 1182 msgid ""
dongsheng@627 1183 "Placing the <filename role=\"special\">series</filename> file under revision "
dongsheng@627 1184 "control is also supported; it is a good idea to place all of the patches that "
dongsheng@627 1185 "it refers to under revision control, as well. If you create a patch "
dongsheng@627 1186 "directory using the <option role=\"hg-ext-mq-cmd-qinit-opt\">-c</option> "
dongsheng@627 1187 "option to <command role=\"hg-ext-mq\">qinit</command>, this will be done for "
dongsheng@627 1188 "you automatically."
dongsheng@627 1189 msgstr ""
dongsheng@627 1190
dongsheng@627 1191 #. type: Content of: <book><appendix><sect1><sect2><title>
dongsheng@650 1192 #: ../en/appB-mq-ref.xml:551
dongsheng@627 1193 msgid "The <filename role=\"special\">status</filename> file"
dongsheng@627 1194 msgstr "<filename role=\"special\">状态</filename>文件"
dongsheng@627 1195
dongsheng@627 1196 #. type: Content of: <book><appendix><sect1><sect2><para>
dongsheng@650 1197 #: ../en/appB-mq-ref.xml:554
dongsheng@627 1198 msgid ""
dongsheng@627 1199 "The <filename role=\"special\">status</filename> file contains the names and "
dongsheng@627 1200 "changeset hashes of all patches that MQ currently has applied. Unlike the "
dongsheng@627 1201 "<filename role=\"special\">series</filename> file, this file is not intended "
dongsheng@627 1202 "for editing. You should not place this file under revision control, or "
dongsheng@627 1203 "modify it in any way. It is used by MQ strictly for internal book-keeping."
dongsheng@627 1204 msgstr ""
dongsheng@627 1205
dongsheng@627 1206 #. type: Content of: <book><appendix><title>
dongsheng@627 1207 #: ../en/appC-srcinstall.xml:5
dongsheng@627 1208 msgid "Installing Mercurial from source"
dongsheng@627 1209 msgstr "从源代码安装 Mercurial"
dongsheng@627 1210
dongsheng@627 1211 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1212 #: ../en/appC-srcinstall.xml:8
dongsheng@627 1213 msgid "On a Unix-like system"
dongsheng@627 1214 msgstr "类 Unix 系统"
dongsheng@627 1215
dongsheng@627 1216 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1217 #: ../en/appC-srcinstall.xml:10
dongsheng@627 1218 msgid ""
dongsheng@627 1219 "If you are using a Unix-like system that has a sufficiently recent version of "
dongsheng@627 1220 "Python (2.3 or newer) available, it is easy to install Mercurial from source."
dongsheng@627 1221 msgstr ""
dongsheng@627 1222
dongsheng@627 1223 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1224 #: ../en/appC-srcinstall.xml:14
dongsheng@627 1225 msgid ""
dongsheng@627 1226 "Download a recent source tarball from <ulink url=\"http://www.selenic.com/"
dongsheng@627 1227 "mercurial/download\">http://www.selenic.com/mercurial/download</ulink>."
dongsheng@627 1228 msgstr ""
dongsheng@627 1229
dongsheng@627 1230 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1231 #: ../en/appC-srcinstall.xml:17
dongsheng@627 1232 msgid "Unpack the tarball:"
dongsheng@627 1233 msgstr ""
dongsheng@627 1234
dongsheng@627 1235 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1236 #: ../en/appC-srcinstall.xml:20
dongsheng@627 1237 msgid ""
dongsheng@627 1238 "Go into the source directory and run the installer script. This will build "
dongsheng@627 1239 "Mercurial and install it in your home directory."
dongsheng@627 1240 msgstr ""
dongsheng@627 1241
dongsheng@627 1242 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1243 #: ../en/appC-srcinstall.xml:27
dongsheng@627 1244 msgid ""
dongsheng@627 1245 "Once the install finishes, Mercurial will be in the <literal>bin</literal> "
dongsheng@627 1246 "subdirectory of your home directory. Don't forget to make sure that this "
dongsheng@627 1247 "directory is present in your shell's search path."
dongsheng@627 1248 msgstr ""
dongsheng@627 1249
dongsheng@627 1250 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1251 #: ../en/appC-srcinstall.xml:32
dongsheng@627 1252 msgid ""
dongsheng@627 1253 "You will probably need to set the <envar>PYTHONPATH</envar> environment "
dongsheng@627 1254 "variable so that the Mercurial executable can find the rest of the Mercurial "
dongsheng@627 1255 "packages. For example, on my laptop, I have set it to <literal>/home/bos/lib/"
dongsheng@627 1256 "python</literal>. The exact path that you will need to use depends on how "
dongsheng@627 1257 "Python was built for your system, but should be easy to figure out. If "
dongsheng@627 1258 "you're uncertain, look through the output of the installer script above, and "
dongsheng@627 1259 "see where the contents of the <literal>mercurial</literal> directory were "
dongsheng@627 1260 "installed to."
dongsheng@627 1261 msgstr ""
dongsheng@627 1262
dongsheng@627 1263 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1264 #: ../en/appC-srcinstall.xml:44
dongsheng@627 1265 msgid "On Windows"
dongsheng@627 1266 msgstr "Windows 系统"
dongsheng@627 1267
dongsheng@627 1268 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1269 #: ../en/appC-srcinstall.xml:46
dongsheng@627 1270 msgid ""
dongsheng@627 1271 "Building and installing Mercurial on Windows requires a variety of tools, a "
dongsheng@627 1272 "fair amount of technical knowledge, and considerable patience. I very much "
dongsheng@627 1273 "<emphasis>do not recommend</emphasis> this route if you are a <quote>casual "
dongsheng@627 1274 "user</quote>. Unless you intend to hack on Mercurial, I strongly suggest "
dongsheng@627 1275 "that you use a binary package instead."
dongsheng@627 1276 msgstr ""
dongsheng@627 1277
dongsheng@627 1278 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1279 #: ../en/appC-srcinstall.xml:53
dongsheng@627 1280 msgid ""
dongsheng@627 1281 "If you are intent on building Mercurial from source on Windows, follow the "
dongsheng@627 1282 "<quote>hard way</quote> directions on the Mercurial wiki at <ulink url="
dongsheng@627 1283 "\"http://www.selenic.com/mercurial/wiki/index.cgi/WindowsInstall\">http://www."
dongsheng@627 1284 "selenic.com/mercurial/wiki/index.cgi/WindowsInstall</ulink>, and expect the "
dongsheng@627 1285 "process to involve a lot of fiddly work."
dongsheng@627 1286 msgstr ""
dongsheng@627 1287
dongsheng@627 1288 #. type: Content of: <book><appendix><title>
dongsheng@627 1289 #: ../en/appD-license.xml:5
dongsheng@627 1290 msgid "Open Publication License"
dongsheng@627 1291 msgstr ""
dongsheng@627 1292
dongsheng@627 1293 #. type: Content of: <book><appendix><para>
dongsheng@627 1294 #: ../en/appD-license.xml:7
dongsheng@627 1295 msgid "Version 1.0, 8 June 1999"
dongsheng@627 1296 msgstr ""
dongsheng@627 1297
dongsheng@627 1298 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1299 #: ../en/appD-license.xml:10
dongsheng@627 1300 msgid "Requirements on both unmodified and modified versions"
dongsheng@627 1301 msgstr ""
dongsheng@627 1302
dongsheng@627 1303 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1304 #: ../en/appD-license.xml:13
dongsheng@627 1305 msgid ""
dongsheng@627 1306 "The Open Publication works may be reproduced and distributed in whole or in "
dongsheng@627 1307 "part, in any medium physical or electronic, provided that the terms of this "
dongsheng@627 1308 "license are adhered to, and that this license or an incorporation of it by "
dongsheng@627 1309 "reference (with any options elected by the author(s) and/or publisher) is "
dongsheng@627 1310 "displayed in the reproduction."
dongsheng@627 1311 msgstr ""
dongsheng@627 1312
dongsheng@627 1313 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1314 #: ../en/appD-license.xml:20
dongsheng@627 1315 msgid "Proper form for an incorporation by reference is as follows:"
dongsheng@627 1316 msgstr ""
dongsheng@627 1317
dongsheng@627 1318 #. type: Content of: <book><appendix><sect1><blockquote><para>
dongsheng@627 1319 #: ../en/appD-license.xml:24
dongsheng@627 1320 msgid ""
dongsheng@627 1321 "Copyright (c) <emphasis>year</emphasis> by <emphasis>author's name or "
dongsheng@627 1322 "designee</emphasis>. This material may be distributed only subject to the "
dongsheng@627 1323 "terms and conditions set forth in the Open Publication License, v<emphasis>x."
dongsheng@627 1324 "y</emphasis> or later (the latest version is presently available at <ulink "
dongsheng@627 1325 "url=\"http://www.opencontent.org/openpub/\">http://www.opencontent.org/"
dongsheng@627 1326 "openpub/</ulink>)."
dongsheng@627 1327 msgstr ""
dongsheng@627 1328
dongsheng@627 1329 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1330 #: ../en/appD-license.xml:33
dongsheng@627 1331 msgid ""
dongsheng@627 1332 "The reference must be immediately followed with any options elected by the "
songdongsheng@658 1333 "author(s) and/or publisher of the document (see <xref linkend=\"sec:opl:"
songdongsheng@658 1334 "options\"/>)."
dongsheng@627 1335 msgstr ""
dongsheng@627 1336
dongsheng@627 1337 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1338 #: ../en/appD-license.xml:37
dongsheng@627 1339 msgid ""
dongsheng@627 1340 "Commercial redistribution of Open Publication-licensed material is permitted."
dongsheng@627 1341 msgstr ""
dongsheng@627 1342
dongsheng@627 1343 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1344 #: ../en/appD-license.xml:40
dongsheng@627 1345 msgid ""
dongsheng@627 1346 "Any publication in standard (paper) book form shall require the citation of "
dongsheng@627 1347 "the original publisher and author. The publisher and author's names shall "
dongsheng@627 1348 "appear on all outer surfaces of the book. On all outer surfaces of the book "
dongsheng@627 1349 "the original publisher's name shall be as large as the title of the work and "
dongsheng@627 1350 "cited as possessive with respect to the title."
dongsheng@627 1351 msgstr ""
dongsheng@627 1352
dongsheng@627 1353 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1354 #: ../en/appD-license.xml:49
dongsheng@627 1355 msgid "Copyright"
dongsheng@627 1356 msgstr ""
dongsheng@627 1357
dongsheng@627 1358 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1359 #: ../en/appD-license.xml:51
dongsheng@627 1360 msgid ""
dongsheng@627 1361 "The copyright to each Open Publication is owned by its author(s) or designee."
dongsheng@627 1362 msgstr ""
dongsheng@627 1363
dongsheng@627 1364 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1365 #: ../en/appD-license.xml:56
dongsheng@627 1366 msgid "Scope of license"
dongsheng@627 1367 msgstr ""
dongsheng@627 1368
dongsheng@627 1369 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1370 #: ../en/appD-license.xml:58
dongsheng@627 1371 msgid ""
dongsheng@627 1372 "The following license terms apply to all Open Publication works, unless "
dongsheng@627 1373 "otherwise explicitly stated in the document."
dongsheng@627 1374 msgstr ""
dongsheng@627 1375
dongsheng@627 1376 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1377 #: ../en/appD-license.xml:62
dongsheng@627 1378 msgid ""
dongsheng@627 1379 "Mere aggregation of Open Publication works or a portion of an Open "
dongsheng@627 1380 "Publication work with other works or programs on the same media shall not "
dongsheng@627 1381 "cause this license to apply to those other works. The aggregate work shall "
dongsheng@627 1382 "contain a notice specifying the inclusion of the Open Publication material "
dongsheng@627 1383 "and appropriate copyright notice."
dongsheng@627 1384 msgstr ""
dongsheng@627 1385
dongsheng@627 1386 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1387 #: ../en/appD-license.xml:69
dongsheng@627 1388 msgid ""
dongsheng@627 1389 "<emphasis role=\"bold\">Severability</emphasis>. If any part of this license "
dongsheng@627 1390 "is found to be unenforceable in any jurisdiction, the remaining portions of "
dongsheng@627 1391 "the license remain in force."
dongsheng@627 1392 msgstr ""
dongsheng@627 1393
dongsheng@627 1394 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1395 #: ../en/appD-license.xml:74
dongsheng@627 1396 msgid ""
dongsheng@627 1397 "<emphasis role=\"bold\">No warranty</emphasis>. Open Publication works are "
dongsheng@627 1398 "licensed and provided <quote>as is</quote> without warranty of any kind, "
dongsheng@627 1399 "express or implied, including, but not limited to, the implied warranties of "
dongsheng@627 1400 "merchantability and fitness for a particular purpose or a warranty of non-"
dongsheng@627 1401 "infringement."
dongsheng@627 1402 msgstr ""
dongsheng@627 1403
dongsheng@627 1404 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1405 #: ../en/appD-license.xml:83
dongsheng@627 1406 msgid "Requirements on modified works"
dongsheng@627 1407 msgstr ""
dongsheng@627 1408
dongsheng@627 1409 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1410 #: ../en/appD-license.xml:85
dongsheng@627 1411 msgid ""
dongsheng@627 1412 "All modified versions of documents covered by this license, including "
dongsheng@627 1413 "translations, anthologies, compilations and partial documents, must meet the "
dongsheng@627 1414 "following requirements:"
dongsheng@627 1415 msgstr ""
dongsheng@627 1416
dongsheng@627 1417 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1418 #: ../en/appD-license.xml:90
dongsheng@627 1419 msgid "The modified version must be labeled as such."
dongsheng@627 1420 msgstr ""
dongsheng@627 1421
dongsheng@627 1422 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1423 #: ../en/appD-license.xml:93
dongsheng@627 1424 msgid ""
dongsheng@627 1425 "The person making the modifications must be identified and the modifications "
dongsheng@627 1426 "dated."
dongsheng@627 1427 msgstr ""
dongsheng@627 1428
dongsheng@627 1429 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1430 #: ../en/appD-license.xml:96
dongsheng@627 1431 msgid ""
dongsheng@627 1432 "Acknowledgement of the original author and publisher if applicable must be "
dongsheng@627 1433 "retained according to normal academic citation practices."
dongsheng@627 1434 msgstr ""
dongsheng@627 1435
dongsheng@627 1436 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1437 #: ../en/appD-license.xml:100
dongsheng@627 1438 msgid "The location of the original unmodified document must be identified."
dongsheng@627 1439 msgstr ""
dongsheng@627 1440
dongsheng@627 1441 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1442 #: ../en/appD-license.xml:103
dongsheng@627 1443 msgid ""
dongsheng@627 1444 "The original author's (or authors') name(s) may not be used to assert or "
dongsheng@627 1445 "imply endorsement of the resulting document without the original author's (or "
dongsheng@627 1446 "authors') permission."
dongsheng@627 1447 msgstr ""
dongsheng@627 1448
dongsheng@627 1449 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1450 #: ../en/appD-license.xml:111
dongsheng@627 1451 msgid "Good-practice recommendations"
dongsheng@627 1452 msgstr ""
dongsheng@627 1453
dongsheng@627 1454 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1455 #: ../en/appD-license.xml:113
dongsheng@627 1456 msgid ""
dongsheng@627 1457 "In addition to the requirements of this license, it is requested from and "
dongsheng@627 1458 "strongly recommended of redistributors that:"
dongsheng@627 1459 msgstr ""
dongsheng@627 1460
dongsheng@627 1461 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1462 #: ../en/appD-license.xml:118
dongsheng@627 1463 msgid ""
dongsheng@627 1464 "If you are distributing Open Publication works on hardcopy or CD-ROM, you "
dongsheng@627 1465 "provide email notification to the authors of your intent to redistribute at "
dongsheng@627 1466 "least thirty days before your manuscript or media freeze, to give the authors "
dongsheng@627 1467 "time to provide updated documents. This notification should describe "
dongsheng@627 1468 "modifications, if any, made to the document."
dongsheng@627 1469 msgstr ""
dongsheng@627 1470
dongsheng@627 1471 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1472 #: ../en/appD-license.xml:125
dongsheng@627 1473 msgid ""
dongsheng@627 1474 "All substantive modifications (including deletions) be either clearly marked "
dongsheng@627 1475 "up in the document or else described in an attachment to the document."
dongsheng@627 1476 msgstr ""
dongsheng@627 1477
dongsheng@627 1478 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1479 #: ../en/appD-license.xml:129
dongsheng@627 1480 msgid ""
dongsheng@627 1481 "Finally, while it is not mandatory under this license, it is considered good "
dongsheng@627 1482 "form to offer a free copy of any hardcopy and CD-ROM expression of an Open "
dongsheng@627 1483 "Publication-licensed work to its author(s)."
dongsheng@627 1484 msgstr ""
dongsheng@627 1485
dongsheng@627 1486 #. type: Content of: <book><appendix><sect1><title>
dongsheng@627 1487 #: ../en/appD-license.xml:137
dongsheng@627 1488 msgid "License options"
dongsheng@627 1489 msgstr ""
dongsheng@627 1490
dongsheng@627 1491 #. type: Content of: <book><appendix><sect1><para>
dongsheng@627 1492 #: ../en/appD-license.xml:139
dongsheng@627 1493 msgid ""
dongsheng@627 1494 "The author(s) and/or publisher of an Open Publication-licensed document may "
dongsheng@627 1495 "elect certain options by appending language to the reference to or copy of "
dongsheng@627 1496 "the license. These options are considered part of the license instance and "
dongsheng@627 1497 "must be included with the license (or its incorporation by reference) in "
dongsheng@627 1498 "derived works."
dongsheng@627 1499 msgstr ""
dongsheng@627 1500
dongsheng@627 1501 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1502 #: ../en/appD-license.xml:147
dongsheng@627 1503 msgid ""
dongsheng@627 1504 "To prohibit distribution of substantively modified versions without the "
dongsheng@627 1505 "explicit permission of the author(s). <quote>Substantive modification</quote> "
dongsheng@627 1506 "is defined as a change to the semantic content of the document, and excludes "
dongsheng@627 1507 "mere changes in format or typographical corrections."
dongsheng@627 1508 msgstr ""
dongsheng@627 1509
dongsheng@627 1510 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1511 #: ../en/appD-license.xml:154
dongsheng@627 1512 msgid ""
dongsheng@627 1513 "To accomplish this, add the phrase <quote>Distribution of substantively "
dongsheng@627 1514 "modified versions of this document is prohibited without the explicit "
dongsheng@627 1515 "permission of the copyright holder.</quote> to the license reference or copy."
dongsheng@627 1516 msgstr ""
dongsheng@627 1517
dongsheng@627 1518 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1519 #: ../en/appD-license.xml:160
dongsheng@627 1520 msgid ""
dongsheng@627 1521 "To prohibit any publication of this work or derivative works in whole or in "
dongsheng@627 1522 "part in standard (paper) book form for commercial purposes is prohibited "
dongsheng@627 1523 "unless prior permission is obtained from the copyright holder."
dongsheng@627 1524 msgstr ""
dongsheng@627 1525
dongsheng@627 1526 #. type: Content of: <book><appendix><sect1><orderedlist><listitem><para>
dongsheng@627 1527 #: ../en/appD-license.xml:165
dongsheng@627 1528 msgid ""
dongsheng@627 1529 "To accomplish this, add the phrase <quote>Distribution of the work or "
dongsheng@627 1530 "derivative of the work in any standard (paper) book form is prohibited unless "
dongsheng@627 1531 "prior permission is obtained from the copyright holder.</quote> to the "
dongsheng@627 1532 "license reference or copy."
dongsheng@627 1533 msgstr ""
dongsheng@627 1534
dongsheng@653 1535 #. type: Content of: <book><preface><title>
dongsheng@653 1536 #: ../en/ch00-preface.xml:5
dongsheng@653 1537 msgid "Preface"
dongsheng@653 1538 msgstr "序言"
dongsheng@653 1539
dongsheng@653 1540 #. type: Content of: <book><preface><sect1><title>
dongsheng@653 1541 #: ../en/ch00-preface.xml:8
dongsheng@653 1542 msgid "Why revision control? Why Mercurial?"
dongsheng@653 1543 msgstr "为什么使用版本控制? 为什么使用 Mercurial?"
dongsheng@653 1544
dongsheng@653 1545 #. type: Content of: <book><preface><sect1><para>
dongsheng@653 1546 #: ../en/ch00-preface.xml:10
dongsheng@653 1547 msgid ""
dongsheng@653 1548 "Revision control is the process of managing multiple versions of a piece of "
dongsheng@653 1549 "information. In its simplest form, this is something that many people do by "
dongsheng@653 1550 "hand: every time you modify a file, save it under a new name that contains a "
dongsheng@653 1551 "number, each one higher than the number of the preceding version."
dongsheng@653 1552 msgstr ""
dongsheng@653 1553
dongsheng@653 1554 #. type: Content of: <book><preface><sect1><para>
dongsheng@653 1555 #: ../en/ch00-preface.xml:16
dongsheng@653 1556 msgid ""
dongsheng@653 1557 "Manually managing multiple versions of even a single file is an error-prone "
dongsheng@653 1558 "task, though, so software tools to help automate this process have long been "
dongsheng@653 1559 "available. The earliest automated revision control tools were intended to "
dongsheng@653 1560 "help a single user to manage revisions of a single file. Over the past few "
dongsheng@653 1561 "decades, the scope of revision control tools has expanded greatly; they now "
dongsheng@653 1562 "manage multiple files, and help multiple people to work together. The best "
dongsheng@653 1563 "modern revision control tools have no problem coping with thousands of people "
dongsheng@653 1564 "working together on projects that consist of hundreds of thousands of files."
dongsheng@653 1565 msgstr ""
dongsheng@653 1566
dongsheng@653 1567 #. type: Content of: <book><preface><sect1><para>
dongsheng@653 1568 #: ../en/ch00-preface.xml:27
dongsheng@653 1569 msgid ""
dongsheng@653 1570 "The arrival of distributed revision control is relatively recent, and so far "
dongsheng@653 1571 "this new field has grown due to people's willingness to explore ill-charted "
dongsheng@653 1572 "territory."
dongsheng@653 1573 msgstr ""
dongsheng@653 1574
dongsheng@653 1575 #. type: Content of: <book><preface><sect1><para>
dongsheng@653 1576 #: ../en/ch00-preface.xml:31
dongsheng@653 1577 msgid ""
dongsheng@653 1578 "I am writing a book about distributed revision control because I believe that "
dongsheng@653 1579 "it is an important subject that deserves a field guide. I chose to write "
dongsheng@653 1580 "about Mercurial because it is the easiest tool to learn the terrain with, and "
dongsheng@653 1581 "yet it scales to the demands of real, challenging environments where many "
dongsheng@653 1582 "other revision control tools buckle."
dongsheng@653 1583 msgstr ""
dongsheng@653 1584
dongsheng@653 1585 #. type: Content of: <book><preface><sect1><sect2><title>
dongsheng@653 1586 #: ../en/ch00-preface.xml:39
dongsheng@653 1587 msgid "Why use revision control?"
dongsheng@653 1588 msgstr "为什么使用版本控制?"
dongsheng@653 1589
dongsheng@653 1590 #. type: Content of: <book><preface><sect1><sect2><para>
dongsheng@653 1591 #: ../en/ch00-preface.xml:41
dongsheng@653 1592 msgid ""
dongsheng@653 1593 "There are a number of reasons why you or your team might want to use an "
dongsheng@653 1594 "automated revision control tool for a project."
dongsheng@653 1595 msgstr ""
dongsheng@653 1596
dongsheng@653 1597 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
dongsheng@653 1598 #: ../en/ch00-preface.xml:46
dongsheng@653 1599 msgid ""
dongsheng@653 1600 "It will track the history and evolution of your project, so you don't have "
dongsheng@653 1601 "to. For every change, you'll have a log of <emphasis>who</emphasis> made it; "
dongsheng@653 1602 "<emphasis>why</emphasis> they made it; <emphasis>when</emphasis> they made "
dongsheng@653 1603 "it; and <emphasis>what</emphasis> the change was."
dongsheng@653 1604 msgstr ""
dongsheng@653 1605
dongsheng@653 1606 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
dongsheng@653 1607 #: ../en/ch00-preface.xml:53
dongsheng@653 1608 msgid ""
dongsheng@653 1609 "When you're working with other people, revision control software makes it "
dongsheng@653 1610 "easier for you to collaborate. For example, when people more or less "
dongsheng@653 1611 "simultaneously make potentially incompatible changes, the software will help "
dongsheng@653 1612 "you to identify and resolve those conflicts."
dongsheng@653 1613 msgstr ""
dongsheng@653 1614
dongsheng@653 1615 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
dongsheng@653 1616 #: ../en/ch00-preface.xml:59
dongsheng@653 1617 msgid ""
dongsheng@653 1618 "It can help you to recover from mistakes. If you make a change that later "
dongsheng@653 1619 "turns out to be in error, you can revert to an earlier version of one or more "
dongsheng@653 1620 "files. In fact, a <emphasis>really</emphasis> good revision control tool "
dongsheng@653 1621 "will even help you to efficiently figure out exactly when a problem was "
songdongsheng@658 1622 "introduced (see <xref linkend=\"sec:undo:bisect\"/> for details)."
dongsheng@653 1623 msgstr ""
dongsheng@653 1624
dongsheng@653 1625 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
dongsheng@653 1626 #: ../en/ch00-preface.xml:66
dongsheng@653 1627 msgid ""
dongsheng@653 1628 "It will help you to work simultaneously on, and manage the drift between, "
dongsheng@653 1629 "multiple versions of your project."
dongsheng@653 1630 msgstr ""
dongsheng@653 1631
dongsheng@653 1632 #. type: Content of: <book><preface><sect1><sect2><para>
dongsheng@653 1633 #: ../en/ch00-preface.xml:71
dongsheng@653 1634 msgid ""
songdongsheng@667 1635 "Most of these reasons are equally valid—at least in theory&emdash;whether "
songdongsheng@667 1636 "you're working on a project by yourself, or with a hundred other people."
dongsheng@653 1637 msgstr ""
dongsheng@653 1638
dongsheng@653 1639 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1640 #: ../en/ch00-preface.xml:76
dongsheng@653 1641 msgid ""
dongsheng@653 1642 "A key question about the practicality of revision control at these two "
dongsheng@653 1643 "different scales (<quote>lone hacker</quote> and <quote>huge team</quote>) is "
dongsheng@653 1644 "how its <emphasis>benefits</emphasis> compare to its <emphasis>costs</"
dongsheng@653 1645 "emphasis>. A revision control tool that's difficult to understand or use is "
dongsheng@653 1646 "going to impose a high cost."
dongsheng@653 1647 msgstr ""
dongsheng@653 1648
dongsheng@653 1649 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1650 #: ../en/ch00-preface.xml:84
dongsheng@653 1651 msgid ""
dongsheng@653 1652 "A five-hundred-person project is likely to collapse under its own weight "
dongsheng@653 1653 "almost immediately without a revision control tool and process. In this case, "
dongsheng@653 1654 "the cost of using revision control might hardly seem worth considering, since "
dongsheng@653 1655 "<emphasis>without</emphasis> it, failure is almost guaranteed."
dongsheng@653 1656 msgstr ""
dongsheng@653 1657
dongsheng@653 1658 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1659 #: ../en/ch00-preface.xml:91
dongsheng@653 1660 msgid ""
dongsheng@653 1661 "On the other hand, a one-person <quote>quick hack</quote> might seem like a "
dongsheng@653 1662 "poor place to use a revision control tool, because surely the cost of using "
dongsheng@653 1663 "one must be close to the overall cost of the project. Right?"
dongsheng@653 1664 msgstr ""
dongsheng@653 1665
dongsheng@653 1666 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1667 #: ../en/ch00-preface.xml:96
dongsheng@653 1668 msgid ""
dongsheng@653 1669 "Mercurial uniquely supports <emphasis>both</emphasis> of these scales of "
dongsheng@653 1670 "development. You can learn the basics in just a few minutes, and due to its "
dongsheng@653 1671 "low overhead, you can apply revision control to the smallest of projects with "
dongsheng@653 1672 "ease. Its simplicity means you won't have a lot of abstruse concepts or "
dongsheng@653 1673 "command sequences competing for mental space with whatever you're "
dongsheng@653 1674 "<emphasis>really</emphasis> trying to do. At the same time, Mercurial's high "
dongsheng@653 1675 "performance and peer-to-peer nature let you scale painlessly to handle large "
dongsheng@653 1676 "projects."
dongsheng@653 1677 msgstr ""
dongsheng@653 1678
dongsheng@653 1679 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1680 #: ../en/ch00-preface.xml:106
dongsheng@653 1681 msgid ""
dongsheng@653 1682 "No revision control tool can rescue a poorly run project, but a good choice "
dongsheng@653 1683 "of tools can make a huge difference to the fluidity with which you can work "
dongsheng@653 1684 "on a project."
dongsheng@653 1685 msgstr ""
dongsheng@653 1686
dongsheng@653 1687 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 1688 #: ../en/ch00-preface.xml:113
dongsheng@653 1689 msgid "The many names of revision control"
dongsheng@653 1690 msgstr "版本控制的别名"
dongsheng@653 1691
dongsheng@653 1692 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1693 #: ../en/ch00-preface.xml:115
dongsheng@653 1694 msgid ""
dongsheng@653 1695 "Revision control is a diverse field, so much so that it is referred to by "
dongsheng@653 1696 "many names and acronyms. Here are a few of the more common variations you'll "
dongsheng@653 1697 "encounter:"
dongsheng@653 1698 msgstr ""
dongsheng@653 1699
dongsheng@653 1700 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1701 #: ../en/ch00-preface.xml:119
dongsheng@653 1702 msgid "Revision control (RCS)"
dongsheng@653 1703 msgstr "版本控制(RCS)"
dongsheng@653 1704
dongsheng@653 1705 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1706 #: ../en/ch00-preface.xml:120
dongsheng@653 1707 msgid "Software configuration management (SCM), or configuration management"
dongsheng@653 1708 msgstr "软件配置管理(SCM),或配置管理"
dongsheng@653 1709
dongsheng@653 1710 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1711 #: ../en/ch00-preface.xml:122
dongsheng@653 1712 msgid "Source code management"
dongsheng@653 1713 msgstr "源代码管理"
dongsheng@653 1714
dongsheng@653 1715 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1716 #: ../en/ch00-preface.xml:123
dongsheng@653 1717 msgid "Source code control, or source control"
dongsheng@653 1718 msgstr "源代码控制,或源控制"
dongsheng@653 1719
dongsheng@653 1720 #. type: Content of: <book><preface><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 1721 #: ../en/ch00-preface.xml:125
dongsheng@653 1722 msgid "Version control (VCS)"
dongsheng@653 1723 msgstr "版本控制(VCS)"
dongsheng@653 1724
dongsheng@653 1725 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1726 #: ../en/ch00-preface.xml:127
dongsheng@653 1727 msgid ""
dongsheng@653 1728 "Some people claim that these terms actually have different meanings, but in "
dongsheng@653 1729 "practice they overlap so much that there's no agreed or even useful way to "
dongsheng@653 1730 "tease them apart."
dongsheng@653 1731 msgstr ""
dongsheng@653 1732
dongsheng@653 1733 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1734 #: ../en/ch00-preface.xml:135
dongsheng@653 1735 msgid "This book is a work in progress"
dongsheng@653 1736 msgstr "本书正在编写中"
dongsheng@653 1737
dongsheng@653 1738 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1739 #: ../en/ch00-preface.xml:137
dongsheng@653 1740 msgid ""
dongsheng@653 1741 "I am releasing this book while I am still writing it, in the hope that it "
dongsheng@653 1742 "will prove useful to others. I am writing under an open license in the hope "
dongsheng@653 1743 "that you, my readers, will contribute feedback and perhaps content of your "
dongsheng@653 1744 "own."
dongsheng@653 1745 msgstr ""
dongsheng@653 1746
dongsheng@653 1747 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1748 #: ../en/ch00-preface.xml:144
dongsheng@653 1749 msgid "About the examples in this book"
dongsheng@653 1750 msgstr "本书的例子"
dongsheng@653 1751
dongsheng@653 1752 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1753 #: ../en/ch00-preface.xml:146
dongsheng@653 1754 msgid ""
dongsheng@653 1755 "This book takes an unusual approach to code samples. Every example is "
songdongsheng@667 1756 "<quote>live</quote>—each one is actually the result of a shell script that "
dongsheng@653 1757 "executes the Mercurial commands you see. Every time an image of the book is "
dongsheng@653 1758 "built from its sources, all the example scripts are automatically run, and "
dongsheng@653 1759 "their current results compared against their expected results."
dongsheng@653 1760 msgstr ""
dongsheng@653 1761
dongsheng@653 1762 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1763 #: ../en/ch00-preface.xml:153
dongsheng@653 1764 msgid ""
dongsheng@653 1765 "The advantage of this approach is that the examples are always accurate; they "
dongsheng@653 1766 "describe <emphasis>exactly</emphasis> the behaviour of the version of "
dongsheng@653 1767 "Mercurial that's mentioned at the front of the book. If I update the version "
dongsheng@653 1768 "of Mercurial that I'm documenting, and the output of some command changes, "
dongsheng@653 1769 "the build fails."
dongsheng@653 1770 msgstr ""
dongsheng@653 1771
dongsheng@653 1772 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1773 #: ../en/ch00-preface.xml:160
dongsheng@653 1774 msgid ""
dongsheng@653 1775 "There is a small disadvantage to this approach, which is that the dates and "
dongsheng@653 1776 "times you'll see in examples tend to be <quote>squashed</quote> together in a "
dongsheng@653 1777 "way that they wouldn't be if the same commands were being typed by a human. "
dongsheng@653 1778 "Where a human can issue no more than one command every few seconds, with any "
dongsheng@653 1779 "resulting timestamps correspondingly spread out, my automated example scripts "
dongsheng@653 1780 "run many commands in one second."
dongsheng@653 1781 msgstr ""
dongsheng@653 1782
dongsheng@653 1783 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1784 #: ../en/ch00-preface.xml:168
dongsheng@653 1785 msgid ""
dongsheng@653 1786 "As an instance of this, several consecutive commits in an example can show up "
dongsheng@653 1787 "as having occurred during the same second. You can see this occur in the "
songdongsheng@658 1788 "<literal role=\"hg-ext\">bisect</literal> example in <xref linkend=\"sec:undo:"
songdongsheng@658 1789 "bisect\"/>, for instance."
dongsheng@653 1790 msgstr ""
dongsheng@653 1791
dongsheng@653 1792 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1793 #: ../en/ch00-preface.xml:174
dongsheng@653 1794 msgid ""
dongsheng@653 1795 "So when you're reading examples, don't place too much weight on the dates or "
dongsheng@653 1796 "times you see in the output of commands. But <emphasis>do</emphasis> be "
dongsheng@653 1797 "confident that the behaviour you're seeing is consistent and reproducible."
dongsheng@653 1798 msgstr ""
dongsheng@653 1799
dongsheng@653 1800 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1801 #: ../en/ch00-preface.xml:182
dongsheng@653 1802 msgid "Trends in the field"
dongsheng@653 1803 msgstr "版本控制的发展趋势"
dongsheng@653 1804
dongsheng@653 1805 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1806 #: ../en/ch00-preface.xml:184
dongsheng@653 1807 msgid ""
dongsheng@653 1808 "There has been an unmistakable trend in the development and use of revision "
dongsheng@653 1809 "control tools over the past four decades, as people have become familiar with "
dongsheng@653 1810 "the capabilities of their tools and constrained by their limitations."
dongsheng@653 1811 msgstr ""
dongsheng@653 1812
dongsheng@653 1813 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1814 #: ../en/ch00-preface.xml:189
dongsheng@653 1815 msgid ""
dongsheng@653 1816 "The first generation began by managing single files on individual computers. "
dongsheng@653 1817 "Although these tools represented a huge advance over ad-hoc manual revision "
dongsheng@653 1818 "control, their locking model and reliance on a single computer limited them "
dongsheng@653 1819 "to small, tightly-knit teams."
dongsheng@653 1820 msgstr ""
dongsheng@653 1821
dongsheng@653 1822 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1823 #: ../en/ch00-preface.xml:195
dongsheng@653 1824 msgid ""
dongsheng@653 1825 "The second generation loosened these constraints by moving to network-"
dongsheng@653 1826 "centered architectures, and managing entire projects at a time. As projects "
dongsheng@653 1827 "grew larger, they ran into new problems. With clients needing to talk to "
dongsheng@653 1828 "servers very frequently, server scaling became an issue for large projects. "
dongsheng@653 1829 "An unreliable network connection could prevent remote users from being able "
dongsheng@653 1830 "to talk to the server at all. As open source projects started making read-"
dongsheng@653 1831 "only access available anonymously to anyone, people without commit privileges "
dongsheng@653 1832 "found that they could not use the tools to interact with a project in a "
dongsheng@653 1833 "natural way, as they could not record their changes."
dongsheng@653 1834 msgstr ""
dongsheng@653 1835
dongsheng@653 1836 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1837 #: ../en/ch00-preface.xml:207
dongsheng@653 1838 msgid ""
dongsheng@653 1839 "The current generation of revision control tools is peer-to-peer in nature. "
dongsheng@653 1840 "All of these systems have dropped the dependency on a single central server, "
dongsheng@653 1841 "and allow people to distribute their revision control data to where it's "
dongsheng@653 1842 "actually needed. Collaboration over the Internet has moved from constrained "
dongsheng@653 1843 "by technology to a matter of choice and consensus. Modern tools can operate "
dongsheng@653 1844 "offline indefinitely and autonomously, with a network connection only needed "
dongsheng@653 1845 "when syncing changes with another repository."
dongsheng@653 1846 msgstr ""
dongsheng@653 1847
dongsheng@653 1848 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 1849 #: ../en/ch00-preface.xml:219
dongsheng@653 1850 msgid "A few of the advantages of distributed revision control"
dongsheng@653 1851 msgstr "分布版本控制的优点"
dongsheng@653 1852
dongsheng@653 1853 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1854 #: ../en/ch00-preface.xml:222
dongsheng@653 1855 msgid ""
dongsheng@653 1856 "Even though distributed revision control tools have for several years been as "
dongsheng@653 1857 "robust and usable as their previous-generation counterparts, people using "
dongsheng@653 1858 "older tools have not yet necessarily woken up to their advantages. There are "
dongsheng@653 1859 "a number of ways in which distributed tools shine relative to centralised "
dongsheng@653 1860 "ones."
dongsheng@653 1861 msgstr ""
dongsheng@653 1862
dongsheng@653 1863 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1864 #: ../en/ch00-preface.xml:229
dongsheng@653 1865 msgid ""
dongsheng@653 1866 "For an individual developer, distributed tools are almost always much faster "
dongsheng@653 1867 "than centralised tools. This is for a simple reason: a centralised tool "
dongsheng@653 1868 "needs to talk over the network for many common operations, because most "
dongsheng@653 1869 "metadata is stored in a single copy on the central server. A distributed "
dongsheng@653 1870 "tool stores all of its metadata locally. All else being equal, talking over "
dongsheng@653 1871 "the network adds overhead to a centralised tool. Don't underestimate the "
dongsheng@653 1872 "value of a snappy, responsive tool: you're going to spend a lot of time "
dongsheng@653 1873 "interacting with your revision control software."
dongsheng@653 1874 msgstr ""
dongsheng@653 1875
dongsheng@653 1876 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1877 #: ../en/ch00-preface.xml:240
dongsheng@653 1878 msgid ""
dongsheng@653 1879 "Distributed tools are indifferent to the vagaries of your server "
dongsheng@653 1880 "infrastructure, again because they replicate metadata to so many locations. "
dongsheng@653 1881 "If you use a centralised system and your server catches fire, you'd better "
dongsheng@653 1882 "hope that your backup media are reliable, and that your last backup was "
dongsheng@653 1883 "recent and actually worked. With a distributed tool, you have many backups "
dongsheng@653 1884 "available on every contributor's computer."
dongsheng@653 1885 msgstr ""
dongsheng@653 1886
dongsheng@653 1887 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 1888 #: ../en/ch00-preface.xml:248
dongsheng@653 1889 msgid ""
dongsheng@653 1890 "The reliability of your network will affect distributed tools far less than "
dongsheng@653 1891 "it will centralised tools. You can't even use a centralised tool without a "
dongsheng@653 1892 "network connection, except for a few highly constrained commands. With a "
dongsheng@653 1893 "distributed tool, if your network connection goes down while you're working, "
dongsheng@653 1894 "you may not even notice. The only thing you won't be able to do is talk to "
dongsheng@653 1895 "repositories on other computers, something that is relatively rare compared "
dongsheng@653 1896 "with local operations. If you have a far-flung team of collaborators, this "
dongsheng@653 1897 "may be significant."
dongsheng@653 1898 msgstr ""
dongsheng@653 1899
dongsheng@653 1900 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 1901 #: ../en/ch00-preface.xml:259
dongsheng@653 1902 msgid "Advantages for open source projects"
dongsheng@653 1903 msgstr "开源项目的优点"
dongsheng@653 1904
dongsheng@653 1905 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 1906 #: ../en/ch00-preface.xml:261
dongsheng@653 1907 msgid ""
dongsheng@653 1908 "If you take a shine to an open source project and decide that you would like "
dongsheng@653 1909 "to start hacking on it, and that project uses a distributed revision control "
dongsheng@653 1910 "tool, you are at once a peer with the people who consider themselves the "
dongsheng@653 1911 "<quote>core</quote> of that project. If they publish their repositories, you "
dongsheng@653 1912 "can immediately copy their project history, start making changes, and record "
dongsheng@653 1913 "your work, using the same tools in the same ways as insiders. By contrast, "
dongsheng@653 1914 "with a centralised tool, you must use the software in a <quote>read only</"
dongsheng@653 1915 "quote> mode unless someone grants you permission to commit changes to their "
dongsheng@653 1916 "central server. Until then, you won't be able to record changes, and your "
dongsheng@653 1917 "local modifications will be at risk of corruption any time you try to update "
dongsheng@653 1918 "your client's view of the repository."
dongsheng@653 1919 msgstr ""
dongsheng@653 1920
dongsheng@653 1921 #. type: Content of: <book><preface><sect1><sect2><sect3><title>
songdongsheng@667 1922 #: ../en/ch00-preface.xml:277
dongsheng@653 1923 msgid "The forking non-problem"
dongsheng@660 1924 msgstr "分叉不是问题"
dongsheng@653 1925
dongsheng@653 1926 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1927 #: ../en/ch00-preface.xml:279
dongsheng@653 1928 msgid ""
dongsheng@653 1929 "It has been suggested that distributed revision control tools pose some sort "
dongsheng@653 1930 "of risk to open source projects because they make it easy to <quote>fork</"
dongsheng@653 1931 "quote> the development of a project. A fork happens when there are "
dongsheng@653 1932 "differences in opinion or attitude between groups of developers that cause "
dongsheng@653 1933 "them to decide that they can't work together any longer. Each side takes a "
dongsheng@653 1934 "more or less complete copy of the project's source code, and goes off in its "
dongsheng@653 1935 "own direction."
dongsheng@653 1936 msgstr ""
dongsheng@653 1937
dongsheng@653 1938 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1939 #: ../en/ch00-preface.xml:289
dongsheng@653 1940 msgid ""
dongsheng@653 1941 "Sometimes the camps in a fork decide to reconcile their differences. With a "
dongsheng@653 1942 "centralised revision control system, the <emphasis>technical</emphasis> "
dongsheng@653 1943 "process of reconciliation is painful, and has to be performed largely by "
dongsheng@653 1944 "hand. You have to decide whose revision history is going to <quote>win</"
dongsheng@653 1945 "quote>, and graft the other team's changes into the tree somehow. This "
dongsheng@653 1946 "usually loses some or all of one side's revision history."
dongsheng@653 1947 msgstr ""
dongsheng@653 1948
dongsheng@653 1949 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1950 #: ../en/ch00-preface.xml:298
dongsheng@653 1951 msgid ""
dongsheng@653 1952 "What distributed tools do with respect to forking is they make forking the "
dongsheng@653 1953 "<emphasis>only</emphasis> way to develop a project. Every single change that "
dongsheng@653 1954 "you make is potentially a fork point. The great strength of this approach is "
dongsheng@653 1955 "that a distributed revision control tool has to be really good at "
dongsheng@653 1956 "<emphasis>merging</emphasis> forks, because forks are absolutely fundamental: "
dongsheng@653 1957 "they happen all the time."
dongsheng@653 1958 msgstr ""
dongsheng@653 1959
dongsheng@653 1960 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1961 #: ../en/ch00-preface.xml:307
dongsheng@653 1962 msgid ""
dongsheng@653 1963 "If every piece of work that everybody does, all the time, is framed in terms "
dongsheng@653 1964 "of forking and merging, then what the open source world refers to as a "
dongsheng@653 1965 "<quote>fork</quote> becomes <emphasis>purely</emphasis> a social issue. If "
dongsheng@653 1966 "anything, distributed tools <emphasis>lower</emphasis> the likelihood of a "
dongsheng@653 1967 "fork:"
dongsheng@653 1968 msgstr ""
dongsheng@653 1969
dongsheng@653 1970 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@667 1971 #: ../en/ch00-preface.xml:314
dongsheng@653 1972 msgid ""
dongsheng@653 1973 "They eliminate the social distinction that centralised tools impose: that "
dongsheng@653 1974 "between insiders (people with commit access) and outsiders (people without)."
dongsheng@653 1975 msgstr ""
dongsheng@653 1976
dongsheng@653 1977 #. type: Content of: <book><preface><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@667 1978 #: ../en/ch00-preface.xml:318
dongsheng@653 1979 msgid ""
dongsheng@653 1980 "They make it easier to reconcile after a social fork, because all that's "
dongsheng@653 1981 "involved from the perspective of the revision control software is just "
dongsheng@653 1982 "another merge."
dongsheng@653 1983 msgstr ""
dongsheng@653 1984
dongsheng@653 1985 #. type: Content of: <book><preface><sect1><sect2><sect3><para>
songdongsheng@667 1986 #: ../en/ch00-preface.xml:323
dongsheng@653 1987 msgid ""
dongsheng@653 1988 "Some people resist distributed tools because they want to retain tight "
dongsheng@653 1989 "control over their projects, and they believe that centralised tools give "
dongsheng@653 1990 "them this control. However, if you're of this belief, and you publish your "
dongsheng@653 1991 "CVS or Subversion repositories publicly, there are plenty of tools available "
dongsheng@653 1992 "that can pull out your entire project's history (albeit slowly) and recreate "
dongsheng@653 1993 "it somewhere that you don't control. So while your control in this case is "
dongsheng@653 1994 "illusory, you are forgoing the ability to fluidly collaborate with whatever "
dongsheng@653 1995 "people feel compelled to mirror and fork your history."
dongsheng@653 1996 msgstr ""
dongsheng@653 1997
dongsheng@653 1998 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 1999 #: ../en/ch00-preface.xml:338
dongsheng@653 2000 msgid "Advantages for commercial projects"
dongsheng@653 2001 msgstr "商业项目的优点"
dongsheng@653 2002
dongsheng@653 2003 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2004 #: ../en/ch00-preface.xml:340
dongsheng@653 2005 msgid ""
dongsheng@653 2006 "Many commercial projects are undertaken by teams that are scattered across "
dongsheng@653 2007 "the globe. Contributors who are far from a central server will see slower "
dongsheng@653 2008 "command execution and perhaps less reliability. Commercial revision control "
dongsheng@653 2009 "systems attempt to ameliorate these problems with remote-site replication add-"
dongsheng@653 2010 "ons that are typically expensive to buy and cantankerous to administer. A "
dongsheng@653 2011 "distributed system doesn't suffer from these problems in the first place. "
dongsheng@653 2012 "Better yet, you can easily set up multiple authoritative servers, say one per "
dongsheng@653 2013 "site, so that there's no redundant communication between repositories over "
dongsheng@653 2014 "expensive long-haul network links."
dongsheng@653 2015 msgstr ""
dongsheng@653 2016
dongsheng@653 2017 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2018 #: ../en/ch00-preface.xml:352
dongsheng@653 2019 msgid ""
dongsheng@653 2020 "Centralised revision control systems tend to have relatively low "
dongsheng@653 2021 "scalability. It's not unusual for an expensive centralised system to fall "
dongsheng@653 2022 "over under the combined load of just a few dozen concurrent users. Once "
dongsheng@653 2023 "again, the typical response tends to be an expensive and clunky replication "
songdongsheng@667 2024 "facility. Since the load on a central server—if you have one at all—is many "
songdongsheng@667 2025 "times lower with a distributed tool (because all of the data is replicated "
songdongsheng@667 2026 "everywhere), a single cheap server can handle the needs of a much larger "
songdongsheng@667 2027 "team, and replication to balance load becomes a simple matter of scripting."
dongsheng@653 2028 msgstr ""
dongsheng@653 2029
dongsheng@653 2030 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2031 #: ../en/ch00-preface.xml:364
dongsheng@653 2032 msgid ""
dongsheng@653 2033 "If you have an employee in the field, troubleshooting a problem at a "
dongsheng@653 2034 "customer's site, they'll benefit from distributed revision control. The tool "
dongsheng@653 2035 "will let them generate custom builds, try different fixes in isolation from "
dongsheng@653 2036 "each other, and search efficiently through history for the sources of bugs "
dongsheng@653 2037 "and regressions in the customer's environment, all without needing to connect "
dongsheng@653 2038 "to your company's network."
dongsheng@653 2039 msgstr ""
dongsheng@653 2040
dongsheng@653 2041 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 2042 #: ../en/ch00-preface.xml:375
dongsheng@653 2043 msgid "Why choose Mercurial?"
dongsheng@653 2044 msgstr "为什么选择 Mercurial?"
dongsheng@653 2045
dongsheng@653 2046 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2047 #: ../en/ch00-preface.xml:377
dongsheng@653 2048 msgid ""
dongsheng@653 2049 "Mercurial has a unique set of properties that make it a particularly good "
dongsheng@653 2050 "choice as a revision control system."
dongsheng@653 2051 msgstr ""
dongsheng@653 2052
dongsheng@653 2053 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 2054 #: ../en/ch00-preface.xml:380
dongsheng@653 2055 msgid "It is easy to learn and use."
dongsheng@653 2056 msgstr ""
dongsheng@653 2057
dongsheng@653 2058 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
dongsheng@653 2059 #: ../en/ch00-preface.xml:381
songdongsheng@667 2060 msgid "It is lightweight."
dongsheng@653 2061 msgstr ""
dongsheng@653 2062
dongsheng@653 2063 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
dongsheng@653 2064 #: ../en/ch00-preface.xml:382
songdongsheng@667 2065 msgid "It scales excellently."
songdongsheng@667 2066 msgstr ""
songdongsheng@667 2067
songdongsheng@667 2068 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 2069 #: ../en/ch00-preface.xml:383
dongsheng@653 2070 msgid "It is easy to customise."
dongsheng@653 2071 msgstr ""
dongsheng@653 2072
dongsheng@653 2073 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2074 #: ../en/ch00-preface.xml:386
dongsheng@653 2075 msgid ""
dongsheng@653 2076 "If you are at all familiar with revision control systems, you should be able "
dongsheng@653 2077 "to get up and running with Mercurial in less than five minutes. Even if not, "
dongsheng@653 2078 "it will take no more than a few minutes longer. Mercurial's command and "
dongsheng@653 2079 "feature sets are generally uniform and consistent, so you can keep track of a "
dongsheng@653 2080 "few general rules instead of a host of exceptions."
dongsheng@653 2081 msgstr ""
dongsheng@653 2082
dongsheng@653 2083 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2084 #: ../en/ch00-preface.xml:393
dongsheng@653 2085 msgid ""
dongsheng@653 2086 "On a small project, you can start working with Mercurial in moments. Creating "
dongsheng@653 2087 "new changes and branches; transferring changes around (whether locally or "
dongsheng@653 2088 "over a network); and history and status operations are all fast. Mercurial "
dongsheng@653 2089 "attempts to stay nimble and largely out of your way by combining low "
dongsheng@653 2090 "cognitive overhead with blazingly fast operations."
dongsheng@653 2091 msgstr ""
dongsheng@653 2092
dongsheng@653 2093 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2094 #: ../en/ch00-preface.xml:400
dongsheng@653 2095 msgid ""
dongsheng@653 2096 "The usefulness of Mercurial is not limited to small projects: it is used by "
dongsheng@653 2097 "projects with hundreds to thousands of contributors, each containing tens of "
dongsheng@653 2098 "thousands of files and hundreds of megabytes of source code."
dongsheng@653 2099 msgstr ""
dongsheng@653 2100
dongsheng@653 2101 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2102 #: ../en/ch00-preface.xml:405
dongsheng@653 2103 msgid ""
dongsheng@653 2104 "If the core functionality of Mercurial is not enough for you, it's easy to "
dongsheng@653 2105 "build on. Mercurial is well suited to scripting tasks, and its clean "
dongsheng@653 2106 "internals and implementation in Python make it easy to add features in the "
dongsheng@653 2107 "form of extensions. There are a number of popular and useful extensions "
dongsheng@653 2108 "already available, ranging from helping to identify bugs to improving "
dongsheng@653 2109 "performance."
dongsheng@653 2110 msgstr ""
dongsheng@653 2111
dongsheng@653 2112 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 2113 #: ../en/ch00-preface.xml:415
dongsheng@653 2114 msgid "Mercurial compared with other tools"
dongsheng@653 2115 msgstr "Mercurial 与其它工具的比较"
dongsheng@653 2116
dongsheng@653 2117 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2118 #: ../en/ch00-preface.xml:417
dongsheng@653 2119 msgid ""
dongsheng@653 2120 "Before you read on, please understand that this section necessarily reflects "
dongsheng@653 2121 "my own experiences, interests, and (dare I say it) biases. I have used every "
dongsheng@653 2122 "one of the revision control tools listed below, in most cases for several "
dongsheng@653 2123 "years at a time."
dongsheng@653 2124 msgstr ""
dongsheng@653 2125
dongsheng@653 2126 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 2127 #: ../en/ch00-preface.xml:425 ../en/ch00-preface.xml:636
dongsheng@653 2128 msgid "Subversion"
dongsheng@653 2129 msgstr ""
dongsheng@653 2130
dongsheng@653 2131 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2132 #: ../en/ch00-preface.xml:427
dongsheng@653 2133 msgid ""
dongsheng@653 2134 "Subversion is a popular revision control tool, developed to replace CVS. It "
dongsheng@653 2135 "has a centralised client/server architecture."
dongsheng@653 2136 msgstr ""
dongsheng@653 2137
dongsheng@653 2138 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2139 #: ../en/ch00-preface.xml:431
dongsheng@653 2140 msgid ""
dongsheng@653 2141 "Subversion and Mercurial have similarly named commands for performing the "
dongsheng@653 2142 "same operations, so if you're familiar with one, it is easy to learn to use "
dongsheng@653 2143 "the other. Both tools are portable to all popular operating systems."
dongsheng@653 2144 msgstr ""
dongsheng@653 2145
dongsheng@653 2146 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2147 #: ../en/ch00-preface.xml:436
dongsheng@653 2148 msgid ""
dongsheng@653 2149 "Prior to version 1.5, Subversion had no useful support for merges. At the "
dongsheng@653 2150 "time of writing, its merge tracking capability is new, and known to be <ulink "
dongsheng@653 2151 "url=\"http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced."
dongsheng@653 2152 "html#svn.branchmerge.advanced.finalword\">complicated and buggy</ulink>."
dongsheng@653 2153 msgstr ""
dongsheng@653 2154
dongsheng@653 2155 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2156 #: ../en/ch00-preface.xml:442
dongsheng@653 2157 msgid ""
dongsheng@653 2158 "Mercurial has a substantial performance advantage over Subversion on every "
dongsheng@653 2159 "revision control operation I have benchmarked. I have measured its advantage "
dongsheng@653 2160 "as ranging from a factor of two to a factor of six when compared with "
dongsheng@653 2161 "Subversion 1.4.3's <emphasis>ra_local</emphasis> file store, which is the "
dongsheng@653 2162 "fastest access method available. In more realistic deployments involving a "
dongsheng@653 2163 "network-based store, Subversion will be at a substantially larger "
dongsheng@653 2164 "disadvantage. Because many Subversion commands must talk to the server and "
dongsheng@653 2165 "Subversion does not have useful replication facilities, server capacity and "
dongsheng@653 2166 "network bandwidth become bottlenecks for modestly large projects."
dongsheng@653 2167 msgstr ""
dongsheng@653 2168
dongsheng@653 2169 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2170 #: ../en/ch00-preface.xml:455
dongsheng@653 2171 msgid ""
dongsheng@653 2172 "Additionally, Subversion incurs substantial storage overhead to avoid network "
dongsheng@653 2173 "transactions for a few common operations, such as finding modified files "
dongsheng@653 2174 "(<literal>status</literal>) and displaying modifications against the current "
dongsheng@653 2175 "revision (<literal>diff</literal>). As a result, a Subversion working copy "
dongsheng@653 2176 "is often the same size as, or larger than, a Mercurial repository and working "
dongsheng@653 2177 "directory, even though the Mercurial repository contains a complete history "
dongsheng@653 2178 "of the project."
dongsheng@653 2179 msgstr ""
dongsheng@653 2180
dongsheng@653 2181 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2182 #: ../en/ch00-preface.xml:465
dongsheng@653 2183 msgid ""
dongsheng@653 2184 "Subversion is widely supported by third party tools. Mercurial currently "
dongsheng@653 2185 "lags considerably in this area. This gap is closing, however, and indeed "
dongsheng@653 2186 "some of Mercurial's GUI tools now outshine their Subversion equivalents. "
dongsheng@653 2187 "Like Mercurial, Subversion has an excellent user manual."
dongsheng@653 2188 msgstr ""
dongsheng@653 2189
dongsheng@653 2190 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2191 #: ../en/ch00-preface.xml:471
dongsheng@653 2192 msgid ""
dongsheng@653 2193 "Because Subversion doesn't store revision history on the client, it is well "
dongsheng@653 2194 "suited to managing projects that deal with lots of large, opaque binary "
dongsheng@653 2195 "files. If you check in fifty revisions to an incompressible 10MB file, "
dongsheng@653 2196 "Subversion's client-side space usage stays constant The space used by any "
dongsheng@653 2197 "distributed SCM will grow rapidly in proportion to the number of revisions, "
dongsheng@653 2198 "because the differences between each revision are large."
dongsheng@653 2199 msgstr ""
dongsheng@653 2200
dongsheng@653 2201 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2202 #: ../en/ch00-preface.xml:480
dongsheng@653 2203 msgid ""
dongsheng@653 2204 "In addition, it's often difficult or, more usually, impossible to merge "
dongsheng@653 2205 "different versions of a binary file. Subversion's ability to let a user lock "
dongsheng@653 2206 "a file, so that they temporarily have the exclusive right to commit changes "
dongsheng@653 2207 "to it, can be a significant advantage to a project where binary files are "
dongsheng@653 2208 "widely used."
dongsheng@653 2209 msgstr ""
dongsheng@653 2210
dongsheng@653 2211 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2212 #: ../en/ch00-preface.xml:487
dongsheng@653 2213 msgid ""
dongsheng@653 2214 "Mercurial can import revision history from a Subversion repository. It can "
dongsheng@653 2215 "also export revision history to a Subversion repository. This makes it easy "
dongsheng@653 2216 "to <quote>test the waters</quote> and use Mercurial and Subversion in "
dongsheng@653 2217 "parallel before deciding to switch. History conversion is incremental, so "
dongsheng@653 2218 "you can perform an initial conversion, then small additional conversions "
dongsheng@653 2219 "afterwards to bring in new changes."
dongsheng@653 2220 msgstr ""
dongsheng@653 2221
dongsheng@653 2222 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 2223 #: ../en/ch00-preface.xml:499 ../en/ch00-preface.xml:638
dongsheng@653 2224 msgid "Git"
dongsheng@653 2225 msgstr ""
dongsheng@653 2226
dongsheng@653 2227 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2228 #: ../en/ch00-preface.xml:501
dongsheng@653 2229 msgid ""
dongsheng@653 2230 "Git is a distributed revision control tool that was developed for managing "
dongsheng@653 2231 "the Linux kernel source tree. Like Mercurial, its early design was somewhat "
dongsheng@653 2232 "influenced by Monotone."
dongsheng@653 2233 msgstr ""
dongsheng@653 2234
dongsheng@653 2235 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2236 #: ../en/ch00-preface.xml:506
dongsheng@653 2237 msgid ""
dongsheng@653 2238 "Git has a very large command set, with version 1.5.0 providing 139 individual "
dongsheng@653 2239 "commands. It has something of a reputation for being difficult to learn. "
dongsheng@653 2240 "Compared to Git, Mercurial has a strong focus on simplicity."
dongsheng@653 2241 msgstr ""
dongsheng@653 2242
dongsheng@653 2243 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2244 #: ../en/ch00-preface.xml:511
dongsheng@653 2245 msgid ""
dongsheng@653 2246 "In terms of performance, Git is extremely fast. In several cases, it is "
dongsheng@653 2247 "faster than Mercurial, at least on Linux, while Mercurial performs better on "
dongsheng@653 2248 "other operations. However, on Windows, the performance and general level of "
dongsheng@653 2249 "support that Git provides is, at the time of writing, far behind that of "
dongsheng@653 2250 "Mercurial."
dongsheng@653 2251 msgstr ""
dongsheng@653 2252
dongsheng@653 2253 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2254 #: ../en/ch00-preface.xml:518
dongsheng@653 2255 msgid ""
dongsheng@653 2256 "While a Mercurial repository needs no maintenance, a Git repository requires "
dongsheng@653 2257 "frequent manual <quote>repacks</quote> of its metadata. Without these, "
dongsheng@653 2258 "performance degrades, while space usage grows rapidly. A server that "
dongsheng@653 2259 "contains many Git repositories that are not rigorously and frequently "
dongsheng@653 2260 "repacked will become heavily disk-bound during backups, and there have been "
dongsheng@653 2261 "instances of daily backups taking far longer than 24 hours as a result. A "
dongsheng@653 2262 "freshly packed Git repository is slightly smaller than a Mercurial "
dongsheng@653 2263 "repository, but an unpacked repository is several orders of magnitude larger."
dongsheng@653 2264 msgstr ""
dongsheng@653 2265
dongsheng@653 2266 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2267 #: ../en/ch00-preface.xml:529
dongsheng@653 2268 msgid ""
dongsheng@653 2269 "The core of Git is written in C. Many Git commands are implemented as shell "
dongsheng@653 2270 "or Perl scripts, and the quality of these scripts varies widely. I have "
dongsheng@653 2271 "encountered several instances where scripts charged along blindly in the "
dongsheng@653 2272 "presence of errors that should have been fatal."
dongsheng@653 2273 msgstr ""
dongsheng@653 2274
dongsheng@653 2275 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2276 #: ../en/ch00-preface.xml:535
dongsheng@653 2277 msgid "Mercurial can import revision history from a Git repository."
dongsheng@653 2278 msgstr ""
dongsheng@653 2279
dongsheng@653 2280 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 2281 #: ../en/ch00-preface.xml:541 ../en/ch00-preface.xml:637
dongsheng@653 2282 msgid "CVS"
dongsheng@653 2283 msgstr ""
dongsheng@653 2284
dongsheng@653 2285 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2286 #: ../en/ch00-preface.xml:543
dongsheng@653 2287 msgid ""
dongsheng@653 2288 "CVS is probably the most widely used revision control tool in the world. Due "
dongsheng@653 2289 "to its age and internal untidiness, it has been only lightly maintained for "
dongsheng@653 2290 "many years."
dongsheng@653 2291 msgstr ""
dongsheng@653 2292
dongsheng@653 2293 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2294 #: ../en/ch00-preface.xml:547
dongsheng@653 2295 msgid ""
dongsheng@653 2296 "It has a centralised client/server architecture. It does not group related "
dongsheng@653 2297 "file changes into atomic commits, making it easy for people to <quote>break "
dongsheng@653 2298 "the build</quote>: one person can successfully commit part of a change and "
dongsheng@653 2299 "then be blocked by the need for a merge, causing other people to see only a "
dongsheng@653 2300 "portion of the work they intended to do. This also affects how you work with "
dongsheng@653 2301 "project history. If you want to see all of the modifications someone made as "
dongsheng@653 2302 "part of a task, you will need to manually inspect the descriptions and "
dongsheng@653 2303 "timestamps of the changes made to each file involved (if you even know what "
dongsheng@653 2304 "those files were)."
dongsheng@653 2305 msgstr ""
dongsheng@653 2306
dongsheng@653 2307 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2308 #: ../en/ch00-preface.xml:559
dongsheng@653 2309 msgid ""
dongsheng@653 2310 "CVS has a muddled notion of tags and branches that I will not attempt to even "
dongsheng@653 2311 "describe. It does not support renaming of files or directories well, making "
dongsheng@653 2312 "it easy to corrupt a repository. It has almost no internal consistency "
dongsheng@653 2313 "checking capabilities, so it is usually not even possible to tell whether or "
dongsheng@653 2314 "how a repository is corrupt. I would not recommend CVS for any project, "
dongsheng@653 2315 "existing or new."
dongsheng@653 2316 msgstr ""
dongsheng@653 2317
dongsheng@653 2318 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2319 #: ../en/ch00-preface.xml:567
dongsheng@653 2320 msgid ""
dongsheng@653 2321 "Mercurial can import CVS revision history. However, there are a few caveats "
dongsheng@653 2322 "that apply; these are true of every other revision control tool's CVS "
dongsheng@653 2323 "importer, too. Due to CVS's lack of atomic changes and unversioned "
dongsheng@653 2324 "filesystem hierarchy, it is not possible to reconstruct CVS history "
dongsheng@653 2325 "completely accurately; some guesswork is involved, and renames will usually "
dongsheng@653 2326 "not show up. Because a lot of advanced CVS administration has to be done by "
dongsheng@653 2327 "hand and is hence error-prone, it's common for CVS importers to run into "
dongsheng@653 2328 "multiple problems with corrupted repositories (completely bogus revision "
dongsheng@653 2329 "timestamps and files that have remained locked for over a decade are just two "
dongsheng@653 2330 "of the less interesting problems I can recall from personal experience)."
dongsheng@653 2331 msgstr ""
dongsheng@653 2332
dongsheng@653 2333 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2334 #: ../en/ch00-preface.xml:581
dongsheng@653 2335 msgid "Mercurial can import revision history from a CVS repository."
dongsheng@653 2336 msgstr ""
dongsheng@653 2337
dongsheng@653 2338 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 2339 #: ../en/ch00-preface.xml:587
dongsheng@653 2340 msgid "Commercial tools"
dongsheng@653 2341 msgstr "商业工具"
dongsheng@653 2342
dongsheng@653 2343 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2344 #: ../en/ch00-preface.xml:589
dongsheng@653 2345 msgid ""
dongsheng@653 2346 "Perforce has a centralised client/server architecture, with no client-side "
dongsheng@653 2347 "caching of any data. Unlike modern revision control tools, Perforce requires "
dongsheng@653 2348 "that a user run a command to inform the server about every file they intend "
dongsheng@653 2349 "to edit."
dongsheng@653 2350 msgstr ""
dongsheng@653 2351
dongsheng@653 2352 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2353 #: ../en/ch00-preface.xml:595
dongsheng@653 2354 msgid ""
dongsheng@653 2355 "The performance of Perforce is quite good for small teams, but it falls off "
dongsheng@653 2356 "rapidly as the number of users grows beyond a few dozen. Modestly large "
dongsheng@653 2357 "Perforce installations require the deployment of proxies to cope with the "
dongsheng@653 2358 "load their users generate."
dongsheng@653 2359 msgstr ""
dongsheng@653 2360
dongsheng@653 2361 #. type: Content of: <book><preface><sect1><sect2><title>
songdongsheng@667 2362 #: ../en/ch00-preface.xml:604
dongsheng@653 2363 msgid "Choosing a revision control tool"
dongsheng@653 2364 msgstr "选择版本控制工具"
dongsheng@653 2365
dongsheng@653 2366 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2367 #: ../en/ch00-preface.xml:606
dongsheng@653 2368 msgid ""
dongsheng@653 2369 "With the exception of CVS, all of the tools listed above have unique "
dongsheng@653 2370 "strengths that suit them to particular styles of work. There is no single "
dongsheng@653 2371 "revision control tool that is best in all situations."
dongsheng@653 2372 msgstr ""
dongsheng@653 2373
dongsheng@653 2374 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2375 #: ../en/ch00-preface.xml:611
dongsheng@653 2376 msgid ""
dongsheng@653 2377 "As an example, Subversion is a good choice for working with frequently edited "
dongsheng@653 2378 "binary files, due to its centralised nature and support for file locking."
dongsheng@653 2379 msgstr ""
dongsheng@653 2380
dongsheng@653 2381 #. type: Content of: <book><preface><sect1><sect2><para>
songdongsheng@667 2382 #: ../en/ch00-preface.xml:615
dongsheng@653 2383 msgid ""
dongsheng@653 2384 "I personally find Mercurial's properties of simplicity, performance, and good "
dongsheng@653 2385 "merge support to be a compelling combination that has served me well for "
dongsheng@653 2386 "several years."
dongsheng@653 2387 msgstr ""
dongsheng@653 2388
dongsheng@653 2389 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 2390 #: ../en/ch00-preface.xml:623
dongsheng@653 2391 msgid "Switching from another tool to Mercurial"
dongsheng@653 2392 msgstr "从其它工具切换到 Mercurial"
dongsheng@653 2393
dongsheng@653 2394 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2395 #: ../en/ch00-preface.xml:625
dongsheng@653 2396 msgid ""
dongsheng@653 2397 "Mercurial is bundled with an extension named <literal role=\"hg-ext"
dongsheng@653 2398 "\">convert</literal>, which can incrementally import revision history from "
dongsheng@653 2399 "several other revision control tools. By <quote>incremental</quote>, I mean "
dongsheng@653 2400 "that you can convert all of a project's history to date in one go, then rerun "
dongsheng@653 2401 "the conversion later to obtain new changes that happened after the initial "
dongsheng@653 2402 "conversion."
dongsheng@653 2403 msgstr ""
dongsheng@653 2404
dongsheng@653 2405 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2406 #: ../en/ch00-preface.xml:633
dongsheng@653 2407 msgid ""
dongsheng@653 2408 "The revision control tools supported by <literal role=\"hg-ext\">convert</"
dongsheng@653 2409 "literal> are as follows:"
dongsheng@653 2410 msgstr "<literal role=\"hg-ext\">convert</literal> 支持的版本控制工具有:"
dongsheng@653 2411
dongsheng@653 2412 #. type: Content of: <book><preface><sect1><itemizedlist><listitem><para>
songdongsheng@667 2413 #: ../en/ch00-preface.xml:639
dongsheng@653 2414 msgid "Darcs"
dongsheng@653 2415 msgstr ""
dongsheng@653 2416
dongsheng@653 2417 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2418 #: ../en/ch00-preface.xml:641
dongsheng@653 2419 msgid ""
dongsheng@653 2420 "In addition, <literal role=\"hg-ext\">convert</literal> can export changes "
dongsheng@653 2421 "from Mercurial to Subversion. This makes it possible to try Subversion and "
dongsheng@653 2422 "Mercurial in parallel before committing to a switchover, without risking the "
dongsheng@653 2423 "loss of any work."
dongsheng@653 2424 msgstr ""
dongsheng@653 2425
dongsheng@653 2426 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2427 #: ../en/ch00-preface.xml:647
dongsheng@653 2428 msgid ""
dongsheng@653 2429 "The <command role=\"hg-ext-convert\">convert</command> command is easy to "
dongsheng@653 2430 "use. Simply point it at the path or URL of the source repository, optionally "
dongsheng@653 2431 "give it the name of the destination repository, and it will start working. "
dongsheng@653 2432 "After the initial conversion, just run the same command again to import new "
dongsheng@653 2433 "changes."
dongsheng@653 2434 msgstr ""
dongsheng@653 2435
dongsheng@653 2436 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 2437 #: ../en/ch00-preface.xml:656
dongsheng@653 2438 msgid "A short history of revision control"
dongsheng@653 2439 msgstr "版本控制简史"
dongsheng@653 2440
dongsheng@653 2441 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2442 #: ../en/ch00-preface.xml:658
dongsheng@653 2443 msgid ""
dongsheng@653 2444 "The best known of the old-time revision control tools is SCCS (Source Code "
dongsheng@653 2445 "Control System), which Marc Rochkind wrote at Bell Labs, in the early 1970s. "
dongsheng@653 2446 "SCCS operated on individual files, and required every person working on a "
dongsheng@653 2447 "project to have access to a shared workspace on a single system. Only one "
dongsheng@653 2448 "person could modify a file at any time; arbitration for access to files was "
dongsheng@653 2449 "via locks. It was common for people to lock files, and later forget to "
dongsheng@653 2450 "unlock them, preventing anyone else from modifying those files without the "
dongsheng@653 2451 "help of an administrator."
dongsheng@653 2452 msgstr ""
dongsheng@653 2453
dongsheng@653 2454 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2455 #: ../en/ch00-preface.xml:669
dongsheng@653 2456 msgid ""
dongsheng@653 2457 "Walter Tichy developed a free alternative to SCCS in the early 1980s; he "
dongsheng@653 2458 "called his program RCS (Revision Control System). Like SCCS, RCS required "
dongsheng@653 2459 "developers to work in a single shared workspace, and to lock files to prevent "
dongsheng@653 2460 "multiple people from modifying them simultaneously."
dongsheng@653 2461 msgstr ""
dongsheng@653 2462
dongsheng@653 2463 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2464 #: ../en/ch00-preface.xml:675
dongsheng@653 2465 msgid ""
dongsheng@653 2466 "Later in the 1980s, Dick Grune used RCS as a building block for a set of "
dongsheng@653 2467 "shell scripts he initially called cmt, but then renamed to CVS (Concurrent "
dongsheng@653 2468 "Versions System). The big innovation of CVS was that it let developers work "
dongsheng@653 2469 "simultaneously and somewhat independently in their own personal workspaces. "
dongsheng@653 2470 "The personal workspaces prevented developers from stepping on each other's "
dongsheng@653 2471 "toes all the time, as was common with SCCS and RCS. Each developer had a copy "
dongsheng@653 2472 "of every project file, and could modify their copies independently. They had "
dongsheng@653 2473 "to merge their edits prior to committing changes to the central repository."
dongsheng@653 2474 msgstr ""
dongsheng@653 2475
dongsheng@653 2476 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2477 #: ../en/ch00-preface.xml:686
dongsheng@653 2478 msgid ""
dongsheng@653 2479 "Brian Berliner took Grune's original scripts and rewrote them in C, releasing "
dongsheng@653 2480 "in 1989 the code that has since developed into the modern version of CVS. "
dongsheng@653 2481 "CVS subsequently acquired the ability to operate over a network connection, "
dongsheng@653 2482 "giving it a client/server architecture. CVS's architecture is centralised; "
dongsheng@653 2483 "only the server has a copy of the history of the project. Client workspaces "
dongsheng@653 2484 "just contain copies of recent versions of the project's files, and a little "
dongsheng@653 2485 "metadata to tell them where the server is. CVS has been enormously "
dongsheng@653 2486 "successful; it is probably the world's most widely used revision control "
dongsheng@653 2487 "system."
dongsheng@653 2488 msgstr ""
dongsheng@653 2489
dongsheng@653 2490 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2491 #: ../en/ch00-preface.xml:697
dongsheng@653 2492 msgid ""
dongsheng@653 2493 "In the early 1990s, Sun Microsystems developed an early distributed revision "
dongsheng@653 2494 "control system, called TeamWare. A TeamWare workspace contains a complete "
dongsheng@653 2495 "copy of the project's history. TeamWare has no notion of a central "
dongsheng@653 2496 "repository. (CVS relied upon RCS for its history storage; TeamWare used "
dongsheng@653 2497 "SCCS.)"
dongsheng@653 2498 msgstr ""
dongsheng@653 2499
dongsheng@653 2500 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2501 #: ../en/ch00-preface.xml:704
dongsheng@653 2502 msgid ""
dongsheng@653 2503 "As the 1990s progressed, awareness grew of a number of problems with CVS. It "
dongsheng@653 2504 "records simultaneous changes to multiple files individually, instead of "
dongsheng@653 2505 "grouping them together as a single logically atomic operation. It does not "
dongsheng@653 2506 "manage its file hierarchy well; it is easy to make a mess of a repository by "
dongsheng@653 2507 "renaming files and directories. Worse, its source code is difficult to read "
dongsheng@653 2508 "and maintain, which made the <quote>pain level</quote> of fixing these "
dongsheng@653 2509 "architectural problems prohibitive."
dongsheng@653 2510 msgstr ""
dongsheng@653 2511
dongsheng@653 2512 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2513 #: ../en/ch00-preface.xml:714
dongsheng@653 2514 msgid ""
dongsheng@653 2515 "In 2001, Jim Blandy and Karl Fogel, two developers who had worked on CVS, "
dongsheng@653 2516 "started a project to replace it with a tool that would have a better "
dongsheng@653 2517 "architecture and cleaner code. The result, Subversion, does not stray from "
dongsheng@653 2518 "CVS's centralised client/server model, but it adds multi-file atomic commits, "
dongsheng@653 2519 "better namespace management, and a number of other features that make it a "
dongsheng@653 2520 "generally better tool than CVS. Since its initial release, it has rapidly "
dongsheng@653 2521 "grown in popularity."
dongsheng@653 2522 msgstr ""
dongsheng@653 2523
dongsheng@653 2524 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2525 #: ../en/ch00-preface.xml:723
dongsheng@653 2526 msgid ""
dongsheng@653 2527 "More or less simultaneously, Graydon Hoare began working on an ambitious "
dongsheng@653 2528 "distributed revision control system that he named Monotone. While Monotone "
dongsheng@653 2529 "addresses many of CVS's design flaws and has a peer-to-peer architecture, it "
dongsheng@653 2530 "goes beyond earlier (and subsequent) revision control tools in a number of "
dongsheng@653 2531 "innovative ways. It uses cryptographic hashes as identifiers, and has an "
dongsheng@653 2532 "integral notion of <quote>trust</quote> for code from different sources."
dongsheng@653 2533 msgstr ""
dongsheng@653 2534
dongsheng@653 2535 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2536 #: ../en/ch00-preface.xml:732
dongsheng@653 2537 msgid ""
dongsheng@653 2538 "Mercurial began life in 2005. While a few aspects of its design are "
dongsheng@653 2539 "influenced by Monotone, Mercurial focuses on ease of use, high performance, "
dongsheng@653 2540 "and scalability to very large projects."
dongsheng@653 2541 msgstr ""
dongsheng@653 2542
dongsheng@653 2543 #. type: Content of: <book><preface><sect1><title>
songdongsheng@667 2544 #: ../en/ch00-preface.xml:740
songdongsheng@667 2545 #, fuzzy
dongsheng@661 2546 msgid "Colophon—this book is Free"
dongsheng@661 2547 msgstr "后记—本书是自由的!"
dongsheng@653 2548
dongsheng@653 2549 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2550 #: ../en/ch00-preface.xml:742
dongsheng@653 2551 msgid ""
dongsheng@653 2552 "This book is licensed under the Open Publication License, and is produced "
dongsheng@653 2553 "entirely using Free Software tools. It is typeset with DocBook XML. "
dongsheng@653 2554 "Illustrations are drawn and rendered with <ulink url=\"http://www.inkscape."
dongsheng@653 2555 "org/\">Inkscape</ulink>."
dongsheng@653 2556 msgstr ""
dongsheng@653 2557
dongsheng@653 2558 #. type: Content of: <book><preface><sect1><para>
songdongsheng@667 2559 #: ../en/ch00-preface.xml:747
dongsheng@653 2560 msgid ""
dongsheng@653 2561 "The complete source code for this book is published as a Mercurial "
dongsheng@653 2562 "repository, at <ulink url=\"http://hg.serpentine.com/mercurial/book\">http://"
dongsheng@653 2563 "hg.serpentine.com/mercurial/book</ulink>."
dongsheng@653 2564 msgstr ""
dongsheng@653 2565
dongsheng@627 2566 #. type: Content of: <book><chapter><title>
dongsheng@650 2567 #: ../en/ch01-tour-basic.xml:5
dongsheng@627 2568 msgid "A tour of Mercurial: the basics"
dongsheng@627 2569 msgstr "Mercurial 教程: 基础知识"
dongsheng@627 2570
dongsheng@627 2571 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 2572 #: ../en/ch01-tour-basic.xml:8
dongsheng@627 2573 msgid "Installing Mercurial on your system"
dongsheng@627 2574 msgstr "安装 Mercurial"
dongsheng@627 2575
dongsheng@627 2576 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 2577 #: ../en/ch01-tour-basic.xml:10
dongsheng@627 2578 msgid ""
dongsheng@627 2579 "Prebuilt binary packages of Mercurial are available for every popular "
dongsheng@627 2580 "operating system. These make it easy to start using Mercurial on your "
dongsheng@627 2581 "computer immediately."
dongsheng@627 2582 msgstr ""
dongsheng@644 2583 "对于每种流行的操作系统,都有已经构建的二进制软件包。这让在你的计算机上开始使"
dongsheng@644 2584 "用 Mercurial 变得很容易。"
dongsheng@627 2585
dongsheng@627 2586 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 2587 #: ../en/ch01-tour-basic.xml:15
songdongsheng@667 2588 msgid "Windows"
songdongsheng@667 2589 msgstr ""
songdongsheng@667 2590
songdongsheng@667 2591 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2592 #: ../en/ch01-tour-basic.xml:17
songdongsheng@667 2593 msgid ""
songdongsheng@667 2594 "The best version of Mercurial for Windows is TortoiseHg, which can be found "
songdongsheng@667 2595 "at <ulink url=\"http://bitbucket.org/tortoisehg/stable/wiki/Home\">http://"
songdongsheng@667 2596 "bitbucket.org/tortoisehg/stable/wiki/Home</ulink>. This package has no "
songdongsheng@667 2597 "external dependencies; it <quote>just works</quote>. It provides both "
songdongsheng@667 2598 "command line and graphical user interfaces."
songdongsheng@667 2599 msgstr ""
songdongsheng@667 2600
songdongsheng@667 2601 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2602 #: ../en/ch01-tour-basic.xml:27
songdongsheng@667 2603 msgid "Mac OS X"
songdongsheng@667 2604 msgstr "Mac OS X"
songdongsheng@667 2605
songdongsheng@667 2606 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2607 #: ../en/ch01-tour-basic.xml:29
songdongsheng@667 2608 msgid ""
songdongsheng@667 2609 "Lee Cantey publishes an installer of Mercurial for Mac OS X at <ulink url="
songdongsheng@667 2610 "\"http://mercurial.berkwood.com\">http://mercurial.berkwood.com</ulink>."
songdongsheng@667 2611 msgstr ""
songdongsheng@667 2612
songdongsheng@667 2613 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2614 #: ../en/ch01-tour-basic.xml:35
dongsheng@627 2615 msgid "Linux"
dongsheng@644 2616 msgstr "Linux"
dongsheng@627 2617
dongsheng@627 2618 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2619 #: ../en/ch01-tour-basic.xml:37
dongsheng@627 2620 msgid ""
dongsheng@627 2621 "Because each Linux distribution has its own packaging tools, policies, and "
dongsheng@627 2622 "rate of development, it's difficult to give a comprehensive set of "
dongsheng@627 2623 "instructions on how to install Mercurial binaries. The version of Mercurial "
dongsheng@627 2624 "that you will end up with can vary depending on how active the person is who "
dongsheng@627 2625 "maintains the package for your distribution."
dongsheng@627 2626 msgstr ""
dongsheng@644 2627 "由于每种 Linux 发行版都有自己的包管理工具,开发策略和进度,从而很难给出安装 "
dongsheng@644 2628 "Mercurial 二进制包的全面说明。你安装的 Mercurial 版本,在很大程度上依赖于你所"
dongsheng@644 2629 "使用的发行版的 Mercurial 维护者的活跃程度。"
dongsheng@627 2630
dongsheng@627 2631 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2632 #: ../en/ch01-tour-basic.xml:44
dongsheng@627 2633 msgid ""
dongsheng@627 2634 "To keep things simple, I will focus on installing Mercurial from the command "
dongsheng@627 2635 "line under the most popular Linux distributions. Most of these distributions "
dongsheng@627 2636 "provide graphical package managers that will let you install Mercurial with a "
dongsheng@627 2637 "single click; the package name to look for is <literal>mercurial</literal>."
dongsheng@627 2638 msgstr ""
dongsheng@644 2639 "为了让事情简单,我会致力于说明在最流行的 Linux 发行版中,从命令行安装 "
dongsheng@644 2640 "Mercurial 的方法。这些发行版都提供了图形界面的包管理器,让你通过点击鼠标安装 "
dongsheng@644 2641 "Mercurial;寻找的包名称是 <literal>mercurial</literal>。"
dongsheng@627 2642
dongsheng@627 2643 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 2644 #: ../en/ch01-tour-basic.xml:52
songdongsheng@667 2645 msgid "Ubuntu and Debian:"
songdongsheng@667 2646 msgstr ""
dongsheng@627 2647
dongsheng@627 2648 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 2649 #: ../en/ch01-tour-basic.xml:54
songdongsheng@667 2650 #, fuzzy
songdongsheng@667 2651 msgid "Fedora and OpenSUSE:"
songdongsheng@667 2652 msgstr "OpenSUSE:"
dongsheng@627 2653
dongsheng@627 2654 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 2655 #: ../en/ch01-tour-basic.xml:56
dongsheng@627 2656 msgid "Gentoo:"
dongsheng@644 2657 msgstr "Gentoo:"
dongsheng@627 2658
dongsheng@646 2659 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2660 #: ../en/ch01-tour-basic.xml:62
dongsheng@627 2661 msgid "Solaris"
dongsheng@646 2662 msgstr "Solaris"
dongsheng@646 2663
dongsheng@646 2664 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2665 #: ../en/ch01-tour-basic.xml:64
songdongsheng@667 2666 #, fuzzy
dongsheng@627 2667 msgid ""
dongsheng@627 2668 "SunFreeWare, at <ulink url=\"http://www.sunfreeware.com\">http://www."
songdongsheng@667 2669 "sunfreeware.com</ulink>, provides prebuilt packages of Mercurial."
dongsheng@627 2670 msgstr ""
dongsheng@646 2671 "位于 <ulink url=\"http://www.sunfreeware.com\">http://www.sunfreeware.com</"
dongsheng@646 2672 "ulink> 的 SunFreeWare 是很好的二进制安装源,它包含 Intel 和 Sparc 架构的 32 位"
dongsheng@646 2673 "和 64 位包,包含 Mercurial 的当前版本。"
dongsheng@646 2674
dongsheng@627 2675 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2676 #: ../en/ch01-tour-basic.xml:73
dongsheng@627 2677 msgid "Getting started"
dongsheng@627 2678 msgstr "开始"
dongsheng@627 2679
dongsheng@627 2680 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2681 #: ../en/ch01-tour-basic.xml:75
dongsheng@627 2682 msgid ""
dongsheng@627 2683 "To begin, we'll use the <command role=\"hg-cmd\">hg version</command> command "
dongsheng@627 2684 "to find out whether Mercurial is actually installed properly. The actual "
dongsheng@627 2685 "version information that it prints isn't so important; it's whether it prints "
dongsheng@627 2686 "anything at all that we care about."
dongsheng@627 2687 msgstr ""
dongsheng@627 2688
dongsheng@627 2689 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2690 #: ../en/ch01-tour-basic.xml:84
dongsheng@627 2691 msgid "Built-in help"
dongsheng@627 2692 msgstr "内置帮助"
dongsheng@627 2693
dongsheng@627 2694 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2695 #: ../en/ch01-tour-basic.xml:86
dongsheng@627 2696 msgid ""
dongsheng@627 2697 "Mercurial provides a built-in help system. This is invaluable for those "
dongsheng@627 2698 "times when you find yourself stuck trying to remember how to run a command. "
dongsheng@627 2699 "If you are completely stuck, simply run <command role=\"hg-cmd\">hg help</"
dongsheng@627 2700 "command>; it will print a brief list of commands, along with a description of "
dongsheng@627 2701 "what each does. If you ask for help on a specific command (as below), it "
dongsheng@627 2702 "prints more detailed information."
dongsheng@627 2703 msgstr ""
dongsheng@627 2704
dongsheng@627 2705 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2706 #: ../en/ch01-tour-basic.xml:97
dongsheng@627 2707 msgid ""
dongsheng@627 2708 "For a more impressive level of detail (which you won't usually need) run "
dongsheng@627 2709 "<command role=\"hg-cmd\">hg help <option role=\"hg-opt-global\">-v</option></"
dongsheng@627 2710 "command>. The <option role=\"hg-opt-global\">-v</option> option is short for "
dongsheng@627 2711 "<option role=\"hg-opt-global\">--verbose</option>, and tells Mercurial to "
dongsheng@627 2712 "print more information than it usually would."
dongsheng@627 2713 msgstr ""
dongsheng@627 2714
dongsheng@627 2715 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2716 #: ../en/ch01-tour-basic.xml:108
dongsheng@627 2717 msgid "Working with a repository"
dongsheng@627 2718 msgstr "使用版本库"
dongsheng@627 2719
dongsheng@627 2720 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2721 #: ../en/ch01-tour-basic.xml:110
dongsheng@627 2722 msgid ""
dongsheng@627 2723 "In Mercurial, everything happens inside a <emphasis>repository</emphasis>. "
dongsheng@627 2724 "The repository for a project contains all of the files that <quote>belong to</"
dongsheng@627 2725 "quote> that project, along with a historical record of the project's files."
dongsheng@627 2726 msgstr ""
dongsheng@627 2727
dongsheng@627 2728 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2729 #: ../en/ch01-tour-basic.xml:116
dongsheng@627 2730 msgid ""
dongsheng@627 2731 "There's nothing particularly magical about a repository; it is simply a "
dongsheng@627 2732 "directory tree in your filesystem that Mercurial treats as special. You can "
dongsheng@627 2733 "rename or delete a repository any time you like, using either the command "
dongsheng@627 2734 "line or your file browser."
dongsheng@627 2735 msgstr ""
dongsheng@627 2736
dongsheng@627 2737 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2738 #: ../en/ch01-tour-basic.xml:123
dongsheng@627 2739 msgid "Making a local copy of a repository"
dongsheng@627 2740 msgstr "创建版本库的工作副本"
dongsheng@627 2741
dongsheng@627 2742 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2743 #: ../en/ch01-tour-basic.xml:125
dongsheng@627 2744 msgid ""
dongsheng@627 2745 "<emphasis>Copying</emphasis> a repository is just a little bit special. "
dongsheng@627 2746 "While you could use a normal file copying command to make a copy of a "
dongsheng@627 2747 "repository, it's best to use a built-in command that Mercurial provides. "
dongsheng@627 2748 "This command is called <command role=\"hg-cmd\">hg clone</command>, because "
songdongsheng@667 2749 "it makes an identical copy of an existing repository."
songdongsheng@667 2750 msgstr ""
songdongsheng@667 2751
songdongsheng@667 2752 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2753 #: ../en/ch01-tour-basic.xml:134
songdongsheng@667 2754 msgid ""
songdongsheng@667 2755 "One advantage of using <command role=\"hg-cmd\">hg clone</command> is that, "
songdongsheng@667 2756 "as we can see above, it lets us clone repositories over the network. Another "
songdongsheng@667 2757 "is that it remembers where we cloned from, which we'll find useful soon when "
songdongsheng@667 2758 "we want to fetch new changes from another repository."
songdongsheng@667 2759 msgstr ""
songdongsheng@667 2760
songdongsheng@667 2761 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2762 #: ../en/ch01-tour-basic.xml:140
dongsheng@627 2763 msgid ""
dongsheng@627 2764 "If our clone succeeded, we should now have a local directory called <filename "
dongsheng@627 2765 "class=\"directory\">hello</filename>. This directory will contain some files."
dongsheng@627 2766 msgstr ""
dongsheng@627 2767
dongsheng@627 2768 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2769 #: ../en/ch01-tour-basic.xml:146
dongsheng@627 2770 msgid ""
dongsheng@627 2771 "These files have the same contents and history in our repository as they do "
dongsheng@627 2772 "in the repository we cloned."
dongsheng@627 2773 msgstr ""
dongsheng@627 2774
dongsheng@627 2775 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2776 #: ../en/ch01-tour-basic.xml:149
dongsheng@627 2777 msgid ""
dongsheng@627 2778 "Every Mercurial repository is complete, self-contained, and independent. It "
songdongsheng@667 2779 "contains its own private copy of a project's files and history. As we just "
songdongsheng@667 2780 "mentioned, a cloned repository remembers the location of the repository it "
songdongsheng@667 2781 "was cloned from, but Mercurial will not communicate with that repository, or "
songdongsheng@667 2782 "any other, unless you tell it to."
songdongsheng@667 2783 msgstr ""
songdongsheng@667 2784
songdongsheng@667 2785 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2786 #: ../en/ch01-tour-basic.xml:156
dongsheng@627 2787 msgid ""
dongsheng@627 2788 "What this means for now is that we're free to experiment with our repository, "
dongsheng@627 2789 "safe in the knowledge that it's a private <quote>sandbox</quote> that won't "
dongsheng@627 2790 "affect anyone else."
dongsheng@627 2791 msgstr ""
dongsheng@627 2792
dongsheng@627 2793 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2794 #: ../en/ch01-tour-basic.xml:162
dongsheng@627 2795 msgid "What's in a repository?"
dongsheng@627 2796 msgstr "什么是版本库?"
dongsheng@627 2797
dongsheng@627 2798 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2799 #: ../en/ch01-tour-basic.xml:164
dongsheng@627 2800 msgid ""
dongsheng@627 2801 "When we take a more detailed look inside a repository, we can see that it "
dongsheng@627 2802 "contains a directory named <filename class=\"directory\">.hg</filename>. "
dongsheng@627 2803 "This is where Mercurial keeps all of its metadata for the repository."
dongsheng@627 2804 msgstr ""
dongsheng@627 2805
dongsheng@627 2806 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2807 #: ../en/ch01-tour-basic.xml:171
dongsheng@627 2808 msgid ""
dongsheng@627 2809 "The contents of the <filename class=\"directory\">.hg</filename> directory "
dongsheng@627 2810 "and its subdirectories are private to Mercurial. Every other file and "
dongsheng@627 2811 "directory in the repository is yours to do with as you please."
dongsheng@627 2812 msgstr ""
dongsheng@627 2813
dongsheng@627 2814 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2815 #: ../en/ch01-tour-basic.xml:177
dongsheng@627 2816 msgid ""
dongsheng@627 2817 "To introduce a little terminology, the <filename class=\"directory\">.hg</"
dongsheng@627 2818 "filename> directory is the <quote>real</quote> repository, and all of the "
dongsheng@627 2819 "files and directories that coexist with it are said to live in the "
dongsheng@627 2820 "<emphasis>working directory</emphasis>. An easy way to remember the "
dongsheng@627 2821 "distinction is that the <emphasis>repository</emphasis> contains the "
dongsheng@627 2822 "<emphasis>history</emphasis> of your project, while the <emphasis>working "
dongsheng@627 2823 "directory</emphasis> contains a <emphasis>snapshot</emphasis> of your project "
dongsheng@627 2824 "at a particular point in history."
dongsheng@627 2825 msgstr ""
dongsheng@627 2826
dongsheng@627 2827 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 2828 #: ../en/ch01-tour-basic.xml:192
dongsheng@627 2829 msgid "A tour through history"
dongsheng@627 2830 msgstr "回溯历史"
dongsheng@627 2831
dongsheng@627 2832 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2833 #: ../en/ch01-tour-basic.xml:194
dongsheng@627 2834 msgid ""
dongsheng@627 2835 "One of the first things we might want to do with a new, unfamiliar repository "
dongsheng@627 2836 "is understand its history. The <command role=\"hg-cmd\">hg log</command> "
songdongsheng@667 2837 "command gives us a view of the history of changes in the repository."
songdongsheng@667 2838 msgstr ""
songdongsheng@667 2839
songdongsheng@667 2840 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2841 #: ../en/ch01-tour-basic.xml:201
dongsheng@627 2842 msgid ""
dongsheng@627 2843 "By default, this command prints a brief paragraph of output for each change "
dongsheng@627 2844 "to the project that was recorded. In Mercurial terminology, we call each of "
dongsheng@627 2845 "these recorded events a <emphasis>changeset</emphasis>, because it can "
dongsheng@627 2846 "contain a record of changes to several files."
dongsheng@627 2847 msgstr ""
dongsheng@627 2848
dongsheng@627 2849 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2850 #: ../en/ch01-tour-basic.xml:207
dongsheng@627 2851 msgid ""
dongsheng@627 2852 "The fields in a record of output from <command role=\"hg-cmd\">hg log</"
dongsheng@627 2853 "command> are as follows."
dongsheng@627 2854 msgstr ""
dongsheng@627 2855
dongsheng@627 2856 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2857 #: ../en/ch01-tour-basic.xml:211
dongsheng@627 2858 msgid ""
dongsheng@627 2859 "<literal>changeset</literal>: This field has the format of a number, followed "
songdongsheng@667 2860 "by a colon, followed by a hexadecimal (or <emphasis>hex</emphasis>) string. "
songdongsheng@667 2861 "These are <emphasis>identifiers</emphasis> for the changeset. The hex string "
songdongsheng@667 2862 "is a unique identifier: the same hex string will always refer to the same "
songdongsheng@667 2863 "changeset. The number is shorter and easier to type than the hex string, but "
songdongsheng@667 2864 "it isn't unique: the same number in two different clones of a repository may "
songdongsheng@667 2865 "identify different changesets. Why provide the number at all, then? For "
songdongsheng@667 2866 "local convenience."
dongsheng@627 2867 msgstr ""
dongsheng@627 2868
dongsheng@627 2869 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2870 #: ../en/ch01-tour-basic.xml:223
dongsheng@627 2871 msgid ""
dongsheng@627 2872 "<literal>user</literal>: The identity of the person who created the "
dongsheng@627 2873 "changeset. This is a free-form field, but it most often contains a person's "
dongsheng@627 2874 "name and email address."
dongsheng@627 2875 msgstr ""
dongsheng@627 2876
dongsheng@627 2877 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2878 #: ../en/ch01-tour-basic.xml:227
dongsheng@627 2879 msgid ""
dongsheng@627 2880 "<literal>date</literal>: The date and time on which the changeset was "
dongsheng@627 2881 "created, and the timezone in which it was created. (The date and time are "
dongsheng@627 2882 "local to that timezone; they display what time and date it was for the person "
dongsheng@627 2883 "who created the changeset.)"
dongsheng@627 2884 msgstr ""
dongsheng@627 2885
dongsheng@627 2886 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2887 #: ../en/ch01-tour-basic.xml:232
dongsheng@627 2888 msgid ""
dongsheng@627 2889 "<literal>summary</literal>: The first line of the text message that the "
dongsheng@627 2890 "creator of the changeset entered to describe the changeset."
dongsheng@627 2891 msgstr ""
dongsheng@627 2892
songdongsheng@667 2893 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 2894 #: ../en/ch01-tour-basic.xml:236
songdongsheng@667 2895 msgid ""
songdongsheng@667 2896 "Some changesets, such as the first in the list above, have a <literal>tag</"
songdongsheng@667 2897 "literal> field. A tag is another way to identify a changeset, by giving it "
songdongsheng@667 2898 "an easy-to-remember name. (The tag named <literal>tip</literal> is special: "
songdongsheng@667 2899 "it always refers to the newest change in a repository.)"
songdongsheng@667 2900 msgstr ""
songdongsheng@667 2901
songdongsheng@667 2902 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2903 #: ../en/ch01-tour-basic.xml:244
dongsheng@627 2904 msgid ""
dongsheng@627 2905 "The default output printed by <command role=\"hg-cmd\">hg log</command> is "
dongsheng@627 2906 "purely a summary; it is missing a lot of detail."
dongsheng@627 2907 msgstr ""
dongsheng@627 2908
dongsheng@627 2909 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 2910 #: ../en/ch01-tour-basic.xml:248
dongsheng@627 2911 msgid ""
songdongsheng@658 2912 "<xref linkend=\"fig:tour-basic:history\"/> provides a graphical "
songdongsheng@658 2913 "representation of the history of the <filename class=\"directory\">hello</"
songdongsheng@658 2914 "filename> repository, to make it a little easier to see which direction "
songdongsheng@658 2915 "history is <quote>flowing</quote> in. We'll be returning to this figure "
songdongsheng@658 2916 "several times in this chapter and the chapter that follows."
songdongsheng@658 2917 msgstr ""
songdongsheng@658 2918
songdongsheng@658 2919 #. type: Content of: <book><chapter><sect1><figure><title>
songdongsheng@667 2920 #: ../en/ch01-tour-basic.xml:257
dongsheng@627 2921 msgid ""
dongsheng@627 2922 "Graphical history of the <filename class=\"directory\">hello</filename> "
dongsheng@627 2923 "repository"
dongsheng@660 2924 msgstr "版本库 <filename class=\"directory\">hello</filename> 的历史图"
dongsheng@627 2925
songdongsheng@658 2926 #. type: Content of: <book><chapter><sect1><figure>
songdongsheng@667 2927 #: ../en/ch01-tour-basic.xml:259 ../en/ch02-tour-merge.xml:50
songdongsheng@658 2928 #: ../en/ch02-tour-merge.xml:181 ../en/ch03-concepts.xml:293
songdongsheng@658 2929 msgid "<placeholder type=\"mediaobject\" id=\"0\"/>"
songdongsheng@658 2930 msgstr ""
songdongsheng@658 2931
songdongsheng@658 2932 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
songdongsheng@667 2933 #: ../en/ch01-tour-basic.xml:260
songdongsheng@658 2934 msgid ""
songdongsheng@658 2935 "<imageobject><imagedata fileref=\"figs/tour-history.png\"/></imageobject>"
songdongsheng@658 2936 msgstr ""
songdongsheng@658 2937
songdongsheng@658 2938 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject><textobject><phrase>
songdongsheng@667 2939 #: ../en/ch01-tour-basic.xml:261 ../en/ch02-tour-merge.xml:52
songdongsheng@658 2940 #: ../en/ch02-tour-merge.xml:82 ../en/ch02-tour-merge.xml:129
songdongsheng@658 2941 #: ../en/ch02-tour-merge.xml:183 ../en/ch02-tour-merge.xml:254
songdongsheng@658 2942 #: ../en/ch03-concepts.xml:57 ../en/ch03-concepts.xml:106
songdongsheng@658 2943 #: ../en/ch03-concepts.xml:191 ../en/ch03-concepts.xml:295
songdongsheng@658 2944 #: ../en/ch03-concepts.xml:346 ../en/ch03-concepts.xml:361
songdongsheng@658 2945 #: ../en/ch03-concepts.xml:402 ../en/ch03-concepts.xml:422
songdongsheng@658 2946 #: ../en/ch03-concepts.xml:465 ../en/ch05-collab.xml:276
songdongsheng@658 2947 #: ../en/ch08-undo.xml:365 ../en/ch08-undo.xml:412 ../en/ch08-undo.xml:477
songdongsheng@658 2948 #: ../en/ch08-undo.xml:515 ../en/ch11-mq.xml:412
songdongsheng@658 2949 msgid "XXX add text"
songdongsheng@658 2950 msgstr ""
songdongsheng@658 2951
dongsheng@627 2952 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 2953 #: ../en/ch01-tour-basic.xml:266
dongsheng@627 2954 msgid "Changesets, revisions, and talking to other people"
songdongsheng@665 2955 msgstr "修改集,版本,与其它用户交互"
dongsheng@627 2956
dongsheng@627 2957 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2958 #: ../en/ch01-tour-basic.xml:269
dongsheng@627 2959 msgid ""
dongsheng@627 2960 "As English is a notoriously sloppy language, and computer science has a "
dongsheng@627 2961 "hallowed history of terminological confusion (why use one term when four will "
dongsheng@627 2962 "do?), revision control has a variety of words and phrases that mean the same "
dongsheng@627 2963 "thing. If you are talking about Mercurial history with other people, you "
dongsheng@627 2964 "will find that the word <quote>changeset</quote> is often compressed to "
dongsheng@627 2965 "<quote>change</quote> or (when written) <quote>cset</quote>, and sometimes a "
dongsheng@627 2966 "changeset is referred to as a <quote>revision</quote> or a <quote>rev</quote>."
dongsheng@627 2967 msgstr ""
dongsheng@627 2968
dongsheng@627 2969 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2970 #: ../en/ch01-tour-basic.xml:279
dongsheng@627 2971 msgid ""
dongsheng@627 2972 "While it doesn't matter what <emphasis>word</emphasis> you use to refer to "
dongsheng@627 2973 "the concept of <quote>a changeset</quote>, the <emphasis>identifier</"
dongsheng@627 2974 "emphasis> that you use to refer to <quote>a <emphasis>specific</emphasis> "
dongsheng@627 2975 "changeset</quote> is of great importance. Recall that the <literal>changeset</"
dongsheng@627 2976 "literal> field in the output from <command role=\"hg-cmd\">hg log</command> "
dongsheng@627 2977 "identifies a changeset using both a number and a hexadecimal string."
dongsheng@627 2978 msgstr ""
dongsheng@627 2979
dongsheng@627 2980 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@667 2981 #: ../en/ch01-tour-basic.xml:288
songdongsheng@667 2982 msgid ""
songdongsheng@667 2983 "The revision number is a handy notation that is <emphasis>only valid in that "
songdongsheng@667 2984 "repository</emphasis>."
songdongsheng@658 2985 msgstr ""
songdongsheng@658 2986
songdongsheng@658 2987 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 2988 #: ../en/ch01-tour-basic.xml:291
dongsheng@627 2989 msgid ""
songdongsheng@667 2990 "The hexadecimal string is the <emphasis>permanent, unchanging identifier</"
dongsheng@627 2991 "emphasis> that will always identify that exact changeset in <emphasis>every</"
dongsheng@627 2992 "emphasis> copy of the repository."
dongsheng@627 2993 msgstr ""
dongsheng@627 2994
dongsheng@627 2995 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 2996 #: ../en/ch01-tour-basic.xml:297
dongsheng@627 2997 msgid ""
dongsheng@627 2998 "This distinction is important. If you send someone an email talking about "
dongsheng@627 2999 "<quote>revision 33</quote>, there's a high likelihood that their revision 33 "
dongsheng@627 3000 "will <emphasis>not be the same</emphasis> as yours. The reason for this is "
dongsheng@627 3001 "that a revision number depends on the order in which changes arrived in a "
dongsheng@627 3002 "repository, and there is no guarantee that the same changes will happen in "
songdongsheng@667 3003 "the same order in different repositories. Three changes <literal>a,b,c</"
songdongsheng@667 3004 "literal> can easily appear in one repository as <literal>0,1,2</literal>, "
songdongsheng@667 3005 "while in another as <literal>0,2,1</literal>."
songdongsheng@667 3006 msgstr ""
songdongsheng@667 3007
songdongsheng@667 3008 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3009 #: ../en/ch01-tour-basic.xml:309
dongsheng@627 3010 msgid ""
dongsheng@627 3011 "Mercurial uses revision numbers purely as a convenient shorthand. If you "
dongsheng@627 3012 "need to discuss a changeset with someone, or make a record of a changeset for "
dongsheng@627 3013 "some other reason (for example, in a bug report), use the hexadecimal "
dongsheng@627 3014 "identifier."
dongsheng@627 3015 msgstr ""
dongsheng@627 3016
dongsheng@627 3017 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3018 #: ../en/ch01-tour-basic.xml:317
dongsheng@627 3019 msgid "Viewing specific revisions"
dongsheng@627 3020 msgstr "察看指定版本"
dongsheng@627 3021
dongsheng@627 3022 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3023 #: ../en/ch01-tour-basic.xml:319
dongsheng@627 3024 msgid ""
dongsheng@627 3025 "To narrow the output of <command role=\"hg-cmd\">hg log</command> down to a "
dongsheng@627 3026 "single revision, use the <option role=\"hg-opt-log\">-r</option> (or <option "
dongsheng@627 3027 "role=\"hg-opt-log\">--rev</option>) option. You can use either a revision "
songdongsheng@667 3028 "number or a hexadecimal identifier, and you can provide as many revisions as "
songdongsheng@667 3029 "you want."
songdongsheng@667 3030 msgstr ""
songdongsheng@667 3031
songdongsheng@667 3032 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3033 #: ../en/ch01-tour-basic.xml:328
dongsheng@627 3034 msgid ""
dongsheng@627 3035 "If you want to see the history of several revisions without having to list "
dongsheng@627 3036 "each one, you can use <emphasis>range notation</emphasis>; this lets you "
dongsheng@627 3037 "express the idea <quote>I want all revisions between <literal>abc</literal> "
dongsheng@627 3038 "and <literal>def</literal>, inclusive</quote>."
dongsheng@627 3039 msgstr ""
dongsheng@627 3040
dongsheng@627 3041 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3042 #: ../en/ch01-tour-basic.xml:336
dongsheng@627 3043 msgid ""
dongsheng@627 3044 "Mercurial also honours the order in which you specify revisions, so <command "
dongsheng@627 3045 "role=\"hg-cmd\">hg log -r 2:4</command> prints 2, 3, and 4. while <command "
dongsheng@627 3046 "role=\"hg-cmd\">hg log -r 4:2</command> prints 4, 3, and 2."
dongsheng@627 3047 msgstr ""
dongsheng@627 3048
dongsheng@627 3049 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3050 #: ../en/ch01-tour-basic.xml:343
dongsheng@627 3051 msgid "More detailed information"
dongsheng@627 3052 msgstr "更详细的信息"
dongsheng@627 3053
dongsheng@627 3054 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3055 #: ../en/ch01-tour-basic.xml:345
dongsheng@627 3056 msgid ""
dongsheng@627 3057 "While the summary information printed by <command role=\"hg-cmd\">hg log</"
dongsheng@627 3058 "command> is useful if you already know what you're looking for, you may need "
dongsheng@627 3059 "to see a complete description of the change, or a list of the files changed, "
dongsheng@627 3060 "if you're trying to decide whether a changeset is the one you're looking for. "
dongsheng@627 3061 "The <command role=\"hg-cmd\">hg log</command> command's <option role=\"hg-opt-"
dongsheng@627 3062 "global\">-v</option> (or <option role=\"hg-opt-global\">--verbose</option>) "
dongsheng@627 3063 "option gives you this extra detail."
dongsheng@627 3064 msgstr ""
dongsheng@627 3065
dongsheng@627 3066 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3067 #: ../en/ch01-tour-basic.xml:357
dongsheng@627 3068 msgid ""
dongsheng@627 3069 "If you want to see both the description and content of a change, add the "
dongsheng@627 3070 "<option role=\"hg-opt-log\">-p</option> (or <option role=\"hg-opt-log\">--"
dongsheng@627 3071 "patch</option>) option. This displays the content of a change as a "
dongsheng@627 3072 "<emphasis>unified diff</emphasis> (if you've never seen a unified diff "
songdongsheng@658 3073 "before, see <xref linkend=\"sec:mq:patch\"/> for an overview)."
dongsheng@627 3074 msgstr ""
dongsheng@627 3075
songdongsheng@667 3076 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3077 #: ../en/ch01-tour-basic.xml:367
songdongsheng@667 3078 msgid ""
songdongsheng@667 3079 "The <option role=\"hg-opt-log\">-p</option> option is tremendously useful, so "
songdongsheng@667 3080 "it's well worth remembering."
songdongsheng@667 3081 msgstr ""
songdongsheng@667 3082
dongsheng@627 3083 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 3084 #: ../en/ch01-tour-basic.xml:374
dongsheng@627 3085 msgid "All about command options"
dongsheng@627 3086 msgstr "命令选项"
dongsheng@627 3087
dongsheng@627 3088 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3089 #: ../en/ch01-tour-basic.xml:376
dongsheng@627 3090 msgid ""
dongsheng@627 3091 "Let's take a brief break from exploring Mercurial commands to discuss a "
dongsheng@627 3092 "pattern in the way that they work; you may find this useful to keep in mind "
dongsheng@627 3093 "as we continue our tour."
dongsheng@627 3094 msgstr ""
dongsheng@627 3095
dongsheng@627 3096 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3097 #: ../en/ch01-tour-basic.xml:380
dongsheng@627 3098 msgid ""
dongsheng@627 3099 "Mercurial has a consistent and straightforward approach to dealing with the "
dongsheng@627 3100 "options that you can pass to commands. It follows the conventions for "
dongsheng@627 3101 "options that are common to modern Linux and Unix systems."
dongsheng@627 3102 msgstr ""
dongsheng@627 3103
dongsheng@627 3104 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 3105 #: ../en/ch01-tour-basic.xml:387
dongsheng@627 3106 msgid ""
dongsheng@627 3107 "Every option has a long name. For example, as we've already seen, the "
dongsheng@627 3108 "<command role=\"hg-cmd\">hg log</command> command accepts a <option role=\"hg-"
dongsheng@627 3109 "opt-log\">--rev</option> option."
dongsheng@627 3110 msgstr ""
dongsheng@627 3111
dongsheng@627 3112 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 3113 #: ../en/ch01-tour-basic.xml:393
dongsheng@627 3114 msgid ""
dongsheng@627 3115 "Most options have short names, too. Instead of <option role=\"hg-opt-log\">--"
dongsheng@627 3116 "rev</option>, we can use <option role=\"hg-opt-log\">-r</option>. (The "
dongsheng@627 3117 "reason that some options don't have short names is that the options in "
dongsheng@627 3118 "question are rarely used.)"
dongsheng@627 3119 msgstr ""
dongsheng@627 3120
dongsheng@627 3121 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 3122 #: ../en/ch01-tour-basic.xml:400
songdongsheng@667 3123 msgid ""
songdongsheng@667 3124 "Long options start with two dashes (e.g. <option role=\"hg-opt-log\">--rev</"
dongsheng@627 3125 "option>), while short options start with one (e.g. <option role=\"hg-opt-log"
dongsheng@627 3126 "\">-r</option>)."
dongsheng@627 3127 msgstr ""
dongsheng@627 3128
dongsheng@627 3129 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 3130 #: ../en/ch01-tour-basic.xml:406
dongsheng@627 3131 msgid ""
dongsheng@627 3132 "Option naming and usage is consistent across commands. For example, every "
dongsheng@627 3133 "command that lets you specify a changeset ID or revision number accepts both "
dongsheng@627 3134 "<option role=\"hg-opt-log\">-r</option> and <option role=\"hg-opt-log\">--"
dongsheng@627 3135 "rev</option> arguments."
dongsheng@627 3136 msgstr ""
dongsheng@627 3137
songdongsheng@667 3138 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@667 3139 #: ../en/ch01-tour-basic.xml:413
songdongsheng@667 3140 msgid ""
songdongsheng@667 3141 "If you are using short options, you can save typing by running them together. "
songdongsheng@667 3142 "For example, the command <command role=\"hg-cmd\">hg log -v -p -r 2</command> "
songdongsheng@667 3143 "can be written as <command role=\"hg-cmd\">hg log -vpr2</command>."
songdongsheng@667 3144 msgstr ""
songdongsheng@667 3145
songdongsheng@667 3146 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3147 #: ../en/ch01-tour-basic.xml:420
dongsheng@627 3148 msgid ""
dongsheng@627 3149 "In the examples throughout this book, I use short options instead of long. "
dongsheng@627 3150 "This just reflects my own preference, so don't read anything significant into "
dongsheng@627 3151 "it."
dongsheng@627 3152 msgstr ""
dongsheng@627 3153
dongsheng@627 3154 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3155 #: ../en/ch01-tour-basic.xml:424
dongsheng@627 3156 msgid ""
dongsheng@627 3157 "Most commands that print output of some kind will print more output when "
dongsheng@627 3158 "passed a <option role=\"hg-opt-global\">-v</option> (or <option role=\"hg-opt-"
dongsheng@627 3159 "global\">--verbose</option>) option, and less when passed <option role=\"hg-"
dongsheng@627 3160 "opt-global\">-q</option> (or <option role=\"hg-opt-global\">--quiet</option>)."
dongsheng@627 3161 msgstr ""
dongsheng@627 3162
songdongsheng@667 3163 #. type: Content of: <book><chapter><sect1><note><title>
songdongsheng@667 3164 #: ../en/ch01-tour-basic.xml:431
songdongsheng@667 3165 msgid "Option naming consistency"
songdongsheng@667 3166 msgstr ""
songdongsheng@667 3167
songdongsheng@667 3168 #. type: Content of: <book><chapter><sect1><note><para>
songdongsheng@667 3169 #: ../en/ch01-tour-basic.xml:433
songdongsheng@667 3170 msgid ""
songdongsheng@667 3171 "Almost always, Mercurial commands use consistent option names to refer to the "
songdongsheng@667 3172 "same concepts. For instance, if a command deals with changesets, you'll "
songdongsheng@667 3173 "always identify them with <option role=\"hg-opt-log\">--rev</option> or "
songdongsheng@667 3174 "<option role=\"hg-opt-log\">-r</option>. This consistent use of option names "
songdongsheng@667 3175 "makes it easier to remember what options a particular command takes."
songdongsheng@667 3176 msgstr ""
songdongsheng@667 3177
dongsheng@627 3178 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 3179 #: ../en/ch01-tour-basic.xml:444
dongsheng@627 3180 msgid "Making and reviewing changes"
dongsheng@627 3181 msgstr "创建和复审修改"
dongsheng@627 3182
dongsheng@627 3183 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3184 #: ../en/ch01-tour-basic.xml:446
dongsheng@627 3185 msgid ""
dongsheng@627 3186 "Now that we have a grasp of viewing history in Mercurial, let's take a look "
dongsheng@627 3187 "at making some changes and examining them."
dongsheng@627 3188 msgstr ""
dongsheng@627 3189
dongsheng@627 3190 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3191 #: ../en/ch01-tour-basic.xml:450
dongsheng@627 3192 msgid ""
dongsheng@627 3193 "The first thing we'll do is isolate our experiment in a repository of its "
dongsheng@627 3194 "own. We use the <command role=\"hg-cmd\">hg clone</command> command, but we "
dongsheng@627 3195 "don't need to clone a copy of the remote repository. Since we already have a "
dongsheng@627 3196 "copy of it locally, we can just clone that instead. This is much faster than "
dongsheng@627 3197 "cloning over the network, and cloning a local repository uses less disk space "
songdongsheng@667 3198 "in most cases, too<placeholder type=\"footnote\" id=\"0\"/>."
songdongsheng@667 3199 msgstr ""
songdongsheng@667 3200
songdongsheng@667 3201 #. type: Content of: <book><chapter><sect1><para><footnote><para>
songdongsheng@667 3202 #: ../en/ch01-tour-basic.xml:457
songdongsheng@667 3203 msgid ""
songdongsheng@667 3204 "The saving of space arises when source and destination repositories are on "
songdongsheng@667 3205 "the same filesystem, in which case Mercurial will use hardlinks to do copy-on-"
songdongsheng@667 3206 "write sharing of its internal metadata. If that explanation meant nothing to "
songdongsheng@667 3207 "you, don't worry: everything happens transparently and automatically, and you "
songdongsheng@667 3208 "don't need to understand it."
songdongsheng@667 3209 msgstr ""
songdongsheng@667 3210
songdongsheng@667 3211 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3212 #: ../en/ch01-tour-basic.xml:467
dongsheng@627 3213 msgid ""
dongsheng@627 3214 "As an aside, it's often good practice to keep a <quote>pristine</quote> copy "
dongsheng@627 3215 "of a remote repository around, which you can then make temporary clones of to "
dongsheng@627 3216 "create sandboxes for each task you want to work on. This lets you work on "
dongsheng@627 3217 "multiple tasks in parallel, each isolated from the others until it's complete "
dongsheng@627 3218 "and you're ready to integrate it back. Because local clones are so cheap, "
dongsheng@627 3219 "there's almost no overhead to cloning and destroying repositories whenever "
dongsheng@627 3220 "you want."
dongsheng@627 3221 msgstr ""
dongsheng@627 3222
dongsheng@627 3223 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3224 #: ../en/ch01-tour-basic.xml:476
dongsheng@627 3225 msgid ""
dongsheng@627 3226 "In our <filename class=\"directory\">my-hello</filename> repository, we have "
dongsheng@627 3227 "a file <filename>hello.c</filename> that contains the classic <quote>hello, "
songdongsheng@667 3228 "world</quote> program."
songdongsheng@667 3229 msgstr ""
songdongsheng@667 3230
songdongsheng@667 3231 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3232 #: ../en/ch01-tour-basic.xml:482
songdongsheng@667 3233 msgid "Let's edit this file so that it prints a second line of output."
songdongsheng@667 3234 msgstr ""
songdongsheng@667 3235
songdongsheng@667 3236 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3237 #: ../en/ch01-tour-basic.xml:487
dongsheng@627 3238 msgid ""
dongsheng@627 3239 "Mercurial's <command role=\"hg-cmd\">hg status</command> command will tell us "
dongsheng@627 3240 "what Mercurial knows about the files in the repository."
dongsheng@627 3241 msgstr ""
dongsheng@627 3242
dongsheng@627 3243 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3244 #: ../en/ch01-tour-basic.xml:493
dongsheng@627 3245 msgid ""
dongsheng@627 3246 "The <command role=\"hg-cmd\">hg status</command> command prints no output for "
dongsheng@627 3247 "some files, but a line starting with <quote><literal>M</literal></quote> for "
dongsheng@627 3248 "<filename>hello.c</filename>. Unless you tell it to, <command role=\"hg-cmd"
dongsheng@627 3249 "\">hg status</command> will not print any output for files that have not been "
dongsheng@627 3250 "modified."
dongsheng@627 3251 msgstr ""
dongsheng@627 3252
dongsheng@627 3253 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3254 #: ../en/ch01-tour-basic.xml:500
dongsheng@627 3255 msgid ""
dongsheng@627 3256 "The <quote><literal>M</literal></quote> indicates that Mercurial has noticed "
dongsheng@627 3257 "that we modified <filename>hello.c</filename>. We didn't need to "
dongsheng@627 3258 "<emphasis>inform</emphasis> Mercurial that we were going to modify the file "
dongsheng@627 3259 "before we started, or that we had modified the file after we were done; it "
dongsheng@627 3260 "was able to figure this out itself."
dongsheng@627 3261 msgstr ""
dongsheng@627 3262
dongsheng@627 3263 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3264 #: ../en/ch01-tour-basic.xml:508
songdongsheng@667 3265 msgid ""
songdongsheng@667 3266 "It's somewhat helpful to know that we've modified <filename>hello.c</"
dongsheng@627 3267 "filename>, but we might prefer to know exactly <emphasis>what</emphasis> "
dongsheng@627 3268 "changes we've made to it. To do this, we use the <command role=\"hg-cmd\">hg "
dongsheng@627 3269 "diff</command> command."
dongsheng@627 3270 msgstr ""
dongsheng@627 3271
dongsheng@627 3272 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 3273 #: ../en/ch01-tour-basic.xml:517 ../en/ch11-mq.xml:187
songdongsheng@667 3274 msgid "Understanding patches"
songdongsheng@667 3275 msgstr "理解补丁"
songdongsheng@667 3276
songdongsheng@667 3277 #. type: Content of: <book><chapter><sect1><tip><para>
songdongsheng@667 3278 #: ../en/ch01-tour-basic.xml:519
songdongsheng@667 3279 msgid ""
songdongsheng@667 3280 "Remember to take a look at <xref linkend=\"sec:mq:patch\"/> if you don't know "
songdongsheng@667 3281 "how to read output above."
songdongsheng@667 3282 msgstr ""
songdongsheng@667 3283
songdongsheng@667 3284 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 3285 #: ../en/ch01-tour-basic.xml:525
dongsheng@627 3286 msgid "Recording changes in a new changeset"
dongsheng@627 3287 msgstr "在新修改集中记录修改"
dongsheng@627 3288
dongsheng@627 3289 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3290 #: ../en/ch01-tour-basic.xml:527
dongsheng@627 3291 msgid ""
dongsheng@627 3292 "We can modify files, build and test our changes, and use <command role=\"hg-"
dongsheng@627 3293 "cmd\">hg status</command> and <command role=\"hg-cmd\">hg diff</command> to "
dongsheng@627 3294 "review our changes, until we're satisfied with what we've done and arrive at "
dongsheng@627 3295 "a natural stopping point where we want to record our work in a new changeset."
dongsheng@627 3296 msgstr ""
dongsheng@627 3297
dongsheng@627 3298 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3299 #: ../en/ch01-tour-basic.xml:534
dongsheng@627 3300 msgid ""
dongsheng@627 3301 "The <command role=\"hg-cmd\">hg commit</command> command lets us create a new "
dongsheng@627 3302 "changeset; we'll usually refer to this as <quote>making a commit</quote> or "
dongsheng@627 3303 "<quote>committing</quote>."
dongsheng@627 3304 msgstr ""
dongsheng@627 3305
dongsheng@627 3306 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3307 #: ../en/ch01-tour-basic.xml:540
dongsheng@627 3308 msgid "Setting up a username"
dongsheng@627 3309 msgstr "配置用户名称"
dongsheng@627 3310
dongsheng@627 3311 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3312 #: ../en/ch01-tour-basic.xml:542
dongsheng@627 3313 msgid ""
dongsheng@627 3314 "When you try to run <command role=\"hg-cmd\">hg commit</command> for the "
dongsheng@627 3315 "first time, it is not guaranteed to succeed. Mercurial records your name and "
dongsheng@627 3316 "address with each change that you commit, so that you and others will later "
dongsheng@627 3317 "be able to tell who made each change. Mercurial tries to automatically "
dongsheng@627 3318 "figure out a sensible username to commit the change with. It will attempt "
dongsheng@627 3319 "each of the following methods, in order:"
dongsheng@627 3320 msgstr ""
dongsheng@627 3321
dongsheng@627 3322 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 3323 #: ../en/ch01-tour-basic.xml:551
dongsheng@627 3324 msgid ""
dongsheng@627 3325 "If you specify a <option role=\"hg-opt-commit\">-u</option> option to the "
dongsheng@627 3326 "<command role=\"hg-cmd\">hg commit</command> command on the command line, "
dongsheng@627 3327 "followed by a username, this is always given the highest precedence."
dongsheng@627 3328 msgstr ""
dongsheng@627 3329
dongsheng@627 3330 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 3331 #: ../en/ch01-tour-basic.xml:556
dongsheng@627 3332 msgid ""
dongsheng@627 3333 "If you have set the <envar>HGUSER</envar> environment variable, this is "
dongsheng@627 3334 "checked next."
dongsheng@627 3335 msgstr ""
dongsheng@627 3336
dongsheng@627 3337 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 3338 #: ../en/ch01-tour-basic.xml:559
dongsheng@627 3339 msgid ""
dongsheng@627 3340 "If you create a file in your home directory called <filename role=\"special"
dongsheng@627 3341 "\">.hgrc</filename>, with a <envar role=\"rc-item-ui\">username</envar> "
dongsheng@627 3342 "entry, that will be used next. To see what the contents of this file should "
songdongsheng@658 3343 "look like, refer to <xref linkend=\"sec:tour-basic:username\"/> below."
dongsheng@627 3344 msgstr ""
dongsheng@627 3345
dongsheng@627 3346 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 3347 #: ../en/ch01-tour-basic.xml:567
dongsheng@627 3348 msgid ""
dongsheng@627 3349 "If you have set the <envar>EMAIL</envar> environment variable, this will be "
dongsheng@627 3350 "used next."
dongsheng@627 3351 msgstr ""
dongsheng@627 3352
dongsheng@627 3353 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@667 3354 #: ../en/ch01-tour-basic.xml:570
dongsheng@627 3355 msgid ""
dongsheng@627 3356 "Mercurial will query your system to find out your local user name and host "
dongsheng@627 3357 "name, and construct a username from these components. Since this often "
dongsheng@627 3358 "results in a username that is not very useful, it will print a warning if it "
dongsheng@627 3359 "has to do this."
dongsheng@627 3360 msgstr ""
dongsheng@627 3361
dongsheng@627 3362 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3363 #: ../en/ch01-tour-basic.xml:577
dongsheng@627 3364 msgid ""
dongsheng@627 3365 "If all of these mechanisms fail, Mercurial will fail, printing an error "
dongsheng@627 3366 "message. In this case, it will not let you commit until you set up a "
dongsheng@627 3367 "username."
dongsheng@627 3368 msgstr ""
dongsheng@627 3369
dongsheng@627 3370 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3371 #: ../en/ch01-tour-basic.xml:581
dongsheng@627 3372 msgid ""
dongsheng@627 3373 "You should think of the <envar>HGUSER</envar> environment variable and the "
dongsheng@627 3374 "<option role=\"hg-opt-commit\">-u</option> option to the <command role=\"hg-"
dongsheng@627 3375 "cmd\">hg commit</command> command as ways to <emphasis>override</emphasis> "
dongsheng@627 3376 "Mercurial's default selection of username. For normal use, the simplest and "
dongsheng@627 3377 "most robust way to set a username for yourself is by creating a <filename "
dongsheng@627 3378 "role=\"special\">.hgrc</filename> file; see below for details."
dongsheng@627 3379 msgstr ""
dongsheng@627 3380
dongsheng@627 3381 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@667 3382 #: ../en/ch01-tour-basic.xml:590
dongsheng@627 3383 msgid "Creating a Mercurial configuration file"
dongsheng@627 3384 msgstr "创建 Mercurial 的配置文件"
dongsheng@627 3385
dongsheng@627 3386 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@667 3387 #: ../en/ch01-tour-basic.xml:592
dongsheng@627 3388 msgid ""
dongsheng@627 3389 "To set a user name, use your favourite editor to create a file called "
dongsheng@627 3390 "<filename role=\"special\">.hgrc</filename> in your home directory. "
dongsheng@627 3391 "Mercurial will use this file to look up your personalised configuration "
dongsheng@627 3392 "settings. The initial contents of your <filename role=\"special\">.hgrc</"
dongsheng@627 3393 "filename> should look like this."
dongsheng@627 3394 msgstr ""
dongsheng@627 3395
songdongsheng@667 3396 #. type: Content of: <book><chapter><sect1><sect2><sect3><remark>
songdongsheng@667 3397 #: ../en/ch01-tour-basic.xml:600
songdongsheng@667 3398 msgid "Figure out what the appropriate directory is on Windows."
songdongsheng@667 3399 msgstr ""
songdongsheng@667 3400
dongsheng@627 3401 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@667 3402 #: ../en/ch01-tour-basic.xml:607
dongsheng@627 3403 msgid ""
dongsheng@627 3404 "The <quote><literal>[ui]</literal></quote> line begins a <emphasis>section</"
dongsheng@627 3405 "emphasis> of the config file, so you can read the <quote><literal>username "
dongsheng@627 3406 "= ...</literal></quote> line as meaning <quote>set the value of the "
dongsheng@627 3407 "<literal>username</literal> item in the <literal>ui</literal> section</"
dongsheng@627 3408 "quote>. A section continues until a new section begins, or the end of the "
dongsheng@627 3409 "file. Mercurial ignores empty lines and treats any text from "
dongsheng@627 3410 "<quote><literal>#</literal></quote> to the end of a line as a comment."
dongsheng@627 3411 msgstr ""
dongsheng@627 3412
dongsheng@627 3413 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@667 3414 #: ../en/ch01-tour-basic.xml:620
dongsheng@627 3415 msgid "Choosing a user name"
dongsheng@627 3416 msgstr "选择用户名称"
dongsheng@627 3417
dongsheng@627 3418 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@667 3419 #: ../en/ch01-tour-basic.xml:622
dongsheng@627 3420 msgid ""
dongsheng@627 3421 "You can use any text you like as the value of the <literal>username</literal> "
songdongsheng@667 3422 "config item, since this information is for reading by other people, but will "
songdongsheng@667 3423 "not be interpreted by Mercurial. The convention that most people follow is "
songdongsheng@667 3424 "to use their name and email address, as in the example above."
dongsheng@627 3425 msgstr ""
dongsheng@627 3426
dongsheng@627 3427 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
songdongsheng@667 3428 #: ../en/ch01-tour-basic.xml:629
dongsheng@627 3429 msgid ""
dongsheng@627 3430 "Mercurial's built-in web server obfuscates email addresses, to make it more "
dongsheng@627 3431 "difficult for the email harvesting tools that spammers use. This reduces the "
dongsheng@627 3432 "likelihood that you'll start receiving more junk email if you publish a "
dongsheng@627 3433 "Mercurial repository on the web."
dongsheng@627 3434 msgstr ""
dongsheng@627 3435
dongsheng@627 3436 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3437 #: ../en/ch01-tour-basic.xml:639
dongsheng@627 3438 msgid "Writing a commit message"
dongsheng@627 3439 msgstr "写提交日志"
dongsheng@627 3440
dongsheng@627 3441 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3442 #: ../en/ch01-tour-basic.xml:641
dongsheng@627 3443 msgid ""
dongsheng@627 3444 "When we commit a change, Mercurial drops us into a text editor, to enter a "
dongsheng@627 3445 "message that will describe the modifications we've made in this changeset. "
dongsheng@627 3446 "This is called the <emphasis>commit message</emphasis>. It will be a record "
dongsheng@627 3447 "for readers of what we did and why, and it will be printed by <command role="
dongsheng@627 3448 "\"hg-cmd\">hg log</command> after we've finished committing."
dongsheng@627 3449 msgstr ""
dongsheng@627 3450
dongsheng@627 3451 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3452 #: ../en/ch01-tour-basic.xml:651
dongsheng@627 3453 msgid ""
dongsheng@627 3454 "The editor that the <command role=\"hg-cmd\">hg commit</command> command "
songdongsheng@667 3455 "drops us into will contain an empty line or two, followed by a number of "
songdongsheng@667 3456 "lines starting with <quote><literal>HG:</literal></quote>."
songdongsheng@667 3457 msgstr ""
songdongsheng@667 3458
songdongsheng@667 3459 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3460 #: ../en/ch01-tour-basic.xml:665
dongsheng@627 3461 msgid ""
dongsheng@627 3462 "Mercurial ignores the lines that start with <quote><literal>HG:</literal></"
dongsheng@627 3463 "quote>; it uses them only to tell us which files it's recording changes to. "
dongsheng@627 3464 "Modifying or deleting these lines has no effect."
dongsheng@627 3465 msgstr ""
dongsheng@627 3466
dongsheng@627 3467 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3468 #: ../en/ch01-tour-basic.xml:671
dongsheng@627 3469 msgid "Writing a good commit message"
dongsheng@627 3470 msgstr "写好提交日志"
dongsheng@627 3471
dongsheng@627 3472 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3473 #: ../en/ch01-tour-basic.xml:673
dongsheng@627 3474 msgid ""
dongsheng@627 3475 "Since <command role=\"hg-cmd\">hg log</command> only prints the first line of "
dongsheng@627 3476 "a commit message by default, it's best to write a commit message whose first "
dongsheng@627 3477 "line stands alone. Here's a real example of a commit message that "
dongsheng@627 3478 "<emphasis>doesn't</emphasis> follow this guideline, and hence has a summary "
dongsheng@627 3479 "that is not readable."
dongsheng@627 3480 msgstr ""
dongsheng@627 3481
dongsheng@627 3482 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3483 #: ../en/ch01-tour-basic.xml:687
dongsheng@627 3484 msgid ""
dongsheng@627 3485 "As far as the remainder of the contents of the commit message are concerned, "
dongsheng@627 3486 "there are no hard-and-fast rules. Mercurial itself doesn't interpret or care "
dongsheng@627 3487 "about the contents of the commit message, though your project may have "
dongsheng@627 3488 "policies that dictate a certain kind of formatting."
dongsheng@627 3489 msgstr ""
dongsheng@627 3490
dongsheng@627 3491 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3492 #: ../en/ch01-tour-basic.xml:693
dongsheng@627 3493 msgid ""
dongsheng@627 3494 "My personal preference is for short, but informative, commit messages that "
dongsheng@627 3495 "tell me something that I can't figure out with a quick glance at the output "
dongsheng@627 3496 "of <command role=\"hg-cmd\">hg log --patch</command>."
dongsheng@627 3497 msgstr ""
dongsheng@627 3498
dongsheng@627 3499 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3500 #: ../en/ch01-tour-basic.xml:700
dongsheng@627 3501 msgid "Aborting a commit"
dongsheng@627 3502 msgstr "终止提交"
dongsheng@627 3503
dongsheng@627 3504 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3505 #: ../en/ch01-tour-basic.xml:702
dongsheng@627 3506 msgid ""
dongsheng@627 3507 "If you decide that you don't want to commit while in the middle of editing a "
dongsheng@627 3508 "commit message, simply exit from your editor without saving the file that "
dongsheng@627 3509 "it's editing. This will cause nothing to happen to either the repository or "
dongsheng@627 3510 "the working directory."
dongsheng@627 3511 msgstr ""
dongsheng@627 3512
dongsheng@627 3513 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3514 #: ../en/ch01-tour-basic.xml:707
dongsheng@627 3515 msgid ""
dongsheng@627 3516 "If we run the <command role=\"hg-cmd\">hg commit</command> command without "
dongsheng@627 3517 "any arguments, it records all of the changes we've made, as reported by "
dongsheng@627 3518 "<command role=\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg "
dongsheng@627 3519 "diff</command>."
dongsheng@627 3520 msgstr ""
dongsheng@627 3521
dongsheng@627 3522 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3523 #: ../en/ch01-tour-basic.xml:714
dongsheng@627 3524 msgid "Admiring our new handiwork"
songdongsheng@665 3525 msgstr "欣赏我们的成果"
dongsheng@627 3526
dongsheng@627 3527 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3528 #: ../en/ch01-tour-basic.xml:716
dongsheng@627 3529 msgid ""
dongsheng@627 3530 "Once we've finished the commit, we can use the <command role=\"hg-cmd\">hg "
dongsheng@627 3531 "tip</command> command to display the changeset we just created. This command "
dongsheng@627 3532 "produces output that is identical to <command role=\"hg-cmd\">hg log</"
dongsheng@627 3533 "command>, but it only displays the newest revision in the repository."
dongsheng@627 3534 msgstr ""
dongsheng@627 3535
dongsheng@627 3536 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3537 #: ../en/ch01-tour-basic.xml:725
songdongsheng@667 3538 msgid ""
songdongsheng@667 3539 "We refer to the newest revision in the repository as the <emphasis>tip "
songdongsheng@667 3540 "revision</emphasis>, or simply the <emphasis>tip</emphasis>."
songdongsheng@667 3541 msgstr ""
songdongsheng@667 3542
songdongsheng@667 3543 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3544 #: ../en/ch01-tour-basic.xml:729
songdongsheng@667 3545 msgid ""
songdongsheng@667 3546 "By the way, the <command role=\"hg-cmd\">hg tip</command> command accepts "
songdongsheng@667 3547 "many of the same options as <command role=\"hg-cmd\">hg log</command>, so "
songdongsheng@667 3548 "<option role=\"hg-opt-global\">-v</option> above indicates <quote>be verbose</"
songdongsheng@667 3549 "quote>, <option role=\"hg-opt-tip\">-p</option> specifies <quote>print a "
songdongsheng@667 3550 "patch</quote>. The use of <option role=\"hg-opt-tip\">-p</option> to print "
songdongsheng@667 3551 "patches is another example of the consistent naming we mentioned earlier."
dongsheng@627 3552 msgstr ""
dongsheng@627 3553
dongsheng@627 3554 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@667 3555 #: ../en/ch01-tour-basic.xml:741
dongsheng@627 3556 msgid "Sharing changes"
dongsheng@627 3557 msgstr "共享修改"
dongsheng@627 3558
dongsheng@627 3559 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@667 3560 #: ../en/ch01-tour-basic.xml:743
dongsheng@627 3561 msgid ""
dongsheng@627 3562 "We mentioned earlier that repositories in Mercurial are self-contained. This "
dongsheng@627 3563 "means that the changeset we just created exists only in our <filename class="
dongsheng@627 3564 "\"directory\">my-hello</filename> repository. Let's look at a few ways that "
dongsheng@627 3565 "we can propagate this change into other repositories."
dongsheng@627 3566 msgstr ""
dongsheng@627 3567
dongsheng@627 3568 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3569 #: ../en/ch01-tour-basic.xml:751
dongsheng@627 3570 msgid "Pulling changes from another repository"
dongsheng@627 3571 msgstr "从其它版本库取得修改"
dongsheng@627 3572
dongsheng@627 3573 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3574 #: ../en/ch01-tour-basic.xml:752
dongsheng@627 3575 msgid ""
dongsheng@627 3576 "To get started, let's clone our original <filename class=\"directory\">hello</"
dongsheng@627 3577 "filename> repository, which does not contain the change we just committed. "
dongsheng@627 3578 "We'll call our temporary repository <filename class=\"directory\">hello-pull</"
dongsheng@627 3579 "filename>."
dongsheng@627 3580 msgstr ""
dongsheng@627 3581
dongsheng@627 3582 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3583 #: ../en/ch01-tour-basic.xml:760
dongsheng@627 3584 msgid ""
dongsheng@627 3585 "We'll use the <command role=\"hg-cmd\">hg pull</command> command to bring "
dongsheng@627 3586 "changes from <filename class=\"directory\">my-hello</filename> into <filename "
dongsheng@627 3587 "class=\"directory\">hello-pull</filename>. However, blindly pulling unknown "
dongsheng@627 3588 "changes into a repository is a somewhat scary prospect. Mercurial provides "
dongsheng@627 3589 "the <command role=\"hg-cmd\">hg incoming</command> command to tell us what "
dongsheng@627 3590 "changes the <command role=\"hg-cmd\">hg pull</command> command "
dongsheng@627 3591 "<emphasis>would</emphasis> pull into the repository, without actually pulling "
dongsheng@627 3592 "the changes in."
dongsheng@627 3593 msgstr ""
dongsheng@627 3594
dongsheng@627 3595 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3596 #: ../en/ch01-tour-basic.xml:773
songdongsheng@667 3597 msgid ""
songdongsheng@667 3598 "Suppose you're pulling changes from a repository on the network somewhere. "
songdongsheng@667 3599 "While you are looking at the <command role=\"hg-cmd\">hg incoming</command> "
songdongsheng@667 3600 "output, and before you pull those changes, someone might have committed "
songdongsheng@667 3601 "something in the remote repository. This means that it's possible to pull "
songdongsheng@667 3602 "more changes than you saw when using <command role=\"hg-cmd\">hg incoming</"
songdongsheng@667 3603 "command>."
songdongsheng@667 3604 msgstr ""
songdongsheng@667 3605
songdongsheng@667 3606 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3607 #: ../en/ch01-tour-basic.xml:781
dongsheng@627 3608 msgid ""
dongsheng@627 3609 "Bringing changes into a repository is a simple matter of running the <command "
dongsheng@627 3610 "role=\"hg-cmd\">hg pull</command> command, and telling it which repository to "
dongsheng@627 3611 "pull from."
dongsheng@627 3612 msgstr ""
dongsheng@627 3613
dongsheng@627 3614 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3615 #: ../en/ch01-tour-basic.xml:788
dongsheng@627 3616 msgid ""
dongsheng@627 3617 "As you can see from the before-and-after output of <command role=\"hg-cmd"
dongsheng@627 3618 "\">hg tip</command>, we have successfully pulled changes into our "
dongsheng@627 3619 "repository. There remains one step before we can see these changes in the "
dongsheng@627 3620 "working directory."
dongsheng@627 3621 msgstr ""
dongsheng@627 3622
dongsheng@627 3623 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3624 #: ../en/ch01-tour-basic.xml:796
dongsheng@627 3625 msgid "Updating the working directory"
dongsheng@627 3626 msgstr "更新工作目录"
dongsheng@627 3627
dongsheng@627 3628 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3629 #: ../en/ch01-tour-basic.xml:798
dongsheng@627 3630 msgid ""
dongsheng@627 3631 "We have so far glossed over the relationship between a repository and its "
dongsheng@627 3632 "working directory. The <command role=\"hg-cmd\">hg pull</command> command "
songdongsheng@658 3633 "that we ran in <xref linkend=\"sec:tour:pull\"/> brought changes into the "
songdongsheng@658 3634 "repository, but if we check, there's no sign of those changes in the working "
songdongsheng@658 3635 "directory. This is because <command role=\"hg-cmd\">hg pull</command> does "
songdongsheng@658 3636 "not (by default) touch the working directory. Instead, we use the <command "
songdongsheng@658 3637 "role=\"hg-cmd\">hg update</command> command to do this."
songdongsheng@658 3638 msgstr ""
songdongsheng@658 3639
songdongsheng@658 3640 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3641 #: ../en/ch01-tour-basic.xml:810
dongsheng@627 3642 msgid ""
dongsheng@627 3643 "It might seem a bit strange that <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 3644 "doesn't update the working directory automatically. There's actually a good "
dongsheng@627 3645 "reason for this: you can use <command role=\"hg-cmd\">hg update</command> to "
dongsheng@627 3646 "update the working directory to the state it was in at <emphasis>any "
dongsheng@627 3647 "revision</emphasis> in the history of the repository. If you had the working "
songdongsheng@667 3648 "directory updated to an old revision—to hunt down the origin of a bug, say—"
songdongsheng@667 3649 "and ran a <command role=\"hg-cmd\">hg pull</command> which automatically "
songdongsheng@667 3650 "updated the working directory to a new revision, you might not be terribly "
songdongsheng@667 3651 "happy."
songdongsheng@667 3652 msgstr ""
songdongsheng@667 3653
songdongsheng@667 3654 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3655 #: ../en/ch01-tour-basic.xml:821
dongsheng@627 3656 msgid ""
dongsheng@627 3657 "However, since pull-then-update is such a common thing to do, Mercurial lets "
dongsheng@627 3658 "you combine the two by passing the <option role=\"hg-opt-pull\">-u</option> "
dongsheng@627 3659 "option to <command role=\"hg-cmd\">hg pull</command>."
dongsheng@627 3660 msgstr ""
dongsheng@627 3661
dongsheng@627 3662 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3663 #: ../en/ch01-tour-basic.xml:826
dongsheng@627 3664 msgid ""
dongsheng@627 3665 "If you look back at the output of <command role=\"hg-cmd\">hg pull</command> "
songdongsheng@658 3666 "in <xref linkend=\"sec:tour:pull\"/> when we ran it without <option role=\"hg-"
songdongsheng@658 3667 "opt-pull\">-u</option>, you can see that it printed a helpful reminder that "
songdongsheng@658 3668 "we'd have to take an explicit step to update the working directory:"
songdongsheng@658 3669 msgstr ""
songdongsheng@658 3670
songdongsheng@658 3671 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3672 #: ../en/ch01-tour-basic.xml:835
dongsheng@627 3673 msgid ""
dongsheng@627 3674 "To find out what revision the working directory is at, use the <command role="
dongsheng@627 3675 "\"hg-cmd\">hg parents</command> command."
dongsheng@627 3676 msgstr ""
dongsheng@627 3677
dongsheng@627 3678 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3679 #: ../en/ch01-tour-basic.xml:841
songdongsheng@658 3680 msgid ""
songdongsheng@658 3681 "If you look back at <xref linkend=\"fig:tour-basic:history\"/>, you'll see "
songdongsheng@658 3682 "arrows connecting each changeset. The node that the arrow leads "
songdongsheng@658 3683 "<emphasis>from</emphasis> in each case is a parent, and the node that the "
songdongsheng@658 3684 "arrow leads <emphasis>to</emphasis> is its child. The working directory has "
songdongsheng@658 3685 "a parent in just the same way; this is the changeset that the working "
songdongsheng@658 3686 "directory currently contains."
songdongsheng@658 3687 msgstr ""
songdongsheng@658 3688
songdongsheng@658 3689 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3690 #: ../en/ch01-tour-basic.xml:850
dongsheng@627 3691 msgid ""
dongsheng@627 3692 "To update the working directory to a particular revision, give a revision "
dongsheng@627 3693 "number or changeset ID to the <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 3694 "command."
dongsheng@627 3695 msgstr ""
dongsheng@627 3696
dongsheng@627 3697 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3698 #: ../en/ch01-tour-basic.xml:857
dongsheng@627 3699 msgid ""
dongsheng@627 3700 "If you omit an explicit revision, <command role=\"hg-cmd\">hg update</"
dongsheng@627 3701 "command> will update to the tip revision, as shown by the second call to "
dongsheng@627 3702 "<command role=\"hg-cmd\">hg update</command> in the example above."
dongsheng@627 3703 msgstr ""
dongsheng@627 3704
dongsheng@627 3705 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3706 #: ../en/ch01-tour-basic.xml:865
dongsheng@627 3707 msgid "Pushing changes to another repository"
dongsheng@627 3708 msgstr "发布修改到其它版本库"
dongsheng@627 3709
dongsheng@627 3710 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3711 #: ../en/ch01-tour-basic.xml:867
dongsheng@627 3712 msgid ""
dongsheng@627 3713 "Mercurial lets us push changes to another repository, from the repository "
dongsheng@627 3714 "we're currently visiting. As with the example of <command role=\"hg-cmd\">hg "
dongsheng@627 3715 "pull</command> above, we'll create a temporary repository to push our changes "
dongsheng@627 3716 "into."
dongsheng@627 3717 msgstr ""
dongsheng@627 3718
dongsheng@627 3719 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3720 #: ../en/ch01-tour-basic.xml:875
dongsheng@627 3721 msgid ""
dongsheng@627 3722 "The <command role=\"hg-cmd\">hg outgoing</command> command tells us what "
dongsheng@627 3723 "changes would be pushed into another repository."
dongsheng@627 3724 msgstr ""
dongsheng@627 3725
dongsheng@627 3726 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3727 #: ../en/ch01-tour-basic.xml:881
dongsheng@627 3728 msgid ""
dongsheng@627 3729 "And the <command role=\"hg-cmd\">hg push</command> command does the actual "
dongsheng@627 3730 "push."
dongsheng@627 3731 msgstr ""
dongsheng@627 3732
dongsheng@627 3733 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3734 #: ../en/ch01-tour-basic.xml:887
dongsheng@627 3735 msgid ""
dongsheng@627 3736 "As with <command role=\"hg-cmd\">hg pull</command>, the <command role=\"hg-cmd"
dongsheng@627 3737 "\">hg push</command> command does not update the working directory in the "
songdongsheng@667 3738 "repository that it's pushing changes into. Unlike <command role=\"hg-cmd\">hg "
songdongsheng@667 3739 "pull</command>, <command role=\"hg-cmd\">hg push</command> does not provide a "
songdongsheng@667 3740 "<literal>-u</literal> option that updates the other repository's working "
songdongsheng@667 3741 "directory. This asymmetry is deliberate: the repository we're pushing to "
songdongsheng@667 3742 "might be on a remote server and shared between several people. If we were to "
songdongsheng@667 3743 "update its working directory while someone was working in it, their work "
songdongsheng@667 3744 "would be disrupted."
songdongsheng@667 3745 msgstr ""
songdongsheng@667 3746
songdongsheng@667 3747 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3748 #: ../en/ch01-tour-basic.xml:899
dongsheng@627 3749 msgid ""
dongsheng@627 3750 "What happens if we try to pull or push changes and the receiving repository "
dongsheng@627 3751 "already has those changes? Nothing too exciting."
dongsheng@627 3752 msgstr ""
dongsheng@627 3753
dongsheng@627 3754 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@667 3755 #: ../en/ch01-tour-basic.xml:906
dongsheng@627 3756 msgid "Sharing changes over a network"
dongsheng@627 3757 msgstr "通过网络共享修改"
dongsheng@627 3758
dongsheng@627 3759 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3760 #: ../en/ch01-tour-basic.xml:908
dongsheng@627 3761 msgid ""
dongsheng@627 3762 "The commands we have covered in the previous few sections are not limited to "
dongsheng@627 3763 "working with local repositories. Each works in exactly the same fashion over "
dongsheng@627 3764 "a network connection; simply pass in a URL instead of a local path."
dongsheng@627 3765 msgstr ""
dongsheng@627 3766
dongsheng@627 3767 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@667 3768 #: ../en/ch01-tour-basic.xml:916
dongsheng@627 3769 msgid ""
dongsheng@627 3770 "In this example, we can see what changes we could push to the remote "
dongsheng@627 3771 "repository, but the repository is understandably not set up to let anonymous "
dongsheng@627 3772 "users push to it."
dongsheng@627 3773 msgstr ""
dongsheng@627 3774
dongsheng@627 3775 #. type: Content of: <book><chapter><title>
dongsheng@650 3776 #: ../en/ch02-tour-merge.xml:5
dongsheng@627 3777 msgid "A tour of Mercurial: merging work"
dongsheng@627 3778 msgstr "Mercurial 教程: 合并工作"
dongsheng@627 3779
dongsheng@627 3780 #. type: Content of: <book><chapter><para>
dongsheng@650 3781 #: ../en/ch02-tour-merge.xml:7
dongsheng@627 3782 msgid ""
dongsheng@627 3783 "We've now covered cloning a repository, making changes in a repository, and "
dongsheng@627 3784 "pulling or pushing changes from one repository into another. Our next step "
dongsheng@627 3785 "is <emphasis>merging</emphasis> changes from separate repositories."
dongsheng@627 3786 msgstr ""
dongsheng@627 3787
dongsheng@627 3788 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 3789 #: ../en/ch02-tour-merge.xml:13
dongsheng@627 3790 msgid "Merging streams of work"
dongsheng@627 3791 msgstr "合并的流程"
dongsheng@627 3792
dongsheng@627 3793 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 3794 #: ../en/ch02-tour-merge.xml:15
dongsheng@627 3795 msgid ""
dongsheng@627 3796 "Merging is a fundamental part of working with a distributed revision control "
dongsheng@627 3797 "tool."
dongsheng@627 3798 msgstr ""
dongsheng@627 3799
dongsheng@627 3800 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 3801 #: ../en/ch02-tour-merge.xml:18
dongsheng@627 3802 msgid ""
dongsheng@627 3803 "Alice and Bob each have a personal copy of a repository for a project they're "
dongsheng@627 3804 "collaborating on. Alice fixes a bug in her repository; Bob adds a new "
dongsheng@627 3805 "feature in his. They want the shared repository to contain both the bug fix "
dongsheng@627 3806 "and the new feature."
dongsheng@627 3807 msgstr ""
dongsheng@627 3808
dongsheng@627 3809 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 3810 #: ../en/ch02-tour-merge.xml:24
dongsheng@627 3811 msgid ""
dongsheng@627 3812 "I frequently work on several different tasks for a single project at once, "
dongsheng@627 3813 "each safely isolated in its own repository. Working this way means that I "
dongsheng@627 3814 "often need to merge one piece of my own work with another."
dongsheng@627 3815 msgstr ""
dongsheng@627 3816
dongsheng@627 3817 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 3818 #: ../en/ch02-tour-merge.xml:30
dongsheng@627 3819 msgid ""
dongsheng@627 3820 "Because merging is such a common thing to need to do, Mercurial makes it "
dongsheng@627 3821 "easy. Let's walk through the process. We'll begin by cloning yet another "
dongsheng@627 3822 "repository (see how often they spring up?) and making a change in it."
dongsheng@627 3823 msgstr ""
dongsheng@627 3824
dongsheng@627 3825 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 3826 #: ../en/ch02-tour-merge.xml:37
dongsheng@627 3827 msgid ""
dongsheng@627 3828 "We should now have two copies of <filename>hello.c</filename> with different "
dongsheng@627 3829 "contents. The histories of the two repositories have also diverged, as "
songdongsheng@658 3830 "illustrated in <xref linkend=\"fig:tour-merge:sep-repos\"/>."
songdongsheng@658 3831 msgstr ""
songdongsheng@658 3832
songdongsheng@658 3833 #. type: Content of: <book><chapter><sect1><figure><title>
songdongsheng@658 3834 #: ../en/ch02-tour-merge.xml:46
dongsheng@627 3835 msgid ""
dongsheng@627 3836 "Divergent recent histories of the <filename class=\"directory\">my-hello</"
dongsheng@627 3837 "filename> and <filename class=\"directory\">my-new-hello</filename> "
dongsheng@627 3838 "repositories"
dongsheng@627 3839 msgstr ""
dongsheng@660 3840 "<filename class=\"directory\">my-hello</filename> 与 <filename class="
dongsheng@660 3841 "\"directory\">my-new-hello</filename> 最新的历史分叉"
dongsheng@627 3842
songdongsheng@658 3843 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
songdongsheng@658 3844 #: ../en/ch02-tour-merge.xml:51
songdongsheng@658 3845 msgid ""
songdongsheng@658 3846 "<imageobject><imagedata fileref=\"figs/tour-merge-sep-repos.png\"/></"
songdongsheng@658 3847 "imageobject>"
songdongsheng@658 3848 msgstr ""
songdongsheng@658 3849
songdongsheng@658 3850 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3851 #: ../en/ch02-tour-merge.xml:56
dongsheng@627 3852 msgid ""
dongsheng@627 3853 "We already know that pulling changes from our <filename class=\"directory"
dongsheng@627 3854 "\">my-hello</filename> repository will have no effect on the working "
dongsheng@627 3855 "directory."
dongsheng@627 3856 msgstr ""
dongsheng@627 3857
dongsheng@627 3858 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 3859 #: ../en/ch02-tour-merge.xml:62
dongsheng@627 3860 msgid ""
dongsheng@627 3861 "However, the <command role=\"hg-cmd\">hg pull</command> command says "
dongsheng@627 3862 "something about <quote>heads</quote>."
dongsheng@627 3863 msgstr ""
dongsheng@627 3864
dongsheng@627 3865 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 3866 #: ../en/ch02-tour-merge.xml:66
dongsheng@627 3867 msgid "Head changesets"
songdongsheng@665 3868 msgstr "顶点修改集"
dongsheng@627 3869
dongsheng@627 3870 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3871 #: ../en/ch02-tour-merge.xml:68
dongsheng@627 3872 msgid ""
dongsheng@627 3873 "A head is a change that has no descendants, or children, as they're also "
dongsheng@627 3874 "known. The tip revision is thus a head, because the newest revision in a "
dongsheng@627 3875 "repository doesn't have any children, but a repository can contain more than "
dongsheng@627 3876 "one head."
dongsheng@627 3877 msgstr ""
dongsheng@627 3878
songdongsheng@658 3879 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 3880 #: ../en/ch02-tour-merge.xml:75
dongsheng@627 3881 msgid ""
dongsheng@627 3882 "Repository contents after pulling from <filename class=\"directory\">my-"
dongsheng@627 3883 "hello</filename> into <filename class=\"directory\">my-new-hello</filename>"
dongsheng@627 3884 msgstr ""
dongsheng@660 3885 "从 <filename class=\"directory\">my-hello</filename> 拉到 <filename class="
dongsheng@660 3886 "\"directory\">my-new-hello</filename> 之后版本库的内容"
dongsheng@627 3887
songdongsheng@658 3888 #. type: Content of: <book><chapter><sect1><sect2><figure>
songdongsheng@658 3889 #: ../en/ch02-tour-merge.xml:78 ../en/ch02-tour-merge.xml:125
songdongsheng@658 3890 #: ../en/ch02-tour-merge.xml:250 ../en/ch03-concepts.xml:55
songdongsheng@658 3891 #: ../en/ch03-concepts.xml:104 ../en/ch03-concepts.xml:189
songdongsheng@658 3892 #: ../en/ch03-concepts.xml:344 ../en/ch03-concepts.xml:359
songdongsheng@658 3893 #: ../en/ch03-concepts.xml:400 ../en/ch03-concepts.xml:420
songdongsheng@658 3894 #: ../en/ch03-concepts.xml:461 ../en/ch05-collab.xml:274
songdongsheng@658 3895 #: ../en/ch08-undo.xml:363 ../en/ch08-undo.xml:410 ../en/ch08-undo.xml:475
songdongsheng@658 3896 #: ../en/ch08-undo.xml:513 ../en/ch11-mq.xml:410
songdongsheng@658 3897 msgid " <placeholder type=\"mediaobject\" id=\"0\"/>"
songdongsheng@658 3898 msgstr ""
songdongsheng@658 3899
songdongsheng@658 3900 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 3901 #: ../en/ch02-tour-merge.xml:79
songdongsheng@658 3902 msgid ""
songdongsheng@658 3903 "<imageobject> <imagedata fileref=\"figs/tour-merge-pull.png\"/> </imageobject>"
songdongsheng@658 3904 msgstr ""
songdongsheng@658 3905
songdongsheng@658 3906 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3907 #: ../en/ch02-tour-merge.xml:86
songdongsheng@658 3908 msgid ""
songdongsheng@658 3909 "In <xref linkend=\"fig:tour-merge:pull\"/>, you can see the effect of the "
songdongsheng@658 3910 "pull from <filename class=\"directory\">my-hello</filename> into <filename "
songdongsheng@658 3911 "class=\"directory\">my-new-hello</filename>. The history that was already "
songdongsheng@658 3912 "present in <filename class=\"directory\">my-new-hello</filename> is "
songdongsheng@658 3913 "untouched, but a new revision has been added. By referring to <xref linkend="
songdongsheng@658 3914 "\"fig:tour-merge:sep-repos\"/>, we can see that the <emphasis>changeset ID</"
songdongsheng@658 3915 "emphasis> remains the same in the new repository, but the <emphasis>revision "
songdongsheng@658 3916 "number</emphasis> has changed. (This, incidentally, is a fine example of why "
songdongsheng@658 3917 "it's not safe to use revision numbers when discussing changesets.) We can "
songdongsheng@658 3918 "view the heads in a repository using the <command role=\"hg-cmd\">hg heads</"
songdongsheng@658 3919 "command> command."
dongsheng@627 3920 msgstr ""
dongsheng@627 3921
dongsheng@627 3922 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 3923 #: ../en/ch02-tour-merge.xml:105
dongsheng@627 3924 msgid "Performing the merge"
dongsheng@627 3925 msgstr "执行合并"
dongsheng@627 3926
dongsheng@627 3927 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3928 #: ../en/ch02-tour-merge.xml:107
dongsheng@627 3929 msgid ""
dongsheng@627 3930 "What happens if we try to use the normal <command role=\"hg-cmd\">hg update</"
dongsheng@627 3931 "command> command to update to the new tip?"
dongsheng@627 3932 msgstr ""
dongsheng@627 3933
dongsheng@627 3934 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3935 #: ../en/ch02-tour-merge.xml:113
dongsheng@627 3936 msgid ""
dongsheng@627 3937 "Mercurial is telling us that the <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 3938 "command won't do a merge; it won't update the working directory when it "
dongsheng@627 3939 "thinks we might be wanting to do a merge, unless we force it to do so. "
dongsheng@627 3940 "Instead, we use the <command role=\"hg-cmd\">hg merge</command> command to "
dongsheng@627 3941 "merge the two heads."
dongsheng@627 3942 msgstr ""
dongsheng@627 3943
songdongsheng@658 3944 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 3945 #: ../en/ch02-tour-merge.xml:123
songdongsheng@658 3946 msgid "Working directory and repository during merge, and following commit"
dongsheng@660 3947 msgstr "在合并期间,以及提交之后的工作目录与版本库"
songdongsheng@658 3948
songdongsheng@658 3949 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 3950 #: ../en/ch02-tour-merge.xml:126
songdongsheng@658 3951 msgid ""
songdongsheng@658 3952 "<imageobject> <imagedata fileref=\"figs/tour-merge-merge.png\"/> </"
dongsheng@627 3953 "imageobject>"
dongsheng@627 3954 msgstr ""
dongsheng@627 3955
songdongsheng@658 3956 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3957 #: ../en/ch02-tour-merge.xml:133
dongsheng@627 3958 msgid ""
dongsheng@627 3959 "This updates the working directory so that it contains changes from "
dongsheng@627 3960 "<emphasis>both</emphasis> heads, which is reflected in both the output of "
dongsheng@627 3961 "<command role=\"hg-cmd\">hg parents</command> and the contents of "
dongsheng@627 3962 "<filename>hello.c</filename>."
dongsheng@627 3963 msgstr ""
dongsheng@627 3964
dongsheng@627 3965 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 3966 #: ../en/ch02-tour-merge.xml:143
dongsheng@627 3967 msgid "Committing the results of the merge"
dongsheng@627 3968 msgstr "提交合并结果"
dongsheng@627 3969
dongsheng@627 3970 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3971 #: ../en/ch02-tour-merge.xml:145
dongsheng@627 3972 msgid ""
dongsheng@627 3973 "Whenever we've done a merge, <command role=\"hg-cmd\">hg parents</command> "
dongsheng@627 3974 "will display two parents until we <command role=\"hg-cmd\">hg commit</"
dongsheng@627 3975 "command> the results of the merge."
dongsheng@627 3976 msgstr ""
dongsheng@627 3977
dongsheng@627 3978 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3979 #: ../en/ch02-tour-merge.xml:152
dongsheng@627 3980 msgid ""
dongsheng@627 3981 "We now have a new tip revision; notice that it has <emphasis>both</emphasis> "
dongsheng@627 3982 "of our former heads as its parents. These are the same revisions that were "
dongsheng@627 3983 "previously displayed by <command role=\"hg-cmd\">hg parents</command>."
dongsheng@627 3984 msgstr ""
dongsheng@627 3985
dongsheng@627 3986 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 3987 #: ../en/ch02-tour-merge.xml:159
songdongsheng@658 3988 msgid ""
songdongsheng@658 3989 "In <xref linkend=\"fig:tour-merge:merge\"/>, you can see a representation of "
songdongsheng@658 3990 "what happens to the working directory during the merge, and how this affects "
songdongsheng@658 3991 "the repository when the commit happens. During the merge, the working "
songdongsheng@658 3992 "directory has two parent changesets, and these become the parents of the new "
songdongsheng@658 3993 "changeset."
dongsheng@627 3994 msgstr ""
dongsheng@627 3995
dongsheng@627 3996 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 3997 #: ../en/ch02-tour-merge.xml:170
dongsheng@627 3998 msgid "Merging conflicting changes"
dongsheng@627 3999 msgstr "合并有冲突的改变"
dongsheng@627 4000
dongsheng@627 4001 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4002 #: ../en/ch02-tour-merge.xml:172
dongsheng@627 4003 msgid ""
dongsheng@627 4004 "Most merges are simple affairs, but sometimes you'll find yourself merging "
dongsheng@627 4005 "changes where each modifies the same portions of the same files. Unless both "
dongsheng@627 4006 "modifications are identical, this results in a <emphasis>conflict</emphasis>, "
dongsheng@627 4007 "where you have to decide how to reconcile the different changes into "
dongsheng@627 4008 "something coherent."
dongsheng@627 4009 msgstr ""
dongsheng@627 4010
songdongsheng@658 4011 #. type: Content of: <book><chapter><sect1><figure><title>
dongsheng@650 4012 #: ../en/ch02-tour-merge.xml:180
songdongsheng@658 4013 msgid "Conflicting changes to a document"
dongsheng@660 4014 msgstr "冲突的修改"
songdongsheng@658 4015
songdongsheng@658 4016 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
songdongsheng@658 4017 #: ../en/ch02-tour-merge.xml:182
songdongsheng@658 4018 msgid ""
songdongsheng@658 4019 "<imageobject><imagedata fileref=\"figs/tour-merge-conflict.png\"/></"
dongsheng@627 4020 "imageobject>"
dongsheng@627 4021 msgstr ""
dongsheng@627 4022
songdongsheng@658 4023 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4024 #: ../en/ch02-tour-merge.xml:187
songdongsheng@658 4025 msgid ""
songdongsheng@658 4026 "<xref linkend=\"fig:tour-merge:conflict\"/> illustrates an instance of two "
songdongsheng@658 4027 "conflicting changes to a document. We started with a single version of the "
songdongsheng@658 4028 "file; then we made some changes; while someone else made different changes to "
songdongsheng@658 4029 "the same text. Our task in resolving the conflicting changes is to decide "
songdongsheng@658 4030 "what the file should look like."
songdongsheng@658 4031 msgstr ""
songdongsheng@658 4032
songdongsheng@658 4033 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4034 #: ../en/ch02-tour-merge.xml:194
dongsheng@627 4035 msgid ""
dongsheng@627 4036 "Mercurial doesn't have a built-in facility for handling conflicts. Instead, "
dongsheng@627 4037 "it runs an external program called <command>hgmerge</command>. This is a "
dongsheng@627 4038 "shell script that is bundled with Mercurial; you can change it to behave "
dongsheng@627 4039 "however you please. What it does by default is try to find one of several "
dongsheng@627 4040 "different merging tools that are likely to be installed on your system. It "
dongsheng@627 4041 "first tries a few fully automatic merging tools; if these don't succeed "
dongsheng@627 4042 "(because the resolution process requires human guidance) or aren't present, "
dongsheng@627 4043 "the script tries a few different graphical merging tools."
dongsheng@627 4044 msgstr ""
dongsheng@627 4045
dongsheng@627 4046 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4047 #: ../en/ch02-tour-merge.xml:205
dongsheng@627 4048 msgid ""
dongsheng@627 4049 "It's also possible to get Mercurial to run another program or script instead "
dongsheng@627 4050 "of <command>hgmerge</command>, by setting the <envar>HGMERGE</envar> "
dongsheng@627 4051 "environment variable to the name of your preferred program."
dongsheng@627 4052 msgstr ""
dongsheng@627 4053
dongsheng@627 4054 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4055 #: ../en/ch02-tour-merge.xml:211
dongsheng@627 4056 msgid "Using a graphical merge tool"
dongsheng@627 4057 msgstr "使用图形合并工具"
dongsheng@627 4058
dongsheng@627 4059 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4060 #: ../en/ch02-tour-merge.xml:213
dongsheng@627 4061 msgid ""
dongsheng@627 4062 "My preferred graphical merge tool is <command>kdiff3</command>, which I'll "
dongsheng@627 4063 "use to describe the features that are common to graphical file merging "
dongsheng@627 4064 "tools. You can see a screenshot of <command>kdiff3</command> in action in "
songdongsheng@658 4065 "<xref linkend=\"fig:tour-merge:kdiff3\"/>. The kind of merge it is "
songdongsheng@658 4066 "performing is called a <emphasis>three-way merge</emphasis>, because there "
songdongsheng@658 4067 "are three different versions of the file of interest to us. The tool thus "
songdongsheng@658 4068 "splits the upper portion of the window into three panes:"
dongsheng@627 4069 msgstr ""
dongsheng@627 4070
dongsheng@627 4071 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4072 #: ../en/ch02-tour-merge.xml:223
dongsheng@627 4073 msgid ""
dongsheng@627 4074 "At the left is the <emphasis>base</emphasis> version of the file, i.e. the "
dongsheng@627 4075 "most recent version from which the two versions we're trying to merge are "
dongsheng@627 4076 "descended."
dongsheng@627 4077 msgstr ""
dongsheng@627 4078
dongsheng@627 4079 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4080 #: ../en/ch02-tour-merge.xml:228
dongsheng@627 4081 msgid ""
dongsheng@627 4082 "In the middle is <quote>our</quote> version of the file, with the contents "
dongsheng@627 4083 "that we modified."
dongsheng@627 4084 msgstr ""
dongsheng@627 4085
dongsheng@627 4086 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4087 #: ../en/ch02-tour-merge.xml:231
dongsheng@627 4088 msgid ""
dongsheng@627 4089 "On the right is <quote>their</quote> version of the file, the one that from "
dongsheng@627 4090 "the changeset that we're trying to merge with."
dongsheng@627 4091 msgstr ""
dongsheng@627 4092
dongsheng@627 4093 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4094 #: ../en/ch02-tour-merge.xml:235
dongsheng@627 4095 msgid ""
dongsheng@627 4096 "In the pane below these is the current <emphasis>result</emphasis> of the "
dongsheng@627 4097 "merge. Our task is to replace all of the red text, which indicates unresolved "
dongsheng@627 4098 "conflicts, with some sensible merger of the <quote>ours</quote> and "
dongsheng@627 4099 "<quote>theirs</quote> versions of the file."
dongsheng@627 4100 msgstr ""
dongsheng@627 4101
dongsheng@627 4102 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4103 #: ../en/ch02-tour-merge.xml:242
dongsheng@627 4104 msgid ""
dongsheng@627 4105 "All four of these panes are <emphasis>locked together</emphasis>; if we "
dongsheng@627 4106 "scroll vertically or horizontally in any of them, the others are updated to "
dongsheng@627 4107 "display the corresponding sections of their respective files."
dongsheng@627 4108 msgstr ""
dongsheng@627 4109
songdongsheng@658 4110 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4111 #: ../en/ch02-tour-merge.xml:248
songdongsheng@658 4112 msgid "Using <command>kdiff3</command> to merge versions of a file"
dongsheng@660 4113 msgstr "使用 <command>kdiff3</command> 合并文件的不同版本"
songdongsheng@658 4114
songdongsheng@658 4115 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4116 #: ../en/ch02-tour-merge.xml:251
songdongsheng@658 4117 msgid ""
songdongsheng@658 4118 "<imageobject> <imagedata width=\"100%\" fileref=\"figs/kdiff3.png\"/></"
dongsheng@630 4119 "imageobject>"
dongsheng@627 4120 msgstr ""
dongsheng@627 4121
songdongsheng@658 4122 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4123 #: ../en/ch02-tour-merge.xml:259
dongsheng@627 4124 msgid ""
dongsheng@627 4125 "For each conflicting portion of the file, we can choose to resolve the "
dongsheng@627 4126 "conflict using some combination of text from the base version, ours, or "
dongsheng@627 4127 "theirs. We can also manually edit the merged file at any time, in case we "
dongsheng@627 4128 "need to make further modifications."
dongsheng@627 4129 msgstr ""
dongsheng@627 4130
dongsheng@627 4131 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4132 #: ../en/ch02-tour-merge.xml:265
dongsheng@627 4133 msgid ""
dongsheng@627 4134 "There are <emphasis>many</emphasis> file merging tools available, too many to "
dongsheng@627 4135 "cover here. They vary in which platforms they are available for, and in "
dongsheng@627 4136 "their particular strengths and weaknesses. Most are tuned for merging files "
dongsheng@627 4137 "containing plain text, while a few are aimed at specialised file formats "
dongsheng@627 4138 "(generally XML)."
dongsheng@627 4139 msgstr ""
dongsheng@627 4140
dongsheng@627 4141 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4142 #: ../en/ch02-tour-merge.xml:274
dongsheng@627 4143 msgid "A worked example"
dongsheng@627 4144 msgstr "合并实例"
dongsheng@627 4145
dongsheng@627 4146 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4147 #: ../en/ch02-tour-merge.xml:276
songdongsheng@658 4148 msgid ""
songdongsheng@658 4149 "In this example, we will reproduce the file modification history of <xref "
songdongsheng@658 4150 "linkend=\"fig:tour-merge:conflict\"/> above. Let's begin by creating a "
songdongsheng@658 4151 "repository with a base version of our document."
songdongsheng@658 4152 msgstr ""
songdongsheng@658 4153
songdongsheng@658 4154 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4155 #: ../en/ch02-tour-merge.xml:283
dongsheng@627 4156 msgid "We'll clone the repository and make a change to the file."
dongsheng@627 4157 msgstr ""
dongsheng@627 4158
dongsheng@627 4159 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4160 #: ../en/ch02-tour-merge.xml:288
dongsheng@627 4161 msgid ""
dongsheng@627 4162 "And another clone, to simulate someone else making a change to the file. "
dongsheng@627 4163 "(This hints at the idea that it's not all that unusual to merge with yourself "
dongsheng@627 4164 "when you isolate tasks in separate repositories, and indeed to find and "
dongsheng@627 4165 "resolve conflicts while doing so.)"
dongsheng@627 4166 msgstr ""
dongsheng@627 4167
dongsheng@627 4168 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4169 #: ../en/ch02-tour-merge.xml:296
dongsheng@627 4170 msgid ""
dongsheng@627 4171 "Having created two different versions of the file, we'll set up an "
dongsheng@627 4172 "environment suitable for running our merge."
dongsheng@627 4173 msgstr ""
dongsheng@627 4174
dongsheng@627 4175 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4176 #: ../en/ch02-tour-merge.xml:302
dongsheng@627 4177 msgid ""
dongsheng@627 4178 "In this example, I won't use Mercurial's normal <command>hgmerge</command> "
dongsheng@627 4179 "program to do the merge, because it would drop my nice automated example-"
dongsheng@627 4180 "running tool into a graphical user interface. Instead, I'll set "
dongsheng@627 4181 "<envar>HGMERGE</envar> to tell Mercurial to use the non-interactive "
dongsheng@627 4182 "<command>merge</command> command. This is bundled with many Unix-like "
dongsheng@627 4183 "systems. If you're following this example on your computer, don't bother "
dongsheng@627 4184 "setting <envar>HGMERGE</envar>."
dongsheng@627 4185 msgstr ""
dongsheng@627 4186
dongsheng@627 4187 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4188 #: ../en/ch02-tour-merge.xml:312
dongsheng@627 4189 msgid "<emphasis role=\"bold\">XXX FIX THIS EXAMPLE.</emphasis>"
dongsheng@627 4190 msgstr ""
dongsheng@627 4191
dongsheng@627 4192 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4193 #: ../en/ch02-tour-merge.xml:317
dongsheng@627 4194 msgid ""
dongsheng@627 4195 "Because <command>merge</command> can't resolve the conflicting changes, it "
dongsheng@627 4196 "leaves <emphasis>merge markers</emphasis> inside the file that has conflicts, "
dongsheng@627 4197 "indicating which lines have conflicts, and whether they came from our version "
dongsheng@627 4198 "of the file or theirs."
dongsheng@627 4199 msgstr ""
dongsheng@627 4200
dongsheng@627 4201 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4202 #: ../en/ch02-tour-merge.xml:323
dongsheng@627 4203 msgid ""
dongsheng@627 4204 "Mercurial can tell from the way <command>merge</command> exits that it wasn't "
dongsheng@627 4205 "able to merge successfully, so it tells us what commands we'll need to run if "
dongsheng@627 4206 "we want to redo the merging operation. This could be useful if, for example, "
dongsheng@627 4207 "we were running a graphical merge tool and quit because we were confused or "
dongsheng@627 4208 "realised we had made a mistake."
dongsheng@627 4209 msgstr ""
dongsheng@627 4210
dongsheng@627 4211 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4212 #: ../en/ch02-tour-merge.xml:330
dongsheng@627 4213 msgid ""
dongsheng@627 4214 "If automatic or manual merges fail, there's nothing to prevent us from "
dongsheng@627 4215 "<quote>fixing up</quote> the affected files ourselves, and committing the "
dongsheng@627 4216 "results of our merge:"
dongsheng@627 4217 msgstr ""
dongsheng@627 4218
dongsheng@627 4219 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 4220 #: ../en/ch02-tour-merge.xml:339
dongsheng@627 4221 msgid "Simplifying the pull-merge-commit sequence"
dongsheng@627 4222 msgstr "简化拉-合并-提交程序"
dongsheng@627 4223
dongsheng@627 4224 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4225 #: ../en/ch02-tour-merge.xml:341
dongsheng@627 4226 msgid ""
dongsheng@627 4227 "The process of merging changes as outlined above is straightforward, but "
dongsheng@627 4228 "requires running three commands in sequence."
dongsheng@627 4229 msgstr ""
dongsheng@627 4230
dongsheng@627 4231 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4232 #: ../en/ch02-tour-merge.xml:347
dongsheng@627 4233 msgid ""
dongsheng@627 4234 "In the case of the final commit, you also need to enter a commit message, "
dongsheng@627 4235 "which is almost always going to be a piece of uninteresting "
dongsheng@627 4236 "<quote>boilerplate</quote> text."
dongsheng@627 4237 msgstr ""
dongsheng@627 4238
dongsheng@627 4239 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4240 #: ../en/ch02-tour-merge.xml:351
dongsheng@627 4241 msgid ""
dongsheng@627 4242 "It would be nice to reduce the number of steps needed, if this were "
dongsheng@627 4243 "possible. Indeed, Mercurial is distributed with an extension called <literal "
dongsheng@627 4244 "role=\"hg-ext\">fetch</literal> that does just this."
dongsheng@627 4245 msgstr ""
dongsheng@627 4246
dongsheng@627 4247 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4248 #: ../en/ch02-tour-merge.xml:356
dongsheng@627 4249 msgid ""
dongsheng@627 4250 "Mercurial provides a flexible extension mechanism that lets people extend its "
dongsheng@627 4251 "functionality, while keeping the core of Mercurial small and easy to deal "
dongsheng@627 4252 "with. Some extensions add new commands that you can use from the command "
dongsheng@627 4253 "line, while others work <quote>behind the scenes,</quote> for example adding "
dongsheng@627 4254 "capabilities to the server."
dongsheng@627 4255 msgstr ""
dongsheng@627 4256
dongsheng@627 4257 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4258 #: ../en/ch02-tour-merge.xml:363
dongsheng@627 4259 msgid ""
dongsheng@627 4260 "The <literal role=\"hg-ext\">fetch</literal> extension adds a new command "
dongsheng@627 4261 "called, not surprisingly, <command role=\"hg-cmd\">hg fetch</command>. This "
dongsheng@627 4262 "extension acts as a combination of <command role=\"hg-cmd\">hg pull</"
dongsheng@627 4263 "command>, <command role=\"hg-cmd\">hg update</command> and <command role=\"hg-"
dongsheng@627 4264 "cmd\">hg merge</command>. It begins by pulling changes from another "
dongsheng@627 4265 "repository into the current repository. If it finds that the changes added a "
dongsheng@627 4266 "new head to the repository, it begins a merge, then commits the result of the "
dongsheng@627 4267 "merge with an automatically-generated commit message. If no new heads were "
dongsheng@627 4268 "added, it updates the working directory to the new tip changeset."
dongsheng@627 4269 msgstr ""
dongsheng@627 4270
dongsheng@627 4271 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4272 #: ../en/ch02-tour-merge.xml:376
dongsheng@627 4273 msgid ""
dongsheng@627 4274 "Enabling the <literal role=\"hg-ext\">fetch</literal> extension is easy. "
dongsheng@627 4275 "Edit your <filename role=\"special\">.hgrc</filename>, and either go to the "
dongsheng@627 4276 "<literal role=\"rc-extensions\">extensions</literal> section or create an "
dongsheng@627 4277 "<literal role=\"rc-extensions\">extensions</literal> section. Then add a line "
dongsheng@627 4278 "that simply reads <quote><literal>fetch </literal></quote>."
dongsheng@627 4279 msgstr ""
dongsheng@627 4280
dongsheng@627 4281 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4282 #: ../en/ch02-tour-merge.xml:385
dongsheng@627 4283 msgid ""
dongsheng@627 4284 "(Normally, on the right-hand side of the <quote><literal>=</literal></quote> "
dongsheng@627 4285 "would appear the location of the extension, but since the <literal role=\"hg-"
dongsheng@627 4286 "ext\">fetch</literal> extension is in the standard distribution, Mercurial "
dongsheng@627 4287 "knows where to search for it.)"
dongsheng@627 4288 msgstr ""
dongsheng@627 4289
dongsheng@627 4290 #. type: Content of: <book><chapter><title>
dongsheng@650 4291 #: ../en/ch03-concepts.xml:5
dongsheng@627 4292 msgid "Behind the scenes"
dongsheng@627 4293 msgstr "Mercurial 内幕"
dongsheng@627 4294
dongsheng@627 4295 #. type: Content of: <book><chapter><para>
dongsheng@650 4296 #: ../en/ch03-concepts.xml:7
dongsheng@627 4297 msgid ""
dongsheng@627 4298 "Unlike many revision control systems, the concepts upon which Mercurial is "
dongsheng@627 4299 "built are simple enough that it's easy to understand how the software really "
dongsheng@627 4300 "works. Knowing this certainly isn't necessary, but I find it useful to have "
dongsheng@627 4301 "a <quote>mental model</quote> of what's going on."
dongsheng@627 4302 msgstr ""
dongsheng@627 4303
dongsheng@627 4304 #. type: Content of: <book><chapter><para>
dongsheng@650 4305 #: ../en/ch03-concepts.xml:13
dongsheng@627 4306 msgid ""
dongsheng@627 4307 "This understanding gives me confidence that Mercurial has been carefully "
dongsheng@627 4308 "designed to be both <emphasis>safe</emphasis> and <emphasis>efficient</"
dongsheng@627 4309 "emphasis>. And just as importantly, if it's easy for me to retain a good "
dongsheng@627 4310 "idea of what the software is doing when I perform a revision control task, "
dongsheng@627 4311 "I'm less likely to be surprised by its behaviour."
dongsheng@627 4312 msgstr ""
dongsheng@627 4313
dongsheng@627 4314 #. type: Content of: <book><chapter><para>
dongsheng@650 4315 #: ../en/ch03-concepts.xml:20
dongsheng@627 4316 msgid ""
dongsheng@627 4317 "In this chapter, we'll initially cover the core concepts behind Mercurial's "
dongsheng@627 4318 "design, then continue to discuss some of the interesting details of its "
dongsheng@627 4319 "implementation."
dongsheng@627 4320 msgstr ""
dongsheng@627 4321
dongsheng@627 4322 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 4323 #: ../en/ch03-concepts.xml:25
dongsheng@627 4324 msgid "Mercurial's historical record"
dongsheng@627 4325 msgstr "Mercurial 的历史记录"
dongsheng@627 4326
dongsheng@627 4327 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 4328 #: ../en/ch03-concepts.xml:28
dongsheng@627 4329 msgid "Tracking the history of a single file"
dongsheng@627 4330 msgstr "跟踪单一文件的历史"
dongsheng@627 4331
dongsheng@627 4332 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 4333 #: ../en/ch03-concepts.xml:30
dongsheng@627 4334 msgid ""
dongsheng@627 4335 "When Mercurial tracks modifications to a file, it stores the history of that "
dongsheng@627 4336 "file in a metadata object called a <emphasis>filelog</emphasis>. Each entry "
dongsheng@627 4337 "in the filelog contains enough information to reconstruct one revision of the "
dongsheng@627 4338 "file that is being tracked. Filelogs are stored as files in the <filename "
dongsheng@627 4339 "role=\"special\" class=\"directory\">.hg/store/data</filename> directory. A "
dongsheng@627 4340 "filelog contains two kinds of information: revision data, and an index to "
dongsheng@627 4341 "help Mercurial to find a revision efficiently."
dongsheng@627 4342 msgstr ""
dongsheng@627 4343
dongsheng@627 4344 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 4345 #: ../en/ch03-concepts.xml:41
dongsheng@627 4346 msgid ""
dongsheng@627 4347 "A file that is large, or has a lot of history, has its filelog stored in "
dongsheng@627 4348 "separate data (<quote><literal>.d</literal></quote> suffix) and index "
dongsheng@627 4349 "(<quote><literal>.i</literal></quote> suffix) files. For small files without "
dongsheng@627 4350 "much history, the revision data and index are combined in a single "
dongsheng@627 4351 "<quote><literal>.i</literal></quote> file. The correspondence between a file "
dongsheng@627 4352 "in the working directory and the filelog that tracks its history in the "
songdongsheng@658 4353 "repository is illustrated in <xref linkend=\"fig:concepts:filelog\"/>."
songdongsheng@658 4354 msgstr ""
songdongsheng@658 4355
songdongsheng@658 4356 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4357 #: ../en/ch03-concepts.xml:53
dongsheng@627 4358 msgid ""
dongsheng@627 4359 "Relationships between files in working directory and filelogs in repository"
dongsheng@660 4360 msgstr "工作目录中的文件与版本库中的文件日志之间的关系"
dongsheng@627 4361
songdongsheng@658 4362 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4363 #: ../en/ch03-concepts.xml:56
songdongsheng@658 4364 msgid "<imageobject><imagedata fileref=\"figs/filelog.png\"/></imageobject>"
songdongsheng@658 4365 msgstr ""
songdongsheng@658 4366
dongsheng@627 4367 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4368 #: ../en/ch03-concepts.xml:63
dongsheng@627 4369 msgid "Managing tracked files"
dongsheng@627 4370 msgstr "管理跟踪的文件"
dongsheng@627 4371
dongsheng@627 4372 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4373 #: ../en/ch03-concepts.xml:65
dongsheng@627 4374 msgid ""
dongsheng@627 4375 "Mercurial uses a structure called a <emphasis>manifest</emphasis> to collect "
dongsheng@627 4376 "together information about the files that it tracks. Each entry in the "
dongsheng@627 4377 "manifest contains information about the files present in a single changeset. "
dongsheng@627 4378 "An entry records which files are present in the changeset, the revision of "
dongsheng@627 4379 "each file, and a few other pieces of file metadata."
dongsheng@627 4380 msgstr ""
dongsheng@627 4381
dongsheng@627 4382 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4383 #: ../en/ch03-concepts.xml:75
dongsheng@627 4384 msgid "Recording changeset information"
dongsheng@627 4385 msgstr "记录修改集信息"
dongsheng@627 4386
dongsheng@627 4387 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4388 #: ../en/ch03-concepts.xml:77
dongsheng@627 4389 msgid ""
dongsheng@627 4390 "The <emphasis>changelog</emphasis> contains information about each "
dongsheng@627 4391 "changeset. Each revision records who committed a change, the changeset "
dongsheng@627 4392 "comment, other pieces of changeset-related information, and the revision of "
dongsheng@627 4393 "the manifest to use."
dongsheng@627 4394 msgstr ""
dongsheng@627 4395
dongsheng@627 4396 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4397 #: ../en/ch03-concepts.xml:85
dongsheng@627 4398 msgid "Relationships between revisions"
dongsheng@627 4399 msgstr "版本之间的关系"
dongsheng@627 4400
dongsheng@627 4401 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4402 #: ../en/ch03-concepts.xml:87
dongsheng@627 4403 msgid ""
dongsheng@627 4404 "Within a changelog, a manifest, or a filelog, each revision stores a pointer "
dongsheng@627 4405 "to its immediate parent (or to its two parents, if it's a merge revision). "
dongsheng@627 4406 "As I mentioned above, there are also relationships between revisions "
dongsheng@627 4407 "<emphasis>across</emphasis> these structures, and they are hierarchical in "
dongsheng@627 4408 "nature."
dongsheng@627 4409 msgstr ""
dongsheng@627 4410
dongsheng@627 4411 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4412 #: ../en/ch03-concepts.xml:94
dongsheng@627 4413 msgid ""
dongsheng@627 4414 "For every changeset in a repository, there is exactly one revision stored in "
dongsheng@627 4415 "the changelog. Each revision of the changelog contains a pointer to a single "
dongsheng@627 4416 "revision of the manifest. A revision of the manifest stores a pointer to a "
dongsheng@627 4417 "single revision of each filelog tracked when that changeset was created. "
songdongsheng@658 4418 "These relationships are illustrated in <xref linkend=\"fig:concepts:metadata"
songdongsheng@658 4419 "\"/>."
songdongsheng@658 4420 msgstr ""
songdongsheng@658 4421
songdongsheng@658 4422 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4423 #: ../en/ch03-concepts.xml:103
dongsheng@627 4424 msgid "Metadata relationships"
dongsheng@660 4425 msgstr "元数据之间的关系"
dongsheng@627 4426
songdongsheng@658 4427 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4428 #: ../en/ch03-concepts.xml:105
songdongsheng@658 4429 msgid "<imageobject><imagedata fileref=\"figs/metadata.png\"/></imageobject>"
songdongsheng@658 4430 msgstr ""
songdongsheng@658 4431
songdongsheng@658 4432 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4433 #: ../en/ch03-concepts.xml:110
dongsheng@627 4434 msgid ""
dongsheng@627 4435 "As the illustration shows, there is <emphasis>not</emphasis> a <quote>one to "
dongsheng@627 4436 "one</quote> relationship between revisions in the changelog, manifest, or "
dongsheng@627 4437 "filelog. If the manifest hasn't changed between two changesets, the changelog "
dongsheng@627 4438 "entries for those changesets will point to the same revision of the "
dongsheng@627 4439 "manifest. If a file that Mercurial tracks hasn't changed between two "
dongsheng@627 4440 "changesets, the entry for that file in the two revisions of the manifest will "
dongsheng@627 4441 "point to the same revision of its filelog."
dongsheng@627 4442 msgstr ""
dongsheng@627 4443
dongsheng@627 4444 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 4445 #: ../en/ch03-concepts.xml:123
dongsheng@627 4446 msgid "Safe, efficient storage"
dongsheng@627 4447 msgstr "安全,高效的存储"
dongsheng@627 4448
dongsheng@627 4449 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4450 #: ../en/ch03-concepts.xml:125
dongsheng@627 4451 msgid ""
dongsheng@627 4452 "The underpinnings of changelogs, manifests, and filelogs are provided by a "
dongsheng@627 4453 "single structure called the <emphasis>revlog</emphasis>."
dongsheng@627 4454 msgstr ""
dongsheng@627 4455
dongsheng@627 4456 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4457 #: ../en/ch03-concepts.xml:130
dongsheng@627 4458 msgid "Efficient storage"
dongsheng@627 4459 msgstr "高效存储"
dongsheng@627 4460
dongsheng@627 4461 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4462 #: ../en/ch03-concepts.xml:132
dongsheng@627 4463 msgid ""
dongsheng@627 4464 "The revlog provides efficient storage of revisions using a <emphasis>delta</"
dongsheng@627 4465 "emphasis> mechanism. Instead of storing a complete copy of a file for each "
dongsheng@627 4466 "revision, it stores the changes needed to transform an older revision into "
dongsheng@627 4467 "the new revision. For many kinds of file data, these deltas are typically a "
dongsheng@627 4468 "fraction of a percent of the size of a full copy of a file."
dongsheng@627 4469 msgstr ""
dongsheng@627 4470
dongsheng@627 4471 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4472 #: ../en/ch03-concepts.xml:140
dongsheng@627 4473 msgid ""
dongsheng@627 4474 "Some obsolete revision control systems can only work with deltas of text "
dongsheng@627 4475 "files. They must either store binary files as complete snapshots or encoded "
dongsheng@627 4476 "into a text representation, both of which are wasteful approaches. Mercurial "
dongsheng@627 4477 "can efficiently handle deltas of files with arbitrary binary contents; it "
dongsheng@627 4478 "doesn't need to treat text as special."
dongsheng@627 4479 msgstr ""
dongsheng@627 4480
dongsheng@627 4481 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4482 #: ../en/ch03-concepts.xml:149
dongsheng@627 4483 msgid "Safe operation"
dongsheng@627 4484 msgstr "安全操作"
dongsheng@627 4485
dongsheng@627 4486 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4487 #: ../en/ch03-concepts.xml:151
dongsheng@627 4488 msgid ""
dongsheng@627 4489 "Mercurial only ever <emphasis>appends</emphasis> data to the end of a revlog "
dongsheng@627 4490 "file. It never modifies a section of a file after it has written it. This is "
dongsheng@627 4491 "both more robust and efficient than schemes that need to modify or rewrite "
dongsheng@627 4492 "data."
dongsheng@627 4493 msgstr ""
dongsheng@627 4494
dongsheng@627 4495 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4496 #: ../en/ch03-concepts.xml:157
dongsheng@627 4497 msgid ""
dongsheng@627 4498 "In addition, Mercurial treats every write as part of a <emphasis>transaction</"
dongsheng@627 4499 "emphasis> that can span a number of files. A transaction is "
dongsheng@627 4500 "<emphasis>atomic</emphasis>: either the entire transaction succeeds and its "
dongsheng@627 4501 "effects are all visible to readers in one go, or the whole thing is undone. "
dongsheng@627 4502 "This guarantee of atomicity means that if you're running two copies of "
dongsheng@627 4503 "Mercurial, where one is reading data and one is writing it, the reader will "
dongsheng@627 4504 "never see a partially written result that might confuse it."
dongsheng@627 4505 msgstr ""
dongsheng@627 4506
dongsheng@627 4507 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4508 #: ../en/ch03-concepts.xml:167
dongsheng@627 4509 msgid ""
dongsheng@627 4510 "The fact that Mercurial only appends to files makes it easier to provide this "
dongsheng@627 4511 "transactional guarantee. The easier it is to do stuff like this, the more "
dongsheng@627 4512 "confident you should be that it's done correctly."
dongsheng@627 4513 msgstr ""
dongsheng@627 4514
dongsheng@627 4515 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4516 #: ../en/ch03-concepts.xml:174
dongsheng@627 4517 msgid "Fast retrieval"
dongsheng@627 4518 msgstr "快速检索"
dongsheng@627 4519
dongsheng@627 4520 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4521 #: ../en/ch03-concepts.xml:176
dongsheng@627 4522 msgid ""
dongsheng@627 4523 "Mercurial cleverly avoids a pitfall common to all earlier revision control "
dongsheng@627 4524 "systems: the problem of <emphasis>inefficient retrieval</emphasis>. Most "
dongsheng@627 4525 "revision control systems store the contents of a revision as an incremental "
dongsheng@627 4526 "series of modifications against a <quote>snapshot</quote>. To reconstruct a "
dongsheng@627 4527 "specific revision, you must first read the snapshot, and then every one of "
dongsheng@627 4528 "the revisions between the snapshot and your target revision. The more "
dongsheng@627 4529 "history that a file accumulates, the more revisions you must read, hence the "
dongsheng@627 4530 "longer it takes to reconstruct a particular revision."
dongsheng@627 4531 msgstr ""
dongsheng@627 4532
songdongsheng@658 4533 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4534 #: ../en/ch03-concepts.xml:188
songdongsheng@658 4535 msgid "Snapshot of a revlog, with incremental deltas"
dongsheng@660 4536 msgstr "版本日志的快照,以及增量差异"
songdongsheng@658 4537
songdongsheng@658 4538 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4539 #: ../en/ch03-concepts.xml:190
songdongsheng@658 4540 msgid "<imageobject><imagedata fileref=\"figs/snapshot.png\"/></imageobject>"
songdongsheng@658 4541 msgstr ""
songdongsheng@658 4542
songdongsheng@658 4543 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 4544 #: ../en/ch03-concepts.xml:195
dongsheng@627 4545 msgid ""
dongsheng@627 4546 "The innovation that Mercurial applies to this problem is simple but "
dongsheng@627 4547 "effective. Once the cumulative amount of delta information stored since the "
dongsheng@627 4548 "last snapshot exceeds a fixed threshold, it stores a new snapshot "
dongsheng@627 4549 "(compressed, of course), instead of another delta. This makes it possible to "
dongsheng@627 4550 "reconstruct <emphasis>any</emphasis> revision of a file quickly. This "
dongsheng@627 4551 "approach works so well that it has since been copied by several other "
dongsheng@627 4552 "revision control systems."
dongsheng@627 4553 msgstr ""
dongsheng@627 4554
dongsheng@627 4555 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4556 #: ../en/ch03-concepts.xml:204
songdongsheng@658 4557 msgid ""
songdongsheng@658 4558 "<xref linkend=\"fig:concepts:snapshot\"/> illustrates the idea. In an entry "
songdongsheng@658 4559 "in a revlog's index file, Mercurial stores the range of entries from the data "
songdongsheng@658 4560 "file that it must read to reconstruct a particular revision."
dongsheng@627 4561 msgstr ""
dongsheng@627 4562
dongsheng@627 4563 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 4564 #: ../en/ch03-concepts.xml:210
dongsheng@627 4565 msgid "Aside: the influence of video compression"
dongsheng@660 4566 msgstr "旁白: 视频压缩的影响"
dongsheng@627 4567
dongsheng@627 4568 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 4569 #: ../en/ch03-concepts.xml:212
dongsheng@627 4570 msgid ""
dongsheng@627 4571 "If you're familiar with video compression or have ever watched a TV feed "
dongsheng@627 4572 "through a digital cable or satellite service, you may know that most video "
dongsheng@627 4573 "compression schemes store each frame of video as a delta against its "
dongsheng@627 4574 "predecessor frame. In addition, these schemes use <quote>lossy</quote> "
dongsheng@627 4575 "compression techniques to increase the compression ratio, so visual errors "
dongsheng@627 4576 "accumulate over the course of a number of inter-frame deltas."
dongsheng@627 4577 msgstr ""
dongsheng@627 4578
dongsheng@627 4579 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 4580 #: ../en/ch03-concepts.xml:221
dongsheng@627 4581 msgid ""
dongsheng@627 4582 "Because it's possible for a video stream to <quote>drop out</quote> "
dongsheng@627 4583 "occasionally due to signal glitches, and to limit the accumulation of "
dongsheng@627 4584 "artefacts introduced by the lossy compression process, video encoders "
dongsheng@627 4585 "periodically insert a complete frame (called a <quote>key frame</quote>) into "
dongsheng@627 4586 "the video stream; the next delta is generated against that frame. This means "
dongsheng@627 4587 "that if the video signal gets interrupted, it will resume once the next key "
dongsheng@627 4588 "frame is received. Also, the accumulation of encoding errors restarts anew "
dongsheng@627 4589 "with each key frame."
dongsheng@627 4590 msgstr ""
dongsheng@627 4591
dongsheng@627 4592 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4593 #: ../en/ch03-concepts.xml:235
dongsheng@627 4594 msgid "Identification and strong integrity"
dongsheng@627 4595 msgstr "鉴别和强完整性"
dongsheng@627 4596
dongsheng@627 4597 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4598 #: ../en/ch03-concepts.xml:237
dongsheng@627 4599 msgid ""
dongsheng@627 4600 "Along with delta or snapshot information, a revlog entry contains a "
dongsheng@627 4601 "cryptographic hash of the data that it represents. This makes it difficult "
dongsheng@627 4602 "to forge the contents of a revision, and easy to detect accidental corruption."
dongsheng@627 4603 msgstr ""
dongsheng@627 4604
dongsheng@627 4605 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4606 #: ../en/ch03-concepts.xml:242
dongsheng@627 4607 msgid ""
dongsheng@627 4608 "Hashes provide more than a mere check against corruption; they are used as "
dongsheng@627 4609 "the identifiers for revisions. The changeset identification hashes that you "
dongsheng@627 4610 "see as an end user are from revisions of the changelog. Although filelogs "
dongsheng@627 4611 "and the manifest also use hashes, Mercurial only uses these behind the scenes."
dongsheng@627 4612 msgstr ""
dongsheng@627 4613
dongsheng@627 4614 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4615 #: ../en/ch03-concepts.xml:249
dongsheng@627 4616 msgid ""
dongsheng@627 4617 "Mercurial verifies that hashes are correct when it retrieves file revisions "
dongsheng@627 4618 "and when it pulls changes from another repository. If it encounters an "
dongsheng@627 4619 "integrity problem, it will complain and stop whatever it's doing."
dongsheng@627 4620 msgstr ""
dongsheng@627 4621
dongsheng@627 4622 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4623 #: ../en/ch03-concepts.xml:254
dongsheng@627 4624 msgid ""
dongsheng@627 4625 "In addition to the effect it has on retrieval efficiency, Mercurial's use of "
dongsheng@627 4626 "periodic snapshots makes it more robust against partial data corruption. If "
dongsheng@627 4627 "a revlog becomes partly corrupted due to a hardware error or system bug, it's "
dongsheng@627 4628 "often possible to reconstruct some or most revisions from the uncorrupted "
dongsheng@627 4629 "sections of the revlog, both before and after the corrupted section. This "
dongsheng@627 4630 "would not be possible with a delta-only storage model."
dongsheng@627 4631 msgstr ""
dongsheng@627 4632
dongsheng@627 4633 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 4634 #: ../en/ch03-concepts.xml:266
dongsheng@627 4635 msgid "Revision history, branching, and merging"
dongsheng@627 4636 msgstr "修订历史,分支与合并"
dongsheng@627 4637
dongsheng@627 4638 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4639 #: ../en/ch03-concepts.xml:268
dongsheng@627 4640 msgid ""
dongsheng@627 4641 "Every entry in a Mercurial revlog knows the identity of its immediate "
dongsheng@627 4642 "ancestor revision, usually referred to as its <emphasis>parent</emphasis>. "
dongsheng@627 4643 "In fact, a revision contains room for not one parent, but two. Mercurial "
dongsheng@627 4644 "uses a special hash, called the <quote>null ID</quote>, to represent the idea "
dongsheng@627 4645 "<quote>there is no parent here</quote>. This hash is simply a string of "
dongsheng@627 4646 "zeroes."
dongsheng@627 4647 msgstr ""
dongsheng@627 4648
dongsheng@627 4649 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4650 #: ../en/ch03-concepts.xml:276
songdongsheng@658 4651 msgid ""
songdongsheng@658 4652 "In <xref linkend=\"fig:concepts:revlog\"/>, you can see an example of the "
songdongsheng@658 4653 "conceptual structure of a revlog. Filelogs, manifests, and changelogs all "
songdongsheng@658 4654 "have this same structure; they differ only in the kind of data stored in each "
songdongsheng@658 4655 "delta or snapshot."
songdongsheng@658 4656 msgstr ""
songdongsheng@658 4657
songdongsheng@658 4658 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 4659 #: ../en/ch03-concepts.xml:282
dongsheng@627 4660 msgid ""
dongsheng@627 4661 "The first revision in a revlog (at the bottom of the image) has the null ID "
dongsheng@627 4662 "in both of its parent slots. For a <quote>normal</quote> revision, its first "
dongsheng@627 4663 "parent slot contains the ID of its parent revision, and its second contains "
dongsheng@627 4664 "the null ID, indicating that the revision has only one real parent. Any two "
dongsheng@627 4665 "revisions that have the same parent ID are branches. A revision that "
dongsheng@627 4666 "represents a merge between branches has two normal revision IDs in its parent "
dongsheng@627 4667 "slots."
dongsheng@627 4668 msgstr ""
dongsheng@627 4669
songdongsheng@658 4670 #. type: Content of: <book><chapter><sect1><figure><title>
songdongsheng@658 4671 #: ../en/ch03-concepts.xml:292
songdongsheng@658 4672 msgid "The conceptual structure of a revlog"
dongsheng@660 4673 msgstr "版本日志的设计结构"
songdongsheng@658 4674
songdongsheng@658 4675 #. type: Content of: <book><chapter><sect1><figure><mediaobject>
songdongsheng@658 4676 #: ../en/ch03-concepts.xml:294
songdongsheng@658 4677 msgid "<imageobject><imagedata fileref=\"figs/revlog.png\"/></imageobject>"
dongsheng@641 4678 msgstr ""
dongsheng@641 4679
dongsheng@627 4680 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 4681 #: ../en/ch03-concepts.xml:301
dongsheng@627 4682 msgid "The working directory"
dongsheng@627 4683 msgstr "工作目录"
dongsheng@627 4684
dongsheng@627 4685 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4686 #: ../en/ch03-concepts.xml:303
dongsheng@627 4687 msgid ""
dongsheng@627 4688 "In the working directory, Mercurial stores a snapshot of the files from the "
dongsheng@627 4689 "repository as of a particular changeset."
dongsheng@627 4690 msgstr ""
dongsheng@627 4691
dongsheng@627 4692 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4693 #: ../en/ch03-concepts.xml:306
dongsheng@627 4694 msgid ""
dongsheng@627 4695 "The working directory <quote>knows</quote> which changeset it contains. When "
dongsheng@627 4696 "you update the working directory to contain a particular changeset, Mercurial "
dongsheng@627 4697 "looks up the appropriate revision of the manifest to find out which files it "
dongsheng@627 4698 "was tracking at the time that changeset was committed, and which revision of "
dongsheng@627 4699 "each file was then current. It then recreates a copy of each of those files, "
dongsheng@627 4700 "with the same contents it had when the changeset was committed."
dongsheng@627 4701 msgstr ""
dongsheng@627 4702
dongsheng@627 4703 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4704 #: ../en/ch03-concepts.xml:315
dongsheng@627 4705 msgid ""
dongsheng@627 4706 "The <emphasis>dirstate</emphasis> contains Mercurial's knowledge of the "
dongsheng@627 4707 "working directory. This details which changeset the working directory is "
dongsheng@627 4708 "updated to, and all of the files that Mercurial is tracking in the working "
dongsheng@627 4709 "directory."
dongsheng@627 4710 msgstr ""
dongsheng@627 4711
dongsheng@627 4712 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4713 #: ../en/ch03-concepts.xml:321
dongsheng@627 4714 msgid ""
dongsheng@627 4715 "Just as a revision of a revlog has room for two parents, so that it can "
dongsheng@627 4716 "represent either a normal revision (with one parent) or a merge of two "
dongsheng@627 4717 "earlier revisions, the dirstate has slots for two parents. When you use the "
dongsheng@627 4718 "<command role=\"hg-cmd\">hg update</command> command, the changeset that you "
dongsheng@627 4719 "update to is stored in the <quote>first parent</quote> slot, and the null ID "
dongsheng@627 4720 "in the second. When you <command role=\"hg-cmd\">hg merge</command> with "
dongsheng@627 4721 "another changeset, the first parent remains unchanged, and the second parent "
dongsheng@627 4722 "is filled in with the changeset you're merging with. The <command role=\"hg-"
dongsheng@627 4723 "cmd\">hg parents</command> command tells you what the parents of the dirstate "
dongsheng@627 4724 "are."
dongsheng@627 4725 msgstr ""
dongsheng@627 4726
dongsheng@627 4727 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4728 #: ../en/ch03-concepts.xml:335
dongsheng@627 4729 msgid "What happens when you commit"
dongsheng@627 4730 msgstr "当你提交时发生的事情"
dongsheng@627 4731
dongsheng@627 4732 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4733 #: ../en/ch03-concepts.xml:337
dongsheng@627 4734 msgid ""
dongsheng@627 4735 "The dirstate stores parent information for more than just book-keeping "
dongsheng@627 4736 "purposes. Mercurial uses the parents of the dirstate as <emphasis>the "
dongsheng@627 4737 "parents of a new changeset</emphasis> when you perform a commit."
dongsheng@627 4738 msgstr ""
dongsheng@627 4739
songdongsheng@658 4740 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4741 #: ../en/ch03-concepts.xml:343
dongsheng@627 4742 msgid "The working directory can have two parents"
dongsheng@660 4743 msgstr "工作目录可以有两个父亲"
dongsheng@627 4744
songdongsheng@658 4745 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4746 #: ../en/ch03-concepts.xml:345
songdongsheng@658 4747 msgid "<imageobject><imagedata fileref=\"figs/wdir.png\"/></imageobject>"
songdongsheng@658 4748 msgstr ""
songdongsheng@658 4749
songdongsheng@658 4750 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4751 #: ../en/ch03-concepts.xml:350
songdongsheng@658 4752 msgid ""
songdongsheng@658 4753 "<xref linkend=\"fig:concepts:wdir\"/> shows the normal state of the working "
songdongsheng@658 4754 "directory, where it has a single changeset as parent. That changeset is the "
songdongsheng@658 4755 "<emphasis>tip</emphasis>, the newest changeset in the repository that has no "
songdongsheng@658 4756 "children."
songdongsheng@658 4757 msgstr ""
songdongsheng@658 4758
songdongsheng@658 4759 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4760 #: ../en/ch03-concepts.xml:357
dongsheng@627 4761 msgid "The working directory gains new parents after a commit"
dongsheng@660 4762 msgstr "提交之后,工作目录的父亲就改变了"
dongsheng@627 4763
songdongsheng@658 4764 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4765 #: ../en/ch03-concepts.xml:360
songdongsheng@658 4766 msgid ""
songdongsheng@658 4767 "<imageobject><imagedata fileref=\"figs/wdir-after-commit.png\"/></imageobject>"
songdongsheng@658 4768 msgstr ""
songdongsheng@658 4769
songdongsheng@658 4770 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4771 #: ../en/ch03-concepts.xml:365
dongsheng@627 4772 msgid ""
dongsheng@627 4773 "It's useful to think of the working directory as <quote>the changeset I'm "
dongsheng@627 4774 "about to commit</quote>. Any files that you tell Mercurial that you've "
dongsheng@627 4775 "added, removed, renamed, or copied will be reflected in that changeset, as "
dongsheng@627 4776 "will modifications to any files that Mercurial is already tracking; the new "
dongsheng@627 4777 "changeset will have the parents of the working directory as its parents."
dongsheng@627 4778 msgstr ""
dongsheng@627 4779
dongsheng@627 4780 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4781 #: ../en/ch03-concepts.xml:373
dongsheng@627 4782 msgid ""
dongsheng@627 4783 "After a commit, Mercurial will update the parents of the working directory, "
dongsheng@627 4784 "so that the first parent is the ID of the new changeset, and the second is "
songdongsheng@658 4785 "the null ID. This is shown in <xref linkend=\"fig:concepts:wdir-after-commit"
songdongsheng@658 4786 "\"/>. Mercurial doesn't touch any of the files in the working directory when "
songdongsheng@658 4787 "you commit; it just modifies the dirstate to note its new parents."
dongsheng@641 4788 msgstr ""
dongsheng@641 4789
dongsheng@641 4790 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4791 #: ../en/ch03-concepts.xml:384
dongsheng@627 4792 msgid "Creating a new head"
dongsheng@627 4793 msgstr "创建新顶点"
dongsheng@627 4794
dongsheng@627 4795 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4796 #: ../en/ch03-concepts.xml:386
dongsheng@627 4797 msgid ""
dongsheng@627 4798 "It's perfectly normal to update the working directory to a changeset other "
dongsheng@627 4799 "than the current tip. For example, you might want to know what your project "
dongsheng@627 4800 "looked like last Tuesday, or you could be looking through changesets to see "
dongsheng@627 4801 "which one introduced a bug. In cases like this, the natural thing to do is "
dongsheng@627 4802 "update the working directory to the changeset you're interested in, and then "
dongsheng@627 4803 "examine the files in the working directory directly to see their contents as "
dongsheng@627 4804 "they were when you committed that changeset. The effect of this is shown in "
songdongsheng@658 4805 "<xref linkend=\"fig:concepts:wdir-pre-branch\"/>."
songdongsheng@658 4806 msgstr ""
songdongsheng@658 4807
songdongsheng@658 4808 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4809 #: ../en/ch03-concepts.xml:398
dongsheng@627 4810 msgid "The working directory, updated to an older changeset"
dongsheng@660 4811 msgstr "同步到旧修改集的工作目录"
dongsheng@627 4812
songdongsheng@658 4813 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4814 #: ../en/ch03-concepts.xml:401
songdongsheng@658 4815 msgid ""
songdongsheng@658 4816 "<imageobject><imagedata fileref=\"figs/wdir-pre-branch.png\"/></imageobject>"
songdongsheng@658 4817 msgstr ""
songdongsheng@658 4818
songdongsheng@658 4819 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4820 #: ../en/ch03-concepts.xml:406
dongsheng@627 4821 msgid ""
dongsheng@627 4822 "Having updated the working directory to an older changeset, what happens if "
dongsheng@627 4823 "you make some changes, and then commit? Mercurial behaves in the same way as "
dongsheng@627 4824 "I outlined above. The parents of the working directory become the parents of "
dongsheng@627 4825 "the new changeset. This new changeset has no children, so it becomes the new "
dongsheng@627 4826 "tip. And the repository now contains two changesets that have no children; "
dongsheng@627 4827 "we call these <emphasis>heads</emphasis>. You can see the structure that "
songdongsheng@658 4828 "this creates in <xref linkend=\"fig:concepts:wdir-branch\"/>."
songdongsheng@658 4829 msgstr ""
songdongsheng@658 4830
songdongsheng@658 4831 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4832 #: ../en/ch03-concepts.xml:418
dongsheng@627 4833 msgid "After a commit made while synced to an older changeset"
dongsheng@660 4834 msgstr "对同步到旧修改集的工作目录提交之后"
dongsheng@627 4835
songdongsheng@658 4836 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4837 #: ../en/ch03-concepts.xml:421
songdongsheng@658 4838 msgid "<imageobject><imagedata fileref=\"figs/wdir-branch.png\"/></imageobject>"
songdongsheng@658 4839 msgstr ""
songdongsheng@658 4840
dongsheng@627 4841 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 4842 #: ../en/ch03-concepts.xml:427
dongsheng@627 4843 msgid ""
dongsheng@627 4844 "If you're new to Mercurial, you should keep in mind a common <quote>error</"
dongsheng@627 4845 "quote>, which is to use the <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 4846 "command without any options. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 4847 "pull</command> command <emphasis>does not</emphasis> update the working "
dongsheng@627 4848 "directory, so you'll bring new changesets into your repository, but the "
dongsheng@627 4849 "working directory will stay synced at the same changeset as before the pull. "
dongsheng@627 4850 "If you make some changes and commit afterwards, you'll thus create a new "
dongsheng@627 4851 "head, because your working directory isn't synced to whatever the current tip "
dongsheng@627 4852 "is."
dongsheng@627 4853 msgstr ""
dongsheng@627 4854
dongsheng@627 4855 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 4856 #: ../en/ch03-concepts.xml:439
dongsheng@627 4857 msgid ""
dongsheng@627 4858 "I put the word <quote>error</quote> in quotes because all that you need to do "
dongsheng@627 4859 "to rectify this situation is <command role=\"hg-cmd\">hg merge</command>, "
dongsheng@627 4860 "then <command role=\"hg-cmd\">hg commit</command>. In other words, this "
dongsheng@627 4861 "almost never has negative consequences; it just surprises people. I'll "
dongsheng@627 4862 "discuss other ways to avoid this behaviour, and why Mercurial behaves in this "
dongsheng@627 4863 "initially surprising way, later on."
dongsheng@627 4864 msgstr ""
dongsheng@627 4865
dongsheng@627 4866 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4867 #: ../en/ch03-concepts.xml:451
dongsheng@627 4868 msgid "Merging heads"
dongsheng@627 4869 msgstr "合并顶点"
dongsheng@627 4870
dongsheng@627 4871 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4872 #: ../en/ch03-concepts.xml:453
dongsheng@627 4873 msgid ""
dongsheng@627 4874 "When you run the <command role=\"hg-cmd\">hg merge</command> command, "
dongsheng@627 4875 "Mercurial leaves the first parent of the working directory unchanged, and "
dongsheng@627 4876 "sets the second parent to the changeset you're merging with, as shown in "
songdongsheng@658 4877 "<xref linkend=\"fig:concepts:wdir-merge\"/>."
songdongsheng@658 4878 msgstr ""
songdongsheng@658 4879
songdongsheng@658 4880 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 4881 #: ../en/ch03-concepts.xml:460
dongsheng@627 4882 msgid "Merging two heads"
dongsheng@660 4883 msgstr "合并两个顶点"
dongsheng@627 4884
songdongsheng@658 4885 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 4886 #: ../en/ch03-concepts.xml:462
songdongsheng@658 4887 msgid ""
songdongsheng@658 4888 "<imageobject> <imagedata fileref=\"figs/wdir-merge.png\"/> </imageobject>"
songdongsheng@658 4889 msgstr ""
songdongsheng@658 4890
songdongsheng@658 4891 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4892 #: ../en/ch03-concepts.xml:469
dongsheng@627 4893 msgid ""
dongsheng@627 4894 "Mercurial also has to modify the working directory, to merge the files "
dongsheng@627 4895 "managed in the two changesets. Simplified a little, the merging process goes "
dongsheng@627 4896 "like this, for every file in the manifests of both changesets."
dongsheng@627 4897 msgstr ""
dongsheng@627 4898
dongsheng@627 4899 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4900 #: ../en/ch03-concepts.xml:474
dongsheng@627 4901 msgid "If neither changeset has modified a file, do nothing with that file."
dongsheng@627 4902 msgstr ""
dongsheng@627 4903
dongsheng@627 4904 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4905 #: ../en/ch03-concepts.xml:477
dongsheng@627 4906 msgid ""
dongsheng@627 4907 "If one changeset has modified a file, and the other hasn't, create the "
dongsheng@627 4908 "modified copy of the file in the working directory."
dongsheng@627 4909 msgstr ""
dongsheng@627 4910
dongsheng@627 4911 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4912 #: ../en/ch03-concepts.xml:481
dongsheng@627 4913 msgid ""
dongsheng@627 4914 "If one changeset has removed a file, and the other hasn't (or has also "
dongsheng@627 4915 "deleted it), delete the file from the working directory."
dongsheng@627 4916 msgstr ""
dongsheng@627 4917
dongsheng@627 4918 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4919 #: ../en/ch03-concepts.xml:485
dongsheng@627 4920 msgid ""
dongsheng@627 4921 "If one changeset has removed a file, but the other has modified the file, ask "
dongsheng@627 4922 "the user what to do: keep the modified file, or remove it?"
dongsheng@627 4923 msgstr ""
dongsheng@627 4924
dongsheng@627 4925 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4926 #: ../en/ch03-concepts.xml:489
dongsheng@627 4927 msgid ""
dongsheng@627 4928 "If both changesets have modified a file, invoke an external merge program to "
dongsheng@627 4929 "choose the new contents for the merged file. This may require input from the "
dongsheng@627 4930 "user."
dongsheng@627 4931 msgstr ""
dongsheng@627 4932
dongsheng@627 4933 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 4934 #: ../en/ch03-concepts.xml:494
dongsheng@627 4935 msgid ""
dongsheng@627 4936 "If one changeset has modified a file, and the other has renamed or copied the "
dongsheng@627 4937 "file, make sure that the changes follow the new name of the file."
dongsheng@627 4938 msgstr ""
dongsheng@627 4939
dongsheng@627 4940 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4941 #: ../en/ch03-concepts.xml:498
dongsheng@627 4942 msgid ""
dongsheng@661 4943 "There are more details—merging has plenty of corner cases&emdash;but these "
dongsheng@661 4944 "are the most common choices that are involved in a merge. As you can see, "
dongsheng@661 4945 "most cases are completely automatic, and indeed most merges finish "
dongsheng@627 4946 "automatically, without requiring your input to resolve any conflicts."
dongsheng@627 4947 msgstr ""
dongsheng@627 4948
dongsheng@627 4949 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4950 #: ../en/ch03-concepts.xml:505
dongsheng@627 4951 msgid ""
dongsheng@627 4952 "When you're thinking about what happens when you commit after a merge, once "
dongsheng@627 4953 "again the working directory is <quote>the changeset I'm about to commit</"
dongsheng@627 4954 "quote>. After the <command role=\"hg-cmd\">hg merge</command> command "
dongsheng@627 4955 "completes, the working directory has two parents; these will become the "
dongsheng@627 4956 "parents of the new changeset."
dongsheng@627 4957 msgstr ""
dongsheng@627 4958
dongsheng@627 4959 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4960 #: ../en/ch03-concepts.xml:512
dongsheng@627 4961 msgid ""
dongsheng@627 4962 "Mercurial lets you perform multiple merges, but you must commit the results "
dongsheng@627 4963 "of each individual merge as you go. This is necessary because Mercurial only "
dongsheng@627 4964 "tracks two parents for both revisions and the working directory. While it "
dongsheng@627 4965 "would be technically possible to merge multiple changesets at once, the "
dongsheng@627 4966 "prospect of user confusion and making a terrible mess of a merge immediately "
dongsheng@627 4967 "becomes overwhelming."
dongsheng@627 4968 msgstr ""
dongsheng@627 4969
dongsheng@627 4970 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 4971 #: ../en/ch03-concepts.xml:523
dongsheng@627 4972 msgid "Other interesting design features"
dongsheng@627 4973 msgstr "其它有趣的设计特性"
dongsheng@627 4974
dongsheng@627 4975 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 4976 #: ../en/ch03-concepts.xml:525
dongsheng@627 4977 msgid ""
dongsheng@627 4978 "In the sections above, I've tried to highlight some of the most important "
dongsheng@627 4979 "aspects of Mercurial's design, to illustrate that it pays careful attention "
dongsheng@627 4980 "to reliability and performance. However, the attention to detail doesn't "
dongsheng@627 4981 "stop there. There are a number of other aspects of Mercurial's construction "
dongsheng@627 4982 "that I personally find interesting. I'll detail a few of them here, separate "
dongsheng@627 4983 "from the <quote>big ticket</quote> items above, so that if you're interested, "
dongsheng@627 4984 "you can gain a better idea of the amount of thinking that goes into a well-"
dongsheng@627 4985 "designed system."
dongsheng@627 4986 msgstr ""
dongsheng@627 4987
dongsheng@627 4988 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 4989 #: ../en/ch03-concepts.xml:536
dongsheng@627 4990 msgid "Clever compression"
dongsheng@627 4991 msgstr "智能压缩"
dongsheng@627 4992
dongsheng@627 4993 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 4994 #: ../en/ch03-concepts.xml:538
dongsheng@627 4995 msgid ""
dongsheng@627 4996 "When appropriate, Mercurial will store both snapshots and deltas in "
dongsheng@627 4997 "compressed form. It does this by always <emphasis>trying to</emphasis> "
dongsheng@627 4998 "compress a snapshot or delta, but only storing the compressed version if it's "
dongsheng@627 4999 "smaller than the uncompressed version."
dongsheng@627 5000 msgstr ""
dongsheng@627 5001
dongsheng@627 5002 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5003 #: ../en/ch03-concepts.xml:544
dongsheng@627 5004 msgid ""
dongsheng@627 5005 "This means that Mercurial does <quote>the right thing</quote> when storing a "
dongsheng@627 5006 "file whose native form is compressed, such as a <literal>zip</literal> "
dongsheng@627 5007 "archive or a JPEG image. When these types of files are compressed a second "
dongsheng@627 5008 "time, the resulting file is usually bigger than the once-compressed form, and "
dongsheng@627 5009 "so Mercurial will store the plain <literal>zip</literal> or JPEG."
dongsheng@627 5010 msgstr ""
dongsheng@627 5011
dongsheng@627 5012 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5013 #: ../en/ch03-concepts.xml:552
dongsheng@627 5014 msgid ""
dongsheng@627 5015 "Deltas between revisions of a compressed file are usually larger than "
dongsheng@627 5016 "snapshots of the file, and Mercurial again does <quote>the right thing</"
dongsheng@627 5017 "quote> in these cases. It finds that such a delta exceeds the threshold at "
dongsheng@627 5018 "which it should store a complete snapshot of the file, so it stores the "
dongsheng@627 5019 "snapshot, again saving space compared to a naive delta-only approach."
dongsheng@627 5020 msgstr ""
dongsheng@627 5021
dongsheng@627 5022 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 5023 #: ../en/ch03-concepts.xml:561
dongsheng@627 5024 msgid "Network recompression"
dongsheng@627 5025 msgstr "网络重新压缩"
dongsheng@627 5026
dongsheng@627 5027 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 5028 #: ../en/ch03-concepts.xml:563
dongsheng@627 5029 msgid ""
dongsheng@627 5030 "When storing revisions on disk, Mercurial uses the <quote>deflate</quote> "
dongsheng@627 5031 "compression algorithm (the same one used by the popular <literal>zip</"
dongsheng@627 5032 "literal> archive format), which balances good speed with a respectable "
dongsheng@627 5033 "compression ratio. However, when transmitting revision data over a network "
dongsheng@627 5034 "connection, Mercurial uncompresses the compressed revision data."
dongsheng@627 5035 msgstr ""
dongsheng@627 5036
dongsheng@627 5037 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 5038 #: ../en/ch03-concepts.xml:571
dongsheng@627 5039 msgid ""
dongsheng@627 5040 "If the connection is over HTTP, Mercurial recompresses the entire stream of "
dongsheng@627 5041 "data using a compression algorithm that gives a better compression ratio (the "
dongsheng@627 5042 "Burrows-Wheeler algorithm from the widely used <literal>bzip2</literal> "
dongsheng@627 5043 "compression package). This combination of algorithm and compression of the "
dongsheng@627 5044 "entire stream (instead of a revision at a time) substantially reduces the "
dongsheng@627 5045 "number of bytes to be transferred, yielding better network performance over "
dongsheng@627 5046 "almost all kinds of network."
dongsheng@627 5047 msgstr ""
dongsheng@627 5048
dongsheng@627 5049 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 5050 #: ../en/ch03-concepts.xml:581
dongsheng@627 5051 msgid ""
dongsheng@627 5052 "(If the connection is over <command>ssh</command>, Mercurial "
dongsheng@627 5053 "<emphasis>doesn't</emphasis> recompress the stream, because <command>ssh</"
dongsheng@627 5054 "command> can already do this itself.)"
dongsheng@627 5055 msgstr ""
dongsheng@627 5056
dongsheng@627 5057 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 5058 #: ../en/ch03-concepts.xml:589
dongsheng@627 5059 msgid "Read/write ordering and atomicity"
dongsheng@627 5060 msgstr "读写顺序与原子性"
dongsheng@627 5061
dongsheng@627 5062 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5063 #: ../en/ch03-concepts.xml:591
dongsheng@627 5064 msgid ""
dongsheng@627 5065 "Appending to files isn't the whole story when it comes to guaranteeing that a "
songdongsheng@658 5066 "reader won't see a partial write. If you recall <xref linkend=\"fig:concepts:"
songdongsheng@658 5067 "metadata\"/>, revisions in the changelog point to revisions in the manifest, "
songdongsheng@658 5068 "and revisions in the manifest point to revisions in filelogs. This hierarchy "
songdongsheng@658 5069 "is deliberate."
songdongsheng@658 5070 msgstr ""
songdongsheng@658 5071
songdongsheng@658 5072 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5073 #: ../en/ch03-concepts.xml:599
dongsheng@627 5074 msgid ""
dongsheng@627 5075 "A writer starts a transaction by writing filelog and manifest data, and "
dongsheng@627 5076 "doesn't write any changelog data until those are finished. A reader starts "
dongsheng@627 5077 "by reading changelog data, then manifest data, followed by filelog data."
dongsheng@627 5078 msgstr ""
dongsheng@627 5079
dongsheng@627 5080 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5081 #: ../en/ch03-concepts.xml:604
dongsheng@627 5082 msgid ""
dongsheng@627 5083 "Since the writer has always finished writing filelog and manifest data before "
dongsheng@627 5084 "it writes to the changelog, a reader will never read a pointer to a partially "
dongsheng@627 5085 "written manifest revision from the changelog, and it will never read a "
dongsheng@627 5086 "pointer to a partially written filelog revision from the manifest."
dongsheng@627 5087 msgstr ""
dongsheng@627 5088
dongsheng@627 5089 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 5090 #: ../en/ch03-concepts.xml:612
dongsheng@627 5091 msgid "Concurrent access"
dongsheng@627 5092 msgstr "并发访问"
dongsheng@627 5093
dongsheng@627 5094 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5095 #: ../en/ch03-concepts.xml:614
dongsheng@627 5096 msgid ""
dongsheng@627 5097 "The read/write ordering and atomicity guarantees mean that Mercurial never "
dongsheng@627 5098 "needs to <emphasis>lock</emphasis> a repository when it's reading data, even "
dongsheng@627 5099 "if the repository is being written to while the read is occurring. This has a "
dongsheng@627 5100 "big effect on scalability; you can have an arbitrary number of Mercurial "
dongsheng@627 5101 "processes safely reading data from a repository safely all at once, no matter "
dongsheng@627 5102 "whether it's being written to or not."
dongsheng@627 5103 msgstr ""
dongsheng@627 5104
dongsheng@627 5105 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5106 #: ../en/ch03-concepts.xml:623
dongsheng@627 5107 msgid ""
dongsheng@627 5108 "The lockless nature of reading means that if you're sharing a repository on a "
dongsheng@627 5109 "multi-user system, you don't need to grant other local users permission to "
dongsheng@627 5110 "<emphasis>write</emphasis> to your repository in order for them to be able to "
dongsheng@627 5111 "clone it or pull changes from it; they only need <emphasis>read</emphasis> "
dongsheng@627 5112 "permission. (This is <emphasis>not</emphasis> a common feature among "
dongsheng@627 5113 "revision control systems, so don't take it for granted! Most require readers "
dongsheng@627 5114 "to be able to lock a repository to access it safely, and this requires write "
dongsheng@627 5115 "permission on at least one directory, which of course makes for all kinds of "
dongsheng@627 5116 "nasty and annoying security and administrative problems.)"
dongsheng@627 5117 msgstr ""
dongsheng@627 5118
dongsheng@627 5119 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5120 #: ../en/ch03-concepts.xml:636
dongsheng@627 5121 msgid ""
dongsheng@627 5122 "Mercurial uses locks to ensure that only one process can write to a "
dongsheng@627 5123 "repository at a time (the locking mechanism is safe even over filesystems "
dongsheng@627 5124 "that are notoriously hostile to locking, such as NFS). If a repository is "
dongsheng@627 5125 "locked, a writer will wait for a while to retry if the repository becomes "
dongsheng@627 5126 "unlocked, but if the repository remains locked for too long, the process "
dongsheng@627 5127 "attempting to write will time out after a while. This means that your daily "
dongsheng@627 5128 "automated scripts won't get stuck forever and pile up if a system crashes "
dongsheng@627 5129 "unnoticed, for example. (Yes, the timeout is configurable, from zero to "
dongsheng@627 5130 "infinity.)"
dongsheng@627 5131 msgstr ""
dongsheng@627 5132
dongsheng@627 5133 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 5134 #: ../en/ch03-concepts.xml:648
dongsheng@627 5135 msgid "Safe dirstate access"
dongsheng@627 5136 msgstr "安全的目录状态访问"
dongsheng@627 5137
dongsheng@627 5138 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 5139 #: ../en/ch03-concepts.xml:650
dongsheng@627 5140 msgid ""
dongsheng@627 5141 "As with revision data, Mercurial doesn't take a lock to read the dirstate "
dongsheng@627 5142 "file; it does acquire a lock to write it. To avoid the possibility of "
dongsheng@627 5143 "reading a partially written copy of the dirstate file, Mercurial writes to a "
dongsheng@627 5144 "file with a unique name in the same directory as the dirstate file, then "
dongsheng@627 5145 "renames the temporary file atomically to <filename>dirstate</filename>. The "
dongsheng@627 5146 "file named <filename>dirstate</filename> is thus guaranteed to be complete, "
dongsheng@627 5147 "not partially written."
dongsheng@627 5148 msgstr ""
dongsheng@627 5149
dongsheng@627 5150 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 5151 #: ../en/ch03-concepts.xml:663
dongsheng@627 5152 msgid "Avoiding seeks"
dongsheng@627 5153 msgstr "避免查找"
dongsheng@627 5154
dongsheng@627 5155 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5156 #: ../en/ch03-concepts.xml:665
dongsheng@627 5157 msgid ""
dongsheng@627 5158 "Critical to Mercurial's performance is the avoidance of seeks of the disk "
dongsheng@627 5159 "head, since any seek is far more expensive than even a comparatively large "
dongsheng@627 5160 "read operation."
dongsheng@627 5161 msgstr ""
dongsheng@627 5162
dongsheng@627 5163 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5164 #: ../en/ch03-concepts.xml:669
dongsheng@627 5165 msgid ""
dongsheng@627 5166 "This is why, for example, the dirstate is stored in a single file. If there "
dongsheng@627 5167 "were a dirstate file per directory that Mercurial tracked, the disk would "
dongsheng@627 5168 "seek once per directory. Instead, Mercurial reads the entire single dirstate "
dongsheng@627 5169 "file in one step."
dongsheng@627 5170 msgstr ""
dongsheng@627 5171
dongsheng@627 5172 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5173 #: ../en/ch03-concepts.xml:675
dongsheng@627 5174 msgid ""
dongsheng@627 5175 "Mercurial also uses a <quote>copy on write</quote> scheme when cloning a "
dongsheng@627 5176 "repository on local storage. Instead of copying every revlog file from the "
dongsheng@627 5177 "old repository into the new repository, it makes a <quote>hard link</quote>, "
dongsheng@627 5178 "which is a shorthand way to say <quote>these two names point to the same "
dongsheng@627 5179 "file</quote>. When Mercurial is about to write to one of a revlog's files, "
dongsheng@627 5180 "it checks to see if the number of names pointing at the file is greater than "
dongsheng@627 5181 "one. If it is, more than one repository is using the file, so Mercurial "
dongsheng@627 5182 "makes a new copy of the file that is private to this repository."
dongsheng@627 5183 msgstr ""
dongsheng@627 5184
dongsheng@627 5185 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5186 #: ../en/ch03-concepts.xml:686
dongsheng@627 5187 msgid ""
dongsheng@627 5188 "A few revision control developers have pointed out that this idea of making a "
dongsheng@627 5189 "complete private copy of a file is not very efficient in its use of storage. "
dongsheng@627 5190 "While this is true, storage is cheap, and this method gives the highest "
dongsheng@627 5191 "performance while deferring most book-keeping to the operating system. An "
dongsheng@627 5192 "alternative scheme would most likely reduce performance and increase the "
dongsheng@627 5193 "complexity of the software, each of which is much more important to the "
dongsheng@627 5194 "<quote>feel</quote> of day-to-day use."
dongsheng@627 5195 msgstr ""
dongsheng@627 5196
dongsheng@627 5197 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 5198 #: ../en/ch03-concepts.xml:698
dongsheng@627 5199 msgid "Other contents of the dirstate"
dongsheng@627 5200 msgstr "目录状态的其它内容"
dongsheng@627 5201
dongsheng@627 5202 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5203 #: ../en/ch03-concepts.xml:700
dongsheng@627 5204 msgid ""
dongsheng@627 5205 "Because Mercurial doesn't force you to tell it when you're modifying a file, "
dongsheng@627 5206 "it uses the dirstate to store some extra information so it can determine "
dongsheng@627 5207 "efficiently whether you have modified a file. For each file in the working "
dongsheng@627 5208 "directory, it stores the time that it last modified the file itself, and the "
dongsheng@627 5209 "size of the file at that time."
dongsheng@627 5210 msgstr ""
dongsheng@627 5211
dongsheng@627 5212 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5213 #: ../en/ch03-concepts.xml:707
dongsheng@627 5214 msgid ""
dongsheng@627 5215 "When you explicitly <command role=\"hg-cmd\">hg add</command>, <command role="
dongsheng@627 5216 "\"hg-cmd\">hg remove</command>, <command role=\"hg-cmd\">hg rename</command> "
dongsheng@627 5217 "or <command role=\"hg-cmd\">hg copy</command> files, Mercurial updates the "
dongsheng@627 5218 "dirstate so that it knows what to do with those files when you commit."
dongsheng@627 5219 msgstr ""
dongsheng@627 5220
dongsheng@627 5221 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 5222 #: ../en/ch03-concepts.xml:714
dongsheng@627 5223 msgid ""
dongsheng@627 5224 "When Mercurial is checking the states of files in the working directory, it "
dongsheng@627 5225 "first checks a file's modification time. If that has not changed, the file "
dongsheng@627 5226 "must not have been modified. If the file's size has changed, the file must "
dongsheng@627 5227 "have been modified. If the modification time has changed, but the size has "
dongsheng@627 5228 "not, only then does Mercurial need to read the actual contents of the file to "
dongsheng@627 5229 "see if they've changed. Storing these few extra pieces of information "
dongsheng@627 5230 "dramatically reduces the amount of data that Mercurial needs to read, which "
dongsheng@627 5231 "yields large performance improvements compared to other revision control "
dongsheng@627 5232 "systems."
dongsheng@627 5233 msgstr ""
dongsheng@627 5234
dongsheng@627 5235 #. type: Content of: <book><chapter><title>
dongsheng@650 5236 #: ../en/ch04-daily.xml:5
dongsheng@627 5237 msgid "Mercurial in daily use"
dongsheng@627 5238 msgstr "Mercurial 的日常使用"
dongsheng@627 5239
dongsheng@627 5240 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 5241 #: ../en/ch04-daily.xml:8
dongsheng@627 5242 msgid "Telling Mercurial which files to track"
dongsheng@627 5243 msgstr "告诉 Mercurial 要跟踪哪些文件"
dongsheng@627 5244
dongsheng@627 5245 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5246 #: ../en/ch04-daily.xml:10
dongsheng@627 5247 msgid ""
dongsheng@627 5248 "Mercurial does not work with files in your repository unless you tell it to "
dongsheng@627 5249 "manage them. The <command role=\"hg-cmd\">hg status</command> command will "
dongsheng@627 5250 "tell you which files Mercurial doesn't know about; it uses a <quote><literal>?"
dongsheng@627 5251 "</literal></quote> to display such files."
dongsheng@627 5252 msgstr ""
dongsheng@627 5253
dongsheng@627 5254 #
dongsheng@627 5255 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5256 #: ../en/ch04-daily.xml:17
dongsheng@627 5257 msgid ""
dongsheng@627 5258 "To tell Mercurial to track a file, use the <command role=\"hg-cmd\">hg add</"
dongsheng@627 5259 "command> command. Once you have added a file, the entry in the output of "
dongsheng@627 5260 "<command role=\"hg-cmd\">hg status</command> for that file changes from "
dongsheng@627 5261 "<quote><literal>?</literal></quote> to <quote><literal>A</literal></quote>."
dongsheng@627 5262 msgstr ""
dongsheng@627 5263
dongsheng@627 5264 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5265 #: ../en/ch04-daily.xml:26
dongsheng@627 5266 msgid ""
dongsheng@627 5267 "After you run a <command role=\"hg-cmd\">hg commit</command>, the files that "
dongsheng@627 5268 "you added before the commit will no longer be listed in the output of "
dongsheng@627 5269 "<command role=\"hg-cmd\">hg status</command>. The reason for this is that "
dongsheng@627 5270 "<command role=\"hg-cmd\">hg status</command> only tells you about "
dongsheng@661 5271 "<quote>interesting</quote> files—those that you have modified or told "
dongsheng@661 5272 "Mercurial to do something with—by default. If you have a repository that "
dongsheng@661 5273 "contains thousands of files, you will rarely want to know about files that "
dongsheng@661 5274 "Mercurial is tracking, but that have not changed. (You can still get this "
dongsheng@661 5275 "information; we'll return to this later.)"
dongsheng@627 5276 msgstr ""
dongsheng@627 5277
dongsheng@627 5278 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5279 #: ../en/ch04-daily.xml:38
dongsheng@627 5280 msgid ""
dongsheng@627 5281 "Once you add a file, Mercurial doesn't do anything with it immediately. "
dongsheng@627 5282 "Instead, it will take a snapshot of the file's state the next time you "
dongsheng@627 5283 "perform a commit. It will then continue to track the changes you make to the "
dongsheng@627 5284 "file every time you commit, until you remove the file."
dongsheng@627 5285 msgstr ""
dongsheng@627 5286
dongsheng@627 5287 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5288 #: ../en/ch04-daily.xml:45
dongsheng@627 5289 msgid "Explicit versus implicit file naming"
dongsheng@627 5290 msgstr "明确与隐含文件命名"
dongsheng@627 5291
dongsheng@627 5292 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5293 #: ../en/ch04-daily.xml:47
dongsheng@627 5294 msgid ""
dongsheng@627 5295 "A useful behaviour that Mercurial has is that if you pass the name of a "
dongsheng@627 5296 "directory to a command, every Mercurial command will treat this as <quote>I "
dongsheng@627 5297 "want to operate on every file in this directory and its subdirectories</"
dongsheng@627 5298 "quote>."
dongsheng@627 5299 msgstr ""
dongsheng@627 5300
dongsheng@627 5301 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5302 #: ../en/ch04-daily.xml:54
dongsheng@627 5303 msgid ""
dongsheng@627 5304 "Notice in this example that Mercurial printed the names of the files it "
dongsheng@627 5305 "added, whereas it didn't do so when we added the file named <filename>a</"
dongsheng@627 5306 "filename> in the earlier example."
dongsheng@627 5307 msgstr ""
dongsheng@627 5308
dongsheng@627 5309 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5310 #: ../en/ch04-daily.xml:59
dongsheng@627 5311 msgid ""
dongsheng@627 5312 "What's going on is that in the former case, we explicitly named the file to "
dongsheng@627 5313 "add on the command line, so the assumption that Mercurial makes in such cases "
dongsheng@627 5314 "is that you know what you were doing, and it doesn't print any output."
dongsheng@627 5315 msgstr ""
dongsheng@627 5316
dongsheng@627 5317 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5318 #: ../en/ch04-daily.xml:64
dongsheng@627 5319 msgid ""
dongsheng@627 5320 "However, when we <emphasis>imply</emphasis> the names of files by giving the "
dongsheng@627 5321 "name of a directory, Mercurial takes the extra step of printing the name of "
dongsheng@627 5322 "each file that it does something with. This makes it more clear what is "
dongsheng@627 5323 "happening, and reduces the likelihood of a silent and nasty surprise. This "
dongsheng@627 5324 "behaviour is common to most Mercurial commands."
dongsheng@627 5325 msgstr ""
dongsheng@627 5326
dongsheng@627 5327 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5328 #: ../en/ch04-daily.xml:73
dongsheng@627 5329 msgid "Aside: Mercurial tracks files, not directories"
dongsheng@627 5330 msgstr "旁白: Mercurial 只跟踪文件,不跟踪目录"
dongsheng@627 5331
dongsheng@627 5332 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5333 #: ../en/ch04-daily.xml:75
dongsheng@627 5334 msgid ""
dongsheng@627 5335 "Mercurial does not track directory information. Instead, it tracks the path "
dongsheng@627 5336 "to a file. Before creating a file, it first creates any missing directory "
dongsheng@627 5337 "components of the path. After it deletes a file, it then deletes any empty "
dongsheng@627 5338 "directories that were in the deleted file's path. This sounds like a trivial "
dongsheng@627 5339 "distinction, but it has one minor practical consequence: it is not possible "
dongsheng@627 5340 "to represent a completely empty directory in Mercurial."
dongsheng@627 5341 msgstr ""
dongsheng@627 5342
dongsheng@627 5343 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5344 #: ../en/ch04-daily.xml:84
dongsheng@627 5345 msgid ""
dongsheng@627 5346 "Empty directories are rarely useful, and there are unintrusive workarounds "
dongsheng@627 5347 "that you can use to achieve an appropriate effect. The developers of "
dongsheng@627 5348 "Mercurial thus felt that the complexity that would be required to manage "
dongsheng@627 5349 "empty directories was not worth the limited benefit this feature would bring."
dongsheng@627 5350 msgstr ""
dongsheng@627 5351
dongsheng@627 5352 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5353 #: ../en/ch04-daily.xml:91
dongsheng@627 5354 msgid ""
dongsheng@627 5355 "If you need an empty directory in your repository, there are a few ways to "
dongsheng@627 5356 "achieve this. One is to create a directory, then <command role=\"hg-cmd\">hg "
dongsheng@627 5357 "add</command> a <quote>hidden</quote> file to that directory. On Unix-like "
dongsheng@627 5358 "systems, any file name that begins with a period (<quote><literal>.</"
dongsheng@627 5359 "literal></quote>) is treated as hidden by most commands and GUI tools. This "
dongsheng@627 5360 "approach is illustrated below."
dongsheng@627 5361 msgstr ""
dongsheng@627 5362
dongsheng@627 5363 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5364 #: ../en/ch04-daily.xml:102
dongsheng@627 5365 msgid ""
dongsheng@627 5366 "Another way to tackle a need for an empty directory is to simply create one "
dongsheng@627 5367 "in your automated build scripts before they will need it."
dongsheng@627 5368 msgstr ""
dongsheng@627 5369
dongsheng@627 5370 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 5371 #: ../en/ch04-daily.xml:109
dongsheng@627 5372 msgid "How to stop tracking a file"
dongsheng@627 5373 msgstr "如何停止跟踪文件"
dongsheng@627 5374
dongsheng@627 5375 #
dongsheng@627 5376 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5377 #: ../en/ch04-daily.xml:111
dongsheng@627 5378 msgid ""
dongsheng@627 5379 "Once you decide that a file no longer belongs in your repository, use the "
dongsheng@627 5380 "<command role=\"hg-cmd\">hg remove</command> command; this deletes the file, "
dongsheng@627 5381 "and tells Mercurial to stop tracking it. A removed file is represented in "
dongsheng@627 5382 "the output of <command role=\"hg-cmd\">hg status</command> with a "
dongsheng@627 5383 "<quote><literal>R</literal></quote>."
dongsheng@627 5384 msgstr ""
dongsheng@627 5385
dongsheng@627 5386 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5387 #: ../en/ch04-daily.xml:120
dongsheng@627 5388 msgid ""
dongsheng@627 5389 "After you <command role=\"hg-cmd\">hg remove</command> a file, Mercurial will "
dongsheng@627 5390 "no longer track changes to that file, even if you recreate a file with the "
dongsheng@627 5391 "same name in your working directory. If you do recreate a file with the same "
dongsheng@627 5392 "name and want Mercurial to track the new file, simply <command role=\"hg-cmd"
dongsheng@627 5393 "\">hg add</command> it. Mercurial will know that the newly added file is not "
dongsheng@627 5394 "related to the old file of the same name."
dongsheng@627 5395 msgstr ""
dongsheng@627 5396
dongsheng@627 5397 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5398 #: ../en/ch04-daily.xml:129
dongsheng@627 5399 msgid "Removing a file does not affect its history"
dongsheng@627 5400 msgstr "删除文件不影响历史"
dongsheng@627 5401
dongsheng@627 5402 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5403 #: ../en/ch04-daily.xml:131
dongsheng@627 5404 msgid "It is important to understand that removing a file has only two effects."
dongsheng@627 5405 msgstr ""
dongsheng@627 5406
dongsheng@627 5407 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 5408 #: ../en/ch04-daily.xml:134
dongsheng@627 5409 msgid "It removes the current version of the file from the working directory."
dongsheng@627 5410 msgstr ""
dongsheng@627 5411
dongsheng@627 5412 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 5413 #: ../en/ch04-daily.xml:137
dongsheng@627 5414 msgid ""
dongsheng@627 5415 "It stops Mercurial from tracking changes to the file, from the time of the "
dongsheng@627 5416 "next commit."
dongsheng@627 5417 msgstr ""
dongsheng@627 5418
dongsheng@627 5419 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5420 #: ../en/ch04-daily.xml:140
dongsheng@627 5421 msgid ""
dongsheng@627 5422 "Removing a file <emphasis>does not</emphasis> in any way alter the "
dongsheng@627 5423 "<emphasis>history</emphasis> of the file."
dongsheng@627 5424 msgstr ""
dongsheng@627 5425
dongsheng@627 5426 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5427 #: ../en/ch04-daily.xml:143
dongsheng@627 5428 msgid ""
dongsheng@627 5429 "If you update the working directory to a changeset in which a file that you "
dongsheng@627 5430 "have removed was still tracked, it will reappear in the working directory, "
dongsheng@627 5431 "with the contents it had when you committed that changeset. If you then "
dongsheng@627 5432 "update the working directory to a later changeset, in which the file had been "
dongsheng@627 5433 "removed, Mercurial will once again remove the file from the working directory."
dongsheng@627 5434 msgstr ""
dongsheng@627 5435
dongsheng@627 5436 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5437 #: ../en/ch04-daily.xml:153
dongsheng@627 5438 msgid "Missing files"
dongsheng@627 5439 msgstr "丢失的文件"
dongsheng@627 5440
dongsheng@627 5441 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5442 #: ../en/ch04-daily.xml:155
dongsheng@627 5443 msgid ""
dongsheng@627 5444 "Mercurial considers a file that you have deleted, but not used <command role="
dongsheng@627 5445 "\"hg-cmd\">hg remove</command> to delete, to be <emphasis>missing</"
dongsheng@627 5446 "emphasis>. A missing file is represented with <quote><literal>!</literal></"
dongsheng@627 5447 "quote> in the output of <command role=\"hg-cmd\">hg status</command>. "
dongsheng@627 5448 "Mercurial commands will not generally do anything with missing files."
dongsheng@627 5449 msgstr ""
dongsheng@627 5450
dongsheng@627 5451 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5452 #: ../en/ch04-daily.xml:165
dongsheng@627 5453 msgid ""
dongsheng@627 5454 "If your repository contains a file that <command role=\"hg-cmd\">hg status</"
dongsheng@627 5455 "command> reports as missing, and you want the file to stay gone, you can run "
dongsheng@627 5456 "<command role=\"hg-cmd\">hg remove <option role=\"hg-opt-remove\">--after</"
dongsheng@627 5457 "option></command> at any time later on, to tell Mercurial that you really did "
dongsheng@627 5458 "mean to remove the file."
dongsheng@627 5459 msgstr ""
dongsheng@627 5460
dongsheng@627 5461 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5462 #: ../en/ch04-daily.xml:175
dongsheng@627 5463 msgid ""
dongsheng@627 5464 "On the other hand, if you deleted the missing file by accident, give <command "
dongsheng@627 5465 "role=\"hg-cmd\">hg revert</command> the name of the file to recover. It will "
dongsheng@627 5466 "reappear, in unmodified form."
dongsheng@627 5467 msgstr ""
dongsheng@627 5468
dongsheng@627 5469 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5470 #: ../en/ch04-daily.xml:184
dongsheng@627 5471 msgid "Aside: why tell Mercurial explicitly to remove a file?"
dongsheng@627 5472 msgstr "旁白: 为什么要明确告诉 Mercurial 删除文件?"
dongsheng@627 5473
dongsheng@627 5474 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5475 #: ../en/ch04-daily.xml:187
dongsheng@627 5476 msgid ""
dongsheng@627 5477 "You might wonder why Mercurial requires you to explicitly tell it that you "
dongsheng@627 5478 "are deleting a file. Early during the development of Mercurial, it let you "
dongsheng@627 5479 "delete a file however you pleased; Mercurial would notice the absence of the "
dongsheng@627 5480 "file automatically when you next ran a <command role=\"hg-cmd\">hg commit</"
dongsheng@627 5481 "command>, and stop tracking the file. In practice, this made it too easy to "
dongsheng@627 5482 "accidentally remove a file without noticing."
dongsheng@627 5483 msgstr ""
dongsheng@627 5484
dongsheng@627 5485 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5486 #: ../en/ch04-daily.xml:198
songdongsheng@667 5487 #, fuzzy
dongsheng@661 5488 msgid "Useful shorthand—adding and removing files in one step"
dongsheng@661 5489 msgstr "有用的速记—一个步骤添加和删除文件"
dongsheng@627 5490
dongsheng@627 5491 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5492 #: ../en/ch04-daily.xml:201
dongsheng@627 5493 msgid ""
dongsheng@627 5494 "Mercurial offers a combination command, <command role=\"hg-cmd\">hg "
dongsheng@627 5495 "addremove</command>, that adds untracked files and marks missing files as "
dongsheng@627 5496 "removed."
dongsheng@627 5497 msgstr ""
dongsheng@627 5498
dongsheng@627 5499 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5500 #: ../en/ch04-daily.xml:207
dongsheng@627 5501 msgid ""
dongsheng@627 5502 "The <command role=\"hg-cmd\">hg commit</command> command also provides a "
dongsheng@627 5503 "<option role=\"hg-opt-commit\">-A</option> option that performs this same add-"
dongsheng@627 5504 "and-remove, immediately followed by a commit."
dongsheng@627 5505 msgstr ""
dongsheng@627 5506
dongsheng@627 5507 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 5508 #: ../en/ch04-daily.xml:217
dongsheng@627 5509 msgid "Copying files"
dongsheng@627 5510 msgstr "复制文件"
dongsheng@627 5511
dongsheng@627 5512 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5513 #: ../en/ch04-daily.xml:219
dongsheng@627 5514 msgid ""
dongsheng@627 5515 "Mercurial provides a <command role=\"hg-cmd\">hg copy</command> command that "
dongsheng@627 5516 "lets you make a new copy of a file. When you copy a file using this command, "
dongsheng@627 5517 "Mercurial makes a record of the fact that the new file is a copy of the "
dongsheng@627 5518 "original file. It treats these copied files specially when you merge your "
dongsheng@627 5519 "work with someone else's."
dongsheng@627 5520 msgstr ""
dongsheng@627 5521
dongsheng@627 5522 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5523 #: ../en/ch04-daily.xml:227
dongsheng@627 5524 msgid "The results of copying during a merge"
dongsheng@627 5525 msgstr "合并期间的复制结果"
dongsheng@627 5526
dongsheng@627 5527 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5528 #: ../en/ch04-daily.xml:229
dongsheng@627 5529 msgid ""
dongsheng@627 5530 "What happens during a merge is that changes <quote>follow</quote> a copy. To "
dongsheng@627 5531 "best illustrate what this means, let's create an example. We'll start with "
dongsheng@627 5532 "the usual tiny repository that contains a single file."
dongsheng@627 5533 msgstr ""
dongsheng@627 5534
dongsheng@627 5535 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5536 #: ../en/ch04-daily.xml:236
dongsheng@627 5537 msgid ""
dongsheng@627 5538 "We need to do some work in parallel, so that we'll have something to merge. "
dongsheng@627 5539 "So let's clone our repository."
dongsheng@627 5540 msgstr ""
dongsheng@627 5541
dongsheng@627 5542 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5543 #: ../en/ch04-daily.xml:242
dongsheng@627 5544 msgid ""
dongsheng@627 5545 "Back in our initial repository, let's use the <command role=\"hg-cmd\">hg "
dongsheng@627 5546 "copy</command> command to make a copy of the first file we created."
dongsheng@627 5547 msgstr ""
dongsheng@627 5548
dongsheng@627 5549 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5550 #: ../en/ch04-daily.xml:248
dongsheng@627 5551 msgid ""
dongsheng@627 5552 "If we look at the output of the <command role=\"hg-cmd\">hg status</command> "
dongsheng@627 5553 "command afterwards, the copied file looks just like a normal added file."
dongsheng@627 5554 msgstr ""
dongsheng@627 5555
dongsheng@627 5556 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5557 #: ../en/ch04-daily.xml:254
dongsheng@627 5558 msgid ""
dongsheng@627 5559 "But if we pass the <option role=\"hg-opt-status\">-C</option> option to "
dongsheng@627 5560 "<command role=\"hg-cmd\">hg status</command>, it prints another line of "
dongsheng@627 5561 "output: this is the file that our newly-added file was copied <emphasis>from</"
dongsheng@627 5562 "emphasis>."
dongsheng@627 5563 msgstr ""
dongsheng@627 5564
dongsheng@627 5565 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5566 #: ../en/ch04-daily.xml:262
dongsheng@627 5567 msgid ""
dongsheng@627 5568 "Now, back in the repository we cloned, let's make a change in parallel. "
dongsheng@627 5569 "We'll add a line of content to the original file that we created."
dongsheng@627 5570 msgstr ""
dongsheng@627 5571
dongsheng@627 5572 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5573 #: ../en/ch04-daily.xml:268
dongsheng@627 5574 msgid ""
dongsheng@627 5575 "Now we have a modified <filename>file</filename> in this repository. When we "
dongsheng@627 5576 "pull the changes from the first repository, and merge the two heads, "
dongsheng@627 5577 "Mercurial will propagate the changes that we made locally to <filename>file</"
dongsheng@627 5578 "filename> into its copy, <filename>new-file</filename>."
dongsheng@627 5579 msgstr ""
dongsheng@627 5580
dongsheng@627 5581 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5582 #: ../en/ch04-daily.xml:278
dongsheng@627 5583 msgid "Why should changes follow copies?"
dongsheng@627 5584 msgstr "为什么复制后需要后续修改?"
dongsheng@627 5585
dongsheng@627 5586 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5587 #: ../en/ch04-daily.xml:280
dongsheng@627 5588 msgid ""
dongsheng@627 5589 "This behaviour, of changes to a file propagating out to copies of the file, "
dongsheng@627 5590 "might seem esoteric, but in most cases it's highly desirable."
dongsheng@627 5591 msgstr ""
dongsheng@627 5592
dongsheng@627 5593 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5594 #: ../en/ch04-daily.xml:284
dongsheng@627 5595 msgid ""
dongsheng@627 5596 "First of all, remember that this propagation <emphasis>only</emphasis> "
dongsheng@627 5597 "happens when you merge. So if you <command role=\"hg-cmd\">hg copy</command> "
dongsheng@627 5598 "a file, and subsequently modify the original file during the normal course of "
dongsheng@627 5599 "your work, nothing will happen."
dongsheng@627 5600 msgstr ""
dongsheng@627 5601
dongsheng@627 5602 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5603 #: ../en/ch04-daily.xml:290
dongsheng@627 5604 msgid ""
dongsheng@627 5605 "The second thing to know is that modifications will only propagate across a "
dongsheng@627 5606 "copy as long as the repository that you're pulling changes from "
dongsheng@627 5607 "<emphasis>doesn't know</emphasis> about the copy."
dongsheng@627 5608 msgstr ""
dongsheng@627 5609
dongsheng@627 5610 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5611 #: ../en/ch04-daily.xml:295
dongsheng@627 5612 msgid ""
dongsheng@627 5613 "The reason that Mercurial does this is as follows. Let's say I make an "
dongsheng@627 5614 "important bug fix in a source file, and commit my changes. Meanwhile, you've "
dongsheng@627 5615 "decided to <command role=\"hg-cmd\">hg copy</command> the file in your "
dongsheng@627 5616 "repository, without knowing about the bug or having seen the fix, and you "
dongsheng@627 5617 "have started hacking on your copy of the file."
dongsheng@627 5618 msgstr ""
dongsheng@627 5619
dongsheng@627 5620 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5621 #: ../en/ch04-daily.xml:302
dongsheng@627 5622 msgid ""
dongsheng@627 5623 "If you pulled and merged my changes, and Mercurial <emphasis>didn't</"
dongsheng@627 5624 "emphasis> propagate changes across copies, your source file would now contain "
dongsheng@627 5625 "the bug, and unless you remembered to propagate the bug fix by hand, the bug "
dongsheng@627 5626 "would <emphasis>remain</emphasis> in your copy of the file."
dongsheng@627 5627 msgstr ""
dongsheng@627 5628
dongsheng@627 5629 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5630 #: ../en/ch04-daily.xml:308
dongsheng@627 5631 msgid ""
dongsheng@627 5632 "By automatically propagating the change that fixed the bug from the original "
dongsheng@627 5633 "file to the copy, Mercurial prevents this class of problem. To my knowledge, "
dongsheng@627 5634 "Mercurial is the <emphasis>only</emphasis> revision control system that "
dongsheng@627 5635 "propagates changes across copies like this."
dongsheng@627 5636 msgstr ""
dongsheng@627 5637
dongsheng@627 5638 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5639 #: ../en/ch04-daily.xml:314
dongsheng@627 5640 msgid ""
dongsheng@627 5641 "Once your change history has a record that the copy and subsequent merge "
dongsheng@627 5642 "occurred, there's usually no further need to propagate changes from the "
dongsheng@627 5643 "original file to the copied file, and that's why Mercurial only propagates "
dongsheng@627 5644 "changes across copies until this point, and no further."
dongsheng@627 5645 msgstr ""
dongsheng@627 5646
dongsheng@627 5647 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5648 #: ../en/ch04-daily.xml:322
dongsheng@627 5649 msgid "How to make changes <emphasis>not</emphasis> follow a copy"
dongsheng@627 5650 msgstr "如何让复制后<emphasis>不</emphasis>修改?"
dongsheng@627 5651
dongsheng@627 5652 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5653 #: ../en/ch04-daily.xml:325
dongsheng@627 5654 msgid ""
dongsheng@627 5655 "If, for some reason, you decide that this business of automatically "
dongsheng@627 5656 "propagating changes across copies is not for you, simply use your system's "
dongsheng@627 5657 "normal file copy command (on Unix-like systems, that's <command>cp</command>) "
dongsheng@627 5658 "to make a copy of a file, then <command role=\"hg-cmd\">hg add</command> the "
songdongsheng@658 5659 "new copy by hand. Before you do so, though, please do reread <xref linkend="
songdongsheng@658 5660 "\"sec:daily:why-copy\"/>, and make an informed decision that this behaviour "
songdongsheng@658 5661 "is not appropriate to your specific case."
dongsheng@627 5662 msgstr ""
dongsheng@627 5663
dongsheng@627 5664 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5665 #: ../en/ch04-daily.xml:338
dongsheng@627 5666 msgid "Behaviour of the <command role=\"hg-cmd\">hg copy</command> command"
dongsheng@627 5667 msgstr "命令 <command role=\"hg-cmd\">hg copy</command> 的特性"
dongsheng@627 5668
dongsheng@627 5669 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5670 #: ../en/ch04-daily.xml:341
dongsheng@627 5671 msgid ""
dongsheng@627 5672 "When you use the <command role=\"hg-cmd\">hg copy</command> command, "
dongsheng@627 5673 "Mercurial makes a copy of each source file as it currently stands in the "
dongsheng@627 5674 "working directory. This means that if you make some modifications to a file, "
dongsheng@627 5675 "then <command role=\"hg-cmd\">hg copy</command> it without first having "
dongsheng@627 5676 "committed those changes, the new copy will also contain the modifications you "
dongsheng@627 5677 "have made up until that point. (I find this behaviour a little "
dongsheng@627 5678 "counterintuitive, which is why I mention it here.)"
dongsheng@627 5679 msgstr ""
dongsheng@627 5680
dongsheng@627 5681 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5682 #: ../en/ch04-daily.xml:351
dongsheng@627 5683 msgid ""
dongsheng@627 5684 "The <command role=\"hg-cmd\">hg copy</command> command acts similarly to the "
dongsheng@627 5685 "Unix <command>cp</command> command (you can use the <command role=\"hg-cmd"
dongsheng@627 5686 "\">hg cp</command> alias if you prefer). The last argument is the "
dongsheng@627 5687 "<emphasis>destination</emphasis>, and all prior arguments are "
dongsheng@627 5688 "<emphasis>sources</emphasis>. If you pass it a single file as the source, "
dongsheng@627 5689 "and the destination does not exist, it creates a new file with that name."
dongsheng@627 5690 msgstr ""
dongsheng@627 5691
dongsheng@627 5692 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5693 #: ../en/ch04-daily.xml:362
dongsheng@627 5694 msgid ""
dongsheng@627 5695 "If the destination is a directory, Mercurial copies its sources into that "
dongsheng@627 5696 "directory."
dongsheng@627 5697 msgstr ""
dongsheng@627 5698
dongsheng@627 5699 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5700 #: ../en/ch04-daily.xml:367
dongsheng@627 5701 msgid ""
dongsheng@627 5702 "Copying a directory is recursive, and preserves the directory structure of "
dongsheng@627 5703 "the source."
dongsheng@627 5704 msgstr ""
dongsheng@627 5705
dongsheng@627 5706 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5707 #: ../en/ch04-daily.xml:373
dongsheng@627 5708 msgid ""
dongsheng@627 5709 "If the source and destination are both directories, the source tree is "
dongsheng@627 5710 "recreated in the destination directory."
dongsheng@627 5711 msgstr ""
dongsheng@627 5712
dongsheng@627 5713 #
dongsheng@627 5714 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5715 #: ../en/ch04-daily.xml:378
dongsheng@627 5716 msgid ""
dongsheng@627 5717 "As with the <command role=\"hg-cmd\">hg rename</command> command, if you copy "
dongsheng@627 5718 "a file manually and then want Mercurial to know that you've copied the file, "
dongsheng@627 5719 "simply use the <option role=\"hg-opt-copy\">--after</option> option to "
dongsheng@627 5720 "<command role=\"hg-cmd\">hg copy</command>."
dongsheng@627 5721 msgstr ""
dongsheng@627 5722
dongsheng@627 5723 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 5724 #: ../en/ch04-daily.xml:389
dongsheng@627 5725 msgid "Renaming files"
dongsheng@627 5726 msgstr "改名文件"
dongsheng@627 5727
dongsheng@627 5728 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5729 #: ../en/ch04-daily.xml:391
dongsheng@627 5730 msgid ""
dongsheng@627 5731 "It's rather more common to need to rename a file than to make a copy of it. "
dongsheng@627 5732 "The reason I discussed the <command role=\"hg-cmd\">hg copy</command> command "
dongsheng@627 5733 "before talking about renaming files is that Mercurial treats a rename in "
dongsheng@627 5734 "essentially the same way as a copy. Therefore, knowing what Mercurial does "
dongsheng@627 5735 "when you copy a file tells you what to expect when you rename a file."
dongsheng@627 5736 msgstr ""
dongsheng@627 5737
dongsheng@627 5738 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5739 #: ../en/ch04-daily.xml:399
dongsheng@627 5740 msgid ""
dongsheng@627 5741 "When you use the <command role=\"hg-cmd\">hg rename</command> command, "
dongsheng@627 5742 "Mercurial makes a copy of each source file, then deletes it and marks the "
dongsheng@627 5743 "file as removed."
dongsheng@627 5744 msgstr ""
dongsheng@627 5745
dongsheng@627 5746 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5747 #: ../en/ch04-daily.xml:405
dongsheng@627 5748 msgid ""
dongsheng@627 5749 "The <command role=\"hg-cmd\">hg status</command> command shows the newly "
dongsheng@627 5750 "copied file as added, and the copied-from file as removed."
dongsheng@627 5751 msgstr ""
dongsheng@627 5752
dongsheng@627 5753 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5754 #: ../en/ch04-daily.xml:411
dongsheng@627 5755 msgid ""
dongsheng@627 5756 "As with the results of a <command role=\"hg-cmd\">hg copy</command>, we must "
dongsheng@627 5757 "use the <option role=\"hg-opt-status\">-C</option> option to <command role="
dongsheng@627 5758 "\"hg-cmd\">hg status</command> to see that the added file is really being "
dongsheng@627 5759 "tracked by Mercurial as a copy of the original, now removed, file."
dongsheng@627 5760 msgstr ""
dongsheng@627 5761
dongsheng@627 5762 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5763 #: ../en/ch04-daily.xml:420
dongsheng@627 5764 msgid ""
dongsheng@627 5765 "As with <command role=\"hg-cmd\">hg remove</command> and <command role=\"hg-"
dongsheng@627 5766 "cmd\">hg copy</command>, you can tell Mercurial about a rename after the fact "
dongsheng@627 5767 "using the <option role=\"hg-opt-rename\">--after</option> option. In most "
dongsheng@627 5768 "other respects, the behaviour of the <command role=\"hg-cmd\">hg rename</"
dongsheng@627 5769 "command> command, and the options it accepts, are similar to the <command "
dongsheng@627 5770 "role=\"hg-cmd\">hg copy</command> command."
dongsheng@627 5771 msgstr ""
dongsheng@627 5772
dongsheng@627 5773 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5774 #: ../en/ch04-daily.xml:430
dongsheng@627 5775 msgid "Renaming files and merging changes"
dongsheng@627 5776 msgstr "改名文件与合并修改"
dongsheng@627 5777
dongsheng@627 5778 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5779 #: ../en/ch04-daily.xml:432
dongsheng@627 5780 msgid ""
dongsheng@627 5781 "Since Mercurial's rename is implemented as copy-and-remove, the same "
dongsheng@627 5782 "propagation of changes happens when you merge after a rename as after a copy."
dongsheng@627 5783 msgstr ""
dongsheng@627 5784
dongsheng@627 5785 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5786 #: ../en/ch04-daily.xml:436
dongsheng@627 5787 msgid ""
dongsheng@627 5788 "If I modify a file, and you rename it to a new name, and then we merge our "
dongsheng@627 5789 "respective changes, my modifications to the file under its original name will "
dongsheng@627 5790 "be propagated into the file under its new name. (This is something you might "
dongsheng@627 5791 "expect to <quote>simply work,</quote> but not all revision control systems "
dongsheng@627 5792 "actually do this.)"
dongsheng@627 5793 msgstr ""
dongsheng@627 5794
dongsheng@627 5795 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5796 #: ../en/ch04-daily.xml:443
dongsheng@627 5797 msgid ""
dongsheng@627 5798 "Whereas having changes follow a copy is a feature where you can perhaps nod "
dongsheng@627 5799 "and say <quote>yes, that might be useful,</quote> it should be clear that "
dongsheng@627 5800 "having them follow a rename is definitely important. Without this facility, "
dongsheng@627 5801 "it would simply be too easy for changes to become orphaned when files are "
dongsheng@627 5802 "renamed."
dongsheng@627 5803 msgstr ""
dongsheng@627 5804
dongsheng@627 5805 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5806 #: ../en/ch04-daily.xml:452
dongsheng@627 5807 msgid "Divergent renames and merging"
dongsheng@627 5808 msgstr "改名与合并的分歧"
dongsheng@627 5809
dongsheng@627 5810 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5811 #: ../en/ch04-daily.xml:454
dongsheng@627 5812 msgid ""
dongsheng@661 5813 "The case of diverging names occurs when two developers start with a file—"
dongsheng@661 5814 "let's call it <filename>foo</filename>&emdash;in their respective "
dongsheng@627 5815 "repositories."
dongsheng@627 5816 msgstr ""
dongsheng@627 5817
dongsheng@627 5818 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5819 #: ../en/ch04-daily.xml:461
dongsheng@627 5820 msgid "Anne renames the file to <filename>bar</filename>."
dongsheng@627 5821 msgstr ""
dongsheng@627 5822
dongsheng@627 5823 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5824 #: ../en/ch04-daily.xml:465
dongsheng@627 5825 msgid "Meanwhile, Bob renames it to <filename>quux</filename>."
dongsheng@627 5826 msgstr ""
dongsheng@627 5827
dongsheng@627 5828 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5829 #: ../en/ch04-daily.xml:470
dongsheng@627 5830 msgid ""
dongsheng@627 5831 "I like to think of this as a conflict because each developer has expressed "
dongsheng@627 5832 "different intentions about what the file ought to be named."
dongsheng@627 5833 msgstr ""
dongsheng@627 5834
dongsheng@627 5835 #
dongsheng@627 5836 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5837 #: ../en/ch04-daily.xml:474
dongsheng@627 5838 msgid ""
dongsheng@627 5839 "What do you think should happen when they merge their work? Mercurial's "
dongsheng@627 5840 "actual behaviour is that it always preserves <emphasis>both</emphasis> names "
dongsheng@627 5841 "when it merges changesets that contain divergent renames."
dongsheng@627 5842 msgstr ""
dongsheng@627 5843
dongsheng@627 5844 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5845 #: ../en/ch04-daily.xml:481
dongsheng@627 5846 msgid ""
dongsheng@627 5847 "Notice that Mercurial does warn about the divergent renames, but it leaves it "
dongsheng@627 5848 "up to you to do something about the divergence after the merge."
dongsheng@627 5849 msgstr ""
dongsheng@627 5850
dongsheng@627 5851 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5852 #: ../en/ch04-daily.xml:487
dongsheng@627 5853 msgid "Convergent renames and merging"
dongsheng@627 5854 msgstr "收敛改名与合并"
dongsheng@627 5855
dongsheng@627 5856 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5857 #: ../en/ch04-daily.xml:489
dongsheng@627 5858 msgid ""
dongsheng@627 5859 "Another kind of rename conflict occurs when two people choose to rename "
dongsheng@627 5860 "different <emphasis>source</emphasis> files to the same "
dongsheng@627 5861 "<emphasis>destination</emphasis>. In this case, Mercurial runs its normal "
dongsheng@627 5862 "merge machinery, and lets you guide it to a suitable resolution."
dongsheng@627 5863 msgstr ""
dongsheng@627 5864
dongsheng@627 5865 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 5866 #: ../en/ch04-daily.xml:497
dongsheng@627 5867 msgid "Other name-related corner cases"
dongsheng@627 5868 msgstr "其它名称相关的角落"
dongsheng@627 5869
dongsheng@627 5870 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 5871 #: ../en/ch04-daily.xml:499
dongsheng@627 5872 msgid ""
dongsheng@627 5873 "Mercurial has a longstanding bug in which it fails to handle a merge where "
dongsheng@627 5874 "one side has a file with a given name, while another has a directory with the "
dongsheng@627 5875 "same name. This is documented as <ulink role=\"hg-bug\" url=\"http://www."
dongsheng@627 5876 "selenic.com/mercurial/bts/issue29\">issue 29</ulink>."
dongsheng@627 5877 msgstr ""
dongsheng@627 5878
dongsheng@627 5879 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 5880 #: ../en/ch04-daily.xml:511
dongsheng@627 5881 msgid "Recovering from mistakes"
dongsheng@627 5882 msgstr "从错误恢复"
dongsheng@627 5883
dongsheng@627 5884 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5885 #: ../en/ch04-daily.xml:513
dongsheng@627 5886 msgid ""
dongsheng@627 5887 "Mercurial has some useful commands that will help you to recover from some "
dongsheng@627 5888 "common mistakes."
dongsheng@627 5889 msgstr ""
dongsheng@627 5890
dongsheng@627 5891 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5892 #: ../en/ch04-daily.xml:516
dongsheng@627 5893 msgid ""
dongsheng@627 5894 "The <command role=\"hg-cmd\">hg revert</command> command lets you undo "
dongsheng@627 5895 "changes that you have made to your working directory. For example, if you "
dongsheng@627 5896 "<command role=\"hg-cmd\">hg add</command> a file by accident, just run "
dongsheng@627 5897 "<command role=\"hg-cmd\">hg revert</command> with the name of the file you "
dongsheng@627 5898 "added, and while the file won't be touched in any way, it won't be tracked "
dongsheng@627 5899 "for adding by Mercurial any longer, either. You can also use <command role="
dongsheng@627 5900 "\"hg-cmd\">hg revert</command> to get rid of erroneous changes to a file."
dongsheng@627 5901 msgstr ""
dongsheng@627 5902
dongsheng@627 5903 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5904 #: ../en/ch04-daily.xml:526
dongsheng@627 5905 msgid ""
dongsheng@627 5906 "It's useful to remember that the <command role=\"hg-cmd\">hg revert</command> "
dongsheng@627 5907 "command is useful for changes that you have not yet committed. Once you've "
dongsheng@627 5908 "committed a change, if you decide it was a mistake, you can still do "
dongsheng@627 5909 "something about it, though your options may be more limited."
dongsheng@627 5910 msgstr ""
dongsheng@627 5911
dongsheng@627 5912 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5913 #: ../en/ch04-daily.xml:532
dongsheng@627 5914 msgid ""
dongsheng@627 5915 "For more information about the <command role=\"hg-cmd\">hg revert</command> "
dongsheng@627 5916 "command, and details about how to deal with changes you have already "
songdongsheng@658 5917 "committed, see <xref linkend=\"chap:undo\"/>."
dongsheng@627 5918 msgstr ""
dongsheng@627 5919
dongsheng@627 5920 #. type: Content of: <book><chapter><title>
dongsheng@650 5921 #: ../en/ch05-collab.xml:5
dongsheng@627 5922 msgid "Collaborating with other people"
dongsheng@627 5923 msgstr "团体协作"
dongsheng@627 5924
dongsheng@627 5925 #. type: Content of: <book><chapter><para>
dongsheng@650 5926 #: ../en/ch05-collab.xml:7
dongsheng@627 5927 msgid ""
dongsheng@627 5928 "As a completely decentralised tool, Mercurial doesn't impose any policy on "
dongsheng@627 5929 "how people ought to work with each other. However, if you're new to "
dongsheng@627 5930 "distributed revision control, it helps to have some tools and examples in "
dongsheng@627 5931 "mind when you're thinking about possible workflow models."
dongsheng@627 5932 msgstr ""
dongsheng@627 5933
dongsheng@627 5934 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 5935 #: ../en/ch05-collab.xml:14
dongsheng@627 5936 msgid "Mercurial's web interface"
dongsheng@630 5937 msgstr "Mercurial 的 web 接口"
dongsheng@627 5938
dongsheng@627 5939 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5940 #: ../en/ch05-collab.xml:16
dongsheng@627 5941 msgid ""
dongsheng@627 5942 "Mercurial has a powerful web interface that provides several useful "
dongsheng@627 5943 "capabilities."
dongsheng@627 5944 msgstr ""
dongsheng@627 5945
dongsheng@627 5946 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5947 #: ../en/ch05-collab.xml:19
dongsheng@627 5948 msgid ""
dongsheng@627 5949 "For interactive use, the web interface lets you browse a single repository or "
dongsheng@627 5950 "a collection of repositories. You can view the history of a repository, "
dongsheng@627 5951 "examine each change (comments and diffs), and view the contents of each "
dongsheng@627 5952 "directory and file."
dongsheng@627 5953 msgstr ""
dongsheng@627 5954
dongsheng@627 5955 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5956 #: ../en/ch05-collab.xml:24
dongsheng@627 5957 msgid ""
dongsheng@627 5958 "Also for human consumption, the web interface provides an RSS feed of the "
dongsheng@627 5959 "changes in a repository. This lets you <quote>subscribe</quote> to a "
dongsheng@627 5960 "repository using your favourite feed reader, and be automatically notified of "
dongsheng@627 5961 "activity in that repository as soon as it happens. I find this capability "
dongsheng@627 5962 "much more convenient than the model of subscribing to a mailing list to which "
dongsheng@627 5963 "notifications are sent, as it requires no additional configuration on the "
dongsheng@627 5964 "part of whoever is serving the repository."
dongsheng@627 5965 msgstr ""
dongsheng@627 5966
dongsheng@627 5967 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5968 #: ../en/ch05-collab.xml:34
dongsheng@627 5969 msgid ""
dongsheng@627 5970 "The web interface also lets remote users clone a repository, pull changes "
dongsheng@627 5971 "from it, and (when the server is configured to permit it) push changes back "
dongsheng@627 5972 "to it. Mercurial's HTTP tunneling protocol aggressively compresses data, so "
dongsheng@627 5973 "that it works efficiently even over low-bandwidth network connections."
dongsheng@627 5974 msgstr ""
dongsheng@627 5975
dongsheng@627 5976 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5977 #: ../en/ch05-collab.xml:40
dongsheng@627 5978 msgid ""
dongsheng@627 5979 "The easiest way to get started with the web interface is to use your web "
dongsheng@627 5980 "browser to visit an existing repository, such as the master Mercurial "
dongsheng@627 5981 "repository at <ulink url=\"http://www.selenic.com/repo/hg?style=gitweb"
dongsheng@627 5982 "\">http://www.selenic.com/repo/hg?style=gitweb</ulink>."
dongsheng@627 5983 msgstr ""
dongsheng@627 5984
dongsheng@627 5985 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 5986 #: ../en/ch05-collab.xml:45
dongsheng@627 5987 msgid ""
dongsheng@627 5988 "If you're interested in providing a web interface to your own repositories, "
dongsheng@627 5989 "Mercurial provides two ways to do this. The first is using the <command role="
dongsheng@627 5990 "\"hg-cmd\">hg serve</command> command, which is best suited to short-term "
songdongsheng@658 5991 "<quote>lightweight</quote> serving. See <xref linkend=\"sec:collab:serve\"/> "
songdongsheng@658 5992 "below for details of how to use this command. If you have a long-lived "
songdongsheng@658 5993 "repository that you'd like to make permanently available, Mercurial has built-"
songdongsheng@658 5994 "in support for the CGI (Common Gateway Interface) standard, which all common "
songdongsheng@658 5995 "web servers support. See <xref linkend=\"sec:collab:cgi\"/> for details of "
songdongsheng@658 5996 "CGI configuration."
dongsheng@627 5997 msgstr ""
dongsheng@627 5998
dongsheng@627 5999 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 6000 #: ../en/ch05-collab.xml:60
dongsheng@627 6001 msgid "Collaboration models"
dongsheng@630 6002 msgstr "协作模型"
dongsheng@627 6003
dongsheng@627 6004 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 6005 #: ../en/ch05-collab.xml:62
dongsheng@627 6006 msgid ""
dongsheng@627 6007 "With a suitably flexible tool, making decisions about workflow is much more "
dongsheng@627 6008 "of a social engineering challenge than a technical one. Mercurial imposes few "
dongsheng@627 6009 "limitations on how you can structure the flow of work in a project, so it's "
dongsheng@627 6010 "up to you and your group to set up and live with a model that matches your "
dongsheng@627 6011 "own particular needs."
dongsheng@627 6012 msgstr ""
dongsheng@627 6013
dongsheng@627 6014 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 6015 #: ../en/ch05-collab.xml:70
dongsheng@627 6016 msgid "Factors to keep in mind"
dongsheng@630 6017 msgstr "要牢记的因素"
dongsheng@627 6018
dongsheng@627 6019 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6020 #: ../en/ch05-collab.xml:72
dongsheng@627 6021 msgid ""
dongsheng@627 6022 "The most important aspect of any model that you must keep in mind is how well "
dongsheng@627 6023 "it matches the needs and capabilities of the people who will be using it. "
dongsheng@627 6024 "This might seem self-evident; even so, you still can't afford to forget it "
dongsheng@627 6025 "for a moment."
dongsheng@627 6026 msgstr ""
dongsheng@627 6027
dongsheng@627 6028 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6029 #: ../en/ch05-collab.xml:78
dongsheng@627 6030 msgid ""
dongsheng@627 6031 "I once put together a workflow model that seemed to make perfect sense to me, "
dongsheng@627 6032 "but that caused a considerable amount of consternation and strife within my "
dongsheng@627 6033 "development team. In spite of my attempts to explain why we needed a complex "
dongsheng@627 6034 "set of branches, and how changes ought to flow between them, a few team "
dongsheng@627 6035 "members revolted. Even though they were smart people, they didn't want to "
dongsheng@627 6036 "pay attention to the constraints we were operating under, or face the "
dongsheng@627 6037 "consequences of those constraints in the details of the model that I was "
dongsheng@627 6038 "advocating."
dongsheng@627 6039 msgstr ""
dongsheng@627 6040
dongsheng@627 6041 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6042 #: ../en/ch05-collab.xml:88
dongsheng@627 6043 msgid ""
dongsheng@627 6044 "Don't sweep foreseeable social or technical problems under the rug. Whatever "
dongsheng@627 6045 "scheme you put into effect, you should plan for mistakes and problem "
dongsheng@627 6046 "scenarios. Consider adding automated machinery to prevent, or quickly "
dongsheng@627 6047 "recover from, trouble that you can anticipate. As an example, if you intend "
dongsheng@627 6048 "to have a branch with not-for-release changes in it, you'd do well to think "
dongsheng@627 6049 "early about the possibility that someone might accidentally merge those "
dongsheng@627 6050 "changes into a release branch. You could avoid this particular problem by "
dongsheng@627 6051 "writing a hook that prevents changes from being merged from an inappropriate "
dongsheng@627 6052 "branch."
dongsheng@627 6053 msgstr ""
dongsheng@627 6054
dongsheng@627 6055 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 6056 #: ../en/ch05-collab.xml:102
dongsheng@627 6057 msgid "Informal anarchy"
dongsheng@630 6058 msgstr "无政府状态"
dongsheng@627 6059
dongsheng@627 6060 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6061 #: ../en/ch05-collab.xml:104
dongsheng@627 6062 msgid ""
dongsheng@627 6063 "I wouldn't suggest an <quote>anything goes</quote> approach as something "
dongsheng@627 6064 "sustainable, but it's a model that's easy to grasp, and it works perfectly "
dongsheng@627 6065 "well in a few unusual situations."
dongsheng@627 6066 msgstr ""
dongsheng@627 6067
dongsheng@627 6068 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6069 #: ../en/ch05-collab.xml:109
dongsheng@627 6070 msgid ""
dongsheng@627 6071 "As one example, many projects have a loose-knit group of collaborators who "
dongsheng@627 6072 "rarely physically meet each other. Some groups like to overcome the "
dongsheng@627 6073 "isolation of working at a distance by organising occasional <quote>sprints</"
dongsheng@627 6074 "quote>. In a sprint, a number of people get together in a single location (a "
dongsheng@627 6075 "company's conference room, a hotel meeting room, that kind of place) and "
dongsheng@627 6076 "spend several days more or less locked in there, hacking intensely on a "
dongsheng@627 6077 "handful of projects."
dongsheng@627 6078 msgstr ""
dongsheng@627 6079
dongsheng@627 6080 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6081 #: ../en/ch05-collab.xml:118
dongsheng@627 6082 msgid ""
dongsheng@627 6083 "A sprint is the perfect place to use the <command role=\"hg-cmd\">hg serve</"
dongsheng@627 6084 "command> command, since <command role=\"hg-cmd\">hg serve</command> does not "
dongsheng@627 6085 "require any fancy server infrastructure. You can get started with <command "
songdongsheng@658 6086 "role=\"hg-cmd\">hg serve</command> in moments, by reading <xref linkend=\"sec:"
songdongsheng@658 6087 "collab:serve\"/> below. Then simply tell the person next to you that you're "
songdongsheng@658 6088 "running a server, send the URL to them in an instant message, and you "
songdongsheng@658 6089 "immediately have a quick-turnaround way to work together. They can type your "
songdongsheng@658 6090 "URL into their web browser and quickly review your changes; or they can pull "
songdongsheng@658 6091 "a bugfix from you and verify it; or they can clone a branch containing a new "
songdongsheng@658 6092 "feature and try it out."
dongsheng@627 6093 msgstr ""
dongsheng@627 6094
dongsheng@627 6095 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6096 #: ../en/ch05-collab.xml:132
dongsheng@627 6097 msgid ""
dongsheng@627 6098 "The charm, and the problem, with doing things in an ad hoc fashion like this "
dongsheng@627 6099 "is that only people who know about your changes, and where they are, can see "
dongsheng@627 6100 "them. Such an informal approach simply doesn't scale beyond a handful "
dongsheng@627 6101 "people, because each individual needs to know about $n$ different "
dongsheng@627 6102 "repositories to pull from."
dongsheng@627 6103 msgstr ""
dongsheng@627 6104
dongsheng@627 6105 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 6106 #: ../en/ch05-collab.xml:141
dongsheng@627 6107 msgid "A single central repository"
dongsheng@630 6108 msgstr "单一中央版本库"
dongsheng@627 6109
dongsheng@627 6110 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6111 #: ../en/ch05-collab.xml:143
dongsheng@627 6112 msgid ""
dongsheng@627 6113 "For smaller projects migrating from a centralised revision control tool, "
dongsheng@627 6114 "perhaps the easiest way to get started is to have changes flow through a "
dongsheng@627 6115 "single shared central repository. This is also the most common "
dongsheng@627 6116 "<quote>building block</quote> for more ambitious workflow schemes."
dongsheng@627 6117 msgstr ""
dongsheng@627 6118
dongsheng@627 6119 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6120 #: ../en/ch05-collab.xml:149
dongsheng@627 6121 msgid ""
dongsheng@627 6122 "Contributors start by cloning a copy of this repository. They can pull "
dongsheng@627 6123 "changes from it whenever they need to, and some (perhaps all) developers have "
dongsheng@627 6124 "permission to push a change back when they're ready for other people to see "
dongsheng@627 6125 "it."
dongsheng@627 6126 msgstr ""
dongsheng@627 6127
dongsheng@627 6128 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6129 #: ../en/ch05-collab.xml:154
dongsheng@627 6130 msgid ""
dongsheng@627 6131 "Under this model, it can still often make sense for people to pull changes "
dongsheng@627 6132 "directly from each other, without going through the central repository. "
dongsheng@627 6133 "Consider a case in which I have a tentative bug fix, but I am worried that if "
dongsheng@627 6134 "I were to publish it to the central repository, it might subsequently break "
dongsheng@627 6135 "everyone else's trees as they pull it. To reduce the potential for damage, I "
dongsheng@627 6136 "can ask you to clone my repository into a temporary repository of your own "
dongsheng@627 6137 "and test it. This lets us put off publishing the potentially unsafe change "
dongsheng@627 6138 "until it has had a little testing."
dongsheng@627 6139 msgstr ""
dongsheng@627 6140
dongsheng@627 6141 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6142 #: ../en/ch05-collab.xml:165
dongsheng@627 6143 msgid ""
dongsheng@627 6144 "In this kind of scenario, people usually use the <command>ssh</command> "
dongsheng@627 6145 "protocol to securely push changes to the central repository, as documented in "
songdongsheng@658 6146 "<xref linkend=\"sec:collab:ssh\"/>. It's also usual to publish a read-only "
songdongsheng@658 6147 "copy of the repository over HTTP using CGI, as in <xref linkend=\"sec:collab:"
songdongsheng@658 6148 "cgi\"/>. Publishing over HTTP satisfies the needs of people who don't have "
songdongsheng@658 6149 "push access, and those who want to use web browsers to browse the "
songdongsheng@658 6150 "repository's history."
dongsheng@627 6151 msgstr ""
dongsheng@627 6152
dongsheng@627 6153 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6154 #: ../en/ch05-collab.xml:177
dongsheng@627 6155 msgid "Working with multiple branches"
dongsheng@630 6156 msgstr "使用多个分支工作"
dongsheng@627 6157
dongsheng@627 6158 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6159 #: ../en/ch05-collab.xml:179
dongsheng@627 6160 msgid ""
dongsheng@627 6161 "Projects of any significant size naturally tend to make progress on several "
dongsheng@627 6162 "fronts simultaneously. In the case of software, it's common for a project to "
dongsheng@627 6163 "go through periodic official releases. A release might then go into "
dongsheng@627 6164 "<quote>maintenance mode</quote> for a while after its first publication; "
dongsheng@627 6165 "maintenance releases tend to contain only bug fixes, not new features. In "
dongsheng@627 6166 "parallel with these maintenance releases, one or more future releases may be "
dongsheng@627 6167 "under development. People normally use the word <quote>branch</quote> to "
dongsheng@627 6168 "refer to one of these many slightly different directions in which development "
dongsheng@627 6169 "is proceeding."
dongsheng@627 6170 msgstr ""
dongsheng@627 6171
dongsheng@627 6172 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6173 #: ../en/ch05-collab.xml:192
dongsheng@627 6174 msgid ""
dongsheng@627 6175 "Mercurial is particularly well suited to managing a number of simultaneous, "
dongsheng@627 6176 "but not identical, branches. Each <quote>development direction</quote> can "
dongsheng@627 6177 "live in its own central repository, and you can merge changes from one to "
dongsheng@627 6178 "another as the need arises. Because repositories are independent of each "
dongsheng@627 6179 "other, unstable changes in a development branch will never affect a stable "
dongsheng@627 6180 "branch unless someone explicitly merges those changes in."
dongsheng@627 6181 msgstr ""
dongsheng@627 6182
dongsheng@627 6183 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6184 #: ../en/ch05-collab.xml:201
dongsheng@627 6185 msgid ""
dongsheng@627 6186 "Here's an example of how this can work in practice. Let's say you have one "
dongsheng@627 6187 "<quote>main branch</quote> on a central server."
dongsheng@627 6188 msgstr ""
dongsheng@627 6189
dongsheng@627 6190 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6191 #: ../en/ch05-collab.xml:207
dongsheng@627 6192 msgid "People clone it, make changes locally, test them, and push them back."
dongsheng@627 6193 msgstr ""
dongsheng@627 6194
dongsheng@627 6195 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6196 #: ../en/ch05-collab.xml:210
dongsheng@627 6197 msgid ""
dongsheng@627 6198 "Once the main branch reaches a release milestone, you can use the <command "
dongsheng@627 6199 "role=\"hg-cmd\">hg tag</command> command to give a permanent name to the "
dongsheng@627 6200 "milestone revision."
dongsheng@627 6201 msgstr ""
dongsheng@627 6202
dongsheng@627 6203 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6204 #: ../en/ch05-collab.xml:216
dongsheng@627 6205 msgid "Let's say some ongoing development occurs on the main branch."
dongsheng@627 6206 msgstr ""
dongsheng@627 6207
dongsheng@627 6208 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6209 #: ../en/ch05-collab.xml:221
dongsheng@627 6210 msgid ""
dongsheng@627 6211 "Using the tag that was recorded at the milestone, people who clone that "
dongsheng@627 6212 "repository at any time in the future can use <command role=\"hg-cmd\">hg "
dongsheng@627 6213 "update</command> to get a copy of the working directory exactly as it was "
dongsheng@627 6214 "when that tagged revision was committed."
dongsheng@627 6215 msgstr ""
dongsheng@627 6216
dongsheng@627 6217 #
dongsheng@627 6218 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6219 #: ../en/ch05-collab.xml:229
dongsheng@627 6220 msgid ""
dongsheng@627 6221 "In addition, immediately after the main branch is tagged, someone can then "
dongsheng@627 6222 "clone the main branch on the server to a new <quote>stable</quote> branch, "
dongsheng@627 6223 "also on the server."
dongsheng@627 6224 msgstr ""
dongsheng@627 6225
dongsheng@627 6226 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6227 #: ../en/ch05-collab.xml:235
dongsheng@627 6228 msgid ""
dongsheng@627 6229 "Someone who needs to make a change to the stable branch can then clone "
dongsheng@627 6230 "<emphasis>that</emphasis> repository, make their changes, commit, and push "
dongsheng@627 6231 "their changes back there."
dongsheng@627 6232 msgstr ""
dongsheng@627 6233
dongsheng@627 6234 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6235 #: ../en/ch05-collab.xml:241
dongsheng@627 6236 msgid ""
dongsheng@627 6237 "Because Mercurial repositories are independent, and Mercurial doesn't move "
dongsheng@627 6238 "changes around automatically, the stable and main branches are "
dongsheng@627 6239 "<emphasis>isolated</emphasis> from each other. The changes that you made on "
dongsheng@627 6240 "the main branch don't <quote>leak</quote> to the stable branch, and vice "
dongsheng@627 6241 "versa."
dongsheng@627 6242 msgstr ""
dongsheng@627 6243
dongsheng@627 6244 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6245 #: ../en/ch05-collab.xml:248
dongsheng@627 6246 msgid ""
dongsheng@627 6247 "You'll often want all of your bugfixes on the stable branch to show up on the "
dongsheng@627 6248 "main branch, too. Rather than rewrite a bugfix on the main branch, you can "
dongsheng@627 6249 "simply pull and merge changes from the stable to the main branch, and "
dongsheng@627 6250 "Mercurial will bring those bugfixes in for you."
dongsheng@627 6251 msgstr ""
dongsheng@627 6252
dongsheng@627 6253 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6254 #: ../en/ch05-collab.xml:256
dongsheng@627 6255 msgid ""
dongsheng@627 6256 "The main branch will still contain changes that are not on the stable branch, "
dongsheng@627 6257 "but it will also contain all of the bugfixes from the stable branch. The "
dongsheng@627 6258 "stable branch remains unaffected by these changes."
dongsheng@627 6259 msgstr ""
dongsheng@627 6260
songdongsheng@658 6261 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 6262 #: ../en/ch05-collab.xml:263 ../en/ch05-collab.xml:273
dongsheng@627 6263 msgid "Feature branches"
dongsheng@630 6264 msgstr "特性分支"
dongsheng@627 6265
dongsheng@627 6266 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6267 #: ../en/ch05-collab.xml:265
dongsheng@627 6268 msgid ""
dongsheng@627 6269 "For larger projects, an effective way to manage change is to break up a team "
dongsheng@627 6270 "into smaller groups. Each group has a shared branch of its own, cloned from "
dongsheng@627 6271 "a single <quote>master</quote> branch used by the entire project. People "
dongsheng@627 6272 "working on an individual branch are typically quite isolated from "
dongsheng@627 6273 "developments on other branches."
dongsheng@627 6274 msgstr ""
dongsheng@627 6275
songdongsheng@658 6276 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@650 6277 #: ../en/ch05-collab.xml:275
dongsheng@641 6278 msgid ""
songdongsheng@658 6279 "<imageobject><imagedata width=\"100%\" fileref=\"figs/feature-branches.png\"/"
songdongsheng@658 6280 "></imageobject>"
songdongsheng@658 6281 msgstr ""
songdongsheng@658 6282
songdongsheng@658 6283 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6284 #: ../en/ch05-collab.xml:280
dongsheng@627 6285 msgid ""
dongsheng@627 6286 "When a particular feature is deemed to be in suitable shape, someone on that "
dongsheng@627 6287 "feature team pulls and merges from the master branch into the feature branch, "
dongsheng@627 6288 "then pushes back up to the master branch."
dongsheng@627 6289 msgstr ""
dongsheng@627 6290
dongsheng@627 6291 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6292 #: ../en/ch05-collab.xml:287
dongsheng@627 6293 msgid "The release train"
dongsheng@630 6294 msgstr "发布列车"
dongsheng@627 6295
dongsheng@627 6296 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6297 #: ../en/ch05-collab.xml:289
dongsheng@627 6298 msgid ""
dongsheng@627 6299 "Some projects are organised on a <quote>train</quote> basis: a release is "
dongsheng@627 6300 "scheduled to happen every few months, and whatever features are ready when "
dongsheng@627 6301 "the <quote>train</quote> is ready to leave are allowed in."
dongsheng@627 6302 msgstr ""
dongsheng@627 6303
dongsheng@627 6304 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6305 #: ../en/ch05-collab.xml:294
dongsheng@627 6306 msgid ""
dongsheng@627 6307 "This model resembles working with feature branches. The difference is that "
dongsheng@627 6308 "when a feature branch misses a train, someone on the feature team pulls and "
dongsheng@627 6309 "merges the changes that went out on that train release into the feature "
dongsheng@627 6310 "branch, and the team continues its work on top of that release so that their "
dongsheng@627 6311 "feature can make the next release."
dongsheng@627 6312 msgstr ""
dongsheng@627 6313
dongsheng@627 6314 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6315 #: ../en/ch05-collab.xml:303
dongsheng@627 6316 msgid "The Linux kernel model"
dongsheng@630 6317 msgstr "Linux 内核模型"
dongsheng@627 6318
dongsheng@627 6319 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6320 #: ../en/ch05-collab.xml:305
dongsheng@627 6321 msgid ""
dongsheng@627 6322 "The development of the Linux kernel has a shallow hierarchical structure, "
dongsheng@627 6323 "surrounded by a cloud of apparent chaos. Because most Linux developers use "
dongsheng@627 6324 "<command>git</command>, a distributed revision control tool with capabilities "
dongsheng@627 6325 "similar to Mercurial, it's useful to describe the way work flows in that "
dongsheng@627 6326 "environment; if you like the ideas, the approach translates well across tools."
dongsheng@627 6327 msgstr ""
dongsheng@627 6328
dongsheng@627 6329 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6330 #: ../en/ch05-collab.xml:313
dongsheng@627 6331 msgid ""
dongsheng@627 6332 "At the center of the community sits Linus Torvalds, the creator of Linux. He "
dongsheng@627 6333 "publishes a single source repository that is considered the "
dongsheng@627 6334 "<quote>authoritative</quote> current tree by the entire developer community. "
dongsheng@627 6335 "Anyone can clone Linus's tree, but he is very choosy about whose trees he "
dongsheng@627 6336 "pulls from."
dongsheng@627 6337 msgstr ""
dongsheng@627 6338
dongsheng@627 6339 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6340 #: ../en/ch05-collab.xml:320
dongsheng@627 6341 msgid ""
dongsheng@627 6342 "Linus has a number of <quote>trusted lieutenants</quote>. As a general rule, "
dongsheng@627 6343 "he pulls whatever changes they publish, in most cases without even reviewing "
dongsheng@627 6344 "those changes. Some of those lieutenants are generally agreed to be "
dongsheng@627 6345 "<quote>maintainers</quote>, responsible for specific subsystems within the "
dongsheng@627 6346 "kernel. If a random kernel hacker wants to make a change to a subsystem that "
dongsheng@627 6347 "they want to end up in Linus's tree, they must find out who the subsystem's "
dongsheng@627 6348 "maintainer is, and ask that maintainer to take their change. If the "
dongsheng@627 6349 "maintainer reviews their changes and agrees to take them, they'll pass them "
dongsheng@627 6350 "along to Linus in due course."
dongsheng@627 6351 msgstr ""
dongsheng@627 6352
dongsheng@627 6353 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6354 #: ../en/ch05-collab.xml:332
dongsheng@627 6355 msgid ""
dongsheng@627 6356 "Individual lieutenants have their own approaches to reviewing, accepting, and "
dongsheng@627 6357 "publishing changes; and for deciding when to feed them to Linus. In "
dongsheng@627 6358 "addition, there are several well known branches that people use for different "
dongsheng@627 6359 "purposes. For example, a few people maintain <quote>stable</quote> "
dongsheng@627 6360 "repositories of older versions of the kernel, to which they apply critical "
dongsheng@627 6361 "fixes as needed. Some maintainers publish multiple trees: one for "
dongsheng@627 6362 "experimental changes; one for changes that they are about to feed upstream; "
dongsheng@627 6363 "and so on. Others just publish a single tree."
dongsheng@627 6364 msgstr ""
dongsheng@627 6365
dongsheng@627 6366 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6367 #: ../en/ch05-collab.xml:343
dongsheng@627 6368 msgid ""
dongsheng@627 6369 "This model has two notable features. The first is that it's <quote>pull "
dongsheng@627 6370 "only</quote>. You have to ask, convince, or beg another developer to take a "
dongsheng@627 6371 "change from you, because there are almost no trees to which more than one "
dongsheng@627 6372 "person can push, and there's no way to push changes into a tree that someone "
dongsheng@627 6373 "else controls."
dongsheng@627 6374 msgstr ""
dongsheng@627 6375
dongsheng@627 6376 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6377 #: ../en/ch05-collab.xml:350
dongsheng@627 6378 msgid ""
dongsheng@627 6379 "The second is that it's based on reputation and acclaim. If you're an "
dongsheng@627 6380 "unknown, Linus will probably ignore changes from you without even "
dongsheng@627 6381 "responding. But a subsystem maintainer will probably review them, and will "
dongsheng@627 6382 "likely take them if they pass their criteria for suitability. The more "
dongsheng@627 6383 "<quote>good</quote> changes you contribute to a maintainer, the more likely "
dongsheng@627 6384 "they are to trust your judgment and accept your changes. If you're well-"
dongsheng@627 6385 "known and maintain a long-lived branch for something Linus hasn't yet "
dongsheng@627 6386 "accepted, people with similar interests may pull your changes regularly to "
dongsheng@627 6387 "keep up with your work."
dongsheng@627 6388 msgstr ""
dongsheng@627 6389
dongsheng@627 6390 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6391 #: ../en/ch05-collab.xml:361
dongsheng@627 6392 msgid ""
dongsheng@627 6393 "Reputation and acclaim don't necessarily cross subsystem or <quote>people</"
dongsheng@627 6394 "quote> boundaries. If you're a respected but specialised storage hacker, and "
dongsheng@627 6395 "you try to fix a networking bug, that change will receive a level of scrutiny "
dongsheng@627 6396 "from a network maintainer comparable to a change from a complete stranger."
dongsheng@627 6397 msgstr ""
dongsheng@627 6398
dongsheng@627 6399 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6400 #: ../en/ch05-collab.xml:368
dongsheng@627 6401 msgid ""
dongsheng@627 6402 "To people who come from more orderly project backgrounds, the comparatively "
dongsheng@627 6403 "chaotic Linux kernel development process often seems completely insane. It's "
dongsheng@627 6404 "subject to the whims of individuals; people make sweeping changes whenever "
dongsheng@627 6405 "they deem it appropriate; and the pace of development is astounding. And yet "
dongsheng@627 6406 "Linux is a highly successful, well-regarded piece of software."
dongsheng@627 6407 msgstr ""
dongsheng@627 6408
dongsheng@627 6409 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6410 #: ../en/ch05-collab.xml:378
dongsheng@627 6411 msgid "Pull-only versus shared-push collaboration"
dongsheng@630 6412 msgstr "只读与共享写协作"
dongsheng@627 6413
dongsheng@627 6414 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6415 #: ../en/ch05-collab.xml:380
dongsheng@627 6416 msgid ""
dongsheng@627 6417 "A perpetual source of heat in the open source community is whether a "
dongsheng@627 6418 "development model in which people only ever pull changes from others is "
dongsheng@627 6419 "<quote>better than</quote> one in which multiple people can push changes to a "
dongsheng@627 6420 "shared repository."
dongsheng@627 6421 msgstr ""
dongsheng@627 6422
dongsheng@627 6423 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6424 #: ../en/ch05-collab.xml:386
dongsheng@627 6425 msgid ""
dongsheng@627 6426 "Typically, the backers of the shared-push model use tools that actively "
dongsheng@627 6427 "enforce this approach. If you're using a centralised revision control tool "
dongsheng@627 6428 "such as Subversion, there's no way to make a choice over which model you'll "
dongsheng@627 6429 "use: the tool gives you shared-push, and if you want to do anything else, "
dongsheng@627 6430 "you'll have to roll your own approach on top (such as applying a patch by "
dongsheng@627 6431 "hand)."
dongsheng@627 6432 msgstr ""
dongsheng@627 6433
dongsheng@627 6434 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6435 #: ../en/ch05-collab.xml:394
dongsheng@627 6436 msgid ""
dongsheng@627 6437 "A good distributed revision control tool, such as Mercurial, will support "
dongsheng@627 6438 "both models. You and your collaborators can then structure how you work "
dongsheng@627 6439 "together based on your own needs and preferences, not on what contortions "
dongsheng@627 6440 "your tools force you into."
dongsheng@627 6441 msgstr ""
dongsheng@627 6442
dongsheng@627 6443 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6444 #: ../en/ch05-collab.xml:402
dongsheng@627 6445 msgid "Where collaboration meets branch management"
dongsheng@630 6446 msgstr "协作与分支管理"
dongsheng@627 6447
dongsheng@627 6448 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6449 #: ../en/ch05-collab.xml:404
dongsheng@627 6450 msgid ""
dongsheng@627 6451 "Once you and your team set up some shared repositories and start propagating "
dongsheng@627 6452 "changes back and forth between local and shared repos, you begin to face a "
dongsheng@627 6453 "related, but slightly different challenge: that of managing the multiple "
dongsheng@627 6454 "directions in which your team may be moving at once. Even though this "
dongsheng@627 6455 "subject is intimately related to how your team collaborates, it's dense "
songdongsheng@658 6456 "enough to merit treatment of its own, in <xref linkend=\"chap:branch\"/>."
dongsheng@627 6457 msgstr ""
dongsheng@627 6458
dongsheng@627 6459 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 6460 #: ../en/ch05-collab.xml:416
dongsheng@627 6461 msgid "The technical side of sharing"
dongsheng@630 6462 msgstr "共享的技术因素"
dongsheng@627 6463
dongsheng@627 6464 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6465 #: ../en/ch05-collab.xml:418
dongsheng@627 6466 msgid ""
dongsheng@627 6467 "The remainder of this chapter is devoted to the question of serving data to "
dongsheng@627 6468 "your collaborators."
dongsheng@627 6469 msgstr ""
dongsheng@627 6470
dongsheng@627 6471 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 6472 #: ../en/ch05-collab.xml:423
dongsheng@627 6473 msgid "Informal sharing with <command role=\"hg-cmd\">hg serve</command>"
dongsheng@630 6474 msgstr "使用 <command role=\"hg-cmd\">hg serve</command> 进行非正式共享"
dongsheng@627 6475
dongsheng@627 6476 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6477 #: ../en/ch05-collab.xml:426
dongsheng@627 6478 msgid ""
dongsheng@627 6479 "Mercurial's <command role=\"hg-cmd\">hg serve</command> command is "
dongsheng@627 6480 "wonderfully suited to small, tight-knit, and fast-paced group environments. "
dongsheng@627 6481 "It also provides a great way to get a feel for using Mercurial commands over "
dongsheng@627 6482 "a network."
dongsheng@627 6483 msgstr ""
dongsheng@627 6484
dongsheng@627 6485 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6486 #: ../en/ch05-collab.xml:431
dongsheng@627 6487 msgid ""
dongsheng@627 6488 "Run <command role=\"hg-cmd\">hg serve</command> inside a repository, and in "
dongsheng@627 6489 "under a second it will bring up a specialised HTTP server; this will accept "
dongsheng@627 6490 "connections from any client, and serve up data for that repository until you "
dongsheng@627 6491 "terminate it. Anyone who knows the URL of the server you just started, and "
dongsheng@627 6492 "can talk to your computer over the network, can then use a web browser or "
dongsheng@627 6493 "Mercurial to read data from that repository. A URL for a <command role=\"hg-"
dongsheng@627 6494 "cmd\">hg serve</command> instance running on a laptop is likely to look "
dongsheng@627 6495 "something like <literal>http://my-laptop.local:8000/</literal>."
dongsheng@627 6496 msgstr ""
dongsheng@627 6497
dongsheng@627 6498 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6499 #: ../en/ch05-collab.xml:442
dongsheng@627 6500 msgid ""
dongsheng@627 6501 "The <command role=\"hg-cmd\">hg serve</command> command is <emphasis>not</"
dongsheng@627 6502 "emphasis> a general-purpose web server. It can do only two things:"
dongsheng@627 6503 msgstr ""
dongsheng@627 6504
dongsheng@627 6505 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 6506 #: ../en/ch05-collab.xml:446
dongsheng@627 6507 msgid ""
dongsheng@627 6508 "Allow people to browse the history of the repository it's serving, from their "
dongsheng@627 6509 "normal web browsers."
dongsheng@627 6510 msgstr ""
dongsheng@627 6511
dongsheng@627 6512 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 6513 #: ../en/ch05-collab.xml:450
dongsheng@627 6514 msgid ""
dongsheng@627 6515 "Speak Mercurial's wire protocol, so that people can <command role=\"hg-cmd"
dongsheng@627 6516 "\">hg clone</command> or <command role=\"hg-cmd\">hg pull</command> changes "
dongsheng@627 6517 "from that repository."
dongsheng@627 6518 msgstr ""
dongsheng@627 6519
dongsheng@627 6520 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6521 #: ../en/ch05-collab.xml:455
dongsheng@627 6522 msgid ""
dongsheng@627 6523 "In particular, <command role=\"hg-cmd\">hg serve</command> won't allow remote "
dongsheng@627 6524 "users to <emphasis>modify</emphasis> your repository. It's intended for read-"
dongsheng@627 6525 "only use."
dongsheng@627 6526 msgstr ""
dongsheng@627 6527
dongsheng@627 6528 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6529 #: ../en/ch05-collab.xml:459
dongsheng@627 6530 msgid ""
dongsheng@627 6531 "If you're getting started with Mercurial, there's nothing to prevent you from "
dongsheng@627 6532 "using <command role=\"hg-cmd\">hg serve</command> to serve up a repository on "
dongsheng@627 6533 "your own computer, then use commands like <command role=\"hg-cmd\">hg clone</"
dongsheng@627 6534 "command>, <command role=\"hg-cmd\">hg incoming</command>, and so on to talk "
dongsheng@627 6535 "to that server as if the repository was hosted remotely. This can help you to "
dongsheng@627 6536 "quickly get acquainted with using commands on network-hosted repositories."
dongsheng@627 6537 msgstr ""
dongsheng@627 6538
dongsheng@627 6539 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6540 #: ../en/ch05-collab.xml:469
dongsheng@627 6541 msgid "A few things to keep in mind"
dongsheng@630 6542 msgstr "要牢记的几件事"
dongsheng@627 6543
dongsheng@627 6544 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6545 #: ../en/ch05-collab.xml:471
dongsheng@627 6546 msgid ""
dongsheng@627 6547 "Because it provides unauthenticated read access to all clients, you should "
dongsheng@627 6548 "only use <command role=\"hg-cmd\">hg serve</command> in an environment where "
dongsheng@627 6549 "you either don't care, or have complete control over, who can access your "
dongsheng@627 6550 "network and pull data from your repository."
dongsheng@627 6551 msgstr ""
dongsheng@627 6552
dongsheng@627 6553 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6554 #: ../en/ch05-collab.xml:477
dongsheng@627 6555 msgid ""
dongsheng@627 6556 "The <command role=\"hg-cmd\">hg serve</command> command knows nothing about "
dongsheng@627 6557 "any firewall software you might have installed on your system or network. It "
dongsheng@627 6558 "cannot detect or control your firewall software. If other people are unable "
dongsheng@627 6559 "to talk to a running <command role=\"hg-cmd\">hg serve</command> instance, "
dongsheng@627 6560 "the second thing you should do (<emphasis>after</emphasis> you make sure that "
dongsheng@627 6561 "they're using the correct URL) is check your firewall configuration."
dongsheng@627 6562 msgstr ""
dongsheng@627 6563
dongsheng@627 6564 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6565 #: ../en/ch05-collab.xml:486
dongsheng@627 6566 msgid ""
dongsheng@627 6567 "By default, <command role=\"hg-cmd\">hg serve</command> listens for incoming "
dongsheng@627 6568 "connections on port 8000. If another process is already listening on the "
dongsheng@627 6569 "port you want to use, you can specify a different port to listen on using the "
dongsheng@627 6570 "<option role=\"hg-opt-serve\">-p</option> option."
dongsheng@627 6571 msgstr ""
dongsheng@627 6572
dongsheng@627 6573 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6574 #: ../en/ch05-collab.xml:492
dongsheng@627 6575 msgid ""
dongsheng@627 6576 "Normally, when <command role=\"hg-cmd\">hg serve</command> starts, it prints "
dongsheng@627 6577 "no output, which can be a bit unnerving. If you'd like to confirm that it is "
dongsheng@627 6578 "indeed running correctly, and find out what URL you should send to your "
dongsheng@627 6579 "collaborators, start it with the <option role=\"hg-opt-global\">-v</option> "
dongsheng@627 6580 "option."
dongsheng@627 6581 msgstr ""
dongsheng@627 6582
dongsheng@627 6583 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 6584 #: ../en/ch05-collab.xml:502
dongsheng@627 6585 msgid "Using the Secure Shell (ssh) protocol"
dongsheng@630 6586 msgstr "使用 ssh 协议"
dongsheng@627 6587
dongsheng@627 6588 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6589 #: ../en/ch05-collab.xml:504
dongsheng@627 6590 msgid ""
dongsheng@627 6591 "You can pull and push changes securely over a network connection using the "
dongsheng@627 6592 "Secure Shell (<literal>ssh</literal>) protocol. To use this successfully, "
dongsheng@627 6593 "you may have to do a little bit of configuration on the client or server "
dongsheng@627 6594 "sides."
dongsheng@627 6595 msgstr ""
dongsheng@627 6596
dongsheng@627 6597 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6598 #: ../en/ch05-collab.xml:509
dongsheng@627 6599 msgid ""
dongsheng@627 6600 "If you're not familiar with ssh, it's a network protocol that lets you "
dongsheng@627 6601 "securely communicate with another computer. To use it with Mercurial, you'll "
dongsheng@627 6602 "be setting up one or more user accounts on a server so that remote users can "
dongsheng@627 6603 "log in and execute commands."
dongsheng@627 6604 msgstr ""
dongsheng@627 6605
dongsheng@627 6606 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 6607 #: ../en/ch05-collab.xml:515
dongsheng@627 6608 msgid ""
dongsheng@627 6609 "(If you <emphasis>are</emphasis> familiar with ssh, you'll probably find some "
dongsheng@627 6610 "of the material that follows to be elementary in nature.)"
dongsheng@627 6611 msgstr ""
dongsheng@627 6612
dongsheng@627 6613 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6614 #: ../en/ch05-collab.xml:520
dongsheng@627 6615 msgid "How to read and write ssh URLs"
dongsheng@630 6616 msgstr "如何读写 ssh 路径"
dongsheng@627 6617
dongsheng@627 6618 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6619 #: ../en/ch05-collab.xml:522
songdongsheng@658 6620 msgid "An ssh URL tends to look like this:"
songdongsheng@658 6621 msgstr ""
songdongsheng@658 6622
songdongsheng@658 6623 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@650 6624 #: ../en/ch05-collab.xml:525
songdongsheng@658 6625 msgid ""
songdongsheng@658 6626 "The <quote><literal>ssh://</literal></quote> part tells Mercurial to use the "
songdongsheng@658 6627 "ssh protocol."
dongsheng@627 6628 msgstr ""
dongsheng@627 6629
dongsheng@627 6630 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
dongsheng@650 6631 #: ../en/ch05-collab.xml:528
dongsheng@627 6632 msgid ""
dongsheng@627 6633 "The <quote><literal>bos@</literal></quote> component indicates what username "
dongsheng@627 6634 "to log into the server as. You can leave this out if the remote username is "
dongsheng@627 6635 "the same as your local username."
dongsheng@627 6636 msgstr ""
dongsheng@627 6637
dongsheng@627 6638 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 6639 #: ../en/ch05-collab.xml:533
dongsheng@627 6640 msgid ""
dongsheng@627 6641 "The <quote><literal>hg.serpentine.com</literal></quote> gives the hostname of "
dongsheng@627 6642 "the server to log into."
dongsheng@627 6643 msgstr ""
dongsheng@627 6644
dongsheng@627 6645 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 6646 #: ../en/ch05-collab.xml:537
dongsheng@627 6647 msgid ""
dongsheng@627 6648 "The <quote>:22</quote> identifies the port number to connect to the server "
dongsheng@650 6649 "on. The default port is 22, so you only need to specify a colon and port "
dongsheng@650 6650 "number if you're <emphasis>not</emphasis> using port 22."
dongsheng@627 6651 msgstr ""
dongsheng@627 6652
dongsheng@627 6653 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 6654 #: ../en/ch05-collab.xml:542
dongsheng@627 6655 msgid ""
dongsheng@627 6656 "The remainder of the URL is the local path to the repository on the server."
dongsheng@627 6657 msgstr ""
dongsheng@627 6658
dongsheng@627 6659 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6660 #: ../en/ch05-collab.xml:546
dongsheng@627 6661 msgid ""
dongsheng@627 6662 "There's plenty of scope for confusion with the path component of ssh URLs, as "
dongsheng@627 6663 "there is no standard way for tools to interpret it. Some programs behave "
dongsheng@627 6664 "differently than others when dealing with these paths. This isn't an ideal "
dongsheng@627 6665 "situation, but it's unlikely to change. Please read the following paragraphs "
dongsheng@627 6666 "carefully."
dongsheng@627 6667 msgstr ""
dongsheng@627 6668
dongsheng@627 6669 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6670 #: ../en/ch05-collab.xml:553
dongsheng@627 6671 msgid ""
dongsheng@627 6672 "Mercurial treats the path to a repository on the server as relative to the "
dongsheng@627 6673 "remote user's home directory. For example, if user <literal>foo</literal> on "
dongsheng@627 6674 "the server has a home directory of <filename class=\"directory\">/home/foo</"
dongsheng@627 6675 "filename>, then an ssh URL that contains a path component of <filename class="
dongsheng@627 6676 "\"directory\">bar</filename> <emphasis>really</emphasis> refers to the "
dongsheng@627 6677 "directory <filename class=\"directory\">/home/foo/bar</filename>."
dongsheng@627 6678 msgstr ""
dongsheng@627 6679
dongsheng@627 6680 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6681 #: ../en/ch05-collab.xml:562
dongsheng@627 6682 msgid ""
dongsheng@627 6683 "If you want to specify a path relative to another user's home directory, you "
dongsheng@627 6684 "can use a path that starts with a tilde character followed by the user's name "
dongsheng@627 6685 "(let's call them <literal>otheruser</literal>), like this."
dongsheng@627 6686 msgstr ""
dongsheng@627 6687
dongsheng@627 6688 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6689 #: ../en/ch05-collab.xml:568
dongsheng@627 6690 msgid ""
dongsheng@627 6691 "And if you really want to specify an <emphasis>absolute</emphasis> path on "
dongsheng@627 6692 "the server, begin the path component with two slashes, as in this example."
dongsheng@627 6693 msgstr ""
dongsheng@627 6694
dongsheng@627 6695 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6696 #: ../en/ch05-collab.xml:575
dongsheng@627 6697 msgid "Finding an ssh client for your system"
dongsheng@630 6698 msgstr "为你的系统寻找 ssh 客户端"
dongsheng@627 6699
dongsheng@627 6700 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6701 #: ../en/ch05-collab.xml:577
dongsheng@627 6702 msgid ""
dongsheng@627 6703 "Almost every Unix-like system comes with OpenSSH preinstalled. If you're "
dongsheng@627 6704 "using such a system, run <literal>which ssh</literal> to find out if the "
dongsheng@627 6705 "<command>ssh</command> command is installed (it's usually in <filename class="
dongsheng@627 6706 "\"directory\">/usr/bin</filename>). In the unlikely event that it isn't "
dongsheng@627 6707 "present, take a look at your system documentation to figure out how to "
dongsheng@627 6708 "install it."
dongsheng@627 6709 msgstr ""
dongsheng@627 6710
dongsheng@627 6711 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6712 #: ../en/ch05-collab.xml:585
dongsheng@627 6713 msgid ""
dongsheng@627 6714 "On Windows, you'll first need to download a suitable ssh client. There are "
dongsheng@627 6715 "two alternatives."
dongsheng@627 6716 msgstr ""
dongsheng@627 6717
dongsheng@627 6718 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6719 #: ../en/ch05-collab.xml:588
dongsheng@627 6720 msgid ""
dongsheng@627 6721 "Simon Tatham's excellent PuTTY package <citation>web:putty</citation> "
dongsheng@627 6722 "provides a complete suite of ssh client commands."
dongsheng@627 6723 msgstr ""
dongsheng@627 6724
dongsheng@627 6725 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6726 #: ../en/ch05-collab.xml:592
songdongsheng@658 6727 msgid ""
songdongsheng@658 6728 "If you have a high tolerance for pain, you can use the Cygwin port of OpenSSH."
songdongsheng@658 6729 msgstr ""
songdongsheng@658 6730
songdongsheng@658 6731 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6732 #: ../en/ch05-collab.xml:595
dongsheng@627 6733 msgid ""
dongsheng@650 6734 "In either case, you'll need to edit your <filename role=\"special\">hg.ini</"
dongsheng@650 6735 "filename> file to tell Mercurial where to find the actual client command. "
dongsheng@650 6736 "For example, if you're using PuTTY, you'll need to use the <command>plink</"
dongsheng@650 6737 "command> command as a command-line ssh client."
dongsheng@627 6738 msgstr ""
dongsheng@627 6739
dongsheng@627 6740 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 6741 #: ../en/ch05-collab.xml:605
dongsheng@627 6742 msgid ""
dongsheng@627 6743 "The path to <command>plink</command> shouldn't contain any whitespace "
dongsheng@627 6744 "characters, or Mercurial may not be able to run it correctly (so putting it "
dongsheng@650 6745 "in <filename class=\"directory\">C:\\Program Files</filename> is probably not "
dongsheng@650 6746 "a good idea)."
dongsheng@650 6747 msgstr ""
dongsheng@650 6748
dongsheng@650 6749 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6750 #: ../en/ch05-collab.xml:614
dongsheng@627 6751 msgid "Generating a key pair"
dongsheng@630 6752 msgstr "产生密钥对"
dongsheng@627 6753
dongsheng@627 6754 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6755 #: ../en/ch05-collab.xml:616
dongsheng@627 6756 msgid ""
dongsheng@627 6757 "To avoid the need to repetitively type a password every time you need to use "
dongsheng@627 6758 "your ssh client, I recommend generating a key pair. On a Unix-like system, "
dongsheng@627 6759 "the <command>ssh-keygen</command> command will do the trick. On Windows, if "
dongsheng@627 6760 "you're using PuTTY, the <command>puttygen</command> command is what you'll "
dongsheng@627 6761 "need."
dongsheng@627 6762 msgstr ""
dongsheng@627 6763
dongsheng@627 6764 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6765 #: ../en/ch05-collab.xml:624
dongsheng@627 6766 msgid ""
dongsheng@627 6767 "When you generate a key pair, it's usually <emphasis>highly</emphasis> "
dongsheng@627 6768 "advisable to protect it with a passphrase. (The only time that you might not "
dongsheng@627 6769 "want to do this is when you're using the ssh protocol for automated tasks on "
dongsheng@627 6770 "a secure network.)"
dongsheng@627 6771 msgstr ""
dongsheng@627 6772
dongsheng@627 6773 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6774 #: ../en/ch05-collab.xml:630
dongsheng@627 6775 msgid ""
dongsheng@627 6776 "Simply generating a key pair isn't enough, however. You'll need to add the "
dongsheng@627 6777 "public key to the set of authorised keys for whatever user you're logging in "
dongsheng@627 6778 "remotely as. For servers using OpenSSH (the vast majority), this will mean "
dongsheng@627 6779 "adding the public key to a list in a file called <filename role=\"special"
dongsheng@627 6780 "\">authorized_keys</filename> in their <filename role=\"special\" class="
dongsheng@627 6781 "\"directory\">.ssh</filename> directory."
dongsheng@627 6782 msgstr ""
dongsheng@627 6783
dongsheng@627 6784 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6785 #: ../en/ch05-collab.xml:639
dongsheng@627 6786 msgid ""
dongsheng@627 6787 "On a Unix-like system, your public key will have a <filename>.pub</filename> "
dongsheng@627 6788 "extension. If you're using <command>puttygen</command> on Windows, you can "
dongsheng@627 6789 "save the public key to a file of your choosing, or paste it from the window "
dongsheng@627 6790 "it's displayed in straight into the <filename role=\"special"
dongsheng@627 6791 "\">authorized_keys</filename> file."
dongsheng@627 6792 msgstr ""
dongsheng@627 6793
dongsheng@627 6794 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6795 #: ../en/ch05-collab.xml:648
dongsheng@627 6796 msgid "Using an authentication agent"
dongsheng@630 6797 msgstr "使用认证代理"
dongsheng@627 6798
dongsheng@627 6799 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6800 #: ../en/ch05-collab.xml:650
dongsheng@627 6801 msgid ""
dongsheng@627 6802 "An authentication agent is a daemon that stores passphrases in memory (so it "
dongsheng@627 6803 "will forget passphrases if you log out and log back in again). An ssh client "
dongsheng@627 6804 "will notice if it's running, and query it for a passphrase. If there's no "
dongsheng@627 6805 "authentication agent running, or the agent doesn't store the necessary "
dongsheng@627 6806 "passphrase, you'll have to type your passphrase every time Mercurial tries to "
dongsheng@627 6807 "communicate with a server on your behalf (e.g. whenever you pull or push "
dongsheng@627 6808 "changes)."
dongsheng@627 6809 msgstr ""
dongsheng@627 6810
dongsheng@627 6811 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6812 #: ../en/ch05-collab.xml:659
dongsheng@627 6813 msgid ""
dongsheng@627 6814 "The downside of storing passphrases in an agent is that it's possible for a "
dongsheng@627 6815 "well-prepared attacker to recover the plain text of your passphrases, in some "
dongsheng@627 6816 "cases even if your system has been power-cycled. You should make your own "
dongsheng@627 6817 "judgment as to whether this is an acceptable risk. It certainly saves a lot "
dongsheng@627 6818 "of repeated typing."
dongsheng@627 6819 msgstr ""
dongsheng@627 6820
dongsheng@627 6821 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6822 #: ../en/ch05-collab.xml:666
dongsheng@627 6823 msgid ""
dongsheng@627 6824 "On Unix-like systems, the agent is called <command>ssh-agent</command>, and "
dongsheng@627 6825 "it's often run automatically for you when you log in. You'll need to use the "
dongsheng@627 6826 "<command>ssh-add</command> command to add passphrases to the agent's store. "
dongsheng@627 6827 "On Windows, if you're using PuTTY, the <command>pageant</command> command "
dongsheng@627 6828 "acts as the agent. It adds an icon to your system tray that will let you "
dongsheng@627 6829 "manage stored passphrases."
dongsheng@627 6830 msgstr ""
dongsheng@627 6831
dongsheng@627 6832 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 6833 #: ../en/ch05-collab.xml:677
dongsheng@627 6834 msgid "Configuring the server side properly"
dongsheng@630 6835 msgstr "正确配置服务器端"
dongsheng@627 6836
dongsheng@627 6837 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6838 #: ../en/ch05-collab.xml:679
dongsheng@627 6839 msgid ""
dongsheng@627 6840 "Because ssh can be fiddly to set up if you're new to it, there's a variety of "
dongsheng@627 6841 "things that can go wrong. Add Mercurial on top, and there's plenty more "
dongsheng@627 6842 "scope for head-scratching. Most of these potential problems occur on the "
dongsheng@627 6843 "server side, not the client side. The good news is that once you've gotten a "
dongsheng@627 6844 "configuration working, it will usually continue to work indefinitely."
dongsheng@627 6845 msgstr ""
dongsheng@627 6846
dongsheng@627 6847 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6848 #: ../en/ch05-collab.xml:687
dongsheng@627 6849 msgid ""
dongsheng@627 6850 "Before you try using Mercurial to talk to an ssh server, it's best to make "
dongsheng@627 6851 "sure that you can use the normal <command>ssh</command> or <command>putty</"
dongsheng@627 6852 "command> command to talk to the server first. If you run into problems with "
dongsheng@627 6853 "using these commands directly, Mercurial surely won't work. Worse, it will "
dongsheng@627 6854 "obscure the underlying problem. Any time you want to debug ssh-related "
dongsheng@627 6855 "Mercurial problems, you should drop back to making sure that plain ssh client "
dongsheng@627 6856 "commands work first, <emphasis>before</emphasis> you worry about whether "
dongsheng@627 6857 "there's a problem with Mercurial."
dongsheng@627 6858 msgstr ""
dongsheng@627 6859
dongsheng@627 6860 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6861 #: ../en/ch05-collab.xml:698
dongsheng@627 6862 msgid ""
dongsheng@627 6863 "The first thing to be sure of on the server side is that you can actually log "
dongsheng@627 6864 "in from another machine at all. If you can't use <command>ssh</command> or "
dongsheng@627 6865 "<command>putty</command> to log in, the error message you get may give you a "
dongsheng@627 6866 "few hints as to what's wrong. The most common problems are as follows."
dongsheng@627 6867 msgstr ""
dongsheng@627 6868
dongsheng@627 6869 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6870 #: ../en/ch05-collab.xml:705
dongsheng@627 6871 msgid ""
dongsheng@627 6872 "If you get a <quote>connection refused</quote> error, either there isn't an "
dongsheng@627 6873 "SSH daemon running on the server at all, or it's inaccessible due to firewall "
dongsheng@627 6874 "configuration."
dongsheng@627 6875 msgstr ""
dongsheng@627 6876
dongsheng@627 6877 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6878 #: ../en/ch05-collab.xml:710
dongsheng@627 6879 msgid ""
dongsheng@627 6880 "If you get a <quote>no route to host</quote> error, you either have an "
dongsheng@627 6881 "incorrect address for the server or a seriously locked down firewall that "
dongsheng@627 6882 "won't admit its existence at all."
dongsheng@627 6883 msgstr ""
dongsheng@627 6884
dongsheng@627 6885 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6886 #: ../en/ch05-collab.xml:715
dongsheng@627 6887 msgid ""
dongsheng@627 6888 "If you get a <quote>permission denied</quote> error, you may have mistyped "
dongsheng@627 6889 "the username on the server, or you could have mistyped your key's passphrase "
dongsheng@627 6890 "or the remote user's password."
dongsheng@627 6891 msgstr ""
dongsheng@627 6892
dongsheng@627 6893 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6894 #: ../en/ch05-collab.xml:720
dongsheng@627 6895 msgid ""
dongsheng@627 6896 "In summary, if you're having trouble talking to the server's ssh daemon, "
dongsheng@627 6897 "first make sure that one is running at all. On many systems it will be "
dongsheng@627 6898 "installed, but disabled, by default. Once you're done with this step, you "
dongsheng@627 6899 "should then check that the server's firewall is configured to allow incoming "
dongsheng@627 6900 "connections on the port the ssh daemon is listening on (usually 22). Don't "
dongsheng@627 6901 "worry about more exotic possibilities for misconfiguration until you've "
dongsheng@627 6902 "checked these two first."
dongsheng@627 6903 msgstr ""
dongsheng@627 6904
dongsheng@627 6905 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6906 #: ../en/ch05-collab.xml:730
dongsheng@627 6907 msgid ""
dongsheng@627 6908 "If you're using an authentication agent on the client side to store "
dongsheng@627 6909 "passphrases for your keys, you ought to be able to log into the server "
dongsheng@627 6910 "without being prompted for a passphrase or a password. If you're prompted "
dongsheng@627 6911 "for a passphrase, there are a few possible culprits."
dongsheng@627 6912 msgstr ""
dongsheng@627 6913
dongsheng@627 6914 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6915 #: ../en/ch05-collab.xml:736
dongsheng@627 6916 msgid ""
dongsheng@627 6917 "You might have forgotten to use <command>ssh-add</command> or "
dongsheng@627 6918 "<command>pageant</command> to store the passphrase."
dongsheng@627 6919 msgstr ""
dongsheng@627 6920
dongsheng@627 6921 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6922 #: ../en/ch05-collab.xml:740
songdongsheng@658 6923 msgid "You might have stored the passphrase for the wrong key."
songdongsheng@658 6924 msgstr ""
songdongsheng@658 6925
songdongsheng@658 6926 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 6927 #: ../en/ch05-collab.xml:743
dongsheng@627 6928 msgid ""
dongsheng@627 6929 "If you're being prompted for the remote user's password, there are another "
dongsheng@627 6930 "few possible problems to check."
dongsheng@627 6931 msgstr ""
dongsheng@627 6932
dongsheng@627 6933 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6934 #: ../en/ch05-collab.xml:746
dongsheng@627 6935 msgid ""
dongsheng@627 6936 "Either the user's home directory or their <filename role=\"special\" class="
dongsheng@627 6937 "\"directory\">.ssh</filename> directory might have excessively liberal "
dongsheng@627 6938 "permissions. As a result, the ssh daemon will not trust or read their "
dongsheng@627 6939 "<filename role=\"special\">authorized_keys</filename> file. For example, a "
dongsheng@627 6940 "group-writable home or <filename role=\"special\" class=\"directory\">.ssh</"
dongsheng@627 6941 "filename> directory will often cause this symptom."
dongsheng@627 6942 msgstr ""
dongsheng@627 6943
dongsheng@627 6944 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6945 #: ../en/ch05-collab.xml:755
dongsheng@627 6946 msgid ""
dongsheng@627 6947 "The user's <filename role=\"special\">authorized_keys</filename> file may "
dongsheng@627 6948 "have a problem. If anyone other than the user owns or can write to that file, "
dongsheng@627 6949 "the ssh daemon will not trust or read it."
dongsheng@627 6950 msgstr ""
dongsheng@627 6951
dongsheng@627 6952 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6953 #: ../en/ch05-collab.xml:762
dongsheng@627 6954 msgid ""
dongsheng@627 6955 "In the ideal world, you should be able to run the following command "
dongsheng@627 6956 "successfully, and it should print exactly one line of output, the current "
dongsheng@627 6957 "date and time."
dongsheng@627 6958 msgstr ""
dongsheng@627 6959
dongsheng@627 6960 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6961 #: ../en/ch05-collab.xml:767
dongsheng@627 6962 msgid ""
dongsheng@627 6963 "If, on your server, you have login scripts that print banners or other junk "
dongsheng@627 6964 "even when running non-interactive commands like this, you should fix them "
dongsheng@627 6965 "before you continue, so that they only print output if they're run "
dongsheng@627 6966 "interactively. Otherwise these banners will at least clutter up Mercurial's "
dongsheng@627 6967 "output. Worse, they could potentially cause problems with running Mercurial "
dongsheng@627 6968 "commands remotely. Mercurial makes tries to detect and ignore banners in non-"
dongsheng@627 6969 "interactive <command>ssh</command> sessions, but it is not foolproof. (If "
dongsheng@627 6970 "you're editing your login scripts on your server, the usual way to see if a "
dongsheng@627 6971 "login script is running in an interactive shell is to check the return code "
dongsheng@627 6972 "from the command <literal>tty -s</literal>.)"
dongsheng@627 6973 msgstr ""
dongsheng@627 6974
dongsheng@627 6975 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6976 #: ../en/ch05-collab.xml:781
dongsheng@627 6977 msgid ""
dongsheng@627 6978 "Once you've verified that plain old ssh is working with your server, the next "
dongsheng@627 6979 "step is to ensure that Mercurial runs on the server. The following command "
dongsheng@627 6980 "should run successfully:"
dongsheng@627 6981 msgstr ""
dongsheng@627 6982
dongsheng@627 6983 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 6984 #: ../en/ch05-collab.xml:788
dongsheng@627 6985 msgid ""
dongsheng@627 6986 "If you see an error message instead of normal <command role=\"hg-cmd\">hg "
dongsheng@627 6987 "version</command> output, this is usually because you haven't installed "
dongsheng@627 6988 "Mercurial to <filename class=\"directory\">/usr/bin</filename>. Don't worry "
dongsheng@627 6989 "if this is the case; you don't need to do that. But you should check for a "
dongsheng@627 6990 "few possible problems."
dongsheng@627 6991 msgstr ""
dongsheng@627 6992
dongsheng@627 6993 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 6994 #: ../en/ch05-collab.xml:795
dongsheng@627 6995 msgid ""
dongsheng@627 6996 "Is Mercurial really installed on the server at all? I know this sounds "
dongsheng@627 6997 "trivial, but it's worth checking!"
dongsheng@627 6998 msgstr ""
dongsheng@627 6999
dongsheng@627 7000 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7001 #: ../en/ch05-collab.xml:799
dongsheng@627 7002 msgid ""
dongsheng@627 7003 "Maybe your shell's search path (usually set via the <envar>PATH</envar> "
dongsheng@627 7004 "environment variable) is simply misconfigured."
dongsheng@627 7005 msgstr ""
dongsheng@627 7006
dongsheng@627 7007 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7008 #: ../en/ch05-collab.xml:803
dongsheng@627 7009 msgid ""
dongsheng@627 7010 "Perhaps your <envar>PATH</envar> environment variable is only being set to "
dongsheng@627 7011 "point to the location of the <command>hg</command> executable if the login "
dongsheng@627 7012 "session is interactive. This can happen if you're setting the path in the "
dongsheng@627 7013 "wrong shell login script. See your shell's documentation for details."
dongsheng@627 7014 msgstr ""
dongsheng@627 7015
dongsheng@627 7016 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7017 #: ../en/ch05-collab.xml:810
dongsheng@627 7018 msgid ""
dongsheng@627 7019 "The <envar>PYTHONPATH</envar> environment variable may need to contain the "
dongsheng@627 7020 "path to the Mercurial Python modules. It might not be set at all; it could "
dongsheng@627 7021 "be incorrect; or it may be set only if the login is interactive."
dongsheng@627 7022 msgstr ""
dongsheng@627 7023
dongsheng@627 7024 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7025 #: ../en/ch05-collab.xml:817
dongsheng@627 7026 msgid ""
dongsheng@627 7027 "If you can run <command role=\"hg-cmd\">hg version</command> over an ssh "
dongsheng@627 7028 "connection, well done! You've got the server and client sorted out. You "
dongsheng@627 7029 "should now be able to use Mercurial to access repositories hosted by that "
dongsheng@627 7030 "username on that server. If you run into problems with Mercurial and ssh at "
dongsheng@627 7031 "this point, try using the <option role=\"hg-opt-global\">--debug</option> "
dongsheng@627 7032 "option to get a clearer picture of what's going on."
dongsheng@627 7033 msgstr ""
dongsheng@627 7034
dongsheng@627 7035 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 7036 #: ../en/ch05-collab.xml:827
dongsheng@627 7037 msgid "Using compression with ssh"
dongsheng@630 7038 msgstr "通过 ssh 使用压缩"
dongsheng@627 7039
dongsheng@627 7040 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7041 #: ../en/ch05-collab.xml:829
dongsheng@627 7042 msgid ""
dongsheng@627 7043 "Mercurial does not compress data when it uses the ssh protocol, because the "
dongsheng@627 7044 "ssh protocol can transparently compress data. However, the default behaviour "
dongsheng@627 7045 "of ssh clients is <emphasis>not</emphasis> to request compression."
dongsheng@627 7046 msgstr ""
dongsheng@627 7047
dongsheng@627 7048 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7049 #: ../en/ch05-collab.xml:834
dongsheng@627 7050 msgid ""
dongsheng@627 7051 "Over any network other than a fast LAN (even a wireless network), using "
dongsheng@627 7052 "compression is likely to significantly speed up Mercurial's network "
dongsheng@627 7053 "operations. For example, over a WAN, someone measured compression as "
dongsheng@627 7054 "reducing the amount of time required to clone a particularly large repository "
dongsheng@627 7055 "from 51 minutes to 17 minutes."
dongsheng@627 7056 msgstr ""
dongsheng@627 7057
dongsheng@627 7058 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7059 #: ../en/ch05-collab.xml:841
dongsheng@627 7060 msgid ""
dongsheng@627 7061 "Both <command>ssh</command> and <command>plink</command> accept a <option "
dongsheng@627 7062 "role=\"cmd-opt-ssh\">-C</option> option which turns on compression. You can "
dongsheng@650 7063 "easily edit your <filename role=\"special\">~/.hgrc</filename> to enable "
dongsheng@627 7064 "compression for all of Mercurial's uses of the ssh protocol."
dongsheng@627 7065 msgstr ""
dongsheng@627 7066
dongsheng@627 7067 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7068 #: ../en/ch05-collab.xml:849
dongsheng@627 7069 msgid ""
dongsheng@627 7070 "If you use <command>ssh</command>, you can configure it to always use "
dongsheng@627 7071 "compression when talking to your server. To do this, edit your <filename "
dongsheng@627 7072 "role=\"special\">.ssh/config</filename> file (which may not yet exist), as "
dongsheng@627 7073 "follows."
dongsheng@627 7074 msgstr ""
dongsheng@627 7075
dongsheng@627 7076 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7077 #: ../en/ch05-collab.xml:857
dongsheng@627 7078 msgid ""
dongsheng@627 7079 "This defines an alias, <literal>hg</literal>. When you use it on the "
dongsheng@627 7080 "<command>ssh</command> command line or in a Mercurial <literal>ssh</literal>-"
dongsheng@627 7081 "protocol URL, it will cause <command>ssh</command> to connect to <literal>hg."
dongsheng@627 7082 "example.com</literal> and use compression. This gives you both a shorter "
dongsheng@627 7083 "name to type and compression, each of which is a good thing in its own right."
dongsheng@627 7084 msgstr ""
dongsheng@627 7085
dongsheng@627 7086 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 7087 #: ../en/ch05-collab.xml:868
dongsheng@627 7088 msgid "Serving over HTTP using CGI"
dongsheng@630 7089 msgstr "使用 CGI 通过 HTTP 提供服务"
dongsheng@627 7090
dongsheng@627 7091 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 7092 #: ../en/ch05-collab.xml:870
dongsheng@627 7093 msgid ""
dongsheng@627 7094 "Depending on how ambitious you are, configuring Mercurial's CGI interface can "
dongsheng@627 7095 "take anything from a few moments to several hours."
dongsheng@627 7096 msgstr ""
dongsheng@627 7097
dongsheng@627 7098 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 7099 #: ../en/ch05-collab.xml:874
dongsheng@627 7100 msgid ""
dongsheng@627 7101 "We'll begin with the simplest of examples, and work our way towards a more "
dongsheng@627 7102 "complex configuration. Even for the most basic case, you're almost certainly "
dongsheng@627 7103 "going to need to read and modify your web server's configuration."
dongsheng@627 7104 msgstr ""
dongsheng@627 7105
dongsheng@627 7106 #. type: Content of: <book><chapter><sect1><note><para>
songdongsheng@658 7107 #: ../en/ch05-collab.xml:880
dongsheng@627 7108 msgid ""
dongsheng@627 7109 "Configuring a web server is a complex, fiddly, and highly system-dependent "
dongsheng@627 7110 "activity. I can't possibly give you instructions that will cover anything "
dongsheng@627 7111 "like all of the cases you will encounter. Please use your discretion and "
dongsheng@627 7112 "judgment in following the sections below. Be prepared to make plenty of "
dongsheng@627 7113 "mistakes, and to spend a lot of time reading your server's error logs."
dongsheng@627 7114 msgstr ""
dongsheng@627 7115
dongsheng@627 7116 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 7117 #: ../en/ch05-collab.xml:890
dongsheng@627 7118 msgid "Web server configuration checklist"
dongsheng@630 7119 msgstr "Web 服务器配置检查表"
dongsheng@627 7120
dongsheng@627 7121 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7122 #: ../en/ch05-collab.xml:892
dongsheng@627 7123 msgid ""
dongsheng@627 7124 "Before you continue, do take a few moments to check a few aspects of your "
dongsheng@627 7125 "system's setup."
dongsheng@627 7126 msgstr ""
dongsheng@627 7127
dongsheng@627 7128 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 7129 #: ../en/ch05-collab.xml:896
dongsheng@627 7130 msgid ""
dongsheng@627 7131 "Do you have a web server installed at all? Mac OS X ships with Apache, but "
dongsheng@627 7132 "many other systems may not have a web server installed."
dongsheng@627 7133 msgstr ""
dongsheng@627 7134
dongsheng@627 7135 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 7136 #: ../en/ch05-collab.xml:900
dongsheng@627 7137 msgid ""
dongsheng@627 7138 "If you have a web server installed, is it actually running? On most systems, "
dongsheng@627 7139 "even if one is present, it will be disabled by default."
dongsheng@627 7140 msgstr ""
dongsheng@627 7141
dongsheng@627 7142 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 7143 #: ../en/ch05-collab.xml:904
dongsheng@627 7144 msgid ""
dongsheng@627 7145 "Is your server configured to allow you to run CGI programs in the directory "
dongsheng@627 7146 "where you plan to do so? Most servers default to explicitly disabling the "
dongsheng@627 7147 "ability to run CGI programs."
dongsheng@627 7148 msgstr ""
dongsheng@627 7149
dongsheng@627 7150 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7151 #: ../en/ch05-collab.xml:910
dongsheng@627 7152 msgid ""
dongsheng@627 7153 "If you don't have a web server installed, and don't have substantial "
dongsheng@627 7154 "experience configuring Apache, you should consider using the "
dongsheng@627 7155 "<literal>lighttpd</literal> web server instead of Apache. Apache has a well-"
dongsheng@627 7156 "deserved reputation for baroque and confusing configuration. While "
dongsheng@627 7157 "<literal>lighttpd</literal> is less capable in some ways than Apache, most of "
dongsheng@627 7158 "these capabilities are not relevant to serving Mercurial repositories. And "
dongsheng@627 7159 "<literal>lighttpd</literal> is undeniably <emphasis>much</emphasis> easier to "
dongsheng@627 7160 "get started with than Apache."
dongsheng@627 7161 msgstr ""
dongsheng@627 7162
dongsheng@627 7163 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 7164 #: ../en/ch05-collab.xml:923
dongsheng@627 7165 msgid "Basic CGI configuration"
dongsheng@630 7166 msgstr "基本 CGI 配置"
dongsheng@627 7167
dongsheng@627 7168 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7169 #: ../en/ch05-collab.xml:925
dongsheng@627 7170 msgid ""
dongsheng@627 7171 "On Unix-like systems, it's common for users to have a subdirectory named "
dongsheng@627 7172 "something like <filename class=\"directory\">public_html</filename> in their "
dongsheng@627 7173 "home directory, from which they can serve up web pages. A file named "
dongsheng@627 7174 "<filename>foo</filename> in this directory will be accessible at a URL of the "
dongsheng@650 7175 "form <literal>http://www.example.com/username/foo</literal>."
dongsheng@650 7176 msgstr ""
dongsheng@650 7177
dongsheng@650 7178 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7179 #: ../en/ch05-collab.xml:933
dongsheng@627 7180 msgid ""
dongsheng@627 7181 "To get started, find the <filename role=\"special\">hgweb.cgi</filename> "
dongsheng@627 7182 "script that should be present in your Mercurial installation. If you can't "
dongsheng@627 7183 "quickly find a local copy on your system, simply download one from the master "
dongsheng@627 7184 "Mercurial repository at <ulink url=\"http://www.selenic.com/repo/hg/raw-file/"
dongsheng@627 7185 "tip/hgweb.cgi\">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>."
dongsheng@627 7186 msgstr ""
dongsheng@627 7187
dongsheng@627 7188 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7189 #: ../en/ch05-collab.xml:940 ../en/ch05-collab.xml:1109
dongsheng@627 7190 msgid ""
dongsheng@627 7191 "You'll need to copy this script into your <filename class=\"directory"
dongsheng@627 7192 "\">public_html</filename> directory, and ensure that it's executable."
dongsheng@627 7193 msgstr ""
dongsheng@627 7194
dongsheng@627 7195 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7196 #: ../en/ch05-collab.xml:945
dongsheng@627 7197 msgid ""
dongsheng@627 7198 "The <literal>755</literal> argument to <command>chmod</command> is a little "
dongsheng@627 7199 "more general than just making the script executable: it ensures that the "
dongsheng@627 7200 "script is executable by anyone, and that <quote>group</quote> and "
dongsheng@627 7201 "<quote>other</quote> write permissions are <emphasis>not</emphasis> set. If "
dongsheng@627 7202 "you were to leave those write permissions enabled, Apache's <literal>suexec</"
dongsheng@627 7203 "literal> subsystem would likely refuse to execute the script. In fact, "
dongsheng@627 7204 "<literal>suexec</literal> also insists that the <emphasis>directory</"
dongsheng@627 7205 "emphasis> in which the script resides must not be writable by others."
dongsheng@627 7206 msgstr ""
dongsheng@627 7207
dongsheng@627 7208 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 7209 #: ../en/ch05-collab.xml:959
dongsheng@627 7210 msgid "What could <emphasis>possibly</emphasis> go wrong?"
dongsheng@630 7211 msgstr "什么<emphasis>可能</emphasis>会出错?"
dongsheng@627 7212
dongsheng@627 7213 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7214 #: ../en/ch05-collab.xml:962
dongsheng@627 7215 msgid ""
dongsheng@627 7216 "Once you've copied the CGI script into place, go into a web browser, and try "
dongsheng@627 7217 "to open the URL <ulink url=\"http://myhostname/ myuser/hgweb.cgi\">http://"
dongsheng@627 7218 "myhostname/ myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace yourself "
dongsheng@627 7219 "for instant failure. There's a high probability that trying to visit this "
dongsheng@627 7220 "URL will fail, and there are many possible reasons for this. In fact, you're "
dongsheng@627 7221 "likely to stumble over almost every one of the possible errors below, so "
dongsheng@627 7222 "please read carefully. The following are all of the problems I ran into on a "
dongsheng@627 7223 "system running Fedora 7, with a fresh installation of Apache, and a user "
dongsheng@627 7224 "account that I created specially to perform this exercise."
dongsheng@627 7225 msgstr ""
dongsheng@627 7226
dongsheng@627 7227 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7228 #: ../en/ch05-collab.xml:976
dongsheng@627 7229 msgid ""
dongsheng@627 7230 "Your web server may have per-user directories disabled. If you're using "
dongsheng@627 7231 "Apache, search your config file for a <literal>UserDir</literal> directive. "
dongsheng@627 7232 "If there's none present, per-user directories will be disabled. If one "
dongsheng@627 7233 "exists, but its value is <literal>disabled</literal>, then per-user "
dongsheng@627 7234 "directories will be disabled. Otherwise, the string after <literal>UserDir</"
dongsheng@627 7235 "literal> gives the name of the subdirectory that Apache will look in under "
dongsheng@627 7236 "your home directory, for example <filename class=\"directory\">public_html</"
dongsheng@627 7237 "filename>."
dongsheng@627 7238 msgstr ""
dongsheng@627 7239
dongsheng@627 7240 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7241 #: ../en/ch05-collab.xml:987
dongsheng@627 7242 msgid ""
dongsheng@627 7243 "Your file access permissions may be too restrictive. The web server must be "
dongsheng@627 7244 "able to traverse your home directory and directories under your <filename "
dongsheng@627 7245 "class=\"directory\">public_html</filename> directory, and read files under "
dongsheng@627 7246 "the latter too. Here's a quick recipe to help you to make your permissions "
dongsheng@627 7247 "more appropriate."
dongsheng@627 7248 msgstr ""
dongsheng@627 7249
dongsheng@627 7250 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7251 #: ../en/ch05-collab.xml:997
dongsheng@627 7252 msgid ""
dongsheng@627 7253 "The other possibility with permissions is that you might get a completely "
dongsheng@627 7254 "empty window when you try to load the script. In this case, it's likely that "
dongsheng@627 7255 "your access permissions are <emphasis>too permissive</emphasis>. Apache's "
dongsheng@627 7256 "<literal>suexec</literal> subsystem won't execute a script that's group- or "
dongsheng@627 7257 "world-writable, for example."
dongsheng@627 7258 msgstr ""
dongsheng@627 7259
dongsheng@627 7260 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7261 #: ../en/ch05-collab.xml:1004
dongsheng@627 7262 msgid ""
dongsheng@627 7263 "Your web server may be configured to disallow execution of CGI programs in "
dongsheng@627 7264 "your per-user web directory. Here's Apache's default per-user configuration "
dongsheng@627 7265 "from my Fedora system."
dongsheng@627 7266 msgstr ""
dongsheng@627 7267
dongsheng@627 7268 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7269 #: ../en/ch05-collab.xml:1011
dongsheng@627 7270 msgid ""
dongsheng@627 7271 "If you find a similar-looking <literal>Directory</literal> group in your "
dongsheng@627 7272 "Apache configuration, the directive to look at inside it is <literal>Options</"
dongsheng@627 7273 "literal>. Add <literal>ExecCGI</literal> to the end of this list if it's "
dongsheng@627 7274 "missing, and restart the web server."
dongsheng@627 7275 msgstr ""
dongsheng@627 7276
dongsheng@627 7277 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7278 #: ../en/ch05-collab.xml:1018
dongsheng@627 7279 msgid ""
dongsheng@627 7280 "If you find that Apache serves you the text of the CGI script instead of "
dongsheng@627 7281 "executing it, you may need to either uncomment (if already present) or add a "
dongsheng@627 7282 "directive like this."
dongsheng@627 7283 msgstr ""
dongsheng@627 7284
dongsheng@627 7285 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7286 #: ../en/ch05-collab.xml:1024
dongsheng@627 7287 msgid ""
dongsheng@627 7288 "The next possibility is that you might be served with a colourful Python "
dongsheng@627 7289 "backtrace claiming that it can't import a <literal>mercurial</literal>-"
dongsheng@627 7290 "related module. This is actually progress! The server is now capable of "
dongsheng@627 7291 "executing your CGI script. This error is only likely to occur if you're "
dongsheng@627 7292 "running a private installation of Mercurial, instead of a system-wide "
dongsheng@627 7293 "version. Remember that the web server runs the CGI program without any of "
dongsheng@627 7294 "the environment variables that you take for granted in an interactive "
dongsheng@627 7295 "session. If this error happens to you, edit your copy of <filename role="
dongsheng@627 7296 "\"special\">hgweb.cgi</filename> and follow the directions inside it to "
dongsheng@627 7297 "correctly set your <envar>PYTHONPATH</envar> environment variable."
dongsheng@627 7298 msgstr ""
dongsheng@627 7299
dongsheng@627 7300 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7301 #: ../en/ch05-collab.xml:1038
dongsheng@627 7302 msgid ""
dongsheng@627 7303 "Finally, you are <emphasis>certain</emphasis> to by served with another "
dongsheng@627 7304 "colourful Python backtrace: this one will complain that it can't find "
dongsheng@627 7305 "<filename class=\"directory\">/path/to/repository</filename>. Edit your "
dongsheng@627 7306 "<filename role=\"special\">hgweb.cgi</filename> script and replace the "
dongsheng@627 7307 "<filename class=\"directory\">/path/to/repository</filename> string with the "
dongsheng@627 7308 "complete path to the repository you want to serve up."
dongsheng@627 7309 msgstr ""
dongsheng@627 7310
dongsheng@627 7311 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7312 #: ../en/ch05-collab.xml:1048
dongsheng@627 7313 msgid ""
dongsheng@627 7314 "At this point, when you try to reload the page, you should be presented with "
dongsheng@627 7315 "a nice HTML view of your repository's history. Whew!"
dongsheng@627 7316 msgstr ""
dongsheng@627 7317
dongsheng@627 7318 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 7319 #: ../en/ch05-collab.xml:1054
dongsheng@627 7320 msgid "Configuring lighttpd"
dongsheng@630 7321 msgstr "配置 lighttpd"
dongsheng@627 7322
dongsheng@627 7323 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7324 #: ../en/ch05-collab.xml:1056
dongsheng@627 7325 msgid ""
dongsheng@627 7326 "To be exhaustive in my experiments, I tried configuring the increasingly "
dongsheng@627 7327 "popular <literal>lighttpd</literal> web server to serve the same repository "
dongsheng@627 7328 "as I described with Apache above. I had already overcome all of the problems "
dongsheng@627 7329 "I outlined with Apache, many of which are not server-specific. As a result, "
dongsheng@627 7330 "I was fairly sure that my file and directory permissions were good, and that "
dongsheng@627 7331 "my <filename role=\"special\">hgweb.cgi</filename> script was properly edited."
dongsheng@627 7332 msgstr ""
dongsheng@627 7333
dongsheng@627 7334 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7335 #: ../en/ch05-collab.xml:1066
dongsheng@627 7336 msgid ""
dongsheng@627 7337 "Once I had Apache running, getting <literal>lighttpd</literal> to serve the "
dongsheng@627 7338 "repository was a snap (in other words, even if you're trying to use "
dongsheng@627 7339 "<literal>lighttpd</literal>, you should read the Apache section). I first "
dongsheng@627 7340 "had to edit the <literal>mod_access</literal> section of its config file to "
dongsheng@627 7341 "enable <literal>mod_cgi</literal> and <literal>mod_userdir</literal>, both of "
dongsheng@627 7342 "which were disabled by default on my system. I then added a few lines to the "
dongsheng@627 7343 "end of the config file, to configure these modules."
dongsheng@627 7344 msgstr ""
dongsheng@627 7345
dongsheng@627 7346 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7347 #: ../en/ch05-collab.xml:1078
dongsheng@627 7348 msgid ""
dongsheng@627 7349 "With this done, <literal>lighttpd</literal> ran immediately for me. If I had "
dongsheng@627 7350 "configured <literal>lighttpd</literal> before Apache, I'd almost certainly "
dongsheng@627 7351 "have run into many of the same system-level configuration problems as I did "
dongsheng@627 7352 "with Apache. However, I found <literal>lighttpd</literal> to be noticeably "
dongsheng@627 7353 "easier to configure than Apache, even though I've used Apache for over a "
dongsheng@627 7354 "decade, and this was my first exposure to <literal>lighttpd</literal>."
dongsheng@627 7355 msgstr ""
dongsheng@627 7356
dongsheng@627 7357 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 7358 #: ../en/ch05-collab.xml:1091
dongsheng@627 7359 msgid "Sharing multiple repositories with one CGI script"
dongsheng@630 7360 msgstr "使用一个 CGI 脚本共享多个版本库"
dongsheng@627 7361
dongsheng@627 7362 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7363 #: ../en/ch05-collab.xml:1093
dongsheng@627 7364 msgid ""
dongsheng@627 7365 "The <filename role=\"special\">hgweb.cgi</filename> script only lets you "
dongsheng@627 7366 "publish a single repository, which is an annoying restriction. If you want "
dongsheng@627 7367 "to publish more than one without wracking yourself with multiple copies of "
dongsheng@627 7368 "the same script, each with different names, a better choice is to use the "
dongsheng@627 7369 "<filename role=\"special\">hgwebdir.cgi</filename> script."
dongsheng@627 7370 msgstr ""
dongsheng@627 7371
dongsheng@627 7372 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7373 #: ../en/ch05-collab.xml:1101
dongsheng@627 7374 msgid ""
dongsheng@627 7375 "The procedure to configure <filename role=\"special\">hgwebdir.cgi</filename> "
dongsheng@627 7376 "is only a little more involved than for <filename role=\"special\">hgweb.cgi</"
dongsheng@627 7377 "filename>. First, you must obtain a copy of the script. If you don't have "
dongsheng@627 7378 "one handy, you can download a copy from the master Mercurial repository at "
dongsheng@627 7379 "<ulink url=\"http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi"
dongsheng@627 7380 "\">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>."
dongsheng@627 7381 msgstr ""
dongsheng@627 7382
dongsheng@627 7383 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7384 #: ../en/ch05-collab.xml:1116
dongsheng@627 7385 msgid ""
dongsheng@627 7386 "With basic configuration out of the way, try to visit <ulink url=\"http://"
dongsheng@627 7387 "myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ myuser/hgwebdir.cgi</"
dongsheng@627 7388 "ulink> in your browser. It should display an empty list of repositories. If "
dongsheng@627 7389 "you get a blank window or error message, try walking through the list of "
songdongsheng@658 7390 "potential problems in <xref linkend=\"sec:collab:wtf\"/>."
songdongsheng@658 7391 msgstr ""
songdongsheng@658 7392
songdongsheng@658 7393 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7394 #: ../en/ch05-collab.xml:1125
dongsheng@627 7395 msgid ""
dongsheng@627 7396 "The <filename role=\"special\">hgwebdir.cgi</filename> script relies on an "
dongsheng@627 7397 "external configuration file. By default, it searches for a file named "
dongsheng@627 7398 "<filename role=\"special\">hgweb.config</filename> in the same directory as "
dongsheng@627 7399 "itself. You'll need to create this file, and make it world-readable. The "
dongsheng@627 7400 "format of the file is similar to a Windows <quote>ini</quote> file, as "
dongsheng@627 7401 "understood by Python's <literal>ConfigParser</literal> <citation>web:"
dongsheng@627 7402 "configparser</citation> module."
dongsheng@627 7403 msgstr ""
dongsheng@627 7404
dongsheng@627 7405 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7406 #: ../en/ch05-collab.xml:1135
dongsheng@627 7407 msgid ""
dongsheng@627 7408 "The easiest way to configure <filename role=\"special\">hgwebdir.cgi</"
dongsheng@627 7409 "filename> is with a section named <literal>collections</literal>. This will "
dongsheng@627 7410 "automatically publish <emphasis>every</emphasis> repository under the "
dongsheng@627 7411 "directories you name. The section should look like this:"
dongsheng@627 7412 msgstr ""
dongsheng@627 7413
dongsheng@627 7414 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7415 #: ../en/ch05-collab.xml:1143
dongsheng@627 7416 msgid ""
dongsheng@627 7417 "Mercurial interprets this by looking at the directory name on the "
dongsheng@627 7418 "<emphasis>right</emphasis> hand side of the <quote><literal>=</literal></"
dongsheng@627 7419 "quote> sign; finding repositories in that directory hierarchy; and using the "
dongsheng@627 7420 "text on the <emphasis>left</emphasis> to strip off matching text from the "
dongsheng@627 7421 "names it will actually list in the web interface. The remaining component of "
dongsheng@627 7422 "a path after this stripping has occurred is called a <quote>virtual path</"
dongsheng@627 7423 "quote>."
dongsheng@627 7424 msgstr ""
dongsheng@627 7425
dongsheng@627 7426 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7427 #: ../en/ch05-collab.xml:1152
dongsheng@627 7428 msgid ""
dongsheng@627 7429 "Given the example above, if we have a repository whose local path is "
dongsheng@627 7430 "<filename class=\"directory\">/my/root/this/repo</filename>, the CGI script "
dongsheng@627 7431 "will strip the leading <filename class=\"directory\">/my/root</filename> from "
dongsheng@627 7432 "the name, and publish the repository with a virtual path of <filename class="
dongsheng@627 7433 "\"directory\">this/repo</filename>. If the base URL for our CGI script is "
dongsheng@627 7434 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi\">http://myhostname/ "
dongsheng@627 7435 "myuser/hgwebdir.cgi</ulink>, the complete URL for that repository will be "
dongsheng@627 7436 "<ulink url=\"http://myhostname/ myuser/hgwebdir.cgi/this/repo\">http://"
dongsheng@627 7437 "myhostname/ myuser/hgwebdir.cgi/this/repo</ulink>."
dongsheng@627 7438 msgstr ""
dongsheng@627 7439
dongsheng@627 7440 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7441 #: ../en/ch05-collab.xml:1166
dongsheng@627 7442 msgid ""
dongsheng@627 7443 "If we replace <filename class=\"directory\">/my/root</filename> on the left "
dongsheng@627 7444 "hand side of this example with <filename class=\"directory\">/my</filename>, "
dongsheng@627 7445 "then <filename role=\"special\">hgwebdir.cgi</filename> will only strip off "
dongsheng@627 7446 "<filename class=\"directory\">/my</filename> from the repository name, and "
dongsheng@627 7447 "will give us a virtual path of <filename class=\"directory\">root/this/repo</"
dongsheng@627 7448 "filename> instead of <filename class=\"directory\">this/repo</filename>."
dongsheng@627 7449 msgstr ""
dongsheng@627 7450
dongsheng@627 7451 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7452 #: ../en/ch05-collab.xml:1176
dongsheng@627 7453 msgid ""
dongsheng@627 7454 "The <filename role=\"special\">hgwebdir.cgi</filename> script will "
dongsheng@627 7455 "recursively search each directory listed in the <literal>collections</"
dongsheng@627 7456 "literal> section of its configuration file, but it will <literal>not</"
dongsheng@627 7457 "literal> recurse into the repositories it finds."
dongsheng@627 7458 msgstr ""
dongsheng@627 7459
dongsheng@627 7460 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7461 #: ../en/ch05-collab.xml:1182
dongsheng@627 7462 msgid ""
dongsheng@627 7463 "The <literal>collections</literal> mechanism makes it easy to publish many "
dongsheng@627 7464 "repositories in a <quote>fire and forget</quote> manner. You only need to "
dongsheng@627 7465 "set up the CGI script and configuration file one time. Afterwards, you can "
dongsheng@627 7466 "publish or unpublish a repository at any time by simply moving it into, or "
dongsheng@627 7467 "out of, the directory hierarchy in which you've configured <filename role="
dongsheng@627 7468 "\"special\">hgwebdir.cgi</filename> to look."
dongsheng@627 7469 msgstr ""
dongsheng@627 7470
dongsheng@627 7471 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 7472 #: ../en/ch05-collab.xml:1192
dongsheng@627 7473 msgid "Explicitly specifying which repositories to publish"
dongsheng@630 7474 msgstr "明确指出要发布的版本库"
dongsheng@627 7475
dongsheng@627 7476 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7477 #: ../en/ch05-collab.xml:1195
dongsheng@627 7478 msgid ""
dongsheng@627 7479 "In addition to the <literal>collections</literal> mechanism, the <filename "
dongsheng@627 7480 "role=\"special\">hgwebdir.cgi</filename> script allows you to publish a "
dongsheng@627 7481 "specific list of repositories. To do so, create a <literal>paths</literal> "
dongsheng@627 7482 "section, with contents of the following form."
dongsheng@627 7483 msgstr ""
dongsheng@627 7484
dongsheng@627 7485 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7486 #: ../en/ch05-collab.xml:1204
dongsheng@627 7487 msgid ""
dongsheng@627 7488 "In this case, the virtual path (the component that will appear in a URL) is "
dongsheng@627 7489 "on the left hand side of each definition, while the path to the repository is "
dongsheng@627 7490 "on the right. Notice that there does not need to be any relationship between "
dongsheng@627 7491 "the virtual path you choose and the location of a repository in your "
dongsheng@627 7492 "filesystem."
dongsheng@627 7493 msgstr ""
dongsheng@627 7494
dongsheng@627 7495 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 7496 #: ../en/ch05-collab.xml:1211
dongsheng@627 7497 msgid ""
dongsheng@627 7498 "If you wish, you can use both the <literal>collections</literal> and "
dongsheng@627 7499 "<literal>paths</literal> mechanisms simultaneously in a single configuration "
dongsheng@627 7500 "file."
dongsheng@627 7501 msgstr ""
dongsheng@627 7502
dongsheng@627 7503 #. type: Content of: <book><chapter><sect1><sect2><sect3><note><para>
songdongsheng@658 7504 #: ../en/ch05-collab.xml:1217
dongsheng@627 7505 msgid ""
dongsheng@627 7506 "If multiple repositories have the same virtual path, <filename role=\"special"
dongsheng@627 7507 "\">hgwebdir.cgi</filename> will not report an error. Instead, it will behave "
dongsheng@627 7508 "unpredictably."
dongsheng@627 7509 msgstr ""
dongsheng@627 7510
dongsheng@627 7511 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 7512 #: ../en/ch05-collab.xml:1226
dongsheng@627 7513 msgid "Downloading source archives"
dongsheng@630 7514 msgstr "下载源代码档案包"
dongsheng@627 7515
dongsheng@627 7516 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7517 #: ../en/ch05-collab.xml:1228
dongsheng@627 7518 msgid ""
dongsheng@627 7519 "Mercurial's web interface lets users download an archive of any revision. "
dongsheng@627 7520 "This archive will contain a snapshot of the working directory as of that "
dongsheng@627 7521 "revision, but it will not contain a copy of the repository data."
dongsheng@627 7522 msgstr ""
dongsheng@627 7523
dongsheng@627 7524 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7525 #: ../en/ch05-collab.xml:1233
dongsheng@627 7526 msgid ""
dongsheng@627 7527 "By default, this feature is not enabled. To enable it, you'll need to add an "
dongsheng@627 7528 "<envar role=\"rc-item-web\">allow_archive</envar> item to the <literal role="
dongsheng@650 7529 "\"rc-web\">web</literal> section of your <filename role=\"special\">~/.hgrc</"
dongsheng@627 7530 "filename>."
dongsheng@627 7531 msgstr ""
dongsheng@627 7532
dongsheng@627 7533 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 7534 #: ../en/ch05-collab.xml:1241
dongsheng@627 7535 msgid "Web configuration options"
dongsheng@630 7536 msgstr "Web 配置选项"
dongsheng@627 7537
dongsheng@627 7538 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 7539 #: ../en/ch05-collab.xml:1243
dongsheng@627 7540 msgid ""
dongsheng@627 7541 "Mercurial's web interfaces (the <command role=\"hg-cmd\">hg serve</command> "
dongsheng@627 7542 "command, and the <filename role=\"special\">hgweb.cgi</filename> and "
dongsheng@627 7543 "<filename role=\"special\">hgwebdir.cgi</filename> scripts) have a number of "
dongsheng@627 7544 "configuration options that you can set. These belong in a section named "
dongsheng@627 7545 "<literal role=\"rc-web\">web</literal>."
dongsheng@627 7546 msgstr ""
dongsheng@627 7547
dongsheng@627 7548 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7549 #: ../en/ch05-collab.xml:1251
dongsheng@627 7550 msgid ""
dongsheng@627 7551 "<envar role=\"rc-item-web\">allow_archive</envar>: Determines which (if any) "
dongsheng@627 7552 "archive download mechanisms Mercurial supports. If you enable this feature, "
dongsheng@627 7553 "users of the web interface will be able to download an archive of whatever "
dongsheng@627 7554 "revision of a repository they are viewing. To enable the archive feature, "
dongsheng@627 7555 "this item must take the form of a sequence of words drawn from the list below."
dongsheng@627 7556 msgstr ""
dongsheng@627 7557
dongsheng@627 7558 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@658 7559 #: ../en/ch05-collab.xml:1260
dongsheng@627 7560 msgid ""
dongsheng@627 7561 "<literal>bz2</literal>: A <command>tar</command> archive, compressed using "
dongsheng@627 7562 "<literal>bzip2</literal> compression. This has the best compression ratio, "
dongsheng@627 7563 "but uses the most CPU time on the server."
dongsheng@627 7564 msgstr ""
dongsheng@627 7565
dongsheng@627 7566 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@658 7567 #: ../en/ch05-collab.xml:1266
dongsheng@627 7568 msgid ""
dongsheng@627 7569 "<literal>gz</literal>: A <command>tar</command> archive, compressed using "
dongsheng@627 7570 "<literal>gzip</literal> compression."
dongsheng@627 7571 msgstr ""
dongsheng@627 7572
dongsheng@627 7573 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><itemizedlist><listitem><para>
songdongsheng@658 7574 #: ../en/ch05-collab.xml:1270
dongsheng@627 7575 msgid ""
dongsheng@627 7576 "<literal>zip</literal>: A <command>zip</command> archive, compressed using "
dongsheng@627 7577 "LZW compression. This format has the worst compression ratio, but is widely "
dongsheng@627 7578 "used in the Windows world."
dongsheng@627 7579 msgstr ""
dongsheng@627 7580
dongsheng@627 7581 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7582 #: ../en/ch05-collab.xml:1276
dongsheng@627 7583 msgid ""
dongsheng@627 7584 "If you provide an empty list, or don't have an <envar role=\"rc-item-web"
dongsheng@627 7585 "\">allow_archive</envar> entry at all, this feature will be disabled. Here "
dongsheng@627 7586 "is an example of how to enable all three supported formats."
dongsheng@627 7587 msgstr ""
dongsheng@627 7588
dongsheng@627 7589 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7590 #: ../en/ch05-collab.xml:1283
dongsheng@627 7591 msgid ""
dongsheng@627 7592 "<envar role=\"rc-item-web\">allowpull</envar>: Boolean. Determines whether "
dongsheng@627 7593 "the web interface allows remote users to <command role=\"hg-cmd\">hg pull</"
dongsheng@627 7594 "command> and <command role=\"hg-cmd\">hg clone</command> this repository over "
dongsheng@627 7595 "HTTP. If set to <literal>no</literal> or <literal>false</literal>, only the "
dongsheng@627 7596 "<quote>human-oriented</quote> portion of the web interface is available."
dongsheng@627 7597 msgstr ""
dongsheng@627 7598
dongsheng@627 7599 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7600 #: ../en/ch05-collab.xml:1292
dongsheng@627 7601 msgid ""
dongsheng@627 7602 "<envar role=\"rc-item-web\">contact</envar>: String. A free-form (but "
dongsheng@627 7603 "preferably brief) string identifying the person or group in charge of the "
dongsheng@627 7604 "repository. This often contains the name and email address of a person or "
dongsheng@627 7605 "mailing list. It often makes sense to place this entry in a repository's own "
dongsheng@627 7606 "<filename role=\"special\">.hg/hgrc</filename> file, but it can make sense to "
dongsheng@650 7607 "use in a global <filename role=\"special\">~/.hgrc</filename> if every "
dongsheng@627 7608 "repository has a single maintainer."
dongsheng@627 7609 msgstr ""
dongsheng@627 7610
dongsheng@627 7611 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7612 #: ../en/ch05-collab.xml:1303
dongsheng@627 7613 msgid ""
dongsheng@627 7614 "<envar role=\"rc-item-web\">maxchanges</envar>: Integer. The default maximum "
dongsheng@627 7615 "number of changesets to display in a single page of output."
dongsheng@627 7616 msgstr ""
dongsheng@627 7617
dongsheng@627 7618 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7619 #: ../en/ch05-collab.xml:1307
dongsheng@627 7620 msgid ""
dongsheng@627 7621 "<envar role=\"rc-item-web\">maxfiles</envar>: Integer. The default maximum "
dongsheng@627 7622 "number of modified files to display in a single page of output."
dongsheng@627 7623 msgstr ""
dongsheng@627 7624
dongsheng@627 7625 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7626 #: ../en/ch05-collab.xml:1311
dongsheng@627 7627 msgid ""
dongsheng@627 7628 "<envar role=\"rc-item-web\">stripes</envar>: Integer. If the web interface "
dongsheng@627 7629 "displays alternating <quote>stripes</quote> to make it easier to visually "
dongsheng@627 7630 "align rows when you are looking at a table, this number controls the number "
dongsheng@627 7631 "of rows in each stripe."
dongsheng@627 7632 msgstr ""
dongsheng@627 7633
dongsheng@627 7634 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 7635 #: ../en/ch05-collab.xml:1317
dongsheng@627 7636 msgid ""
dongsheng@627 7637 "<envar role=\"rc-item-web\">style</envar>: Controls the template Mercurial "
dongsheng@627 7638 "uses to display the web interface. Mercurial ships with two web templates, "
dongsheng@627 7639 "named <literal>default</literal> and <literal>gitweb</literal> (the latter is "
dongsheng@627 7640 "much more visually attractive). You can also specify a custom template of "
songdongsheng@658 7641 "your own; see <xref linkend=\"chap:template\"/> for details. Here, you can "
songdongsheng@658 7642 "see how to enable the <literal>gitweb</literal> style."
dongsheng@627 7643 msgstr ""
dongsheng@627 7644
dongsheng@627 7645 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 7646 #: ../en/ch05-collab.xml:1330
dongsheng@627 7647 msgid ""
dongsheng@627 7648 "<envar role=\"rc-item-web\">templates</envar>: Path. The directory in which "
dongsheng@627 7649 "to search for template files. By default, Mercurial searches in the "
dongsheng@627 7650 "directory in which it was installed."
dongsheng@627 7651 msgstr ""
dongsheng@627 7652
dongsheng@627 7653 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 7654 #: ../en/ch05-collab.xml:1335
dongsheng@627 7655 msgid ""
dongsheng@627 7656 "If you are using <filename role=\"special\">hgwebdir.cgi</filename>, you can "
dongsheng@627 7657 "place a few configuration items in a <literal role=\"rc-web\">web</literal> "
dongsheng@627 7658 "section of the <filename role=\"special\">hgweb.config</filename> file "
dongsheng@650 7659 "instead of a <filename role=\"special\">~/.hgrc</filename> file, for "
dongsheng@627 7660 "convenience. These items are <envar role=\"rc-item-web\">motd</envar> and "
dongsheng@627 7661 "<envar role=\"rc-item-web\">style</envar>."
dongsheng@627 7662 msgstr ""
dongsheng@627 7663
dongsheng@627 7664 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 7665 #: ../en/ch05-collab.xml:1346
dongsheng@627 7666 msgid "Options specific to an individual repository"
dongsheng@630 7667 msgstr "针对单个版本库的选项"
dongsheng@627 7668
dongsheng@627 7669 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 7670 #: ../en/ch05-collab.xml:1348
dongsheng@627 7671 msgid ""
dongsheng@627 7672 "A few <literal role=\"rc-web\">web</literal> configuration items ought to be "
dongsheng@627 7673 "placed in a repository's local <filename role=\"special\">.hg/hgrc</"
dongsheng@650 7674 "filename>, rather than a user's or global <filename role=\"special\">~/.hgrc</"
dongsheng@627 7675 "filename>."
dongsheng@627 7676 msgstr ""
dongsheng@627 7677
dongsheng@627 7678 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 7679 #: ../en/ch05-collab.xml:1353
dongsheng@627 7680 msgid ""
dongsheng@627 7681 "<envar role=\"rc-item-web\">description</envar>: String. A free-form (but "
dongsheng@627 7682 "preferably brief) string that describes the contents or purpose of the "
dongsheng@627 7683 "repository."
dongsheng@627 7684 msgstr ""
dongsheng@627 7685
dongsheng@627 7686 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 7687 #: ../en/ch05-collab.xml:1358
dongsheng@627 7688 msgid ""
dongsheng@627 7689 "<envar role=\"rc-item-web\">name</envar>: String. The name to use for the "
dongsheng@627 7690 "repository in the web interface. This overrides the default name, which is "
dongsheng@627 7691 "the last component of the repository's path."
dongsheng@627 7692 msgstr ""
dongsheng@627 7693
dongsheng@627 7694 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 7695 #: ../en/ch05-collab.xml:1366
dongsheng@627 7696 msgid ""
dongsheng@627 7697 "Options specific to the <command role=\"hg-cmd\">hg serve</command> command"
dongsheng@630 7698 msgstr "命令 <command role=\"hg-cmd\">hg serve</command> 的选项"
dongsheng@627 7699
dongsheng@627 7700 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 7701 #: ../en/ch05-collab.xml:1369
dongsheng@627 7702 msgid ""
dongsheng@627 7703 "Some of the items in the <literal role=\"rc-web\">web</literal> section of a "
dongsheng@650 7704 "<filename role=\"special\">~/.hgrc</filename> file are only for use with the "
dongsheng@650 7705 "<command role=\"hg-cmd\">hg serve</command> command."
dongsheng@627 7706 msgstr ""
dongsheng@627 7707
dongsheng@627 7708 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 7709 #: ../en/ch05-collab.xml:1375
dongsheng@627 7710 msgid ""
dongsheng@627 7711 "<envar role=\"rc-item-web\">accesslog</envar>: Path. The name of a file into "
dongsheng@627 7712 "which to write an access log. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 7713 "serve</command> command writes this information to standard output, not to a "
dongsheng@627 7714 "file. Log entries are written in the standard <quote>combined</quote> file "
dongsheng@627 7715 "format used by almost all web servers."
dongsheng@627 7716 msgstr ""
dongsheng@627 7717
dongsheng@627 7718 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 7719 #: ../en/ch05-collab.xml:1383
dongsheng@627 7720 msgid ""
dongsheng@627 7721 "<envar role=\"rc-item-web\">address</envar>: String. The local address on "
dongsheng@627 7722 "which the server should listen for incoming connections. By default, the "
dongsheng@627 7723 "server listens on all addresses."
dongsheng@627 7724 msgstr ""
dongsheng@627 7725
dongsheng@627 7726 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 7727 #: ../en/ch05-collab.xml:1388
dongsheng@627 7728 msgid ""
dongsheng@627 7729 "<envar role=\"rc-item-web\">errorlog</envar>: Path. The name of a file into "
dongsheng@627 7730 "which to write an error log. By default, the <command role=\"hg-cmd\">hg "
dongsheng@627 7731 "serve</command> command writes this information to standard error, not to a "
dongsheng@627 7732 "file."
dongsheng@627 7733 msgstr ""
dongsheng@627 7734
dongsheng@627 7735 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 7736 #: ../en/ch05-collab.xml:1394
dongsheng@627 7737 msgid ""
dongsheng@627 7738 "<envar role=\"rc-item-web\">ipv6</envar>: Boolean. Whether to use the IPv6 "
dongsheng@627 7739 "protocol. By default, IPv6 is not used."
dongsheng@627 7740 msgstr ""
dongsheng@627 7741
dongsheng@627 7742 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 7743 #: ../en/ch05-collab.xml:1398
dongsheng@627 7744 msgid ""
dongsheng@627 7745 "<envar role=\"rc-item-web\">port</envar>: Integer. The TCP port number on "
dongsheng@627 7746 "which the server should listen. The default port number used is 8000."
dongsheng@627 7747 msgstr ""
dongsheng@627 7748
dongsheng@627 7749 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 7750 #: ../en/ch05-collab.xml:1405
dongsheng@650 7751 msgid ""
dongsheng@650 7752 "Choosing the right <filename role=\"special\">~/.hgrc</filename> file to add "
dongsheng@650 7753 "<literal role=\"rc-web\">web</literal> items to"
dongsheng@627 7754 msgstr ""
dongsheng@653 7755 "选择正确的 <filename role=\"special\"> ~/.hgrc</filename> 文件增加到 <literal "
dongsheng@630 7756 "role=\"rc-web\">web</literal> 条目"
dongsheng@627 7757
dongsheng@627 7758 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 7759 #: ../en/ch05-collab.xml:1409
dongsheng@627 7760 msgid ""
dongsheng@627 7761 "It is important to remember that a web server like Apache or "
dongsheng@627 7762 "<literal>lighttpd</literal> will run under a user ID that is different to "
dongsheng@627 7763 "yours. CGI scripts run by your server, such as <filename role=\"special"
dongsheng@627 7764 "\">hgweb.cgi</filename>, will usually also run under that user ID."
dongsheng@627 7765 msgstr ""
dongsheng@627 7766
dongsheng@627 7767 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 7768 #: ../en/ch05-collab.xml:1416
dongsheng@627 7769 msgid ""
dongsheng@627 7770 "If you add <literal role=\"rc-web\">web</literal> items to your own personal "
dongsheng@650 7771 "<filename role=\"special\">~/.hgrc</filename> file, CGI scripts won't read "
dongsheng@650 7772 "that <filename role=\"special\">~/.hgrc</filename> file. Those settings will "
dongsheng@650 7773 "thus only affect the behaviour of the <command role=\"hg-cmd\">hg serve</"
dongsheng@627 7774 "command> command when you run it. To cause CGI scripts to see your settings, "
dongsheng@650 7775 "either create a <filename role=\"special\">~/.hgrc</filename> file in the "
dongsheng@627 7776 "home directory of the user ID that runs your web server, or add those "
dongsheng@650 7777 "settings to a system-wide <filename role=\"special\">~/.hgrc</filename> file."
dongsheng@627 7778 msgstr ""
dongsheng@627 7779
dongsheng@627 7780 #. type: Content of: <book><chapter><title>
dongsheng@650 7781 #: ../en/ch06-filenames.xml:5
dongsheng@627 7782 msgid "File names and pattern matching"
dongsheng@627 7783 msgstr "文件名称与模式匹配"
dongsheng@627 7784
dongsheng@627 7785 #. type: Content of: <book><chapter><para>
dongsheng@650 7786 #: ../en/ch06-filenames.xml:7
dongsheng@627 7787 msgid ""
dongsheng@627 7788 "Mercurial provides mechanisms that let you work with file names in a "
dongsheng@627 7789 "consistent and expressive way."
dongsheng@627 7790 msgstr ""
dongsheng@627 7791
dongsheng@627 7792 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 7793 #: ../en/ch06-filenames.xml:11
dongsheng@627 7794 msgid "Simple file naming"
dongsheng@630 7795 msgstr "简单文件名称"
dongsheng@627 7796
dongsheng@627 7797 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7798 #: ../en/ch06-filenames.xml:13
dongsheng@627 7799 msgid ""
dongsheng@627 7800 "Mercurial uses a unified piece of machinery <quote>under the hood</quote> to "
dongsheng@627 7801 "handle file names. Every command behaves uniformly with respect to file "
dongsheng@627 7802 "names. The way in which commands work with file names is as follows."
dongsheng@627 7803 msgstr ""
dongsheng@627 7804
dongsheng@627 7805 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7806 #: ../en/ch06-filenames.xml:18
dongsheng@627 7807 msgid ""
dongsheng@627 7808 "If you explicitly name real files on the command line, Mercurial works with "
dongsheng@627 7809 "exactly those files, as you would expect. &interaction.filenames.files;"
dongsheng@627 7810 msgstr ""
dongsheng@627 7811
dongsheng@627 7812 #
dongsheng@627 7813 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7814 #: ../en/ch06-filenames.xml:22
dongsheng@627 7815 msgid ""
dongsheng@627 7816 "When you provide a directory name, Mercurial will interpret this as "
dongsheng@627 7817 "<quote>operate on every file in this directory and its subdirectories</"
dongsheng@627 7818 "quote>. Mercurial traverses the files and subdirectories in a directory in "
dongsheng@627 7819 "alphabetical order. When it encounters a subdirectory, it will traverse that "
dongsheng@627 7820 "subdirectory before continuing with the current directory."
dongsheng@627 7821 msgstr ""
dongsheng@627 7822
dongsheng@627 7823 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 7824 #: ../en/ch06-filenames.xml:33
dongsheng@627 7825 msgid "Running commands without any file names"
dongsheng@630 7826 msgstr "不提供文件名称的执行命令"
dongsheng@627 7827
dongsheng@627 7828 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7829 #: ../en/ch06-filenames.xml:35
dongsheng@627 7830 msgid ""
dongsheng@627 7831 "Mercurial's commands that work with file names have useful default behaviours "
dongsheng@627 7832 "when you invoke them without providing any file names or patterns. What kind "
dongsheng@627 7833 "of behaviour you should expect depends on what the command does. Here are a "
dongsheng@627 7834 "few rules of thumb you can use to predict what a command is likely to do if "
dongsheng@627 7835 "you don't give it any names to work with."
dongsheng@627 7836 msgstr ""
dongsheng@627 7837
dongsheng@627 7838 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 7839 #: ../en/ch06-filenames.xml:42
dongsheng@627 7840 msgid ""
dongsheng@627 7841 "Most commands will operate on the entire working directory. This is what the "
dongsheng@627 7842 "<command role=\"hg-cmd\">hg add</command> command does, for example."
dongsheng@627 7843 msgstr ""
dongsheng@627 7844
dongsheng@627 7845 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 7846 #: ../en/ch06-filenames.xml:46
dongsheng@627 7847 msgid ""
dongsheng@627 7848 "If the command has effects that are difficult or impossible to reverse, it "
dongsheng@627 7849 "will force you to explicitly provide at least one name or pattern (see "
dongsheng@627 7850 "below). This protects you from accidentally deleting files by running "
dongsheng@627 7851 "<command role=\"hg-cmd\">hg remove</command> with no arguments, for example."
dongsheng@627 7852 msgstr ""
dongsheng@627 7853
dongsheng@627 7854 #
dongsheng@627 7855 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7856 #: ../en/ch06-filenames.xml:54
dongsheng@627 7857 msgid ""
dongsheng@627 7858 "It's easy to work around these default behaviours if they don't suit you. If "
dongsheng@627 7859 "a command normally operates on the whole working directory, you can invoke it "
dongsheng@627 7860 "on just the current directory and its subdirectories by giving it the name "
dongsheng@627 7861 "<quote><filename class=\"directory\">.</filename></quote>."
dongsheng@627 7862 msgstr ""
dongsheng@627 7863
dongsheng@627 7864 #
dongsheng@627 7865 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7866 #: ../en/ch06-filenames.xml:62
dongsheng@627 7867 msgid ""
dongsheng@627 7868 "Along the same lines, some commands normally print file names relative to the "
dongsheng@627 7869 "root of the repository, even if you're invoking them from a subdirectory. "
dongsheng@627 7870 "Such a command will print file names relative to your subdirectory if you "
dongsheng@627 7871 "give it explicit names. Here, we're going to run <command role=\"hg-cmd\">hg "
dongsheng@627 7872 "status</command> from a subdirectory, and get it to operate on the entire "
dongsheng@627 7873 "working directory while printing file names relative to our subdirectory, by "
dongsheng@627 7874 "passing it the output of the <command role=\"hg-cmd\">hg root</command> "
dongsheng@627 7875 "command."
dongsheng@627 7876 msgstr ""
dongsheng@627 7877
dongsheng@627 7878 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 7879 #: ../en/ch06-filenames.xml:76
dongsheng@627 7880 msgid "Telling you what's going on"
dongsheng@630 7881 msgstr "告诉你正在做什么"
dongsheng@627 7882
dongsheng@627 7883 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7884 #: ../en/ch06-filenames.xml:78
dongsheng@627 7885 msgid ""
dongsheng@627 7886 "The <command role=\"hg-cmd\">hg add</command> example in the preceding "
dongsheng@627 7887 "section illustrates something else that's helpful about Mercurial commands. "
dongsheng@627 7888 "If a command operates on a file that you didn't name explicitly on the "
dongsheng@627 7889 "command line, it will usually print the name of the file, so that you will "
dongsheng@627 7890 "not be surprised what's going on."
dongsheng@627 7891 msgstr ""
dongsheng@627 7892
dongsheng@627 7893 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7894 #: ../en/ch06-filenames.xml:85
dongsheng@627 7895 msgid ""
dongsheng@627 7896 "The principle here is of <emphasis>least surprise</emphasis>. If you've "
dongsheng@627 7897 "exactly named a file on the command line, there's no point in repeating it "
dongsheng@627 7898 "back at you. If Mercurial is acting on a file <emphasis>implicitly</"
dongsheng@627 7899 "emphasis>, because you provided no names, or a directory, or a pattern (see "
dongsheng@627 7900 "below), it's safest to tell you what it's doing."
dongsheng@627 7901 msgstr ""
dongsheng@627 7902
dongsheng@627 7903 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7904 #: ../en/ch06-filenames.xml:92
dongsheng@627 7905 msgid ""
dongsheng@627 7906 "For commands that behave this way, you can silence them using the <option "
dongsheng@627 7907 "role=\"hg-opt-global\">-q</option> option. You can also get them to print "
dongsheng@627 7908 "the name of every file, even those you've named explicitly, using the <option "
dongsheng@627 7909 "role=\"hg-opt-global\">-v</option> option."
dongsheng@627 7910 msgstr ""
dongsheng@627 7911
dongsheng@627 7912 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 7913 #: ../en/ch06-filenames.xml:100
dongsheng@627 7914 msgid "Using patterns to identify files"
dongsheng@630 7915 msgstr "使用模式标识文件"
dongsheng@627 7916
dongsheng@627 7917 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7918 #: ../en/ch06-filenames.xml:102
dongsheng@627 7919 msgid ""
dongsheng@627 7920 "In addition to working with file and directory names, Mercurial lets you use "
dongsheng@627 7921 "<emphasis>patterns</emphasis> to identify files. Mercurial's pattern "
dongsheng@627 7922 "handling is expressive."
dongsheng@627 7923 msgstr ""
dongsheng@627 7924
dongsheng@627 7925 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7926 #: ../en/ch06-filenames.xml:106
dongsheng@627 7927 msgid ""
dongsheng@627 7928 "On Unix-like systems (Linux, MacOS, etc.), the job of matching file names to "
dongsheng@627 7929 "patterns normally falls to the shell. On these systems, you must explicitly "
dongsheng@627 7930 "tell Mercurial that a name is a pattern. On Windows, the shell does not "
dongsheng@627 7931 "expand patterns, so Mercurial will automatically identify names that are "
dongsheng@627 7932 "patterns, and expand them for you."
dongsheng@627 7933 msgstr ""
dongsheng@627 7934
dongsheng@627 7935 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7936 #: ../en/ch06-filenames.xml:113
dongsheng@627 7937 msgid ""
dongsheng@627 7938 "To provide a pattern in place of a regular name on the command line, the "
dongsheng@627 7939 "mechanism is simple:"
dongsheng@627 7940 msgstr ""
dongsheng@627 7941
dongsheng@627 7942 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7943 #: ../en/ch06-filenames.xml:116
dongsheng@627 7944 msgid ""
dongsheng@627 7945 "That is, a pattern is identified by a short text string that says what kind "
dongsheng@627 7946 "of pattern this is, followed by a colon, followed by the actual pattern."
dongsheng@627 7947 msgstr ""
dongsheng@627 7948
dongsheng@627 7949 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7950 #: ../en/ch06-filenames.xml:120
dongsheng@627 7951 msgid ""
dongsheng@627 7952 "Mercurial supports two kinds of pattern syntax. The most frequently used is "
dongsheng@627 7953 "called <literal>glob</literal>; this is the same kind of pattern matching "
dongsheng@627 7954 "used by the Unix shell, and should be familiar to Windows command prompt "
dongsheng@627 7955 "users, too."
dongsheng@627 7956 msgstr ""
dongsheng@627 7957
dongsheng@627 7958 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7959 #: ../en/ch06-filenames.xml:125
dongsheng@627 7960 msgid ""
dongsheng@627 7961 "When Mercurial does automatic pattern matching on Windows, it uses "
dongsheng@627 7962 "<literal>glob</literal> syntax. You can thus omit the <quote><literal>glob:</"
dongsheng@627 7963 "literal></quote> prefix on Windows, but it's safe to use it, too."
dongsheng@627 7964 msgstr ""
dongsheng@627 7965
dongsheng@627 7966 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7967 #: ../en/ch06-filenames.xml:130
dongsheng@627 7968 msgid ""
dongsheng@627 7969 "The <literal>re</literal> syntax is more powerful; it lets you specify "
dongsheng@627 7970 "patterns using regular expressions, also known as regexps."
dongsheng@627 7971 msgstr ""
dongsheng@627 7972
dongsheng@627 7973 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 7974 #: ../en/ch06-filenames.xml:134
dongsheng@627 7975 msgid ""
dongsheng@627 7976 "By the way, in the examples that follow, notice that I'm careful to wrap all "
dongsheng@627 7977 "of my patterns in quote characters, so that they won't get expanded by the "
dongsheng@627 7978 "shell before Mercurial sees them."
dongsheng@627 7979 msgstr ""
dongsheng@627 7980
dongsheng@627 7981 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 7982 #: ../en/ch06-filenames.xml:140
dongsheng@627 7983 msgid "Shell-style <literal>glob</literal> patterns"
dongsheng@630 7984 msgstr "外壳风格的 <literal>glob</literal> 模式"
dongsheng@627 7985
dongsheng@627 7986 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 7987 #: ../en/ch06-filenames.xml:142
dongsheng@627 7988 msgid ""
dongsheng@627 7989 "This is an overview of the kinds of patterns you can use when you're matching "
dongsheng@627 7990 "on glob patterns."
dongsheng@627 7991 msgstr ""
dongsheng@627 7992
dongsheng@627 7993 #
dongsheng@627 7994 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 7995 #: ../en/ch06-filenames.xml:145
dongsheng@627 7996 msgid ""
dongsheng@627 7997 "The <quote><literal>*</literal></quote> character matches any string, within "
dongsheng@627 7998 "a single directory."
dongsheng@627 7999 msgstr ""
dongsheng@627 8000
dongsheng@627 8001 #
dongsheng@627 8002 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8003 #: ../en/ch06-filenames.xml:150
dongsheng@627 8004 msgid ""
dongsheng@627 8005 "The <quote><literal>**</literal></quote> pattern matches any string, and "
dongsheng@627 8006 "crosses directory boundaries. It's not a standard Unix glob token, but it's "
dongsheng@627 8007 "accepted by several popular Unix shells, and is very useful."
dongsheng@627 8008 msgstr ""
dongsheng@627 8009
dongsheng@627 8010 #
dongsheng@627 8011 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8012 #: ../en/ch06-filenames.xml:157
dongsheng@627 8013 msgid ""
dongsheng@627 8014 "The <quote><literal>?</literal></quote> pattern matches any single character."
dongsheng@627 8015 msgstr ""
dongsheng@627 8016
dongsheng@627 8017 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8018 #: ../en/ch06-filenames.xml:162
dongsheng@627 8019 msgid ""
dongsheng@627 8020 "The <quote><literal>[</literal></quote> character begins a "
dongsheng@627 8021 "<emphasis>character class</emphasis>. This matches any single character "
dongsheng@627 8022 "within the class. The class ends with a <quote><literal>]</literal></quote> "
dongsheng@627 8023 "character. A class may contain multiple <emphasis>range</emphasis>s of the "
dongsheng@627 8024 "form <quote><literal>a-f</literal></quote>, which is shorthand for "
dongsheng@627 8025 "<quote><literal>abcdef</literal></quote>."
dongsheng@627 8026 msgstr ""
dongsheng@627 8027
dongsheng@627 8028 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8029 #: ../en/ch06-filenames.xml:172
dongsheng@627 8030 msgid ""
dongsheng@627 8031 "If the first character after the <quote><literal>[</literal></quote> in a "
dongsheng@627 8032 "character class is a <quote><literal>!</literal></quote>, it "
dongsheng@627 8033 "<emphasis>negates</emphasis> the class, making it match any single character "
dongsheng@627 8034 "not in the class."
dongsheng@627 8035 msgstr ""
dongsheng@627 8036
dongsheng@627 8037 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8038 #: ../en/ch06-filenames.xml:178
dongsheng@627 8039 msgid ""
dongsheng@627 8040 "A <quote><literal>{</literal></quote> begins a group of subpatterns, where "
dongsheng@627 8041 "the whole group matches if any subpattern in the group matches. The "
dongsheng@627 8042 "<quote><literal>,</literal></quote> character separates subpatterns, and "
dongsheng@627 8043 "<quote><literal>}</literal></quote> ends the group."
dongsheng@627 8044 msgstr ""
dongsheng@627 8045
dongsheng@627 8046 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 8047 #: ../en/ch06-filenames.xml:187
dongsheng@627 8048 msgid "Watch out!"
dongsheng@630 8049 msgstr "千万小心!"
dongsheng@627 8050
dongsheng@627 8051 #
dongsheng@627 8052 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 8053 #: ../en/ch06-filenames.xml:189
dongsheng@627 8054 msgid ""
dongsheng@627 8055 "Don't forget that if you want to match a pattern in any directory, you should "
dongsheng@627 8056 "not be using the <quote><literal>*</literal></quote> match-any token, as this "
dongsheng@627 8057 "will only match within one directory. Instead, use the <quote><literal>**</"
dongsheng@627 8058 "literal></quote> token. This small example illustrates the difference "
dongsheng@627 8059 "between the two."
dongsheng@627 8060 msgstr ""
dongsheng@627 8061
dongsheng@627 8062 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8063 #: ../en/ch06-filenames.xml:201
dongsheng@627 8064 msgid "Regular expression matching with <literal>re</literal> patterns"
dongsheng@630 8065 msgstr "使用 <literal>re</literal> 模式的正则表达式匹配"
dongsheng@627 8066
dongsheng@627 8067 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8068 #: ../en/ch06-filenames.xml:204
dongsheng@627 8069 msgid ""
dongsheng@627 8070 "Mercurial accepts the same regular expression syntax as the Python "
dongsheng@627 8071 "programming language (it uses Python's regexp engine internally). This is "
dongsheng@627 8072 "based on the Perl language's regexp syntax, which is the most popular dialect "
dongsheng@627 8073 "in use (it's also used in Java, for example)."
dongsheng@627 8074 msgstr ""
dongsheng@627 8075
dongsheng@627 8076 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8077 #: ../en/ch06-filenames.xml:210
dongsheng@627 8078 msgid ""
dongsheng@627 8079 "I won't discuss Mercurial's regexp dialect in any detail here, as regexps are "
dongsheng@627 8080 "not often used. Perl-style regexps are in any case already exhaustively "
dongsheng@627 8081 "documented on a multitude of web sites, and in many books. Instead, I will "
dongsheng@627 8082 "focus here on a few things you should know if you find yourself needing to "
dongsheng@627 8083 "use regexps with Mercurial."
dongsheng@627 8084 msgstr ""
dongsheng@627 8085
dongsheng@627 8086 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8087 #: ../en/ch06-filenames.xml:217
dongsheng@627 8088 msgid ""
dongsheng@627 8089 "A regexp is matched against an entire file name, relative to the root of the "
dongsheng@627 8090 "repository. In other words, even if you're already in subbdirectory "
dongsheng@627 8091 "<filename class=\"directory\">foo</filename>, if you want to match files "
dongsheng@627 8092 "under this directory, your pattern must start with <quote><literal>foo/</"
dongsheng@627 8093 "literal></quote>."
dongsheng@627 8094 msgstr ""
dongsheng@627 8095
dongsheng@627 8096 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8097 #: ../en/ch06-filenames.xml:224
dongsheng@627 8098 msgid ""
dongsheng@627 8099 "One thing to note, if you're familiar with Perl-style regexps, is that "
dongsheng@627 8100 "Mercurial's are <emphasis>rooted</emphasis>. That is, a regexp starts "
dongsheng@627 8101 "matching against the beginning of a string; it doesn't look for a match "
dongsheng@627 8102 "anywhere within the string. To match anywhere in a string, start your "
dongsheng@627 8103 "pattern with <quote><literal>.*</literal></quote>."
dongsheng@627 8104 msgstr ""
dongsheng@627 8105
dongsheng@627 8106 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8107 #: ../en/ch06-filenames.xml:234
dongsheng@627 8108 msgid "Filtering files"
dongsheng@630 8109 msgstr "过滤文件"
dongsheng@627 8110
dongsheng@627 8111 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8112 #: ../en/ch06-filenames.xml:236
dongsheng@627 8113 msgid ""
dongsheng@627 8114 "Not only does Mercurial give you a variety of ways to specify files; it lets "
dongsheng@627 8115 "you further winnow those files using <emphasis>filters</emphasis>. Commands "
dongsheng@627 8116 "that work with file names accept two filtering options."
dongsheng@627 8117 msgstr ""
dongsheng@627 8118
dongsheng@627 8119 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8120 #: ../en/ch06-filenames.xml:241
dongsheng@627 8121 msgid ""
dongsheng@627 8122 "<option role=\"hg-opt-global\">-I</option>, or <option role=\"hg-opt-global"
dongsheng@627 8123 "\">--include</option>, lets you specify a pattern that file names must match "
dongsheng@627 8124 "in order to be processed."
dongsheng@627 8125 msgstr ""
dongsheng@627 8126
dongsheng@627 8127 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8128 #: ../en/ch06-filenames.xml:246
dongsheng@627 8129 msgid ""
dongsheng@627 8130 "<option role=\"hg-opt-global\">-X</option>, or <option role=\"hg-opt-global"
dongsheng@627 8131 "\">--exclude</option>, gives you a way to <emphasis>avoid</emphasis> "
dongsheng@627 8132 "processing files, if they match this pattern."
dongsheng@627 8133 msgstr ""
dongsheng@627 8134
dongsheng@627 8135 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8136 #: ../en/ch06-filenames.xml:251
dongsheng@627 8137 msgid ""
dongsheng@627 8138 "You can provide multiple <option role=\"hg-opt-global\">-I</option> and "
dongsheng@627 8139 "<option role=\"hg-opt-global\">-X</option> options on the command line, and "
dongsheng@627 8140 "intermix them as you please. Mercurial interprets the patterns you provide "
dongsheng@627 8141 "using glob syntax by default (but you can use regexps if you need to)."
dongsheng@627 8142 msgstr ""
dongsheng@627 8143
dongsheng@627 8144 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8145 #: ../en/ch06-filenames.xml:258
dongsheng@627 8146 msgid ""
dongsheng@627 8147 "You can read a <option role=\"hg-opt-global\">-I</option> filter as "
dongsheng@627 8148 "<quote>process only the files that match this filter</quote>."
dongsheng@627 8149 msgstr ""
dongsheng@627 8150
dongsheng@627 8151 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8152 #: ../en/ch06-filenames.xml:264
dongsheng@627 8153 msgid ""
dongsheng@627 8154 "The <option role=\"hg-opt-global\">-X</option> filter is best read as "
dongsheng@627 8155 "<quote>process only the files that don't match this pattern</quote>."
dongsheng@627 8156 msgstr ""
dongsheng@627 8157
dongsheng@627 8158 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8159 #: ../en/ch06-filenames.xml:272
dongsheng@627 8160 msgid "Ignoring unwanted files and directories"
dongsheng@630 8161 msgstr "忽略不需要的文件和目录"
dongsheng@627 8162
dongsheng@627 8163 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8164 #: ../en/ch06-filenames.xml:274
dongsheng@627 8165 msgid "XXX."
dongsheng@627 8166 msgstr ""
dongsheng@627 8167
dongsheng@627 8168 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8169 #: ../en/ch06-filenames.xml:278
dongsheng@627 8170 msgid "Case sensitivity"
dongsheng@630 8171 msgstr "大小写敏感性"
dongsheng@627 8172
dongsheng@627 8173 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8174 #: ../en/ch06-filenames.xml:280
dongsheng@627 8175 msgid ""
dongsheng@627 8176 "If you're working in a mixed development environment that contains both Linux "
dongsheng@627 8177 "(or other Unix) systems and Macs or Windows systems, you should keep in the "
dongsheng@627 8178 "back of your mind the knowledge that they treat the case (<quote>N</quote> "
dongsheng@627 8179 "versus <quote>n</quote>) of file names in incompatible ways. This is not "
dongsheng@627 8180 "very likely to affect you, and it's easy to deal with if it does, but it "
dongsheng@627 8181 "could surprise you if you don't know about it."
dongsheng@627 8182 msgstr ""
dongsheng@627 8183
dongsheng@627 8184 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8185 #: ../en/ch06-filenames.xml:289
dongsheng@627 8186 msgid ""
dongsheng@627 8187 "Operating systems and filesystems differ in the way they handle the "
dongsheng@627 8188 "<emphasis>case</emphasis> of characters in file and directory names. There "
dongsheng@627 8189 "are three common ways to handle case in names."
dongsheng@627 8190 msgstr ""
dongsheng@627 8191
dongsheng@627 8192 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8193 #: ../en/ch06-filenames.xml:294
dongsheng@627 8194 msgid ""
dongsheng@627 8195 "Completely case insensitive. Uppercase and lowercase versions of a letter "
dongsheng@627 8196 "are treated as identical, both when creating a file and during subsequent "
dongsheng@627 8197 "accesses. This is common on older DOS-based systems."
dongsheng@627 8198 msgstr ""
dongsheng@627 8199
dongsheng@627 8200 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8201 #: ../en/ch06-filenames.xml:299
dongsheng@627 8202 msgid ""
dongsheng@627 8203 "Case preserving, but insensitive. When a file or directory is created, the "
dongsheng@627 8204 "case of its name is stored, and can be retrieved and displayed by the "
dongsheng@627 8205 "operating system. When an existing file is being looked up, its case is "
dongsheng@627 8206 "ignored. This is the standard arrangement on Windows and MacOS. The names "
dongsheng@627 8207 "<filename>foo</filename> and <filename>FoO</filename> identify the same "
dongsheng@627 8208 "file. This treatment of uppercase and lowercase letters as interchangeable "
dongsheng@627 8209 "is also referred to as <emphasis>case folding</emphasis>."
dongsheng@627 8210 msgstr ""
dongsheng@627 8211
dongsheng@627 8212 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8213 #: ../en/ch06-filenames.xml:310
dongsheng@627 8214 msgid ""
dongsheng@627 8215 "Case sensitive. The case of a name is significant at all times. The names "
dongsheng@627 8216 "<filename>foo</filename> and {FoO} identify different files. This is the way "
dongsheng@627 8217 "Linux and Unix systems normally work."
dongsheng@627 8218 msgstr ""
dongsheng@627 8219
dongsheng@627 8220 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8221 #: ../en/ch06-filenames.xml:316
dongsheng@627 8222 msgid ""
dongsheng@627 8223 "On Unix-like systems, it is possible to have any or all of the above ways of "
dongsheng@627 8224 "handling case in action at once. For example, if you use a USB thumb drive "
dongsheng@627 8225 "formatted with a FAT32 filesystem on a Linux system, Linux will handle names "
dongsheng@627 8226 "on that filesystem in a case preserving, but insensitive, way."
dongsheng@627 8227 msgstr ""
dongsheng@627 8228
dongsheng@627 8229 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8230 #: ../en/ch06-filenames.xml:323
dongsheng@627 8231 msgid "Safe, portable repository storage"
dongsheng@630 8232 msgstr "安全,可移植的版本库存储"
dongsheng@627 8233
dongsheng@627 8234 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8235 #: ../en/ch06-filenames.xml:325
dongsheng@627 8236 msgid ""
dongsheng@627 8237 "Mercurial's repository storage mechanism is <emphasis>case safe</emphasis>. "
dongsheng@627 8238 "It translates file names so that they can be safely stored on both case "
dongsheng@627 8239 "sensitive and case insensitive filesystems. This means that you can use "
dongsheng@627 8240 "normal file copying tools to transfer a Mercurial repository onto, for "
dongsheng@627 8241 "example, a USB thumb drive, and safely move that drive and repository back "
dongsheng@627 8242 "and forth between a Mac, a PC running Windows, and a Linux box."
dongsheng@627 8243 msgstr ""
dongsheng@627 8244
dongsheng@627 8245 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8246 #: ../en/ch06-filenames.xml:336
dongsheng@627 8247 msgid "Detecting case conflicts"
dongsheng@630 8248 msgstr "检测大小写冲突"
dongsheng@627 8249
dongsheng@627 8250 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8251 #: ../en/ch06-filenames.xml:338
dongsheng@627 8252 msgid ""
dongsheng@627 8253 "When operating in the working directory, Mercurial honours the naming policy "
dongsheng@627 8254 "of the filesystem where the working directory is located. If the filesystem "
dongsheng@627 8255 "is case preserving, but insensitive, Mercurial will treat names that differ "
dongsheng@627 8256 "only in case as the same."
dongsheng@627 8257 msgstr ""
dongsheng@627 8258
dongsheng@627 8259 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8260 #: ../en/ch06-filenames.xml:344
dongsheng@627 8261 msgid ""
dongsheng@627 8262 "An important aspect of this approach is that it is possible to commit a "
dongsheng@627 8263 "changeset on a case sensitive (typically Linux or Unix) filesystem that will "
dongsheng@627 8264 "cause trouble for users on case insensitive (usually Windows and MacOS) "
dongsheng@627 8265 "users. If a Linux user commits changes to two files, one named "
dongsheng@627 8266 "<filename>myfile.c</filename> and the other named <filename>MyFile.C</"
dongsheng@627 8267 "filename>, they will be stored correctly in the repository. And in the "
dongsheng@627 8268 "working directories of other Linux users, they will be correctly represented "
dongsheng@627 8269 "as separate files."
dongsheng@627 8270 msgstr ""
dongsheng@627 8271
dongsheng@627 8272 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8273 #: ../en/ch06-filenames.xml:355
dongsheng@627 8274 msgid ""
dongsheng@627 8275 "If a Windows or Mac user pulls this change, they will not initially have a "
dongsheng@627 8276 "problem, because Mercurial's repository storage mechanism is case safe. "
dongsheng@627 8277 "However, once they try to <command role=\"hg-cmd\">hg update</command> the "
dongsheng@627 8278 "working directory to that changeset, or <command role=\"hg-cmd\">hg merge</"
dongsheng@627 8279 "command> with that changeset, Mercurial will spot the conflict between the "
dongsheng@627 8280 "two file names that the filesystem would treat as the same, and forbid the "
dongsheng@627 8281 "update or merge from occurring."
dongsheng@627 8282 msgstr ""
dongsheng@627 8283
dongsheng@627 8284 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8285 #: ../en/ch06-filenames.xml:367
dongsheng@627 8286 msgid "Fixing a case conflict"
dongsheng@630 8287 msgstr "修正大小写冲突"
dongsheng@627 8288
dongsheng@627 8289 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8290 #: ../en/ch06-filenames.xml:369
dongsheng@627 8291 msgid ""
dongsheng@627 8292 "If you are using Windows or a Mac in a mixed environment where some of your "
dongsheng@627 8293 "collaborators are using Linux or Unix, and Mercurial reports a case folding "
dongsheng@627 8294 "conflict when you try to <command role=\"hg-cmd\">hg update</command> or "
dongsheng@627 8295 "<command role=\"hg-cmd\">hg merge</command>, the procedure to fix the problem "
dongsheng@627 8296 "is simple."
dongsheng@627 8297 msgstr ""
dongsheng@627 8298
dongsheng@627 8299 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8300 #: ../en/ch06-filenames.xml:376
dongsheng@627 8301 msgid ""
dongsheng@627 8302 "Just find a nearby Linux or Unix box, clone the problem repository onto it, "
dongsheng@627 8303 "and use Mercurial's <command role=\"hg-cmd\">hg rename</command> command to "
dongsheng@627 8304 "change the names of any offending files or directories so that they will no "
dongsheng@627 8305 "longer cause case folding conflicts. Commit this change, <command role=\"hg-"
dongsheng@627 8306 "cmd\">hg pull</command> or <command role=\"hg-cmd\">hg push</command> it "
dongsheng@627 8307 "across to your Windows or MacOS system, and <command role=\"hg-cmd\">hg "
dongsheng@627 8308 "update</command> to the revision with the non-conflicting names."
dongsheng@627 8309 msgstr ""
dongsheng@627 8310
dongsheng@627 8311 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8312 #: ../en/ch06-filenames.xml:386
dongsheng@627 8313 msgid ""
dongsheng@627 8314 "The changeset with case-conflicting names will remain in your project's "
dongsheng@627 8315 "history, and you still won't be able to <command role=\"hg-cmd\">hg update</"
dongsheng@627 8316 "command> your working directory to that changeset on a Windows or MacOS "
dongsheng@627 8317 "system, but you can continue development unimpeded."
dongsheng@627 8318 msgstr ""
dongsheng@627 8319
dongsheng@627 8320 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@650 8321 #: ../en/ch06-filenames.xml:393
dongsheng@627 8322 msgid ""
dongsheng@627 8323 "Prior to version 0.9.3, Mercurial did not use a case safe repository storage "
dongsheng@627 8324 "mechanism, and did not detect case folding conflicts. If you are using an "
dongsheng@627 8325 "older version of Mercurial on Windows or MacOS, I strongly recommend that you "
dongsheng@627 8326 "upgrade."
dongsheng@627 8327 msgstr ""
dongsheng@627 8328
dongsheng@627 8329 #. type: Content of: <book><chapter><title>
dongsheng@650 8330 #: ../en/ch07-branch.xml:5
dongsheng@627 8331 msgid "Managing releases and branchy development"
dongsheng@627 8332 msgstr "发布管理与分支开发"
dongsheng@627 8333
dongsheng@627 8334 #. type: Content of: <book><chapter><para>
dongsheng@650 8335 #: ../en/ch07-branch.xml:7
dongsheng@627 8336 msgid ""
dongsheng@627 8337 "Mercurial provides several mechanisms for you to manage a project that is "
dongsheng@627 8338 "making progress on multiple fronts at once. To understand these mechanisms, "
dongsheng@627 8339 "let's first take a brief look at a fairly normal software project structure."
dongsheng@627 8340 msgstr ""
dongsheng@627 8341
dongsheng@627 8342 #. type: Content of: <book><chapter><para>
dongsheng@650 8343 #: ../en/ch07-branch.xml:12
dongsheng@627 8344 msgid ""
dongsheng@627 8345 "Many software projects issue periodic <quote>major</quote> releases that "
dongsheng@627 8346 "contain substantial new features. In parallel, they may issue <quote>minor</"
dongsheng@627 8347 "quote> releases. These are usually identical to the major releases off which "
dongsheng@627 8348 "they're based, but with a few bugs fixed."
dongsheng@627 8349 msgstr ""
dongsheng@627 8350
dongsheng@627 8351 #. type: Content of: <book><chapter><para>
dongsheng@650 8352 #: ../en/ch07-branch.xml:18
dongsheng@627 8353 msgid ""
dongsheng@627 8354 "In this chapter, we'll start by talking about how to keep records of project "
dongsheng@627 8355 "milestones such as releases. We'll then continue on to talk about the flow "
dongsheng@627 8356 "of work between different phases of a project, and how Mercurial can help you "
dongsheng@627 8357 "to isolate and manage this work."
dongsheng@627 8358 msgstr ""
dongsheng@627 8359
dongsheng@627 8360 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8361 #: ../en/ch07-branch.xml:25
dongsheng@627 8362 msgid "Giving a persistent name to a revision"
dongsheng@635 8363 msgstr "给版本指定一个永久的名称"
dongsheng@627 8364
dongsheng@627 8365 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8366 #: ../en/ch07-branch.xml:27
dongsheng@627 8367 msgid ""
dongsheng@627 8368 "Once you decide that you'd like to call a particular revision a "
dongsheng@627 8369 "<quote>release</quote>, it's a good idea to record the identity of that "
dongsheng@627 8370 "revision. This will let you reproduce that release at a later date, for "
dongsheng@627 8371 "whatever purpose you might need at the time (reproducing a bug, porting to a "
dongsheng@627 8372 "new platform, etc). &interaction.tag.init;"
dongsheng@627 8373 msgstr ""
dongsheng@627 8374
dongsheng@627 8375 #
dongsheng@627 8376 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8377 #: ../en/ch07-branch.xml:34
dongsheng@627 8378 msgid ""
dongsheng@627 8379 "Mercurial lets you give a permanent name to any revision using the <command "
dongsheng@627 8380 "role=\"hg-cmd\">hg tag</command> command. Not surprisingly, these names are "
dongsheng@627 8381 "called <quote>tags</quote>."
dongsheng@627 8382 msgstr ""
dongsheng@627 8383
dongsheng@627 8384 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8385 #: ../en/ch07-branch.xml:40
dongsheng@627 8386 msgid ""
dongsheng@627 8387 "A tag is nothing more than a <quote>symbolic name</quote> for a revision. "
dongsheng@627 8388 "Tags exist purely for your convenience, so that you have a handy permanent "
dongsheng@627 8389 "way to refer to a revision; Mercurial doesn't interpret the tag names you use "
dongsheng@627 8390 "in any way. Neither does Mercurial place any restrictions on the name of a "
dongsheng@627 8391 "tag, beyond a few that are necessary to ensure that a tag can be parsed "
dongsheng@627 8392 "unambiguously. A tag name cannot contain any of the following characters:"
dongsheng@627 8393 msgstr ""
dongsheng@627 8394
dongsheng@627 8395 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8396 #: ../en/ch07-branch.xml:49
dongsheng@627 8397 msgid "Colon (ASCII 58, <quote><literal>:</literal></quote>)"
dongsheng@627 8398 msgstr ""
dongsheng@627 8399
dongsheng@627 8400 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8401 #: ../en/ch07-branch.xml:52
dongsheng@627 8402 msgid "Carriage return (ASCII 13, <quote><literal>\\r</literal></quote>)"
dongsheng@627 8403 msgstr ""
dongsheng@627 8404
dongsheng@627 8405 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8406 #: ../en/ch07-branch.xml:55
dongsheng@627 8407 msgid "Newline (ASCII 10, <quote><literal>\\n</literal></quote>)"
dongsheng@627 8408 msgstr ""
dongsheng@627 8409
dongsheng@627 8410 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8411 #: ../en/ch07-branch.xml:59
dongsheng@627 8412 msgid ""
dongsheng@627 8413 "You can use the <command role=\"hg-cmd\">hg tags</command> command to display "
dongsheng@627 8414 "the tags present in your repository. In the output, each tagged revision is "
dongsheng@627 8415 "identified first by its name, then by revision number, and finally by the "
dongsheng@627 8416 "unique hash of the revision."
dongsheng@627 8417 msgstr ""
dongsheng@627 8418
dongsheng@627 8419 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8420 #: ../en/ch07-branch.xml:67
dongsheng@627 8421 msgid ""
dongsheng@627 8422 "Notice that <literal>tip</literal> is listed in the output of <command role="
dongsheng@627 8423 "\"hg-cmd\">hg tags</command>. The <literal>tip</literal> tag is a special "
dongsheng@627 8424 "<quote>floating</quote> tag, which always identifies the newest revision in "
dongsheng@627 8425 "the repository."
dongsheng@627 8426 msgstr ""
dongsheng@627 8427
dongsheng@627 8428 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8429 #: ../en/ch07-branch.xml:73
dongsheng@627 8430 msgid ""
dongsheng@627 8431 "In the output of the <command role=\"hg-cmd\">hg tags</command> command, tags "
dongsheng@627 8432 "are listed in reverse order, by revision number. This usually means that "
dongsheng@627 8433 "recent tags are listed before older tags. It also means that <literal>tip</"
dongsheng@627 8434 "literal> is always going to be the first tag listed in the output of <command "
dongsheng@627 8435 "role=\"hg-cmd\">hg tags</command>."
dongsheng@627 8436 msgstr ""
dongsheng@627 8437
dongsheng@627 8438 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8439 #: ../en/ch07-branch.xml:80
dongsheng@627 8440 msgid ""
dongsheng@627 8441 "When you run <command role=\"hg-cmd\">hg log</command>, if it displays a "
dongsheng@627 8442 "revision that has tags associated with it, it will print those tags."
dongsheng@627 8443 msgstr ""
dongsheng@627 8444
dongsheng@627 8445 #
dongsheng@627 8446 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8447 #: ../en/ch07-branch.xml:86
dongsheng@627 8448 msgid ""
dongsheng@627 8449 "Any time you need to provide a revision ID to a Mercurial command, the "
dongsheng@627 8450 "command will accept a tag name in its place. Internally, Mercurial will "
dongsheng@627 8451 "translate your tag name into the corresponding revision ID, then use that."
dongsheng@627 8452 msgstr ""
dongsheng@627 8453
dongsheng@627 8454 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8455 #: ../en/ch07-branch.xml:93
dongsheng@627 8456 msgid ""
dongsheng@627 8457 "There's no limit on the number of tags you can have in a repository, or on "
dongsheng@627 8458 "the number of tags that a single revision can have. As a practical matter, "
dongsheng@627 8459 "it's not a great idea to have <quote>too many</quote> (a number which will "
dongsheng@627 8460 "vary from project to project), simply because tags are supposed to help you "
dongsheng@627 8461 "to find revisions. If you have lots of tags, the ease of using them to "
dongsheng@627 8462 "identify revisions diminishes rapidly."
dongsheng@627 8463 msgstr ""
dongsheng@627 8464
dongsheng@627 8465 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8466 #: ../en/ch07-branch.xml:101
dongsheng@627 8467 msgid ""
dongsheng@627 8468 "For example, if your project has milestones as frequent as every few days, "
dongsheng@627 8469 "it's perfectly reasonable to tag each one of those. But if you have a "
dongsheng@627 8470 "continuous build system that makes sure every revision can be built cleanly, "
dongsheng@627 8471 "you'd be introducing a lot of noise if you were to tag every clean build. "
dongsheng@627 8472 "Instead, you could tag failed builds (on the assumption that they're rare!), "
dongsheng@627 8473 "or simply not use tags to track buildability."
dongsheng@627 8474 msgstr ""
dongsheng@627 8475
dongsheng@627 8476 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8477 #: ../en/ch07-branch.xml:109
dongsheng@627 8478 msgid ""
dongsheng@627 8479 "If you want to remove a tag that you no longer want, use <command role=\"hg-"
dongsheng@627 8480 "cmd\">hg tag --remove</command>."
dongsheng@627 8481 msgstr ""
dongsheng@627 8482
dongsheng@627 8483 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8484 #: ../en/ch07-branch.xml:114
dongsheng@627 8485 msgid ""
dongsheng@627 8486 "You can also modify a tag at any time, so that it identifies a different "
dongsheng@627 8487 "revision, by simply issuing a new <command role=\"hg-cmd\">hg tag</command> "
dongsheng@627 8488 "command. You'll have to use the <option role=\"hg-opt-tag\">-f</option> "
dongsheng@627 8489 "option to tell Mercurial that you <emphasis>really</emphasis> want to update "
dongsheng@627 8490 "the tag."
dongsheng@627 8491 msgstr ""
dongsheng@627 8492
dongsheng@627 8493 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8494 #: ../en/ch07-branch.xml:123
dongsheng@627 8495 msgid ""
dongsheng@627 8496 "There will still be a permanent record of the previous identity of the tag, "
dongsheng@627 8497 "but Mercurial will no longer use it. There's thus no penalty to tagging the "
dongsheng@627 8498 "wrong revision; all you have to do is turn around and tag the correct "
dongsheng@627 8499 "revision once you discover your error."
dongsheng@627 8500 msgstr ""
dongsheng@627 8501
dongsheng@627 8502 #
dongsheng@627 8503 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8504 #: ../en/ch07-branch.xml:129
dongsheng@627 8505 msgid ""
dongsheng@627 8506 "Mercurial stores tags in a normal revision-controlled file in your "
dongsheng@627 8507 "repository. If you've created any tags, you'll find them in a file named "
dongsheng@627 8508 "<filename role=\"special\">.hgtags</filename>. When you run the <command "
dongsheng@627 8509 "role=\"hg-cmd\">hg tag</command> command, Mercurial modifies this file, then "
dongsheng@627 8510 "automatically commits the change to it. This means that every time you run "
dongsheng@627 8511 "<command role=\"hg-cmd\">hg tag</command>, you'll see a corresponding "
dongsheng@627 8512 "changeset in the output of <command role=\"hg-cmd\">hg log</command>."
dongsheng@627 8513 msgstr ""
dongsheng@627 8514
dongsheng@627 8515 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8516 #: ../en/ch07-branch.xml:142
dongsheng@627 8517 msgid "Handling tag conflicts during a merge"
dongsheng@635 8518 msgstr "在合并期间处理标签冲突"
dongsheng@627 8519
dongsheng@627 8520 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8521 #: ../en/ch07-branch.xml:144
dongsheng@627 8522 msgid ""
dongsheng@627 8523 "You won't often need to care about the <filename role=\"special\">.hgtags</"
dongsheng@627 8524 "filename> file, but it sometimes makes its presence known during a merge. "
dongsheng@627 8525 "The format of the file is simple: it consists of a series of lines. Each "
dongsheng@627 8526 "line starts with a changeset hash, followed by a space, followed by the name "
dongsheng@627 8527 "of a tag."
dongsheng@627 8528 msgstr ""
dongsheng@627 8529
dongsheng@627 8530 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8531 #: ../en/ch07-branch.xml:151
dongsheng@627 8532 msgid ""
dongsheng@627 8533 "If you're resolving a conflict in the <filename role=\"special\">.hgtags</"
dongsheng@627 8534 "filename> file during a merge, there's one twist to modifying the <filename "
dongsheng@627 8535 "role=\"special\">.hgtags</filename> file: when Mercurial is parsing the tags "
dongsheng@627 8536 "in a repository, it <emphasis>never</emphasis> reads the working copy of the "
dongsheng@627 8537 "<filename role=\"special\">.hgtags</filename> file. Instead, it reads the "
dongsheng@627 8538 "<emphasis>most recently committed</emphasis> revision of the file."
dongsheng@627 8539 msgstr ""
dongsheng@627 8540
dongsheng@627 8541 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8542 #: ../en/ch07-branch.xml:161
dongsheng@627 8543 msgid ""
dongsheng@627 8544 "An unfortunate consequence of this design is that you can't actually verify "
dongsheng@627 8545 "that your merged <filename role=\"special\">.hgtags</filename> file is "
dongsheng@627 8546 "correct until <emphasis>after</emphasis> you've committed a change. So if "
dongsheng@627 8547 "you find yourself resolving a conflict on <filename role=\"special\">.hgtags</"
dongsheng@627 8548 "filename> during a merge, be sure to run <command role=\"hg-cmd\">hg tags</"
dongsheng@627 8549 "command> after you commit. If it finds an error in the <filename role="
dongsheng@627 8550 "\"special\">.hgtags</filename> file, it will report the location of the "
dongsheng@627 8551 "error, which you can then fix and commit. You should then run <command role="
dongsheng@627 8552 "\"hg-cmd\">hg tags</command> again, just to be sure that your fix is correct."
dongsheng@627 8553 msgstr ""
dongsheng@627 8554
dongsheng@627 8555 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8556 #: ../en/ch07-branch.xml:176
dongsheng@627 8557 msgid "Tags and cloning"
dongsheng@635 8558 msgstr "标签与克隆"
dongsheng@627 8559
dongsheng@627 8560 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8561 #: ../en/ch07-branch.xml:178
dongsheng@627 8562 msgid ""
dongsheng@627 8563 "You may have noticed that the <command role=\"hg-cmd\">hg clone</command> "
dongsheng@627 8564 "command has a <option role=\"hg-opt-clone\">-r</option> option that lets you "
dongsheng@627 8565 "clone an exact copy of the repository as of a particular changeset. The new "
dongsheng@627 8566 "clone will not contain any project history that comes after the revision you "
dongsheng@627 8567 "specified. This has an interaction with tags that can surprise the unwary."
dongsheng@627 8568 msgstr ""
dongsheng@627 8569
dongsheng@627 8570 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8571 #: ../en/ch07-branch.xml:186
dongsheng@627 8572 msgid ""
dongsheng@627 8573 "Recall that a tag is stored as a revision to the <filename role=\"special\">."
dongsheng@627 8574 "hgtags</filename> file, so that when you create a tag, the changeset in which "
dongsheng@627 8575 "it's recorded necessarily refers to an older changeset. When you run "
dongsheng@627 8576 "<command role=\"hg-cmd\">hg clone -r foo</command> to clone a repository as "
dongsheng@627 8577 "of tag <literal>foo</literal>, the new clone <emphasis>will not contain the "
dongsheng@627 8578 "history that created the tag</emphasis> that you used to clone the "
dongsheng@627 8579 "repository. The result is that you'll get exactly the right subset of the "
dongsheng@627 8580 "project's history in the new repository, but <emphasis>not</emphasis> the tag "
dongsheng@627 8581 "you might have expected."
dongsheng@627 8582 msgstr ""
dongsheng@627 8583
dongsheng@627 8584 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 8585 #: ../en/ch07-branch.xml:201
dongsheng@627 8586 msgid "When permanent tags are too much"
dongsheng@635 8587 msgstr "当永久标签太多的时候"
dongsheng@627 8588
dongsheng@627 8589 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8590 #: ../en/ch07-branch.xml:203
dongsheng@627 8591 msgid ""
dongsheng@627 8592 "Since Mercurial's tags are revision controlled and carried around with a "
dongsheng@627 8593 "project's history, everyone you work with will see the tags you create. But "
dongsheng@627 8594 "giving names to revisions has uses beyond simply noting that revision "
dongsheng@627 8595 "<literal>4237e45506ee</literal> is really <literal>v2.0.2</literal>. If "
dongsheng@627 8596 "you're trying to track down a subtle bug, you might want a tag to remind you "
dongsheng@627 8597 "of something like <quote>Anne saw the symptoms with this revision</quote>."
dongsheng@627 8598 msgstr ""
dongsheng@627 8599
dongsheng@627 8600 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 8601 #: ../en/ch07-branch.xml:213
dongsheng@627 8602 msgid ""
dongsheng@627 8603 "For cases like this, what you might want to use are <emphasis>local</"
dongsheng@627 8604 "emphasis> tags. You can create a local tag with the <option role=\"hg-opt-tag"
dongsheng@627 8605 "\">-l</option> option to the <command role=\"hg-cmd\">hg tag</command> "
dongsheng@627 8606 "command. This will store the tag in a file called <filename role=\"special"
dongsheng@627 8607 "\">.hg/localtags</filename>. Unlike <filename role=\"special\">.hgtags</"
dongsheng@627 8608 "filename>, <filename role=\"special\">.hg/localtags</filename> is not "
dongsheng@627 8609 "revision controlled. Any tags you create using <option role=\"hg-opt-tag\">-"
dongsheng@627 8610 "l</option> remain strictly local to the repository you're currently working "
dongsheng@627 8611 "in."
dongsheng@627 8612 msgstr ""
dongsheng@627 8613
dongsheng@627 8614 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8615 #: ../en/ch07-branch.xml:228
songdongsheng@667 8616 #, fuzzy
dongsheng@661 8617 msgid "The flow of changes—big picture vs. little"
dongsheng@661 8618 msgstr "修改流程—宏观与微观"
dongsheng@627 8619
dongsheng@627 8620 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8621 #: ../en/ch07-branch.xml:230
dongsheng@627 8622 msgid ""
dongsheng@627 8623 "To return to the outline I sketched at the beginning of a chapter, let's "
dongsheng@627 8624 "think about a project that has multiple concurrent pieces of work under "
dongsheng@627 8625 "development at once."
dongsheng@627 8626 msgstr ""
dongsheng@627 8627
dongsheng@627 8628 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8629 #: ../en/ch07-branch.xml:234
dongsheng@627 8630 msgid ""
dongsheng@627 8631 "There might be a push for a new <quote>main</quote> release; a new minor "
dongsheng@627 8632 "bugfix release to the last main release; and an unexpected <quote>hot fix</"
dongsheng@627 8633 "quote> to an old release that is now in maintenance mode."
dongsheng@627 8634 msgstr ""
dongsheng@627 8635
dongsheng@627 8636 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8637 #: ../en/ch07-branch.xml:239
dongsheng@627 8638 msgid ""
dongsheng@627 8639 "The usual way people refer to these different concurrent directions of "
dongsheng@627 8640 "development is as <quote>branches</quote>. However, we've already seen "
dongsheng@627 8641 "numerous times that Mercurial treats <emphasis>all of history</emphasis> as a "
dongsheng@627 8642 "series of branches and merges. Really, what we have here is two ideas that "
dongsheng@627 8643 "are peripherally related, but which happen to share a name."
dongsheng@627 8644 msgstr ""
dongsheng@627 8645
dongsheng@627 8646 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8647 #: ../en/ch07-branch.xml:246
dongsheng@627 8648 msgid ""
dongsheng@627 8649 "<quote>Big picture</quote> branches represent the sweep of a project's "
dongsheng@627 8650 "evolution; people give them names, and talk about them in conversation."
dongsheng@627 8651 msgstr ""
dongsheng@627 8652
dongsheng@627 8653 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 8654 #: ../en/ch07-branch.xml:250
dongsheng@627 8655 msgid ""
dongsheng@627 8656 "<quote>Little picture</quote> branches are artefacts of the day-to-day "
dongsheng@627 8657 "activity of developing and merging changes. They expose the narrative of how "
dongsheng@627 8658 "the code was developed."
dongsheng@627 8659 msgstr ""
dongsheng@627 8660
dongsheng@627 8661 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8662 #: ../en/ch07-branch.xml:258
dongsheng@627 8663 msgid "Managing big-picture branches in repositories"
dongsheng@635 8664 msgstr "在版本库中管理分支"
dongsheng@627 8665
dongsheng@627 8666 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8667 #: ../en/ch07-branch.xml:260
dongsheng@627 8668 msgid ""
dongsheng@627 8669 "The easiest way to isolate a <quote>big picture</quote> branch in Mercurial "
dongsheng@661 8670 "is in a dedicated repository. If you have an existing shared repository—"
dongsheng@661 8671 "let's call it <literal>myproject</literal>&emdash;that reaches a <quote>1.0</"
dongsheng@661 8672 "quote> milestone, you can start to prepare for future maintenance releases on "
dongsheng@661 8673 "top of version 1.0 by tagging the revision from which you prepared the 1.0 "
dongsheng@661 8674 "release."
dongsheng@627 8675 msgstr ""
dongsheng@627 8676
dongsheng@627 8677 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8678 #: ../en/ch07-branch.xml:270
dongsheng@627 8679 msgid ""
dongsheng@627 8680 "You can then clone a new shared <literal>myproject-1.0.1</literal> repository "
dongsheng@627 8681 "as of that tag."
dongsheng@627 8682 msgstr ""
dongsheng@627 8683
dongsheng@627 8684 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8685 #: ../en/ch07-branch.xml:276
dongsheng@627 8686 msgid ""
dongsheng@627 8687 "Afterwards, if someone needs to work on a bug fix that ought to go into an "
dongsheng@627 8688 "upcoming 1.0.1 minor release, they clone the <literal>myproject-1.0.1</"
dongsheng@627 8689 "literal> repository, make their changes, and push them back."
dongsheng@627 8690 msgstr ""
dongsheng@627 8691
dongsheng@627 8692 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8693 #: ../en/ch07-branch.xml:283
dongsheng@627 8694 msgid ""
dongsheng@627 8695 "Meanwhile, development for the next major release can continue, isolated and "
dongsheng@627 8696 "unabated, in the <literal>myproject</literal> repository."
dongsheng@627 8697 msgstr ""
dongsheng@627 8698
dongsheng@627 8699 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8700 #: ../en/ch07-branch.xml:291
dongsheng@627 8701 msgid "Don't repeat yourself: merging across branches"
dongsheng@635 8702 msgstr "不要重复劳动:在分支间合并"
dongsheng@627 8703
dongsheng@627 8704 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8705 #: ../en/ch07-branch.xml:293
dongsheng@627 8706 msgid ""
dongsheng@627 8707 "In many cases, if you have a bug to fix on a maintenance branch, the chances "
dongsheng@627 8708 "are good that the bug exists on your project's main branch (and possibly "
dongsheng@627 8709 "other maintenance branches, too). It's a rare developer who wants to fix the "
dongsheng@627 8710 "same bug multiple times, so let's look at a few ways that Mercurial can help "
dongsheng@627 8711 "you to manage these bugfixes without duplicating your work."
dongsheng@627 8712 msgstr ""
dongsheng@627 8713
dongsheng@627 8714 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8715 #: ../en/ch07-branch.xml:301
dongsheng@627 8716 msgid ""
dongsheng@627 8717 "In the simplest instance, all you need to do is pull changes from your "
dongsheng@627 8718 "maintenance branch into your local clone of the target branch."
dongsheng@627 8719 msgstr ""
dongsheng@627 8720
dongsheng@627 8721 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8722 #: ../en/ch07-branch.xml:307
dongsheng@627 8723 msgid ""
dongsheng@627 8724 "You'll then need to merge the heads of the two branches, and push back to the "
dongsheng@627 8725 "main branch."
dongsheng@627 8726 msgstr ""
dongsheng@627 8727
dongsheng@627 8728 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8729 #: ../en/ch07-branch.xml:314
dongsheng@627 8730 msgid "Naming branches within one repository"
dongsheng@635 8731 msgstr "版本库中的命名分支"
dongsheng@627 8732
dongsheng@627 8733 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8734 #: ../en/ch07-branch.xml:316
dongsheng@627 8735 msgid ""
dongsheng@627 8736 "In most instances, isolating branches in repositories is the right approach. "
dongsheng@627 8737 "Its simplicity makes it easy to understand; and so it's hard to make "
dongsheng@627 8738 "mistakes. There's a one-to-one relationship between branches you're working "
dongsheng@627 8739 "in and directories on your system. This lets you use normal (non-Mercurial-"
dongsheng@627 8740 "aware) tools to work on files within a branch/repository."
dongsheng@627 8741 msgstr ""
dongsheng@627 8742
dongsheng@627 8743 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8744 #: ../en/ch07-branch.xml:323
dongsheng@627 8745 msgid ""
dongsheng@627 8746 "If you're more in the <quote>power user</quote> category (<emphasis>and</"
dongsheng@627 8747 "emphasis> your collaborators are too), there is an alternative way of "
dongsheng@627 8748 "handling branches that you can consider. I've already mentioned the human-"
dongsheng@627 8749 "level distinction between <quote>small picture</quote> and <quote>big "
dongsheng@627 8750 "picture</quote> branches. While Mercurial works with multiple <quote>small "
dongsheng@627 8751 "picture</quote> branches in a repository all the time (for example after you "
dongsheng@627 8752 "pull changes in, but before you merge them), it can <emphasis>also</emphasis> "
dongsheng@627 8753 "work with multiple <quote>big picture</quote> branches."
dongsheng@627 8754 msgstr ""
dongsheng@627 8755
dongsheng@627 8756 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8757 #: ../en/ch07-branch.xml:334
dongsheng@627 8758 msgid ""
dongsheng@627 8759 "The key to working this way is that Mercurial lets you assign a persistent "
dongsheng@627 8760 "<emphasis>name</emphasis> to a branch. There always exists a branch named "
dongsheng@627 8761 "<literal>default</literal>. Even before you start naming branches yourself, "
dongsheng@627 8762 "you can find traces of the <literal>default</literal> branch if you look for "
dongsheng@627 8763 "them."
dongsheng@627 8764 msgstr ""
dongsheng@627 8765
dongsheng@627 8766 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8767 #: ../en/ch07-branch.xml:341
dongsheng@627 8768 msgid ""
dongsheng@627 8769 "As an example, when you run the <command role=\"hg-cmd\">hg commit</command> "
dongsheng@627 8770 "command, and it pops up your editor so that you can enter a commit message, "
dongsheng@627 8771 "look for a line that contains the text <quote><literal>HG: branch default</"
dongsheng@627 8772 "literal></quote> at the bottom. This is telling you that your commit will "
dongsheng@627 8773 "occur on the branch named <literal>default</literal>."
dongsheng@627 8774 msgstr ""
dongsheng@627 8775
dongsheng@627 8776 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8777 #: ../en/ch07-branch.xml:348
dongsheng@627 8778 msgid ""
dongsheng@627 8779 "To start working with named branches, use the <command role=\"hg-cmd\">hg "
dongsheng@627 8780 "branches</command> command. This command lists the named branches already "
dongsheng@627 8781 "present in your repository, telling you which changeset is the tip of each."
dongsheng@627 8782 msgstr ""
dongsheng@627 8783
dongsheng@627 8784 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8785 #: ../en/ch07-branch.xml:355
dongsheng@627 8786 msgid ""
dongsheng@627 8787 "Since you haven't created any named branches yet, the only one that exists is "
dongsheng@627 8788 "<literal>default</literal>."
dongsheng@627 8789 msgstr ""
dongsheng@627 8790
dongsheng@627 8791 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8792 #: ../en/ch07-branch.xml:358
dongsheng@627 8793 msgid ""
dongsheng@627 8794 "To find out what the <quote>current</quote> branch is, run the <command role="
dongsheng@627 8795 "\"hg-cmd\">hg branch</command> command, giving it no arguments. This tells "
dongsheng@627 8796 "you what branch the parent of the current changeset is on."
dongsheng@627 8797 msgstr ""
dongsheng@627 8798
dongsheng@627 8799 #
dongsheng@627 8800 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8801 #: ../en/ch07-branch.xml:365
dongsheng@627 8802 msgid ""
dongsheng@627 8803 "To create a new branch, run the <command role=\"hg-cmd\">hg branch</command> "
dongsheng@627 8804 "command again. This time, give it one argument: the name of the branch you "
dongsheng@627 8805 "want to create."
dongsheng@627 8806 msgstr ""
dongsheng@627 8807
dongsheng@627 8808 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8809 #: ../en/ch07-branch.xml:371
dongsheng@627 8810 msgid ""
dongsheng@627 8811 "After you've created a branch, you might wonder what effect the <command role="
dongsheng@627 8812 "\"hg-cmd\">hg branch</command> command has had. What do the <command role="
dongsheng@627 8813 "\"hg-cmd\">hg status</command> and <command role=\"hg-cmd\">hg tip</command> "
dongsheng@627 8814 "commands report?"
dongsheng@627 8815 msgstr ""
dongsheng@627 8816
dongsheng@627 8817 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8818 #: ../en/ch07-branch.xml:378
dongsheng@627 8819 msgid ""
dongsheng@627 8820 "Nothing has changed in the working directory, and there's been no new history "
dongsheng@627 8821 "created. As this suggests, running the <command role=\"hg-cmd\">hg branch</"
dongsheng@627 8822 "command> command has no permanent effect; it only tells Mercurial what branch "
dongsheng@627 8823 "name to use the <emphasis>next</emphasis> time you commit a changeset."
dongsheng@627 8824 msgstr ""
dongsheng@627 8825
dongsheng@627 8826 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8827 #: ../en/ch07-branch.xml:385
dongsheng@627 8828 msgid ""
dongsheng@627 8829 "When you commit a change, Mercurial records the name of the branch on which "
dongsheng@627 8830 "you committed. Once you've switched from the <literal>default</literal> "
dongsheng@627 8831 "branch to another and committed, you'll see the name of the new branch show "
dongsheng@627 8832 "up in the output of <command role=\"hg-cmd\">hg log</command>, <command role="
dongsheng@627 8833 "\"hg-cmd\">hg tip</command>, and other commands that display the same kind of "
dongsheng@627 8834 "output."
dongsheng@627 8835 msgstr ""
dongsheng@627 8836
dongsheng@627 8837 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8838 #: ../en/ch07-branch.xml:395
dongsheng@627 8839 msgid ""
dongsheng@627 8840 "The <command role=\"hg-cmd\">hg log</command>-like commands will print the "
dongsheng@627 8841 "branch name of every changeset that's not on the <literal>default</literal> "
dongsheng@627 8842 "branch. As a result, if you never use named branches, you'll never see this "
dongsheng@627 8843 "information."
dongsheng@627 8844 msgstr ""
dongsheng@627 8845
dongsheng@627 8846 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8847 #: ../en/ch07-branch.xml:400
dongsheng@627 8848 msgid ""
dongsheng@627 8849 "Once you've named a branch and committed a change with that name, every "
dongsheng@627 8850 "subsequent commit that descends from that change will inherit the same branch "
dongsheng@627 8851 "name. You can change the name of a branch at any time, using the <command "
dongsheng@627 8852 "role=\"hg-cmd\">hg branch</command> command."
dongsheng@627 8853 msgstr ""
dongsheng@627 8854
dongsheng@627 8855 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8856 #: ../en/ch07-branch.xml:408
dongsheng@627 8857 msgid ""
dongsheng@627 8858 "In practice, this is something you won't do very often, as branch names tend "
dongsheng@627 8859 "to have fairly long lifetimes. (This isn't a rule, just an observation.)"
dongsheng@627 8860 msgstr ""
dongsheng@627 8861
dongsheng@627 8862 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8863 #: ../en/ch07-branch.xml:414
dongsheng@627 8864 msgid "Dealing with multiple named branches in a repository"
dongsheng@635 8865 msgstr "在版本库中处理多个命名分支"
dongsheng@627 8866
dongsheng@627 8867 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8868 #: ../en/ch07-branch.xml:417
dongsheng@627 8869 msgid ""
dongsheng@627 8870 "If you have more than one named branch in a repository, Mercurial will "
dongsheng@627 8871 "remember the branch that your working directory on when you start a command "
dongsheng@627 8872 "like <command role=\"hg-cmd\">hg update</command> or <command role=\"hg-cmd"
dongsheng@627 8873 "\">hg pull -u</command>. It will update the working directory to the tip of "
dongsheng@627 8874 "this branch, no matter what the <quote>repo-wide</quote> tip is. To update "
dongsheng@627 8875 "to a revision that's on a different named branch, you may need to use the "
dongsheng@627 8876 "<option role=\"hg-opt-update\">-C</option> option to <command role=\"hg-cmd"
dongsheng@627 8877 "\">hg update</command>."
dongsheng@627 8878 msgstr ""
dongsheng@627 8879
dongsheng@627 8880 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8881 #: ../en/ch07-branch.xml:427
dongsheng@627 8882 msgid ""
dongsheng@627 8883 "This behaviour is a little subtle, so let's see it in action. First, let's "
dongsheng@627 8884 "remind ourselves what branch we're currently on, and what branches are in our "
dongsheng@627 8885 "repository."
dongsheng@627 8886 msgstr ""
dongsheng@627 8887
dongsheng@627 8888 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8889 #: ../en/ch07-branch.xml:433
dongsheng@627 8890 msgid ""
dongsheng@627 8891 "We're on the <literal>bar</literal> branch, but there also exists an older "
dongsheng@627 8892 "<command role=\"hg-cmd\">hg foo</command> branch."
dongsheng@627 8893 msgstr ""
dongsheng@627 8894
dongsheng@627 8895 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8896 #: ../en/ch07-branch.xml:437
dongsheng@627 8897 msgid ""
dongsheng@627 8898 "We can <command role=\"hg-cmd\">hg update</command> back and forth between "
dongsheng@627 8899 "the tips of the <literal>foo</literal> and <literal>bar</literal> branches "
dongsheng@627 8900 "without needing to use the <option role=\"hg-opt-update\">-C</option> option, "
dongsheng@627 8901 "because this only involves going backwards and forwards linearly through our "
dongsheng@627 8902 "change history."
dongsheng@627 8903 msgstr ""
dongsheng@627 8904
dongsheng@627 8905 #
dongsheng@627 8906 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8907 #: ../en/ch07-branch.xml:446
dongsheng@627 8908 msgid ""
dongsheng@627 8909 "If we go back to the <literal>foo</literal> branch and then run <command role="
dongsheng@627 8910 "\"hg-cmd\">hg update</command>, it will keep us on <literal>foo</literal>, "
dongsheng@627 8911 "not move us to the tip of <literal>bar</literal>."
dongsheng@627 8912 msgstr ""
dongsheng@627 8913
dongsheng@627 8914 #
dongsheng@627 8915 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8916 #: ../en/ch07-branch.xml:453
dongsheng@627 8917 msgid ""
dongsheng@627 8918 "Committing a new change on the <literal>foo</literal> branch introduces a new "
dongsheng@627 8919 "head."
dongsheng@627 8920 msgstr ""
dongsheng@627 8921
dongsheng@627 8922 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8923 #: ../en/ch07-branch.xml:460
dongsheng@627 8924 msgid "Branch names and merging"
dongsheng@635 8925 msgstr "分支名称与合并"
dongsheng@627 8926
dongsheng@627 8927 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8928 #: ../en/ch07-branch.xml:462
dongsheng@627 8929 msgid ""
dongsheng@627 8930 "As you've probably noticed, merges in Mercurial are not symmetrical. Let's "
dongsheng@627 8931 "say our repository has two heads, 17 and 23. If I <command role=\"hg-cmd"
dongsheng@627 8932 "\">hg update</command> to 17 and then <command role=\"hg-cmd\">hg merge</"
dongsheng@627 8933 "command> with 23, Mercurial records 17 as the first parent of the merge, and "
dongsheng@627 8934 "23 as the second. Whereas if I <command role=\"hg-cmd\">hg update</command> "
dongsheng@627 8935 "to 23 and then <command role=\"hg-cmd\">hg merge</command> with 17, it "
dongsheng@627 8936 "records 23 as the first parent, and 17 as the second."
dongsheng@627 8937 msgstr ""
dongsheng@627 8938
dongsheng@627 8939 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8940 #: ../en/ch07-branch.xml:472
dongsheng@627 8941 msgid ""
dongsheng@627 8942 "This affects Mercurial's choice of branch name when you merge. After a "
dongsheng@627 8943 "merge, Mercurial will retain the branch name of the first parent when you "
dongsheng@627 8944 "commit the result of the merge. If your first parent's branch name is "
dongsheng@627 8945 "<literal>foo</literal>, and you merge with <literal>bar</literal>, the branch "
dongsheng@627 8946 "name will still be <literal>foo</literal> after you merge."
dongsheng@627 8947 msgstr ""
dongsheng@627 8948
dongsheng@627 8949 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8950 #: ../en/ch07-branch.xml:479
dongsheng@627 8951 msgid ""
dongsheng@627 8952 "It's not unusual for a repository to contain multiple heads, each with the "
dongsheng@627 8953 "same branch name. Let's say I'm working on the <literal>foo</literal> "
dongsheng@627 8954 "branch, and so are you. We commit different changes; I pull your changes; I "
dongsheng@627 8955 "now have two heads, each claiming to be on the <literal>foo</literal> "
dongsheng@627 8956 "branch. The result of a merge will be a single head on the <literal>foo</"
dongsheng@627 8957 "literal> branch, as you might hope."
dongsheng@627 8958 msgstr ""
dongsheng@627 8959
dongsheng@627 8960 #
dongsheng@627 8961 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8962 #: ../en/ch07-branch.xml:487
dongsheng@627 8963 msgid ""
dongsheng@627 8964 "But if I'm working on the <literal>bar</literal> branch, and I merge work "
dongsheng@627 8965 "from the <literal>foo</literal> branch, the result will remain on the "
dongsheng@627 8966 "<literal>bar</literal> branch."
dongsheng@627 8967 msgstr ""
dongsheng@627 8968
dongsheng@627 8969 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8970 #: ../en/ch07-branch.xml:493
dongsheng@627 8971 msgid ""
dongsheng@627 8972 "To give a more concrete example, if I'm working on the <literal>bleeding-"
dongsheng@627 8973 "edge</literal> branch, and I want to bring in the latest fixes from the "
dongsheng@627 8974 "<literal>stable</literal> branch, Mercurial will choose the <quote>right</"
dongsheng@627 8975 "quote> (<literal>bleeding-edge</literal>) branch name when I pull and merge "
dongsheng@627 8976 "from <literal>stable</literal>."
dongsheng@627 8977 msgstr ""
dongsheng@627 8978
dongsheng@627 8979 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 8980 #: ../en/ch07-branch.xml:502
dongsheng@627 8981 msgid "Branch naming is generally useful"
dongsheng@635 8982 msgstr "分支名称通常都很有用"
dongsheng@627 8983
dongsheng@627 8984 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8985 #: ../en/ch07-branch.xml:504
dongsheng@627 8986 msgid ""
dongsheng@627 8987 "You shouldn't think of named branches as applicable only to situations where "
dongsheng@627 8988 "you have multiple long-lived branches cohabiting in a single repository. "
dongsheng@627 8989 "They're very useful even in the one-branch-per-repository case."
dongsheng@627 8990 msgstr ""
dongsheng@627 8991
dongsheng@627 8992 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 8993 #: ../en/ch07-branch.xml:509
dongsheng@627 8994 msgid ""
dongsheng@627 8995 "In the simplest case, giving a name to each branch gives you a permanent "
dongsheng@627 8996 "record of which branch a changeset originated on. This gives you more "
dongsheng@627 8997 "context when you're trying to follow the history of a long-lived branchy "
dongsheng@627 8998 "project."
dongsheng@627 8999 msgstr ""
dongsheng@627 9000
dongsheng@627 9001 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9002 #: ../en/ch07-branch.xml:514
dongsheng@627 9003 msgid ""
dongsheng@627 9004 "If you're working with shared repositories, you can set up a <literal role="
dongsheng@627 9005 "\"hook\">pretxnchangegroup</literal> hook on each that will block incoming "
dongsheng@627 9006 "changes that have the <quote>wrong</quote> branch name. This provides a "
dongsheng@627 9007 "simple, but effective, defence against people accidentally pushing changes "
dongsheng@627 9008 "from a <quote>bleeding edge</quote> branch to a <quote>stable</quote> "
dongsheng@627 9009 "branch. Such a hook might look like this inside the shared repo's <filename "
dongsheng@627 9010 "role=\"special\"> /.hgrc</filename>."
dongsheng@627 9011 msgstr ""
dongsheng@627 9012
dongsheng@627 9013 #. type: Content of: <book><chapter><title>
dongsheng@650 9014 #: ../en/ch08-undo.xml:5
dongsheng@627 9015 msgid "Finding and fixing mistakes"
dongsheng@627 9016 msgstr "查找和修改错误"
dongsheng@627 9017
dongsheng@627 9018 #. type: Content of: <book><chapter><para>
dongsheng@650 9019 #: ../en/ch08-undo.xml:7
dongsheng@627 9020 msgid ""
dongsheng@627 9021 "To err might be human, but to really handle the consequences well takes a top-"
dongsheng@627 9022 "notch revision control system. In this chapter, we'll discuss some of the "
dongsheng@627 9023 "techniques you can use when you find that a problem has crept into your "
dongsheng@627 9024 "project. Mercurial has some highly capable features that will help you to "
dongsheng@627 9025 "isolate the sources of problems, and to handle them appropriately."
dongsheng@627 9026 msgstr ""
dongsheng@627 9027
dongsheng@627 9028 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 9029 #: ../en/ch08-undo.xml:15
dongsheng@627 9030 msgid "Erasing local history"
dongsheng@635 9031 msgstr "销毁本地历史"
dongsheng@627 9032
dongsheng@627 9033 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9034 #: ../en/ch08-undo.xml:18
dongsheng@627 9035 msgid "The accidental commit"
dongsheng@635 9036 msgstr "意外的提交"
dongsheng@627 9037
dongsheng@627 9038 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9039 #: ../en/ch08-undo.xml:20
dongsheng@627 9040 msgid ""
dongsheng@627 9041 "I have the occasional but persistent problem of typing rather more quickly "
dongsheng@627 9042 "than I can think, which sometimes results in me committing a changeset that "
dongsheng@627 9043 "is either incomplete or plain wrong. In my case, the usual kind of "
dongsheng@627 9044 "incomplete changeset is one in which I've created a new source file, but "
dongsheng@627 9045 "forgotten to <command role=\"hg-cmd\">hg add</command> it. A <quote>plain "
dongsheng@627 9046 "wrong</quote> changeset is not as common, but no less annoying."
dongsheng@627 9047 msgstr ""
dongsheng@627 9048
dongsheng@627 9049 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9050 #: ../en/ch08-undo.xml:31
dongsheng@627 9051 msgid "Rolling back a transaction"
dongsheng@635 9052 msgstr "回滚一个事务"
dongsheng@627 9053
dongsheng@627 9054 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9055 #: ../en/ch08-undo.xml:33
dongsheng@627 9056 msgid ""
songdongsheng@658 9057 "In <xref linkend=\"sec:concepts:txn\"/>, I mentioned that Mercurial treats "
songdongsheng@658 9058 "each modification of a repository as a <emphasis>transaction</emphasis>. "
songdongsheng@658 9059 "Every time you commit a changeset or pull changes from another repository, "
songdongsheng@658 9060 "Mercurial remembers what you did. You can undo, or <emphasis>roll back</"
songdongsheng@658 9061 "emphasis>, exactly one of these actions using the <command role=\"hg-cmd\">hg "
songdongsheng@658 9062 "rollback</command> command. (See <xref linkend=\"sec:undo:rollback-after-push"
songdongsheng@658 9063 "\"/> for an important caveat about the use of this command.)"
dongsheng@627 9064 msgstr ""
dongsheng@627 9065
dongsheng@627 9066 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9067 #: ../en/ch08-undo.xml:43
dongsheng@627 9068 msgid ""
dongsheng@627 9069 "Here's a mistake that I often find myself making: committing a change in "
dongsheng@627 9070 "which I've created a new file, but forgotten to <command role=\"hg-cmd\">hg "
dongsheng@627 9071 "add</command> it."
dongsheng@627 9072 msgstr ""
dongsheng@627 9073
dongsheng@627 9074 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9075 #: ../en/ch08-undo.xml:50
dongsheng@627 9076 msgid ""
dongsheng@627 9077 "Looking at the output of <command role=\"hg-cmd\">hg status</command> after "
dongsheng@627 9078 "the commit immediately confirms the error."
dongsheng@627 9079 msgstr ""
dongsheng@627 9080
dongsheng@627 9081 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9082 #: ../en/ch08-undo.xml:56
dongsheng@627 9083 msgid ""
dongsheng@627 9084 "The commit captured the changes to the file <filename>a</filename>, but not "
dongsheng@627 9085 "the new file <filename>b</filename>. If I were to push this changeset to a "
dongsheng@627 9086 "repository that I shared with a colleague, the chances are high that "
dongsheng@627 9087 "something in <filename>a</filename> would refer to <filename>b</filename>, "
dongsheng@627 9088 "which would not be present in their repository when they pulled my changes. "
dongsheng@627 9089 "I would thus become the object of some indignation."
dongsheng@627 9090 msgstr ""
dongsheng@627 9091
dongsheng@627 9092 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9093 #: ../en/ch08-undo.xml:65
dongsheng@627 9094 msgid ""
dongsheng@661 9095 "However, luck is with me—I've caught my error before I pushed the changeset. "
dongsheng@661 9096 "I use the <command role=\"hg-cmd\">hg rollback</command> command, and "
dongsheng@661 9097 "Mercurial makes that last changeset vanish."
dongsheng@627 9098 msgstr ""
dongsheng@627 9099
dongsheng@627 9100 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9101 #: ../en/ch08-undo.xml:72
dongsheng@627 9102 msgid ""
dongsheng@627 9103 "Notice that the changeset is no longer present in the repository's history, "
dongsheng@627 9104 "and the working directory once again thinks that the file <filename>a</"
dongsheng@627 9105 "filename> is modified. The commit and rollback have left the working "
dongsheng@627 9106 "directory exactly as it was prior to the commit; the changeset has been "
dongsheng@627 9107 "completely erased. I can now safely <command role=\"hg-cmd\">hg add</"
dongsheng@627 9108 "command> the file <filename>b</filename>, and rerun my commit."
dongsheng@627 9109 msgstr ""
dongsheng@627 9110
dongsheng@627 9111 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9112 #: ../en/ch08-undo.xml:85
dongsheng@627 9113 msgid "The erroneous pull"
dongsheng@635 9114 msgstr "错误的抓取"
dongsheng@627 9115
dongsheng@627 9116 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9117 #: ../en/ch08-undo.xml:87
dongsheng@627 9118 msgid ""
dongsheng@627 9119 "It's common practice with Mercurial to maintain separate development branches "
dongsheng@627 9120 "of a project in different repositories. Your development team might have one "
dongsheng@627 9121 "shared repository for your project's <quote>0.9</quote> release, and another, "
dongsheng@627 9122 "containing different changes, for the <quote>1.0</quote> release."
dongsheng@627 9123 msgstr ""
dongsheng@627 9124
dongsheng@627 9125 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9126 #: ../en/ch08-undo.xml:94
dongsheng@627 9127 msgid ""
dongsheng@627 9128 "Given this, you can imagine that the consequences could be messy if you had a "
dongsheng@627 9129 "local <quote>0.9</quote> repository, and accidentally pulled changes from the "
dongsheng@627 9130 "shared <quote>1.0</quote> repository into it. At worst, you could be paying "
dongsheng@627 9131 "insufficient attention, and push those changes into the shared <quote>0.9</"
dongsheng@627 9132 "quote> tree, confusing your entire team (but don't worry, we'll return to "
dongsheng@627 9133 "this horror scenario later). However, it's more likely that you'll notice "
dongsheng@627 9134 "immediately, because Mercurial will display the URL it's pulling from, or you "
dongsheng@627 9135 "will see it pull a suspiciously large number of changes into the repository."
dongsheng@627 9136 msgstr ""
dongsheng@627 9137
dongsheng@627 9138 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9139 #: ../en/ch08-undo.xml:106
dongsheng@627 9140 msgid ""
dongsheng@627 9141 "The <command role=\"hg-cmd\">hg rollback</command> command will work nicely "
dongsheng@627 9142 "to expunge all of the changesets that you just pulled. Mercurial groups all "
dongsheng@627 9143 "changes from one <command role=\"hg-cmd\">hg pull</command> into a single "
dongsheng@627 9144 "transaction, so one <command role=\"hg-cmd\">hg rollback</command> is all you "
dongsheng@627 9145 "need to undo this mistake."
dongsheng@627 9146 msgstr ""
dongsheng@627 9147
dongsheng@627 9148 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9149 #: ../en/ch08-undo.xml:115
dongsheng@627 9150 msgid "Rolling back is useless once you've pushed"
dongsheng@635 9151 msgstr "当完成推送后,回滚是无效的"
dongsheng@627 9152
dongsheng@627 9153 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9154 #: ../en/ch08-undo.xml:117
dongsheng@627 9155 msgid ""
dongsheng@627 9156 "The value of the <command role=\"hg-cmd\">hg rollback</command> command drops "
dongsheng@627 9157 "to zero once you've pushed your changes to another repository. Rolling back "
dongsheng@627 9158 "a change makes it disappear entirely, but <emphasis>only</emphasis> in the "
dongsheng@627 9159 "repository in which you perform the <command role=\"hg-cmd\">hg rollback</"
dongsheng@627 9160 "command>. Because a rollback eliminates history, there's no way for the "
dongsheng@627 9161 "disappearance of a change to propagate between repositories."
dongsheng@627 9162 msgstr ""
dongsheng@627 9163
dongsheng@627 9164 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9165 #: ../en/ch08-undo.xml:126
dongsheng@627 9166 msgid ""
dongsheng@661 9167 "If you've pushed a change to another repository—particularly if it's a shared "
dongsheng@661 9168 "repository—it has essentially <quote>escaped into the wild,</quote> and "
dongsheng@661 9169 "you'll have to recover from your mistake in a different way. What will "
dongsheng@661 9170 "happen if you push a changeset somewhere, then roll it back, then pull from "
dongsheng@661 9171 "the repository you pushed to, is that the changeset will reappear in your "
dongsheng@661 9172 "repository."
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:135
dongsheng@627 9177 msgid ""
dongsheng@627 9178 "(If you absolutely know for sure that the change you want to roll back is the "
dongsheng@627 9179 "most recent change in the repository that you pushed to, <emphasis>and</"
dongsheng@627 9180 "emphasis> you know that nobody else could have pulled it from that "
dongsheng@627 9181 "repository, you can roll back the changeset there, too, but you really should "
dongsheng@627 9182 "really not rely on this working reliably. If you do this, sooner or later a "
dongsheng@627 9183 "change really will make it into a repository that you don't directly control "
dongsheng@627 9184 "(or have forgotten about), and come back to bite you.)"
dongsheng@627 9185 msgstr ""
dongsheng@627 9186
dongsheng@627 9187 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9188 #: ../en/ch08-undo.xml:147
dongsheng@627 9189 msgid "You can only roll back once"
dongsheng@635 9190 msgstr "你只能回滚一次"
dongsheng@627 9191
dongsheng@627 9192 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9193 #: ../en/ch08-undo.xml:149
dongsheng@627 9194 msgid ""
dongsheng@627 9195 "Mercurial stores exactly one transaction in its transaction log; that "
dongsheng@627 9196 "transaction is the most recent one that occurred in the repository. This "
dongsheng@627 9197 "means that you can only roll back one transaction. If you expect to be able "
dongsheng@627 9198 "to roll back one transaction, then its predecessor, this is not the behaviour "
dongsheng@627 9199 "you will get."
dongsheng@627 9200 msgstr ""
dongsheng@627 9201
dongsheng@627 9202 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9203 #: ../en/ch08-undo.xml:158
dongsheng@627 9204 msgid ""
dongsheng@627 9205 "Once you've rolled back one transaction in a repository, you can't roll back "
dongsheng@627 9206 "again in that repository until you perform another commit or pull."
dongsheng@627 9207 msgstr ""
dongsheng@627 9208
dongsheng@627 9209 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 9210 #: ../en/ch08-undo.xml:165
dongsheng@627 9211 msgid "Reverting the mistaken change"
dongsheng@635 9212 msgstr "撤销错误的修改"
dongsheng@627 9213
dongsheng@627 9214 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9215 #: ../en/ch08-undo.xml:167
dongsheng@627 9216 msgid ""
dongsheng@627 9217 "If you make a modification to a file, and decide that you really didn't want "
dongsheng@627 9218 "to change the file at all, and you haven't yet committed your changes, the "
dongsheng@627 9219 "<command role=\"hg-cmd\">hg revert</command> command is the one you'll need. "
dongsheng@627 9220 "It looks at the changeset that's the parent of the working directory, and "
dongsheng@627 9221 "restores the contents of the file to their state as of that changeset. "
dongsheng@627 9222 "(That's a long-winded way of saying that, in the normal case, it undoes your "
dongsheng@627 9223 "modifications.)"
dongsheng@627 9224 msgstr ""
dongsheng@627 9225
dongsheng@627 9226 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9227 #: ../en/ch08-undo.xml:176
dongsheng@627 9228 msgid ""
dongsheng@627 9229 "Let's illustrate how the <command role=\"hg-cmd\">hg revert</command> command "
dongsheng@627 9230 "works with yet another small example. We'll begin by modifying a file that "
dongsheng@627 9231 "Mercurial is already tracking."
dongsheng@627 9232 msgstr ""
dongsheng@627 9233
dongsheng@627 9234 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9235 #: ../en/ch08-undo.xml:183
dongsheng@627 9236 msgid ""
dongsheng@627 9237 "If we don't want that change, we can simply <command role=\"hg-cmd\">hg "
dongsheng@627 9238 "revert</command> the file."
dongsheng@627 9239 msgstr ""
dongsheng@627 9240
dongsheng@627 9241 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9242 #: ../en/ch08-undo.xml:189
dongsheng@627 9243 msgid ""
dongsheng@627 9244 "The <command role=\"hg-cmd\">hg revert</command> command provides us with an "
dongsheng@627 9245 "extra degree of safety by saving our modified file with a <filename>.orig</"
dongsheng@627 9246 "filename> extension."
dongsheng@627 9247 msgstr ""
dongsheng@627 9248
dongsheng@627 9249 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9250 #: ../en/ch08-undo.xml:196
dongsheng@627 9251 msgid ""
dongsheng@627 9252 "Here is a summary of the cases that the <command role=\"hg-cmd\">hg revert</"
dongsheng@627 9253 "command> command can deal with. We will describe each of these in more "
dongsheng@627 9254 "detail in the section that follows."
dongsheng@627 9255 msgstr ""
dongsheng@627 9256
dongsheng@627 9257 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 9258 #: ../en/ch08-undo.xml:201
dongsheng@627 9259 msgid "If you modify a file, it will restore the file to its unmodified state."
dongsheng@627 9260 msgstr ""
dongsheng@627 9261
dongsheng@627 9262 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 9263 #: ../en/ch08-undo.xml:204
dongsheng@627 9264 msgid ""
dongsheng@627 9265 "If you <command role=\"hg-cmd\">hg add</command> a file, it will undo the "
dongsheng@627 9266 "<quote>added</quote> state of the file, but leave the file itself untouched."
dongsheng@627 9267 msgstr ""
dongsheng@627 9268
dongsheng@627 9269 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 9270 #: ../en/ch08-undo.xml:208
dongsheng@627 9271 msgid ""
dongsheng@627 9272 "If you delete a file without telling Mercurial, it will restore the file to "
dongsheng@627 9273 "its unmodified contents."
dongsheng@627 9274 msgstr ""
dongsheng@627 9275
dongsheng@627 9276 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 9277 #: ../en/ch08-undo.xml:211
dongsheng@627 9278 msgid ""
dongsheng@627 9279 "If you use the <command role=\"hg-cmd\">hg remove</command> command to remove "
dongsheng@627 9280 "a file, it will undo the <quote>removed</quote> state of the file, and "
dongsheng@627 9281 "restore the file to its unmodified contents."
dongsheng@627 9282 msgstr ""
dongsheng@627 9283
dongsheng@627 9284 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9285 #: ../en/ch08-undo.xml:218
dongsheng@627 9286 msgid "File management errors"
dongsheng@635 9287 msgstr "文件管理错误"
dongsheng@627 9288
dongsheng@627 9289 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9290 #: ../en/ch08-undo.xml:220
dongsheng@627 9291 msgid ""
dongsheng@627 9292 "The <command role=\"hg-cmd\">hg revert</command> command is useful for more "
dongsheng@627 9293 "than just modified files. It lets you reverse the results of all of "
dongsheng@661 9294 "Mercurial's file management commands—<command role=\"hg-cmd\">hg add</"
dongsheng@627 9295 "command>, <command role=\"hg-cmd\">hg remove</command>, and so on."
dongsheng@627 9296 msgstr ""
dongsheng@627 9297
dongsheng@627 9298 #
dongsheng@627 9299 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9300 #: ../en/ch08-undo.xml:226
dongsheng@627 9301 msgid ""
dongsheng@627 9302 "If you <command role=\"hg-cmd\">hg add</command> a file, then decide that in "
dongsheng@627 9303 "fact you don't want Mercurial to track it, use <command role=\"hg-cmd\">hg "
dongsheng@627 9304 "revert</command> to undo the add. Don't worry; Mercurial will not modify the "
dongsheng@627 9305 "file in any way. It will just <quote>unmark</quote> the file."
dongsheng@627 9306 msgstr ""
dongsheng@627 9307
dongsheng@627 9308 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9309 #: ../en/ch08-undo.xml:234
dongsheng@627 9310 msgid ""
dongsheng@627 9311 "Similarly, if you ask Mercurial to <command role=\"hg-cmd\">hg remove</"
dongsheng@627 9312 "command> a file, you can use <command role=\"hg-cmd\">hg revert</command> to "
dongsheng@627 9313 "restore it to the contents it had as of the parent of the working directory. "
dongsheng@627 9314 "&interaction.daily.revert.remove; This works just as well for a file that you "
dongsheng@627 9315 "deleted by hand, without telling Mercurial (recall that in Mercurial "
dongsheng@627 9316 "terminology, this kind of file is called <quote>missing</quote>)."
dongsheng@627 9317 msgstr ""
dongsheng@627 9318
dongsheng@627 9319 #
dongsheng@627 9320 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9321 #: ../en/ch08-undo.xml:245
dongsheng@627 9322 msgid ""
dongsheng@627 9323 "If you revert a <command role=\"hg-cmd\">hg copy</command>, the copied-to "
dongsheng@627 9324 "file remains in your working directory afterwards, untracked. Since a copy "
dongsheng@627 9325 "doesn't affect the copied-from file in any way, Mercurial doesn't do anything "
dongsheng@627 9326 "with the copied-from file."
dongsheng@627 9327 msgstr ""
dongsheng@627 9328
dongsheng@627 9329 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 9330 #: ../en/ch08-undo.xml:254
dongsheng@627 9331 msgid "A slightly special case: reverting a rename"
dongsheng@635 9332 msgstr "一个稍微特别的案例:撤销改名"
dongsheng@627 9333
dongsheng@627 9334 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9335 #: ../en/ch08-undo.xml:256
dongsheng@627 9336 msgid ""
dongsheng@627 9337 "If you <command role=\"hg-cmd\">hg rename</command> a file, there is one "
dongsheng@627 9338 "small detail that you should remember. When you <command role=\"hg-cmd\">hg "
dongsheng@627 9339 "revert</command> a rename, it's not enough to provide the name of the renamed-"
dongsheng@627 9340 "to file, as you can see here."
dongsheng@627 9341 msgstr ""
dongsheng@627 9342
dongsheng@627 9343 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9344 #: ../en/ch08-undo.xml:264
dongsheng@627 9345 msgid ""
dongsheng@627 9346 "As you can see from the output of <command role=\"hg-cmd\">hg status</"
dongsheng@627 9347 "command>, the renamed-to file is no longer identified as added, but the "
dongsheng@627 9348 "renamed-<emphasis>from</emphasis> file is still removed! This is counter-"
dongsheng@627 9349 "intuitive (at least to me), but at least it's easy to deal with."
dongsheng@627 9350 msgstr ""
dongsheng@627 9351
dongsheng@627 9352 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9353 #: ../en/ch08-undo.xml:273
dongsheng@627 9354 msgid ""
dongsheng@627 9355 "So remember, to revert a <command role=\"hg-cmd\">hg rename</command>, you "
dongsheng@627 9356 "must provide <emphasis>both</emphasis> the source and destination names."
dongsheng@627 9357 msgstr ""
dongsheng@627 9358
dongsheng@627 9359 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9360 #: ../en/ch08-undo.xml:278
dongsheng@627 9361 msgid "% TODO: the output doesn't look like it will be removed!"
dongsheng@627 9362 msgstr ""
dongsheng@627 9363
dongsheng@627 9364 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9365 #: ../en/ch08-undo.xml:281
dongsheng@627 9366 msgid ""
dongsheng@627 9367 "(By the way, if you rename a file, then modify the renamed-to file, then "
dongsheng@627 9368 "revert both components of the rename, when Mercurial restores the file that "
dongsheng@627 9369 "was removed as part of the rename, it will be unmodified. If you need the "
dongsheng@627 9370 "modifications in the renamed-to file to show up in the renamed-from file, "
dongsheng@627 9371 "don't forget to copy them over.)"
dongsheng@627 9372 msgstr ""
dongsheng@627 9373
dongsheng@627 9374 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 9375 #: ../en/ch08-undo.xml:288
dongsheng@627 9376 msgid ""
dongsheng@627 9377 "These fiddly aspects of reverting a rename arguably constitute a small bug in "
dongsheng@627 9378 "Mercurial."
dongsheng@627 9379 msgstr ""
dongsheng@627 9380
dongsheng@627 9381 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 9382 #: ../en/ch08-undo.xml:295
dongsheng@627 9383 msgid "Dealing with committed changes"
dongsheng@635 9384 msgstr "处理已经提交的修改"
dongsheng@627 9385
dongsheng@627 9386 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9387 #: ../en/ch08-undo.xml:297
dongsheng@627 9388 msgid ""
dongsheng@627 9389 "Consider a case where you have committed a change $a$, and another change $b$ "
dongsheng@627 9390 "on top of it; you then realise that change $a$ was incorrect. Mercurial lets "
dongsheng@627 9391 "you <quote>back out</quote> an entire changeset automatically, and building "
dongsheng@627 9392 "blocks that let you reverse part of a changeset by hand."
dongsheng@627 9393 msgstr ""
dongsheng@627 9394
dongsheng@627 9395 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 9396 #: ../en/ch08-undo.xml:303
dongsheng@627 9397 msgid ""
dongsheng@627 9398 "Before you read this section, here's something to keep in mind: the <command "
dongsheng@627 9399 "role=\"hg-cmd\">hg backout</command> command undoes changes by "
dongsheng@627 9400 "<emphasis>adding</emphasis> history, not by modifying or erasing it. It's "
dongsheng@627 9401 "the right tool to use if you're fixing bugs, but not if you're trying to undo "
dongsheng@627 9402 "some change that has catastrophic consequences. To deal with those, see "
songdongsheng@658 9403 "<xref linkend=\"sec:undo:aaaiiieee\"/>."
dongsheng@627 9404 msgstr ""
dongsheng@627 9405
dongsheng@627 9406 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9407 #: ../en/ch08-undo.xml:312
dongsheng@627 9408 msgid "Backing out a changeset"
dongsheng@635 9409 msgstr "恢复一个修改集"
dongsheng@627 9410
dongsheng@627 9411 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9412 #: ../en/ch08-undo.xml:314
dongsheng@627 9413 msgid ""
dongsheng@627 9414 "The <command role=\"hg-cmd\">hg backout</command> command lets you "
dongsheng@627 9415 "<quote>undo</quote> the effects of an entire changeset in an automated "
dongsheng@627 9416 "fashion. Because Mercurial's history is immutable, this command "
dongsheng@627 9417 "<emphasis>does not</emphasis> get rid of the changeset you want to undo. "
dongsheng@627 9418 "Instead, it creates a new changeset that <emphasis>reverses</emphasis> the "
dongsheng@627 9419 "effect of the to-be-undone changeset."
dongsheng@627 9420 msgstr ""
dongsheng@627 9421
dongsheng@627 9422 #
dongsheng@627 9423 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9424 #: ../en/ch08-undo.xml:323
dongsheng@627 9425 msgid ""
dongsheng@627 9426 "The operation of the <command role=\"hg-cmd\">hg backout</command> command is "
dongsheng@627 9427 "a little intricate, so let's illustrate it with some examples. First, we'll "
dongsheng@627 9428 "create a repository with some simple changes."
dongsheng@627 9429 msgstr ""
dongsheng@627 9430
dongsheng@627 9431 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9432 #: ../en/ch08-undo.xml:330
dongsheng@627 9433 msgid ""
dongsheng@627 9434 "The <command role=\"hg-cmd\">hg backout</command> command takes a single "
dongsheng@627 9435 "changeset ID as its argument; this is the changeset to back out. Normally, "
dongsheng@627 9436 "<command role=\"hg-cmd\">hg backout</command> will drop you into a text "
dongsheng@627 9437 "editor to write a commit message, so you can record why you're backing the "
dongsheng@627 9438 "change out. In this example, we provide a commit message on the command line "
dongsheng@627 9439 "using the <option role=\"hg-opt-backout\">-m</option> option."
dongsheng@627 9440 msgstr ""
dongsheng@627 9441
dongsheng@627 9442 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 9443 #: ../en/ch08-undo.xml:341
dongsheng@627 9444 msgid "Backing out the tip changeset"
dongsheng@635 9445 msgstr "恢复顶点修改集"
dongsheng@627 9446
dongsheng@627 9447 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9448 #: ../en/ch08-undo.xml:343
dongsheng@627 9449 msgid "We're going to start by backing out the last changeset we committed."
dongsheng@627 9450 msgstr ""
dongsheng@627 9451
dongsheng@627 9452 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 9453 #: ../en/ch08-undo.xml:348
dongsheng@627 9454 msgid ""
dongsheng@627 9455 "You can see that the second line from <filename>myfile</filename> is no "
dongsheng@627 9456 "longer present. Taking a look at the output of <command role=\"hg-cmd\">hg "
dongsheng@627 9457 "log</command> gives us an idea of what the <command role=\"hg-cmd\">hg "
dongsheng@627 9458 "backout</command> command has done. &interaction.backout.simple.log; Notice "
dongsheng@627 9459 "that the new changeset that <command role=\"hg-cmd\">hg backout</command> has "
dongsheng@627 9460 "created is a child of the changeset we backed out. It's easier to see this "
songdongsheng@658 9461 "in <xref linkend=\"fig:undo:backout\"/>, which presents a graphical view of "
songdongsheng@658 9462 "the change history. As you can see, the history is nice and linear."
songdongsheng@658 9463 msgstr ""
songdongsheng@658 9464
songdongsheng@658 9465 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 9466 #: ../en/ch08-undo.xml:361 ../en/ch08-undo.xml:473
dongsheng@627 9467 msgid ""
dongsheng@627 9468 "Backing out a change using the <command role=\"hg-cmd\">hg backout</command> "
dongsheng@627 9469 "command"
dongsheng@660 9470 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 恢复一个修改"
dongsheng@627 9471
songdongsheng@658 9472 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 9473 #: ../en/ch08-undo.xml:364
songdongsheng@658 9474 msgid "<imageobject><imagedata fileref=\"figs/undo-simple.png\"/></imageobject>"
songdongsheng@658 9475 msgstr ""
songdongsheng@658 9476
dongsheng@627 9477 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 9478 #: ../en/ch08-undo.xml:371
dongsheng@627 9479 msgid "Backing out a non-tip change"
dongsheng@635 9480 msgstr "恢复非顶点的修改"
dongsheng@627 9481
dongsheng@627 9482 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9483 #: ../en/ch08-undo.xml:373
dongsheng@627 9484 msgid ""
dongsheng@627 9485 "If you want to back out a change other than the last one you committed, pass "
dongsheng@627 9486 "the <option role=\"hg-opt-backout\">--merge</option> option to the <command "
dongsheng@627 9487 "role=\"hg-cmd\">hg backout</command> command."
dongsheng@627 9488 msgstr ""
dongsheng@627 9489
dongsheng@627 9490 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9491 #: ../en/ch08-undo.xml:380
dongsheng@627 9492 msgid ""
dongsheng@627 9493 "This makes backing out any changeset a <quote>one-shot</quote> operation "
dongsheng@627 9494 "that's usually simple and fast."
dongsheng@627 9495 msgstr ""
dongsheng@627 9496
dongsheng@627 9497 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9498 #: ../en/ch08-undo.xml:386
dongsheng@627 9499 msgid ""
dongsheng@627 9500 "If you take a look at the contents of <filename>myfile</filename> after the "
dongsheng@627 9501 "backout finishes, you'll see that the first and third changes are present, "
dongsheng@627 9502 "but not the second."
dongsheng@627 9503 msgstr ""
dongsheng@627 9504
dongsheng@627 9505 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9506 #: ../en/ch08-undo.xml:393
songdongsheng@658 9507 msgid ""
songdongsheng@658 9508 "As the graphical history in <xref linkend=\"fig:undo:backout-non-tip\"/> "
songdongsheng@658 9509 "illustrates, Mercurial actually commits <emphasis>two</emphasis> changes in "
songdongsheng@658 9510 "this kind of situation (the box-shaped nodes are the ones that Mercurial "
songdongsheng@658 9511 "commits automatically). Before Mercurial begins the backout process, it "
songdongsheng@658 9512 "first remembers what the current parent of the working directory is. It then "
songdongsheng@658 9513 "backs out the target changeset, and commits that as a changeset. Finally, it "
songdongsheng@658 9514 "merges back to the previous parent of the working directory, and commits the "
songdongsheng@658 9515 "result of the merge."
songdongsheng@658 9516 msgstr ""
songdongsheng@658 9517
songdongsheng@658 9518 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9519 #: ../en/ch08-undo.xml:404
dongsheng@627 9520 msgid ""
dongsheng@627 9521 "% TODO: to me it looks like mercurial doesn't commit the second merge "
dongsheng@627 9522 "automatically!"
dongsheng@627 9523 msgstr ""
dongsheng@627 9524
songdongsheng@658 9525 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 9526 #: ../en/ch08-undo.xml:408
dongsheng@627 9527 msgid ""
dongsheng@627 9528 "Automated backout of a non-tip change using the <command role=\"hg-cmd\">hg "
dongsheng@627 9529 "backout</command> command"
dongsheng@660 9530 msgstr "使用 <command role=\"hg-cmd\">hg backout</command> 自动恢复非顶点的修改"
dongsheng@627 9531
songdongsheng@658 9532 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 9533 #: ../en/ch08-undo.xml:411
songdongsheng@658 9534 msgid ""
songdongsheng@658 9535 "<imageobject><imagedata fileref=\"figs/undo-non-tip.png\"/></imageobject>"
songdongsheng@658 9536 msgstr ""
songdongsheng@658 9537
songdongsheng@658 9538 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9539 #: ../en/ch08-undo.xml:416
dongsheng@627 9540 msgid ""
dongsheng@627 9541 "The result is that you end up <quote>back where you were</quote>, only with "
dongsheng@627 9542 "some extra history that undoes the effect of the changeset you wanted to back "
dongsheng@627 9543 "out."
dongsheng@627 9544 msgstr ""
dongsheng@627 9545
dongsheng@627 9546 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 9547 #: ../en/ch08-undo.xml:421
dongsheng@627 9548 msgid "Always use the <option role=\"hg-opt-backout\">--merge</option> option"
dongsheng@635 9549 msgstr "始终使用选项 <option role=\"hg-opt-backout\">--merge</option>"
dongsheng@627 9550
dongsheng@627 9551 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 9552 #: ../en/ch08-undo.xml:424
dongsheng@627 9553 msgid ""
dongsheng@627 9554 "In fact, since the <option role=\"hg-opt-backout\">--merge</option> option "
dongsheng@627 9555 "will do the <quote>right thing</quote> whether or not the changeset you're "
dongsheng@627 9556 "backing out is the tip (i.e. it won't try to merge if it's backing out the "
dongsheng@627 9557 "tip, since there's no need), you should <emphasis>always</emphasis> use this "
dongsheng@627 9558 "option when you run the <command role=\"hg-cmd\">hg backout</command> command."
dongsheng@627 9559 msgstr ""
dongsheng@627 9560
dongsheng@627 9561 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 9562 #: ../en/ch08-undo.xml:435
dongsheng@627 9563 msgid "Gaining more control of the backout process"
dongsheng@635 9564 msgstr "在恢复处理中获得更多控制"
dongsheng@627 9565
dongsheng@627 9566 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9567 #: ../en/ch08-undo.xml:437
dongsheng@627 9568 msgid ""
dongsheng@627 9569 "While I've recommended that you always use the <option role=\"hg-opt-backout"
dongsheng@627 9570 "\">--merge</option> option when backing out a change, the <command role=\"hg-"
dongsheng@627 9571 "cmd\">hg backout</command> command lets you decide how to merge a backout "
dongsheng@627 9572 "changeset. Taking control of the backout process by hand is something you "
dongsheng@627 9573 "will rarely need to do, but it can be useful to understand what the <command "
dongsheng@627 9574 "role=\"hg-cmd\">hg backout</command> command is doing for you automatically. "
dongsheng@627 9575 "To illustrate this, let's clone our first repository, but omit the backout "
dongsheng@627 9576 "change that it contains."
dongsheng@627 9577 msgstr ""
dongsheng@627 9578
dongsheng@627 9579 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9580 #: ../en/ch08-undo.xml:450
dongsheng@627 9581 msgid ""
dongsheng@627 9582 "As with our earlier example, We'll commit a third changeset, then back out "
dongsheng@627 9583 "its parent, and see what happens."
dongsheng@627 9584 msgstr ""
dongsheng@627 9585
dongsheng@627 9586 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9587 #: ../en/ch08-undo.xml:456
dongsheng@627 9588 msgid ""
dongsheng@627 9589 "Our new changeset is again a descendant of the changeset we backout out; it's "
dongsheng@627 9590 "thus a new head, <emphasis>not</emphasis> a descendant of the changeset that "
dongsheng@627 9591 "was the tip. The <command role=\"hg-cmd\">hg backout</command> command was "
dongsheng@627 9592 "quite explicit in telling us this."
dongsheng@627 9593 msgstr ""
dongsheng@627 9594
dongsheng@627 9595 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9596 #: ../en/ch08-undo.xml:464
dongsheng@627 9597 msgid ""
dongsheng@627 9598 "Again, it's easier to see what has happened by looking at a graph of the "
songdongsheng@658 9599 "revision history, in <xref linkend=\"fig:undo:backout-manual\"/>. This makes "
songdongsheng@658 9600 "it clear that when we use <command role=\"hg-cmd\">hg backout</command> to "
songdongsheng@658 9601 "back out a change other than the tip, Mercurial adds a new head to the "
songdongsheng@658 9602 "repository (the change it committed is box-shaped)."
songdongsheng@658 9603 msgstr ""
songdongsheng@658 9604
songdongsheng@658 9605 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 9606 #: ../en/ch08-undo.xml:476
songdongsheng@658 9607 msgid "<imageobject><imagedata fileref=\"figs/undo-manual.png\"/></imageobject>"
songdongsheng@658 9608 msgstr ""
songdongsheng@658 9609
songdongsheng@658 9610 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9611 #: ../en/ch08-undo.xml:481
dongsheng@627 9612 msgid ""
dongsheng@627 9613 "After the <command role=\"hg-cmd\">hg backout</command> command has "
dongsheng@627 9614 "completed, it leaves the new <quote>backout</quote> changeset as the parent "
dongsheng@627 9615 "of the working directory."
dongsheng@627 9616 msgstr ""
dongsheng@627 9617
dongsheng@627 9618 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9619 #: ../en/ch08-undo.xml:488
dongsheng@627 9620 msgid "Now we have two isolated sets of changes."
dongsheng@627 9621 msgstr ""
dongsheng@627 9622
dongsheng@627 9623 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9624 #: ../en/ch08-undo.xml:492
dongsheng@627 9625 msgid ""
dongsheng@627 9626 "Let's think about what we expect to see as the contents of <filename>myfile</"
dongsheng@627 9627 "filename> now. The first change should be present, because we've never "
dongsheng@627 9628 "backed it out. The second change should be missing, as that's the change we "
dongsheng@627 9629 "backed out. Since the history graph shows the third change as a separate "
dongsheng@627 9630 "head, we <emphasis>don't</emphasis> expect to see the third change present in "
dongsheng@627 9631 "<filename>myfile</filename>."
dongsheng@627 9632 msgstr ""
dongsheng@627 9633
dongsheng@627 9634 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9635 #: ../en/ch08-undo.xml:502
dongsheng@627 9636 msgid ""
dongsheng@627 9637 "To get the third change back into the file, we just do a normal merge of our "
dongsheng@627 9638 "two heads."
dongsheng@627 9639 msgstr ""
dongsheng@627 9640
dongsheng@627 9641 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9642 #: ../en/ch08-undo.xml:507
songdongsheng@658 9643 msgid ""
songdongsheng@658 9644 "Afterwards, the graphical history of our repository looks like <xref linkend="
songdongsheng@658 9645 "\"fig:undo:backout-manual-merge\"/>."
songdongsheng@658 9646 msgstr ""
songdongsheng@658 9647
songdongsheng@658 9648 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 9649 #: ../en/ch08-undo.xml:512
dongsheng@627 9650 msgid "Manually merging a backout change"
dongsheng@660 9651 msgstr "手工合并恢复修改"
dongsheng@627 9652
songdongsheng@658 9653 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
songdongsheng@658 9654 #: ../en/ch08-undo.xml:514
songdongsheng@658 9655 msgid ""
songdongsheng@658 9656 "<imageobject><imagedata fileref=\"figs/undo-manual-merge.png\"/></imageobject>"
songdongsheng@658 9657 msgstr ""
songdongsheng@658 9658
dongsheng@627 9659 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 9660 #: ../en/ch08-undo.xml:521
dongsheng@627 9661 msgid "Why <command role=\"hg-cmd\">hg backout</command> works as it does"
dongsheng@635 9662 msgstr "<command role=\"hg-cmd\">hg backout</command> 的内幕"
dongsheng@627 9663
dongsheng@627 9664 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9665 #: ../en/ch08-undo.xml:524
dongsheng@627 9666 msgid ""
dongsheng@627 9667 "Here's a brief description of how the <command role=\"hg-cmd\">hg backout</"
dongsheng@627 9668 "command> command works."
dongsheng@627 9669 msgstr ""
dongsheng@627 9670
dongsheng@627 9671 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9672 #: ../en/ch08-undo.xml:527
dongsheng@627 9673 msgid ""
dongsheng@627 9674 "It ensures that the working directory is <quote>clean</quote>, i.e. that the "
dongsheng@627 9675 "output of <command role=\"hg-cmd\">hg status</command> would be empty."
dongsheng@627 9676 msgstr ""
dongsheng@627 9677
dongsheng@627 9678 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9679 #: ../en/ch08-undo.xml:531
dongsheng@627 9680 msgid ""
dongsheng@627 9681 "It remembers the current parent of the working directory. Let's call this "
dongsheng@627 9682 "changeset <literal>orig</literal>"
dongsheng@627 9683 msgstr ""
dongsheng@627 9684
dongsheng@627 9685 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9686 #: ../en/ch08-undo.xml:535
dongsheng@627 9687 msgid ""
dongsheng@627 9688 "It does the equivalent of a <command role=\"hg-cmd\">hg update</command> to "
dongsheng@627 9689 "sync the working directory to the changeset you want to back out. Let's call "
dongsheng@627 9690 "this changeset <literal>backout</literal>"
dongsheng@627 9691 msgstr ""
dongsheng@627 9692
dongsheng@627 9693 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9694 #: ../en/ch08-undo.xml:540
dongsheng@627 9695 msgid ""
dongsheng@627 9696 "It finds the parent of that changeset. Let's call that changeset "
dongsheng@627 9697 "<literal>parent</literal>."
dongsheng@627 9698 msgstr ""
dongsheng@627 9699
dongsheng@627 9700 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9701 #: ../en/ch08-undo.xml:543
dongsheng@627 9702 msgid ""
dongsheng@627 9703 "For each file that the <literal>backout</literal> changeset affected, it does "
dongsheng@627 9704 "the equivalent of a <command role=\"hg-cmd\">hg revert -r parent</command> on "
dongsheng@627 9705 "that file, to restore it to the contents it had before that changeset was "
dongsheng@627 9706 "committed."
dongsheng@627 9707 msgstr ""
dongsheng@627 9708
dongsheng@627 9709 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9710 #: ../en/ch08-undo.xml:550
dongsheng@627 9711 msgid ""
dongsheng@627 9712 "It commits the result as a new changeset. This changeset has "
dongsheng@627 9713 "<literal>backout</literal> as its parent."
dongsheng@627 9714 msgstr ""
dongsheng@627 9715
dongsheng@627 9716 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 9717 #: ../en/ch08-undo.xml:554
dongsheng@627 9718 msgid ""
dongsheng@627 9719 "If you specify <option role=\"hg-opt-backout\">--merge</option> on the "
dongsheng@627 9720 "command line, it merges with <literal>orig</literal>, and commits the result "
dongsheng@627 9721 "of the merge."
dongsheng@627 9722 msgstr ""
dongsheng@627 9723
dongsheng@627 9724 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9725 #: ../en/ch08-undo.xml:560
dongsheng@627 9726 msgid ""
dongsheng@627 9727 "An alternative way to implement the <command role=\"hg-cmd\">hg backout</"
dongsheng@627 9728 "command> command would be to <command role=\"hg-cmd\">hg export</command> the "
dongsheng@627 9729 "to-be-backed-out changeset as a diff, then use the <option role=\"cmd-opt-"
dongsheng@627 9730 "patch\">--reverse</option> option to the <command>patch</command> command to "
dongsheng@627 9731 "reverse the effect of the change without fiddling with the working "
dongsheng@627 9732 "directory. This sounds much simpler, but it would not work nearly as well."
dongsheng@627 9733 msgstr ""
dongsheng@627 9734
dongsheng@627 9735 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9736 #: ../en/ch08-undo.xml:570
dongsheng@627 9737 msgid ""
dongsheng@627 9738 "The reason that <command role=\"hg-cmd\">hg backout</command> does an update, "
dongsheng@627 9739 "a commit, a merge, and another commit is to give the merge machinery the best "
dongsheng@627 9740 "chance to do a good job when dealing with all the changes <emphasis>between</"
dongsheng@627 9741 "emphasis> the change you're backing out and the current tip."
dongsheng@627 9742 msgstr ""
dongsheng@627 9743
dongsheng@627 9744 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9745 #: ../en/ch08-undo.xml:577
dongsheng@627 9746 msgid ""
dongsheng@627 9747 "If you're backing out a changeset that's 100 revisions back in your project's "
dongsheng@627 9748 "history, the chances that the <command>patch</command> command will be able "
dongsheng@627 9749 "to apply a reverse diff cleanly are not good, because intervening changes are "
dongsheng@627 9750 "likely to have <quote>broken the context</quote> that <command>patch</"
dongsheng@627 9751 "command> uses to determine whether it can apply a patch (if this sounds like "
songdongsheng@658 9752 "gibberish, see <xref linkend=\"sec:mq:patch\"/> for a discussion of the "
dongsheng@627 9753 "<command>patch</command> command). Also, Mercurial's merge machinery will "
dongsheng@627 9754 "handle files and directories being renamed, permission changes, and "
dongsheng@627 9755 "modifications to binary files, none of which <command>patch</command> can "
dongsheng@627 9756 "deal with."
dongsheng@627 9757 msgstr ""
dongsheng@627 9758
dongsheng@627 9759 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 9760 #: ../en/ch08-undo.xml:594
dongsheng@627 9761 msgid "Changes that should never have been"
dongsheng@635 9762 msgstr "不该发生的修改"
dongsheng@627 9763
dongsheng@627 9764 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9765 #: ../en/ch08-undo.xml:596
dongsheng@627 9766 msgid ""
dongsheng@627 9767 "Most of the time, the <command role=\"hg-cmd\">hg backout</command> command "
dongsheng@627 9768 "is exactly what you need if you want to undo the effects of a change. It "
dongsheng@627 9769 "leaves a permanent record of exactly what you did, both when committing the "
dongsheng@627 9770 "original changeset and when you cleaned up after it."
dongsheng@627 9771 msgstr ""
dongsheng@627 9772
dongsheng@627 9773 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9774 #: ../en/ch08-undo.xml:602
dongsheng@627 9775 msgid ""
dongsheng@627 9776 "On rare occasions, though, you may find that you've committed a change that "
dongsheng@627 9777 "really should not be present in the repository at all. For example, it would "
dongsheng@627 9778 "be very unusual, and usually considered a mistake, to commit a software "
dongsheng@627 9779 "project's object files as well as its source files. Object files have almost "
dongsheng@627 9780 "no intrinsic value, and they're <emphasis>big</emphasis>, so they increase "
dongsheng@627 9781 "the size of the repository and the amount of time it takes to clone or pull "
dongsheng@627 9782 "changes."
dongsheng@627 9783 msgstr ""
dongsheng@627 9784
dongsheng@627 9785 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9786 #: ../en/ch08-undo.xml:611
dongsheng@627 9787 msgid ""
dongsheng@627 9788 "Before I discuss the options that you have if you commit a <quote>brown paper "
dongsheng@627 9789 "bag</quote> change (the kind that's so bad that you want to pull a brown "
dongsheng@627 9790 "paper bag over your head), let me first discuss some approaches that probably "
dongsheng@627 9791 "won't work."
dongsheng@627 9792 msgstr ""
dongsheng@627 9793
dongsheng@627 9794 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9795 #: ../en/ch08-undo.xml:616
dongsheng@627 9796 msgid ""
dongsheng@661 9797 "Since Mercurial treats history as accumulative—every change builds on top of "
dongsheng@661 9798 "all changes that preceded it—you generally can't just make disastrous changes "
dongsheng@661 9799 "disappear. The one exception is when you've just committed a change, and it "
dongsheng@661 9800 "hasn't been pushed or pulled into another repository. That's when you can "
dongsheng@661 9801 "safely use the <command role=\"hg-cmd\">hg rollback</command> command, as I "
dongsheng@661 9802 "detailed in <xref linkend=\"sec:undo:rollback\"/>."
songdongsheng@658 9803 msgstr ""
songdongsheng@658 9804
songdongsheng@658 9805 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9806 #: ../en/ch08-undo.xml:625
dongsheng@627 9807 msgid ""
dongsheng@627 9808 "After you've pushed a bad change to another repository, you <emphasis>could</"
dongsheng@627 9809 "emphasis> still use <command role=\"hg-cmd\">hg rollback</command> to make "
dongsheng@627 9810 "your local copy of the change disappear, but it won't have the consequences "
dongsheng@627 9811 "you want. The change will still be present in the remote repository, so it "
dongsheng@627 9812 "will reappear in your local repository the next time you pull."
dongsheng@627 9813 msgstr ""
dongsheng@627 9814
dongsheng@627 9815 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9816 #: ../en/ch08-undo.xml:633
dongsheng@627 9817 msgid ""
dongsheng@627 9818 "If a situation like this arises, and you know which repositories your bad "
dongsheng@627 9819 "change has propagated into, you can <emphasis>try</emphasis> to get rid of "
dongsheng@627 9820 "the changeefrom <emphasis>every</emphasis> one of those repositories. This "
dongsheng@627 9821 "is, of course, not a satisfactory solution: if you miss even a single "
dongsheng@627 9822 "repository while you're expunging, the change is still <quote>in the wild</"
dongsheng@627 9823 "quote>, and could propagate further."
dongsheng@627 9824 msgstr ""
dongsheng@627 9825
dongsheng@627 9826 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9827 #: ../en/ch08-undo.xml:641
dongsheng@627 9828 msgid ""
dongsheng@627 9829 "If you've committed one or more changes <emphasis>after</emphasis> the change "
dongsheng@627 9830 "that you'd like to see disappear, your options are further reduced. Mercurial "
dongsheng@627 9831 "doesn't provide a way to <quote>punch a hole</quote> in history, leaving "
dongsheng@627 9832 "changesets intact."
dongsheng@627 9833 msgstr ""
dongsheng@627 9834
dongsheng@627 9835 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9836 #: ../en/ch08-undo.xml:647
dongsheng@627 9837 msgid ""
dongsheng@627 9838 "XXX This needs filling out. The <literal>hg-replay</literal> script in the "
dongsheng@627 9839 "<literal>examples</literal> directory works, but doesn't handle merge "
dongsheng@627 9840 "changesets. Kind of an important omission."
dongsheng@627 9841 msgstr ""
dongsheng@627 9842
dongsheng@627 9843 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 9844 #: ../en/ch08-undo.xml:653
dongsheng@627 9845 msgid "Protect yourself from <quote>escaped</quote> changes"
dongsheng@635 9846 msgstr "使用<quote>校验</quote>修改来保护你自己"
dongsheng@627 9847
dongsheng@627 9848 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9849 #: ../en/ch08-undo.xml:656
dongsheng@627 9850 msgid ""
dongsheng@627 9851 "If you've committed some changes to your local repository and they've been "
dongsheng@627 9852 "pushed or pulled somewhere else, this isn't necessarily a disaster. You can "
dongsheng@627 9853 "protect yourself ahead of time against some classes of bad changeset. This "
dongsheng@627 9854 "is particularly easy if your team usually pulls changes from a central "
dongsheng@627 9855 "repository."
dongsheng@627 9856 msgstr ""
dongsheng@627 9857
dongsheng@627 9858 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9859 #: ../en/ch08-undo.xml:663
dongsheng@627 9860 msgid ""
dongsheng@627 9861 "By configuring some hooks on that repository to validate incoming changesets "
songdongsheng@658 9862 "(see chapter <xref linkend=\"chap:hook\"/>), you can automatically prevent "
dongsheng@627 9863 "some kinds of bad changeset from being pushed to the central repository at "
dongsheng@627 9864 "all. With such a configuration in place, some kinds of bad changeset will "
dongsheng@627 9865 "naturally tend to <quote>die out</quote> because they can't propagate into "
dongsheng@627 9866 "the central repository. Better yet, this happens without any need for "
dongsheng@627 9867 "explicit intervention."
dongsheng@627 9868 msgstr ""
dongsheng@627 9869
dongsheng@627 9870 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 9871 #: ../en/ch08-undo.xml:673
dongsheng@627 9872 msgid ""
dongsheng@627 9873 "For instance, an incoming change hook that verifies that a changeset will "
dongsheng@627 9874 "actually compile can prevent people from inadvertantly <quote>breaking the "
dongsheng@627 9875 "build</quote>."
dongsheng@627 9876 msgstr ""
dongsheng@627 9877
dongsheng@627 9878 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 9879 #: ../en/ch08-undo.xml:680
dongsheng@627 9880 msgid "Finding the source of a bug"
dongsheng@635 9881 msgstr "查找问题的根源"
dongsheng@627 9882
dongsheng@627 9883 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9884 #: ../en/ch08-undo.xml:682
dongsheng@627 9885 msgid ""
dongsheng@627 9886 "While it's all very well to be able to back out a changeset that introduced a "
dongsheng@627 9887 "bug, this requires that you know which changeset to back out. Mercurial "
dongsheng@627 9888 "provides an invaluable command, called <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 9889 "command>, that helps you to automate this process and accomplish it very "
dongsheng@627 9890 "efficiently."
dongsheng@627 9891 msgstr ""
dongsheng@627 9892
dongsheng@627 9893 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9894 #: ../en/ch08-undo.xml:689
dongsheng@627 9895 msgid ""
dongsheng@627 9896 "The idea behind the <command role=\"hg-cmd\">hg bisect</command> command is "
dongsheng@627 9897 "that a changeset has introduced some change of behaviour that you can "
dongsheng@627 9898 "identify with a simple binary test. You don't know which piece of code "
dongsheng@627 9899 "introduced the change, but you know how to test for the presence of the bug. "
dongsheng@627 9900 "The <command role=\"hg-cmd\">hg bisect</command> command uses your test to "
dongsheng@627 9901 "direct its search for the changeset that introduced the code that caused the "
dongsheng@627 9902 "bug."
dongsheng@627 9903 msgstr ""
dongsheng@627 9904
dongsheng@627 9905 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9906 #: ../en/ch08-undo.xml:698
dongsheng@627 9907 msgid ""
dongsheng@627 9908 "Here are a few scenarios to help you understand how you might apply this "
dongsheng@627 9909 "command."
dongsheng@627 9910 msgstr ""
dongsheng@627 9911
dongsheng@627 9912 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 9913 #: ../en/ch08-undo.xml:701
dongsheng@627 9914 msgid ""
dongsheng@627 9915 "The most recent version of your software has a bug that you remember wasn't "
dongsheng@627 9916 "present a few weeks ago, but you don't know when it was introduced. Here, "
dongsheng@627 9917 "your binary test checks for the presence of that bug."
dongsheng@627 9918 msgstr ""
dongsheng@627 9919
dongsheng@627 9920 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 9921 #: ../en/ch08-undo.xml:706
dongsheng@627 9922 msgid ""
dongsheng@627 9923 "You fixed a bug in a rush, and now it's time to close the entry in your "
dongsheng@627 9924 "team's bug database. The bug database requires a changeset ID when you close "
dongsheng@627 9925 "an entry, but you don't remember which changeset you fixed the bug in. Once "
dongsheng@627 9926 "again, your binary test checks for the presence of the bug."
dongsheng@627 9927 msgstr ""
dongsheng@627 9928
dongsheng@627 9929 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 9930 #: ../en/ch08-undo.xml:713
dongsheng@627 9931 msgid ""
dongsheng@627 9932 "Your software works correctly, but runs 15% slower than the last time you "
dongsheng@627 9933 "measured it. You want to know which changeset introduced the performance "
dongsheng@627 9934 "regression. In this case, your binary test measures the performance of your "
dongsheng@627 9935 "software, to see whether it's <quote>fast</quote> or <quote>slow</quote>."
dongsheng@627 9936 msgstr ""
dongsheng@627 9937
dongsheng@627 9938 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 9939 #: ../en/ch08-undo.xml:720
dongsheng@627 9940 msgid ""
dongsheng@627 9941 "The sizes of the components of your project that you ship exploded recently, "
dongsheng@627 9942 "and you suspect that something changed in the way you build your project."
dongsheng@627 9943 msgstr ""
dongsheng@627 9944
dongsheng@627 9945 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9946 #: ../en/ch08-undo.xml:725
dongsheng@627 9947 msgid ""
dongsheng@627 9948 "From these examples, it should be clear that the <command role=\"hg-cmd\">hg "
dongsheng@627 9949 "bisect</command> command is not useful only for finding the sources of bugs. "
dongsheng@627 9950 "You can use it to find any <quote>emergent property</quote> of a repository "
dongsheng@627 9951 "(anything that you can't find from a simple text search of the files in the "
dongsheng@627 9952 "tree) for which you can write a binary test."
dongsheng@627 9953 msgstr ""
dongsheng@627 9954
dongsheng@627 9955 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9956 #: ../en/ch08-undo.xml:732
dongsheng@627 9957 msgid ""
dongsheng@627 9958 "We'll introduce a little bit of terminology here, just to make it clear which "
dongsheng@627 9959 "parts of the search process are your responsibility, and which are "
dongsheng@627 9960 "Mercurial's. A <emphasis>test</emphasis> is something that <emphasis>you</"
dongsheng@627 9961 "emphasis> run when <command role=\"hg-cmd\">hg bisect</command> chooses a "
dongsheng@627 9962 "changeset. A <emphasis>probe</emphasis> is what <command role=\"hg-cmd\">hg "
dongsheng@627 9963 "bisect</command> runs to tell whether a revision is good. Finally, we'll use "
dongsheng@627 9964 "the word <quote>bisect</quote>, as both a noun and a verb, to stand in for "
dongsheng@627 9965 "the phrase <quote>search using the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 9966 "command> command</quote>."
dongsheng@627 9967 msgstr ""
dongsheng@627 9968
dongsheng@627 9969 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9970 #: ../en/ch08-undo.xml:745
dongsheng@627 9971 msgid ""
dongsheng@627 9972 "One simple way to automate the searching process would be simply to probe "
dongsheng@627 9973 "every changeset. However, this scales poorly. If it took ten minutes to "
dongsheng@627 9974 "test a single changeset, and you had 10,000 changesets in your repository, "
dongsheng@627 9975 "the exhaustive approach would take on average 35 <emphasis>days</emphasis> to "
dongsheng@627 9976 "find the changeset that introduced a bug. Even if you knew that the bug was "
dongsheng@627 9977 "introduced by one of the last 500 changesets, and limited your search to "
dongsheng@627 9978 "those, you'd still be looking at over 40 hours to find the changeset that "
dongsheng@627 9979 "introduced your bug."
dongsheng@627 9980 msgstr ""
dongsheng@627 9981
dongsheng@627 9982 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9983 #: ../en/ch08-undo.xml:755
dongsheng@627 9984 msgid ""
dongsheng@627 9985 "What the <command role=\"hg-cmd\">hg bisect</command> command does is use its "
dongsheng@627 9986 "knowledge of the <quote>shape</quote> of your project's revision history to "
dongsheng@627 9987 "perform a search in time proportional to the <emphasis>logarithm</emphasis> "
dongsheng@627 9988 "of the number of changesets to check (the kind of search it performs is "
dongsheng@627 9989 "called a dichotomic search). With this approach, searching through 10,000 "
dongsheng@627 9990 "changesets will take less than three hours, even at ten minutes per test (the "
dongsheng@627 9991 "search will require about 14 tests). Limit your search to the last hundred "
dongsheng@627 9992 "changesets, and it will take only about an hour (roughly seven tests)."
dongsheng@627 9993 msgstr ""
dongsheng@627 9994
dongsheng@627 9995 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 9996 #: ../en/ch08-undo.xml:766
dongsheng@627 9997 msgid ""
dongsheng@627 9998 "The <command role=\"hg-cmd\">hg bisect</command> command is aware of the "
dongsheng@627 9999 "<quote>branchy</quote> nature of a Mercurial project's revision history, so "
dongsheng@627 10000 "it has no problems dealing with branches, merges, or multiple heads in a "
dongsheng@627 10001 "repository. It can prune entire branches of history with a single probe, "
dongsheng@627 10002 "which is how it operates so efficiently."
dongsheng@627 10003 msgstr ""
dongsheng@627 10004
dongsheng@627 10005 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10006 #: ../en/ch08-undo.xml:774
dongsheng@627 10007 msgid "Using the <command role=\"hg-cmd\">hg bisect</command> command"
dongsheng@635 10008 msgstr "使用命令 <command role=\"hg-cmd\">hg bisect</command>"
dongsheng@627 10009
dongsheng@627 10010 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10011 #: ../en/ch08-undo.xml:777
dongsheng@627 10012 msgid ""
dongsheng@627 10013 "Here's an example of <command role=\"hg-cmd\">hg bisect</command> in action."
dongsheng@627 10014 msgstr ""
dongsheng@627 10015
dongsheng@627 10016 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 10017 #: ../en/ch08-undo.xml:781
dongsheng@627 10018 msgid ""
dongsheng@627 10019 "In versions 0.9.5 and earlier of Mercurial, <command role=\"hg-cmd\">hg "
dongsheng@627 10020 "bisect</command> was not a core command: it was distributed with Mercurial as "
dongsheng@627 10021 "an extension. This section describes the built-in command, not the old "
dongsheng@627 10022 "extension."
dongsheng@627 10023 msgstr ""
dongsheng@627 10024
dongsheng@627 10025 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10026 #: ../en/ch08-undo.xml:788
dongsheng@627 10027 msgid ""
dongsheng@627 10028 "Now let's create a repository, so that we can try out the <command role=\"hg-"
dongsheng@627 10029 "cmd\">hg bisect</command> command in isolation."
dongsheng@627 10030 msgstr ""
dongsheng@627 10031
dongsheng@627 10032 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10033 #: ../en/ch08-undo.xml:794
dongsheng@627 10034 msgid ""
dongsheng@627 10035 "We'll simulate a project that has a bug in it in a simple-minded way: create "
dongsheng@627 10036 "trivial changes in a loop, and nominate one specific change that will have "
dongsheng@627 10037 "the <quote>bug</quote>. This loop creates 35 changesets, each adding a "
dongsheng@627 10038 "single file to the repository. We'll represent our <quote>bug</quote> with a "
dongsheng@627 10039 "file that contains the text <quote>i have a gub</quote>."
dongsheng@627 10040 msgstr ""
dongsheng@627 10041
dongsheng@627 10042 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10043 #: ../en/ch08-undo.xml:804
dongsheng@627 10044 msgid ""
dongsheng@627 10045 "The next thing that we'd like to do is figure out how to use the <command "
dongsheng@627 10046 "role=\"hg-cmd\">hg bisect</command> command. We can use Mercurial's normal "
dongsheng@627 10047 "built-in help mechanism for this."
dongsheng@627 10048 msgstr ""
dongsheng@627 10049
dongsheng@627 10050 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10051 #: ../en/ch08-undo.xml:811
dongsheng@627 10052 msgid ""
dongsheng@627 10053 "The <command role=\"hg-cmd\">hg bisect</command> command works in steps. "
dongsheng@627 10054 "Each step proceeds as follows."
dongsheng@627 10055 msgstr ""
dongsheng@627 10056
dongsheng@627 10057 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 10058 #: ../en/ch08-undo.xml:814
dongsheng@627 10059 msgid "You run your binary test."
dongsheng@627 10060 msgstr ""
dongsheng@627 10061
dongsheng@627 10062 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
songdongsheng@658 10063 #: ../en/ch08-undo.xml:816
dongsheng@627 10064 msgid ""
dongsheng@627 10065 "If the test succeeded, you tell <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10066 "by running the <command role=\"hg-cmd\">hg bisect good</command> command."
dongsheng@627 10067 msgstr ""
dongsheng@627 10068
dongsheng@627 10069 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><itemizedlist><listitem><para>
songdongsheng@658 10070 #: ../en/ch08-undo.xml:821
dongsheng@627 10071 msgid ""
dongsheng@627 10072 "If it failed, run the <command role=\"hg-cmd\">hg bisect bad</command> "
dongsheng@627 10073 "command."
dongsheng@627 10074 msgstr ""
dongsheng@627 10075
dongsheng@627 10076 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 10077 #: ../en/ch08-undo.xml:825
dongsheng@627 10078 msgid ""
dongsheng@627 10079 "The command uses your information to decide which changeset to test next."
dongsheng@627 10080 msgstr ""
dongsheng@627 10081
dongsheng@627 10082 #. type: Content of: <book><chapter><sect1><sect2><orderedlist><listitem><para>
songdongsheng@658 10083 #: ../en/ch08-undo.xml:828
dongsheng@627 10084 msgid ""
dongsheng@627 10085 "It updates the working directory to that changeset, and the process begins "
dongsheng@627 10086 "again."
dongsheng@627 10087 msgstr ""
dongsheng@627 10088
dongsheng@627 10089 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10090 #: ../en/ch08-undo.xml:831
dongsheng@627 10091 msgid ""
dongsheng@627 10092 "The process ends when <command role=\"hg-cmd\">hg bisect</command> identifies "
dongsheng@627 10093 "a unique changeset that marks the point where your test transitioned from "
dongsheng@627 10094 "<quote>succeeding</quote> to <quote>failing</quote>."
dongsheng@627 10095 msgstr ""
dongsheng@627 10096
dongsheng@627 10097 #
dongsheng@627 10098 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10099 #: ../en/ch08-undo.xml:836
dongsheng@627 10100 msgid ""
dongsheng@627 10101 "To start the search, we must run the <command role=\"hg-cmd\">hg bisect --"
dongsheng@627 10102 "reset</command> command."
dongsheng@627 10103 msgstr ""
dongsheng@627 10104
dongsheng@627 10105 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10106 #: ../en/ch08-undo.xml:841
dongsheng@627 10107 msgid ""
dongsheng@627 10108 "In our case, the binary test we use is simple: we check to see if any file in "
dongsheng@627 10109 "the repository contains the string <quote>i have a gub</quote>. If it does, "
dongsheng@627 10110 "this changeset contains the change that <quote>caused the bug</quote>. By "
dongsheng@627 10111 "convention, a changeset that has the property we're searching for is "
dongsheng@627 10112 "<quote>bad</quote>, while one that doesn't is <quote>good</quote>."
dongsheng@627 10113 msgstr ""
dongsheng@627 10114
dongsheng@627 10115 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10116 #: ../en/ch08-undo.xml:849
dongsheng@627 10117 msgid ""
dongsheng@627 10118 "Most of the time, the revision to which the working directory is synced "
dongsheng@627 10119 "(usually the tip) already exhibits the problem introduced by the buggy "
dongsheng@627 10120 "change, so we'll mark it as <quote>bad</quote>."
dongsheng@627 10121 msgstr ""
dongsheng@627 10122
dongsheng@627 10123 #
dongsheng@627 10124 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10125 #: ../en/ch08-undo.xml:856
dongsheng@627 10126 msgid ""
dongsheng@627 10127 "Our next task is to nominate a changeset that we know <emphasis>doesn't</"
dongsheng@627 10128 "emphasis> have the bug; the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10129 "command will <quote>bracket</quote> its search between the first pair of good "
dongsheng@627 10130 "and bad changesets. In our case, we know that revision 10 didn't have the "
dongsheng@627 10131 "bug. (I'll have more words about choosing the first <quote>good</quote> "
dongsheng@627 10132 "changeset later.)"
dongsheng@627 10133 msgstr ""
dongsheng@627 10134
dongsheng@627 10135 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10136 #: ../en/ch08-undo.xml:866
dongsheng@627 10137 msgid "Notice that this command printed some output."
dongsheng@627 10138 msgstr ""
dongsheng@627 10139
dongsheng@627 10140 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10141 #: ../en/ch08-undo.xml:868
dongsheng@627 10142 msgid ""
dongsheng@627 10143 "It told us how many changesets it must consider before it can identify the "
dongsheng@627 10144 "one that introduced the bug, and how many tests that will require."
dongsheng@627 10145 msgstr ""
dongsheng@627 10146
dongsheng@627 10147 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10148 #: ../en/ch08-undo.xml:872
dongsheng@627 10149 msgid ""
dongsheng@627 10150 "It updated the working directory to the next changeset to test, and told us "
dongsheng@627 10151 "which changeset it's testing."
dongsheng@627 10152 msgstr ""
dongsheng@627 10153
dongsheng@627 10154 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10155 #: ../en/ch08-undo.xml:877
dongsheng@627 10156 msgid ""
dongsheng@627 10157 "We now run our test in the working directory. We use the <command>grep</"
dongsheng@627 10158 "command> command to see if our <quote>bad</quote> file is present in the "
dongsheng@627 10159 "working directory. If it is, this revision is bad; if not, this revision is "
dongsheng@627 10160 "good. &interaction.bisect.search.step1;"
dongsheng@627 10161 msgstr ""
dongsheng@627 10162
dongsheng@627 10163 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10164 #: ../en/ch08-undo.xml:883
dongsheng@627 10165 msgid ""
dongsheng@627 10166 "This test looks like a perfect candidate for automation, so let's turn it "
dongsheng@627 10167 "into a shell function."
dongsheng@627 10168 msgstr ""
dongsheng@627 10169
dongsheng@627 10170 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10171 #: ../en/ch08-undo.xml:887
dongsheng@627 10172 msgid ""
dongsheng@627 10173 "We can now run an entire test step with a single command, <literal>mytest</"
dongsheng@627 10174 "literal>."
dongsheng@627 10175 msgstr ""
dongsheng@627 10176
dongsheng@627 10177 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10178 #: ../en/ch08-undo.xml:892
dongsheng@627 10179 msgid "A few more invocations of our canned test step command, and we're done."
dongsheng@627 10180 msgstr ""
dongsheng@627 10181
dongsheng@627 10182 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10183 #: ../en/ch08-undo.xml:897
dongsheng@627 10184 msgid ""
dongsheng@627 10185 "Even though we had 40 changesets to search through, the <command role=\"hg-cmd"
dongsheng@627 10186 "\">hg bisect</command> command let us find the changeset that introduced our "
dongsheng@627 10187 "<quote>bug</quote> with only five tests. Because the number of tests that "
dongsheng@627 10188 "the <command role=\"hg-cmd\">hg bisect</command> command performs grows "
dongsheng@627 10189 "logarithmically with the number of changesets to search, the advantage that "
dongsheng@627 10190 "it has over the <quote>brute force</quote> search approach increases with "
dongsheng@627 10191 "every changeset you add."
dongsheng@627 10192 msgstr ""
dongsheng@627 10193
dongsheng@627 10194 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10195 #: ../en/ch08-undo.xml:908
dongsheng@627 10196 msgid "Cleaning up after your search"
dongsheng@635 10197 msgstr "搜索后的清理"
dongsheng@627 10198
dongsheng@627 10199 #
dongsheng@627 10200 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10201 #: ../en/ch08-undo.xml:910
dongsheng@627 10202 msgid ""
dongsheng@627 10203 "When you're finished using the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10204 "command in a repository, you can use the <command role=\"hg-cmd\">hg bisect "
dongsheng@627 10205 "reset</command> command to drop the information it was using to drive your "
dongsheng@627 10206 "search. The command doesn't use much space, so it doesn't matter if you "
dongsheng@627 10207 "forget to run this command. However, <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10208 "command> won't let you start a new search in that repository until you do a "
dongsheng@627 10209 "<command role=\"hg-cmd\">hg bisect reset</command>."
dongsheng@627 10210 msgstr ""
dongsheng@627 10211
dongsheng@627 10212 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 10213 #: ../en/ch08-undo.xml:925
dongsheng@627 10214 msgid "Tips for finding bugs effectively"
dongsheng@635 10215 msgstr "有效查找问题的技巧"
dongsheng@627 10216
dongsheng@627 10217 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10218 #: ../en/ch08-undo.xml:928
dongsheng@627 10219 msgid "Give consistent input"
dongsheng@635 10220 msgstr "给出一致的输入"
dongsheng@627 10221
dongsheng@627 10222 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10223 #: ../en/ch08-undo.xml:930
dongsheng@627 10224 msgid ""
dongsheng@627 10225 "The <command role=\"hg-cmd\">hg bisect</command> command requires that you "
dongsheng@627 10226 "correctly report the result of every test you perform. If you tell it that a "
dongsheng@627 10227 "test failed when it really succeeded, it <emphasis>might</emphasis> be able "
dongsheng@627 10228 "to detect the inconsistency. If it can identify an inconsistency in your "
dongsheng@627 10229 "reports, it will tell you that a particular changeset is both good and bad. "
dongsheng@627 10230 "However, it can't do this perfectly; it's about as likely to report the wrong "
dongsheng@627 10231 "changeset as the source of the bug."
dongsheng@627 10232 msgstr ""
dongsheng@627 10233
dongsheng@627 10234 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10235 #: ../en/ch08-undo.xml:942
dongsheng@627 10236 msgid "Automate as much as possible"
dongsheng@635 10237 msgstr "尽量自动"
dongsheng@627 10238
dongsheng@627 10239 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10240 #: ../en/ch08-undo.xml:944
dongsheng@627 10241 msgid ""
dongsheng@627 10242 "When I started using the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10243 "command, I tried a few times to run my tests by hand, on the command line. "
dongsheng@627 10244 "This is an approach that I, at least, am not suited to. After a few tries, I "
dongsheng@627 10245 "found that I was making enough mistakes that I was having to restart my "
dongsheng@627 10246 "searches several times before finally getting correct results."
dongsheng@627 10247 msgstr ""
dongsheng@627 10248
dongsheng@627 10249 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10250 #: ../en/ch08-undo.xml:952
dongsheng@627 10251 msgid ""
dongsheng@627 10252 "My initial problems with driving the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10253 "command> command by hand occurred even with simple searches on small "
dongsheng@627 10254 "repositories; if the problem you're looking for is more subtle, or the number "
dongsheng@627 10255 "of tests that <command role=\"hg-cmd\">hg bisect</command> must perform "
dongsheng@627 10256 "increases, the likelihood of operator error ruining the search is much "
dongsheng@627 10257 "higher. Once I started automating my tests, I had much better results."
dongsheng@627 10258 msgstr ""
dongsheng@627 10259
dongsheng@627 10260 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10261 #: ../en/ch08-undo.xml:961
dongsheng@627 10262 msgid "The key to automated testing is twofold:"
dongsheng@627 10263 msgstr ""
dongsheng@627 10264
dongsheng@627 10265 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10266 #: ../en/ch08-undo.xml:963
dongsheng@627 10267 msgid "always test for the same symptom, and"
dongsheng@627 10268 msgstr ""
dongsheng@627 10269
dongsheng@627 10270 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10271 #: ../en/ch08-undo.xml:965
dongsheng@627 10272 msgid ""
dongsheng@627 10273 "always feed consistent input to the <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10274 "command> command."
dongsheng@627 10275 msgstr ""
dongsheng@627 10276
dongsheng@627 10277 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10278 #: ../en/ch08-undo.xml:968
dongsheng@627 10279 msgid ""
dongsheng@627 10280 "In my tutorial example above, the <command>grep</command> command tests for "
dongsheng@627 10281 "the symptom, and the <literal>if</literal> statement takes the result of this "
dongsheng@627 10282 "check and ensures that we always feed the same input to the <command role="
dongsheng@627 10283 "\"hg-cmd\">hg bisect</command> command. The <literal>mytest</literal> "
dongsheng@627 10284 "function marries these together in a reproducible way, so that every test is "
dongsheng@627 10285 "uniform and consistent."
dongsheng@627 10286 msgstr ""
dongsheng@627 10287
dongsheng@627 10288 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10289 #: ../en/ch08-undo.xml:978
dongsheng@627 10290 msgid "Check your results"
dongsheng@635 10291 msgstr "检查你的结果"
dongsheng@627 10292
dongsheng@627 10293 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10294 #: ../en/ch08-undo.xml:980
dongsheng@627 10295 msgid ""
dongsheng@627 10296 "Because the output of a <command role=\"hg-cmd\">hg bisect</command> search "
dongsheng@627 10297 "is only as good as the input you give it, don't take the changeset it reports "
dongsheng@627 10298 "as the absolute truth. A simple way to cross-check its report is to manually "
dongsheng@627 10299 "run your test at each of the following changesets:"
dongsheng@627 10300 msgstr ""
dongsheng@627 10301
dongsheng@627 10302 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10303 #: ../en/ch08-undo.xml:986
dongsheng@627 10304 msgid ""
dongsheng@627 10305 "The changeset that it reports as the first bad revision. Your test should "
dongsheng@627 10306 "still report this as bad."
dongsheng@627 10307 msgstr ""
dongsheng@627 10308
dongsheng@627 10309 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10310 #: ../en/ch08-undo.xml:990
dongsheng@627 10311 msgid ""
dongsheng@627 10312 "The parent of that changeset (either parent, if it's a merge). Your test "
dongsheng@627 10313 "should report this changeset as good."
dongsheng@627 10314 msgstr ""
dongsheng@627 10315
dongsheng@627 10316 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 10317 #: ../en/ch08-undo.xml:994
dongsheng@627 10318 msgid ""
dongsheng@627 10319 "A child of that changeset. Your test should report this changeset as bad."
dongsheng@627 10320 msgstr ""
dongsheng@627 10321
dongsheng@627 10322 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10323 #: ../en/ch08-undo.xml:1000
dongsheng@627 10324 msgid "Beware interference between bugs"
dongsheng@635 10325 msgstr "谨防问题之间的冲突"
dongsheng@627 10326
dongsheng@627 10327 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10328 #: ../en/ch08-undo.xml:1002
dongsheng@627 10329 msgid ""
dongsheng@627 10330 "It's possible that your search for one bug could be disrupted by the presence "
dongsheng@627 10331 "of another. For example, let's say your software crashes at revision 100, "
dongsheng@627 10332 "and worked correctly at revision 50. Unknown to you, someone else introduced "
dongsheng@627 10333 "a different crashing bug at revision 60, and fixed it at revision 80. This "
dongsheng@627 10334 "could distort your results in one of several ways."
dongsheng@627 10335 msgstr ""
dongsheng@627 10336
dongsheng@627 10337 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10338 #: ../en/ch08-undo.xml:1010
dongsheng@627 10339 msgid ""
dongsheng@627 10340 "It is possible that this other bug completely <quote>masks</quote> yours, "
dongsheng@627 10341 "which is to say that it occurs before your bug has a chance to manifest "
dongsheng@627 10342 "itself. If you can't avoid that other bug (for example, it prevents your "
dongsheng@627 10343 "project from building), and so can't tell whether your bug is present in a "
dongsheng@627 10344 "particular changeset, the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@627 10345 "command cannot help you directly. Instead, you can mark a changeset as "
dongsheng@627 10346 "untested by running <command role=\"hg-cmd\">hg bisect --skip</command>."
dongsheng@627 10347 msgstr ""
dongsheng@627 10348
dongsheng@627 10349 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10350 #: ../en/ch08-undo.xml:1020
dongsheng@627 10351 msgid ""
dongsheng@627 10352 "A different problem could arise if your test for a bug's presence is not "
dongsheng@627 10353 "specific enough. If you check for <quote>my program crashes</quote>, then "
dongsheng@627 10354 "both your crashing bug and an unrelated crashing bug that masks it will look "
dongsheng@627 10355 "like the same thing, and mislead <command role=\"hg-cmd\">hg bisect</command>."
dongsheng@627 10356 msgstr ""
dongsheng@627 10357
dongsheng@627 10358 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10359 #: ../en/ch08-undo.xml:1027
dongsheng@627 10360 msgid ""
dongsheng@627 10361 "Another useful situation in which to use <command role=\"hg-cmd\">hg bisect --"
dongsheng@627 10362 "skip</command> is if you can't test a revision because your project was in a "
dongsheng@627 10363 "broken and hence untestable state at that revision, perhaps because someone "
dongsheng@627 10364 "checked in a change that prevented the project from building."
dongsheng@627 10365 msgstr ""
dongsheng@627 10366
dongsheng@627 10367 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 10368 #: ../en/ch08-undo.xml:1036
dongsheng@627 10369 msgid "Bracket your search lazily"
dongsheng@635 10370 msgstr "减少你的查找工作"
dongsheng@627 10371
dongsheng@627 10372 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10373 #: ../en/ch08-undo.xml:1038
dongsheng@627 10374 msgid ""
dongsheng@627 10375 "Choosing the first <quote>good</quote> and <quote>bad</quote> changesets that "
dongsheng@627 10376 "will mark the end points of your search is often easy, but it bears a little "
dongsheng@627 10377 "discussion nevertheless. From the perspective of <command role=\"hg-cmd\">hg "
dongsheng@627 10378 "bisect</command>, the <quote>newest</quote> changeset is conventionally "
dongsheng@627 10379 "<quote>bad</quote>, and the older changeset is <quote>good</quote>."
dongsheng@627 10380 msgstr ""
dongsheng@627 10381
dongsheng@627 10382 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10383 #: ../en/ch08-undo.xml:1046
dongsheng@627 10384 msgid ""
dongsheng@627 10385 "If you're having trouble remembering when a suitable <quote>good</quote> "
dongsheng@627 10386 "change was, so that you can tell <command role=\"hg-cmd\">hg bisect</"
dongsheng@627 10387 "command>, you could do worse than testing changesets at random. Just "
dongsheng@627 10388 "remember to eliminate contenders that can't possibly exhibit the bug (perhaps "
dongsheng@627 10389 "because the feature with the bug isn't present yet) and those where another "
dongsheng@627 10390 "problem masks the bug (as I discussed above)."
dongsheng@627 10391 msgstr ""
dongsheng@627 10392
dongsheng@627 10393 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 10394 #: ../en/ch08-undo.xml:1055
dongsheng@627 10395 msgid ""
dongsheng@627 10396 "Even if you end up <quote>early</quote> by thousands of changesets or months "
dongsheng@627 10397 "of history, you will only add a handful of tests to the total number that "
dongsheng@627 10398 "<command role=\"hg-cmd\">hg bisect</command> must perform, thanks to its "
dongsheng@627 10399 "logarithmic behaviour."
dongsheng@627 10400 msgstr ""
dongsheng@627 10401
dongsheng@627 10402 #. type: Content of: <book><chapter><title>
dongsheng@650 10403 #: ../en/ch09-hook.xml:5
dongsheng@627 10404 msgid "Handling repository events with hooks"
dongsheng@627 10405 msgstr "使用钩子处理版本库事件"
dongsheng@627 10406
dongsheng@627 10407 #. type: Content of: <book><chapter><para>
dongsheng@650 10408 #: ../en/ch09-hook.xml:7
dongsheng@627 10409 msgid ""
dongsheng@627 10410 "Mercurial offers a powerful mechanism to let you perform automated actions in "
dongsheng@627 10411 "response to events that occur in a repository. In some cases, you can even "
dongsheng@627 10412 "control Mercurial's response to those events."
dongsheng@627 10413 msgstr ""
dongsheng@627 10414
dongsheng@627 10415 #. type: Content of: <book><chapter><para>
dongsheng@650 10416 #: ../en/ch09-hook.xml:12
dongsheng@627 10417 msgid ""
dongsheng@627 10418 "The name Mercurial uses for one of these actions is a <emphasis>hook</"
dongsheng@627 10419 "emphasis>. Hooks are called <quote>triggers</quote> in some revision control "
dongsheng@627 10420 "systems, but the two names refer to the same idea."
dongsheng@627 10421 msgstr ""
dongsheng@627 10422
dongsheng@627 10423 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10424 #: ../en/ch09-hook.xml:18
dongsheng@627 10425 msgid "An overview of hooks in Mercurial"
dongsheng@635 10426 msgstr "Mercurial 钩子概述"
dongsheng@627 10427
dongsheng@627 10428 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10429 #: ../en/ch09-hook.xml:20
dongsheng@627 10430 msgid ""
songdongsheng@658 10431 "Here is a brief list of the hooks that Mercurial supports. We will revisit "
songdongsheng@658 10432 "each of these hooks in more detail later, in <xref linkend=\"sec:hook:ref\"/>."
dongsheng@627 10433 msgstr ""
dongsheng@627 10434
dongsheng@627 10435 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10436 #: ../en/ch09-hook.xml:25
dongsheng@627 10437 msgid ""
dongsheng@627 10438 "<literal role=\"hook\">changegroup</literal>: This is run after a group of "
dongsheng@627 10439 "changesets has been brought into the repository from elsewhere."
dongsheng@627 10440 msgstr ""
dongsheng@627 10441
dongsheng@627 10442 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10443 #: ../en/ch09-hook.xml:29
dongsheng@627 10444 msgid ""
dongsheng@627 10445 "<literal role=\"hook\">commit</literal>: This is run after a new changeset "
dongsheng@627 10446 "has been created in the local repository."
dongsheng@627 10447 msgstr ""
dongsheng@627 10448
dongsheng@627 10449 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10450 #: ../en/ch09-hook.xml:33
dongsheng@627 10451 msgid ""
dongsheng@627 10452 "<literal role=\"hook\">incoming</literal>: This is run once for each new "
dongsheng@627 10453 "changeset that is brought into the repository from elsewhere. Notice the "
dongsheng@627 10454 "difference from <literal role=\"hook\">changegroup</literal>, which is run "
dongsheng@627 10455 "once per <emphasis>group</emphasis> of changesets brought in."
dongsheng@627 10456 msgstr ""
dongsheng@627 10457
dongsheng@627 10458 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10459 #: ../en/ch09-hook.xml:40
dongsheng@627 10460 msgid ""
dongsheng@627 10461 "<literal role=\"hook\">outgoing</literal>: This is run after a group of "
dongsheng@627 10462 "changesets has been transmitted from this repository."
dongsheng@627 10463 msgstr ""
dongsheng@627 10464
dongsheng@627 10465 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10466 #: ../en/ch09-hook.xml:44
dongsheng@627 10467 msgid ""
dongsheng@627 10468 "<literal role=\"hook\">prechangegroup</literal>: This is run before starting "
dongsheng@627 10469 "to bring a group of changesets into the repository."
dongsheng@627 10470 msgstr ""
dongsheng@627 10471
dongsheng@627 10472 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10473 #: ../en/ch09-hook.xml:49
dongsheng@627 10474 msgid ""
dongsheng@627 10475 "<literal role=\"hook\">precommit</literal>: Controlling. This is run before "
dongsheng@627 10476 "starting a commit."
dongsheng@627 10477 msgstr ""
dongsheng@627 10478
dongsheng@627 10479 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10480 #: ../en/ch09-hook.xml:53
dongsheng@627 10481 msgid ""
dongsheng@627 10482 "<literal role=\"hook\">preoutgoing</literal>: Controlling. This is run before "
dongsheng@627 10483 "starting to transmit a group of changesets from this repository."
dongsheng@627 10484 msgstr ""
dongsheng@627 10485
dongsheng@627 10486 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10487 #: ../en/ch09-hook.xml:58
dongsheng@627 10488 msgid ""
dongsheng@627 10489 "<literal role=\"hook\">pretag</literal>: Controlling. This is run before "
dongsheng@627 10490 "creating a tag."
dongsheng@627 10491 msgstr ""
dongsheng@627 10492
dongsheng@627 10493 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10494 #: ../en/ch09-hook.xml:62
dongsheng@627 10495 msgid ""
dongsheng@627 10496 "<literal role=\"hook\">pretxnchangegroup</literal>: Controlling. This is run "
dongsheng@627 10497 "after a group of changesets has been brought into the local repository from "
dongsheng@627 10498 "another, but before the transaction completes that will make the changes "
dongsheng@627 10499 "permanent in the repository."
dongsheng@627 10500 msgstr ""
dongsheng@627 10501
dongsheng@627 10502 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10503 #: ../en/ch09-hook.xml:70
dongsheng@627 10504 msgid ""
dongsheng@627 10505 "<literal role=\"hook\">pretxncommit</literal>: Controlling. This is run after "
dongsheng@627 10506 "a new changeset has been created in the local repository, but before the "
dongsheng@627 10507 "transaction completes that will make it permanent."
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:76
dongsheng@627 10512 msgid ""
dongsheng@627 10513 "<literal role=\"hook\">preupdate</literal>: Controlling. This is run before "
dongsheng@627 10514 "starting an update or merge of the working directory."
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:81
dongsheng@627 10519 msgid ""
dongsheng@627 10520 "<literal role=\"hook\">tag</literal>: This is run after a tag is created."
dongsheng@627 10521 msgstr ""
dongsheng@627 10522
dongsheng@627 10523 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 10524 #: ../en/ch09-hook.xml:85
dongsheng@627 10525 msgid ""
dongsheng@627 10526 "<literal role=\"hook\">update</literal>: This is run after an update or merge "
dongsheng@627 10527 "of the working directory has finished."
dongsheng@627 10528 msgstr ""
dongsheng@627 10529
dongsheng@627 10530 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10531 #: ../en/ch09-hook.xml:90
dongsheng@627 10532 msgid ""
dongsheng@627 10533 "Each of the hooks whose description begins with the word <quote>Controlling</"
dongsheng@627 10534 "quote> has the ability to determine whether an activity can proceed. If the "
dongsheng@627 10535 "hook succeeds, the activity may proceed; if it fails, the activity is either "
dongsheng@627 10536 "not permitted or undone, depending on the hook."
dongsheng@627 10537 msgstr ""
dongsheng@627 10538
dongsheng@627 10539 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10540 #: ../en/ch09-hook.xml:99
dongsheng@627 10541 msgid "Hooks and security"
dongsheng@635 10542 msgstr "钩子与安全性"
dongsheng@627 10543
dongsheng@627 10544 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10545 #: ../en/ch09-hook.xml:102
dongsheng@627 10546 msgid "Hooks are run with your privileges"
dongsheng@635 10547 msgstr "钩子以你的特权执行"
dongsheng@627 10548
dongsheng@627 10549 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10550 #: ../en/ch09-hook.xml:104
dongsheng@627 10551 msgid ""
dongsheng@627 10552 "When you run a Mercurial command in a repository, and the command causes a "
dongsheng@627 10553 "hook to run, that hook runs on <emphasis>your</emphasis> system, under "
dongsheng@627 10554 "<emphasis>your</emphasis> user account, with <emphasis>your</emphasis> "
dongsheng@627 10555 "privilege level. Since hooks are arbitrary pieces of executable code, you "
dongsheng@627 10556 "should treat them with an appropriate level of suspicion. Do not install a "
dongsheng@627 10557 "hook unless you are confident that you know who created it and what it does."
dongsheng@627 10558 msgstr ""
dongsheng@627 10559
dongsheng@627 10560 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10561 #: ../en/ch09-hook.xml:115
dongsheng@627 10562 msgid ""
dongsheng@627 10563 "In some cases, you may be exposed to hooks that you did not install "
dongsheng@627 10564 "yourself. If you work with Mercurial on an unfamiliar system, Mercurial will "
dongsheng@650 10565 "run hooks defined in that system's global <filename role=\"special\">~/.hgrc</"
dongsheng@650 10566 "filename> file."
dongsheng@650 10567 msgstr ""
dongsheng@650 10568
dongsheng@650 10569 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10570 #: ../en/ch09-hook.xml:122
dongsheng@627 10571 msgid ""
dongsheng@627 10572 "If you are working with a repository owned by another user, Mercurial can run "
dongsheng@627 10573 "hooks defined in that user's repository, but it will still run them as "
dongsheng@627 10574 "<quote>you</quote>. For example, if you <command role=\"hg-cmd\">hg pull</"
dongsheng@627 10575 "command> from that repository, and its <filename role=\"special\">.hg/hgrc</"
dongsheng@627 10576 "filename> defines a local <literal role=\"hook\">outgoing</literal> hook, "
dongsheng@627 10577 "that hook will run under your user account, even though you don't own that "
dongsheng@627 10578 "repository."
dongsheng@627 10579 msgstr ""
dongsheng@627 10580
dongsheng@627 10581 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@650 10582 #: ../en/ch09-hook.xml:134
dongsheng@627 10583 msgid ""
dongsheng@627 10584 "This only applies if you are pulling from a repository on a local or network "
dongsheng@627 10585 "filesystem. If you're pulling over http or ssh, any <literal role=\"hook"
dongsheng@627 10586 "\">outgoing</literal> hook will run under whatever account is executing the "
dongsheng@627 10587 "server process, on the server."
dongsheng@627 10588 msgstr ""
dongsheng@627 10589
dongsheng@627 10590 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10591 #: ../en/ch09-hook.xml:142
dongsheng@627 10592 msgid ""
dongsheng@627 10593 "XXX To see what hooks are defined in a repository, use the <command role=\"hg-"
dongsheng@627 10594 "cmd\">hg config hooks</command> command. If you are working in one "
dongsheng@627 10595 "repository, but talking to another that you do not own (e.g. using <command "
dongsheng@627 10596 "role=\"hg-cmd\">hg pull</command> or <command role=\"hg-cmd\">hg incoming</"
dongsheng@627 10597 "command>), remember that it is the other repository's hooks you should be "
dongsheng@627 10598 "checking, not your own."
dongsheng@627 10599 msgstr ""
dongsheng@627 10600
dongsheng@627 10601 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10602 #: ../en/ch09-hook.xml:153
dongsheng@627 10603 msgid "Hooks do not propagate"
dongsheng@635 10604 msgstr "钩子不会传播"
dongsheng@627 10605
dongsheng@627 10606 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10607 #: ../en/ch09-hook.xml:155
dongsheng@627 10608 msgid ""
dongsheng@627 10609 "In Mercurial, hooks are not revision controlled, and do not propagate when "
dongsheng@627 10610 "you clone, or pull from, a repository. The reason for this is simple: a hook "
dongsheng@627 10611 "is a completely arbitrary piece of executable code. It runs under your user "
dongsheng@627 10612 "identity, with your privilege level, on your machine."
dongsheng@627 10613 msgstr ""
dongsheng@627 10614
dongsheng@627 10615 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10616 #: ../en/ch09-hook.xml:162
dongsheng@627 10617 msgid ""
dongsheng@627 10618 "It would be extremely reckless for any distributed revision control system to "
dongsheng@627 10619 "implement revision-controlled hooks, as this would offer an easily "
dongsheng@627 10620 "exploitable way to subvert the accounts of users of the revision control "
dongsheng@627 10621 "system."
dongsheng@627 10622 msgstr ""
dongsheng@627 10623
dongsheng@627 10624 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10625 #: ../en/ch09-hook.xml:168
dongsheng@627 10626 msgid ""
dongsheng@627 10627 "Since Mercurial does not propagate hooks, if you are collaborating with other "
dongsheng@627 10628 "people on a common project, you should not assume that they are using the "
dongsheng@627 10629 "same Mercurial hooks as you are, or that theirs are correctly configured. "
dongsheng@627 10630 "You should document the hooks you expect people to use."
dongsheng@627 10631 msgstr ""
dongsheng@627 10632
dongsheng@627 10633 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10634 #: ../en/ch09-hook.xml:175
dongsheng@627 10635 msgid ""
dongsheng@627 10636 "In a corporate intranet, this is somewhat easier to control, as you can for "
dongsheng@627 10637 "example provide a <quote>standard</quote> installation of Mercurial on an NFS "
dongsheng@650 10638 "filesystem, and use a site-wide <filename role=\"special\">~/.hgrc</filename> "
dongsheng@650 10639 "file to define hooks that all users will see. However, this too has its "
dongsheng@627 10640 "limits; see below."
dongsheng@627 10641 msgstr ""
dongsheng@627 10642
dongsheng@627 10643 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10644 #: ../en/ch09-hook.xml:184
dongsheng@627 10645 msgid "Hooks can be overridden"
dongsheng@635 10646 msgstr "钩子可以被覆盖"
dongsheng@627 10647
dongsheng@627 10648 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10649 #: ../en/ch09-hook.xml:186
dongsheng@627 10650 msgid ""
dongsheng@627 10651 "Mercurial allows you to override a hook definition by redefining the hook. "
dongsheng@627 10652 "You can disable it by setting its value to the empty string, or change its "
dongsheng@627 10653 "behaviour as you wish."
dongsheng@627 10654 msgstr ""
dongsheng@627 10655
dongsheng@627 10656 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10657 #: ../en/ch09-hook.xml:191
dongsheng@650 10658 msgid ""
dongsheng@650 10659 "If you deploy a system- or site-wide <filename role=\"special\">~/.hgrc</"
dongsheng@650 10660 "filename> file that defines some hooks, you should thus understand that your "
dongsheng@650 10661 "users can disable or override those hooks."
dongsheng@650 10662 msgstr ""
dongsheng@650 10663
dongsheng@650 10664 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10665 #: ../en/ch09-hook.xml:199
dongsheng@627 10666 msgid "Ensuring that critical hooks are run"
dongsheng@635 10667 msgstr "确保关键钩子的执行"
dongsheng@627 10668
dongsheng@627 10669 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10670 #: ../en/ch09-hook.xml:201
dongsheng@627 10671 msgid ""
dongsheng@627 10672 "Sometimes you may want to enforce a policy that you do not want others to be "
dongsheng@627 10673 "able to work around. For example, you may have a requirement that every "
dongsheng@627 10674 "changeset must pass a rigorous set of tests. Defining this requirement via a "
dongsheng@650 10675 "hook in a site-wide <filename role=\"special\">~/.hgrc</filename> won't work "
dongsheng@650 10676 "for remote users on laptops, and of course local users can subvert it at will "
dongsheng@650 10677 "by overriding the hook."
dongsheng@650 10678 msgstr ""
dongsheng@650 10679
dongsheng@650 10680 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10681 #: ../en/ch09-hook.xml:210
dongsheng@627 10682 msgid ""
dongsheng@627 10683 "Instead, you can set up your policies for use of Mercurial so that people are "
dongsheng@627 10684 "expected to propagate changes through a well-known <quote>canonical</quote> "
dongsheng@627 10685 "server that you have locked down and configured appropriately."
dongsheng@627 10686 msgstr ""
dongsheng@627 10687
dongsheng@627 10688 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10689 #: ../en/ch09-hook.xml:216
dongsheng@627 10690 msgid ""
dongsheng@627 10691 "One way to do this is via a combination of social engineering and "
dongsheng@627 10692 "technology. Set up a restricted-access account; users can push changes over "
dongsheng@627 10693 "the network to repositories managed by this account, but they cannot log into "
dongsheng@627 10694 "the account and run normal shell commands. In this scenario, a user can "
dongsheng@627 10695 "commit a changeset that contains any old garbage they want."
dongsheng@627 10696 msgstr ""
dongsheng@627 10697
dongsheng@627 10698 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10699 #: ../en/ch09-hook.xml:225
dongsheng@627 10700 msgid ""
dongsheng@627 10701 "When someone pushes a changeset to the server that everyone pulls from, the "
dongsheng@627 10702 "server will test the changeset before it accepts it as permanent, and reject "
dongsheng@627 10703 "it if it fails to pass the test suite. If people only pull changes from this "
dongsheng@627 10704 "filtering server, it will serve to ensure that all changes that people pull "
dongsheng@627 10705 "have been automatically vetted."
dongsheng@627 10706 msgstr ""
dongsheng@627 10707
dongsheng@627 10708 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10709 #: ../en/ch09-hook.xml:236
dongsheng@627 10710 msgid "Care with <literal>pretxn</literal> hooks in a shared-access repository"
dongsheng@635 10711 msgstr "在共享版本库中注意 <literal>pretxn</literal> 钩子"
dongsheng@627 10712
dongsheng@627 10713 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10714 #: ../en/ch09-hook.xml:239
dongsheng@627 10715 msgid ""
dongsheng@627 10716 "If you want to use hooks to do some automated work in a repository that a "
dongsheng@627 10717 "number of people have shared access to, you need to be careful in how you do "
dongsheng@627 10718 "this."
dongsheng@627 10719 msgstr ""
dongsheng@627 10720
dongsheng@627 10721 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10722 #: ../en/ch09-hook.xml:244
dongsheng@627 10723 msgid ""
dongsheng@627 10724 "Mercurial only locks a repository when it is writing to the repository, and "
dongsheng@627 10725 "only the parts of Mercurial that write to the repository pay attention to "
dongsheng@627 10726 "locks. Write locks are necessary to prevent multiple simultaneous writers "
dongsheng@627 10727 "from scribbling on each other's work, corrupting the repository."
dongsheng@627 10728 msgstr ""
dongsheng@627 10729
dongsheng@627 10730 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10731 #: ../en/ch09-hook.xml:251
dongsheng@627 10732 msgid ""
dongsheng@627 10733 "Because Mercurial is careful with the order in which it reads and writes "
dongsheng@627 10734 "data, it does not need to acquire a lock when it wants to read data from the "
dongsheng@627 10735 "repository. The parts of Mercurial that read from the repository never pay "
dongsheng@627 10736 "attention to locks. This lockless reading scheme greatly increases "
dongsheng@627 10737 "performance and concurrency."
dongsheng@627 10738 msgstr ""
dongsheng@627 10739
dongsheng@627 10740 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10741 #: ../en/ch09-hook.xml:259
dongsheng@627 10742 msgid ""
dongsheng@627 10743 "With great performance comes a trade-off, though, one which has the potential "
dongsheng@627 10744 "to cause you trouble unless you're aware of it. To describe this requires a "
dongsheng@627 10745 "little detail about how Mercurial adds changesets to a repository and reads "
dongsheng@627 10746 "those changes."
dongsheng@627 10747 msgstr ""
dongsheng@627 10748
dongsheng@627 10749 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10750 #: ../en/ch09-hook.xml:266
dongsheng@627 10751 msgid ""
dongsheng@627 10752 "When Mercurial <emphasis>writes</emphasis> metadata, it writes it straight "
dongsheng@627 10753 "into the destination file. It writes file data first, then manifest data "
dongsheng@627 10754 "(which contains pointers to the new file data), then changelog data (which "
dongsheng@627 10755 "contains pointers to the new manifest data). Before the first write to each "
dongsheng@627 10756 "file, it stores a record of where the end of the file was in its transaction "
dongsheng@627 10757 "log. If the transaction must be rolled back, Mercurial simply truncates each "
dongsheng@627 10758 "file back to the size it was before the transaction began."
dongsheng@627 10759 msgstr ""
dongsheng@627 10760
dongsheng@627 10761 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10762 #: ../en/ch09-hook.xml:277
dongsheng@627 10763 msgid ""
dongsheng@627 10764 "When Mercurial <emphasis>reads</emphasis> metadata, it reads the changelog "
dongsheng@627 10765 "first, then everything else. Since a reader will only access parts of the "
dongsheng@627 10766 "manifest or file metadata that it can see in the changelog, it can never see "
dongsheng@627 10767 "partially written data."
dongsheng@627 10768 msgstr ""
dongsheng@627 10769
dongsheng@627 10770 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10771 #: ../en/ch09-hook.xml:283
dongsheng@627 10772 msgid ""
dongsheng@627 10773 "Some controlling hooks (<literal role=\"hook\">pretxncommit</literal> and "
dongsheng@627 10774 "<literal role=\"hook\">pretxnchangegroup</literal>) run when a transaction is "
dongsheng@627 10775 "almost complete. All of the metadata has been written, but Mercurial can "
dongsheng@627 10776 "still roll the transaction back and cause the newly-written data to disappear."
dongsheng@627 10777 msgstr ""
dongsheng@627 10778
dongsheng@627 10779 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10780 #: ../en/ch09-hook.xml:291
dongsheng@627 10781 msgid ""
dongsheng@627 10782 "If one of these hooks runs for long, it opens a window of time during which a "
dongsheng@627 10783 "reader can see the metadata for changesets that are not yet permanent, and "
dongsheng@627 10784 "should not be thought of as <quote>really there</quote>. The longer the hook "
dongsheng@627 10785 "runs, the longer that window is open."
dongsheng@627 10786 msgstr ""
dongsheng@627 10787
dongsheng@627 10788 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10789 #: ../en/ch09-hook.xml:299
dongsheng@627 10790 msgid "The problem illustrated"
dongsheng@635 10791 msgstr "问题的演示"
dongsheng@627 10792
dongsheng@627 10793 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10794 #: ../en/ch09-hook.xml:301
dongsheng@627 10795 msgid ""
dongsheng@627 10796 "In principle, a good use for the <literal role=\"hook\">pretxnchangegroup</"
dongsheng@627 10797 "literal> hook would be to automatically build and test incoming changes "
dongsheng@627 10798 "before they are accepted into a central repository. This could let you "
dongsheng@627 10799 "guarantee that nobody can push changes to this repository that <quote>break "
dongsheng@627 10800 "the build</quote>. But if a client can pull changes while they're being "
dongsheng@627 10801 "tested, the usefulness of the test is zero; an unsuspecting someone can pull "
dongsheng@627 10802 "untested changes, potentially breaking their build."
dongsheng@627 10803 msgstr ""
dongsheng@627 10804
dongsheng@627 10805 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10806 #: ../en/ch09-hook.xml:312
dongsheng@627 10807 msgid ""
dongsheng@627 10808 "The safest technological answer to this challenge is to set up such a "
dongsheng@627 10809 "<quote>gatekeeper</quote> repository as <emphasis>unidirectional</emphasis>. "
dongsheng@627 10810 "Let it take changes pushed in from the outside, but do not allow anyone to "
dongsheng@627 10811 "pull changes from it (use the <literal role=\"hook\">preoutgoing</literal> "
dongsheng@627 10812 "hook to lock it down). Configure a <literal role=\"hook\">changegroup</"
dongsheng@627 10813 "literal> hook so that if a build or test succeeds, the hook will push the new "
dongsheng@627 10814 "changes out to another repository that people <emphasis>can</emphasis> pull "
dongsheng@627 10815 "from."
dongsheng@627 10816 msgstr ""
dongsheng@627 10817
dongsheng@627 10818 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10819 #: ../en/ch09-hook.xml:324
dongsheng@627 10820 msgid ""
dongsheng@627 10821 "In practice, putting a centralised bottleneck like this in place is not often "
dongsheng@627 10822 "a good idea, and transaction visibility has nothing to do with the problem. "
dongsheng@661 10823 "As the size of a project—and the time it takes to build and test—grows, you "
dongsheng@661 10824 "rapidly run into a wall with this <quote>try before you buy</quote> approach, "
dongsheng@661 10825 "where you have more changesets to test than time in which to deal with them. "
dongsheng@661 10826 "The inevitable result is frustration on the part of all involved."
dongsheng@627 10827 msgstr ""
dongsheng@627 10828
dongsheng@627 10829 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10830 #: ../en/ch09-hook.xml:335
dongsheng@627 10831 msgid ""
dongsheng@627 10832 "An approach that scales better is to get people to build and test before they "
dongsheng@627 10833 "push, then run automated builds and tests centrally <emphasis>after</"
dongsheng@627 10834 "emphasis> a push, to be sure all is well. The advantage of this approach is "
dongsheng@627 10835 "that it does not impose a limit on the rate at which the repository can "
dongsheng@627 10836 "accept changes."
dongsheng@627 10837 msgstr ""
dongsheng@627 10838
dongsheng@627 10839 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10840 #: ../en/ch09-hook.xml:346
dongsheng@627 10841 msgid "A short tutorial on using hooks"
dongsheng@635 10842 msgstr "使用钩子的简短指南"
dongsheng@627 10843
dongsheng@627 10844 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10845 #: ../en/ch09-hook.xml:348
dongsheng@627 10846 msgid ""
dongsheng@627 10847 "It is easy to write a Mercurial hook. Let's start with a hook that runs when "
dongsheng@627 10848 "you finish a <command role=\"hg-cmd\">hg commit</command>, and simply prints "
dongsheng@627 10849 "the hash of the changeset you just created. The hook is called <literal role="
dongsheng@627 10850 "\"hook\">commit</literal>."
dongsheng@627 10851 msgstr ""
dongsheng@627 10852
dongsheng@627 10853 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10854 #: ../en/ch09-hook.xml:355
dongsheng@627 10855 msgid "All hooks follow the pattern in this example."
dongsheng@627 10856 msgstr ""
dongsheng@627 10857
dongsheng@627 10858 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10859 #: ../en/ch09-hook.xml:359
dongsheng@627 10860 msgid ""
dongsheng@627 10861 "You add an entry to the <literal role=\"rc-hooks\">hooks</literal> section of "
dongsheng@650 10862 "your <filename role=\"special\">~/.hgrc</filename>. On the left is the name "
dongsheng@627 10863 "of the event to trigger on; on the right is the action to take. As you can "
dongsheng@627 10864 "see, you can run an arbitrary shell command in a hook. Mercurial passes "
dongsheng@627 10865 "extra information to the hook using environment variables (look for "
dongsheng@627 10866 "<envar>HG_NODE</envar> in the example)."
dongsheng@627 10867 msgstr ""
dongsheng@627 10868
dongsheng@627 10869 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10870 #: ../en/ch09-hook.xml:369
dongsheng@627 10871 msgid "Performing multiple actions per event"
dongsheng@635 10872 msgstr "每个事件执行多个操作"
dongsheng@627 10873
dongsheng@627 10874 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10875 #: ../en/ch09-hook.xml:371
dongsheng@627 10876 msgid ""
dongsheng@627 10877 "Quite often, you will want to define more than one hook for a particular kind "
dongsheng@627 10878 "of event, as shown below."
dongsheng@627 10879 msgstr ""
dongsheng@627 10880
dongsheng@627 10881 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10882 #: ../en/ch09-hook.xml:376
dongsheng@627 10883 msgid ""
dongsheng@627 10884 "Mercurial lets you do this by adding an <emphasis>extension</emphasis> to the "
dongsheng@627 10885 "end of a hook's name. You extend a hook's name by giving the name of the "
dongsheng@627 10886 "hook, followed by a full stop (the <quote><literal>.</literal></quote> "
dongsheng@627 10887 "character), followed by some more text of your choosing. For example, "
dongsheng@627 10888 "Mercurial will run both <literal>commit.foo</literal> and <literal>commit."
dongsheng@627 10889 "bar</literal> when the <literal>commit</literal> event occurs."
dongsheng@627 10890 msgstr ""
dongsheng@627 10891
dongsheng@627 10892 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10893 #: ../en/ch09-hook.xml:387
dongsheng@627 10894 msgid ""
dongsheng@627 10895 "To give a well-defined order of execution when there are multiple hooks "
dongsheng@627 10896 "defined for an event, Mercurial sorts hooks by extension, and executes the "
dongsheng@627 10897 "hook commands in this sorted order. In the above example, it will execute "
dongsheng@627 10898 "<literal>commit.bar</literal> before <literal>commit.foo</literal>, and "
dongsheng@627 10899 "<literal>commit</literal> before both."
dongsheng@627 10900 msgstr ""
dongsheng@627 10901
dongsheng@627 10902 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10903 #: ../en/ch09-hook.xml:396
dongsheng@627 10904 msgid ""
dongsheng@627 10905 "It is a good idea to use a somewhat descriptive extension when you define a "
dongsheng@627 10906 "new hook. This will help you to remember what the hook was for. If the hook "
dongsheng@627 10907 "fails, you'll get an error message that contains the hook name and extension, "
dongsheng@627 10908 "so using a descriptive extension could give you an immediate hint as to why "
songdongsheng@658 10909 "the hook failed (see <xref linkend=\"sec:hook:perm\"/> for an example)."
dongsheng@627 10910 msgstr ""
dongsheng@627 10911
dongsheng@627 10912 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10913 #: ../en/ch09-hook.xml:407
dongsheng@627 10914 msgid "Controlling whether an activity can proceed"
dongsheng@635 10915 msgstr "控制处理的活动"
dongsheng@627 10916
dongsheng@627 10917 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10918 #: ../en/ch09-hook.xml:409
dongsheng@627 10919 msgid ""
dongsheng@627 10920 "In our earlier examples, we used the <literal role=\"hook\">commit</literal> "
dongsheng@627 10921 "hook, which is run after a commit has completed. This is one of several "
dongsheng@627 10922 "Mercurial hooks that run after an activity finishes. Such hooks have no way "
dongsheng@627 10923 "of influencing the activity itself."
dongsheng@627 10924 msgstr ""
dongsheng@627 10925
dongsheng@627 10926 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10927 #: ../en/ch09-hook.xml:416
dongsheng@627 10928 msgid ""
dongsheng@627 10929 "Mercurial defines a number of events that occur before an activity starts; or "
dongsheng@627 10930 "after it starts, but before it finishes. Hooks that trigger on these events "
dongsheng@627 10931 "have the added ability to choose whether the activity can continue, or will "
dongsheng@627 10932 "abort."
dongsheng@627 10933 msgstr ""
dongsheng@627 10934
dongsheng@627 10935 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10936 #: ../en/ch09-hook.xml:422
dongsheng@627 10937 msgid ""
dongsheng@627 10938 "The <literal role=\"hook\">pretxncommit</literal> hook runs after a commit "
dongsheng@627 10939 "has all but completed. In other words, the metadata representing the "
dongsheng@627 10940 "changeset has been written out to disk, but the transaction has not yet been "
dongsheng@627 10941 "allowed to complete. The <literal role=\"hook\">pretxncommit</literal> hook "
dongsheng@627 10942 "has the ability to decide whether the transaction can complete, or must be "
dongsheng@627 10943 "rolled back."
dongsheng@627 10944 msgstr ""
dongsheng@627 10945
dongsheng@627 10946 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10947 #: ../en/ch09-hook.xml:431
dongsheng@627 10948 msgid ""
dongsheng@627 10949 "If the <literal role=\"hook\">pretxncommit</literal> hook exits with a status "
dongsheng@627 10950 "code of zero, the transaction is allowed to complete; the commit finishes; "
dongsheng@627 10951 "and the <literal role=\"hook\">commit</literal> hook is run. If the <literal "
dongsheng@627 10952 "role=\"hook\">pretxncommit</literal> hook exits with a non-zero status code, "
dongsheng@627 10953 "the transaction is rolled back; the metadata representing the changeset is "
dongsheng@627 10954 "erased; and the <literal role=\"hook\">commit</literal> hook is not run."
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:443
dongsheng@627 10959 msgid ""
dongsheng@627 10960 "The hook in the example above checks that a commit comment contains a bug "
dongsheng@627 10961 "ID. If it does, the commit can complete. If not, the commit is rolled back."
dongsheng@627 10962 msgstr ""
dongsheng@627 10963
dongsheng@627 10964 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 10965 #: ../en/ch09-hook.xml:451
dongsheng@627 10966 msgid "Writing your own hooks"
dongsheng@635 10967 msgstr "编写钩子"
dongsheng@627 10968
dongsheng@627 10969 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 10970 #: ../en/ch09-hook.xml:453
dongsheng@627 10971 msgid ""
dongsheng@627 10972 "When you are writing a hook, you might find it useful to run Mercurial either "
dongsheng@627 10973 "with the <option role=\"hg-opt-global\">-v</option> option, or the <envar "
dongsheng@627 10974 "role=\"rc-item-ui\">verbose</envar> config item set to <quote>true</quote>. "
dongsheng@627 10975 "When you do so, Mercurial will print a message before it calls each hook."
dongsheng@627 10976 msgstr ""
dongsheng@627 10977
dongsheng@627 10978 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 10979 #: ../en/ch09-hook.xml:462
dongsheng@627 10980 msgid "Choosing how your hook should run"
dongsheng@635 10981 msgstr "选择钩子的执行方式"
dongsheng@627 10982
dongsheng@627 10983 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10984 #: ../en/ch09-hook.xml:464
dongsheng@627 10985 msgid ""
dongsheng@661 10986 "You can write a hook either as a normal program—typically a shell script—or "
dongsheng@661 10987 "as a Python function that is executed within the Mercurial process."
dongsheng@627 10988 msgstr ""
dongsheng@627 10989
dongsheng@627 10990 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 10991 #: ../en/ch09-hook.xml:469
dongsheng@627 10992 msgid ""
dongsheng@627 10993 "Writing a hook as an external program has the advantage that it requires no "
dongsheng@627 10994 "knowledge of Mercurial's internals. You can call normal Mercurial commands "
dongsheng@627 10995 "to get any added information you need. The trade-off is that external hooks "
dongsheng@627 10996 "are slower than in-process hooks."
dongsheng@627 10997 msgstr ""
dongsheng@627 10998
dongsheng@627 10999 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11000 #: ../en/ch09-hook.xml:476
dongsheng@627 11001 msgid ""
dongsheng@627 11002 "An in-process Python hook has complete access to the Mercurial API, and does "
dongsheng@627 11003 "not <quote>shell out</quote> to another process, so it is inherently faster "
dongsheng@627 11004 "than an external hook. It is also easier to obtain much of the information "
dongsheng@627 11005 "that a hook requires by using the Mercurial API than by running Mercurial "
dongsheng@627 11006 "commands."
dongsheng@627 11007 msgstr ""
dongsheng@627 11008
dongsheng@627 11009 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11010 #: ../en/ch09-hook.xml:484
dongsheng@627 11011 msgid ""
dongsheng@627 11012 "If you are comfortable with Python, or require high performance, writing your "
dongsheng@627 11013 "hooks in Python may be a good choice. However, when you have a "
dongsheng@627 11014 "straightforward hook to write and you don't need to care about performance "
dongsheng@627 11015 "(probably the majority of hooks), a shell script is perfectly fine."
dongsheng@627 11016 msgstr ""
dongsheng@627 11017
dongsheng@627 11018 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11019 #: ../en/ch09-hook.xml:493
dongsheng@627 11020 msgid "Hook parameters"
dongsheng@635 11021 msgstr "钩子的参数"
dongsheng@627 11022
dongsheng@627 11023 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11024 #: ../en/ch09-hook.xml:495
dongsheng@627 11025 msgid ""
dongsheng@627 11026 "Mercurial calls each hook with a set of well-defined parameters. In Python, "
dongsheng@627 11027 "a parameter is passed as a keyword argument to your hook function. For an "
dongsheng@627 11028 "external program, a parameter is passed as an environment variable."
dongsheng@627 11029 msgstr ""
dongsheng@627 11030
dongsheng@627 11031 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11032 #: ../en/ch09-hook.xml:501
dongsheng@627 11033 msgid ""
dongsheng@627 11034 "Whether your hook is written in Python or as a shell script, the hook-"
dongsheng@627 11035 "specific parameter names and values will be the same. A boolean parameter "
dongsheng@627 11036 "will be represented as a boolean value in Python, but as the number 1 (for "
dongsheng@627 11037 "<quote>true</quote>) or 0 (for <quote>false</quote>) as an environment "
dongsheng@627 11038 "variable for an external hook. If a hook parameter is named <literal>foo</"
dongsheng@627 11039 "literal>, the keyword argument for a Python hook will also be named "
dongsheng@627 11040 "<literal>foo</literal>, while the environment variable for an external hook "
dongsheng@627 11041 "will be named <literal>HG_FOO</literal>."
dongsheng@627 11042 msgstr ""
dongsheng@627 11043
dongsheng@627 11044 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11045 #: ../en/ch09-hook.xml:515
dongsheng@627 11046 msgid "Hook return values and activity control"
dongsheng@635 11047 msgstr "钩子的返回值与活动控制"
dongsheng@627 11048
dongsheng@627 11049 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11050 #: ../en/ch09-hook.xml:517
dongsheng@627 11051 msgid ""
dongsheng@627 11052 "A hook that executes successfully must exit with a status of zero if "
dongsheng@627 11053 "external, or return boolean <quote>false</quote> if in-process. Failure is "
dongsheng@627 11054 "indicated with a non-zero exit status from an external hook, or an in-process "
dongsheng@627 11055 "hook returning boolean <quote>true</quote>. If an in-process hook raises an "
dongsheng@627 11056 "exception, the hook is considered to have failed."
dongsheng@627 11057 msgstr ""
dongsheng@627 11058
dongsheng@627 11059 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11060 #: ../en/ch09-hook.xml:525
dongsheng@627 11061 msgid ""
dongsheng@627 11062 "For a hook that controls whether an activity can proceed, zero/false means "
dongsheng@627 11063 "<quote>allow</quote>, while non-zero/true/exception means <quote>deny</quote>."
dongsheng@627 11064 msgstr ""
dongsheng@627 11065
dongsheng@627 11066 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11067 #: ../en/ch09-hook.xml:532
dongsheng@627 11068 msgid "Writing an external hook"
dongsheng@635 11069 msgstr "编写外部钩子"
dongsheng@627 11070
dongsheng@627 11071 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11072 #: ../en/ch09-hook.xml:534
dongsheng@650 11073 msgid ""
dongsheng@650 11074 "When you define an external hook in your <filename role=\"special\">~/.hgrc</"
dongsheng@650 11075 "filename> and the hook is run, its value is passed to your shell, which "
dongsheng@627 11076 "interprets it. This means that you can use normal shell constructs in the "
dongsheng@627 11077 "body of the hook."
dongsheng@627 11078 msgstr ""
dongsheng@627 11079
dongsheng@627 11080 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11081 #: ../en/ch09-hook.xml:541
dongsheng@627 11082 msgid ""
dongsheng@627 11083 "An executable hook is always run with its current directory set to a "
dongsheng@627 11084 "repository's root directory."
dongsheng@627 11085 msgstr ""
dongsheng@627 11086
dongsheng@627 11087 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11088 #: ../en/ch09-hook.xml:545
dongsheng@627 11089 msgid ""
dongsheng@627 11090 "Each hook parameter is passed in as an environment variable; the name is "
dongsheng@627 11091 "upper-cased, and prefixed with the string <quote><literal>HG_</literal></"
dongsheng@627 11092 "quote>."
dongsheng@627 11093 msgstr ""
dongsheng@627 11094
dongsheng@627 11095 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11096 #: ../en/ch09-hook.xml:550
dongsheng@627 11097 msgid ""
dongsheng@627 11098 "With the exception of hook parameters, Mercurial does not set or modify any "
dongsheng@627 11099 "environment variables when running a hook. This is useful to remember if you "
dongsheng@627 11100 "are writing a site-wide hook that may be run by a number of different users "
dongsheng@627 11101 "with differing environment variables set. In multi-user situations, you "
dongsheng@627 11102 "should not rely on environment variables being set to the values you have in "
dongsheng@627 11103 "your environment when testing the hook."
dongsheng@627 11104 msgstr ""
dongsheng@627 11105
dongsheng@627 11106 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11107 #: ../en/ch09-hook.xml:561
dongsheng@627 11108 msgid "Telling Mercurial to use an in-process hook"
dongsheng@642 11109 msgstr "让 Mercurial 使用进程内钩子"
dongsheng@627 11110
dongsheng@627 11111 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11112 #: ../en/ch09-hook.xml:563
dongsheng@650 11113 msgid ""
dongsheng@650 11114 "The <filename role=\"special\">~/.hgrc</filename> syntax for defining an in-"
dongsheng@627 11115 "process hook is slightly different than for an executable hook. The value of "
dongsheng@627 11116 "the hook must start with the text <quote><literal>python:</literal></quote>, "
dongsheng@627 11117 "and continue with the fully-qualified name of a callable object to use as the "
dongsheng@627 11118 "hook's value."
dongsheng@627 11119 msgstr ""
dongsheng@627 11120
dongsheng@627 11121 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11122 #: ../en/ch09-hook.xml:571
dongsheng@627 11123 msgid ""
dongsheng@627 11124 "The module in which a hook lives is automatically imported when a hook is "
dongsheng@627 11125 "run. So long as you have the module name and <envar>PYTHONPATH</envar> "
dongsheng@627 11126 "right, it should <quote>just work</quote>."
dongsheng@627 11127 msgstr ""
dongsheng@627 11128
dongsheng@627 11129 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11130 #: ../en/ch09-hook.xml:577
dongsheng@650 11131 msgid ""
dongsheng@650 11132 "The following <filename role=\"special\">~/.hgrc</filename> example snippet "
dongsheng@627 11133 "illustrates the syntax and meaning of the notions we just described."
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:583
dongsheng@627 11138 msgid ""
dongsheng@627 11139 "When Mercurial runs the <literal>commit.example</literal> hook, it imports "
dongsheng@627 11140 "<literal>mymodule.submodule</literal>, looks for the callable object named "
dongsheng@627 11141 "<literal>myhook</literal>, and calls it."
dongsheng@627 11142 msgstr ""
dongsheng@627 11143
dongsheng@627 11144 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11145 #: ../en/ch09-hook.xml:591
dongsheng@627 11146 msgid "Writing an in-process hook"
dongsheng@635 11147 msgstr "编写进程内钩子"
dongsheng@627 11148
dongsheng@627 11149 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11150 #: ../en/ch09-hook.xml:593
dongsheng@627 11151 msgid ""
dongsheng@627 11152 "The simplest in-process hook does nothing, but illustrates the basic shape of "
dongsheng@627 11153 "the hook API:"
dongsheng@627 11154 msgstr ""
dongsheng@627 11155
dongsheng@627 11156 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11157 #: ../en/ch09-hook.xml:598
dongsheng@627 11158 msgid ""
dongsheng@627 11159 "The first argument to a Python hook is always a <literal role=\"py-mod-"
dongsheng@627 11160 "mercurial.ui\">ui</literal> object. The second is a repository object; at "
dongsheng@627 11161 "the moment, it is always an instance of <literal role=\"py-mod-mercurial."
dongsheng@627 11162 "localrepo\">localrepository</literal>. Following these two arguments are "
dongsheng@627 11163 "other keyword arguments. Which ones are passed in depends on the hook being "
dongsheng@627 11164 "called, but a hook can ignore arguments it doesn't care about by dropping "
dongsheng@627 11165 "them into a keyword argument dict, as with <literal>**kwargs</literal> above."
dongsheng@627 11166 msgstr ""
dongsheng@627 11167
dongsheng@627 11168 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 11169 #: ../en/ch09-hook.xml:613
dongsheng@627 11170 msgid "Some hook examples"
dongsheng@635 11171 msgstr "钩子样例"
dongsheng@627 11172
dongsheng@627 11173 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11174 #: ../en/ch09-hook.xml:616
dongsheng@627 11175 msgid "Writing meaningful commit messages"
dongsheng@635 11176 msgstr "编写有意义的提交日志"
dongsheng@627 11177
dongsheng@627 11178 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11179 #: ../en/ch09-hook.xml:618
dongsheng@627 11180 msgid ""
dongsheng@627 11181 "It's hard to imagine a useful commit message being very short. The simple "
dongsheng@627 11182 "<literal role=\"hook\">pretxncommit</literal> hook of the example below will "
dongsheng@627 11183 "prevent you from committing a changeset with a message that is less than ten "
dongsheng@627 11184 "bytes long."
dongsheng@627 11185 msgstr ""
dongsheng@627 11186
dongsheng@627 11187 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11188 #: ../en/ch09-hook.xml:628
dongsheng@627 11189 msgid "Checking for trailing whitespace"
dongsheng@635 11190 msgstr "检查行尾空格"
dongsheng@627 11191
dongsheng@627 11192 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11193 #: ../en/ch09-hook.xml:630
dongsheng@627 11194 msgid ""
dongsheng@627 11195 "An interesting use of a commit-related hook is to help you to write cleaner "
dongsheng@627 11196 "code. A simple example of <quote>cleaner code</quote> is the dictum that a "
dongsheng@627 11197 "change should not add any new lines of text that contain <quote>trailing "
dongsheng@627 11198 "whitespace</quote>. Trailing whitespace is a series of space and tab "
dongsheng@627 11199 "characters at the end of a line of text. In most cases, trailing whitespace "
dongsheng@627 11200 "is unnecessary, invisible noise, but it is occasionally problematic, and "
dongsheng@627 11201 "people often prefer to get rid of it."
dongsheng@627 11202 msgstr ""
dongsheng@627 11203
dongsheng@627 11204 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11205 #: ../en/ch09-hook.xml:641
dongsheng@627 11206 msgid ""
dongsheng@627 11207 "You can use either the <literal role=\"hook\">precommit</literal> or <literal "
dongsheng@627 11208 "role=\"hook\">pretxncommit</literal> hook to tell whether you have a trailing "
dongsheng@627 11209 "whitespace problem. If you use the <literal role=\"hook\">precommit</"
dongsheng@627 11210 "literal> hook, the hook will not know which files you are committing, so it "
dongsheng@627 11211 "will have to check every modified file in the repository for trailing white "
dongsheng@627 11212 "space. If you want to commit a change to just the file <filename>foo</"
dongsheng@627 11213 "filename>, but the file <filename>bar</filename> contains trailing "
dongsheng@627 11214 "whitespace, doing a check in the <literal role=\"hook\">precommit</literal> "
dongsheng@627 11215 "hook will prevent you from committing <filename>foo</filename> due to the "
dongsheng@627 11216 "problem with <filename>bar</filename>. This doesn't seem right."
dongsheng@627 11217 msgstr ""
dongsheng@627 11218
dongsheng@627 11219 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11220 #: ../en/ch09-hook.xml:657
dongsheng@627 11221 msgid ""
dongsheng@627 11222 "Should you choose the <literal role=\"hook\">pretxncommit</literal> hook, the "
dongsheng@627 11223 "check won't occur until just before the transaction for the commit "
dongsheng@627 11224 "completes. This will allow you to check for problems only the exact files "
dongsheng@627 11225 "that are being committed. However, if you entered the commit message "
dongsheng@627 11226 "interactively and the hook fails, the transaction will roll back; you'll have "
dongsheng@627 11227 "to re-enter the commit message after you fix the trailing whitespace and run "
dongsheng@627 11228 "<command role=\"hg-cmd\">hg commit</command> again."
dongsheng@627 11229 msgstr ""
dongsheng@627 11230
dongsheng@627 11231 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11232 #: ../en/ch09-hook.xml:670
dongsheng@627 11233 msgid ""
dongsheng@627 11234 "In this example, we introduce a simple <literal role=\"hook\">pretxncommit</"
dongsheng@627 11235 "literal> hook that checks for trailing whitespace. This hook is short, but "
dongsheng@627 11236 "not very helpful. It exits with an error status if a change adds a line with "
dongsheng@627 11237 "trailing whitespace to any file, but does not print any information that "
dongsheng@627 11238 "might help us to identify the offending file or line. It also has the nice "
dongsheng@627 11239 "property of not paying attention to unmodified lines; only lines that "
dongsheng@627 11240 "introduce new trailing whitespace cause problems."
dongsheng@627 11241 msgstr ""
dongsheng@627 11242
dongsheng@627 11243 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11244 #: ../en/ch09-hook.xml:681
dongsheng@627 11245 msgid ""
dongsheng@627 11246 "The above version is much more complex, but also more useful. It parses a "
dongsheng@627 11247 "unified diff to see if any lines add trailing whitespace, and prints the name "
dongsheng@627 11248 "of the file and the line number of each such occurrence. Even better, if the "
dongsheng@627 11249 "change adds trailing whitespace, this hook saves the commit comment and "
dongsheng@627 11250 "prints the name of the save file before exiting and telling Mercurial to roll "
dongsheng@627 11251 "the transaction back, so you can use the <option role=\"hg-opt-commit\">-l "
dongsheng@627 11252 "filename</option> option to <command role=\"hg-cmd\">hg commit</command> to "
dongsheng@627 11253 "reuse the saved commit message once you've corrected the problem."
dongsheng@627 11254 msgstr ""
dongsheng@627 11255
dongsheng@627 11256 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11257 #: ../en/ch09-hook.xml:695
dongsheng@627 11258 msgid ""
dongsheng@627 11259 "As a final aside, note in the example above the use of <command>perl</"
dongsheng@627 11260 "command>'s in-place editing feature to get rid of trailing whitespace from a "
dongsheng@627 11261 "file. This is concise and useful enough that I will reproduce it here."
dongsheng@627 11262 msgstr ""
dongsheng@627 11263
dongsheng@627 11264 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 11265 #: ../en/ch09-hook.xml:705
dongsheng@627 11266 msgid "Bundled hooks"
dongsheng@635 11267 msgstr "内置的钩子"
dongsheng@627 11268
dongsheng@627 11269 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 11270 #: ../en/ch09-hook.xml:707
dongsheng@627 11271 msgid ""
dongsheng@627 11272 "Mercurial ships with several bundled hooks. You can find them in the "
dongsheng@627 11273 "<filename class=\"directory\">hgext</filename> directory of a Mercurial "
dongsheng@627 11274 "source tree. If you are using a Mercurial binary package, the hooks will be "
dongsheng@627 11275 "located in the <filename class=\"directory\">hgext</filename> directory of "
dongsheng@627 11276 "wherever your package installer put Mercurial."
dongsheng@627 11277 msgstr ""
dongsheng@627 11278
dongsheng@627 11279 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11280 #: ../en/ch09-hook.xml:716
songdongsheng@667 11281 #, fuzzy
dongsheng@627 11282 msgid ""
dongsheng@661 11283 "<literal role=\"hg-ext\">acl</literal>—access control for parts of a "
dongsheng@627 11284 "repository"
dongsheng@661 11285 msgstr "<literal role=\"hg-ext\">acl</literal>—版本库的访问控制"
dongsheng@627 11286
dongsheng@627 11287 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11288 #: ../en/ch09-hook.xml:719
dongsheng@627 11289 msgid ""
dongsheng@627 11290 "The <literal role=\"hg-ext\">acl</literal> extension lets you control which "
dongsheng@627 11291 "remote users are allowed to push changesets to a networked server. You can "
dongsheng@627 11292 "protect any portion of a repository (including the entire repo), so that a "
dongsheng@627 11293 "specific remote user can push changes that do not affect the protected "
dongsheng@627 11294 "portion."
dongsheng@627 11295 msgstr ""
dongsheng@627 11296
dongsheng@627 11297 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11298 #: ../en/ch09-hook.xml:727
dongsheng@627 11299 msgid ""
dongsheng@627 11300 "This extension implements access control based on the identity of the user "
dongsheng@627 11301 "performing a push, <emphasis>not</emphasis> on who committed the changesets "
dongsheng@627 11302 "they're pushing. It makes sense to use this hook only if you have a locked-"
dongsheng@627 11303 "down server environment that authenticates remote users, and you want to be "
dongsheng@627 11304 "sure that only specific users are allowed to push changes to that server."
dongsheng@627 11305 msgstr ""
dongsheng@627 11306
dongsheng@627 11307 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11308 #: ../en/ch09-hook.xml:737
dongsheng@627 11309 msgid "Configuring the <literal role=\"hook\">acl</literal> hook"
dongsheng@635 11310 msgstr "配置 <literal role=\"hook\">acl</literal> 钩子"
dongsheng@627 11311
dongsheng@627 11312 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11313 #: ../en/ch09-hook.xml:740
dongsheng@627 11314 msgid ""
dongsheng@627 11315 "In order to manage incoming changesets, the <literal role=\"hg-ext\">acl</"
dongsheng@627 11316 "literal> hook must be used as a <literal role=\"hook\">pretxnchangegroup</"
dongsheng@627 11317 "literal> hook. This lets it see which files are modified by each incoming "
dongsheng@627 11318 "changeset, and roll back a group of changesets if they modify "
dongsheng@627 11319 "<quote>forbidden</quote> files. Example:"
dongsheng@627 11320 msgstr ""
dongsheng@627 11321
dongsheng@627 11322 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11323 #: ../en/ch09-hook.xml:750
dongsheng@627 11324 msgid ""
dongsheng@627 11325 "The <literal role=\"hg-ext\">acl</literal> extension is configured using "
dongsheng@627 11326 "three sections."
dongsheng@627 11327 msgstr ""
dongsheng@627 11328
dongsheng@627 11329 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11330 #: ../en/ch09-hook.xml:754
dongsheng@627 11331 msgid ""
dongsheng@627 11332 "The <literal role=\"rc-acl\">acl</literal> section has only one entry, <envar "
dongsheng@627 11333 "role=\"rc-item-acl\">sources</envar>, which lists the sources of incoming "
dongsheng@627 11334 "changesets that the hook should pay attention to. You don't normally need to "
dongsheng@627 11335 "configure this section."
dongsheng@627 11336 msgstr ""
dongsheng@627 11337
dongsheng@627 11338 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11339 #: ../en/ch09-hook.xml:761
dongsheng@627 11340 msgid ""
dongsheng@627 11341 "<envar role=\"rc-item-acl\">serve</envar>: Control incoming changesets that "
dongsheng@627 11342 "are arriving from a remote repository over http or ssh. This is the default "
dongsheng@627 11343 "value of <envar role=\"rc-item-acl\">sources</envar>, and usually the only "
dongsheng@627 11344 "setting you'll need for this configuration item."
dongsheng@627 11345 msgstr ""
dongsheng@627 11346
dongsheng@627 11347 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11348 #: ../en/ch09-hook.xml:769
dongsheng@627 11349 msgid ""
dongsheng@627 11350 "<envar role=\"rc-item-acl\">pull</envar>: Control incoming changesets that "
dongsheng@627 11351 "are arriving via a pull from a local repository."
dongsheng@627 11352 msgstr ""
dongsheng@627 11353
dongsheng@627 11354 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11355 #: ../en/ch09-hook.xml:774
dongsheng@627 11356 msgid ""
dongsheng@627 11357 "<envar role=\"rc-item-acl\">push</envar>: Control incoming changesets that "
dongsheng@627 11358 "are arriving via a push from a local repository."
dongsheng@627 11359 msgstr ""
dongsheng@627 11360
dongsheng@627 11361 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11362 #: ../en/ch09-hook.xml:779
dongsheng@627 11363 msgid ""
dongsheng@627 11364 "<envar role=\"rc-item-acl\">bundle</envar>: Control incoming changesets that "
dongsheng@627 11365 "are arriving from another repository via a bundle."
dongsheng@627 11366 msgstr ""
dongsheng@627 11367
dongsheng@627 11368 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11369 #: ../en/ch09-hook.xml:785
dongsheng@627 11370 msgid ""
dongsheng@627 11371 "The <literal role=\"rc-acl.allow\">acl.allow</literal> section controls the "
dongsheng@627 11372 "users that are allowed to add changesets to the repository. If this section "
dongsheng@627 11373 "is not present, all users that are not explicitly denied are allowed. If "
dongsheng@627 11374 "this section is present, all users that are not explicitly allowed are denied "
dongsheng@627 11375 "(so an empty section means that all users are denied)."
dongsheng@627 11376 msgstr ""
dongsheng@627 11377
dongsheng@627 11378 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11379 #: ../en/ch09-hook.xml:794
dongsheng@627 11380 msgid ""
dongsheng@627 11381 "The <literal role=\"rc-acl.deny\">acl.deny</literal> section determines which "
dongsheng@627 11382 "users are denied from adding changesets to the repository. If this section "
dongsheng@627 11383 "is not present or is empty, no users are denied."
dongsheng@627 11384 msgstr ""
dongsheng@627 11385
dongsheng@627 11386 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11387 #: ../en/ch09-hook.xml:800
dongsheng@627 11388 msgid ""
dongsheng@627 11389 "The syntaxes for the <literal role=\"rc-acl.allow\">acl.allow</literal> and "
dongsheng@627 11390 "<literal role=\"rc-acl.deny\">acl.deny</literal> sections are identical. On "
dongsheng@627 11391 "the left of each entry is a glob pattern that matches files or directories, "
dongsheng@627 11392 "relative to the root of the repository; on the right, a user name."
dongsheng@627 11393 msgstr ""
dongsheng@627 11394
dongsheng@627 11395 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11396 #: ../en/ch09-hook.xml:808
dongsheng@627 11397 msgid ""
dongsheng@627 11398 "In the following example, the user <literal>docwriter</literal> can only push "
dongsheng@627 11399 "changes to the <filename class=\"directory\">docs</filename> subtree of the "
dongsheng@627 11400 "repository, while <literal>intern</literal> can push changes to any file or "
dongsheng@627 11401 "directory except <filename class=\"directory\">source/sensitive</filename>."
dongsheng@627 11402 msgstr ""
dongsheng@627 11403
dongsheng@627 11404 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 11405 #: ../en/ch09-hook.xml:822 ../en/ch09-hook.xml:1089 ../en/ch09-hook.xml:1279
dongsheng@627 11406 msgid "Testing and troubleshooting"
dongsheng@635 11407 msgstr "测试与问题处理"
dongsheng@627 11408
dongsheng@627 11409 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11410 #: ../en/ch09-hook.xml:824
dongsheng@627 11411 msgid ""
dongsheng@627 11412 "If you want to test the <literal role=\"hg-ext\">acl</literal> hook, run it "
dongsheng@627 11413 "with Mercurial's debugging output enabled. Since you'll probably be running "
dongsheng@627 11414 "it on a server where it's not convenient (or sometimes possible) to pass in "
dongsheng@627 11415 "the <option role=\"hg-opt-global\">--debug</option> option, don't forget that "
dongsheng@650 11416 "you can enable debugging output in your <filename role=\"special\">~/.hgrc</"
dongsheng@627 11417 "filename>:"
dongsheng@627 11418 msgstr ""
dongsheng@627 11419
dongsheng@627 11420 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11421 #: ../en/ch09-hook.xml:835
dongsheng@627 11422 msgid ""
dongsheng@627 11423 "With this enabled, the <literal role=\"hg-ext\">acl</literal> hook will print "
dongsheng@627 11424 "enough information to let you figure out why it is allowing or forbidding "
dongsheng@627 11425 "pushes from specific users."
dongsheng@627 11426 msgstr ""
dongsheng@627 11427
dongsheng@627 11428 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11429 #: ../en/ch09-hook.xml:844
songdongsheng@667 11430 #, fuzzy
dongsheng@661 11431 msgid "<literal role=\"hg-ext\">bugzilla</literal>—integration with Bugzilla"
dongsheng@661 11432 msgstr "<literal role=\"hg-ext\">bugzilla</literal>—与 Bugzilla 的集成"
dongsheng@627 11433
dongsheng@627 11434 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11435 #: ../en/ch09-hook.xml:848
dongsheng@627 11436 msgid ""
dongsheng@627 11437 "The <literal role=\"hg-ext\">bugzilla</literal> extension adds a comment to a "
dongsheng@627 11438 "Bugzilla bug whenever it finds a reference to that bug ID in a commit "
dongsheng@627 11439 "comment. You can install this hook on a shared server, so that any time a "
dongsheng@627 11440 "remote user pushes changes to this server, the hook gets run."
dongsheng@627 11441 msgstr ""
dongsheng@627 11442
dongsheng@627 11443 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11444 #: ../en/ch09-hook.xml:855
dongsheng@627 11445 msgid ""
dongsheng@627 11446 "It adds a comment to the bug that looks like this (you can configure the "
dongsheng@661 11447 "contents of the comment—see below):"
dongsheng@627 11448 msgstr ""
dongsheng@627 11449
dongsheng@627 11450 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11451 #: ../en/ch09-hook.xml:864
dongsheng@627 11452 msgid ""
dongsheng@627 11453 "The value of this hook is that it automates the process of updating a bug any "
dongsheng@627 11454 "time a changeset refers to it. If you configure the hook properly, it makes "
dongsheng@627 11455 "it easy for people to browse straight from a Bugzilla bug to a changeset that "
dongsheng@627 11456 "refers to that bug."
dongsheng@627 11457 msgstr ""
dongsheng@627 11458
dongsheng@627 11459 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11460 #: ../en/ch09-hook.xml:871
dongsheng@627 11461 msgid ""
dongsheng@627 11462 "You can use the code in this hook as a starting point for some more exotic "
dongsheng@627 11463 "Bugzilla integration recipes. Here are a few possibilities:"
dongsheng@627 11464 msgstr ""
dongsheng@627 11465
dongsheng@627 11466 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 11467 #: ../en/ch09-hook.xml:876
dongsheng@627 11468 msgid ""
dongsheng@627 11469 "Require that every changeset pushed to the server have a valid bug ID in its "
dongsheng@627 11470 "commit comment. In this case, you'd want to configure the hook as a <literal "
dongsheng@627 11471 "role=\"hook\">pretxncommit</literal> hook. This would allow the hook to "
dongsheng@627 11472 "reject changes that didn't contain bug IDs."
dongsheng@627 11473 msgstr ""
dongsheng@627 11474
dongsheng@627 11475 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 11476 #: ../en/ch09-hook.xml:884
dongsheng@627 11477 msgid ""
dongsheng@627 11478 "Allow incoming changesets to automatically modify the <emphasis>state</"
dongsheng@627 11479 "emphasis> of a bug, as well as simply adding a comment. For example, the "
dongsheng@627 11480 "hook could recognise the string <quote>fixed bug 31337</quote> as indicating "
dongsheng@627 11481 "that it should update the state of bug 31337 to <quote>requires testing</"
dongsheng@627 11482 "quote>."
dongsheng@627 11483 msgstr ""
dongsheng@627 11484
dongsheng@627 11485 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11486 #: ../en/ch09-hook.xml:894
dongsheng@627 11487 msgid "Configuring the <literal role=\"hook\">bugzilla</literal> hook"
dongsheng@635 11488 msgstr "配置 <literal role=\"hook\">bugzilla</literal> 钩子"
dongsheng@627 11489
dongsheng@627 11490 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11491 #: ../en/ch09-hook.xml:897
dongsheng@650 11492 msgid ""
dongsheng@650 11493 "You should configure this hook in your server's <filename role=\"special\">~/."
dongsheng@650 11494 "hgrc</filename> as an <literal role=\"hook\">incoming</literal> hook, for "
dongsheng@627 11495 "example as follows:"
dongsheng@627 11496 msgstr ""
dongsheng@627 11497
dongsheng@627 11498 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11499 #: ../en/ch09-hook.xml:905
dongsheng@627 11500 msgid ""
dongsheng@627 11501 "Because of the specialised nature of this hook, and because Bugzilla was not "
dongsheng@627 11502 "written with this kind of integration in mind, configuring this hook is a "
dongsheng@627 11503 "somewhat involved process."
dongsheng@627 11504 msgstr ""
dongsheng@627 11505
dongsheng@627 11506 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11507 #: ../en/ch09-hook.xml:911
dongsheng@627 11508 msgid ""
dongsheng@627 11509 "Before you begin, you must install the MySQL bindings for Python on the host"
dongsheng@627 11510 "(s) where you'll be running the hook. If this is not available as a binary "
dongsheng@627 11511 "package for your system, you can download it from <citation>web:mysql-python</"
dongsheng@627 11512 "citation>."
dongsheng@627 11513 msgstr ""
dongsheng@627 11514
dongsheng@627 11515 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11516 #: ../en/ch09-hook.xml:918
dongsheng@627 11517 msgid ""
dongsheng@627 11518 "Configuration information for this hook lives in the <literal role=\"rc-"
dongsheng@650 11519 "bugzilla\">bugzilla</literal> section of your <filename role=\"special\">~/."
dongsheng@627 11520 "hgrc</filename>."
dongsheng@627 11521 msgstr ""
dongsheng@627 11522
dongsheng@627 11523 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11524 #: ../en/ch09-hook.xml:923
dongsheng@627 11525 msgid ""
dongsheng@627 11526 "<envar role=\"rc-item-bugzilla\">version</envar>: The version of Bugzilla "
dongsheng@627 11527 "installed on the server. The database schema that Bugzilla uses changes "
dongsheng@627 11528 "occasionally, so this hook has to know exactly which schema to use. At the "
dongsheng@627 11529 "moment, the only version supported is <literal>2.16</literal>."
dongsheng@627 11530 msgstr ""
dongsheng@627 11531
dongsheng@627 11532 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11533 #: ../en/ch09-hook.xml:932
dongsheng@627 11534 msgid ""
dongsheng@627 11535 "<envar role=\"rc-item-bugzilla\">host</envar>: The hostname of the MySQL "
dongsheng@627 11536 "server that stores your Bugzilla data. The database must be configured to "
dongsheng@627 11537 "allow connections from whatever host you are running the <literal role=\"hook"
dongsheng@627 11538 "\">bugzilla</literal> hook on."
dongsheng@627 11539 msgstr ""
dongsheng@627 11540
dongsheng@627 11541 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11542 #: ../en/ch09-hook.xml:939
dongsheng@627 11543 msgid ""
dongsheng@627 11544 "<envar role=\"rc-item-bugzilla\">user</envar>: The username with which to "
dongsheng@627 11545 "connect to the MySQL server. The database must be configured to allow this "
dongsheng@627 11546 "user to connect from whatever host you are running the <literal role=\"hook"
dongsheng@627 11547 "\">bugzilla</literal> hook on. This user must be able to access and modify "
dongsheng@627 11548 "Bugzilla tables. The default value of this item is <literal>bugs</literal>, "
dongsheng@627 11549 "which is the standard name of the Bugzilla user in a MySQL database."
dongsheng@627 11550 msgstr ""
dongsheng@627 11551
dongsheng@627 11552 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11553 #: ../en/ch09-hook.xml:950
dongsheng@627 11554 msgid ""
dongsheng@627 11555 "<envar role=\"rc-item-bugzilla\">password</envar>: The MySQL password for the "
dongsheng@627 11556 "user you configured above. This is stored as plain text, so you should make "
dongsheng@650 11557 "sure that unauthorised users cannot read the <filename role=\"special\">~/."
dongsheng@650 11558 "hgrc</filename> file where you store this information."
dongsheng@627 11559 msgstr ""
dongsheng@627 11560
dongsheng@627 11561 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11562 #: ../en/ch09-hook.xml:959
dongsheng@627 11563 msgid ""
dongsheng@627 11564 "<envar role=\"rc-item-bugzilla\">db</envar>: The name of the Bugzilla "
dongsheng@627 11565 "database on the MySQL server. The default value of this item is "
dongsheng@627 11566 "<literal>bugs</literal>, which is the standard name of the MySQL database "
dongsheng@627 11567 "where Bugzilla stores its data."
dongsheng@627 11568 msgstr ""
dongsheng@627 11569
dongsheng@627 11570 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11571 #: ../en/ch09-hook.xml:966
dongsheng@627 11572 msgid ""
dongsheng@627 11573 "<envar role=\"rc-item-bugzilla\">notify</envar>: If you want Bugzilla to send "
dongsheng@627 11574 "out a notification email to subscribers after this hook has added a comment "
dongsheng@627 11575 "to a bug, you will need this hook to run a command whenever it updates the "
dongsheng@627 11576 "database. The command to run depends on where you have installed Bugzilla, "
dongsheng@627 11577 "but it will typically look something like this, if you have Bugzilla "
dongsheng@627 11578 "installed in <filename class=\"directory\">/var/www/html/bugzilla</filename>:"
dongsheng@627 11579 msgstr ""
dongsheng@627 11580
dongsheng@627 11581 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11582 #: ../en/ch09-hook.xml:979
dongsheng@627 11583 msgid ""
dongsheng@627 11584 "The Bugzilla <literal>processmail</literal> program expects to be given a bug "
dongsheng@627 11585 "ID (the hook replaces <quote><literal>%s</literal></quote> with the bug ID) "
dongsheng@627 11586 "and an email address. It also expects to be able to write to some files in "
dongsheng@627 11587 "the directory that it runs in. If Bugzilla and this hook are not installed "
dongsheng@627 11588 "on the same machine, you will need to find a way to run <literal>processmail</"
dongsheng@627 11589 "literal> on the server where Bugzilla is installed."
dongsheng@627 11590 msgstr ""
dongsheng@627 11591
dongsheng@627 11592 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11593 #: ../en/ch09-hook.xml:994
dongsheng@627 11594 msgid "Mapping committer names to Bugzilla user names"
dongsheng@635 11595 msgstr "提交者的名称与 Bugzilla 用户名称的映射"
dongsheng@627 11596
dongsheng@627 11597 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11598 #: ../en/ch09-hook.xml:996
dongsheng@627 11599 msgid ""
dongsheng@627 11600 "By default, the <literal role=\"hg-ext\">bugzilla</literal> hook tries to use "
dongsheng@627 11601 "the email address of a changeset's committer as the Bugzilla user name with "
dongsheng@627 11602 "which to update a bug. If this does not suit your needs, you can map "
dongsheng@627 11603 "committer email addresses to Bugzilla user names using a <literal role=\"rc-"
dongsheng@627 11604 "usermap\">usermap</literal> section."
dongsheng@627 11605 msgstr ""
dongsheng@627 11606
dongsheng@627 11607 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11608 #: ../en/ch09-hook.xml:1005
dongsheng@627 11609 msgid ""
dongsheng@627 11610 "Each item in the <literal role=\"rc-usermap\">usermap</literal> section "
dongsheng@627 11611 "contains an email address on the left, and a Bugzilla user name on the right."
dongsheng@627 11612 msgstr ""
dongsheng@627 11613
dongsheng@627 11614 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11615 #: ../en/ch09-hook.xml:1012
dongsheng@627 11616 msgid ""
dongsheng@627 11617 "You can either keep the <literal role=\"rc-usermap\">usermap</literal> data "
dongsheng@627 11618 "in a normal <filename role=\"special\">~/.hgrc</filename>, or tell the "
dongsheng@627 11619 "<literal role=\"hg-ext\">bugzilla</literal> hook to read the information from "
dongsheng@627 11620 "an external <filename>usermap</filename> file. In the latter case, you can "
dongsheng@627 11621 "store <filename>usermap</filename> data by itself in (for example) a user-"
dongsheng@627 11622 "modifiable repository. This makes it possible to let your users maintain "
dongsheng@627 11623 "their own <envar role=\"rc-item-bugzilla\">usermap</envar> entries. The main "
dongsheng@650 11624 "<filename role=\"special\">~/.hgrc</filename> file might look like this:"
dongsheng@627 11625 msgstr ""
dongsheng@627 11626
dongsheng@627 11627 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11628 #: ../en/ch09-hook.xml:1028
dongsheng@627 11629 msgid ""
dongsheng@627 11630 "While the <filename>usermap</filename> file that it refers to might look like "
dongsheng@627 11631 "this:"
dongsheng@627 11632 msgstr ""
dongsheng@627 11633
dongsheng@627 11634 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11635 #: ../en/ch09-hook.xml:1036
dongsheng@627 11636 msgid "Configuring the text that gets added to a bug"
dongsheng@635 11637 msgstr "配置增加到问题中的正文"
dongsheng@627 11638
dongsheng@627 11639 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11640 #: ../en/ch09-hook.xml:1038
dongsheng@627 11641 msgid ""
dongsheng@627 11642 "You can configure the text that this hook adds as a comment; you specify it "
dongsheng@650 11643 "in the form of a Mercurial template. Several <filename role=\"special\">~/."
dongsheng@650 11644 "hgrc</filename> entries (still in the <literal role=\"rc-bugzilla\">bugzilla</"
dongsheng@650 11645 "literal> section) control this behaviour."
dongsheng@627 11646 msgstr ""
dongsheng@627 11647
dongsheng@627 11648 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11649 #: ../en/ch09-hook.xml:1045
dongsheng@627 11650 msgid ""
dongsheng@627 11651 "<literal>strip</literal>: The number of leading path elements to strip from a "
dongsheng@627 11652 "repository's path name to construct a partial path for a URL. For example, if "
dongsheng@627 11653 "the repositories on your server live under <filename class=\"directory\">/"
dongsheng@627 11654 "home/hg/repos</filename>, and you have a repository whose path is <filename "
dongsheng@627 11655 "class=\"directory\">/home/hg/repos/app/tests</filename>, then setting "
dongsheng@627 11656 "<literal>strip</literal> to <literal>4</literal> will give a partial path of "
dongsheng@627 11657 "<filename class=\"directory\">app/tests</filename>. The hook will make this "
dongsheng@627 11658 "partial path available when expanding a template, as <literal>webroot</"
dongsheng@627 11659 "literal>."
dongsheng@627 11660 msgstr ""
dongsheng@627 11661
dongsheng@627 11662 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11663 #: ../en/ch09-hook.xml:1059
dongsheng@627 11664 msgid ""
dongsheng@627 11665 "<literal>template</literal>: The text of the template to use. In addition to "
dongsheng@627 11666 "the usual changeset-related variables, this template can use <literal>hgweb</"
dongsheng@627 11667 "literal> (the value of the <literal>hgweb</literal> configuration item above) "
dongsheng@627 11668 "and <literal>webroot</literal> (the path constructed using <literal>strip</"
dongsheng@627 11669 "literal> above)."
dongsheng@627 11670 msgstr ""
dongsheng@627 11671
dongsheng@627 11672 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11673 #: ../en/ch09-hook.xml:1069
dongsheng@627 11674 msgid ""
dongsheng@627 11675 "In addition, you can add a <envar role=\"rc-item-web\">baseurl</envar> item "
dongsheng@627 11676 "to the <literal role=\"rc-web\">web</literal> section of your <filename role="
dongsheng@650 11677 "\"special\">~/.hgrc</filename>. The <literal role=\"hg-ext\">bugzilla</"
dongsheng@627 11678 "literal> hook will make this available when expanding a template, as the base "
dongsheng@627 11679 "string to use when constructing a URL that will let users browse from a "
dongsheng@627 11680 "Bugzilla comment to view a changeset. Example:"
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:1081
dongsheng@627 11685 msgid ""
dongsheng@627 11686 "Here is an example set of <literal role=\"hg-ext\">bugzilla</literal> hook "
dongsheng@627 11687 "config information."
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:1091
dongsheng@627 11692 msgid ""
dongsheng@627 11693 "The most common problems with configuring the <literal role=\"hg-ext"
dongsheng@627 11694 "\">bugzilla</literal> hook relate to running Bugzilla's "
dongsheng@627 11695 "<filename>processmail</filename> script and mapping committer names to user "
dongsheng@627 11696 "names."
dongsheng@627 11697 msgstr ""
dongsheng@627 11698
dongsheng@627 11699 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11700 #: ../en/ch09-hook.xml:1097
dongsheng@627 11701 msgid ""
songdongsheng@658 11702 "Recall from <xref linkend=\"sec:hook:bugzilla:config\"/> above that the user "
songdongsheng@658 11703 "that runs the Mercurial process on the server is also the one that will run "
songdongsheng@658 11704 "the <filename>processmail</filename> script. The <filename>processmail</"
songdongsheng@658 11705 "filename> script sometimes causes Bugzilla to write to files in its "
songdongsheng@658 11706 "configuration directory, and Bugzilla's configuration files are usually owned "
songdongsheng@658 11707 "by the user that your web server runs under."
dongsheng@627 11708 msgstr ""
dongsheng@627 11709
dongsheng@627 11710 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11711 #: ../en/ch09-hook.xml:1108
dongsheng@627 11712 msgid ""
dongsheng@627 11713 "You can cause <filename>processmail</filename> to be run with the suitable "
dongsheng@627 11714 "user's identity using the <command>sudo</command> command. Here is an "
dongsheng@627 11715 "example entry for a <filename>sudoers</filename> file."
dongsheng@627 11716 msgstr ""
dongsheng@627 11717
dongsheng@627 11718 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11719 #: ../en/ch09-hook.xml:1115
dongsheng@627 11720 msgid ""
dongsheng@627 11721 "This allows the <literal>hg_user</literal> user to run a "
dongsheng@627 11722 "<filename>processmail-wrapper</filename> program under the identity of "
dongsheng@627 11723 "<literal>httpd_user</literal>."
dongsheng@627 11724 msgstr ""
dongsheng@627 11725
dongsheng@627 11726 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11727 #: ../en/ch09-hook.xml:1120
dongsheng@627 11728 msgid ""
dongsheng@627 11729 "This indirection through a wrapper script is necessary, because "
dongsheng@627 11730 "<filename>processmail</filename> expects to be run with its current directory "
dongsheng@627 11731 "set to wherever you installed Bugzilla; you can't specify that kind of "
dongsheng@627 11732 "constraint in a <filename>sudoers</filename> file. The contents of the "
dongsheng@627 11733 "wrapper script are simple:"
dongsheng@627 11734 msgstr ""
dongsheng@627 11735
dongsheng@627 11736 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11737 #: ../en/ch09-hook.xml:1129
dongsheng@627 11738 msgid ""
dongsheng@627 11739 "It doesn't seem to matter what email address you pass to "
dongsheng@627 11740 "<filename>processmail</filename>."
dongsheng@627 11741 msgstr ""
dongsheng@627 11742
dongsheng@627 11743 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11744 #: ../en/ch09-hook.xml:1133
dongsheng@627 11745 msgid ""
dongsheng@627 11746 "If your <literal role=\"rc-usermap\">usermap</literal> is not set up "
dongsheng@627 11747 "correctly, users will see an error message from the <literal role=\"hg-ext"
dongsheng@627 11748 "\">bugzilla</literal> hook when they push changes to the server. The error "
dongsheng@627 11749 "message will look like this:"
dongsheng@627 11750 msgstr ""
dongsheng@627 11751
dongsheng@627 11752 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11753 #: ../en/ch09-hook.xml:1140
dongsheng@627 11754 msgid ""
dongsheng@627 11755 "What this means is that the committer's address, <literal>john.q."
dongsheng@627 11756 "public@example.com</literal>, is not a valid Bugzilla user name, nor does it "
dongsheng@627 11757 "have an entry in your <literal role=\"rc-usermap\">usermap</literal> that "
dongsheng@627 11758 "maps it to a valid Bugzilla user name."
dongsheng@627 11759 msgstr ""
dongsheng@627 11760
dongsheng@627 11761 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 11762 #: ../en/ch09-hook.xml:1150
songdongsheng@667 11763 #, fuzzy
dongsheng@661 11764 msgid "<literal role=\"hg-ext\">notify</literal>—send email notifications"
dongsheng@661 11765 msgstr "<literal role=\"hg-ext\">notify</literal>—邮件通知"
dongsheng@627 11766
dongsheng@627 11767 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11768 #: ../en/ch09-hook.xml:1153
dongsheng@627 11769 msgid ""
dongsheng@627 11770 "Although Mercurial's built-in web server provides RSS feeds of changes in "
dongsheng@627 11771 "every repository, many people prefer to receive change notifications via "
dongsheng@627 11772 "email. The <literal role=\"hg-ext\">notify</literal> hook lets you send out "
dongsheng@627 11773 "notifications to a set of email addresses whenever changesets arrive that "
dongsheng@627 11774 "those subscribers are interested in."
dongsheng@627 11775 msgstr ""
dongsheng@627 11776
dongsheng@627 11777 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11778 #: ../en/ch09-hook.xml:1161
dongsheng@627 11779 msgid ""
dongsheng@627 11780 "As with the <literal role=\"hg-ext\">bugzilla</literal> hook, the <literal "
dongsheng@627 11781 "role=\"hg-ext\">notify</literal> hook is template-driven, so you can "
dongsheng@627 11782 "customise the contents of the notification messages that it sends."
dongsheng@627 11783 msgstr ""
dongsheng@627 11784
dongsheng@627 11785 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 11786 #: ../en/ch09-hook.xml:1167
dongsheng@627 11787 msgid ""
dongsheng@627 11788 "By default, the <literal role=\"hg-ext\">notify</literal> hook includes a "
dongsheng@627 11789 "diff of every changeset that it sends out; you can limit the size of the "
dongsheng@627 11790 "diff, or turn this feature off entirely. It is useful for letting "
dongsheng@627 11791 "subscribers review changes immediately, rather than clicking to follow a URL."
dongsheng@627 11792 msgstr ""
dongsheng@627 11793
dongsheng@627 11794 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
dongsheng@650 11795 #: ../en/ch09-hook.xml:1175
dongsheng@627 11796 msgid "Configuring the <literal role=\"hg-ext\">notify</literal> hook"
dongsheng@635 11797 msgstr "配置 <literal role=\"hg-ext\">notify</literal> 钩子"
dongsheng@627 11798
dongsheng@627 11799 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11800 #: ../en/ch09-hook.xml:1178
dongsheng@627 11801 msgid ""
dongsheng@627 11802 "You can set up the <literal role=\"hg-ext\">notify</literal> hook to send one "
dongsheng@627 11803 "email message per incoming changeset, or one per incoming group of changesets "
dongsheng@627 11804 "(all those that arrived in a single pull or push)."
dongsheng@627 11805 msgstr ""
dongsheng@627 11806
dongsheng@627 11807 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
dongsheng@650 11808 #: ../en/ch09-hook.xml:1190
dongsheng@627 11809 msgid ""
dongsheng@627 11810 "Configuration information for this hook lives in the <literal role=\"rc-notify"
dongsheng@650 11811 "\">notify</literal> section of a <filename role=\"special\">~/.hgrc</"
dongsheng@650 11812 "filename> file."
dongsheng@627 11813 msgstr ""
dongsheng@627 11814
dongsheng@627 11815 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11816 #: ../en/ch09-hook.xml:1195
dongsheng@627 11817 msgid ""
dongsheng@627 11818 "<envar role=\"rc-item-notify\">test</envar>: By default, this hook does not "
dongsheng@627 11819 "send out email at all; instead, it prints the message that it "
dongsheng@627 11820 "<emphasis>would</emphasis> send. Set this item to <literal>false</literal> "
dongsheng@627 11821 "to allow email to be sent. The reason that sending of email is turned off by "
dongsheng@627 11822 "default is that it takes several tries to configure this extension exactly as "
dongsheng@627 11823 "you would like, and it would be bad form to spam subscribers with a number of "
dongsheng@627 11824 "<quote>broken</quote> notifications while you debug your configuration."
dongsheng@627 11825 msgstr ""
dongsheng@627 11826
dongsheng@627 11827 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11828 #: ../en/ch09-hook.xml:1207
dongsheng@627 11829 msgid ""
dongsheng@627 11830 "<envar role=\"rc-item-notify\">config</envar>: The path to a configuration "
dongsheng@627 11831 "file that contains subscription information. This is kept separate from the "
dongsheng@650 11832 "main <filename role=\"special\">~/.hgrc</filename> so that you can maintain "
dongsheng@627 11833 "it in a repository of its own. People can then clone that repository, update "
dongsheng@627 11834 "their subscriptions, and push the changes back to your server."
dongsheng@627 11835 msgstr ""
dongsheng@627 11836
dongsheng@627 11837 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11838 #: ../en/ch09-hook.xml:1216
dongsheng@627 11839 msgid ""
dongsheng@627 11840 "<envar role=\"rc-item-notify\">strip</envar>: The number of leading path "
dongsheng@627 11841 "separator characters to strip from a repository's path, when deciding whether "
dongsheng@627 11842 "a repository has subscribers. For example, if the repositories on your "
dongsheng@627 11843 "server live in <filename class=\"directory\">/home/hg/repos</filename>, and "
dongsheng@627 11844 "<literal role=\"hg-ext\">notify</literal> is considering a repository named "
dongsheng@627 11845 "<filename class=\"directory\">/home/hg/repos/shared/test</filename>, setting "
dongsheng@627 11846 "<envar role=\"rc-item-notify\">strip</envar> to <literal>4</literal> will "
dongsheng@627 11847 "cause <literal role=\"hg-ext\">notify</literal> to trim the path it considers "
dongsheng@627 11848 "down to <filename class=\"directory\">shared/test</filename>, and it will "
dongsheng@627 11849 "match subscribers against that."
dongsheng@627 11850 msgstr ""
dongsheng@627 11851
dongsheng@627 11852 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11853 #: ../en/ch09-hook.xml:1233
dongsheng@627 11854 msgid ""
dongsheng@627 11855 "<envar role=\"rc-item-notify\">template</envar>: The template text to use "
dongsheng@627 11856 "when sending messages. This specifies both the contents of the message "
dongsheng@627 11857 "header and its body."
dongsheng@627 11858 msgstr ""
dongsheng@627 11859
dongsheng@627 11860 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11861 #: ../en/ch09-hook.xml:1239
dongsheng@627 11862 msgid ""
dongsheng@627 11863 "<envar role=\"rc-item-notify\">maxdiff</envar>: The maximum number of lines "
dongsheng@627 11864 "of diff data to append to the end of a message. If a diff is longer than "
dongsheng@627 11865 "this, it is truncated. By default, this is set to 300. Set this to "
dongsheng@627 11866 "<literal>0</literal> to omit diffs from notification emails."
dongsheng@627 11867 msgstr ""
dongsheng@627 11868
dongsheng@627 11869 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
dongsheng@650 11870 #: ../en/ch09-hook.xml:1248
dongsheng@627 11871 msgid ""
dongsheng@627 11872 "<envar role=\"rc-item-notify\">sources</envar>: A list of sources of "
dongsheng@627 11873 "changesets to consider. This lets you limit <literal role=\"hg-ext\">notify</"
dongsheng@627 11874 "literal> to only sending out email about changes that remote users pushed "
songdongsheng@658 11875 "into this repository via a server, for example. See <xref linkend=\"sec:hook:"
songdongsheng@658 11876 "sources\"/> for the sources you can specify here."
dongsheng@627 11877 msgstr ""
dongsheng@627 11878
dongsheng@627 11879 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 11880 #: ../en/ch09-hook.xml:1259
dongsheng@627 11881 msgid ""
dongsheng@627 11882 "If you set the <envar role=\"rc-item-web\">baseurl</envar> item in the "
dongsheng@627 11883 "<literal role=\"rc-web\">web</literal> section, you can use it in a template; "
dongsheng@627 11884 "it will be available as <literal>webroot</literal>."
dongsheng@627 11885 msgstr ""
dongsheng@627 11886
dongsheng@627 11887 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 11888 #: ../en/ch09-hook.xml:1265
dongsheng@627 11889 msgid ""
dongsheng@627 11890 "Here is an example set of <literal role=\"hg-ext\">notify</literal> "
dongsheng@627 11891 "configuration information."
dongsheng@627 11892 msgstr ""
dongsheng@627 11893
dongsheng@627 11894 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 11895 #: ../en/ch09-hook.xml:1271
dongsheng@627 11896 msgid "This will produce a message that looks like the following:"
dongsheng@627 11897 msgstr ""
dongsheng@627 11898
dongsheng@627 11899 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 11900 #: ../en/ch09-hook.xml:1281
dongsheng@627 11901 msgid ""
dongsheng@627 11902 "Do not forget that by default, the <literal role=\"hg-ext\">notify</literal> "
dongsheng@627 11903 "extension <emphasis>will not send any mail</emphasis> until you explicitly "
dongsheng@627 11904 "configure it to do so, by setting <envar role=\"rc-item-notify\">test</envar> "
dongsheng@627 11905 "to <literal>false</literal>. Until you do that, it simply prints the message "
dongsheng@627 11906 "it <emphasis>would</emphasis> send."
dongsheng@627 11907 msgstr ""
dongsheng@627 11908
dongsheng@627 11909 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 11910 #: ../en/ch09-hook.xml:1293
dongsheng@627 11911 msgid "Information for writers of hooks"
dongsheng@635 11912 msgstr "编写钩子的信息"
dongsheng@627 11913
dongsheng@627 11914 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 11915 #: ../en/ch09-hook.xml:1296
dongsheng@627 11916 msgid "In-process hook execution"
dongsheng@635 11917 msgstr "进程内钩子的执行"
dongsheng@627 11918
dongsheng@627 11919 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 11920 #: ../en/ch09-hook.xml:1298
dongsheng@627 11921 msgid "An in-process hook is called with arguments of the following form:"
dongsheng@627 11922 msgstr ""
dongsheng@627 11923
dongsheng@627 11924 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 11925 #: ../en/ch09-hook.xml:1302
dongsheng@627 11926 msgid ""
dongsheng@627 11927 "The <literal>ui</literal> parameter is a <literal role=\"py-mod-mercurial.ui"
dongsheng@627 11928 "\">ui</literal> object. The <literal>repo</literal> parameter is a <literal "
dongsheng@627 11929 "role=\"py-mod-mercurial.localrepo\">localrepository</literal> object. The "
dongsheng@627 11930 "names and values of the <literal>**kwargs</literal> parameters depend on the "
dongsheng@627 11931 "hook being invoked, with the following common features:"
dongsheng@627 11932 msgstr ""
dongsheng@627 11933
dongsheng@627 11934 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 11935 #: ../en/ch09-hook.xml:1311
dongsheng@627 11936 msgid ""
dongsheng@627 11937 "If a parameter is named <literal>node</literal> or <literal>parentN</"
dongsheng@627 11938 "literal>, it will contain a hexadecimal changeset ID. The empty string is "
dongsheng@627 11939 "used to represent <quote>null changeset ID</quote> instead of a string of "
dongsheng@627 11940 "zeroes."
dongsheng@627 11941 msgstr ""
dongsheng@627 11942
dongsheng@627 11943 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 11944 #: ../en/ch09-hook.xml:1318
dongsheng@627 11945 msgid ""
dongsheng@627 11946 "If a parameter is named <literal>url</literal>, it will contain the URL of a "
dongsheng@627 11947 "remote repository, if that can be determined."
dongsheng@627 11948 msgstr ""
dongsheng@627 11949
dongsheng@627 11950 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 11951 #: ../en/ch09-hook.xml:1323
dongsheng@627 11952 msgid ""
dongsheng@627 11953 "Boolean-valued parameters are represented as Python <literal>bool</literal> "
dongsheng@627 11954 "objects."
dongsheng@627 11955 msgstr ""
dongsheng@627 11956
dongsheng@627 11957 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 11958 #: ../en/ch09-hook.xml:1328
dongsheng@627 11959 msgid ""
dongsheng@627 11960 "An in-process hook is called without a change to the process's working "
dongsheng@627 11961 "directory (unlike external hooks, which are run in the root of the "
dongsheng@627 11962 "repository). It must not change the process's working directory, or it will "
dongsheng@627 11963 "cause any calls it makes into the Mercurial API to fail."
dongsheng@627 11964 msgstr ""
dongsheng@627 11965
dongsheng@627 11966 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 11967 #: ../en/ch09-hook.xml:1335
dongsheng@627 11968 msgid ""
dongsheng@627 11969 "If a hook returns a boolean <quote>false</quote> value, it is considered to "
dongsheng@627 11970 "have succeeded. If it returns a boolean <quote>true</quote> value or raises "
dongsheng@627 11971 "an exception, it is considered to have failed. A useful way to think of the "
dongsheng@627 11972 "calling convention is <quote>tell me if you fail</quote>."
dongsheng@627 11973 msgstr ""
dongsheng@627 11974
dongsheng@627 11975 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 11976 #: ../en/ch09-hook.xml:1342
dongsheng@627 11977 msgid ""
dongsheng@627 11978 "Note that changeset IDs are passed into Python hooks as hexadecimal strings, "
dongsheng@627 11979 "not the binary hashes that Mercurial's APIs normally use. To convert a hash "
dongsheng@650 11980 "from hex to binary, use the <literal>bin</literal> function."
dongsheng@650 11981 msgstr ""
dongsheng@650 11982
dongsheng@650 11983 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 11984 #: ../en/ch09-hook.xml:1350
dongsheng@627 11985 msgid "External hook execution"
dongsheng@635 11986 msgstr "外部钩子的执行"
dongsheng@627 11987
dongsheng@627 11988 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 11989 #: ../en/ch09-hook.xml:1352
dongsheng@627 11990 msgid ""
dongsheng@627 11991 "An external hook is passed to the shell of the user running Mercurial. "
dongsheng@627 11992 "Features of that shell, such as variable substitution and command "
dongsheng@627 11993 "redirection, are available. The hook is run in the root directory of the "
dongsheng@627 11994 "repository (unlike in-process hooks, which are run in the same directory that "
dongsheng@627 11995 "Mercurial was run in)."
dongsheng@627 11996 msgstr ""
dongsheng@627 11997
dongsheng@627 11998 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 11999 #: ../en/ch09-hook.xml:1360
dongsheng@627 12000 msgid ""
dongsheng@627 12001 "Hook parameters are passed to the hook as environment variables. Each "
dongsheng@627 12002 "environment variable's name is converted in upper case and prefixed with the "
dongsheng@627 12003 "string <quote><literal>HG_</literal></quote>. For example, if the name of a "
dongsheng@627 12004 "parameter is <quote><literal>node</literal></quote>, the name of the "
dongsheng@627 12005 "environment variable representing that parameter will be "
dongsheng@627 12006 "<quote><literal>HG_NODE</literal></quote>."
dongsheng@627 12007 msgstr ""
dongsheng@627 12008
dongsheng@627 12009 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12010 #: ../en/ch09-hook.xml:1369
dongsheng@627 12011 msgid ""
dongsheng@627 12012 "A boolean parameter is represented as the string <quote><literal>1</literal></"
dongsheng@627 12013 "quote> for <quote>true</quote>, <quote><literal>0</literal></quote> for "
dongsheng@627 12014 "<quote>false</quote>. If an environment variable is named <envar>HG_NODE</"
dongsheng@627 12015 "envar>, <envar>HG_PARENT1</envar> or <envar>HG_PARENT2</envar>, it contains a "
dongsheng@627 12016 "changeset ID represented as a hexadecimal string. The empty string is used "
dongsheng@627 12017 "to represent <quote>null changeset ID</quote> instead of a string of zeroes. "
dongsheng@627 12018 "If an environment variable is named <envar>HG_URL</envar>, it will contain "
dongsheng@627 12019 "the URL of a remote repository, if that can be determined."
dongsheng@627 12020 msgstr ""
dongsheng@627 12021
dongsheng@627 12022 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12023 #: ../en/ch09-hook.xml:1381
dongsheng@627 12024 msgid ""
dongsheng@627 12025 "If a hook exits with a status of zero, it is considered to have succeeded. "
dongsheng@627 12026 "If it exits with a non-zero status, it is considered to have failed."
dongsheng@627 12027 msgstr ""
dongsheng@627 12028
dongsheng@627 12029 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12030 #: ../en/ch09-hook.xml:1388
dongsheng@627 12031 msgid "Finding out where changesets come from"
dongsheng@635 12032 msgstr "检查修改集来自何处"
dongsheng@627 12033
dongsheng@627 12034 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12035 #: ../en/ch09-hook.xml:1390
dongsheng@627 12036 msgid ""
dongsheng@627 12037 "A hook that involves the transfer of changesets between a local repository "
dongsheng@627 12038 "and another may be able to find out information about the <quote>far side</"
dongsheng@627 12039 "quote>. Mercurial knows <emphasis>how</emphasis> changes are being "
dongsheng@627 12040 "transferred, and in many cases <emphasis>where</emphasis> they are being "
dongsheng@627 12041 "transferred to or from."
dongsheng@627 12042 msgstr ""
dongsheng@627 12043
dongsheng@627 12044 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 12045 #: ../en/ch09-hook.xml:1399
dongsheng@627 12046 msgid "Sources of changesets"
dongsheng@635 12047 msgstr "修改集的来源"
dongsheng@627 12048
dongsheng@627 12049 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 12050 #: ../en/ch09-hook.xml:1401
dongsheng@627 12051 msgid ""
dongsheng@627 12052 "Mercurial will tell a hook what means are, or were, used to transfer "
dongsheng@627 12053 "changesets between repositories. This is provided by Mercurial in a Python "
dongsheng@627 12054 "parameter named <literal>source</literal>, or an environment variable named "
dongsheng@627 12055 "<envar>HG_SOURCE</envar>."
dongsheng@627 12056 msgstr ""
dongsheng@627 12057
dongsheng@627 12058 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12059 #: ../en/ch09-hook.xml:1409
dongsheng@627 12060 msgid ""
dongsheng@627 12061 "<literal>serve</literal>: Changesets are transferred to or from a remote "
dongsheng@627 12062 "repository over http or ssh."
dongsheng@627 12063 msgstr ""
dongsheng@627 12064
dongsheng@627 12065 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12066 #: ../en/ch09-hook.xml:1414
dongsheng@627 12067 msgid ""
dongsheng@627 12068 "<literal>pull</literal>: Changesets are being transferred via a pull from one "
dongsheng@627 12069 "repository into another."
dongsheng@627 12070 msgstr ""
dongsheng@627 12071
dongsheng@627 12072 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12073 #: ../en/ch09-hook.xml:1419
dongsheng@627 12074 msgid ""
dongsheng@627 12075 "<literal>push</literal>: Changesets are being transferred via a push from one "
dongsheng@627 12076 "repository into another."
dongsheng@627 12077 msgstr ""
dongsheng@627 12078
dongsheng@627 12079 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12080 #: ../en/ch09-hook.xml:1424
dongsheng@627 12081 msgid ""
dongsheng@627 12082 "<literal>bundle</literal>: Changesets are being transferred to or from a "
dongsheng@627 12083 "bundle."
dongsheng@627 12084 msgstr ""
dongsheng@627 12085
dongsheng@627 12086 #. type: Content of: <book><chapter><sect1><sect2><sect3><title>
songdongsheng@658 12087 #: ../en/ch09-hook.xml:1431
songdongsheng@667 12088 #, fuzzy
dongsheng@661 12089 msgid "Where changes are going—remote repository URLs"
dongsheng@661 12090 msgstr "修改集要到哪里—远程版本库的地址"
dongsheng@627 12091
dongsheng@627 12092 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 12093 #: ../en/ch09-hook.xml:1434
dongsheng@627 12094 msgid ""
dongsheng@627 12095 "When possible, Mercurial will tell a hook the location of the <quote>far "
dongsheng@627 12096 "side</quote> of an activity that transfers changeset data between "
dongsheng@627 12097 "repositories. This is provided by Mercurial in a Python parameter named "
dongsheng@627 12098 "<literal>url</literal>, or an environment variable named <envar>HG_URL</"
dongsheng@627 12099 "envar>."
dongsheng@627 12100 msgstr ""
dongsheng@627 12101
dongsheng@627 12102 #. type: Content of: <book><chapter><sect1><sect2><sect3><para>
songdongsheng@658 12103 #: ../en/ch09-hook.xml:1442
dongsheng@627 12104 msgid ""
dongsheng@627 12105 "This information is not always known. If a hook is invoked in a repository "
dongsheng@627 12106 "that is being served via http or ssh, Mercurial cannot tell where the remote "
dongsheng@627 12107 "repository is, but it may know where the client is connecting from. In such "
dongsheng@627 12108 "cases, the URL will take one of the following forms:"
dongsheng@627 12109 msgstr ""
dongsheng@627 12110
dongsheng@627 12111 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12112 #: ../en/ch09-hook.xml:1449
dongsheng@627 12113 msgid ""
dongsheng@661 12114 "<literal>remote:ssh:1.2.3.4</literal>—remote ssh client, at the IP address "
dongsheng@661 12115 "<literal>1.2.3.4</literal>."
dongsheng@627 12116 msgstr ""
dongsheng@627 12117
dongsheng@627 12118 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12119 #: ../en/ch09-hook.xml:1454
dongsheng@627 12120 msgid ""
dongsheng@661 12121 "<literal>remote:http:1.2.3.4</literal>—remote http client, at the IP address "
dongsheng@661 12122 "<literal>1.2.3.4</literal>. If the client is using SSL, this will be of the "
dongsheng@661 12123 "form <literal>remote:https:1.2.3.4</literal>."
dongsheng@627 12124 msgstr ""
dongsheng@627 12125
dongsheng@627 12126 #. type: Content of: <book><chapter><sect1><sect2><sect3><itemizedlist><listitem><para>
songdongsheng@658 12127 #: ../en/ch09-hook.xml:1461
dongsheng@661 12128 msgid "Empty—no information could be discovered about the remote client."
dongsheng@627 12129 msgstr ""
dongsheng@627 12130
dongsheng@627 12131 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 12132 #: ../en/ch09-hook.xml:1470
dongsheng@627 12133 msgid "Hook reference"
dongsheng@635 12134 msgstr "钩子参考"
dongsheng@627 12135
dongsheng@627 12136 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12137 #: ../en/ch09-hook.xml:1473
songdongsheng@667 12138 #, fuzzy
dongsheng@627 12139 msgid ""
dongsheng@661 12140 "<literal role=\"hook\">changegroup</literal>—after remote changesets added"
dongsheng@661 12141 msgstr "<literal role=\"hook\">changegroup</literal>—增加远程修改集之后"
dongsheng@627 12142
dongsheng@627 12143 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12144 #: ../en/ch09-hook.xml:1476
dongsheng@627 12145 msgid ""
dongsheng@627 12146 "This hook is run after a group of pre-existing changesets has been added to "
dongsheng@627 12147 "the repository, for example via a <command role=\"hg-cmd\">hg pull</command> "
dongsheng@627 12148 "or <command role=\"hg-cmd\">hg unbundle</command>. This hook is run once per "
dongsheng@627 12149 "operation that added one or more changesets. This is in contrast to the "
dongsheng@627 12150 "<literal role=\"hook\">incoming</literal> hook, which is run once per "
dongsheng@627 12151 "changeset, regardless of whether the changesets arrive in a group."
dongsheng@627 12152 msgstr ""
dongsheng@627 12153
dongsheng@627 12154 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12155 #: ../en/ch09-hook.xml:1486
dongsheng@627 12156 msgid ""
dongsheng@627 12157 "Some possible uses for this hook include kicking off an automated build or "
dongsheng@627 12158 "test of the added changesets, updating a bug database, or notifying "
dongsheng@627 12159 "subscribers that a repository contains new changes."
dongsheng@627 12160 msgstr ""
dongsheng@627 12161
dongsheng@627 12162 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12163 #: ../en/ch09-hook.xml:1492 ../en/ch09-hook.xml:1532 ../en/ch09-hook.xml:1576
dongsheng@650 12164 #: ../en/ch09-hook.xml:1618 ../en/ch09-hook.xml:1673 ../en/ch09-hook.xml:1713
songdongsheng@658 12165 #: ../en/ch09-hook.xml:1749 ../en/ch09-hook.xml:1783 ../en/ch09-hook.xml:1846
songdongsheng@658 12166 #: ../en/ch09-hook.xml:1904 ../en/ch09-hook.xml:1940 ../en/ch09-hook.xml:1967
dongsheng@627 12167 msgid "Parameters to this hook:"
dongsheng@627 12168 msgstr ""
dongsheng@627 12169
dongsheng@627 12170 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12171 #: ../en/ch09-hook.xml:1495 ../en/ch09-hook.xml:1849
dongsheng@627 12172 msgid ""
dongsheng@627 12173 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 12174 "changeset in the group that was added. All changesets between this and "
dongsheng@650 12175 "<literal role=\"tag\">tip</literal>, inclusive, were added by a single "
dongsheng@650 12176 "<command role=\"hg-cmd\">hg pull</command>, <command role=\"hg-cmd\">hg push</"
dongsheng@650 12177 "command> or <command role=\"hg-cmd\">hg unbundle</command>."
dongsheng@627 12178 msgstr ""
dongsheng@627 12179
dongsheng@627 12180 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12181 #: ../en/ch09-hook.xml:1504 ../en/ch09-hook.xml:1583 ../en/ch09-hook.xml:1676
dongsheng@650 12182 #: ../en/ch09-hook.xml:1859
dongsheng@627 12183 msgid ""
songdongsheng@658 12184 "<literal>source</literal>: A string. The source of these changes. See <xref "
songdongsheng@658 12185 "linkend=\"sec:hook:sources\"/> for details."
dongsheng@627 12186 msgstr ""
dongsheng@627 12187
dongsheng@627 12188 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12189 #: ../en/ch09-hook.xml:1509 ../en/ch09-hook.xml:1588 ../en/ch09-hook.xml:1639
songdongsheng@658 12190 #: ../en/ch09-hook.xml:1681 ../en/ch09-hook.xml:1762 ../en/ch09-hook.xml:1864
dongsheng@627 12191 msgid ""
dongsheng@627 12192 "<literal>url</literal>: A URL. The location of the remote repository, if "
songdongsheng@658 12193 "known. See <xref linkend=\"sec:hook:url\"/> for more information."
songdongsheng@658 12194 msgstr ""
songdongsheng@658 12195
songdongsheng@658 12196 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12197 #: ../en/ch09-hook.xml:1515
songdongsheng@658 12198 msgid ""
songdongsheng@658 12199 "See also: <literal role=\"hook\">incoming</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12200 "incoming\"/>), <literal role=\"hook\">prechangegroup</literal> (<xref linkend="
songdongsheng@658 12201 "\"sec:hook:prechangegroup\"/>), <literal role=\"hook\">pretxnchangegroup</"
songdongsheng@658 12202 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
dongsheng@627 12203 msgstr ""
dongsheng@627 12204
dongsheng@627 12205 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12206 #: ../en/ch09-hook.xml:1526
songdongsheng@667 12207 #, fuzzy
dongsheng@661 12208 msgid "<literal role=\"hook\">commit</literal>—after a new changeset is created"
dongsheng@661 12209 msgstr "<literal role=\"hook\">commit</literal>—创建新修改集之后"
dongsheng@627 12210
dongsheng@627 12211 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12212 #: ../en/ch09-hook.xml:1529
dongsheng@627 12213 msgid "This hook is run after a new changeset has been created."
dongsheng@627 12214 msgstr ""
dongsheng@627 12215
dongsheng@627 12216 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12217 #: ../en/ch09-hook.xml:1535 ../en/ch09-hook.xml:1907
dongsheng@627 12218 msgid ""
dongsheng@627 12219 "<literal>node</literal>: A changeset ID. The changeset ID of the newly "
dongsheng@627 12220 "committed changeset."
dongsheng@627 12221 msgstr ""
dongsheng@627 12222
dongsheng@627 12223 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12224 #: ../en/ch09-hook.xml:1539 ../en/ch09-hook.xml:1911
dongsheng@627 12225 msgid ""
dongsheng@627 12226 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 12227 "parent of the newly committed changeset."
dongsheng@627 12228 msgstr ""
dongsheng@627 12229
dongsheng@627 12230 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12231 #: ../en/ch09-hook.xml:1544 ../en/ch09-hook.xml:1916
dongsheng@627 12232 msgid ""
dongsheng@627 12233 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
dongsheng@627 12234 "parent of the newly committed changeset."
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:1550
songdongsheng@658 12239 msgid ""
songdongsheng@658 12240 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
songdongsheng@658 12241 "hook:precommit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref "
songdongsheng@658 12242 "linkend=\"sec:hook:pretxncommit\"/>)"
dongsheng@627 12243 msgstr ""
dongsheng@627 12244
dongsheng@627 12245 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12246 #: ../en/ch09-hook.xml:1559
songdongsheng@667 12247 #, fuzzy
dongsheng@627 12248 msgid ""
dongsheng@661 12249 "<literal role=\"hook\">incoming</literal>—after one remote changeset is added"
dongsheng@661 12250 msgstr "<literal role=\"hook\">incoming</literal>—增加远程修改集之后"
dongsheng@627 12251
dongsheng@627 12252 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12253 #: ../en/ch09-hook.xml:1562
dongsheng@627 12254 msgid ""
dongsheng@627 12255 "This hook is run after a pre-existing changeset has been added to the "
dongsheng@627 12256 "repository, for example via a <command role=\"hg-cmd\">hg push</command>. If "
dongsheng@627 12257 "a group of changesets was added in a single operation, this hook is called "
dongsheng@627 12258 "once for each added changeset."
dongsheng@627 12259 msgstr ""
dongsheng@627 12260
dongsheng@627 12261 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12262 #: ../en/ch09-hook.xml:1569
dongsheng@627 12263 msgid ""
dongsheng@627 12264 "You can use this hook for the same purposes as the <literal role=\"hook"
songdongsheng@658 12265 "\">changegroup</literal> hook (<xref linkend=\"sec:hook:changegroup\"/>); "
songdongsheng@658 12266 "it's simply more convenient sometimes to run a hook once per group of "
dongsheng@627 12267 "changesets, while other times it's handier once per changeset."
dongsheng@627 12268 msgstr ""
dongsheng@627 12269
dongsheng@627 12270 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12271 #: ../en/ch09-hook.xml:1579
dongsheng@627 12272 msgid ""
dongsheng@627 12273 "<literal>node</literal>: A changeset ID. The ID of the newly added changeset."
dongsheng@627 12274 msgstr ""
dongsheng@627 12275
dongsheng@627 12276 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12277 #: ../en/ch09-hook.xml:1594
songdongsheng@658 12278 msgid ""
songdongsheng@658 12279 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 12280 "hook:changegroup\"/>) <literal role=\"hook\">prechangegroup</literal> (<xref "
songdongsheng@658 12281 "linkend=\"sec:hook:prechangegroup\"/>), <literal role=\"hook"
songdongsheng@658 12282 "\">pretxnchangegroup</literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/"
songdongsheng@658 12283 ">)"
dongsheng@627 12284 msgstr ""
dongsheng@627 12285
dongsheng@627 12286 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12287 #: ../en/ch09-hook.xml:1605
songdongsheng@667 12288 #, fuzzy
dongsheng@627 12289 msgid ""
dongsheng@661 12290 "<literal role=\"hook\">outgoing</literal>—after changesets are propagated"
dongsheng@661 12291 msgstr "<literal role=\"hook\">outgoing</literal>—传播修改集之后"
dongsheng@627 12292
dongsheng@627 12293 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12294 #: ../en/ch09-hook.xml:1608
dongsheng@627 12295 msgid ""
dongsheng@627 12296 "This hook is run after a group of changesets has been propagated out of this "
dongsheng@627 12297 "repository, for example by a <command role=\"hg-cmd\">hg push</command> or "
dongsheng@627 12298 "<command role=\"hg-cmd\">hg bundle</command> command."
dongsheng@627 12299 msgstr ""
dongsheng@627 12300
dongsheng@627 12301 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12302 #: ../en/ch09-hook.xml:1614
dongsheng@627 12303 msgid ""
dongsheng@627 12304 "One possible use for this hook is to notify administrators that changes have "
dongsheng@627 12305 "been pulled."
dongsheng@627 12306 msgstr ""
dongsheng@627 12307
dongsheng@627 12308 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12309 #: ../en/ch09-hook.xml:1621
dongsheng@627 12310 msgid ""
dongsheng@627 12311 "<literal>node</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 12312 "changeset of the group that was sent."
dongsheng@627 12313 msgstr ""
dongsheng@627 12314
dongsheng@627 12315 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12316 #: ../en/ch09-hook.xml:1626
dongsheng@627 12317 msgid ""
dongsheng@627 12318 "<literal>source</literal>: A string. The source of the of the operation (see "
songdongsheng@658 12319 "<xref linkend=\"sec:hook:sources\"/>). If a remote client pulled changes "
songdongsheng@658 12320 "from this repository, <literal>source</literal> will be <literal>serve</"
songdongsheng@658 12321 "literal>. If the client that obtained changes from this repository was "
songdongsheng@658 12322 "local, <literal>source</literal> will be <literal>bundle</literal>, "
songdongsheng@658 12323 "<literal>pull</literal>, or <literal>push</literal>, depending on the "
songdongsheng@658 12324 "operation the client performed."
songdongsheng@658 12325 msgstr ""
songdongsheng@658 12326
songdongsheng@658 12327 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12328 #: ../en/ch09-hook.xml:1645
songdongsheng@658 12329 msgid ""
songdongsheng@658 12330 "See also: <literal role=\"hook\">preoutgoing</literal> (<xref linkend=\"sec:"
songdongsheng@658 12331 "hook:preoutgoing\"/>)"
dongsheng@627 12332 msgstr ""
dongsheng@627 12333
dongsheng@627 12334 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12335 #: ../en/ch09-hook.xml:1652
songdongsheng@667 12336 #, fuzzy
dongsheng@627 12337 msgid ""
dongsheng@661 12338 "<literal role=\"hook\">prechangegroup</literal>—before starting to add remote "
dongsheng@661 12339 "changesets"
dongsheng@661 12340 msgstr "<literal role=\"hook\">prechangegroup</literal>—增加远程修改集之前"
dongsheng@627 12341
dongsheng@627 12342 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12343 #: ../en/ch09-hook.xml:1656
dongsheng@627 12344 msgid ""
dongsheng@627 12345 "This controlling hook is run before Mercurial begins to add a group of "
dongsheng@627 12346 "changesets from another repository."
dongsheng@627 12347 msgstr ""
dongsheng@627 12348
dongsheng@627 12349 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12350 #: ../en/ch09-hook.xml:1660
dongsheng@627 12351 msgid ""
dongsheng@627 12352 "This hook does not have any information about the changesets to be added, "
dongsheng@627 12353 "because it is run before transmission of those changesets is allowed to "
dongsheng@627 12354 "begin. If this hook fails, the changesets will not be transmitted."
dongsheng@627 12355 msgstr ""
dongsheng@627 12356
dongsheng@627 12357 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12358 #: ../en/ch09-hook.xml:1666
dongsheng@627 12359 msgid ""
dongsheng@627 12360 "One use for this hook is to prevent external changes from being added to a "
dongsheng@627 12361 "repository. For example, you could use this to <quote>freeze</quote> a "
dongsheng@627 12362 "server-hosted branch temporarily or permanently so that users cannot push to "
dongsheng@627 12363 "it, while still allowing a local administrator to modify the repository."
dongsheng@627 12364 msgstr ""
dongsheng@627 12365
dongsheng@627 12366 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12367 #: ../en/ch09-hook.xml:1687
songdongsheng@658 12368 msgid ""
songdongsheng@658 12369 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 12370 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
songdongsheng@658 12371 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">pretxnchangegroup</"
songdongsheng@658 12372 "literal> (<xref linkend=\"sec:hook:pretxnchangegroup\"/>)"
dongsheng@627 12373 msgstr ""
dongsheng@627 12374
dongsheng@627 12375 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12376 #: ../en/ch09-hook.xml:1698
songdongsheng@667 12377 #, fuzzy
dongsheng@627 12378 msgid ""
dongsheng@661 12379 "<literal role=\"hook\">precommit</literal>—before starting to commit a "
dongsheng@627 12380 "changeset"
dongsheng@661 12381 msgstr "<literal role=\"hook\">precommit</literal>—提交修改集之前"
dongsheng@627 12382
dongsheng@627 12383 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12384 #: ../en/ch09-hook.xml:1701
dongsheng@627 12385 msgid ""
dongsheng@627 12386 "This hook is run before Mercurial begins to commit a new changeset. It is run "
dongsheng@627 12387 "before Mercurial has any of the metadata for the commit, such as the files to "
dongsheng@627 12388 "be committed, the commit message, or the commit date."
dongsheng@627 12389 msgstr ""
dongsheng@627 12390
dongsheng@627 12391 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12392 #: ../en/ch09-hook.xml:1707
dongsheng@627 12393 msgid ""
dongsheng@627 12394 "One use for this hook is to disable the ability to commit new changesets, "
dongsheng@627 12395 "while still allowing incoming changesets. Another is to run a build or test, "
dongsheng@627 12396 "and only allow the commit to begin if the build or test succeeds."
dongsheng@627 12397 msgstr ""
dongsheng@627 12398
dongsheng@627 12399 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12400 #: ../en/ch09-hook.xml:1716
dongsheng@627 12401 msgid ""
dongsheng@627 12402 "<literal>parent1</literal>: A changeset ID. The changeset ID of the first "
dongsheng@627 12403 "parent of the working directory."
dongsheng@627 12404 msgstr ""
dongsheng@627 12405
dongsheng@627 12406 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12407 #: ../en/ch09-hook.xml:1721
dongsheng@627 12408 msgid ""
dongsheng@627 12409 "<literal>parent2</literal>: A changeset ID. The changeset ID of the second "
dongsheng@627 12410 "parent of the working directory."
dongsheng@627 12411 msgstr ""
dongsheng@627 12412
dongsheng@627 12413 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12414 #: ../en/ch09-hook.xml:1726
dongsheng@627 12415 msgid ""
dongsheng@627 12416 "If the commit proceeds, the parents of the working directory will become the "
dongsheng@627 12417 "parents of the new changeset."
dongsheng@627 12418 msgstr ""
dongsheng@627 12419
dongsheng@627 12420 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12421 #: ../en/ch09-hook.xml:1730
dongsheng@627 12422 msgid ""
songdongsheng@658 12423 "See also: <literal role=\"hook\">commit</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12424 "commit\"/>), <literal role=\"hook\">pretxncommit</literal> (<xref linkend="
songdongsheng@658 12425 "\"sec:hook:pretxncommit\"/>)"
dongsheng@627 12426 msgstr ""
dongsheng@627 12427
dongsheng@627 12428 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12429 #: ../en/ch09-hook.xml:1738
songdongsheng@667 12430 #, fuzzy
dongsheng@627 12431 msgid ""
dongsheng@661 12432 "<literal role=\"hook\">preoutgoing</literal>—before starting to propagate "
dongsheng@661 12433 "changesets"
dongsheng@661 12434 msgstr "<literal role=\"hook\">preoutgoing</literal>—传播修改集之前"
dongsheng@627 12435
dongsheng@627 12436 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12437 #: ../en/ch09-hook.xml:1741
dongsheng@627 12438 msgid ""
dongsheng@627 12439 "This hook is invoked before Mercurial knows the identities of the changesets "
dongsheng@627 12440 "to be transmitted."
dongsheng@627 12441 msgstr ""
dongsheng@627 12442
dongsheng@627 12443 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12444 #: ../en/ch09-hook.xml:1745
dongsheng@627 12445 msgid ""
dongsheng@627 12446 "One use for this hook is to prevent changes from being transmitted to another "
dongsheng@627 12447 "repository."
dongsheng@627 12448 msgstr ""
dongsheng@627 12449
dongsheng@627 12450 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 12451 #: ../en/ch09-hook.xml:1752
dongsheng@627 12452 msgid ""
dongsheng@627 12453 "<literal>source</literal>: A string. The source of the operation that is "
songdongsheng@658 12454 "attempting to obtain changes from this repository (see <xref linkend=\"sec:"
songdongsheng@658 12455 "hook:sources\"/>). See the documentation for the <literal>source</literal> "
songdongsheng@658 12456 "parameter to the <literal role=\"hook\">outgoing</literal> hook, in <xref "
songdongsheng@658 12457 "linkend=\"sec:hook:outgoing\"/>, for possible values of this parameter."
songdongsheng@658 12458 msgstr ""
songdongsheng@658 12459
songdongsheng@658 12460 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12461 #: ../en/ch09-hook.xml:1768
songdongsheng@658 12462 msgid ""
songdongsheng@658 12463 "See also: <literal role=\"hook\">outgoing</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12464 "outgoing\"/>)"
dongsheng@627 12465 msgstr ""
dongsheng@627 12466
dongsheng@627 12467 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12468 #: ../en/ch09-hook.xml:1775
songdongsheng@667 12469 #, fuzzy
dongsheng@661 12470 msgid "<literal role=\"hook\">pretag</literal>—before tagging a changeset"
dongsheng@661 12471 msgstr "<literal role=\"hook\">pretag</literal>—创建标签之前"
dongsheng@627 12472
dongsheng@627 12473 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12474 #: ../en/ch09-hook.xml:1778
dongsheng@627 12475 msgid ""
dongsheng@627 12476 "This controlling hook is run before a tag is created. If the hook succeeds, "
dongsheng@627 12477 "creation of the tag proceeds. If the hook fails, the tag is not created."
dongsheng@627 12478 msgstr ""
dongsheng@627 12479
dongsheng@627 12480 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12481 #: ../en/ch09-hook.xml:1786
dongsheng@627 12482 msgid ""
dongsheng@627 12483 "<literal>local</literal>: A boolean. Whether the tag is local to this "
dongsheng@627 12484 "repository instance (i.e. stored in <filename role=\"special\">.hg/localtags</"
dongsheng@627 12485 "filename>) or managed by Mercurial (stored in <filename role=\"special\">."
dongsheng@627 12486 "hgtags</filename>)."
dongsheng@627 12487 msgstr ""
dongsheng@627 12488
dongsheng@627 12489 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12490 #: ../en/ch09-hook.xml:1793
dongsheng@627 12491 msgid ""
dongsheng@627 12492 "<literal>node</literal>: A changeset ID. The ID of the changeset to be "
dongsheng@627 12493 "tagged."
dongsheng@627 12494 msgstr ""
dongsheng@627 12495
dongsheng@627 12496 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12497 #: ../en/ch09-hook.xml:1797
dongsheng@627 12498 msgid "<literal>tag</literal>: A string. The name of the tag to be created."
dongsheng@627 12499 msgstr ""
dongsheng@627 12500
dongsheng@627 12501 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12502 #: ../en/ch09-hook.xml:1802
dongsheng@627 12503 msgid ""
dongsheng@627 12504 "If the tag to be created is revision-controlled, the <literal role=\"hook"
dongsheng@627 12505 "\">precommit</literal> and <literal role=\"hook\">pretxncommit</literal> "
songdongsheng@658 12506 "hooks (<xref linkend=\"sec:hook:commit\"/> and <xref linkend=\"sec:hook:"
songdongsheng@658 12507 "pretxncommit\"/>) will also be run."
dongsheng@627 12508 msgstr ""
dongsheng@627 12509
dongsheng@627 12510 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12511 #: ../en/ch09-hook.xml:1810
dongsheng@627 12512 msgid ""
songdongsheng@658 12513 "See also: <literal role=\"hook\">tag</literal> (<xref linkend=\"sec:hook:tag"
songdongsheng@658 12514 "\"/>)"
dongsheng@627 12515 msgstr ""
dongsheng@627 12516
dongsheng@627 12517 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12518 #: ../en/ch09-hook.xml:1815
songdongsheng@667 12519 #, fuzzy
dongsheng@627 12520 msgid ""
dongsheng@661 12521 "<literal role=\"hook\">pretxnchangegroup</literal>—before completing addition "
dongsheng@661 12522 "of remote changesets"
dongsheng@661 12523 msgstr ""
dongsheng@661 12524 "<literal role=\"hook\">pretxnchangegroup</literal>—完成增加远程修改集之前"
dongsheng@627 12525
dongsheng@627 12526 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12527 #: ../en/ch09-hook.xml:1819
dongsheng@627 12528 msgid ""
dongsheng@661 12529 "This controlling hook is run before a transaction—that manages the addition "
dongsheng@661 12530 "of a group of new changesets from outside the repository—completes. If the "
dongsheng@661 12531 "hook succeeds, the transaction completes, and all of the changesets become "
dongsheng@661 12532 "permanent within this repository. If the hook fails, the transaction is "
dongsheng@661 12533 "rolled back, and the data for the changesets is erased."
dongsheng@627 12534 msgstr ""
dongsheng@627 12535
dongsheng@627 12536 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12537 #: ../en/ch09-hook.xml:1828
dongsheng@627 12538 msgid ""
dongsheng@627 12539 "This hook can access the metadata associated with the almost-added "
dongsheng@627 12540 "changesets, but it should not do anything permanent with this data. It must "
dongsheng@627 12541 "also not modify the working directory."
dongsheng@627 12542 msgstr ""
dongsheng@627 12543
dongsheng@627 12544 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12545 #: ../en/ch09-hook.xml:1834
dongsheng@627 12546 msgid ""
dongsheng@627 12547 "While this hook is running, if other Mercurial processes access this "
dongsheng@627 12548 "repository, they will be able to see the almost-added changesets as if they "
dongsheng@627 12549 "are permanent. This may lead to race conditions if you do not take steps to "
dongsheng@627 12550 "avoid them."
dongsheng@627 12551 msgstr ""
dongsheng@627 12552
dongsheng@627 12553 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12554 #: ../en/ch09-hook.xml:1841
dongsheng@627 12555 msgid ""
dongsheng@627 12556 "This hook can be used to automatically vet a group of changesets. If the "
dongsheng@627 12557 "hook fails, all of the changesets are <quote>rejected</quote> when the "
dongsheng@627 12558 "transaction rolls back."
dongsheng@627 12559 msgstr ""
dongsheng@627 12560
dongsheng@627 12561 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12562 #: ../en/ch09-hook.xml:1870
songdongsheng@658 12563 msgid ""
songdongsheng@658 12564 "See also: <literal role=\"hook\">changegroup</literal> (<xref linkend=\"sec:"
songdongsheng@658 12565 "hook:changegroup\"/>), <literal role=\"hook\">incoming</literal> (<xref "
songdongsheng@658 12566 "linkend=\"sec:hook:incoming\"/>), <literal role=\"hook\">prechangegroup</"
songdongsheng@658 12567 "literal> (<xref linkend=\"sec:hook:prechangegroup\"/>)"
dongsheng@627 12568 msgstr ""
dongsheng@627 12569
dongsheng@627 12570 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12571 #: ../en/ch09-hook.xml:1881
songdongsheng@667 12572 #, fuzzy
dongsheng@627 12573 msgid ""
dongsheng@661 12574 "<literal role=\"hook\">pretxncommit</literal>—before completing commit of new "
dongsheng@661 12575 "changeset"
dongsheng@661 12576 msgstr "<literal role=\"hook\">pretxncommit</literal>—完成提交之前"
dongsheng@627 12577
dongsheng@627 12578 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12579 #: ../en/ch09-hook.xml:1884
dongsheng@627 12580 msgid ""
dongsheng@661 12581 "This controlling hook is run before a transaction—that manages a new commit—"
dongsheng@661 12582 "completes. If the hook succeeds, the transaction completes and the changeset "
dongsheng@661 12583 "becomes permanent within this repository. If the hook fails, the transaction "
dongsheng@661 12584 "is rolled back, and the commit data is erased."
dongsheng@627 12585 msgstr ""
dongsheng@627 12586
dongsheng@627 12587 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12588 #: ../en/ch09-hook.xml:1892
dongsheng@627 12589 msgid ""
dongsheng@627 12590 "This hook can access the metadata associated with the almost-new changeset, "
dongsheng@627 12591 "but it should not do anything permanent with this data. It must also not "
dongsheng@627 12592 "modify the working directory."
dongsheng@627 12593 msgstr ""
dongsheng@627 12594
dongsheng@627 12595 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12596 #: ../en/ch09-hook.xml:1898
dongsheng@627 12597 msgid ""
dongsheng@627 12598 "While this hook is running, if other Mercurial processes access this "
dongsheng@627 12599 "repository, they will be able to see the almost-new changeset as if it is "
dongsheng@627 12600 "permanent. This may lead to race conditions if you do not take steps to "
dongsheng@627 12601 "avoid them."
dongsheng@627 12602 msgstr ""
dongsheng@627 12603
dongsheng@627 12604 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12605 #: ../en/ch09-hook.xml:1922
songdongsheng@658 12606 msgid ""
songdongsheng@658 12607 "See also: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:"
songdongsheng@658 12608 "hook:precommit\"/>)"
dongsheng@660 12609 msgstr ""
dongsheng@660 12610 "参见: <literal role=\"hook\">precommit</literal> (<xref linkend=\"sec:hook:"
dongsheng@660 12611 "precommit\"/>)"
dongsheng@627 12612
dongsheng@627 12613 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12614 #: ../en/ch09-hook.xml:1929
songdongsheng@667 12615 #, fuzzy
dongsheng@627 12616 msgid ""
dongsheng@661 12617 "<literal role=\"hook\">preupdate</literal>—before updating or merging working "
dongsheng@661 12618 "directory"
dongsheng@661 12619 msgstr "<literal role=\"hook\">preupdate</literal>—更新或合并工作目录之前"
dongsheng@627 12620
dongsheng@627 12621 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12622 #: ../en/ch09-hook.xml:1932
dongsheng@627 12623 msgid ""
dongsheng@627 12624 "This controlling hook is run before an update or merge of the working "
dongsheng@627 12625 "directory begins. It is run only if Mercurial's normal pre-update checks "
dongsheng@627 12626 "determine that the update or merge can proceed. If the hook succeeds, the "
dongsheng@627 12627 "update or merge may proceed; if it fails, the update or merge does not start."
dongsheng@627 12628 msgstr ""
dongsheng@627 12629
dongsheng@627 12630 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12631 #: ../en/ch09-hook.xml:1943
songdongsheng@658 12632 msgid ""
songdongsheng@658 12633 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
dongsheng@627 12634 "working directory is to be updated to. If the working directory is being "
dongsheng@627 12635 "merged, it will not change this parent."
dongsheng@627 12636 msgstr ""
dongsheng@627 12637
dongsheng@627 12638 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12639 #: ../en/ch09-hook.xml:1949
songdongsheng@658 12640 msgid ""
songdongsheng@658 12641 "<literal>parent2</literal>: A changeset ID. Only set if the working directory "
songdongsheng@658 12642 "is being merged. The ID of the revision that the working directory is being "
songdongsheng@658 12643 "merged with."
songdongsheng@658 12644 msgstr ""
songdongsheng@658 12645
songdongsheng@658 12646 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12647 #: ../en/ch09-hook.xml:1956
songdongsheng@658 12648 msgid ""
songdongsheng@658 12649 "See also: <literal role=\"hook\">update</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12650 "update\"/>)"
dongsheng@627 12651 msgstr ""
dongsheng@627 12652
dongsheng@627 12653 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12654 #: ../en/ch09-hook.xml:1961
songdongsheng@667 12655 #, fuzzy
dongsheng@661 12656 msgid "<literal role=\"hook\">tag</literal>—after tagging a changeset"
dongsheng@661 12657 msgstr "<literal role=\"hook\">tag</literal>—创建标签之后"
dongsheng@627 12658
dongsheng@627 12659 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12660 #: ../en/ch09-hook.xml:1964
dongsheng@627 12661 msgid "This hook is run after a tag has been created."
dongsheng@627 12662 msgstr ""
dongsheng@627 12663
dongsheng@627 12664 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12665 #: ../en/ch09-hook.xml:1970
dongsheng@627 12666 msgid ""
dongsheng@627 12667 "<literal>local</literal>: A boolean. Whether the new tag is local to this "
dongsheng@627 12668 "repository instance (i.e. stored in <filename role=\"special\">.hg/"
dongsheng@627 12669 "localtags</filename>) or managed by Mercurial (stored in <filename role="
dongsheng@627 12670 "\"special\">.hgtags</filename>)."
dongsheng@627 12671 msgstr ""
dongsheng@627 12672
dongsheng@627 12673 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12674 #: ../en/ch09-hook.xml:1978
dongsheng@627 12675 msgid ""
dongsheng@627 12676 "<literal>node</literal>: A changeset ID. The ID of the changeset that was "
dongsheng@627 12677 "tagged."
dongsheng@627 12678 msgstr ""
dongsheng@627 12679
dongsheng@627 12680 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12681 #: ../en/ch09-hook.xml:1982
dongsheng@627 12682 msgid "<literal>tag</literal>: A string. The name of the tag that was created."
dongsheng@627 12683 msgstr ""
dongsheng@627 12684
dongsheng@627 12685 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12686 #: ../en/ch09-hook.xml:1987
dongsheng@627 12687 msgid ""
dongsheng@627 12688 "If the created tag is revision-controlled, the <literal role=\"hook\">commit</"
songdongsheng@658 12689 "literal> hook (section <xref linkend=\"sec:hook:commit\"/>) is run before "
dongsheng@627 12690 "this hook."
dongsheng@627 12691 msgstr ""
dongsheng@627 12692
dongsheng@627 12693 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12694 #: ../en/ch09-hook.xml:1992
songdongsheng@658 12695 msgid ""
songdongsheng@658 12696 "See also: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:"
songdongsheng@658 12697 "pretag\"/>)"
dongsheng@660 12698 msgstr ""
dongsheng@660 12699 "参见: <literal role=\"hook\">pretag</literal> (<xref linkend=\"sec:hook:pretag"
dongsheng@660 12700 "\"/>)"
dongsheng@627 12701
dongsheng@627 12702 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 12703 #: ../en/ch09-hook.xml:1998
songdongsheng@667 12704 #, fuzzy
dongsheng@627 12705 msgid ""
dongsheng@661 12706 "<literal role=\"hook\">update</literal>—after updating or merging working "
dongsheng@661 12707 "directory"
dongsheng@661 12708 msgstr "<literal role=\"hook\">update</literal>—更新或合并工作目录之后"
dongsheng@627 12709
dongsheng@627 12710 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12711 #: ../en/ch09-hook.xml:2001
dongsheng@627 12712 msgid ""
dongsheng@627 12713 "This hook is run after an update or merge of the working directory "
dongsheng@627 12714 "completes. Since a merge can fail (if the external <command>hgmerge</"
dongsheng@627 12715 "command> command fails to resolve conflicts in a file), this hook "
dongsheng@627 12716 "communicates whether the update or merge completed cleanly."
dongsheng@627 12717 msgstr ""
dongsheng@627 12718
dongsheng@627 12719 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12720 #: ../en/ch09-hook.xml:2009
dongsheng@627 12721 msgid ""
dongsheng@627 12722 "<literal>error</literal>: A boolean. Indicates whether the update or merge "
dongsheng@627 12723 "completed successfully."
dongsheng@627 12724 msgstr ""
dongsheng@627 12725
dongsheng@627 12726 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12727 #: ../en/ch09-hook.xml:2014
dongsheng@627 12728 msgid ""
dongsheng@627 12729 "<literal>parent1</literal>: A changeset ID. The ID of the parent that the "
dongsheng@627 12730 "working directory was updated to. If the working directory was merged, it "
dongsheng@627 12731 "will not have changed this parent."
dongsheng@627 12732 msgstr ""
dongsheng@627 12733
dongsheng@627 12734 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 12735 #: ../en/ch09-hook.xml:2020
dongsheng@627 12736 msgid ""
dongsheng@627 12737 "<literal>parent2</literal>: A changeset ID. Only set if the working "
dongsheng@627 12738 "directory was merged. The ID of the revision that the working directory was "
dongsheng@627 12739 "merged with."
dongsheng@627 12740 msgstr ""
dongsheng@627 12741
dongsheng@627 12742 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 12743 #: ../en/ch09-hook.xml:2026
songdongsheng@658 12744 msgid ""
songdongsheng@658 12745 "See also: <literal role=\"hook\">preupdate</literal> (<xref linkend=\"sec:"
songdongsheng@658 12746 "hook:preupdate\"/>)"
dongsheng@627 12747 msgstr ""
dongsheng@627 12748
dongsheng@627 12749 #. type: Content of: <book><chapter><title>
dongsheng@650 12750 #: ../en/ch10-template.xml:5
dongsheng@627 12751 msgid "Customising the output of Mercurial"
dongsheng@627 12752 msgstr "定制 Mercurial 的输出"
dongsheng@627 12753
dongsheng@627 12754 #. type: Content of: <book><chapter><para>
dongsheng@650 12755 #: ../en/ch10-template.xml:7
dongsheng@627 12756 msgid ""
dongsheng@627 12757 "Mercurial provides a powerful mechanism to let you control how it displays "
dongsheng@627 12758 "information. The mechanism is based on templates. You can use templates to "
dongsheng@627 12759 "generate specific output for a single command, or to customise the entire "
dongsheng@627 12760 "appearance of the built-in web interface."
dongsheng@627 12761 msgstr ""
dongsheng@627 12762
dongsheng@627 12763 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 12764 #: ../en/ch10-template.xml:14
dongsheng@627 12765 msgid "Using precanned output styles"
dongsheng@636 12766 msgstr "使用预定义的输出样式"
dongsheng@627 12767
dongsheng@627 12768 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12769 #: ../en/ch10-template.xml:16
dongsheng@627 12770 msgid ""
dongsheng@627 12771 "Packaged with Mercurial are some output styles that you can use immediately. "
dongsheng@627 12772 "A style is simply a precanned template that someone wrote and installed "
dongsheng@627 12773 "somewhere that Mercurial can find."
dongsheng@627 12774 msgstr ""
dongsheng@627 12775
dongsheng@627 12776 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12777 #: ../en/ch10-template.xml:21
dongsheng@627 12778 msgid ""
dongsheng@627 12779 "Before we take a look at Mercurial's bundled styles, let's review its normal "
dongsheng@627 12780 "output."
dongsheng@627 12781 msgstr ""
dongsheng@627 12782
dongsheng@627 12783 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12784 #: ../en/ch10-template.xml:26
dongsheng@627 12785 msgid ""
dongsheng@661 12786 "This is somewhat informative, but it takes up a lot of space—five lines of "
dongsheng@661 12787 "output per changeset. The <literal>compact</literal> style reduces this to "
dongsheng@661 12788 "three lines, presented in a sparse manner."
dongsheng@627 12789 msgstr ""
dongsheng@627 12790
dongsheng@627 12791 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12792 #: ../en/ch10-template.xml:33
dongsheng@627 12793 msgid ""
dongsheng@627 12794 "The <literal>changelog</literal> style hints at the expressive power of "
dongsheng@627 12795 "Mercurial's templating engine. This style attempts to follow the GNU "
dongsheng@627 12796 "Project's changelog guidelines<citation>web:changelog</citation>."
dongsheng@627 12797 msgstr ""
dongsheng@627 12798
dongsheng@627 12799 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12800 #: ../en/ch10-template.xml:40
dongsheng@627 12801 msgid ""
dongsheng@627 12802 "You will not be shocked to learn that Mercurial's default output style is "
dongsheng@627 12803 "named <literal>default</literal>."
dongsheng@627 12804 msgstr ""
dongsheng@627 12805
dongsheng@627 12806 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 12807 #: ../en/ch10-template.xml:44
dongsheng@627 12808 msgid "Setting a default style"
dongsheng@636 12809 msgstr "设置默认样式"
dongsheng@627 12810
dongsheng@627 12811 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12812 #: ../en/ch10-template.xml:46
dongsheng@627 12813 msgid ""
dongsheng@627 12814 "You can modify the output style that Mercurial will use for every command by "
dongsheng@650 12815 "editing your <filename role=\"special\">~/.hgrc</filename> file, naming the "
dongsheng@627 12816 "style you would prefer to use."
dongsheng@627 12817 msgstr ""
dongsheng@627 12818
dongsheng@627 12819 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 12820 #: ../en/ch10-template.xml:54
dongsheng@627 12821 msgid ""
dongsheng@627 12822 "If you write a style of your own, you can use it by either providing the path "
dongsheng@627 12823 "to your style file, or copying your style file into a location where "
dongsheng@627 12824 "Mercurial can find it (typically the <literal>templates</literal> "
dongsheng@627 12825 "subdirectory of your Mercurial install directory)."
dongsheng@627 12826 msgstr ""
dongsheng@627 12827
dongsheng@627 12828 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 12829 #: ../en/ch10-template.xml:63
dongsheng@627 12830 msgid "Commands that support styles and templates"
dongsheng@636 12831 msgstr "支持样式和模版的命令"
dongsheng@627 12832
dongsheng@627 12833 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12834 #: ../en/ch10-template.xml:65
dongsheng@627 12835 msgid ""
dongsheng@627 12836 "All of Mercurial's <quote><literal>log</literal>-like</quote> commands let "
dongsheng@627 12837 "you use styles and templates: <command role=\"hg-cmd\">hg incoming</command>, "
dongsheng@627 12838 "<command role=\"hg-cmd\">hg log</command>, <command role=\"hg-cmd\">hg "
dongsheng@627 12839 "outgoing</command>, and <command role=\"hg-cmd\">hg tip</command>."
dongsheng@627 12840 msgstr ""
dongsheng@627 12841
dongsheng@627 12842 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12843 #: ../en/ch10-template.xml:72
dongsheng@627 12844 msgid ""
dongsheng@627 12845 "As I write this manual, these are so far the only commands that support "
dongsheng@627 12846 "styles and templates. Since these are the most important commands that need "
dongsheng@627 12847 "customisable output, there has been little pressure from the Mercurial user "
dongsheng@627 12848 "community to add style and template support to other commands."
dongsheng@627 12849 msgstr ""
dongsheng@627 12850
dongsheng@627 12851 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 12852 #: ../en/ch10-template.xml:80
dongsheng@627 12853 msgid "The basics of templating"
dongsheng@636 12854 msgstr "模版基础"
dongsheng@627 12855
dongsheng@627 12856 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12857 #: ../en/ch10-template.xml:82
dongsheng@627 12858 msgid ""
dongsheng@627 12859 "At its simplest, a Mercurial template is a piece of text. Some of the text "
dongsheng@627 12860 "never changes, while other parts are <emphasis>expanded</emphasis>, or "
dongsheng@627 12861 "replaced with new text, when necessary."
dongsheng@627 12862 msgstr ""
dongsheng@627 12863
dongsheng@627 12864 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12865 #: ../en/ch10-template.xml:87
dongsheng@627 12866 msgid ""
dongsheng@627 12867 "Before we continue, let's look again at a simple example of Mercurial's "
dongsheng@627 12868 "normal output."
dongsheng@627 12869 msgstr ""
dongsheng@627 12870
dongsheng@627 12871 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12872 #: ../en/ch10-template.xml:92
dongsheng@627 12873 msgid ""
dongsheng@627 12874 "Now, let's run the same command, but using a template to change its output."
dongsheng@627 12875 msgstr ""
dongsheng@627 12876
dongsheng@627 12877 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12878 #: ../en/ch10-template.xml:97
dongsheng@627 12879 msgid ""
dongsheng@627 12880 "The example above illustrates the simplest possible template; it's just a "
dongsheng@627 12881 "piece of static text, printed once for each changeset. The <option role=\"hg-"
dongsheng@627 12882 "opt-log\">--template</option> option to the <command role=\"hg-cmd\">hg log</"
dongsheng@627 12883 "command> command tells Mercurial to use the given text as the template when "
dongsheng@627 12884 "printing each changeset."
dongsheng@627 12885 msgstr ""
dongsheng@627 12886
dongsheng@627 12887 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12888 #: ../en/ch10-template.xml:105
dongsheng@627 12889 msgid ""
dongsheng@627 12890 "Notice that the template string above ends with the text <quote><literal>\\n</"
dongsheng@627 12891 "literal></quote>. This is an <emphasis>escape sequence</emphasis>, telling "
dongsheng@627 12892 "Mercurial to print a newline at the end of each template item. If you omit "
songdongsheng@658 12893 "this newline, Mercurial will run each piece of output together. See <xref "
songdongsheng@658 12894 "linkend=\"sec:template:escape\"/> for more details of escape sequences."
dongsheng@627 12895 msgstr ""
dongsheng@627 12896
dongsheng@627 12897 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12898 #: ../en/ch10-template.xml:113
dongsheng@627 12899 msgid ""
dongsheng@627 12900 "A template that prints a fixed string of text all the time isn't very useful; "
dongsheng@627 12901 "let's try something a bit more complex."
dongsheng@627 12902 msgstr ""
dongsheng@627 12903
dongsheng@627 12904 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 12905 #: ../en/ch10-template.xml:119
dongsheng@627 12906 msgid ""
dongsheng@627 12907 "As you can see, the string <quote><literal>{desc}</literal></quote> in the "
dongsheng@627 12908 "template has been replaced in the output with the description of each "
dongsheng@627 12909 "changeset. Every time Mercurial finds text enclosed in curly braces "
dongsheng@627 12910 "(<quote><literal>{</literal></quote> and <quote><literal>}</literal></"
dongsheng@627 12911 "quote>), it will try to replace the braces and text with the expansion of "
dongsheng@627 12912 "whatever is inside. To print a literal curly brace, you must escape it, as "
songdongsheng@658 12913 "described in <xref linkend=\"sec:template:escape\"/>."
dongsheng@627 12914 msgstr ""
dongsheng@627 12915
dongsheng@627 12916 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 12917 #: ../en/ch10-template.xml:131
dongsheng@627 12918 msgid "Common template keywords"
dongsheng@636 12919 msgstr "模版关键字"
dongsheng@627 12920
dongsheng@627 12921 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 12922 #: ../en/ch10-template.xml:133
dongsheng@627 12923 msgid ""
dongsheng@627 12924 "You can start writing simple templates immediately using the keywords below."
dongsheng@627 12925 msgstr ""
dongsheng@627 12926
dongsheng@627 12927 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12928 #: ../en/ch10-template.xml:137
dongsheng@627 12929 msgid ""
dongsheng@627 12930 "<literal role=\"template-keyword\">author</literal>: String. The unmodified "
dongsheng@627 12931 "author of the changeset."
dongsheng@627 12932 msgstr ""
dongsheng@627 12933
dongsheng@627 12934 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12935 #: ../en/ch10-template.xml:141
dongsheng@627 12936 msgid ""
dongsheng@627 12937 "<literal role=\"template-keyword\">branches</literal>: String. The name of "
dongsheng@627 12938 "the branch on which the changeset was committed. Will be empty if the branch "
dongsheng@627 12939 "name was <literal>default</literal>."
dongsheng@627 12940 msgstr ""
dongsheng@627 12941
dongsheng@627 12942 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12943 #: ../en/ch10-template.xml:147
dongsheng@627 12944 msgid ""
dongsheng@627 12945 "<literal role=\"template-keyword\">date</literal>: Date information. The "
dongsheng@627 12946 "date when the changeset was committed. This is <emphasis>not</emphasis> "
dongsheng@627 12947 "human-readable; you must pass it through a filter that will render it "
songdongsheng@658 12948 "appropriately. See <xref linkend=\"sec:template:filter\"/> for more "
dongsheng@627 12949 "information on filters. The date is expressed as a pair of numbers. The "
dongsheng@627 12950 "first number is a Unix UTC timestamp (seconds since January 1, 1970); the "
dongsheng@627 12951 "second is the offset of the committer's timezone from UTC, in seconds."
dongsheng@627 12952 msgstr ""
dongsheng@627 12953
dongsheng@627 12954 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12955 #: ../en/ch10-template.xml:158
dongsheng@627 12956 msgid ""
dongsheng@627 12957 "<literal role=\"template-keyword\">desc</literal>: String. The text of the "
dongsheng@627 12958 "changeset description."
dongsheng@627 12959 msgstr ""
dongsheng@627 12960
dongsheng@627 12961 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12962 #: ../en/ch10-template.xml:161
dongsheng@627 12963 msgid ""
dongsheng@627 12964 "<literal role=\"template-keyword\">files</literal>: List of strings. All "
dongsheng@627 12965 "files modified, added, or removed by this changeset."
dongsheng@627 12966 msgstr ""
dongsheng@627 12967
dongsheng@627 12968 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12969 #: ../en/ch10-template.xml:166
dongsheng@627 12970 msgid ""
dongsheng@627 12971 "<literal role=\"template-keyword\">file_adds</literal>: List of strings. "
dongsheng@627 12972 "Files added by this changeset."
dongsheng@627 12973 msgstr ""
dongsheng@627 12974
dongsheng@627 12975 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12976 #: ../en/ch10-template.xml:170
dongsheng@627 12977 msgid ""
dongsheng@627 12978 "<literal role=\"template-keyword\">file_dels</literal>: List of strings. "
dongsheng@627 12979 "Files removed by this changeset."
dongsheng@627 12980 msgstr ""
dongsheng@627 12981
dongsheng@627 12982 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12983 #: ../en/ch10-template.xml:174
dongsheng@627 12984 msgid ""
dongsheng@627 12985 "<literal role=\"template-keyword\">node</literal>: String. The changeset "
dongsheng@627 12986 "identification hash, as a 40-character hexadecimal string."
dongsheng@627 12987 msgstr ""
dongsheng@627 12988
dongsheng@627 12989 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12990 #: ../en/ch10-template.xml:178
dongsheng@627 12991 msgid ""
dongsheng@627 12992 "<literal role=\"template-keyword\">parents</literal>: List of strings. The "
dongsheng@627 12993 "parents of the changeset."
dongsheng@627 12994 msgstr ""
dongsheng@627 12995
dongsheng@627 12996 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 12997 #: ../en/ch10-template.xml:182
dongsheng@627 12998 msgid ""
dongsheng@627 12999 "<literal role=\"template-keyword\">rev</literal>: Integer. The repository-"
dongsheng@627 13000 "local changeset revision number."
dongsheng@627 13001 msgstr ""
dongsheng@627 13002
dongsheng@627 13003 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13004 #: ../en/ch10-template.xml:186
dongsheng@627 13005 msgid ""
dongsheng@627 13006 "<literal role=\"template-keyword\">tags</literal>: List of strings. Any tags "
dongsheng@627 13007 "associated with the changeset."
dongsheng@627 13008 msgstr ""
dongsheng@627 13009
dongsheng@627 13010 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13011 #: ../en/ch10-template.xml:191
dongsheng@627 13012 msgid ""
dongsheng@627 13013 "A few simple experiments will show us what to expect when we use these "
dongsheng@627 13014 "keywords; you can see the results below."
dongsheng@627 13015 msgstr ""
dongsheng@627 13016
dongsheng@627 13017 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13018 #: ../en/ch10-template.xml:196
dongsheng@627 13019 msgid ""
dongsheng@627 13020 "As we noted above, the date keyword does not produce human-readable output, "
dongsheng@627 13021 "so we must treat it specially. This involves using a <emphasis>filter</"
songdongsheng@658 13022 "emphasis>, about which more in <xref linkend=\"sec:template:filter\"/>."
dongsheng@627 13023 msgstr ""
dongsheng@627 13024
dongsheng@627 13025 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 13026 #: ../en/ch10-template.xml:205
dongsheng@627 13027 msgid "Escape sequences"
dongsheng@636 13028 msgstr "转义序列"
dongsheng@627 13029
dongsheng@627 13030 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13031 #: ../en/ch10-template.xml:207
dongsheng@627 13032 msgid ""
dongsheng@627 13033 "Mercurial's templating engine recognises the most commonly used escape "
dongsheng@627 13034 "sequences in strings. When it sees a backslash (<quote><literal>\\</"
dongsheng@627 13035 "literal></quote>) character, it looks at the following character and "
dongsheng@627 13036 "substitutes the two characters with a single replacement, as described below."
dongsheng@627 13037 msgstr ""
dongsheng@627 13038
dongsheng@627 13039 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13040 #: ../en/ch10-template.xml:214
dongsheng@650 13041 msgid ""
dongsheng@650 13042 "<literal>\\</literal>: Backslash, <quote><literal>\\</literal></quote>, ASCII "
dongsheng@650 13043 "134."
dongsheng@627 13044 msgstr ""
dongsheng@627 13045
dongsheng@627 13046 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13047 #: ../en/ch10-template.xml:218
dongsheng@650 13048 msgid "<literal>\\n</literal>: Newline, ASCII 12."
dongsheng@627 13049 msgstr ""
dongsheng@627 13050
dongsheng@627 13051 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13052 #: ../en/ch10-template.xml:221
dongsheng@650 13053 msgid "<literal>\\r</literal>: Carriage return, ASCII 15."
dongsheng@627 13054 msgstr ""
dongsheng@627 13055
dongsheng@627 13056 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13057 #: ../en/ch10-template.xml:224
dongsheng@650 13058 msgid "<literal>\\t</literal>: Tab, ASCII 11."
dongsheng@627 13059 msgstr ""
dongsheng@627 13060
dongsheng@627 13061 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13062 #: ../en/ch10-template.xml:227
dongsheng@650 13063 msgid "<literal>\\v</literal>: Vertical tab, ASCII 13."
dongsheng@627 13064 msgstr ""
dongsheng@627 13065
dongsheng@627 13066 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13067 #: ../en/ch10-template.xml:230
dongsheng@650 13068 msgid ""
dongsheng@650 13069 "<literal>{</literal>: Open curly brace, <quote><literal>{</literal></quote>, "
dongsheng@650 13070 "ASCII 173."
dongsheng@627 13071 msgstr ""
dongsheng@627 13072
dongsheng@627 13073 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13074 #: ../en/ch10-template.xml:234
dongsheng@650 13075 msgid ""
dongsheng@650 13076 "<literal>}</literal>: Close curly brace, <quote><literal>}</literal></quote>, "
dongsheng@650 13077 "ASCII 175."
dongsheng@650 13078 msgstr ""
dongsheng@650 13079
dongsheng@650 13080 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13081 #: ../en/ch10-template.xml:239
dongsheng@627 13082 msgid ""
dongsheng@627 13083 "As indicated above, if you want the expansion of a template to contain a "
dongsheng@627 13084 "literal <quote><literal>\\</literal></quote>, <quote><literal>{</literal></"
dongsheng@627 13085 "quote>, or <quote><literal>{</literal></quote> character, you must escape it."
dongsheng@627 13086 msgstr ""
dongsheng@627 13087
dongsheng@627 13088 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 13089 #: ../en/ch10-template.xml:247
dongsheng@627 13090 msgid "Filtering keywords to change their results"
dongsheng@636 13091 msgstr "通过过滤关键字来修改输出结果"
dongsheng@627 13092
dongsheng@627 13093 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13094 #: ../en/ch10-template.xml:249
dongsheng@627 13095 msgid ""
dongsheng@627 13096 "Some of the results of template expansion are not immediately easy to use. "
dongsheng@627 13097 "Mercurial lets you specify an optional chain of <emphasis>filters</emphasis> "
dongsheng@627 13098 "to modify the result of expanding a keyword. You have already seen a common "
dongsheng@627 13099 "filter, <literal role=\"template-kw-filt-date\">isodate</literal>, in action "
dongsheng@627 13100 "above, to make a date readable."
dongsheng@627 13101 msgstr ""
dongsheng@627 13102
dongsheng@627 13103 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13104 #: ../en/ch10-template.xml:256
dongsheng@627 13105 msgid ""
dongsheng@627 13106 "Below is a list of the most commonly used filters that Mercurial supports. "
dongsheng@627 13107 "While some filters can be applied to any text, others can only be used in "
dongsheng@627 13108 "specific circumstances. The name of each filter is followed first by an "
dongsheng@627 13109 "indication of where it can be used, then a description of its effect."
dongsheng@627 13110 msgstr ""
dongsheng@627 13111
dongsheng@627 13112 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13113 #: ../en/ch10-template.xml:263
dongsheng@627 13114 msgid ""
dongsheng@627 13115 "<literal role=\"template-filter\">addbreaks</literal>: Any text. Add an XHTML "
dongsheng@627 13116 "<quote><literal>&lt;br/&gt;</literal></quote> tag before the end of every "
dongsheng@627 13117 "line except the last. For example, <quote><literal>foo\\nbar</literal></"
dongsheng@627 13118 "quote> becomes <quote><literal>foo&lt;br/&gt;\\nbar</literal></quote>."
dongsheng@627 13119 msgstr ""
dongsheng@627 13120
dongsheng@627 13121 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13122 #: ../en/ch10-template.xml:270
dongsheng@627 13123 msgid ""
dongsheng@627 13124 "<literal role=\"template-kw-filt-date\">age</literal>: <literal role="
dongsheng@627 13125 "\"template-keyword\">date</literal> keyword. Render the age of the date, "
dongsheng@627 13126 "relative to the current time. Yields a string like <quote><literal>10 "
dongsheng@627 13127 "minutes</literal></quote>."
dongsheng@627 13128 msgstr ""
dongsheng@627 13129
dongsheng@627 13130 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13131 #: ../en/ch10-template.xml:277
dongsheng@627 13132 msgid ""
dongsheng@627 13133 "<literal role=\"template-filter\">basename</literal>: Any text, but most "
dongsheng@627 13134 "useful for the <literal role=\"template-keyword\">files</literal> keyword and "
dongsheng@627 13135 "its relatives. Treat the text as a path, and return the basename. For "
dongsheng@627 13136 "example, <quote><literal>foo/bar/baz</literal></quote> becomes "
dongsheng@627 13137 "<quote><literal>baz</literal></quote>."
dongsheng@627 13138 msgstr ""
dongsheng@627 13139
dongsheng@627 13140 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13141 #: ../en/ch10-template.xml:286
dongsheng@627 13142 msgid ""
dongsheng@627 13143 "<literal role=\"template-kw-filt-date\">date</literal>: <literal role="
dongsheng@627 13144 "\"template-keyword\">date</literal> keyword. Render a date in a similar "
dongsheng@627 13145 "format to the Unix <literal role=\"template-keyword\">date</literal> command, "
dongsheng@627 13146 "but with timezone included. Yields a string like <quote><literal>Mon Sep 04 "
dongsheng@627 13147 "15:13:13 2006 -0700</literal></quote>."
dongsheng@627 13148 msgstr ""
dongsheng@627 13149
dongsheng@627 13150 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13151 #: ../en/ch10-template.xml:294
dongsheng@627 13152 msgid ""
dongsheng@627 13153 "<literal role=\"template-kw-filt-author\">domain</literal>: Any text, but "
dongsheng@627 13154 "most useful for the <literal role=\"template-keyword\">author</literal> "
dongsheng@627 13155 "keyword. Finds the first string that looks like an email address, and "
dongsheng@627 13156 "extract just the domain component. For example, <quote><literal>Bryan "
dongsheng@627 13157 "O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> becomes "
dongsheng@627 13158 "<quote><literal>serpentine.com</literal></quote>."
dongsheng@627 13159 msgstr ""
dongsheng@627 13160
dongsheng@627 13161 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13162 #: ../en/ch10-template.xml:304
dongsheng@627 13163 msgid ""
dongsheng@627 13164 "<literal role=\"template-kw-filt-author\">email</literal>: Any text, but most "
dongsheng@627 13165 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 13166 "Extract the first string that looks like an email address. For example, "
dongsheng@627 13167 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 13168 "becomes <quote><literal>bos@serpentine.com</literal></quote>."
dongsheng@627 13169 msgstr ""
dongsheng@627 13170
dongsheng@627 13171 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13172 #: ../en/ch10-template.xml:313
dongsheng@627 13173 msgid ""
dongsheng@627 13174 "<literal role=\"template-filter\">escape</literal>: Any text. Replace the "
dongsheng@627 13175 "special XML/XHTML characters <quote><literal>&amp;</literal></quote>, "
dongsheng@627 13176 "<quote><literal>&lt;</literal></quote> and <quote><literal>&gt;</literal></"
dongsheng@627 13177 "quote> with XML entities."
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:321
dongsheng@627 13182 msgid ""
dongsheng@627 13183 "<literal role=\"template-filter\">fill68</literal>: Any text. Wrap the text "
dongsheng@627 13184 "to fit in 68 columns. This is useful before you pass text through the "
dongsheng@627 13185 "<literal role=\"template-filter\">tabindent</literal> filter, and still want "
dongsheng@627 13186 "it to fit in an 80-column fixed-font window."
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:329
dongsheng@627 13191 msgid ""
dongsheng@627 13192 "<literal role=\"template-filter\">fill76</literal>: Any text. Wrap the text "
dongsheng@627 13193 "to fit in 76 columns."
dongsheng@627 13194 msgstr ""
dongsheng@627 13195
dongsheng@627 13196 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13197 #: ../en/ch10-template.xml:333
dongsheng@627 13198 msgid ""
dongsheng@627 13199 "<literal role=\"template-filter\">firstline</literal>: Any text. Yield the "
dongsheng@627 13200 "first line of text, without any trailing newlines."
dongsheng@627 13201 msgstr ""
dongsheng@627 13202
dongsheng@627 13203 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13204 #: ../en/ch10-template.xml:338
dongsheng@627 13205 msgid ""
dongsheng@627 13206 "<literal role=\"template-kw-filt-date\">hgdate</literal>: <literal role="
dongsheng@627 13207 "\"template-keyword\">date</literal> keyword. Render the date as a pair of "
dongsheng@627 13208 "readable numbers. Yields a string like <quote><literal>1157407993 25200</"
dongsheng@627 13209 "literal></quote>."
dongsheng@627 13210 msgstr ""
dongsheng@627 13211
dongsheng@627 13212 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13213 #: ../en/ch10-template.xml:345
dongsheng@627 13214 msgid ""
dongsheng@627 13215 "<literal role=\"template-kw-filt-date\">isodate</literal>: <literal role="
dongsheng@627 13216 "\"template-keyword\">date</literal> keyword. Render the date as a text "
dongsheng@627 13217 "string in ISO 8601 format. Yields a string like <quote><literal>2006-09-04 "
dongsheng@627 13218 "15:13:13 -0700</literal></quote>."
dongsheng@627 13219 msgstr ""
dongsheng@627 13220
dongsheng@627 13221 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13222 #: ../en/ch10-template.xml:352
dongsheng@627 13223 msgid ""
dongsheng@627 13224 "<literal role=\"template-filter\">obfuscate</literal>: Any text, but most "
dongsheng@627 13225 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 13226 "Yield the input text rendered as a sequence of XML entities. This helps to "
dongsheng@627 13227 "defeat some particularly stupid screen-scraping email harvesting spambots."
dongsheng@627 13228 msgstr ""
dongsheng@627 13229
dongsheng@627 13230 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13231 #: ../en/ch10-template.xml:360
dongsheng@627 13232 msgid ""
dongsheng@627 13233 "<literal role=\"template-kw-filt-author\">person</literal>: Any text, but "
dongsheng@627 13234 "most useful for the <literal role=\"template-keyword\">author</literal> "
dongsheng@627 13235 "keyword. Yield the text before an email address. For example, "
dongsheng@627 13236 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 13237 "becomes <quote><literal>Bryan O'Sullivan</literal></quote>."
dongsheng@627 13238 msgstr ""
dongsheng@627 13239
dongsheng@627 13240 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13241 #: ../en/ch10-template.xml:369
dongsheng@627 13242 msgid ""
dongsheng@627 13243 "<literal role=\"template-kw-filt-date\">rfc822date</literal>: <literal role="
dongsheng@627 13244 "\"template-keyword\">date</literal> keyword. Render a date using the same "
dongsheng@627 13245 "format used in email headers. Yields a string like <quote><literal>Mon, 04 "
dongsheng@627 13246 "Sep 2006 15:13:13 -0700</literal></quote>."
dongsheng@627 13247 msgstr ""
dongsheng@627 13248
dongsheng@627 13249 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13250 #: ../en/ch10-template.xml:376
dongsheng@627 13251 msgid ""
dongsheng@627 13252 "<literal role=\"template-kw-filt-node\">short</literal>: Changeset hash. "
dongsheng@627 13253 "Yield the short form of a changeset hash, i.e. a 12-character hexadecimal "
dongsheng@627 13254 "string."
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:381
dongsheng@627 13259 msgid ""
dongsheng@627 13260 "<literal role=\"template-kw-filt-date\">shortdate</literal>: <literal role="
dongsheng@627 13261 "\"template-keyword\">date</literal> keyword. Render the year, month, and day "
dongsheng@627 13262 "of the date. Yields a string like <quote><literal>2006-09-04</literal></"
dongsheng@627 13263 "quote>."
dongsheng@627 13264 msgstr ""
dongsheng@627 13265
dongsheng@627 13266 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13267 #: ../en/ch10-template.xml:387
dongsheng@627 13268 msgid ""
dongsheng@627 13269 "<literal role=\"template-filter\">strip</literal>: Any text. Strip all "
dongsheng@627 13270 "leading and trailing whitespace from the string."
dongsheng@627 13271 msgstr ""
dongsheng@627 13272
dongsheng@627 13273 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13274 #: ../en/ch10-template.xml:391
dongsheng@627 13275 msgid ""
dongsheng@627 13276 "<literal role=\"template-filter\">tabindent</literal>: Any text. Yield the "
dongsheng@627 13277 "text, with every line except the first starting with a tab character."
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:396
dongsheng@627 13282 msgid ""
dongsheng@627 13283 "<literal role=\"template-filter\">urlescape</literal>: Any text. Escape all "
dongsheng@627 13284 "characters that are considered <quote>special</quote> by URL parsers. For "
dongsheng@627 13285 "example, <literal>foo bar</literal> becomes <literal>foo%20bar</literal>."
dongsheng@627 13286 msgstr ""
dongsheng@627 13287
dongsheng@627 13288 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 13289 #: ../en/ch10-template.xml:403
dongsheng@627 13290 msgid ""
dongsheng@627 13291 "<literal role=\"template-kw-filt-author\">user</literal>: Any text, but most "
dongsheng@627 13292 "useful for the <literal role=\"template-keyword\">author</literal> keyword. "
dongsheng@627 13293 "Return the <quote>user</quote> portion of an email address. For example, "
dongsheng@627 13294 "<quote><literal>Bryan O'Sullivan &lt;bos@serpentine.com&gt;</literal></quote> "
dongsheng@627 13295 "becomes <quote><literal>bos</literal></quote>."
dongsheng@627 13296 msgstr ""
dongsheng@627 13297
dongsheng@627 13298 #. type: Content of: <book><chapter><sect1><note><para>
songdongsheng@658 13299 #: ../en/ch10-template.xml:416
dongsheng@627 13300 msgid ""
dongsheng@627 13301 "If you try to apply a filter to a piece of data that it cannot process, "
dongsheng@627 13302 "Mercurial will fail and print a Python exception. For example, trying to run "
dongsheng@627 13303 "the output of the <literal role=\"template-keyword\">desc</literal> keyword "
dongsheng@627 13304 "into the <literal role=\"template-kw-filt-date\">isodate</literal> filter is "
dongsheng@627 13305 "not a good idea."
dongsheng@627 13306 msgstr ""
dongsheng@627 13307
dongsheng@627 13308 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13309 #: ../en/ch10-template.xml:425
dongsheng@627 13310 msgid "Combining filters"
dongsheng@636 13311 msgstr "组合过滤器"
dongsheng@627 13312
dongsheng@627 13313 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13314 #: ../en/ch10-template.xml:427
dongsheng@627 13315 msgid ""
dongsheng@627 13316 "It is easy to combine filters to yield output in the form you would like. "
dongsheng@627 13317 "The following chain of filters tidies up a description, then makes sure that "
dongsheng@627 13318 "it fits cleanly into 68 columns, then indents it by a further 8 characters "
dongsheng@627 13319 "(at least on Unix-like systems, where a tab is conventionally 8 characters "
dongsheng@627 13320 "wide)."
dongsheng@627 13321 msgstr ""
dongsheng@627 13322
dongsheng@627 13323 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13324 #: ../en/ch10-template.xml:436
dongsheng@627 13325 msgid ""
dongsheng@627 13326 "Note the use of <quote><literal>\\t</literal></quote> (a tab character) in "
dongsheng@627 13327 "the template to force the first line to be indented; this is necessary since "
dongsheng@627 13328 "<literal role=\"template-keyword\">tabindent</literal> indents all lines "
dongsheng@627 13329 "<emphasis>except</emphasis> the first."
dongsheng@627 13330 msgstr ""
dongsheng@627 13331
dongsheng@627 13332 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13333 #: ../en/ch10-template.xml:442
dongsheng@627 13334 msgid ""
dongsheng@627 13335 "Keep in mind that the order of filters in a chain is significant. The first "
dongsheng@627 13336 "filter is applied to the result of the keyword; the second to the result of "
dongsheng@627 13337 "the first filter; and so on. For example, using <literal>fill68|tabindent</"
dongsheng@627 13338 "literal> gives very different results from <literal>tabindent|fill68</"
dongsheng@627 13339 "literal>."
dongsheng@627 13340 msgstr ""
dongsheng@627 13341
dongsheng@627 13342 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 13343 #: ../en/ch10-template.xml:453
dongsheng@627 13344 msgid "From templates to styles"
dongsheng@636 13345 msgstr "从模版到样式"
dongsheng@627 13346
dongsheng@627 13347 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13348 #: ../en/ch10-template.xml:455
dongsheng@627 13349 msgid ""
dongsheng@627 13350 "A command line template provides a quick and simple way to format some "
dongsheng@627 13351 "output. Templates can become verbose, though, and it's useful to be able to "
dongsheng@627 13352 "give a template a name. A style file is a template with a name, stored in a "
dongsheng@627 13353 "file."
dongsheng@627 13354 msgstr ""
dongsheng@627 13355
dongsheng@627 13356 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13357 #: ../en/ch10-template.xml:460
dongsheng@627 13358 msgid ""
dongsheng@627 13359 "More than that, using a style file unlocks the power of Mercurial's "
dongsheng@627 13360 "templating engine in ways that are not possible using the command line "
dongsheng@627 13361 "<option role=\"hg-opt-log\">--template</option> option."
dongsheng@627 13362 msgstr ""
dongsheng@627 13363
dongsheng@627 13364 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13365 #: ../en/ch10-template.xml:466
dongsheng@627 13366 msgid "The simplest of style files"
dongsheng@636 13367 msgstr "最简单的样式文件"
dongsheng@627 13368
dongsheng@627 13369 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13370 #: ../en/ch10-template.xml:468
dongsheng@627 13371 msgid "Our simple style file contains just one line:"
dongsheng@627 13372 msgstr ""
dongsheng@627 13373
dongsheng@627 13374 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13375 #: ../en/ch10-template.xml:472
dongsheng@627 13376 msgid ""
dongsheng@627 13377 "This tells Mercurial, <quote>if you're printing a changeset, use the text on "
dongsheng@627 13378 "the right as the template</quote>."
dongsheng@627 13379 msgstr ""
dongsheng@627 13380
dongsheng@627 13381 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13382 #: ../en/ch10-template.xml:478
dongsheng@627 13383 msgid "Style file syntax"
dongsheng@636 13384 msgstr "样式文件语法"
dongsheng@627 13385
dongsheng@627 13386 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13387 #: ../en/ch10-template.xml:480
dongsheng@627 13388 msgid "The syntax rules for a style file are simple."
dongsheng@627 13389 msgstr ""
dongsheng@627 13390
dongsheng@627 13391 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13392 #: ../en/ch10-template.xml:483
dongsheng@627 13393 msgid "The file is processed one line at a time."
dongsheng@627 13394 msgstr ""
dongsheng@627 13395
dongsheng@627 13396 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13397 #: ../en/ch10-template.xml:486
dongsheng@627 13398 msgid "Leading and trailing white space are ignored."
dongsheng@627 13399 msgstr ""
dongsheng@627 13400
dongsheng@627 13401 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13402 #: ../en/ch10-template.xml:489
songdongsheng@658 13403 msgid "Empty lines are skipped."
songdongsheng@658 13404 msgstr ""
songdongsheng@658 13405
songdongsheng@658 13406 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 13407 #: ../en/ch10-template.xml:491
dongsheng@627 13408 msgid ""
dongsheng@627 13409 "If a line starts with either of the characters <quote><literal>#</literal></"
dongsheng@627 13410 "quote> or <quote><literal>;</literal></quote>, the entire line is treated as "
dongsheng@627 13411 "a comment, and skipped as if empty."
dongsheng@627 13412 msgstr ""
dongsheng@627 13413
dongsheng@627 13414 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13415 #: ../en/ch10-template.xml:496
dongsheng@627 13416 msgid ""
dongsheng@627 13417 "A line starts with a keyword. This must start with an alphabetic character "
dongsheng@627 13418 "or underscore, and can subsequently contain any alphanumeric character or "
dongsheng@627 13419 "underscore. (In regexp notation, a keyword must match <literal>[A-Za-z_][A-"
dongsheng@627 13420 "Za-z0-9_]*</literal>.)"
dongsheng@627 13421 msgstr ""
dongsheng@627 13422
dongsheng@627 13423 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13424 #: ../en/ch10-template.xml:502
dongsheng@627 13425 msgid ""
dongsheng@627 13426 "The next element must be an <quote><literal>=</literal></quote> character, "
dongsheng@627 13427 "which can be preceded or followed by an arbitrary amount of white space."
dongsheng@627 13428 msgstr ""
dongsheng@627 13429
dongsheng@627 13430 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13431 #: ../en/ch10-template.xml:507
dongsheng@627 13432 msgid ""
dongsheng@627 13433 "If the rest of the line starts and ends with matching quote characters "
dongsheng@627 13434 "(either single or double quote), it is treated as a template body."
dongsheng@627 13435 msgstr ""
dongsheng@627 13436
dongsheng@627 13437 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13438 #: ../en/ch10-template.xml:511
dongsheng@627 13439 msgid ""
dongsheng@627 13440 "If the rest of the line <emphasis>does not</emphasis> start with a quote "
dongsheng@627 13441 "character, it is treated as the name of a file; the contents of this file "
dongsheng@627 13442 "will be read and used as a template body."
dongsheng@627 13443 msgstr ""
dongsheng@627 13444
dongsheng@627 13445 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 13446 #: ../en/ch10-template.xml:520
dongsheng@627 13447 msgid "Style files by example"
dongsheng@636 13448 msgstr "样式文件例子"
dongsheng@627 13449
dongsheng@627 13450 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 13451 #: ../en/ch10-template.xml:522
dongsheng@627 13452 msgid ""
dongsheng@627 13453 "To illustrate how to write a style file, we will construct a few by example. "
dongsheng@627 13454 "Rather than provide a complete style file and walk through it, we'll mirror "
dongsheng@627 13455 "the usual process of developing a style file by starting with something very "
dongsheng@627 13456 "simple, and walking through a series of successively more complete examples."
dongsheng@627 13457 msgstr ""
dongsheng@627 13458
dongsheng@627 13459 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13460 #: ../en/ch10-template.xml:529
dongsheng@627 13461 msgid "Identifying mistakes in style files"
dongsheng@636 13462 msgstr "在样式文件中定位错误"
dongsheng@627 13463
dongsheng@627 13464 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13465 #: ../en/ch10-template.xml:531
dongsheng@627 13466 msgid ""
dongsheng@627 13467 "If Mercurial encounters a problem in a style file you are working on, it "
dongsheng@627 13468 "prints a terse error message that, once you figure out what it means, is "
dongsheng@627 13469 "actually quite useful."
dongsheng@627 13470 msgstr ""
dongsheng@627 13471
dongsheng@627 13472 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13473 #: ../en/ch10-template.xml:537
dongsheng@627 13474 msgid ""
dongsheng@627 13475 "Notice that <filename>broken.style</filename> attempts to define a "
dongsheng@627 13476 "<literal>changeset</literal> keyword, but forgets to give any content for it. "
dongsheng@627 13477 "When instructed to use this style file, Mercurial promptly complains."
dongsheng@627 13478 msgstr ""
dongsheng@627 13479
dongsheng@627 13480 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13481 #: ../en/ch10-template.xml:544
dongsheng@627 13482 msgid "This error message looks intimidating, but it is not too hard to follow."
dongsheng@627 13483 msgstr ""
dongsheng@627 13484
dongsheng@627 13485 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13486 #: ../en/ch10-template.xml:548
dongsheng@627 13487 msgid ""
dongsheng@627 13488 "The first component is simply Mercurial's way of saying <quote>I am giving "
dongsheng@627 13489 "up</quote>."
dongsheng@627 13490 msgstr ""
dongsheng@627 13491
dongsheng@627 13492 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13493 #: ../en/ch10-template.xml:552
dongsheng@627 13494 msgid "Next comes the name of the style file that contains the error."
dongsheng@627 13495 msgstr ""
dongsheng@627 13496
dongsheng@627 13497 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13498 #: ../en/ch10-template.xml:556
dongsheng@627 13499 msgid ""
dongsheng@627 13500 "Following the file name is the line number where the error was encountered."
dongsheng@627 13501 msgstr ""
dongsheng@627 13502
dongsheng@627 13503 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13504 #: ../en/ch10-template.xml:560
dongsheng@627 13505 msgid "Finally, a description of what went wrong."
dongsheng@627 13506 msgstr ""
dongsheng@627 13507
dongsheng@627 13508 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13509 #: ../en/ch10-template.xml:564
dongsheng@627 13510 msgid ""
dongsheng@627 13511 "The description of the problem is not always clear (as in this case), but "
dongsheng@627 13512 "even when it is cryptic, it is almost always trivial to visually inspect the "
dongsheng@627 13513 "offending line in the style file and see what is wrong."
dongsheng@627 13514 msgstr ""
dongsheng@627 13515
dongsheng@627 13516 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13517 #: ../en/ch10-template.xml:572
dongsheng@627 13518 msgid "Uniquely identifying a repository"
dongsheng@636 13519 msgstr "版本库的唯一标识"
dongsheng@627 13520
dongsheng@627 13521 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13522 #: ../en/ch10-template.xml:574
dongsheng@627 13523 msgid ""
dongsheng@627 13524 "If you would like to be able to identify a Mercurial repository <quote>fairly "
dongsheng@627 13525 "uniquely</quote> using a short string as an identifier, you can use the first "
dongsheng@627 13526 "revision in the repository."
dongsheng@627 13527 msgstr ""
dongsheng@627 13528
dongsheng@627 13529 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13530 #: ../en/ch10-template.xml:581
dongsheng@627 13531 msgid ""
dongsheng@627 13532 "This is not guaranteed to be unique, but it is nevertheless useful in many "
dongsheng@627 13533 "cases."
dongsheng@627 13534 msgstr ""
dongsheng@627 13535
dongsheng@627 13536 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13537 #: ../en/ch10-template.xml:584
dongsheng@627 13538 msgid ""
dongsheng@627 13539 "It will not work in a completely empty repository, because such a repository "
dongsheng@627 13540 "does not have a revision zero."
dongsheng@627 13541 msgstr ""
dongsheng@627 13542
dongsheng@627 13543 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13544 #: ../en/ch10-template.xml:588
dongsheng@627 13545 msgid ""
dongsheng@627 13546 "Neither will it work in the (extremely rare) case where a repository is a "
dongsheng@627 13547 "merge of two or more formerly independent repositories, and you still have "
dongsheng@627 13548 "those repositories around."
dongsheng@627 13549 msgstr ""
dongsheng@627 13550
dongsheng@627 13551 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13552 #: ../en/ch10-template.xml:593
dongsheng@627 13553 msgid "Here are some uses to which you could put this identifier:"
dongsheng@627 13554 msgstr ""
dongsheng@627 13555
dongsheng@627 13556 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13557 #: ../en/ch10-template.xml:596
dongsheng@627 13558 msgid ""
dongsheng@627 13559 "As a key into a table for a database that manages repositories on a server."
dongsheng@627 13560 msgstr ""
dongsheng@627 13561
dongsheng@627 13562 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13563 #: ../en/ch10-template.xml:599
dongsheng@627 13564 msgid ""
dongsheng@627 13565 "As half of a {<emphasis>repository ID</emphasis>, <emphasis>revision ID</"
dongsheng@627 13566 "emphasis>} tuple. Save this information away when you run an automated build "
dongsheng@627 13567 "or other activity, so that you can <quote>replay</quote> the build later if "
dongsheng@627 13568 "necessary."
dongsheng@627 13569 msgstr ""
dongsheng@627 13570
dongsheng@627 13571 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 13572 #: ../en/ch10-template.xml:608
dongsheng@627 13573 msgid "Mimicking Subversion's output"
dongsheng@636 13574 msgstr "模仿 Subversion 的输出"
dongsheng@627 13575
dongsheng@627 13576 #
dongsheng@627 13577 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13578 #: ../en/ch10-template.xml:610
dongsheng@627 13579 msgid ""
dongsheng@627 13580 "Let's try to emulate the default output format used by another revision "
dongsheng@627 13581 "control tool, Subversion."
dongsheng@627 13582 msgstr ""
dongsheng@627 13583
dongsheng@627 13584 #
dongsheng@627 13585 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13586 #: ../en/ch10-template.xml:615
dongsheng@627 13587 msgid ""
dongsheng@627 13588 "Since Subversion's output style is fairly simple, it is easy to copy-and-"
dongsheng@627 13589 "paste a hunk of its output into a file, and replace the text produced above "
dongsheng@627 13590 "by Subversion with the template values we'd like to see expanded."
dongsheng@627 13591 msgstr ""
dongsheng@627 13592
dongsheng@627 13593 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13594 #: ../en/ch10-template.xml:622
dongsheng@627 13595 msgid ""
dongsheng@627 13596 "There are a few small ways in which this template deviates from the output "
dongsheng@627 13597 "produced by Subversion."
dongsheng@627 13598 msgstr ""
dongsheng@627 13599
dongsheng@627 13600 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13601 #: ../en/ch10-template.xml:625
dongsheng@627 13602 msgid ""
dongsheng@627 13603 "Subversion prints a <quote>readable</quote> date (the <quote><literal>Wed, 27 "
dongsheng@627 13604 "Sep 2006</literal></quote> in the example output above) in parentheses. "
dongsheng@627 13605 "Mercurial's templating engine does not provide a way to display a date in "
dongsheng@627 13606 "this format without also printing the time and time zone."
dongsheng@627 13607 msgstr ""
dongsheng@627 13608
dongsheng@627 13609 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13610 #: ../en/ch10-template.xml:632
dongsheng@627 13611 msgid ""
dongsheng@627 13612 "We emulate Subversion's printing of <quote>separator</quote> lines full of "
dongsheng@627 13613 "<quote><literal>-</literal></quote> characters by ending the template with "
dongsheng@627 13614 "such a line. We use the templating engine's <literal role=\"template-keyword"
dongsheng@627 13615 "\">header</literal> keyword to print a separator line as the first line of "
dongsheng@627 13616 "output (see below), thus achieving similar output to Subversion."
dongsheng@627 13617 msgstr ""
dongsheng@627 13618
dongsheng@627 13619 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 13620 #: ../en/ch10-template.xml:641
dongsheng@627 13621 msgid ""
dongsheng@627 13622 "Subversion's output includes a count in the header of the number of lines in "
dongsheng@627 13623 "the commit message. We cannot replicate this in Mercurial; the templating "
dongsheng@627 13624 "engine does not currently provide a filter that counts the number of lines "
dongsheng@627 13625 "the template generates."
dongsheng@627 13626 msgstr ""
dongsheng@627 13627
dongsheng@627 13628 #
dongsheng@627 13629 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13630 #: ../en/ch10-template.xml:647
dongsheng@627 13631 msgid ""
dongsheng@627 13632 "It took me no more than a minute or two of work to replace literal text from "
dongsheng@627 13633 "an example of Subversion's output with some keywords and filters to give the "
dongsheng@627 13634 "template above. The style file simply refers to the template."
dongsheng@627 13635 msgstr ""
dongsheng@627 13636
dongsheng@627 13637 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 13638 #: ../en/ch10-template.xml:654
dongsheng@627 13639 msgid ""
dongsheng@627 13640 "We could have included the text of the template file directly in the style "
dongsheng@627 13641 "file by enclosing it in quotes and replacing the newlines with "
dongsheng@627 13642 "<quote><literal>\\n</literal></quote> sequences, but it would have made the "
dongsheng@627 13643 "style file too difficult to read. Readability is a good guide when you're "
dongsheng@627 13644 "trying to decide whether some text belongs in a style file, or in a template "
dongsheng@627 13645 "file that the style file points to. If the style file will look too big or "
dongsheng@627 13646 "cluttered if you insert a literal piece of text, drop it into a template "
dongsheng@627 13647 "instead."
dongsheng@627 13648 msgstr ""
dongsheng@627 13649
dongsheng@627 13650 #. type: Content of: <book><chapter><title>
dongsheng@650 13651 #: ../en/ch11-mq.xml:5
dongsheng@627 13652 msgid "Managing change with Mercurial Queues"
dongsheng@627 13653 msgstr "使用 MQ 管理修改"
dongsheng@627 13654
dongsheng@627 13655 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 13656 #: ../en/ch11-mq.xml:8
dongsheng@627 13657 msgid "The patch management problem"
dongsheng@636 13658 msgstr "补丁的管理问题"
dongsheng@627 13659
dongsheng@627 13660 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13661 #: ../en/ch11-mq.xml:10
dongsheng@627 13662 msgid ""
dongsheng@627 13663 "Here is a common scenario: you need to install a software package from "
dongsheng@627 13664 "source, but you find a bug that you must fix in the source before you can "
dongsheng@627 13665 "start using the package. You make your changes, forget about the package for "
dongsheng@627 13666 "a while, and a few months later you need to upgrade to a newer version of the "
dongsheng@627 13667 "package. If the newer version of the package still has the bug, you must "
dongsheng@627 13668 "extract your fix from the older source tree and apply it against the newer "
dongsheng@627 13669 "version. This is a tedious task, and it's easy to make mistakes."
dongsheng@627 13670 msgstr ""
dongsheng@627 13671
dongsheng@627 13672 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13673 #: ../en/ch11-mq.xml:20
dongsheng@627 13674 msgid ""
dongsheng@627 13675 "This is a simple case of the <quote>patch management</quote> problem. You "
dongsheng@627 13676 "have an <quote>upstream</quote> source tree that you can't change; you need "
dongsheng@627 13677 "to make some local changes on top of the upstream tree; and you'd like to be "
dongsheng@627 13678 "able to keep those changes separate, so that you can apply them to newer "
dongsheng@627 13679 "versions of the upstream source."
dongsheng@627 13680 msgstr ""
dongsheng@627 13681
dongsheng@627 13682 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13683 #: ../en/ch11-mq.xml:27
dongsheng@627 13684 msgid ""
dongsheng@627 13685 "The patch management problem arises in many situations. Probably the most "
dongsheng@627 13686 "visible is that a user of an open source software project will contribute a "
dongsheng@627 13687 "bug fix or new feature to the project's maintainers in the form of a patch."
dongsheng@627 13688 msgstr ""
dongsheng@627 13689
dongsheng@627 13690 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13691 #: ../en/ch11-mq.xml:32
dongsheng@627 13692 msgid ""
dongsheng@627 13693 "Distributors of operating systems that include open source software often "
dongsheng@627 13694 "need to make changes to the packages they distribute so that they will build "
dongsheng@627 13695 "properly in their environments."
dongsheng@627 13696 msgstr ""
dongsheng@627 13697
dongsheng@627 13698 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13699 #: ../en/ch11-mq.xml:37
dongsheng@627 13700 msgid ""
dongsheng@627 13701 "When you have few changes to maintain, it is easy to manage a single patch "
dongsheng@627 13702 "using the standard <command>diff</command> and <command>patch</command> "
songdongsheng@658 13703 "programs (see <xref linkend=\"sec:mq:patch\"/> for a discussion of these "
songdongsheng@658 13704 "tools). Once the number of changes grows, it starts to make sense to maintain "
songdongsheng@658 13705 "patches as discrete <quote>chunks of work,</quote> so that for example a "
songdongsheng@658 13706 "single patch will contain only one bug fix (the patch might modify several "
songdongsheng@658 13707 "files, but it's doing <quote>only one thing</quote>), and you may have a "
songdongsheng@658 13708 "number of such patches for different bugs you need fixed and local changes "
songdongsheng@658 13709 "you require. In this situation, if you submit a bug fix patch to the "
dongsheng@627 13710 "upstream maintainers of a package and they include your fix in a subsequent "
dongsheng@627 13711 "release, you can simply drop that single patch when you're updating to the "
dongsheng@627 13712 "newer release."
dongsheng@627 13713 msgstr ""
dongsheng@627 13714
dongsheng@627 13715 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13716 #: ../en/ch11-mq.xml:52
dongsheng@627 13717 msgid ""
dongsheng@627 13718 "Maintaining a single patch against an upstream tree is a little tedious and "
dongsheng@627 13719 "error-prone, but not difficult. However, the complexity of the problem grows "
dongsheng@627 13720 "rapidly as the number of patches you have to maintain increases. With more "
dongsheng@627 13721 "than a tiny number of patches in hand, understanding which ones you have "
dongsheng@627 13722 "applied and maintaining them moves from messy to overwhelming."
dongsheng@627 13723 msgstr ""
dongsheng@627 13724
dongsheng@627 13725 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13726 #: ../en/ch11-mq.xml:59
dongsheng@627 13727 msgid ""
dongsheng@627 13728 "Fortunately, Mercurial includes a powerful extension, Mercurial Queues (or "
dongsheng@627 13729 "simply <quote>MQ</quote>), that massively simplifies the patch management "
dongsheng@627 13730 "problem."
dongsheng@627 13731 msgstr ""
dongsheng@627 13732
dongsheng@627 13733 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 13734 #: ../en/ch11-mq.xml:65
dongsheng@627 13735 msgid "The prehistory of Mercurial Queues"
dongsheng@636 13736 msgstr "MQ 的历史"
dongsheng@627 13737
dongsheng@627 13738 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13739 #: ../en/ch11-mq.xml:67
dongsheng@627 13740 msgid ""
dongsheng@627 13741 "During the late 1990s, several Linux kernel developers started to maintain "
dongsheng@627 13742 "<quote>patch series</quote> that modified the behaviour of the Linux kernel. "
dongsheng@627 13743 "Some of these series were focused on stability, some on feature coverage, and "
dongsheng@627 13744 "others were more speculative."
dongsheng@627 13745 msgstr ""
dongsheng@627 13746
dongsheng@627 13747 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13748 #: ../en/ch11-mq.xml:73
dongsheng@627 13749 msgid ""
dongsheng@627 13750 "The sizes of these patch series grew rapidly. In 2002, Andrew Morton "
dongsheng@627 13751 "published some shell scripts he had been using to automate the task of "
dongsheng@627 13752 "managing his patch queues. Andrew was successfully using these scripts to "
dongsheng@627 13753 "manage hundreds (sometimes thousands) of patches on top of the Linux kernel."
dongsheng@627 13754 msgstr ""
dongsheng@627 13755
dongsheng@627 13756 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 13757 #: ../en/ch11-mq.xml:80
dongsheng@627 13758 msgid "A patchwork quilt"
dongsheng@627 13759 msgstr ""
dongsheng@627 13760
dongsheng@627 13761 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13762 #: ../en/ch11-mq.xml:82
dongsheng@627 13763 msgid ""
dongsheng@627 13764 "In early 2003, Andreas Gruenbacher and Martin Quinson borrowed the approach "
dongsheng@627 13765 "of Andrew's scripts and published a tool called <quote>patchwork quilt</"
dongsheng@627 13766 "quote> <citation>web:quilt</citation>, or simply <quote>quilt</quote> (see "
dongsheng@627 13767 "<citation>gruenbacher:2005</citation> for a paper describing it). Because "
dongsheng@627 13768 "quilt substantially automated patch management, it rapidly gained a large "
dongsheng@627 13769 "following among open source software developers."
dongsheng@627 13770 msgstr ""
dongsheng@627 13771
dongsheng@627 13772 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13773 #: ../en/ch11-mq.xml:91
dongsheng@627 13774 msgid ""
dongsheng@627 13775 "Quilt manages a <emphasis>stack of patches</emphasis> on top of a directory "
dongsheng@627 13776 "tree. To begin, you tell quilt to manage a directory tree, and tell it which "
dongsheng@627 13777 "files you want to manage; it stores away the names and contents of those "
dongsheng@627 13778 "files. To fix a bug, you create a new patch (using a single command), edit "
dongsheng@627 13779 "the files you need to fix, then <quote>refresh</quote> the patch."
dongsheng@627 13780 msgstr ""
dongsheng@627 13781
dongsheng@627 13782 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13783 #: ../en/ch11-mq.xml:99
dongsheng@627 13784 msgid ""
dongsheng@627 13785 "The refresh step causes quilt to scan the directory tree; it updates the "
dongsheng@627 13786 "patch with all of the changes you have made. You can create another patch on "
dongsheng@627 13787 "top of the first, which will track the changes required to modify the tree "
dongsheng@627 13788 "from <quote>tree with one patch applied</quote> to <quote>tree with two "
dongsheng@627 13789 "patches applied</quote>."
dongsheng@627 13790 msgstr ""
dongsheng@627 13791
dongsheng@627 13792 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13793 #: ../en/ch11-mq.xml:106
dongsheng@627 13794 msgid ""
dongsheng@627 13795 "You can <emphasis>change</emphasis> which patches are applied to the tree. "
dongsheng@627 13796 "If you <quote>pop</quote> a patch, the changes made by that patch will vanish "
dongsheng@627 13797 "from the directory tree. Quilt remembers which patches you have popped, "
dongsheng@627 13798 "though, so you can <quote>push</quote> a popped patch again, and the "
dongsheng@627 13799 "directory tree will be restored to contain the modifications in the patch. "
dongsheng@627 13800 "Most importantly, you can run the <quote>refresh</quote> command at any time, "
dongsheng@627 13801 "and the topmost applied patch will be updated. This means that you can, at "
dongsheng@627 13802 "any time, change both which patches are applied and what modifications those "
dongsheng@627 13803 "patches make."
dongsheng@627 13804 msgstr ""
dongsheng@627 13805
dongsheng@627 13806 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13807 #: ../en/ch11-mq.xml:118
dongsheng@627 13808 msgid ""
dongsheng@627 13809 "Quilt knows nothing about revision control tools, so it works equally well on "
dongsheng@627 13810 "top of an unpacked tarball or a Subversion working copy."
dongsheng@627 13811 msgstr ""
dongsheng@627 13812
dongsheng@627 13813 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 13814 #: ../en/ch11-mq.xml:124
dongsheng@627 13815 msgid "From patchwork quilt to Mercurial Queues"
dongsheng@636 13816 msgstr "从 patchwork quilt 到 MQ"
dongsheng@627 13817
dongsheng@627 13818 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13819 #: ../en/ch11-mq.xml:126
dongsheng@627 13820 msgid ""
dongsheng@627 13821 "In mid-2005, Chris Mason took the features of quilt and wrote an extension "
dongsheng@627 13822 "that he called Mercurial Queues, which added quilt-like behaviour to "
dongsheng@627 13823 "Mercurial."
dongsheng@627 13824 msgstr ""
dongsheng@627 13825
dongsheng@627 13826 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13827 #: ../en/ch11-mq.xml:130
dongsheng@627 13828 msgid ""
dongsheng@627 13829 "The key difference between quilt and MQ is that quilt knows nothing about "
dongsheng@627 13830 "revision control systems, while MQ is <emphasis>integrated</emphasis> into "
dongsheng@627 13831 "Mercurial. Each patch that you push is represented as a Mercurial "
dongsheng@627 13832 "changeset. Pop a patch, and the changeset goes away."
dongsheng@627 13833 msgstr ""
dongsheng@627 13834
dongsheng@627 13835 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 13836 #: ../en/ch11-mq.xml:136
dongsheng@627 13837 msgid ""
dongsheng@627 13838 "Because quilt does not care about revision control tools, it is still a "
dongsheng@627 13839 "tremendously useful piece of software to know about for situations where you "
dongsheng@627 13840 "cannot use Mercurial and MQ."
dongsheng@627 13841 msgstr ""
dongsheng@627 13842
dongsheng@627 13843 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 13844 #: ../en/ch11-mq.xml:144
dongsheng@627 13845 msgid "The huge advantage of MQ"
dongsheng@636 13846 msgstr "MQ 的巨大优势"
dongsheng@627 13847
dongsheng@627 13848 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13849 #: ../en/ch11-mq.xml:146
dongsheng@627 13850 msgid ""
dongsheng@627 13851 "I cannot overstate the value that MQ offers through the unification of "
dongsheng@627 13852 "patches and revision control."
dongsheng@627 13853 msgstr ""
dongsheng@627 13854
dongsheng@627 13855 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13856 #: ../en/ch11-mq.xml:149
dongsheng@627 13857 msgid ""
dongsheng@627 13858 "A major reason that patches have persisted in the free software and open "
dongsheng@661 13859 "source world—in spite of the availability of increasingly capable revision "
dongsheng@661 13860 "control tools over the years—is the <emphasis>agility</emphasis> they offer."
dongsheng@627 13861 msgstr ""
dongsheng@627 13862
dongsheng@627 13863 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13864 #: ../en/ch11-mq.xml:155
dongsheng@627 13865 msgid ""
dongsheng@627 13866 "Traditional revision control tools make a permanent, irreversible record of "
dongsheng@627 13867 "everything that you do. While this has great value, it's also somewhat "
dongsheng@627 13868 "stifling. If you want to perform a wild-eyed experiment, you have to be "
dongsheng@661 13869 "careful in how you go about it, or you risk leaving unneeded—or worse, "
dongsheng@661 13870 "misleading or destabilising—traces of your missteps and errors in the "
dongsheng@627 13871 "permanent revision record."
dongsheng@627 13872 msgstr ""
dongsheng@627 13873
dongsheng@627 13874 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13875 #: ../en/ch11-mq.xml:163
dongsheng@627 13876 msgid ""
dongsheng@627 13877 "By contrast, MQ's marriage of distributed revision control with patches makes "
dongsheng@627 13878 "it much easier to isolate your work. Your patches live on top of normal "
dongsheng@627 13879 "revision history, and you can make them disappear or reappear at will. If "
dongsheng@627 13880 "you don't like a patch, you can drop it. If a patch isn't quite as you want "
dongsheng@661 13881 "it to be, simply fix it—as many times as you need to, until you have refined "
dongsheng@661 13882 "it into the form you desire."
dongsheng@627 13883 msgstr ""
dongsheng@627 13884
dongsheng@627 13885 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13886 #: ../en/ch11-mq.xml:171
dongsheng@627 13887 msgid ""
dongsheng@627 13888 "As an example, the integration of patches with revision control makes "
dongsheng@661 13889 "understanding patches and debugging their effects—and their interplay with "
dongsheng@661 13890 "the code they're based on—<emphasis>enormously</emphasis> easier. Since every "
dongsheng@661 13891 "applied patch has an associated changeset, you can give <command role=\"hg-cmd"
dongsheng@661 13892 "\">hg log</command> a file name to see which changesets and patches affected "
dongsheng@661 13893 "the file. You can use the <command role=\"hg-cmd\">hg bisect</command> "
dongsheng@661 13894 "command to binary-search through all changesets and applied patches to see "
dongsheng@661 13895 "where a bug got introduced or fixed. You can use the <command role=\"hg-cmd"
dongsheng@661 13896 "\">hg annotate</command> command to see which changeset or patch modified a "
dongsheng@661 13897 "particular line of a source file. And so on."
dongsheng@627 13898 msgstr ""
dongsheng@627 13899
dongsheng@627 13900 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13901 #: ../en/ch11-mq.xml:189
dongsheng@627 13902 msgid ""
dongsheng@627 13903 "Because MQ doesn't hide its patch-oriented nature, it is helpful to "
dongsheng@627 13904 "understand what patches are, and a little about the tools that work with them."
dongsheng@627 13905 msgstr ""
dongsheng@627 13906
dongsheng@627 13907 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13908 #: ../en/ch11-mq.xml:193
dongsheng@627 13909 msgid ""
dongsheng@627 13910 "The traditional Unix <command>diff</command> command compares two files, and "
dongsheng@627 13911 "prints a list of differences between them. The <command>patch</command> "
dongsheng@627 13912 "command understands these differences as <emphasis>modifications</emphasis> "
dongsheng@627 13913 "to make to a file. Take a look below for a simple example of these commands "
dongsheng@627 13914 "in action."
dongsheng@627 13915 msgstr ""
dongsheng@627 13916
dongsheng@627 13917 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13918 #: ../en/ch11-mq.xml:202
dongsheng@627 13919 msgid ""
dongsheng@627 13920 "The type of file that <command>diff</command> generates (and <command>patch</"
dongsheng@627 13921 "command> takes as input) is called a <quote>patch</quote> or a <quote>diff</"
dongsheng@627 13922 "quote>; there is no difference between a patch and a diff. (We'll use the "
dongsheng@627 13923 "term <quote>patch</quote>, since it's more commonly used.)"
dongsheng@627 13924 msgstr ""
dongsheng@627 13925
dongsheng@627 13926 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13927 #: ../en/ch11-mq.xml:208
dongsheng@627 13928 msgid ""
dongsheng@627 13929 "A patch file can start with arbitrary text; the <command>patch</command> "
dongsheng@627 13930 "command ignores this text, but MQ uses it as the commit message when creating "
dongsheng@627 13931 "changesets. To find the beginning of the patch content, <command>patch</"
dongsheng@627 13932 "command> searches for the first line that starts with the string "
dongsheng@627 13933 "<quote><literal>diff -</literal></quote>."
dongsheng@627 13934 msgstr ""
dongsheng@627 13935
dongsheng@627 13936 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13937 #: ../en/ch11-mq.xml:215
dongsheng@627 13938 msgid ""
dongsheng@627 13939 "MQ works with <emphasis>unified</emphasis> diffs (<command>patch</command> "
dongsheng@627 13940 "can accept several other diff formats, but MQ doesn't). A unified diff "
dongsheng@627 13941 "contains two kinds of header. The <emphasis>file header</emphasis> describes "
dongsheng@627 13942 "the file being modified; it contains the name of the file to modify. When "
dongsheng@627 13943 "<command>patch</command> sees a new file header, it looks for a file with "
dongsheng@627 13944 "that name to start modifying."
dongsheng@627 13945 msgstr ""
dongsheng@627 13946
dongsheng@627 13947 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13948 #: ../en/ch11-mq.xml:223
dongsheng@627 13949 msgid ""
dongsheng@627 13950 "After the file header comes a series of <emphasis>hunks</emphasis>. Each "
dongsheng@627 13951 "hunk starts with a header; this identifies the range of line numbers within "
dongsheng@627 13952 "the file that the hunk should modify. Following the header, a hunk starts "
dongsheng@627 13953 "and ends with a few (usually three) lines of text from the unmodified file; "
dongsheng@627 13954 "these are called the <emphasis>context</emphasis> for the hunk. If there's "
dongsheng@627 13955 "only a small amount of context between successive hunks, <command>diff</"
dongsheng@627 13956 "command> doesn't print a new hunk header; it just runs the hunks together, "
dongsheng@627 13957 "with a few lines of context between modifications."
dongsheng@627 13958 msgstr ""
dongsheng@627 13959
dongsheng@627 13960 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13961 #: ../en/ch11-mq.xml:235
dongsheng@627 13962 msgid ""
dongsheng@627 13963 "Each line of context begins with a space character. Within the hunk, a line "
dongsheng@627 13964 "that begins with <quote><literal>-</literal></quote> means <quote>remove this "
dongsheng@627 13965 "line,</quote> while a line that begins with <quote><literal>+</literal></"
dongsheng@627 13966 "quote> means <quote>insert this line.</quote> For example, a line that is "
dongsheng@627 13967 "modified is represented by one deletion and one insertion."
dongsheng@627 13968 msgstr ""
dongsheng@627 13969
dongsheng@627 13970 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13971 #: ../en/ch11-mq.xml:243
dongsheng@627 13972 msgid ""
songdongsheng@658 13973 "We will return to some of the more subtle aspects of patches later (in <xref "
songdongsheng@658 13974 "linkend=\"sec:mq:adv-patch\"/>), but you should have enough information now "
songdongsheng@658 13975 "to use MQ."
dongsheng@627 13976 msgstr ""
dongsheng@627 13977
dongsheng@627 13978 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 13979 #: ../en/ch11-mq.xml:250
dongsheng@627 13980 msgid "Getting started with Mercurial Queues"
dongsheng@636 13981 msgstr "开始使用 MQ"
dongsheng@627 13982
dongsheng@627 13983 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13984 #: ../en/ch11-mq.xml:252
dongsheng@627 13985 msgid ""
dongsheng@627 13986 "Because MQ is implemented as an extension, you must explicitly enable before "
dongsheng@627 13987 "you can use it. (You don't need to download anything; MQ ships with the "
dongsheng@627 13988 "standard Mercurial distribution.) To enable MQ, edit your <filename role="
dongsheng@627 13989 "\"home\">~/.hgrc</filename> file, and add the lines below."
dongsheng@627 13990 msgstr ""
dongsheng@627 13991
dongsheng@627 13992 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 13993 #: ../en/ch11-mq.xml:262
dongsheng@627 13994 msgid ""
dongsheng@627 13995 "Once the extension is enabled, it will make a number of new commands "
dongsheng@627 13996 "available. To verify that the extension is working, you can use <command "
dongsheng@627 13997 "role=\"hg-cmd\">hg help</command> to see if the <command role=\"hg-ext-mq"
dongsheng@627 13998 "\">qinit</command> command is now available."
dongsheng@627 13999 msgstr ""
dongsheng@627 14000
dongsheng@627 14001 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14002 #: ../en/ch11-mq.xml:270
dongsheng@627 14003 msgid ""
dongsheng@627 14004 "You can use MQ with <emphasis>any</emphasis> Mercurial repository, and its "
dongsheng@627 14005 "commands only operate within that repository. To get started, simply prepare "
dongsheng@627 14006 "the repository using the <command role=\"hg-ext-mq\">qinit</command> command."
dongsheng@627 14007 msgstr ""
dongsheng@627 14008
dongsheng@627 14009 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 14010 #: ../en/ch11-mq.xml:277
dongsheng@627 14011 msgid ""
dongsheng@627 14012 "This command creates an empty directory called <filename role=\"special\" "
dongsheng@627 14013 "class=\"directory\">.hg/patches</filename>, where MQ will keep its metadata. "
dongsheng@627 14014 "As with many Mercurial commands, the <command role=\"hg-ext-mq\">qinit</"
dongsheng@627 14015 "command> command prints nothing if it succeeds."
dongsheng@627 14016 msgstr ""
dongsheng@627 14017
dongsheng@627 14018 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14019 #: ../en/ch11-mq.xml:284
dongsheng@627 14020 msgid "Creating a new patch"
dongsheng@636 14021 msgstr "创建新补丁"
dongsheng@627 14022
dongsheng@627 14023 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14024 #: ../en/ch11-mq.xml:286
dongsheng@627 14025 msgid ""
dongsheng@627 14026 "To begin work on a new patch, use the <command role=\"hg-ext-mq\">qnew</"
dongsheng@627 14027 "command> command. This command takes one argument, the name of the patch to "
dongsheng@627 14028 "create."
dongsheng@627 14029 msgstr ""
dongsheng@627 14030
dongsheng@627 14031 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14032 #: ../en/ch11-mq.xml:290
dongsheng@627 14033 msgid ""
dongsheng@627 14034 "MQ will use this as the name of an actual file in the <filename role=\"special"
dongsheng@627 14035 "\" class=\"directory\">.hg/patches</filename> directory, as you can see below."
dongsheng@627 14036 msgstr ""
dongsheng@627 14037
dongsheng@627 14038 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14039 #: ../en/ch11-mq.xml:297
dongsheng@627 14040 msgid ""
dongsheng@627 14041 "Also newly present in the <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 14042 "patches</filename> directory are two other files, <filename role=\"special"
dongsheng@627 14043 "\">series</filename> and <filename role=\"special\">status</filename>. The "
dongsheng@627 14044 "<filename role=\"special\">series</filename> file lists all of the patches "
dongsheng@627 14045 "that MQ knows about for this repository, with one patch per line. Mercurial "
dongsheng@627 14046 "uses the <filename role=\"special\">status</filename> file for internal book-"
dongsheng@627 14047 "keeping; it tracks all of the patches that MQ has <emphasis>applied</"
dongsheng@627 14048 "emphasis> in this repository."
dongsheng@627 14049 msgstr ""
dongsheng@627 14050
dongsheng@627 14051 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@650 14052 #: ../en/ch11-mq.xml:309
dongsheng@627 14053 msgid ""
dongsheng@627 14054 "You may sometimes want to edit the <filename role=\"special\">series</"
dongsheng@627 14055 "filename> file by hand; for example, to change the sequence in which some "
dongsheng@627 14056 "patches are applied. However, manually editing the <filename role=\"special"
dongsheng@627 14057 "\">status</filename> file is almost always a bad idea, as it's easy to "
dongsheng@627 14058 "corrupt MQ's idea of what is happening."
dongsheng@627 14059 msgstr ""
dongsheng@627 14060
dongsheng@627 14061 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14062 #: ../en/ch11-mq.xml:318
dongsheng@627 14063 msgid ""
dongsheng@627 14064 "Once you have created your new patch, you can edit files in the working "
dongsheng@627 14065 "directory as you usually would. All of the normal Mercurial commands, such "
dongsheng@627 14066 "as <command role=\"hg-cmd\">hg diff</command> and <command role=\"hg-cmd\">hg "
dongsheng@627 14067 "annotate</command>, work exactly as they did before."
dongsheng@627 14068 msgstr ""
dongsheng@627 14069
dongsheng@627 14070 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14071 #: ../en/ch11-mq.xml:326
dongsheng@627 14072 msgid "Refreshing a patch"
dongsheng@636 14073 msgstr "刷新补丁"
dongsheng@627 14074
dongsheng@627 14075 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14076 #: ../en/ch11-mq.xml:328
dongsheng@627 14077 msgid ""
dongsheng@627 14078 "When you reach a point where you want to save your work, use the <command "
dongsheng@627 14079 "role=\"hg-ext-mq\">qrefresh</command> command to update the patch you are "
dongsheng@627 14080 "working on."
dongsheng@627 14081 msgstr ""
dongsheng@627 14082
dongsheng@627 14083 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14084 #: ../en/ch11-mq.xml:334
dongsheng@627 14085 msgid ""
dongsheng@627 14086 "This command folds the changes you have made in the working directory into "
dongsheng@627 14087 "your patch, and updates its corresponding changeset to contain those changes."
dongsheng@627 14088 msgstr ""
dongsheng@627 14089
dongsheng@627 14090 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14091 #: ../en/ch11-mq.xml:338
dongsheng@627 14092 msgid ""
dongsheng@627 14093 "You can run <command role=\"hg-ext-mq\">qrefresh</command> as often as you "
dongsheng@627 14094 "like, so it's a good way to <quote>checkpoint</quote> your work. Refresh "
dongsheng@627 14095 "your patch at an opportune time; try an experiment; and if the experiment "
dongsheng@627 14096 "doesn't work out, <command role=\"hg-cmd\">hg revert</command> your "
dongsheng@627 14097 "modifications back to the last time you refreshed."
dongsheng@627 14098 msgstr ""
dongsheng@627 14099
dongsheng@627 14100 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14101 #: ../en/ch11-mq.xml:349
dongsheng@627 14102 msgid "Stacking and tracking patches"
dongsheng@636 14103 msgstr "堆叠和跟踪补丁"
dongsheng@627 14104
dongsheng@627 14105 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14106 #: ../en/ch11-mq.xml:351
dongsheng@627 14107 msgid ""
dongsheng@627 14108 "Once you have finished working on a patch, or need to work on another, you "
dongsheng@627 14109 "can use the <command role=\"hg-ext-mq\">qnew</command> command again to "
dongsheng@627 14110 "create a new patch. Mercurial will apply this patch on top of your existing "
dongsheng@627 14111 "patch."
dongsheng@627 14112 msgstr ""
dongsheng@627 14113
dongsheng@627 14114 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14115 #: ../en/ch11-mq.xml:358
dongsheng@627 14116 msgid ""
dongsheng@627 14117 "Notice that the patch contains the changes in our prior patch as part of its "
dongsheng@627 14118 "context (you can see this more clearly in the output of <command role=\"hg-cmd"
dongsheng@627 14119 "\">hg annotate</command>)."
dongsheng@627 14120 msgstr ""
dongsheng@627 14121
dongsheng@627 14122 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14123 #: ../en/ch11-mq.xml:363
dongsheng@627 14124 msgid ""
dongsheng@627 14125 "So far, with the exception of <command role=\"hg-ext-mq\">qnew</command> and "
dongsheng@627 14126 "<command role=\"hg-ext-mq\">qrefresh</command>, we've been careful to only "
dongsheng@627 14127 "use regular Mercurial commands. However, MQ provides many commands that are "
dongsheng@627 14128 "easier to use when you are thinking about patches, as illustrated below."
dongsheng@627 14129 msgstr ""
dongsheng@627 14130
dongsheng@627 14131 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 14132 #: ../en/ch11-mq.xml:373
dongsheng@627 14133 msgid ""
dongsheng@627 14134 "The <command role=\"hg-ext-mq\">qseries</command> command lists every patch "
dongsheng@627 14135 "that MQ knows about in this repository, from oldest to newest (most recently "
dongsheng@627 14136 "<emphasis>created</emphasis>)."
dongsheng@627 14137 msgstr ""
dongsheng@627 14138
dongsheng@627 14139 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 14140 #: ../en/ch11-mq.xml:379
dongsheng@627 14141 msgid ""
dongsheng@627 14142 "The <command role=\"hg-ext-mq\">qapplied</command> command lists every patch "
dongsheng@627 14143 "that MQ has <emphasis>applied</emphasis> in this repository, again from "
dongsheng@627 14144 "oldest to newest (most recently applied)."
dongsheng@627 14145 msgstr ""
dongsheng@627 14146
dongsheng@627 14147 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14148 #: ../en/ch11-mq.xml:388
dongsheng@627 14149 msgid "Manipulating the patch stack"
dongsheng@636 14150 msgstr "操作补丁堆栈"
dongsheng@627 14151
dongsheng@627 14152 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14153 #: ../en/ch11-mq.xml:390
dongsheng@627 14154 msgid ""
dongsheng@627 14155 "The previous discussion implied that there must be a difference between "
dongsheng@627 14156 "<quote>known</quote> and <quote>applied</quote> patches, and there is. MQ "
dongsheng@627 14157 "can manage a patch without it being applied in the repository."
dongsheng@627 14158 msgstr ""
dongsheng@627 14159
dongsheng@627 14160 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14161 #: ../en/ch11-mq.xml:395
dongsheng@627 14162 msgid ""
dongsheng@627 14163 "An <emphasis>applied</emphasis> patch has a corresponding changeset in the "
dongsheng@627 14164 "repository, and the effects of the patch and changeset are visible in the "
dongsheng@627 14165 "working directory. You can undo the application of a patch using the "
dongsheng@627 14166 "<command role=\"hg-ext-mq\">qpop</command> command. MQ still <emphasis>knows "
dongsheng@627 14167 "about</emphasis>, or manages, a popped patch, but the patch no longer has a "
dongsheng@627 14168 "corresponding changeset in the repository, and the working directory does not "
songdongsheng@658 14169 "contain the changes made by the patch. <xref linkend=\"fig:mq:stack\"/> "
songdongsheng@658 14170 "illustrates the difference between applied and tracked patches."
songdongsheng@658 14171 msgstr ""
songdongsheng@658 14172
songdongsheng@658 14173 #. type: Content of: <book><chapter><sect1><sect2><figure><title>
songdongsheng@658 14174 #: ../en/ch11-mq.xml:408
songdongsheng@658 14175 msgid "Applied and unapplied patches in the MQ patch stack"
dongsheng@660 14176 msgstr "在 MQ 补丁堆栈中应用和撤销补丁"
songdongsheng@658 14177
songdongsheng@658 14178 #. type: Content of: <book><chapter><sect1><sect2><figure><mediaobject>
dongsheng@650 14179 #: ../en/ch11-mq.xml:411
songdongsheng@658 14180 msgid "<imageobject><imagedata fileref=\"figs/mq-stack.png\"/></imageobject>"
dongsheng@627 14181 msgstr ""
dongsheng@627 14182
dongsheng@627 14183 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14184 #: ../en/ch11-mq.xml:416
dongsheng@627 14185 msgid ""
dongsheng@627 14186 "You can reapply an unapplied, or popped, patch using the <command role=\"hg-"
dongsheng@627 14187 "ext-mq\">qpush</command> command. This creates a new changeset to correspond "
dongsheng@627 14188 "to the patch, and the patch's changes once again become present in the "
dongsheng@627 14189 "working directory. See below for examples of <command role=\"hg-ext-mq"
dongsheng@627 14190 "\">qpop</command> and <command role=\"hg-ext-mq\">qpush</command> in action."
dongsheng@627 14191 msgstr ""
dongsheng@627 14192
dongsheng@627 14193 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14194 #: ../en/ch11-mq.xml:425
dongsheng@627 14195 msgid ""
dongsheng@627 14196 "Notice that once we have popped a patch or two patches, the output of "
dongsheng@627 14197 "<command role=\"hg-ext-mq\">qseries</command> remains the same, while that of "
dongsheng@627 14198 "<command role=\"hg-ext-mq\">qapplied</command> has changed."
dongsheng@627 14199 msgstr ""
dongsheng@627 14200
dongsheng@627 14201 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 14202 #: ../en/ch11-mq.xml:433
dongsheng@627 14203 msgid "Pushing and popping many patches"
dongsheng@636 14204 msgstr "压入或弹出多个补丁"
dongsheng@627 14205
dongsheng@627 14206 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 14207 #: ../en/ch11-mq.xml:435
dongsheng@627 14208 msgid ""
dongsheng@627 14209 "While <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-"
dongsheng@627 14210 "mq\">qpop</command> each operate on a single patch at a time by default, you "
dongsheng@627 14211 "can push and pop many patches in one go. The <option role=\"hg-ext-mq-cmd-"
dongsheng@627 14212 "qpush-opt\">hg -a</option> option to <command role=\"hg-ext-mq\">qpush</"
dongsheng@627 14213 "command> causes it to push all unapplied patches, while the <option role=\"hg-"
dongsheng@627 14214 "ext-mq-cmd-qpop-opt\">-a</option> option to <command role=\"hg-ext-mq\">qpop</"
dongsheng@627 14215 "command> causes it to pop all applied patches. (For some more ways to push "
songdongsheng@658 14216 "and pop many patches, see <xref linkend=\"sec:mq:perf\"/> below.)"
dongsheng@627 14217 msgstr ""
dongsheng@627 14218
dongsheng@627 14219 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14220 #: ../en/ch11-mq.xml:451
dongsheng@627 14221 msgid "Safety checks, and overriding them"
dongsheng@636 14222 msgstr "安全的检查,然后覆盖它们"
dongsheng@627 14223
dongsheng@627 14224 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14225 #: ../en/ch11-mq.xml:453
dongsheng@627 14226 msgid ""
dongsheng@627 14227 "Several MQ commands check the working directory before they do anything, and "
dongsheng@627 14228 "fail if they find any modifications. They do this to ensure that you won't "
dongsheng@627 14229 "lose any changes that you have made, but not yet incorporated into a patch. "
dongsheng@627 14230 "The example below illustrates this; the <command role=\"hg-ext-mq\">qnew</"
dongsheng@627 14231 "command> command will not create a new patch if there are outstanding "
dongsheng@627 14232 "changes, caused in this case by the <command role=\"hg-cmd\">hg add</command> "
dongsheng@627 14233 "of <filename>file3</filename>."
dongsheng@627 14234 msgstr ""
dongsheng@627 14235
dongsheng@627 14236 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14237 #: ../en/ch11-mq.xml:465
dongsheng@627 14238 msgid ""
dongsheng@627 14239 "Commands that check the working directory all take an <quote>I know what I'm "
dongsheng@627 14240 "doing</quote> option, which is always named <option>-f</option>. The exact "
dongsheng@627 14241 "meaning of <option>-f</option> depends on the command. For example, <command "
dongsheng@627 14242 "role=\"hg-cmd\">hg qnew <option role=\"hg-ext-mq-cmd-qnew-opt\">hg -f</"
dongsheng@627 14243 "option></command> will incorporate any outstanding changes into the new patch "
dongsheng@627 14244 "it creates, but <command role=\"hg-cmd\">hg qpop <option role=\"hg-ext-mq-cmd-"
dongsheng@627 14245 "qpop-opt\">hg -f</option></command> will revert modifications to any files "
dongsheng@627 14246 "affected by the patch that it is popping. Be sure to read the documentation "
dongsheng@627 14247 "for a command's <option>-f</option> option before you use it!"
dongsheng@627 14248 msgstr ""
dongsheng@627 14249
dongsheng@627 14250 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14251 #: ../en/ch11-mq.xml:480
dongsheng@627 14252 msgid "Working on several patches at once"
dongsheng@636 14253 msgstr "同时处理多个补丁"
dongsheng@627 14254
dongsheng@627 14255 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14256 #: ../en/ch11-mq.xml:482
dongsheng@627 14257 msgid ""
dongsheng@627 14258 "The <command role=\"hg-ext-mq\">qrefresh</command> command always refreshes "
dongsheng@627 14259 "the <emphasis>topmost</emphasis> applied patch. This means that you can "
dongsheng@627 14260 "suspend work on one patch (by refreshing it), pop or push to make a different "
dongsheng@627 14261 "patch the top, and work on <emphasis>that</emphasis> patch for a while."
dongsheng@627 14262 msgstr ""
dongsheng@627 14263
dongsheng@627 14264 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14265 #: ../en/ch11-mq.xml:489
dongsheng@627 14266 msgid ""
dongsheng@627 14267 "Here's an example that illustrates how you can use this ability. Let's say "
dongsheng@627 14268 "you're developing a new feature as two patches. The first is a change to the "
dongsheng@661 14269 "core of your software, and the second—layered on top of the first—changes the "
dongsheng@661 14270 "user interface to use the code you just added to the core. If you notice a "
dongsheng@661 14271 "bug in the core while you're working on the UI patch, it's easy to fix the "
dongsheng@661 14272 "core. Simply <command role=\"hg-ext-mq\">qrefresh</command> the UI patch to "
dongsheng@661 14273 "save your in-progress changes, and <command role=\"hg-ext-mq\">qpop</command> "
dongsheng@661 14274 "down to the core patch. Fix the core bug, <command role=\"hg-ext-mq"
dongsheng@661 14275 "\">qrefresh</command> the core patch, and <command role=\"hg-ext-mq\">qpush</"
dongsheng@661 14276 "command> back to the UI patch to continue where you left off."
dongsheng@627 14277 msgstr ""
dongsheng@627 14278
dongsheng@627 14279 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14280 #: ../en/ch11-mq.xml:506
dongsheng@627 14281 msgid "More about patches"
dongsheng@636 14282 msgstr "关于补丁的更多信息"
dongsheng@627 14283
dongsheng@627 14284 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14285 #: ../en/ch11-mq.xml:508
dongsheng@627 14286 msgid ""
dongsheng@627 14287 "MQ uses the GNU <command>patch</command> command to apply patches, so it's "
dongsheng@627 14288 "helpful to know a few more detailed aspects of how <command>patch</command> "
dongsheng@627 14289 "works, and about patches themselves."
dongsheng@627 14290 msgstr ""
dongsheng@627 14291
dongsheng@627 14292 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14293 #: ../en/ch11-mq.xml:514
dongsheng@627 14294 msgid "The strip count"
dongsheng@636 14295 msgstr "修剪计数"
dongsheng@627 14296
dongsheng@627 14297 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14298 #: ../en/ch11-mq.xml:516
dongsheng@627 14299 msgid ""
dongsheng@627 14300 "If you look at the file headers in a patch, you will notice that the "
dongsheng@627 14301 "pathnames usually have an extra component on the front that isn't present in "
dongsheng@627 14302 "the actual path name. This is a holdover from the way that people used to "
dongsheng@627 14303 "generate patches (people still do this, but it's somewhat rare with modern "
dongsheng@627 14304 "revision control tools)."
dongsheng@627 14305 msgstr ""
dongsheng@627 14306
dongsheng@627 14307 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14308 #: ../en/ch11-mq.xml:523
dongsheng@627 14309 msgid ""
dongsheng@627 14310 "Alice would unpack a tarball, edit her files, then decide that she wanted to "
dongsheng@627 14311 "create a patch. So she'd rename her working directory, unpack the tarball "
dongsheng@627 14312 "again (hence the need for the rename), and use the <option role=\"cmd-opt-diff"
dongsheng@627 14313 "\">-r</option> and <option role=\"cmd-opt-diff\">-N</option> options to "
dongsheng@627 14314 "<command>diff</command> to recursively generate a patch between the "
dongsheng@627 14315 "unmodified directory and the modified one. The result would be that the name "
dongsheng@627 14316 "of the unmodified directory would be at the front of the left-hand path in "
dongsheng@627 14317 "every file header, and the name of the modified directory would be at the "
dongsheng@627 14318 "front of the right-hand path."
dongsheng@627 14319 msgstr ""
dongsheng@627 14320
dongsheng@627 14321 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14322 #: ../en/ch11-mq.xml:536
dongsheng@627 14323 msgid ""
dongsheng@627 14324 "Since someone receiving a patch from the Alices of the net would be unlikely "
dongsheng@627 14325 "to have unmodified and modified directories with exactly the same names, the "
dongsheng@627 14326 "<command>patch</command> command has a <option role=\"cmd-opt-patch\">-p</"
dongsheng@627 14327 "option> option that indicates the number of leading path name components to "
dongsheng@627 14328 "strip when trying to apply a patch. This number is called the "
dongsheng@627 14329 "<emphasis>strip count</emphasis>."
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:544
dongsheng@627 14334 msgid ""
dongsheng@627 14335 "An option of <quote><literal>-p1</literal></quote> means <quote>use a strip "
dongsheng@627 14336 "count of one</quote>. If <command>patch</command> sees a file name "
dongsheng@627 14337 "<filename>foo/bar/baz</filename> in a file header, it will strip "
dongsheng@627 14338 "<filename>foo</filename> and try to patch a file named <filename>bar/baz</"
dongsheng@627 14339 "filename>. (Strictly speaking, the strip count refers to the number of "
dongsheng@627 14340 "<emphasis>path separators</emphasis> (and the components that go with them ) "
dongsheng@627 14341 "to strip. A strip count of one will turn <filename>foo/bar</filename> into "
dongsheng@627 14342 "<filename>bar</filename>, but <filename>/foo/bar</filename> (notice the extra "
dongsheng@627 14343 "leading slash) into <filename>foo/bar</filename>.)"
dongsheng@627 14344 msgstr ""
dongsheng@627 14345
dongsheng@627 14346 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14347 #: ../en/ch11-mq.xml:557
dongsheng@627 14348 msgid ""
dongsheng@627 14349 "The <quote>standard</quote> strip count for patches is one; almost all "
dongsheng@627 14350 "patches contain one leading path name component that needs to be stripped. "
dongsheng@627 14351 "Mercurial's <command role=\"hg-cmd\">hg diff</command> command generates path "
dongsheng@627 14352 "names in this form, and the <command role=\"hg-cmd\">hg import</command> "
dongsheng@627 14353 "command and MQ expect patches to have a strip count of one."
dongsheng@627 14354 msgstr ""
dongsheng@627 14355
dongsheng@627 14356 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14357 #: ../en/ch11-mq.xml:565
dongsheng@627 14358 msgid ""
dongsheng@627 14359 "If you receive a patch from someone that you want to add to your patch queue, "
dongsheng@627 14360 "and the patch needs a strip count other than one, you cannot just <command "
dongsheng@627 14361 "role=\"hg-ext-mq\">qimport</command> the patch, because <command role=\"hg-"
dongsheng@627 14362 "ext-mq\">qimport</command> does not yet have a <literal>-p</literal> option "
dongsheng@627 14363 "(see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/mercurial/bts/"
dongsheng@627 14364 "issue311\">issue 311</ulink>). Your best bet is to <command role=\"hg-ext-mq"
dongsheng@627 14365 "\">qnew</command> a patch of your own, then use <command>patch -pN</command> "
dongsheng@627 14366 "to apply their patch, followed by <command role=\"hg-cmd\">hg addremove</"
dongsheng@627 14367 "command> to pick up any files added or removed by the patch, followed by "
dongsheng@627 14368 "<command role=\"hg-ext-mq\">hg qrefresh</command>. This complexity may become "
dongsheng@627 14369 "unnecessary; see <ulink role=\"hg-bug\" url=\"http://www.selenic.com/"
dongsheng@627 14370 "mercurial/bts/issue311\">issue 311</ulink> for details."
dongsheng@627 14371 msgstr ""
dongsheng@627 14372
dongsheng@627 14373 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14374 #: ../en/ch11-mq.xml:584
dongsheng@627 14375 msgid "Strategies for applying a patch"
dongsheng@636 14376 msgstr "应用补丁的策略"
dongsheng@627 14377
dongsheng@627 14378 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14379 #: ../en/ch11-mq.xml:586
dongsheng@627 14380 msgid ""
dongsheng@627 14381 "When <command>patch</command> applies a hunk, it tries a handful of "
dongsheng@627 14382 "successively less accurate strategies to try to make the hunk apply. This "
dongsheng@627 14383 "falling-back technique often makes it possible to take a patch that was "
dongsheng@627 14384 "generated against an old version of a file, and apply it against a newer "
dongsheng@627 14385 "version of that file."
dongsheng@627 14386 msgstr ""
dongsheng@627 14387
dongsheng@627 14388 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14389 #: ../en/ch11-mq.xml:593
dongsheng@627 14390 msgid ""
dongsheng@627 14391 "First, <command>patch</command> tries an exact match, where the line numbers, "
dongsheng@627 14392 "the context, and the text to be modified must apply exactly. If it cannot "
dongsheng@627 14393 "make an exact match, it tries to find an exact match for the context, without "
dongsheng@627 14394 "honouring the line numbering information. If this succeeds, it prints a line "
dongsheng@627 14395 "of output saying that the hunk was applied, but at some <emphasis>offset</"
dongsheng@627 14396 "emphasis> from the original line number."
dongsheng@627 14397 msgstr ""
dongsheng@627 14398
dongsheng@627 14399 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14400 #: ../en/ch11-mq.xml:602
dongsheng@627 14401 msgid ""
dongsheng@627 14402 "If a context-only match fails, <command>patch</command> removes the first and "
dongsheng@627 14403 "last lines of the context, and tries a <emphasis>reduced</emphasis> context-"
dongsheng@627 14404 "only match. If the hunk with reduced context succeeds, it prints a message "
dongsheng@627 14405 "saying that it applied the hunk with a <emphasis>fuzz factor</emphasis> (the "
dongsheng@627 14406 "number after the fuzz factor indicates how many lines of context "
dongsheng@627 14407 "<command>patch</command> had to trim before the patch applied)."
dongsheng@627 14408 msgstr ""
dongsheng@627 14409
dongsheng@627 14410 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14411 #: ../en/ch11-mq.xml:611
dongsheng@627 14412 msgid ""
dongsheng@627 14413 "When neither of these techniques works, <command>patch</command> prints a "
dongsheng@627 14414 "message saying that the hunk in question was rejected. It saves rejected "
dongsheng@627 14415 "hunks (also simply called <quote>rejects</quote>) to a file with the same "
dongsheng@627 14416 "name, and an added <filename role=\"special\">.rej</filename> extension. It "
dongsheng@627 14417 "also saves an unmodified copy of the file with a <filename role=\"special\">."
dongsheng@627 14418 "orig</filename> extension; the copy of the file without any extensions will "
dongsheng@627 14419 "contain any changes made by hunks that <emphasis>did</emphasis> apply "
dongsheng@627 14420 "cleanly. If you have a patch that modifies <filename>foo</filename> with six "
dongsheng@627 14421 "hunks, and one of them fails to apply, you will have: an unmodified "
dongsheng@627 14422 "<filename>foo.orig</filename>, a <filename>foo.rej</filename> containing one "
dongsheng@627 14423 "hunk, and <filename>foo</filename>, containing the changes made by the five "
dongsheng@627 14424 "successful hunks."
dongsheng@627 14425 msgstr ""
dongsheng@627 14426
dongsheng@627 14427 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14428 #: ../en/ch11-mq.xml:629
dongsheng@627 14429 msgid "Some quirks of patch representation"
dongsheng@636 14430 msgstr "补丁的一些特性"
dongsheng@627 14431
dongsheng@627 14432 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14433 #: ../en/ch11-mq.xml:631
dongsheng@627 14434 msgid ""
dongsheng@627 14435 "There are a few useful things to know about how <command>patch</command> "
dongsheng@627 14436 "works with files."
dongsheng@627 14437 msgstr ""
dongsheng@627 14438
dongsheng@627 14439 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14440 #: ../en/ch11-mq.xml:634
dongsheng@627 14441 msgid ""
dongsheng@627 14442 "This should already be obvious, but <command>patch</command> cannot handle "
dongsheng@627 14443 "binary files."
dongsheng@627 14444 msgstr ""
dongsheng@627 14445
dongsheng@627 14446 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14447 #: ../en/ch11-mq.xml:638
dongsheng@627 14448 msgid ""
dongsheng@627 14449 "Neither does it care about the executable bit; it creates new files as "
dongsheng@627 14450 "readable, but not executable."
dongsheng@627 14451 msgstr ""
dongsheng@627 14452
dongsheng@627 14453 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14454 #: ../en/ch11-mq.xml:642
dongsheng@627 14455 msgid ""
dongsheng@627 14456 "<command>patch</command> treats the removal of a file as a diff between the "
dongsheng@627 14457 "file to be removed and the empty file. So your idea of <quote>I deleted this "
dongsheng@627 14458 "file</quote> looks like <quote>every line of this file was deleted</quote> in "
dongsheng@627 14459 "a patch."
dongsheng@627 14460 msgstr ""
dongsheng@627 14461
dongsheng@627 14462 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14463 #: ../en/ch11-mq.xml:648
dongsheng@627 14464 msgid ""
dongsheng@627 14465 "It treats the addition of a file as a diff between the empty file and the "
dongsheng@627 14466 "file to be added. So in a patch, your idea of <quote>I added this file</"
dongsheng@627 14467 "quote> looks like <quote>every line of this file was added</quote>."
dongsheng@627 14468 msgstr ""
dongsheng@627 14469
dongsheng@627 14470 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14471 #: ../en/ch11-mq.xml:654
dongsheng@627 14472 msgid ""
dongsheng@627 14473 "It treats a renamed file as the removal of the old name, and the addition of "
dongsheng@627 14474 "the new name. This means that renamed files have a big footprint in "
dongsheng@627 14475 "patches. (Note also that Mercurial does not currently try to infer when "
dongsheng@627 14476 "files have been renamed or copied in a patch.)"
dongsheng@627 14477 msgstr ""
dongsheng@627 14478
dongsheng@627 14479 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14480 #: ../en/ch11-mq.xml:660
dongsheng@627 14481 msgid ""
dongsheng@627 14482 "<command>patch</command> cannot represent empty files, so you cannot use a "
dongsheng@627 14483 "patch to represent the notion <quote>I added this empty file to the tree</"
dongsheng@627 14484 "quote>."
dongsheng@627 14485 msgstr ""
dongsheng@627 14486
dongsheng@627 14487 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14488 #: ../en/ch11-mq.xml:667
dongsheng@627 14489 msgid "Beware the fuzz"
dongsheng@636 14490 msgstr "当心毛刺"
dongsheng@627 14491
dongsheng@627 14492 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14493 #: ../en/ch11-mq.xml:669
dongsheng@627 14494 msgid ""
dongsheng@627 14495 "While applying a hunk at an offset, or with a fuzz factor, will often be "
dongsheng@627 14496 "completely successful, these inexact techniques naturally leave open the "
dongsheng@627 14497 "possibility of corrupting the patched file. The most common cases typically "
dongsheng@627 14498 "involve applying a patch twice, or at an incorrect location in the file. If "
dongsheng@627 14499 "<command>patch</command> or <command role=\"hg-ext-mq\">qpush</command> ever "
dongsheng@627 14500 "mentions an offset or fuzz factor, you should make sure that the modified "
dongsheng@627 14501 "files are correct afterwards."
dongsheng@627 14502 msgstr ""
dongsheng@627 14503
dongsheng@627 14504 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14505 #: ../en/ch11-mq.xml:679
dongsheng@627 14506 msgid ""
dongsheng@627 14507 "It's often a good idea to refresh a patch that has applied with an offset or "
dongsheng@627 14508 "fuzz factor; refreshing the patch generates new context information that will "
dongsheng@627 14509 "make it apply cleanly. I say <quote>often,</quote> not <quote>always,</"
dongsheng@627 14510 "quote> because sometimes refreshing a patch will make it fail to apply "
dongsheng@627 14511 "against a different revision of the underlying files. In some cases, such as "
dongsheng@627 14512 "when you're maintaining a patch that must sit on top of multiple versions of "
dongsheng@627 14513 "a source tree, it's acceptable to have a patch apply with some fuzz, provided "
dongsheng@627 14514 "you've verified the results of the patching process in such cases."
dongsheng@627 14515 msgstr ""
dongsheng@627 14516
dongsheng@627 14517 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14518 #: ../en/ch11-mq.xml:692
dongsheng@627 14519 msgid "Handling rejection"
dongsheng@636 14520 msgstr "处理拒绝"
dongsheng@627 14521
dongsheng@627 14522 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14523 #: ../en/ch11-mq.xml:694
dongsheng@627 14524 msgid ""
dongsheng@627 14525 "If <command role=\"hg-ext-mq\">qpush</command> fails to apply a patch, it "
dongsheng@627 14526 "will print an error message and exit. If it has left <filename role=\"special"
dongsheng@627 14527 "\">.rej</filename> files behind, it is usually best to fix up the rejected "
dongsheng@627 14528 "hunks before you push more patches or do any further work."
dongsheng@627 14529 msgstr ""
dongsheng@627 14530
dongsheng@627 14531 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14532 #: ../en/ch11-mq.xml:700
dongsheng@627 14533 msgid ""
dongsheng@627 14534 "If your patch <emphasis>used to</emphasis> apply cleanly, and no longer does "
dongsheng@627 14535 "because you've changed the underlying code that your patches are based on, "
songdongsheng@658 14536 "Mercurial Queues can help; see <xref linkend=\"sec:mq:merge\"/> for details."
songdongsheng@658 14537 msgstr ""
songdongsheng@658 14538
songdongsheng@658 14539 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14540 #: ../en/ch11-mq.xml:705
dongsheng@627 14541 msgid ""
dongsheng@627 14542 "Unfortunately, there aren't any great techniques for dealing with rejected "
dongsheng@627 14543 "hunks. Most often, you'll need to view the <filename role=\"special\">.rej</"
dongsheng@627 14544 "filename> file and edit the target file, applying the rejected hunks by hand."
dongsheng@627 14545 msgstr ""
dongsheng@627 14546
dongsheng@627 14547 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14548 #: ../en/ch11-mq.xml:710
dongsheng@627 14549 msgid ""
dongsheng@627 14550 "If you're feeling adventurous, Neil Brown, a Linux kernel hacker, wrote a "
dongsheng@627 14551 "tool called <command>wiggle</command> <citation>web:wiggle</citation>, which "
dongsheng@627 14552 "is more vigorous than <command>patch</command> in its attempts to make a "
dongsheng@627 14553 "patch apply."
dongsheng@627 14554 msgstr ""
dongsheng@627 14555
dongsheng@627 14556 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14557 #: ../en/ch11-mq.xml:716
dongsheng@627 14558 msgid ""
dongsheng@627 14559 "Another Linux kernel hacker, Chris Mason (the author of Mercurial Queues), "
dongsheng@627 14560 "wrote a similar tool called <command>mpatch</command> <citation>web:mpatch</"
dongsheng@627 14561 "citation>, which takes a simple approach to automating the application of "
dongsheng@627 14562 "hunks rejected by <command>patch</command>. The <command>mpatch</command> "
dongsheng@627 14563 "command can help with four common reasons that a hunk may be rejected:"
dongsheng@627 14564 msgstr ""
dongsheng@627 14565
dongsheng@627 14566 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14567 #: ../en/ch11-mq.xml:725
dongsheng@627 14568 msgid "The context in the middle of a hunk has changed."
dongsheng@627 14569 msgstr ""
dongsheng@627 14570
dongsheng@627 14571 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14572 #: ../en/ch11-mq.xml:728
dongsheng@627 14573 msgid "A hunk is missing some context at the beginning or end."
dongsheng@627 14574 msgstr ""
dongsheng@627 14575
dongsheng@627 14576 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14577 #: ../en/ch11-mq.xml:731
dongsheng@627 14578 msgid ""
dongsheng@661 14579 "A large hunk might apply better—either entirely or in part&emdash;if it was "
dongsheng@661 14580 "broken up into smaller hunks."
dongsheng@627 14581 msgstr ""
dongsheng@627 14582
dongsheng@627 14583 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 14584 #: ../en/ch11-mq.xml:735
dongsheng@627 14585 msgid ""
dongsheng@627 14586 "A hunk removes lines with slightly different content than those currently "
dongsheng@627 14587 "present in the file."
dongsheng@627 14588 msgstr ""
dongsheng@627 14589
dongsheng@627 14590 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14591 #: ../en/ch11-mq.xml:739
dongsheng@627 14592 msgid ""
dongsheng@627 14593 "If you use <command>wiggle</command> or <command>mpatch</command>, you should "
dongsheng@627 14594 "be doubly careful to check your results when you're done. In fact, "
dongsheng@627 14595 "<command>mpatch</command> enforces this method of double-checking the tool's "
dongsheng@627 14596 "output, by automatically dropping you into a merge program when it has done "
dongsheng@627 14597 "its job, so that you can verify its work and finish off any remaining merges."
dongsheng@627 14598 msgstr ""
dongsheng@627 14599
dongsheng@627 14600 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14601 #: ../en/ch11-mq.xml:751
dongsheng@627 14602 msgid "Getting the best performance out of MQ"
dongsheng@636 14603 msgstr "MQ 的性能"
dongsheng@627 14604
dongsheng@627 14605 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14606 #: ../en/ch11-mq.xml:753
dongsheng@627 14607 msgid ""
dongsheng@627 14608 "MQ is very efficient at handling a large number of patches. I ran some "
dongsheng@627 14609 "performance experiments in mid-2006 for a talk that I gave at the 2006 "
dongsheng@627 14610 "EuroPython conference <citation>web:europython</citation>. I used as my data "
dongsheng@627 14611 "set the Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. I "
dongsheng@627 14612 "applied these on top of a Linux kernel repository containing all 27,472 "
dongsheng@627 14613 "revisions between Linux 2.6.12-rc2 and Linux 2.6.17."
dongsheng@627 14614 msgstr ""
dongsheng@627 14615
dongsheng@627 14616 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14617 #: ../en/ch11-mq.xml:762
dongsheng@627 14618 msgid ""
dongsheng@627 14619 "On my old, slow laptop, I was able to <command role=\"hg-cmd\">hg qpush "
dongsheng@627 14620 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option></command> all 1,738 "
dongsheng@627 14621 "patches in 3.5 minutes, and <command role=\"hg-cmd\">hg qpop <option role="
dongsheng@627 14622 "\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> them all in 30 seconds. "
dongsheng@627 14623 "(On a newer laptop, the time to push all patches dropped to two minutes.) I "
dongsheng@627 14624 "could <command role=\"hg-ext-mq\">qrefresh</command> one of the biggest "
dongsheng@627 14625 "patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds."
dongsheng@627 14626 msgstr ""
dongsheng@627 14627
dongsheng@627 14628 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14629 #: ../en/ch11-mq.xml:773
dongsheng@627 14630 msgid ""
dongsheng@627 14631 "Clearly, MQ is well suited to working in large trees, but there are a few "
dongsheng@627 14632 "tricks you can use to get the best performance of it."
dongsheng@627 14633 msgstr ""
dongsheng@627 14634
dongsheng@627 14635 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14636 #: ../en/ch11-mq.xml:777
dongsheng@627 14637 msgid ""
dongsheng@627 14638 "First of all, try to <quote>batch</quote> operations together. Every time "
dongsheng@627 14639 "you run <command role=\"hg-ext-mq\">qpush</command> or <command role=\"hg-ext-"
dongsheng@627 14640 "mq\">qpop</command>, these commands scan the working directory once to make "
dongsheng@627 14641 "sure you haven't made some changes and then forgotten to run <command role="
dongsheng@627 14642 "\"hg-ext-mq\">qrefresh</command>. On a small tree, the time that this scan "
dongsheng@627 14643 "takes is unnoticeable. However, on a medium-sized tree (containing tens of "
dongsheng@627 14644 "thousands of files), it can take a second or more."
dongsheng@627 14645 msgstr ""
dongsheng@627 14646
dongsheng@627 14647 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14648 #: ../en/ch11-mq.xml:788
dongsheng@627 14649 msgid ""
dongsheng@627 14650 "The <command role=\"hg-ext-mq\">qpush</command> and <command role=\"hg-ext-mq"
dongsheng@627 14651 "\">qpop</command> commands allow you to push and pop multiple patches at a "
dongsheng@627 14652 "time. You can identify the <quote>destination patch</quote> that you want to "
dongsheng@627 14653 "end up at. When you <command role=\"hg-ext-mq\">qpush</command> with a "
dongsheng@627 14654 "destination specified, it will push patches until that patch is at the top of "
dongsheng@627 14655 "the applied stack. When you <command role=\"hg-ext-mq\">qpop</command> to a "
dongsheng@627 14656 "destination, MQ will pop patches until the destination patch is at the top."
dongsheng@627 14657 msgstr ""
dongsheng@627 14658
dongsheng@627 14659 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14660 #: ../en/ch11-mq.xml:798
dongsheng@627 14661 msgid ""
dongsheng@627 14662 "You can identify a destination patch using either the name of the patch, or "
dongsheng@627 14663 "by number. If you use numeric addressing, patches are counted from zero; "
dongsheng@627 14664 "this means that the first patch is zero, the second is one, and so on."
dongsheng@627 14665 msgstr ""
dongsheng@627 14666
dongsheng@627 14667 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14668 #: ../en/ch11-mq.xml:805
dongsheng@627 14669 msgid "Updating your patches when the underlying code changes"
dongsheng@636 14670 msgstr "当基础代码改变时,更新补丁的方法"
dongsheng@627 14671
dongsheng@627 14672 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14673 #: ../en/ch11-mq.xml:808
dongsheng@627 14674 msgid ""
dongsheng@627 14675 "It's common to have a stack of patches on top of an underlying repository "
dongsheng@627 14676 "that you don't modify directly. If you're working on changes to third-party "
dongsheng@627 14677 "code, or on a feature that is taking longer to develop than the rate of "
dongsheng@627 14678 "change of the code beneath, you will often need to sync up with the "
dongsheng@627 14679 "underlying code, and fix up any hunks in your patches that no longer apply. "
dongsheng@627 14680 "This is called <emphasis>rebasing</emphasis> your patch series."
dongsheng@627 14681 msgstr ""
dongsheng@627 14682
dongsheng@627 14683 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14684 #: ../en/ch11-mq.xml:817
dongsheng@627 14685 msgid ""
dongsheng@627 14686 "The simplest way to do this is to <command role=\"hg-cmd\">hg qpop <option "
dongsheng@627 14687 "role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches, then "
dongsheng@627 14688 "<command role=\"hg-cmd\">hg pull</command> changes into the underlying "
dongsheng@627 14689 "repository, and finally <command role=\"hg-cmd\">hg qpush <option role=\"hg-"
dongsheng@627 14690 "ext-mq-cmd-qpop-opt\">hg -a</option></command> your patches again. MQ will "
dongsheng@627 14691 "stop pushing any time it runs across a patch that fails to apply during "
dongsheng@627 14692 "conflicts, allowing you to fix your conflicts, <command role=\"hg-ext-mq"
dongsheng@627 14693 "\">qrefresh</command> the affected patch, and continue pushing until you have "
dongsheng@627 14694 "fixed your entire stack."
dongsheng@627 14695 msgstr ""
dongsheng@627 14696
dongsheng@627 14697 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14698 #: ../en/ch11-mq.xml:829
dongsheng@627 14699 msgid ""
dongsheng@627 14700 "This approach is easy to use and works well if you don't expect changes to "
dongsheng@627 14701 "the underlying code to affect how well your patches apply. If your patch "
dongsheng@627 14702 "stack touches code that is modified frequently or invasively in the "
dongsheng@627 14703 "underlying repository, however, fixing up rejected hunks by hand quickly "
dongsheng@627 14704 "becomes tiresome."
dongsheng@627 14705 msgstr ""
dongsheng@627 14706
dongsheng@627 14707 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14708 #: ../en/ch11-mq.xml:836
dongsheng@627 14709 msgid ""
dongsheng@627 14710 "It's possible to partially automate the rebasing process. If your patches "
dongsheng@627 14711 "apply cleanly against some revision of the underlying repo, MQ can use this "
dongsheng@627 14712 "information to help you to resolve conflicts between your patches and a "
dongsheng@627 14713 "different revision."
dongsheng@627 14714 msgstr ""
dongsheng@627 14715
dongsheng@627 14716 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14717 #: ../en/ch11-mq.xml:842
songdongsheng@658 14718 msgid "The process is a little involved."
songdongsheng@658 14719 msgstr ""
songdongsheng@658 14720
songdongsheng@658 14721 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 14722 #: ../en/ch11-mq.xml:844
dongsheng@627 14723 msgid ""
dongsheng@627 14724 "To begin, <command role=\"hg-cmd\">hg qpush -a</command> all of your patches "
dongsheng@627 14725 "on top of the revision where you know that they apply cleanly."
dongsheng@627 14726 msgstr ""
dongsheng@627 14727
dongsheng@627 14728 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
songdongsheng@658 14729 #: ../en/ch11-mq.xml:848
dongsheng@627 14730 msgid ""
dongsheng@627 14731 "Save a backup copy of your patch directory using <command role=\"hg-cmd\">hg "
dongsheng@627 14732 "qsave <option role=\"hg-ext-mq-cmd-qsave-opt\">hg -e</option> <option role="
dongsheng@627 14733 "\"hg-ext-mq-cmd-qsave-opt\">hg -c</option></command>. This prints the name "
dongsheng@627 14734 "of the directory that it has saved the patches in. It will save the patches "
dongsheng@627 14735 "to a directory called <filename role=\"special\" class=\"directory\">.hg/"
dongsheng@627 14736 "patches.N</filename>, where <literal>N</literal> is a small integer. It also "
dongsheng@627 14737 "commits a <quote>save changeset</quote> on top of your applied patches; this "
dongsheng@627 14738 "is for internal book-keeping, and records the states of the <filename role="
dongsheng@627 14739 "\"special\">series</filename> and <filename role=\"special\">status</"
dongsheng@627 14740 "filename> files."
dongsheng@627 14741 msgstr ""
dongsheng@627 14742
dongsheng@627 14743 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
songdongsheng@658 14744 #: ../en/ch11-mq.xml:862
dongsheng@627 14745 msgid ""
dongsheng@627 14746 "Use <command role=\"hg-cmd\">hg pull</command> to bring new changes into the "
dongsheng@627 14747 "underlying repository. (Don't run <command role=\"hg-cmd\">hg pull -u</"
dongsheng@627 14748 "command>; see below for why.)"
dongsheng@627 14749 msgstr ""
dongsheng@627 14750
dongsheng@627 14751 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
songdongsheng@658 14752 #: ../en/ch11-mq.xml:867
dongsheng@627 14753 msgid ""
dongsheng@627 14754 "Update to the new tip revision, using <command role=\"hg-cmd\">hg update "
dongsheng@627 14755 "<option role=\"hg-opt-update\">-C</option></command> to override the patches "
dongsheng@627 14756 "you have pushed."
dongsheng@627 14757 msgstr ""
dongsheng@627 14758
dongsheng@627 14759 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
songdongsheng@658 14760 #: ../en/ch11-mq.xml:872
dongsheng@650 14761 msgid ""
dongsheng@650 14762 "Merge all patches using <command>hg qpush -m -a</command>. The <option role="
dongsheng@650 14763 "\"hg-ext-mq-cmd-qpush-opt\">-m</option> option to <command role=\"hg-ext-mq"
dongsheng@650 14764 "\">qpush</command> tells MQ to perform a three-way merge if the patch fails "
dongsheng@650 14765 "to apply."
dongsheng@650 14766 msgstr ""
dongsheng@650 14767
dongsheng@650 14768 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14769 #: ../en/ch11-mq.xml:880
dongsheng@627 14770 msgid ""
dongsheng@627 14771 "During the <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-"
dongsheng@627 14772 "qpush-opt\">hg -m</option></command>, each patch in the <filename role="
dongsheng@627 14773 "\"special\">series</filename> file is applied normally. If a patch applies "
dongsheng@627 14774 "with fuzz or rejects, MQ looks at the queue you <command role=\"hg-ext-mq"
dongsheng@627 14775 "\">qsave</command>d, and performs a three-way merge with the corresponding "
dongsheng@627 14776 "changeset. This merge uses Mercurial's normal merge machinery, so it may pop "
dongsheng@627 14777 "up a GUI merge tool to help you to resolve problems."
dongsheng@627 14778 msgstr ""
dongsheng@627 14779
dongsheng@627 14780 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14781 #: ../en/ch11-mq.xml:890
dongsheng@627 14782 msgid ""
dongsheng@627 14783 "When you finish resolving the effects of a patch, MQ refreshes your patch "
dongsheng@627 14784 "based on the result of the merge."
dongsheng@627 14785 msgstr ""
dongsheng@627 14786
dongsheng@627 14787 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14788 #: ../en/ch11-mq.xml:893
dongsheng@627 14789 msgid ""
dongsheng@627 14790 "At the end of this process, your repository will have one extra head from the "
dongsheng@627 14791 "old patch queue, and a copy of the old patch queue will be in <filename role="
dongsheng@627 14792 "\"special\" class=\"directory\">.hg/patches.N</filename>. You can remove the "
dongsheng@627 14793 "extra head using <command role=\"hg-cmd\">hg qpop -a -n patches.N</command> "
dongsheng@627 14794 "or <command role=\"hg-cmd\">hg strip</command>. You can delete <filename "
dongsheng@627 14795 "role=\"special\" class=\"directory\">.hg/patches.N</filename> once you are "
dongsheng@627 14796 "sure that you no longer need it as a backup."
dongsheng@627 14797 msgstr ""
dongsheng@627 14798
dongsheng@627 14799 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14800 #: ../en/ch11-mq.xml:905
dongsheng@627 14801 msgid "Identifying patches"
dongsheng@636 14802 msgstr "标识补丁"
dongsheng@627 14803
dongsheng@627 14804 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14805 #: ../en/ch11-mq.xml:907
dongsheng@627 14806 msgid ""
dongsheng@627 14807 "MQ commands that work with patches let you refer to a patch either by using "
dongsheng@627 14808 "its name or by a number. By name is obvious enough; pass the name "
dongsheng@627 14809 "<filename>foo.patch</filename> to <command role=\"hg-ext-mq\">qpush</"
dongsheng@627 14810 "command>, for example, and it will push patches until <filename>foo.patch</"
dongsheng@627 14811 "filename> is applied."
dongsheng@627 14812 msgstr ""
dongsheng@627 14813
dongsheng@627 14814 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14815 #: ../en/ch11-mq.xml:914
dongsheng@627 14816 msgid ""
dongsheng@627 14817 "As a shortcut, you can refer to a patch using both a name and a numeric "
dongsheng@627 14818 "offset; <literal>foo.patch-2</literal> means <quote>two patches before "
dongsheng@627 14819 "<literal>foo.patch</literal></quote>, while <literal>bar.patch+4</literal> "
dongsheng@627 14820 "means <quote>four patches after <literal>bar.patch</literal></quote>."
dongsheng@627 14821 msgstr ""
dongsheng@627 14822
dongsheng@627 14823 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14824 #: ../en/ch11-mq.xml:920
dongsheng@627 14825 msgid ""
dongsheng@627 14826 "Referring to a patch by index isn't much different. The first patch printed "
dongsheng@627 14827 "in the output of <command role=\"hg-ext-mq\">qseries</command> is patch zero "
dongsheng@627 14828 "(yes, it's one of those start-at-zero counting systems); the second is patch "
dongsheng@627 14829 "one; and so on."
dongsheng@627 14830 msgstr ""
dongsheng@627 14831
dongsheng@627 14832 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14833 #: ../en/ch11-mq.xml:926
dongsheng@627 14834 msgid ""
dongsheng@627 14835 "MQ also makes it easy to work with patches when you are using normal "
dongsheng@627 14836 "Mercurial commands. Every command that accepts a changeset ID will also "
dongsheng@627 14837 "accept the name of an applied patch. MQ augments the tags normally in the "
dongsheng@627 14838 "repository with an eponymous one for each applied patch. In addition, the "
dongsheng@650 14839 "special tags <literal role=\"tag\">qbase</literal> and <literal role=\"tag"
dongsheng@650 14840 "\">qtip</literal> identify the <quote>bottom-most</quote> and topmost applied "
dongsheng@650 14841 "patches, respectively."
dongsheng@650 14842 msgstr ""
dongsheng@650 14843
dongsheng@650 14844 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14845 #: ../en/ch11-mq.xml:936
dongsheng@627 14846 msgid ""
dongsheng@627 14847 "These additions to Mercurial's normal tagging capabilities make dealing with "
dongsheng@627 14848 "patches even more of a breeze."
dongsheng@627 14849 msgstr ""
dongsheng@627 14850
dongsheng@627 14851 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14852 #: ../en/ch11-mq.xml:939
dongsheng@627 14853 msgid "Want to patchbomb a mailing list with your latest series of changes?"
dongsheng@627 14854 msgstr ""
dongsheng@627 14855
dongsheng@627 14856 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14857 #: ../en/ch11-mq.xml:942
songdongsheng@658 14858 msgid ""
songdongsheng@658 14859 "(Don't know what <quote>patchbombing</quote> is? See <xref linkend=\"sec:"
songdongsheng@658 14860 "hgext:patchbomb\"/>.)"
dongsheng@627 14861 msgstr ""
dongsheng@627 14862
dongsheng@627 14863 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14864 #: ../en/ch11-mq.xml:945
dongsheng@627 14865 msgid ""
dongsheng@627 14866 "Need to see all of the patches since <literal>foo.patch</literal> that have "
dongsheng@627 14867 "touched files in a subdirectory of your tree?"
dongsheng@627 14868 msgstr ""
dongsheng@627 14869
dongsheng@650 14870 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14871 #: ../en/ch11-mq.xml:952
dongsheng@627 14872 msgid ""
dongsheng@627 14873 "Because MQ makes the names of patches available to the rest of Mercurial "
dongsheng@627 14874 "through its normal internal tag machinery, you don't need to type in the "
dongsheng@627 14875 "entire name of a patch when you want to identify it by name."
dongsheng@627 14876 msgstr ""
dongsheng@627 14877
dongsheng@627 14878 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14879 #: ../en/ch11-mq.xml:957
dongsheng@627 14880 msgid ""
dongsheng@627 14881 "Another nice consequence of representing patch names as tags is that when you "
dongsheng@627 14882 "run the <command role=\"hg-cmd\">hg log</command> command, it will display a "
dongsheng@627 14883 "patch's name as a tag, simply as part of its normal output. This makes it "
dongsheng@627 14884 "easy to visually distinguish applied patches from underlying <quote>normal</"
dongsheng@627 14885 "quote> revisions. The following example shows a few normal Mercurial "
dongsheng@627 14886 "commands in use with applied patches."
dongsheng@627 14887 msgstr ""
dongsheng@627 14888
dongsheng@627 14889 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14890 #: ../en/ch11-mq.xml:970
dongsheng@627 14891 msgid "Useful things to know about"
dongsheng@636 14892 msgstr "其它需要了解的东西"
dongsheng@627 14893
dongsheng@627 14894 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14895 #: ../en/ch11-mq.xml:972
dongsheng@627 14896 msgid ""
dongsheng@627 14897 "There are a number of aspects of MQ usage that don't fit tidily into sections "
dongsheng@627 14898 "of their own, but that are good to know. Here they are, in one place."
dongsheng@627 14899 msgstr ""
dongsheng@627 14900
dongsheng@627 14901 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14902 #: ../en/ch11-mq.xml:977
dongsheng@627 14903 msgid ""
dongsheng@627 14904 "Normally, when you <command role=\"hg-ext-mq\">qpop</command> a patch and "
dongsheng@627 14905 "<command role=\"hg-ext-mq\">qpush</command> it again, the changeset that "
dongsheng@627 14906 "represents the patch after the pop/push will have a <emphasis>different "
dongsheng@627 14907 "identity</emphasis> than the changeset that represented the hash beforehand. "
songdongsheng@658 14908 "See <xref linkend=\"sec:mqref:cmd:qpush\"/> for information as to why this is."
dongsheng@627 14909 msgstr ""
dongsheng@627 14910
dongsheng@627 14911 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
songdongsheng@658 14912 #: ../en/ch11-mq.xml:986
dongsheng@627 14913 msgid ""
dongsheng@627 14914 "It's not a good idea to <command role=\"hg-cmd\">hg merge</command> changes "
dongsheng@627 14915 "from another branch with a patch changeset, at least if you want to maintain "
dongsheng@627 14916 "the <quote>patchiness</quote> of that changeset and changesets below it on "
dongsheng@627 14917 "the patch stack. If you try to do this, it will appear to succeed, but MQ "
dongsheng@627 14918 "will become confused."
dongsheng@627 14919 msgstr ""
dongsheng@627 14920
dongsheng@627 14921 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 14922 #: ../en/ch11-mq.xml:997
dongsheng@627 14923 msgid "Managing patches in a repository"
dongsheng@636 14924 msgstr "在版本库管理补丁"
dongsheng@627 14925
dongsheng@627 14926 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14927 #: ../en/ch11-mq.xml:999
dongsheng@627 14928 msgid ""
dongsheng@627 14929 "Because MQ's <filename role=\"special\" class=\"directory\">.hg/patches</"
dongsheng@627 14930 "filename> directory resides outside a Mercurial repository's working "
dongsheng@627 14931 "directory, the <quote>underlying</quote> Mercurial repository knows nothing "
dongsheng@627 14932 "about the management or presence of patches."
dongsheng@627 14933 msgstr ""
dongsheng@627 14934
dongsheng@627 14935 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14936 #: ../en/ch11-mq.xml:1005
dongsheng@627 14937 msgid ""
dongsheng@627 14938 "This presents the interesting possibility of managing the contents of the "
dongsheng@627 14939 "patch directory as a Mercurial repository in its own right. This can be a "
dongsheng@627 14940 "useful way to work. For example, you can work on a patch for a while, "
dongsheng@627 14941 "<command role=\"hg-ext-mq\">qrefresh</command> it, then <command role=\"hg-cmd"
dongsheng@627 14942 "\">hg commit</command> the current state of the patch. This lets you "
dongsheng@627 14943 "<quote>roll back</quote> to that version of the patch later on."
dongsheng@627 14944 msgstr ""
dongsheng@627 14945
dongsheng@627 14946 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14947 #: ../en/ch11-mq.xml:1014
dongsheng@627 14948 msgid ""
dongsheng@627 14949 "You can then share different versions of the same patch stack among multiple "
dongsheng@627 14950 "underlying repositories. I use this when I am developing a Linux kernel "
dongsheng@627 14951 "feature. I have a pristine copy of my kernel sources for each of several CPU "
dongsheng@627 14952 "architectures, and a cloned repository under each that contains the patches I "
dongsheng@627 14953 "am working on. When I want to test a change on a different architecture, I "
dongsheng@627 14954 "push my current patches to the patch repository associated with that kernel "
dongsheng@627 14955 "tree, pop and push all of my patches, and build and test that kernel."
dongsheng@627 14956 msgstr ""
dongsheng@627 14957
dongsheng@627 14958 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 14959 #: ../en/ch11-mq.xml:1024
dongsheng@627 14960 msgid ""
dongsheng@627 14961 "Managing patches in a repository makes it possible for multiple developers to "
dongsheng@627 14962 "work on the same patch series without colliding with each other, all on top "
dongsheng@627 14963 "of an underlying source base that they may or may not control."
dongsheng@627 14964 msgstr ""
dongsheng@627 14965
dongsheng@627 14966 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 14967 #: ../en/ch11-mq.xml:1030
dongsheng@627 14968 msgid "MQ support for patch repositories"
dongsheng@636 14969 msgstr "MQ 支持补丁版本库"
dongsheng@627 14970
dongsheng@627 14971 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 14972 #: ../en/ch11-mq.xml:1032
dongsheng@627 14973 msgid ""
dongsheng@627 14974 "MQ helps you to work with the <filename role=\"special\" class=\"directory\">."
dongsheng@627 14975 "hg/patches</filename> directory as a repository; when you prepare a "
dongsheng@627 14976 "repository for working with patches using <command role=\"hg-ext-mq\">qinit</"
dongsheng@627 14977 "command>, you can pass the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
dongsheng@627 14978 "option> option to create the <filename role=\"special\" class=\"directory\">."
dongsheng@627 14979 "hg/patches</filename> directory as a Mercurial repository."
dongsheng@627 14980 msgstr ""
dongsheng@627 14981
dongsheng@627 14982 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 14983 #: ../en/ch11-mq.xml:1042
dongsheng@627 14984 msgid ""
dongsheng@627 14985 "If you forget to use the <option role=\"hg-ext-mq-cmd-qinit-opt\">hg -c</"
dongsheng@627 14986 "option> option, you can simply go into the <filename role=\"special\" class="
dongsheng@627 14987 "\"directory\">.hg/patches</filename> directory at any time and run <command "
dongsheng@627 14988 "role=\"hg-cmd\">hg init</command>. Don't forget to add an entry for the "
dongsheng@627 14989 "<filename role=\"special\">status</filename> file to the <filename role="
dongsheng@627 14990 "\"special\">.hgignore</filename> file, though"
dongsheng@627 14991 msgstr ""
dongsheng@627 14992
dongsheng@627 14993 #. type: Content of: <book><chapter><sect1><sect2><note><para>
songdongsheng@658 14994 #: ../en/ch11-mq.xml:1051
dongsheng@627 14995 msgid ""
dongsheng@627 14996 "(<command role=\"hg-cmd\">hg qinit <option role=\"hg-ext-mq-cmd-qinit-opt"
dongsheng@627 14997 "\">hg -c</option></command> does this for you automatically); you "
dongsheng@627 14998 "<emphasis>really</emphasis> don't want to manage the <filename role=\"special"
dongsheng@627 14999 "\">status</filename> file."
dongsheng@627 15000 msgstr ""
dongsheng@627 15001
dongsheng@627 15002 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15003 #: ../en/ch11-mq.xml:1058
dongsheng@627 15004 msgid ""
dongsheng@627 15005 "As a convenience, if MQ notices that the <filename class=\"directory\">.hg/"
dongsheng@627 15006 "patches</filename> directory is a repository, it will automatically <command "
dongsheng@627 15007 "role=\"hg-cmd\">hg add</command> every patch that you create and import."
dongsheng@627 15008 msgstr ""
dongsheng@627 15009
dongsheng@627 15010 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15011 #: ../en/ch11-mq.xml:1063
dongsheng@627 15012 msgid ""
dongsheng@627 15013 "MQ provides a shortcut command, <command role=\"hg-ext-mq\">qcommit</"
dongsheng@627 15014 "command>, that runs <command role=\"hg-cmd\">hg commit</command> in the "
dongsheng@627 15015 "<filename role=\"special\" class=\"directory\">.hg/patches</filename> "
dongsheng@627 15016 "directory. This saves some bothersome typing."
dongsheng@627 15017 msgstr ""
dongsheng@627 15018
dongsheng@627 15019 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15020 #: ../en/ch11-mq.xml:1069
dongsheng@627 15021 msgid ""
dongsheng@627 15022 "Finally, as a convenience to manage the patch directory, you can define the "
dongsheng@627 15023 "alias <command>mq</command> on Unix systems. For example, on Linux systems "
dongsheng@627 15024 "using the <command>bash</command> shell, you can include the following "
dongsheng@627 15025 "snippet in your <filename role=\"home\">~/.bashrc</filename>."
dongsheng@627 15026 msgstr ""
dongsheng@627 15027
dongsheng@627 15028 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15029 #: ../en/ch11-mq.xml:1078
dongsheng@627 15030 msgid ""
dongsheng@627 15031 "You can then issue commands of the form <command>mq pull</command> from the "
dongsheng@627 15032 "main repository."
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:1083
dongsheng@627 15037 msgid "A few things to watch out for"
dongsheng@636 15038 msgstr "需要注意的事情"
dongsheng@627 15039
dongsheng@627 15040 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15041 #: ../en/ch11-mq.xml:1085
dongsheng@627 15042 msgid ""
dongsheng@627 15043 "MQ's support for working with a repository full of patches is limited in a "
dongsheng@627 15044 "few small respects."
dongsheng@627 15045 msgstr ""
dongsheng@627 15046
dongsheng@627 15047 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15048 #: ../en/ch11-mq.xml:1088
dongsheng@627 15049 msgid ""
dongsheng@627 15050 "MQ cannot automatically detect changes that you make to the patch directory. "
dongsheng@627 15051 "If you <command role=\"hg-cmd\">hg pull</command>, manually edit, or <command "
dongsheng@627 15052 "role=\"hg-cmd\">hg update</command> changes to patches or the <filename role="
dongsheng@627 15053 "\"special\">series</filename> file, you will have to <command role=\"hg-cmd"
dongsheng@627 15054 "\">hg qpop <option role=\"hg-ext-mq-cmd-qpop-opt\">hg -a</option></command> "
dongsheng@627 15055 "and then <command role=\"hg-cmd\">hg qpush <option role=\"hg-ext-mq-cmd-qpush-"
dongsheng@627 15056 "opt\">hg -a</option></command> in the underlying repository to see those "
dongsheng@627 15057 "changes show up there. If you forget to do this, you can confuse MQ's idea "
dongsheng@627 15058 "of which patches are applied."
dongsheng@627 15059 msgstr ""
dongsheng@627 15060
dongsheng@627 15061 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 15062 #: ../en/ch11-mq.xml:1104
dongsheng@627 15063 msgid "Third party tools for working with patches"
dongsheng@636 15064 msgstr "操作补丁的第三方工具"
dongsheng@627 15065
dongsheng@627 15066 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15067 #: ../en/ch11-mq.xml:1106
dongsheng@627 15068 msgid ""
dongsheng@627 15069 "Once you've been working with patches for a while, you'll find yourself "
dongsheng@627 15070 "hungry for tools that will help you to understand and manipulate the patches "
dongsheng@627 15071 "you're dealing with."
dongsheng@627 15072 msgstr ""
dongsheng@627 15073
dongsheng@627 15074 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15075 #: ../en/ch11-mq.xml:1110
dongsheng@627 15076 msgid ""
dongsheng@627 15077 "The <command>diffstat</command> command <citation>web:diffstat</citation> "
dongsheng@627 15078 "generates a histogram of the modifications made to each file in a patch. It "
dongsheng@661 15079 "provides a good way to <quote>get a sense of</quote> a patch—which files it "
dongsheng@661 15080 "affects, and how much change it introduces to each file and as a whole. (I "
dongsheng@661 15081 "find that it's a good idea to use <command>diffstat</command>'s <option role="
dongsheng@661 15082 "\"cmd-opt-diffstat\">-p</option> option as a matter of course, as otherwise "
dongsheng@661 15083 "it will try to do clever things with prefixes of file names that inevitably "
dongsheng@661 15084 "confuse at least me.)"
dongsheng@627 15085 msgstr ""
dongsheng@627 15086
dongsheng@627 15087 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15088 #: ../en/ch11-mq.xml:1124
dongsheng@627 15089 msgid ""
dongsheng@627 15090 "The <literal role=\"package\">patchutils</literal> package <citation>web:"
dongsheng@627 15091 "patchutils</citation> is invaluable. It provides a set of small utilities "
dongsheng@627 15092 "that follow the <quote>Unix philosophy;</quote> each does one useful thing "
dongsheng@627 15093 "with a patch. The <literal role=\"package\">patchutils</literal> command I "
dongsheng@627 15094 "use most is <command>filterdiff</command>, which extracts subsets from a "
dongsheng@627 15095 "patch file. For example, given a patch that modifies hundreds of files "
dongsheng@627 15096 "across dozens of directories, a single invocation of <command>filterdiff</"
dongsheng@627 15097 "command> can generate a smaller patch that only touches files whose names "
songdongsheng@658 15098 "match a particular glob pattern. See <xref linkend=\"mq-collab:tips:interdiff"
songdongsheng@658 15099 "\"/> for another example."
dongsheng@627 15100 msgstr ""
dongsheng@627 15101
dongsheng@627 15102 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 15103 #: ../en/ch11-mq.xml:1140
dongsheng@627 15104 msgid "Good ways to work with patches"
dongsheng@636 15105 msgstr "操作补丁的好习惯"
dongsheng@627 15106
dongsheng@627 15107 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15108 #: ../en/ch11-mq.xml:1142
dongsheng@627 15109 msgid ""
dongsheng@627 15110 "Whether you are working on a patch series to submit to a free software or "
dongsheng@627 15111 "open source project, or a series that you intend to treat as a sequence of "
dongsheng@627 15112 "regular changesets when you're done, you can use some simple techniques to "
dongsheng@627 15113 "keep your work well organised."
dongsheng@627 15114 msgstr ""
dongsheng@627 15115
dongsheng@627 15116 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15117 #: ../en/ch11-mq.xml:1148
dongsheng@627 15118 msgid ""
dongsheng@627 15119 "Give your patches descriptive names. A good name for a patch might be "
dongsheng@627 15120 "<filename>rework-device-alloc.patch</filename>, because it will immediately "
dongsheng@627 15121 "give you a hint what the purpose of the patch is. Long names shouldn't be a "
dongsheng@627 15122 "problem; you won't be typing the names often, but you <emphasis>will</"
dongsheng@627 15123 "emphasis> be running commands like <command role=\"hg-ext-mq\">qapplied</"
dongsheng@627 15124 "command> and <command role=\"hg-ext-mq\">qtop</command> over and over. Good "
dongsheng@627 15125 "naming becomes especially important when you have a number of patches to work "
dongsheng@627 15126 "with, or if you are juggling a number of different tasks and your patches "
dongsheng@627 15127 "only get a fraction of your attention."
dongsheng@627 15128 msgstr ""
dongsheng@627 15129
dongsheng@627 15130 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15131 #: ../en/ch11-mq.xml:1160
dongsheng@627 15132 msgid ""
dongsheng@627 15133 "Be aware of what patch you're working on. Use the <command role=\"hg-ext-mq"
dongsheng@661 15134 "\">qtop</command> command and skim over the text of your patches frequently—"
dongsheng@661 15135 "for example, using <command role=\"hg-cmd\">hg tip <option role=\"hg-opt-tip"
dongsheng@661 15136 "\">-p</option></command>)—to be sure of where you stand. I have several "
dongsheng@661 15137 "times worked on and <command role=\"hg-ext-mq\">qrefresh</command>ed a patch "
dongsheng@661 15138 "other than the one I intended, and it's often tricky to migrate changes into "
dongsheng@661 15139 "the right patch after making them in the wrong one."
dongsheng@627 15140 msgstr ""
dongsheng@627 15141
dongsheng@627 15142 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15143 #: ../en/ch11-mq.xml:1170
dongsheng@627 15144 msgid ""
dongsheng@627 15145 "For this reason, it is very much worth investing a little time to learn how "
songdongsheng@658 15146 "to use some of the third-party tools I described in <xref linkend=\"sec:mq:"
songdongsheng@658 15147 "tools\"/>, particularly <command>diffstat</command> and <command>filterdiff</"
songdongsheng@658 15148 "command>. The former will give you a quick idea of what changes your patch "
songdongsheng@658 15149 "is making, while the latter makes it easy to splice hunks selectively out of "
songdongsheng@658 15150 "one patch and into another."
dongsheng@627 15151 msgstr ""
dongsheng@627 15152
dongsheng@627 15153 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 15154 #: ../en/ch11-mq.xml:1181
dongsheng@627 15155 msgid "MQ cookbook"
dongsheng@636 15156 msgstr "MQ 手册"
dongsheng@627 15157
dongsheng@627 15158 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 15159 #: ../en/ch11-mq.xml:1184
dongsheng@627 15160 msgid "Manage <quote>trivial</quote> patches"
dongsheng@636 15161 msgstr "管理<quote>琐碎的</quote>补丁"
dongsheng@627 15162
dongsheng@627 15163 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15164 #: ../en/ch11-mq.xml:1186
dongsheng@627 15165 msgid ""
dongsheng@627 15166 "Because the overhead of dropping files into a new Mercurial repository is so "
dongsheng@627 15167 "low, it makes a lot of sense to manage patches this way even if you simply "
dongsheng@627 15168 "want to make a few changes to a source tarball that you downloaded."
dongsheng@627 15169 msgstr ""
dongsheng@627 15170
dongsheng@627 15171 #
dongsheng@627 15172 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15173 #: ../en/ch11-mq.xml:1191
dongsheng@627 15174 msgid ""
dongsheng@627 15175 "Begin by downloading and unpacking the source tarball, and turning it into a "
dongsheng@627 15176 "Mercurial repository."
dongsheng@627 15177 msgstr ""
dongsheng@627 15178
dongsheng@627 15179 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15180 #: ../en/ch11-mq.xml:1196
dongsheng@627 15181 msgid "Continue by creating a patch stack and making your changes."
dongsheng@627 15182 msgstr ""
dongsheng@627 15183
dongsheng@627 15184 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15185 #: ../en/ch11-mq.xml:1201
dongsheng@627 15186 msgid ""
dongsheng@627 15187 "Let's say a few weeks or months pass, and your package author releases a new "
dongsheng@627 15188 "version. First, bring their changes into the repository."
dongsheng@627 15189 msgstr ""
dongsheng@627 15190
dongsheng@627 15191 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15192 #: ../en/ch11-mq.xml:1207
dongsheng@627 15193 msgid ""
dongsheng@627 15194 "The pipeline starting with <command role=\"hg-cmd\">hg locate</command> above "
dongsheng@627 15195 "deletes all files in the working directory, so that <command role=\"hg-cmd"
dongsheng@627 15196 "\">hg commit</command>'s <option role=\"hg-opt-commit\">--addremove</option> "
dongsheng@627 15197 "option can actually tell which files have really been removed in the newer "
dongsheng@627 15198 "version of the source."
dongsheng@627 15199 msgstr ""
dongsheng@627 15200
dongsheng@627 15201 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15202 #: ../en/ch11-mq.xml:1215
dongsheng@627 15203 msgid "Finally, you can apply your patches on top of the new tree."
dongsheng@627 15204 msgstr ""
dongsheng@627 15205
dongsheng@627 15206 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 15207 #: ../en/ch11-mq.xml:1222
dongsheng@627 15208 msgid "Combining entire patches"
dongsheng@636 15209 msgstr "组合全部的补丁"
dongsheng@627 15210
dongsheng@627 15211 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15212 #: ../en/ch11-mq.xml:1224
dongsheng@627 15213 msgid ""
dongsheng@627 15214 "MQ provides a command, <command role=\"hg-ext-mq\">qfold</command> that lets "
dongsheng@627 15215 "you combine entire patches. This <quote>folds</quote> the patches you name, "
dongsheng@627 15216 "in the order you name them, into the topmost applied patch, and concatenates "
dongsheng@627 15217 "their descriptions onto the end of its description. The patches that you "
dongsheng@627 15218 "fold must be unapplied before you fold them."
dongsheng@627 15219 msgstr ""
dongsheng@627 15220
dongsheng@627 15221 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15222 #: ../en/ch11-mq.xml:1232
dongsheng@627 15223 msgid ""
dongsheng@627 15224 "The order in which you fold patches matters. If your topmost applied patch "
dongsheng@627 15225 "is <literal>foo</literal>, and you <command role=\"hg-ext-mq\">qfold</"
dongsheng@627 15226 "command> <literal>bar</literal> and <literal>quux</literal> into it, you will "
dongsheng@627 15227 "end up with a patch that has the same effect as if you applied first "
dongsheng@627 15228 "<literal>foo</literal>, then <literal>bar</literal>, followed by "
dongsheng@627 15229 "<literal>quux</literal>."
dongsheng@627 15230 msgstr ""
dongsheng@627 15231
dongsheng@627 15232 #. type: Content of: <book><chapter><sect1><sect2><title>
songdongsheng@658 15233 #: ../en/ch11-mq.xml:1243
dongsheng@627 15234 msgid "Merging part of one patch into another"
dongsheng@636 15235 msgstr "合并补丁的部分内容到其它补丁"
dongsheng@627 15236
dongsheng@627 15237 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15238 #: ../en/ch11-mq.xml:1245
dongsheng@627 15239 msgid ""
dongsheng@627 15240 "Merging <emphasis>part</emphasis> of one patch into another is more difficult "
dongsheng@627 15241 "than combining entire patches."
dongsheng@627 15242 msgstr ""
dongsheng@627 15243
dongsheng@627 15244 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15245 #: ../en/ch11-mq.xml:1249
dongsheng@627 15246 msgid ""
dongsheng@627 15247 "If you want to move changes to entire files, you can use <command>filterdiff</"
dongsheng@627 15248 "command>'s <option role=\"cmd-opt-filterdiff\">-i</option> and <option role="
dongsheng@627 15249 "\"cmd-opt-filterdiff\">-x</option> options to choose the modifications to "
dongsheng@627 15250 "snip out of one patch, concatenating its output onto the end of the patch you "
dongsheng@627 15251 "want to merge into. You usually won't need to modify the patch you've merged "
dongsheng@627 15252 "the changes from. Instead, MQ will report some rejected hunks when you "
dongsheng@627 15253 "<command role=\"hg-ext-mq\">qpush</command> it (from the hunks you moved into "
dongsheng@627 15254 "the other patch), and you can simply <command role=\"hg-ext-mq\">qrefresh</"
dongsheng@627 15255 "command> the patch to drop the duplicate hunks."
dongsheng@627 15256 msgstr ""
dongsheng@627 15257
dongsheng@627 15258 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15259 #: ../en/ch11-mq.xml:1262
dongsheng@627 15260 msgid ""
dongsheng@627 15261 "If you have a patch that has multiple hunks modifying a file, and you only "
dongsheng@627 15262 "want to move a few of those hunks, the job becomes more messy, but you can "
dongsheng@627 15263 "still partly automate it. Use <command>lsdiff -nvv</command> to print some "
dongsheng@627 15264 "metadata about the patch."
dongsheng@627 15265 msgstr ""
dongsheng@627 15266
dongsheng@627 15267 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15268 #: ../en/ch11-mq.xml:1270
dongsheng@627 15269 msgid "This command prints three different kinds of number:"
dongsheng@627 15270 msgstr ""
dongsheng@627 15271
dongsheng@627 15272 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 15273 #: ../en/ch11-mq.xml:1273
dongsheng@627 15274 msgid ""
dongsheng@627 15275 "(in the first column) a <emphasis>file number</emphasis> to identify each "
dongsheng@627 15276 "file modified in the patch;"
dongsheng@627 15277 msgstr ""
dongsheng@627 15278
dongsheng@627 15279 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 15280 #: ../en/ch11-mq.xml:1277
dongsheng@627 15281 msgid ""
dongsheng@627 15282 "(on the next line, indented) the line number within a modified file where a "
dongsheng@627 15283 "hunk starts; and"
dongsheng@627 15284 msgstr ""
dongsheng@627 15285
dongsheng@627 15286 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
songdongsheng@658 15287 #: ../en/ch11-mq.xml:1280
dongsheng@627 15288 msgid ""
dongsheng@627 15289 "(on the same line) a <emphasis>hunk number</emphasis> to identify that hunk."
dongsheng@627 15290 msgstr ""
dongsheng@627 15291
dongsheng@627 15292 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15293 #: ../en/ch11-mq.xml:1284
dongsheng@627 15294 msgid ""
dongsheng@627 15295 "You'll have to use some visual inspection, and reading of the patch, to "
dongsheng@627 15296 "identify the file and hunk numbers you'll want, but you can then pass them to "
dongsheng@627 15297 "to <command>filterdiff</command>'s <option role=\"cmd-opt-filterdiff\">--"
dongsheng@627 15298 "files</option> and <option role=\"cmd-opt-filterdiff\">--hunks</option> "
dongsheng@627 15299 "options, to select exactly the file and hunk you want to extract."
dongsheng@627 15300 msgstr ""
dongsheng@627 15301
dongsheng@627 15302 #. type: Content of: <book><chapter><sect1><sect2><para>
songdongsheng@658 15303 #: ../en/ch11-mq.xml:1292
dongsheng@627 15304 msgid ""
dongsheng@627 15305 "Once you have this hunk, you can concatenate it onto the end of your "
songdongsheng@658 15306 "destination patch and continue with the remainder of <xref linkend=\"sec:mq:"
songdongsheng@658 15307 "combine\"/>."
dongsheng@627 15308 msgstr ""
dongsheng@627 15309
dongsheng@627 15310 #. type: Content of: <book><chapter><sect1><title>
songdongsheng@658 15311 #: ../en/ch11-mq.xml:1299
dongsheng@627 15312 msgid "Differences between quilt and MQ"
dongsheng@636 15313 msgstr "MQ 与 quilt 的区别"
dongsheng@627 15314
dongsheng@627 15315 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15316 #: ../en/ch11-mq.xml:1301
dongsheng@627 15317 msgid ""
dongsheng@627 15318 "If you are already familiar with quilt, MQ provides a similar command set. "
dongsheng@627 15319 "There are a few differences in the way that it works."
dongsheng@627 15320 msgstr ""
dongsheng@627 15321
dongsheng@627 15322 #. type: Content of: <book><chapter><sect1><para>
songdongsheng@658 15323 #: ../en/ch11-mq.xml:1305
dongsheng@627 15324 msgid ""
dongsheng@627 15325 "You will already have noticed that most quilt commands have MQ counterparts "
dongsheng@627 15326 "that simply begin with a <quote><literal>q</literal></quote>. The exceptions "
dongsheng@627 15327 "are quilt's <literal>add</literal> and <literal>remove</literal> commands, "
dongsheng@627 15328 "the counterparts for which are the normal Mercurial <command role=\"hg-cmd"
dongsheng@627 15329 "\">hg add</command> and <command role=\"hg-cmd\">hg remove</command> "
dongsheng@627 15330 "commands. There is no MQ equivalent of the quilt <literal>edit</literal> "
dongsheng@627 15331 "command."
dongsheng@627 15332 msgstr ""
dongsheng@627 15333
dongsheng@627 15334 #. type: Content of: <book><chapter><title>
dongsheng@650 15335 #: ../en/ch12-mq-collab.xml:5
dongsheng@627 15336 msgid "Advanced uses of Mercurial Queues"
dongsheng@627 15337 msgstr "MQ 的高级用法"
dongsheng@627 15338
dongsheng@627 15339 #. type: Content of: <book><chapter><para>
dongsheng@650 15340 #: ../en/ch12-mq-collab.xml:7
dongsheng@627 15341 msgid ""
dongsheng@627 15342 "While it's easy to pick up straightforward uses of Mercurial Queues, use of a "
dongsheng@627 15343 "little discipline and some of MQ's less frequently used capabilities makes it "
dongsheng@627 15344 "possible to work in complicated development environments."
dongsheng@627 15345 msgstr ""
dongsheng@627 15346
dongsheng@627 15347 #. type: Content of: <book><chapter><para>
dongsheng@650 15348 #: ../en/ch12-mq-collab.xml:12
dongsheng@627 15349 msgid ""
dongsheng@627 15350 "In this chapter, I will use as an example a technique I have used to manage "
dongsheng@627 15351 "the development of an Infiniband device driver for the Linux kernel. The "
dongsheng@627 15352 "driver in question is large (at least as drivers go), with 25,000 lines of "
dongsheng@627 15353 "code spread across 35 source files. It is maintained by a small team of "
dongsheng@627 15354 "developers."
dongsheng@627 15355 msgstr ""
dongsheng@627 15356
dongsheng@627 15357 #. type: Content of: <book><chapter><para>
dongsheng@650 15358 #: ../en/ch12-mq-collab.xml:18
dongsheng@627 15359 msgid ""
dongsheng@627 15360 "While much of the material in this chapter is specific to Linux, the same "
dongsheng@627 15361 "principles apply to any code base for which you're not the primary owner, and "
dongsheng@627 15362 "upon which you need to do a lot of development."
dongsheng@627 15363 msgstr ""
dongsheng@627 15364
dongsheng@627 15365 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15366 #: ../en/ch12-mq-collab.xml:24
dongsheng@627 15367 msgid "The problem of many targets"
dongsheng@636 15368 msgstr "多个目标的问题"
dongsheng@627 15369
dongsheng@627 15370 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15371 #: ../en/ch12-mq-collab.xml:26
dongsheng@627 15372 msgid ""
dongsheng@627 15373 "The Linux kernel changes rapidly, and has never been internally stable; "
dongsheng@627 15374 "developers frequently make drastic changes between releases. This means that "
dongsheng@627 15375 "a version of the driver that works well with a particular released version of "
dongsheng@627 15376 "the kernel will not even <emphasis>compile</emphasis> correctly against, "
dongsheng@627 15377 "typically, any other version."
dongsheng@627 15378 msgstr ""
dongsheng@627 15379
dongsheng@627 15380 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15381 #: ../en/ch12-mq-collab.xml:33
dongsheng@627 15382 msgid ""
dongsheng@627 15383 "To maintain a driver, we have to keep a number of distinct versions of Linux "
dongsheng@627 15384 "in mind."
dongsheng@627 15385 msgstr ""
dongsheng@627 15386
dongsheng@627 15387 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15388 #: ../en/ch12-mq-collab.xml:36
dongsheng@627 15389 msgid ""
dongsheng@627 15390 "One target is the main Linux kernel development tree. Maintenance of the code "
dongsheng@627 15391 "is in this case partly shared by other developers in the kernel community, "
dongsheng@627 15392 "who make <quote>drive-by</quote> modifications to the driver as they develop "
dongsheng@627 15393 "and refine kernel subsystems."
dongsheng@627 15394 msgstr ""
dongsheng@627 15395
dongsheng@627 15396 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15397 #: ../en/ch12-mq-collab.xml:42
dongsheng@627 15398 msgid ""
dongsheng@627 15399 "We also maintain a number of <quote>backports</quote> to older versions of "
dongsheng@627 15400 "the Linux kernel, to support the needs of customers who are running older "
dongsheng@627 15401 "Linux distributions that do not incorporate our drivers. (To "
dongsheng@627 15402 "<emphasis>backport</emphasis> a piece of code is to modify it to work in an "
dongsheng@627 15403 "older version of its target environment than the version it was developed "
dongsheng@627 15404 "for.)"
dongsheng@627 15405 msgstr ""
dongsheng@627 15406
dongsheng@627 15407 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15408 #: ../en/ch12-mq-collab.xml:50
dongsheng@627 15409 msgid ""
dongsheng@627 15410 "Finally, we make software releases on a schedule that is necessarily not "
dongsheng@627 15411 "aligned with those used by Linux distributors and kernel developers, so that "
dongsheng@627 15412 "we can deliver new features to customers without forcing them to upgrade "
dongsheng@627 15413 "their entire kernels or distributions."
dongsheng@627 15414 msgstr ""
dongsheng@627 15415
dongsheng@627 15416 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 15417 #: ../en/ch12-mq-collab.xml:58
dongsheng@627 15418 msgid "Tempting approaches that don't work well"
dongsheng@636 15419 msgstr "工作不好的诱人方法"
dongsheng@627 15420
dongsheng@627 15421 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15422 #: ../en/ch12-mq-collab.xml:60
dongsheng@627 15423 msgid ""
dongsheng@627 15424 "There are two <quote>standard</quote> ways to maintain a piece of software "
dongsheng@627 15425 "that has to target many different environments."
dongsheng@627 15426 msgstr ""
dongsheng@627 15427
dongsheng@627 15428 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15429 #: ../en/ch12-mq-collab.xml:64
dongsheng@627 15430 msgid ""
dongsheng@627 15431 "The first is to maintain a number of branches, each intended for a single "
dongsheng@627 15432 "target. The trouble with this approach is that you must maintain iron "
dongsheng@627 15433 "discipline in the flow of changes between repositories. A new feature or bug "
dongsheng@627 15434 "fix must start life in a <quote>pristine</quote> repository, then percolate "
dongsheng@627 15435 "out to every backport repository. Backport changes are more limited in the "
dongsheng@627 15436 "branches they should propagate to; a backport change that is applied to a "
dongsheng@627 15437 "branch where it doesn't belong will probably stop the driver from compiling."
dongsheng@627 15438 msgstr ""
dongsheng@627 15439
dongsheng@627 15440 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15441 #: ../en/ch12-mq-collab.xml:74
dongsheng@627 15442 msgid ""
dongsheng@627 15443 "The second is to maintain a single source tree filled with conditional "
dongsheng@627 15444 "statements that turn chunks of code on or off depending on the intended "
dongsheng@627 15445 "target. Because these <quote>ifdefs</quote> are not allowed in the Linux "
dongsheng@627 15446 "kernel tree, a manual or automatic process must be followed to strip them out "
dongsheng@627 15447 "and yield a clean tree. A code base maintained in this fashion rapidly "
dongsheng@627 15448 "becomes a rat's nest of conditional blocks that are difficult to understand "
dongsheng@627 15449 "and maintain."
dongsheng@627 15450 msgstr ""
dongsheng@627 15451
dongsheng@627 15452 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15453 #: ../en/ch12-mq-collab.xml:83
dongsheng@627 15454 msgid ""
dongsheng@627 15455 "Neither of these approaches is well suited to a situation where you don't "
dongsheng@627 15456 "<quote>own</quote> the canonical copy of a source tree. In the case of a "
dongsheng@627 15457 "Linux driver that is distributed with the standard kernel, Linus's tree "
dongsheng@627 15458 "contains the copy of the code that will be treated by the world as "
dongsheng@627 15459 "canonical. The upstream version of <quote>my</quote> driver can be modified "
dongsheng@627 15460 "by people I don't know, without me even finding out about it until after the "
dongsheng@627 15461 "changes show up in Linus's tree."
dongsheng@627 15462 msgstr ""
dongsheng@627 15463
dongsheng@627 15464 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15465 #: ../en/ch12-mq-collab.xml:93
dongsheng@627 15466 msgid ""
dongsheng@627 15467 "These approaches have the added weakness of making it difficult to generate "
dongsheng@627 15468 "well-formed patches to submit upstream."
dongsheng@627 15469 msgstr ""
dongsheng@627 15470
dongsheng@627 15471 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15472 #: ../en/ch12-mq-collab.xml:97
dongsheng@627 15473 msgid ""
dongsheng@627 15474 "In principle, Mercurial Queues seems like a good candidate to manage a "
dongsheng@627 15475 "development scenario such as the above. While this is indeed the case, MQ "
dongsheng@627 15476 "contains a few added features that make the job more pleasant."
dongsheng@627 15477 msgstr ""
dongsheng@627 15478
dongsheng@627 15479 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15480 #: ../en/ch12-mq-collab.xml:105
dongsheng@627 15481 msgid "Conditionally applying patches with guards"
dongsheng@636 15482 msgstr "有条件的应用补丁"
dongsheng@627 15483
dongsheng@627 15484 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15485 #: ../en/ch12-mq-collab.xml:107
dongsheng@627 15486 msgid ""
dongsheng@627 15487 "Perhaps the best way to maintain sanity with so many targets is to be able to "
dongsheng@627 15488 "choose specific patches to apply for a given situation. MQ provides a "
dongsheng@627 15489 "feature called <quote>guards</quote> (which originates with quilt's "
dongsheng@627 15490 "<literal>guards</literal> command) that does just this. To start off, let's "
dongsheng@627 15491 "create a simple repository for experimenting in."
dongsheng@627 15492 msgstr ""
dongsheng@627 15493
dongsheng@627 15494 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15495 #: ../en/ch12-mq-collab.xml:116
dongsheng@627 15496 msgid ""
dongsheng@627 15497 "This gives us a tiny repository that contains two patches that don't have any "
dongsheng@627 15498 "dependencies on each other, because they touch different files."
dongsheng@627 15499 msgstr ""
dongsheng@627 15500
dongsheng@627 15501 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15502 #: ../en/ch12-mq-collab.xml:120
dongsheng@627 15503 msgid ""
dongsheng@627 15504 "The idea behind conditional application is that you can <quote>tag</quote> a "
dongsheng@627 15505 "patch with a <emphasis>guard</emphasis>, which is simply a text string of "
dongsheng@627 15506 "your choosing, then tell MQ to select specific guards to use when applying "
dongsheng@627 15507 "patches. MQ will then either apply, or skip over, a guarded patch, depending "
dongsheng@627 15508 "on the guards that you have selected."
dongsheng@627 15509 msgstr ""
dongsheng@627 15510
dongsheng@627 15511 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15512 #: ../en/ch12-mq-collab.xml:127
dongsheng@627 15513 msgid ""
dongsheng@627 15514 "A patch can have an arbitrary number of guards; each one is "
dongsheng@627 15515 "<emphasis>positive</emphasis> (<quote>apply this patch if this guard is "
dongsheng@627 15516 "selected</quote>) or <emphasis>negative</emphasis> (<quote>skip this patch if "
dongsheng@627 15517 "this guard is selected</quote>). A patch with no guards is always applied."
dongsheng@627 15518 msgstr ""
dongsheng@627 15519
dongsheng@627 15520 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15521 #: ../en/ch12-mq-collab.xml:135
dongsheng@627 15522 msgid "Controlling the guards on a patch"
dongsheng@636 15523 msgstr "控制补丁的应用条件"
dongsheng@627 15524
dongsheng@627 15525 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15526 #: ../en/ch12-mq-collab.xml:137
dongsheng@627 15527 msgid ""
dongsheng@627 15528 "The <command role=\"hg-ext-mq\">qguard</command> command lets you determine "
dongsheng@627 15529 "which guards should apply to a patch, or display the guards that are already "
dongsheng@627 15530 "in effect. Without any arguments, it displays the guards on the current "
dongsheng@627 15531 "topmost patch."
dongsheng@627 15532 msgstr ""
dongsheng@627 15533
dongsheng@627 15534 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15535 #: ../en/ch12-mq-collab.xml:144
dongsheng@627 15536 msgid ""
dongsheng@627 15537 "To set a positive guard on a patch, prefix the name of the guard with a "
dongsheng@627 15538 "<quote><literal>+</literal></quote>."
dongsheng@627 15539 msgstr ""
dongsheng@627 15540
dongsheng@627 15541 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15542 #: ../en/ch12-mq-collab.xml:149
dongsheng@627 15543 msgid ""
dongsheng@627 15544 "To set a negative guard on a patch, prefix the name of the guard with a "
dongsheng@627 15545 "<quote><literal>-</literal></quote>."
dongsheng@627 15546 msgstr ""
dongsheng@627 15547
dongsheng@627 15548 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@650 15549 #: ../en/ch12-mq-collab.xml:156
dongsheng@627 15550 msgid ""
dongsheng@627 15551 "The <command role=\"hg-ext-mq\">qguard</command> command <emphasis>sets</"
dongsheng@627 15552 "emphasis> the guards on a patch; it doesn't <emphasis>modify</emphasis> "
dongsheng@627 15553 "them. What this means is that if you run <command role=\"hg-cmd\">hg qguard "
dongsheng@627 15554 "+a +b</command> on a patch, then <command role=\"hg-cmd\">hg qguard +c</"
dongsheng@627 15555 "command> on the same patch, the <emphasis>only</emphasis> guard that will be "
dongsheng@627 15556 "set on it afterwards is <literal>+c</literal>."
dongsheng@627 15557 msgstr ""
dongsheng@627 15558
dongsheng@627 15559 #
dongsheng@627 15560 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15561 #: ../en/ch12-mq-collab.xml:165
dongsheng@627 15562 msgid ""
dongsheng@627 15563 "Mercurial stores guards in the <filename role=\"special\">series</filename> "
dongsheng@627 15564 "file; the form in which they are stored is easy both to understand and to "
dongsheng@627 15565 "edit by hand. (In other words, you don't have to use the <command role=\"hg-"
dongsheng@627 15566 "ext-mq\">qguard</command> command if you don't want to; it's okay to simply "
dongsheng@627 15567 "edit the <filename role=\"special\">series</filename> file.)"
dongsheng@627 15568 msgstr ""
dongsheng@627 15569
dongsheng@627 15570 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15571 #: ../en/ch12-mq-collab.xml:177
dongsheng@627 15572 msgid "Selecting the guards to use"
dongsheng@636 15573 msgstr "选择使用的条件"
dongsheng@627 15574
dongsheng@627 15575 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15576 #: ../en/ch12-mq-collab.xml:179
dongsheng@627 15577 msgid ""
dongsheng@627 15578 "The <command role=\"hg-ext-mq\">qselect</command> command determines which "
dongsheng@627 15579 "guards are active at a given time. The effect of this is to determine which "
dongsheng@627 15580 "patches MQ will apply the next time you run <command role=\"hg-ext-mq"
dongsheng@627 15581 "\">qpush</command>. It has no other effect; in particular, it doesn't do "
dongsheng@627 15582 "anything to patches that are already applied."
dongsheng@627 15583 msgstr ""
dongsheng@627 15584
dongsheng@627 15585 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15586 #: ../en/ch12-mq-collab.xml:186
dongsheng@627 15587 msgid ""
dongsheng@627 15588 "With no arguments, the <command role=\"hg-ext-mq\">qselect</command> command "
dongsheng@627 15589 "lists the guards currently in effect, one per line of output. Each argument "
dongsheng@627 15590 "is treated as the name of a guard to apply."
dongsheng@627 15591 msgstr ""
dongsheng@627 15592
dongsheng@627 15593 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15594 #: ../en/ch12-mq-collab.xml:193
dongsheng@627 15595 msgid ""
dongsheng@627 15596 "In case you're interested, the currently selected guards are stored in the "
dongsheng@627 15597 "<filename role=\"special\">guards</filename> file."
dongsheng@627 15598 msgstr ""
dongsheng@627 15599
dongsheng@627 15600 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15601 #: ../en/ch12-mq-collab.xml:198
dongsheng@627 15602 msgid ""
dongsheng@627 15603 "We can see the effect the selected guards have when we run <command role=\"hg-"
dongsheng@627 15604 "ext-mq\">qpush</command>."
dongsheng@627 15605 msgstr ""
dongsheng@627 15606
dongsheng@627 15607 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15608 #: ../en/ch12-mq-collab.xml:203
dongsheng@627 15609 msgid ""
dongsheng@627 15610 "A guard cannot start with a <quote><literal>+</literal></quote> or "
dongsheng@627 15611 "<quote><literal>-</literal></quote> character. The name of a guard must not "
dongsheng@627 15612 "contain white space, but most other characters are acceptable. If you try to "
dongsheng@627 15613 "use a guard with an invalid name, MQ will complain:"
dongsheng@627 15614 msgstr ""
dongsheng@627 15615
dongsheng@627 15616 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15617 #: ../en/ch12-mq-collab.xml:212
dongsheng@627 15618 msgid "Changing the selected guards changes the patches that are applied."
dongsheng@627 15619 msgstr ""
dongsheng@627 15620
dongsheng@627 15621 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15622 #: ../en/ch12-mq-collab.xml:217
dongsheng@627 15623 msgid ""
dongsheng@627 15624 "You can see in the example below that negative guards take precedence over "
dongsheng@627 15625 "positive guards."
dongsheng@627 15626 msgstr ""
dongsheng@627 15627
dongsheng@627 15628 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15629 #: ../en/ch12-mq-collab.xml:224
dongsheng@627 15630 msgid "MQ's rules for applying patches"
dongsheng@636 15631 msgstr "MQ 应用补丁的规则"
dongsheng@627 15632
dongsheng@627 15633 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15634 #: ../en/ch12-mq-collab.xml:226
dongsheng@627 15635 msgid ""
dongsheng@627 15636 "The rules that MQ uses when deciding whether to apply a patch are as follows."
dongsheng@627 15637 msgstr ""
dongsheng@627 15638
dongsheng@627 15639 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15640 #: ../en/ch12-mq-collab.xml:229
dongsheng@627 15641 msgid "A patch that has no guards is always applied."
dongsheng@627 15642 msgstr ""
dongsheng@627 15643
dongsheng@627 15644 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15645 #: ../en/ch12-mq-collab.xml:232
dongsheng@627 15646 msgid ""
dongsheng@627 15647 "If the patch has any negative guard that matches any currently selected "
dongsheng@627 15648 "guard, the patch is skipped."
dongsheng@627 15649 msgstr ""
dongsheng@627 15650
dongsheng@627 15651 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15652 #: ../en/ch12-mq-collab.xml:235
dongsheng@627 15653 msgid ""
dongsheng@627 15654 "If the patch has any positive guard that matches any currently selected "
dongsheng@627 15655 "guard, the patch is applied."
dongsheng@627 15656 msgstr ""
dongsheng@627 15657
dongsheng@627 15658 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15659 #: ../en/ch12-mq-collab.xml:238
dongsheng@627 15660 msgid ""
dongsheng@627 15661 "If the patch has positive or negative guards, but none matches any currently "
dongsheng@627 15662 "selected guard, the patch is skipped."
dongsheng@627 15663 msgstr ""
dongsheng@627 15664
dongsheng@627 15665 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15666 #: ../en/ch12-mq-collab.xml:245
dongsheng@627 15667 msgid "Trimming the work environment"
dongsheng@636 15668 msgstr "修剪工作环境"
dongsheng@627 15669
dongsheng@627 15670 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15671 #: ../en/ch12-mq-collab.xml:247
dongsheng@627 15672 msgid ""
dongsheng@627 15673 "In working on the device driver I mentioned earlier, I don't apply the "
dongsheng@627 15674 "patches to a normal Linux kernel tree. Instead, I use a repository that "
dongsheng@627 15675 "contains only a snapshot of the source files and headers that are relevant to "
dongsheng@627 15676 "Infiniband development. This repository is 1% the size of a kernel "
dongsheng@627 15677 "repository, so it's easier to work with."
dongsheng@627 15678 msgstr ""
dongsheng@627 15679
dongsheng@627 15680 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15681 #: ../en/ch12-mq-collab.xml:254
dongsheng@627 15682 msgid ""
dongsheng@627 15683 "I then choose a <quote>base</quote> version on top of which the patches are "
dongsheng@627 15684 "applied. This is a snapshot of the Linux kernel tree as of a revision of my "
dongsheng@627 15685 "choosing. When I take the snapshot, I record the changeset ID from the "
dongsheng@627 15686 "kernel repository in the commit message. Since the snapshot preserves the "
dongsheng@627 15687 "<quote>shape</quote> and content of the relevant parts of the kernel tree, I "
dongsheng@627 15688 "can apply my patches on top of either my tiny repository or a normal kernel "
dongsheng@627 15689 "tree."
dongsheng@627 15690 msgstr ""
dongsheng@627 15691
dongsheng@627 15692 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15693 #: ../en/ch12-mq-collab.xml:263
dongsheng@627 15694 msgid ""
dongsheng@627 15695 "Normally, the base tree atop which the patches apply should be a snapshot of "
dongsheng@627 15696 "a very recent upstream tree. This best facilitates the development of "
dongsheng@627 15697 "patches that can easily be submitted upstream with few or no modifications."
dongsheng@627 15698 msgstr ""
dongsheng@627 15699
dongsheng@627 15700 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15701 #: ../en/ch12-mq-collab.xml:270
dongsheng@627 15702 msgid "Dividing up the <filename role=\"special\">series</filename> file"
dongsheng@636 15703 msgstr "分类补丁<filename role=\"special\">系列</filename>"
dongsheng@627 15704
dongsheng@627 15705 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15706 #: ../en/ch12-mq-collab.xml:273
dongsheng@627 15707 msgid ""
dongsheng@627 15708 "I categorise the patches in the <filename role=\"special\">series</filename> "
dongsheng@627 15709 "file into a number of logical groups. Each section of like patches begins "
dongsheng@627 15710 "with a block of comments that describes the purpose of the patches that "
dongsheng@627 15711 "follow."
dongsheng@627 15712 msgstr ""
dongsheng@627 15713
dongsheng@627 15714 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15715 #: ../en/ch12-mq-collab.xml:279
dongsheng@627 15716 msgid ""
dongsheng@627 15717 "The sequence of patch groups that I maintain follows. The ordering of these "
dongsheng@627 15718 "groups is important; I'll describe why after I introduce the groups."
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:283
dongsheng@627 15723 msgid ""
dongsheng@627 15724 "The <quote>accepted</quote> group. Patches that the development team has "
dongsheng@627 15725 "submitted to the maintainer of the Infiniband subsystem, and which he has "
dongsheng@627 15726 "accepted, but which are not present in the snapshot that the tiny repository "
dongsheng@627 15727 "is based on. These are <quote>read only</quote> patches, present only to "
dongsheng@627 15728 "transform the tree into a similar state as it is in the upstream maintainer's "
dongsheng@627 15729 "repository."
dongsheng@627 15730 msgstr ""
dongsheng@627 15731
dongsheng@627 15732 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15733 #: ../en/ch12-mq-collab.xml:291
dongsheng@627 15734 msgid ""
dongsheng@627 15735 "The <quote>rework</quote> group. Patches that I have submitted, but that the "
dongsheng@627 15736 "upstream maintainer has requested modifications to before he will accept them."
dongsheng@627 15737 msgstr ""
dongsheng@627 15738
dongsheng@627 15739 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15740 #: ../en/ch12-mq-collab.xml:296
dongsheng@627 15741 msgid ""
dongsheng@627 15742 "The <quote>pending</quote> group. Patches that I have not yet submitted to "
dongsheng@627 15743 "the upstream maintainer, but which we have finished working on. These will be "
dongsheng@627 15744 "<quote>read only</quote> for a while. If the upstream maintainer accepts "
dongsheng@627 15745 "them upon submission, I'll move them to the end of the <quote>accepted</"
dongsheng@627 15746 "quote> group. If he requests that I modify any, I'll move them to the "
dongsheng@627 15747 "beginning of the <quote>rework</quote> group."
dongsheng@627 15748 msgstr ""
dongsheng@627 15749
dongsheng@627 15750 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15751 #: ../en/ch12-mq-collab.xml:305
dongsheng@627 15752 msgid ""
dongsheng@627 15753 "The <quote>in progress</quote> group. Patches that are actively being "
dongsheng@627 15754 "developed, and should not be submitted anywhere yet."
dongsheng@627 15755 msgstr ""
dongsheng@627 15756
dongsheng@627 15757 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15758 #: ../en/ch12-mq-collab.xml:309
dongsheng@627 15759 msgid ""
dongsheng@627 15760 "The <quote>backport</quote> group. Patches that adapt the source tree to "
dongsheng@627 15761 "older versions of the kernel tree."
dongsheng@627 15762 msgstr ""
dongsheng@627 15763
dongsheng@627 15764 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15765 #: ../en/ch12-mq-collab.xml:313
dongsheng@627 15766 msgid ""
dongsheng@627 15767 "The <quote>do not ship</quote> group. Patches that for some reason should "
dongsheng@627 15768 "never be submitted upstream. For example, one such patch might change "
dongsheng@627 15769 "embedded driver identification strings to make it easier to distinguish, in "
dongsheng@627 15770 "the field, between an out-of-tree version of the driver and a version shipped "
dongsheng@627 15771 "by a distribution vendor."
dongsheng@627 15772 msgstr ""
dongsheng@627 15773
dongsheng@627 15774 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15775 #: ../en/ch12-mq-collab.xml:321
dongsheng@627 15776 msgid ""
dongsheng@627 15777 "Now to return to the reasons for ordering groups of patches in this way. We "
dongsheng@627 15778 "would like the lowest patches in the stack to be as stable as possible, so "
dongsheng@627 15779 "that we will not need to rework higher patches due to changes in context. "
dongsheng@627 15780 "Putting patches that will never be changed first in the <filename role="
dongsheng@627 15781 "\"special\">series</filename> file serves this purpose."
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:329
dongsheng@627 15786 msgid ""
dongsheng@627 15787 "We would also like the patches that we know we'll need to modify to be "
dongsheng@627 15788 "applied on top of a source tree that resembles the upstream tree as closely "
dongsheng@627 15789 "as possible. This is why we keep accepted patches around for a while."
dongsheng@627 15790 msgstr ""
dongsheng@627 15791
dongsheng@627 15792 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15793 #: ../en/ch12-mq-collab.xml:334
dongsheng@627 15794 msgid ""
dongsheng@627 15795 "The <quote>backport</quote> and <quote>do not ship</quote> patches float at "
dongsheng@627 15796 "the end of the <filename role=\"special\">series</filename> file. The "
dongsheng@627 15797 "backport patches must be applied on top of all other patches, and the "
dongsheng@627 15798 "<quote>do not ship</quote> patches might as well stay out of harm's way."
dongsheng@627 15799 msgstr ""
dongsheng@627 15800
dongsheng@627 15801 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15802 #: ../en/ch12-mq-collab.xml:343
dongsheng@627 15803 msgid "Maintaining the patch series"
dongsheng@636 15804 msgstr "维护补丁系列"
dongsheng@627 15805
dongsheng@627 15806 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15807 #: ../en/ch12-mq-collab.xml:345
dongsheng@627 15808 msgid ""
dongsheng@627 15809 "In my work, I use a number of guards to control which patches are to be "
dongsheng@627 15810 "applied."
dongsheng@627 15811 msgstr ""
dongsheng@627 15812
dongsheng@627 15813 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15814 #: ../en/ch12-mq-collab.xml:349
dongsheng@627 15815 msgid ""
dongsheng@627 15816 "<quote>Accepted</quote> patches are guarded with <literal>accepted</"
dongsheng@627 15817 "literal>. I enable this guard most of the time. When I'm applying the "
dongsheng@627 15818 "patches on top of a tree where the patches are already present, I can turn "
dongsheng@627 15819 "this patch off, and the patches that follow it will apply cleanly."
dongsheng@627 15820 msgstr ""
dongsheng@627 15821
dongsheng@627 15822 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15823 #: ../en/ch12-mq-collab.xml:356
dongsheng@627 15824 msgid ""
dongsheng@627 15825 "Patches that are <quote>finished</quote>, but not yet submitted, have no "
dongsheng@627 15826 "guards. If I'm applying the patch stack to a copy of the upstream tree, I "
dongsheng@627 15827 "don't need to enable any guards in order to get a reasonably safe source tree."
dongsheng@627 15828 msgstr ""
dongsheng@627 15829
dongsheng@627 15830 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15831 #: ../en/ch12-mq-collab.xml:362
dongsheng@627 15832 msgid ""
dongsheng@627 15833 "Those patches that need reworking before being resubmitted are guarded with "
dongsheng@627 15834 "<literal>rework</literal>."
dongsheng@627 15835 msgstr ""
dongsheng@627 15836
dongsheng@627 15837 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15838 #: ../en/ch12-mq-collab.xml:366
dongsheng@627 15839 msgid ""
dongsheng@627 15840 "For those patches that are still under development, I use <literal>devel</"
dongsheng@627 15841 "literal>."
dongsheng@627 15842 msgstr ""
dongsheng@627 15843
dongsheng@627 15844 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 15845 #: ../en/ch12-mq-collab.xml:369
dongsheng@627 15846 msgid ""
dongsheng@627 15847 "A backport patch may have several guards, one for each version of the kernel "
dongsheng@627 15848 "to which it applies. For example, a patch that backports a piece of code to "
dongsheng@627 15849 "2.6.9 will have a <literal>2.6.9</literal> guard."
dongsheng@627 15850 msgstr ""
dongsheng@627 15851
dongsheng@627 15852 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 15853 #: ../en/ch12-mq-collab.xml:374
dongsheng@627 15854 msgid ""
dongsheng@627 15855 "This variety of guards gives me considerable flexibility in determining what "
dongsheng@627 15856 "kind of source tree I want to end up with. For most situations, the "
dongsheng@627 15857 "selection of appropriate guards is automated during the build process, but I "
dongsheng@627 15858 "can manually tune the guards to use for less common circumstances."
dongsheng@627 15859 msgstr ""
dongsheng@627 15860
dongsheng@627 15861 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 15862 #: ../en/ch12-mq-collab.xml:381
dongsheng@627 15863 msgid "The art of writing backport patches"
dongsheng@636 15864 msgstr "编写向后移植补丁的艺术"
dongsheng@627 15865
dongsheng@627 15866 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15867 #: ../en/ch12-mq-collab.xml:383
dongsheng@627 15868 msgid ""
dongsheng@627 15869 "Using MQ, writing a backport patch is a simple process. All such a patch has "
dongsheng@627 15870 "to do is modify a piece of code that uses a kernel feature not present in the "
dongsheng@627 15871 "older version of the kernel, so that the driver continues to work correctly "
dongsheng@627 15872 "under that older version."
dongsheng@627 15873 msgstr ""
dongsheng@627 15874
dongsheng@627 15875 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15876 #: ../en/ch12-mq-collab.xml:389
dongsheng@627 15877 msgid ""
dongsheng@627 15878 "A useful goal when writing a good backport patch is to make your code look as "
dongsheng@627 15879 "if it was written for the older version of the kernel you're targeting. The "
dongsheng@627 15880 "less obtrusive the patch, the easier it will be to understand and maintain. "
dongsheng@627 15881 "If you're writing a collection of backport patches to avoid the <quote>rat's "
dongsheng@627 15882 "nest</quote> effect of lots of <literal>#ifdef</literal>s (hunks of source "
dongsheng@627 15883 "code that are only used conditionally) in your code, don't introduce version-"
dongsheng@627 15884 "dependent <literal>#ifdef</literal>s into the patches. Instead, write "
dongsheng@627 15885 "several patches, each of which makes unconditional changes, and control their "
dongsheng@627 15886 "application using guards."
dongsheng@627 15887 msgstr ""
dongsheng@627 15888
dongsheng@627 15889 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15890 #: ../en/ch12-mq-collab.xml:402
dongsheng@627 15891 msgid ""
dongsheng@627 15892 "There are two reasons to divide backport patches into a distinct group, away "
dongsheng@627 15893 "from the <quote>regular</quote> patches whose effects they modify. The first "
dongsheng@627 15894 "is that intermingling the two makes it more difficult to use a tool like the "
dongsheng@627 15895 "<literal role=\"hg-ext\">patchbomb</literal> extension to automate the "
dongsheng@627 15896 "process of submitting the patches to an upstream maintainer. The second is "
dongsheng@627 15897 "that a backport patch could perturb the context in which a subsequent regular "
dongsheng@627 15898 "patch is applied, making it impossible to apply the regular patch cleanly "
dongsheng@627 15899 "<emphasis>without</emphasis> the earlier backport patch already being applied."
dongsheng@627 15900 msgstr ""
dongsheng@627 15901
dongsheng@627 15902 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 15903 #: ../en/ch12-mq-collab.xml:417
dongsheng@627 15904 msgid "Useful tips for developing with MQ"
dongsheng@636 15905 msgstr "使用 MQ 开发的技巧"
dongsheng@627 15906
dongsheng@627 15907 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 15908 #: ../en/ch12-mq-collab.xml:420
dongsheng@627 15909 msgid "Organising patches in directories"
dongsheng@636 15910 msgstr "将补丁放到几个目录中"
dongsheng@627 15911
dongsheng@627 15912 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15913 #: ../en/ch12-mq-collab.xml:422
dongsheng@627 15914 msgid ""
dongsheng@627 15915 "If you're working on a substantial project with MQ, it's not difficult to "
dongsheng@627 15916 "accumulate a large number of patches. For example, I have one patch "
dongsheng@627 15917 "repository that contains over 250 patches."
dongsheng@627 15918 msgstr ""
dongsheng@627 15919
dongsheng@627 15920 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15921 #: ../en/ch12-mq-collab.xml:427
dongsheng@627 15922 msgid ""
dongsheng@627 15923 "If you can group these patches into separate logical categories, you can if "
dongsheng@627 15924 "you like store them in different directories; MQ has no problems with patch "
dongsheng@627 15925 "names that contain path separators."
dongsheng@627 15926 msgstr ""
dongsheng@627 15927
dongsheng@627 15928 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 15929 #: ../en/ch12-mq-collab.xml:434
dongsheng@627 15930 msgid "Viewing the history of a patch"
dongsheng@636 15931 msgstr "察看补丁的历史"
dongsheng@627 15932
dongsheng@627 15933 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15934 #: ../en/ch12-mq-collab.xml:436
dongsheng@627 15935 msgid ""
dongsheng@627 15936 "If you're developing a set of patches over a long time, it's a good idea to "
songdongsheng@658 15937 "maintain them in a repository, as discussed in <xref linkend=\"sec:mq:repo\"/"
songdongsheng@658 15938 ">. If you do so, you'll quickly discover that using the <command role=\"hg-"
songdongsheng@658 15939 "cmd\">hg diff</command> command to look at the history of changes to a patch "
songdongsheng@658 15940 "is unworkable. This is in part because you're looking at the second "
dongsheng@627 15941 "derivative of the real code (a diff of a diff), but also because MQ adds "
dongsheng@627 15942 "noise to the process by modifying time stamps and directory names when it "
dongsheng@627 15943 "updates a patch."
dongsheng@627 15944 msgstr ""
dongsheng@627 15945
dongsheng@627 15946 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15947 #: ../en/ch12-mq-collab.xml:448
dongsheng@627 15948 msgid ""
dongsheng@627 15949 "However, you can use the <literal role=\"hg-ext\">extdiff</literal> "
dongsheng@627 15950 "extension, which is bundled with Mercurial, to turn a diff of two versions of "
dongsheng@627 15951 "a patch into something readable. To do this, you will need a third-party "
dongsheng@627 15952 "package called <literal role=\"package\">patchutils</literal> <citation>web:"
dongsheng@627 15953 "patchutils</citation>. This provides a command named <command>interdiff</"
dongsheng@627 15954 "command>, which shows the differences between two diffs as a diff. Used on "
dongsheng@627 15955 "two versions of the same diff, it generates a diff that represents the diff "
dongsheng@627 15956 "from the first to the second version."
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:459
dongsheng@627 15961 msgid ""
dongsheng@627 15962 "You can enable the <literal role=\"hg-ext\">extdiff</literal> extension in "
dongsheng@627 15963 "the usual way, by adding a line to the <literal role=\"rc-extensions"
dongsheng@650 15964 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
dongsheng@627 15965 "filename>."
dongsheng@627 15966 msgstr ""
dongsheng@627 15967
dongsheng@627 15968 #
dongsheng@646 15969 #. &example.hg-interdiff;
dongsheng@627 15970 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15971 #: ../en/ch12-mq-collab.xml:466
dongsheng@627 15972 msgid ""
dongsheng@627 15973 "The <command>interdiff</command> command expects to be passed the names of "
dongsheng@627 15974 "two files, but the <literal role=\"hg-ext\">extdiff</literal> extension "
dongsheng@627 15975 "passes the program it runs a pair of directories, each of which can contain "
dongsheng@627 15976 "an arbitrary number of files. We thus need a small program that will run "
dongsheng@627 15977 "<command>interdiff</command> on each pair of files in these two directories. "
dongsheng@627 15978 "This program is available as <filename role=\"special\">hg-interdiff</"
dongsheng@627 15979 "filename> in the <filename class=\"directory\">examples</filename> directory "
dongsheng@627 15980 "of the source code repository that accompanies this book."
dongsheng@627 15981 msgstr ""
dongsheng@627 15982
dongsheng@627 15983 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15984 #: ../en/ch12-mq-collab.xml:478
dongsheng@627 15985 msgid ""
dongsheng@627 15986 "With the <filename role=\"special\">hg-interdiff</filename> program in your "
dongsheng@627 15987 "shell's search path, you can run it as follows, from inside an MQ patch "
dongsheng@627 15988 "directory:"
dongsheng@627 15989 msgstr ""
dongsheng@627 15990
dongsheng@627 15991 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 15992 #: ../en/ch12-mq-collab.xml:482
dongsheng@627 15993 msgid ""
dongsheng@627 15994 "Since you'll probably want to use this long-winded command a lot, you can get "
dongsheng@627 15995 "<literal role=\"hg-ext\">hgext</literal> to make it available as a normal "
dongsheng@650 15996 "Mercurial command, again by editing your <filename role=\"special\">~/.hgrc</"
dongsheng@627 15997 "filename>."
dongsheng@627 15998 msgstr ""
dongsheng@627 15999
dongsheng@627 16000 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16001 #: ../en/ch12-mq-collab.xml:489
dongsheng@627 16002 msgid ""
dongsheng@627 16003 "This directs <literal role=\"hg-ext\">hgext</literal> to make an "
dongsheng@627 16004 "<literal>interdiff</literal> command available, so you can now shorten the "
dongsheng@627 16005 "previous invocation of <command role=\"hg-ext-extdiff\">extdiff</command> to "
dongsheng@627 16006 "something a little more wieldy."
dongsheng@627 16007 msgstr ""
dongsheng@627 16008
dongsheng@627 16009 #. type: Content of: <book><chapter><sect1><sect2><note><para>
dongsheng@650 16010 #: ../en/ch12-mq-collab.xml:497
dongsheng@627 16011 msgid ""
dongsheng@627 16012 "The <command>interdiff</command> command works well only if the underlying "
dongsheng@627 16013 "files against which versions of a patch are generated remain the same. If "
dongsheng@627 16014 "you create a patch, modify the underlying files, and then regenerate the "
dongsheng@627 16015 "patch, <command>interdiff</command> may not produce useful output."
dongsheng@627 16016 msgstr ""
dongsheng@627 16017
dongsheng@627 16018 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16019 #: ../en/ch12-mq-collab.xml:505
dongsheng@627 16020 msgid ""
dongsheng@627 16021 "The <literal role=\"hg-ext\">extdiff</literal> extension is useful for more "
dongsheng@627 16022 "than merely improving the presentation of MQ patches. To read more about it, "
songdongsheng@658 16023 "go to <xref linkend=\"sec:hgext:extdiff\"/>."
dongsheng@627 16024 msgstr ""
dongsheng@627 16025
dongsheng@627 16026 #. type: Content of: <book><chapter><title>
dongsheng@650 16027 #: ../en/ch13-hgext.xml:5
dongsheng@627 16028 msgid "Adding functionality with extensions"
dongsheng@627 16029 msgstr "使用扩展增加功能"
dongsheng@627 16030
dongsheng@627 16031 #. type: Content of: <book><chapter><para>
dongsheng@650 16032 #: ../en/ch13-hgext.xml:7
dongsheng@627 16033 msgid ""
dongsheng@627 16034 "While the core of Mercurial is quite complete from a functionality "
dongsheng@627 16035 "standpoint, it's deliberately shorn of fancy features. This approach of "
dongsheng@627 16036 "preserving simplicity keeps the software easy to deal with for both "
dongsheng@627 16037 "maintainers and users."
dongsheng@627 16038 msgstr ""
dongsheng@627 16039
dongsheng@627 16040 #. type: Content of: <book><chapter><para>
dongsheng@650 16041 #: ../en/ch13-hgext.xml:12
dongsheng@627 16042 msgid ""
dongsheng@627 16043 "However, Mercurial doesn't box you in with an inflexible command set: you can "
dongsheng@627 16044 "add features to it as <emphasis>extensions</emphasis> (sometimes known as "
dongsheng@627 16045 "<emphasis>plugins</emphasis>). We've already discussed a few of these "
dongsheng@627 16046 "extensions in earlier chapters."
dongsheng@627 16047 msgstr ""
dongsheng@627 16048
dongsheng@627 16049 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@650 16050 #: ../en/ch13-hgext.xml:18
dongsheng@627 16051 msgid ""
songdongsheng@658 16052 "<xref linkend=\"sec:tour-merge:fetch\"/> covers the <literal role=\"hg-ext"
songdongsheng@658 16053 "\">fetch</literal> extension; this combines pulling new changes and merging "
songdongsheng@658 16054 "them with local changes into a single command, <command role=\"hg-ext-fetch"
songdongsheng@658 16055 "\">fetch</command>."
dongsheng@627 16056 msgstr ""
dongsheng@627 16057
dongsheng@627 16058 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@650 16059 #: ../en/ch13-hgext.xml:24
dongsheng@627 16060 msgid ""
songdongsheng@658 16061 "In <xref linkend=\"chap:hook\"/>, we covered several extensions that are "
songdongsheng@658 16062 "useful for hook-related functionality: <literal role=\"hg-ext\">acl</literal> "
songdongsheng@658 16063 "adds access control lists; <literal role=\"hg-ext\">bugzilla</literal> adds "
songdongsheng@658 16064 "integration with the Bugzilla bug tracking system; and <literal role=\"hg-ext"
songdongsheng@658 16065 "\">notify</literal> sends notification emails on new changes."
dongsheng@627 16066 msgstr ""
dongsheng@627 16067
dongsheng@627 16068 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@650 16069 #: ../en/ch13-hgext.xml:33
dongsheng@627 16070 msgid ""
dongsheng@627 16071 "The Mercurial Queues patch management extension is so invaluable that it "
songdongsheng@658 16072 "merits two chapters and an appendix all to itself. <xref linkend=\"chap:mq\"/"
songdongsheng@658 16073 "> covers the basics; <xref linkend=\"chap:mq-collab\"/> discusses advanced "
songdongsheng@658 16074 "topics; and <xref linkend=\"chap:mqref\"/> goes into detail on each command."
dongsheng@627 16075 msgstr ""
dongsheng@627 16076
dongsheng@627 16077 #. type: Content of: <book><chapter><para>
dongsheng@650 16078 #: ../en/ch13-hgext.xml:43
dongsheng@627 16079 msgid ""
dongsheng@627 16080 "In this chapter, we'll cover some of the other extensions that are available "
dongsheng@627 16081 "for Mercurial, and briefly touch on some of the machinery you'll need to know "
dongsheng@627 16082 "about if you want to write an extension of your own."
dongsheng@627 16083 msgstr ""
dongsheng@627 16084
dongsheng@627 16085 #. type: Content of: <book><chapter><itemizedlist><listitem><para>
dongsheng@650 16086 #: ../en/ch13-hgext.xml:48
dongsheng@627 16087 msgid ""
songdongsheng@658 16088 "In <xref linkend=\"sec:hgext:inotify\"/>, we'll discuss the possibility of "
songdongsheng@658 16089 "<emphasis>huge</emphasis> performance improvements using the <literal role="
songdongsheng@658 16090 "\"hg-ext\">inotify</literal> extension."
dongsheng@627 16091 msgstr ""
dongsheng@627 16092
dongsheng@627 16093 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 16094 #: ../en/ch13-hgext.xml:55
dongsheng@627 16095 msgid ""
dongsheng@627 16096 "Improve performance with the <literal role=\"hg-ext\">inotify</literal> "
dongsheng@627 16097 "extension"
dongsheng@636 16098 msgstr "使用扩展 <literal role=\"hg-ext\">inotify</literal> 以提高性能"
dongsheng@627 16099
dongsheng@627 16100 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16101 #: ../en/ch13-hgext.xml:58
dongsheng@627 16102 msgid ""
dongsheng@627 16103 "Are you interested in having some of the most common Mercurial operations run "
dongsheng@627 16104 "as much as a hundred times faster? Read on!"
dongsheng@627 16105 msgstr ""
dongsheng@627 16106
dongsheng@627 16107 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16108 #: ../en/ch13-hgext.xml:62
dongsheng@627 16109 msgid ""
dongsheng@627 16110 "Mercurial has great performance under normal circumstances. For example, "
dongsheng@627 16111 "when you run the <command role=\"hg-cmd\">hg status</command> command, "
dongsheng@627 16112 "Mercurial has to scan almost every directory and file in your repository so "
dongsheng@627 16113 "that it can display file status. Many other Mercurial commands need to do "
dongsheng@627 16114 "the same work behind the scenes; for example, the <command role=\"hg-cmd\">hg "
dongsheng@627 16115 "diff</command> command uses the status machinery to avoid doing an expensive "
dongsheng@627 16116 "comparison operation on files that obviously haven't changed."
dongsheng@627 16117 msgstr ""
dongsheng@627 16118
dongsheng@627 16119 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16120 #: ../en/ch13-hgext.xml:72
dongsheng@627 16121 msgid ""
dongsheng@627 16122 "Because obtaining file status is crucial to good performance, the authors of "
dongsheng@627 16123 "Mercurial have optimised this code to within an inch of its life. However, "
dongsheng@627 16124 "there's no avoiding the fact that when you run <command role=\"hg-cmd\">hg "
dongsheng@627 16125 "status</command>, Mercurial is going to have to perform at least one "
dongsheng@627 16126 "expensive system call for each managed file to determine whether it's changed "
dongsheng@627 16127 "since the last time Mercurial checked. For a sufficiently large repository, "
dongsheng@627 16128 "this can take a long time."
dongsheng@627 16129 msgstr ""
dongsheng@627 16130
dongsheng@627 16131 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16132 #: ../en/ch13-hgext.xml:82
dongsheng@627 16133 msgid ""
dongsheng@627 16134 "To put a number on the magnitude of this effect, I created a repository "
dongsheng@627 16135 "containing 150,000 managed files. I timed <command role=\"hg-cmd\">hg "
dongsheng@627 16136 "status</command> as taking ten seconds to run, even when <emphasis>none</"
dongsheng@627 16137 "emphasis> of those files had been modified."
dongsheng@627 16138 msgstr ""
dongsheng@627 16139
dongsheng@627 16140 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16141 #: ../en/ch13-hgext.xml:88
dongsheng@627 16142 msgid ""
dongsheng@627 16143 "Many modern operating systems contain a file notification facility. If a "
dongsheng@627 16144 "program signs up to an appropriate service, the operating system will notify "
dongsheng@627 16145 "it every time a file of interest is created, modified, or deleted. On Linux "
dongsheng@627 16146 "systems, the kernel component that does this is called <literal>inotify</"
dongsheng@627 16147 "literal>."
dongsheng@627 16148 msgstr ""
dongsheng@627 16149
dongsheng@627 16150 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16151 #: ../en/ch13-hgext.xml:95
dongsheng@627 16152 msgid ""
dongsheng@627 16153 "Mercurial's <literal role=\"hg-ext\">inotify</literal> extension talks to the "
dongsheng@627 16154 "kernel's <literal>inotify</literal> component to optimise <command role=\"hg-"
dongsheng@627 16155 "cmd\">hg status</command> commands. The extension has two components. A "
dongsheng@627 16156 "daemon sits in the background and receives notifications from the "
dongsheng@627 16157 "<literal>inotify</literal> subsystem. It also listens for connections from a "
dongsheng@627 16158 "regular Mercurial command. The extension modifies Mercurial's behaviour so "
dongsheng@627 16159 "that instead of scanning the filesystem, it queries the daemon. Since the "
dongsheng@627 16160 "daemon has perfect information about the state of the repository, it can "
dongsheng@627 16161 "respond with a result instantaneously, avoiding the need to scan every "
dongsheng@627 16162 "directory and file in the repository."
dongsheng@627 16163 msgstr ""
dongsheng@627 16164
dongsheng@627 16165 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16166 #: ../en/ch13-hgext.xml:108
dongsheng@627 16167 msgid ""
dongsheng@627 16168 "Recall the ten seconds that I measured plain Mercurial as taking to run "
dongsheng@627 16169 "<command role=\"hg-cmd\">hg status</command> on a 150,000 file repository. "
dongsheng@627 16170 "With the <literal role=\"hg-ext\">inotify</literal> extension enabled, the "
dongsheng@627 16171 "time dropped to 0.1 seconds, a factor of <emphasis>one hundred</emphasis> "
dongsheng@627 16172 "faster."
dongsheng@627 16173 msgstr ""
dongsheng@627 16174
dongsheng@627 16175 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16176 #: ../en/ch13-hgext.xml:115
dongsheng@627 16177 msgid "Before we continue, please pay attention to some caveats."
dongsheng@627 16178 msgstr ""
dongsheng@627 16179
dongsheng@627 16180 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 16181 #: ../en/ch13-hgext.xml:118
dongsheng@627 16182 msgid ""
dongsheng@627 16183 "The <literal role=\"hg-ext\">inotify</literal> extension is Linux-specific. "
dongsheng@627 16184 "Because it interfaces directly to the Linux kernel's <literal>inotify</"
dongsheng@627 16185 "literal> subsystem, it does not work on other operating systems."
dongsheng@627 16186 msgstr ""
dongsheng@627 16187
dongsheng@627 16188 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 16189 #: ../en/ch13-hgext.xml:123
dongsheng@627 16190 msgid ""
dongsheng@627 16191 "It should work on any Linux distribution that was released after early 2005. "
dongsheng@627 16192 "Older distributions are likely to have a kernel that lacks <literal>inotify</"
dongsheng@627 16193 "literal>, or a version of <literal>glibc</literal> that does not have the "
dongsheng@627 16194 "necessary interfacing support."
dongsheng@627 16195 msgstr ""
dongsheng@627 16196
dongsheng@627 16197 #. type: Content of: <book><chapter><sect1><itemizedlist><listitem><para>
dongsheng@650 16198 #: ../en/ch13-hgext.xml:130
dongsheng@627 16199 msgid ""
dongsheng@627 16200 "Not all filesystems are suitable for use with the <literal role=\"hg-ext"
dongsheng@627 16201 "\">inotify</literal> extension. Network filesystems such as NFS are a non-"
dongsheng@627 16202 "starter, for example, particularly if you're running Mercurial on several "
dongsheng@627 16203 "systems, all mounting the same network filesystem. The kernel's "
dongsheng@627 16204 "<literal>inotify</literal> system has no way of knowing about changes made on "
dongsheng@627 16205 "another system. Most local filesystems (e.g. ext3, XFS, ReiserFS) should "
dongsheng@627 16206 "work fine."
dongsheng@627 16207 msgstr ""
dongsheng@627 16208
dongsheng@627 16209 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16210 #: ../en/ch13-hgext.xml:141
dongsheng@627 16211 msgid ""
dongsheng@627 16212 "The <literal role=\"hg-ext\">inotify</literal> extension is not yet shipped "
dongsheng@627 16213 "with Mercurial as of May 2007, so it's a little more involved to set up than "
dongsheng@627 16214 "other extensions. But the performance improvement is worth it!"
dongsheng@627 16215 msgstr ""
dongsheng@627 16216
dongsheng@627 16217 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16218 #: ../en/ch13-hgext.xml:146
dongsheng@627 16219 msgid ""
dongsheng@627 16220 "The extension currently comes in two parts: a set of patches to the Mercurial "
dongsheng@627 16221 "source code, and a library of Python bindings to the <literal>inotify</"
dongsheng@627 16222 "literal> subsystem."
dongsheng@627 16223 msgstr ""
dongsheng@627 16224
dongsheng@627 16225 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@650 16226 #: ../en/ch13-hgext.xml:150
dongsheng@627 16227 msgid ""
dongsheng@627 16228 "There are <emphasis>two</emphasis> Python <literal>inotify</literal> binding "
dongsheng@627 16229 "libraries. One of them is called <literal>pyinotify</literal>, and is "
dongsheng@627 16230 "packaged by some Linux distributions as <literal>python-inotify</literal>. "
dongsheng@627 16231 "This is <emphasis>not</emphasis> the one you'll need, as it is too buggy and "
dongsheng@627 16232 "inefficient to be practical."
dongsheng@627 16233 msgstr ""
dongsheng@627 16234
dongsheng@627 16235 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16236 #: ../en/ch13-hgext.xml:157
dongsheng@627 16237 msgid ""
dongsheng@627 16238 "To get going, it's best to already have a functioning copy of Mercurial "
dongsheng@627 16239 "installed."
dongsheng@627 16240 msgstr ""
dongsheng@627 16241
dongsheng@627 16242 #. type: Content of: <book><chapter><sect1><note><para>
dongsheng@650 16243 #: ../en/ch13-hgext.xml:160
dongsheng@627 16244 msgid ""
dongsheng@627 16245 "If you follow the instructions below, you'll be <emphasis>replacing</"
dongsheng@627 16246 "emphasis> and overwriting any existing installation of Mercurial that you "
dongsheng@627 16247 "might already have, using the latest <quote>bleeding edge</quote> Mercurial "
dongsheng@627 16248 "code. Don't say you weren't warned!"
dongsheng@627 16249 msgstr ""
dongsheng@627 16250
dongsheng@627 16251 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16252 #: ../en/ch13-hgext.xml:167
dongsheng@627 16253 msgid ""
dongsheng@627 16254 "Clone the Python <literal>inotify</literal> binding repository. Build and "
dongsheng@627 16255 "install it."
dongsheng@627 16256 msgstr ""
dongsheng@627 16257
dongsheng@627 16258 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16259 #: ../en/ch13-hgext.xml:174
dongsheng@627 16260 msgid ""
dongsheng@627 16261 "Clone the <filename class=\"directory\">crew</filename> Mercurial "
dongsheng@627 16262 "repository. Clone the <literal role=\"hg-ext\">inotify</literal> patch "
dongsheng@627 16263 "repository so that Mercurial Queues will be able to apply patches to your "
dongsheng@627 16264 "cope of the <filename class=\"directory\">crew</filename> repository."
dongsheng@627 16265 msgstr ""
dongsheng@627 16266
dongsheng@627 16267 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16268 #: ../en/ch13-hgext.xml:184
dongsheng@627 16269 msgid ""
dongsheng@627 16270 "Make sure that you have the Mercurial Queues extension, <literal role=\"hg-ext"
songdongsheng@658 16271 "\">mq</literal>, enabled. If you've never used MQ, read <xref linkend=\"sec:"
songdongsheng@658 16272 "mq:start\"/> to get started quickly."
dongsheng@627 16273 msgstr ""
dongsheng@627 16274
dongsheng@627 16275 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16276 #: ../en/ch13-hgext.xml:190
dongsheng@627 16277 msgid ""
dongsheng@627 16278 "Go into the <filename class=\"directory\">inotify</filename> repo, and apply "
dongsheng@627 16279 "all of the <literal role=\"hg-ext\">inotify</literal> patches using the "
dongsheng@627 16280 "<option role=\"hg-ext-mq-cmd-qpush-opt\">hg -a</option> option to the "
dongsheng@627 16281 "<command role=\"hg-ext-mq\">qpush</command> command."
dongsheng@627 16282 msgstr ""
dongsheng@627 16283
dongsheng@627 16284 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16285 #: ../en/ch13-hgext.xml:199
dongsheng@627 16286 msgid ""
dongsheng@627 16287 "If you get an error message from <command role=\"hg-ext-mq\">qpush</command>, "
dongsheng@627 16288 "you should not continue. Instead, ask for help."
dongsheng@627 16289 msgstr ""
dongsheng@627 16290
dongsheng@627 16291 #. type: Content of: <book><chapter><sect1><orderedlist><listitem><para>
dongsheng@650 16292 #: ../en/ch13-hgext.xml:203
dongsheng@627 16293 msgid "Build and install the patched version of Mercurial."
dongsheng@627 16294 msgstr ""
dongsheng@627 16295
dongsheng@627 16296 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16297 #: ../en/ch13-hgext.xml:209
dongsheng@627 16298 msgid ""
dongsheng@627 16299 "Once you've build a suitably patched version of Mercurial, all you need to do "
dongsheng@627 16300 "to enable the <literal role=\"hg-ext\">inotify</literal> extension is add an "
dongsheng@650 16301 "entry to your <filename role=\"special\">~/.hgrc</filename>."
dongsheng@650 16302 msgstr ""
dongsheng@650 16303
dongsheng@650 16304 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16305 #: ../en/ch13-hgext.xml:214
dongsheng@627 16306 msgid ""
dongsheng@627 16307 "When the <literal role=\"hg-ext\">inotify</literal> extension is enabled, "
dongsheng@627 16308 "Mercurial will automatically and transparently start the status daemon the "
dongsheng@627 16309 "first time you run a command that needs status in a repository. It runs one "
dongsheng@627 16310 "status daemon per repository."
dongsheng@627 16311 msgstr ""
dongsheng@627 16312
dongsheng@627 16313 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16314 #: ../en/ch13-hgext.xml:220
dongsheng@627 16315 msgid ""
dongsheng@627 16316 "The status daemon is started silently, and runs in the background. If you "
dongsheng@627 16317 "look at a list of running processes after you've enabled the <literal role="
dongsheng@627 16318 "\"hg-ext\">inotify</literal> extension and run a few commands in different "
dongsheng@627 16319 "repositories, you'll thus see a few <literal>hg</literal> processes sitting "
dongsheng@627 16320 "around, waiting for updates from the kernel and queries from Mercurial."
dongsheng@627 16321 msgstr ""
dongsheng@627 16322
dongsheng@627 16323 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16324 #: ../en/ch13-hgext.xml:228
dongsheng@627 16325 msgid ""
dongsheng@627 16326 "The first time you run a Mercurial command in a repository when you have the "
dongsheng@627 16327 "<literal role=\"hg-ext\">inotify</literal> extension enabled, it will run "
dongsheng@627 16328 "with about the same performance as a normal Mercurial command. This is "
dongsheng@627 16329 "because the status daemon needs to perform a normal status scan so that it "
dongsheng@627 16330 "has a baseline against which to apply later updates from the kernel. "
dongsheng@627 16331 "However, <emphasis>every</emphasis> subsequent command that does any kind of "
dongsheng@627 16332 "status check should be noticeably faster on repositories of even fairly "
dongsheng@627 16333 "modest size. Better yet, the bigger your repository is, the greater a "
dongsheng@627 16334 "performance advantage you'll see. The <literal role=\"hg-ext\">inotify</"
dongsheng@627 16335 "literal> daemon makes status operations almost instantaneous on repositories "
dongsheng@627 16336 "of all sizes!"
dongsheng@627 16337 msgstr ""
dongsheng@627 16338
dongsheng@627 16339 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16340 #: ../en/ch13-hgext.xml:242
dongsheng@627 16341 msgid ""
dongsheng@627 16342 "If you like, you can manually start a status daemon using the <command role="
dongsheng@627 16343 "\"hg-ext-inotify\">inserve</command> command. This gives you slightly finer "
dongsheng@627 16344 "control over how the daemon ought to run. This command will of course only "
dongsheng@627 16345 "be available when the <literal role=\"hg-ext\">inotify</literal> extension is "
dongsheng@627 16346 "enabled."
dongsheng@627 16347 msgstr ""
dongsheng@627 16348
dongsheng@627 16349 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16350 #: ../en/ch13-hgext.xml:249
dongsheng@627 16351 msgid ""
dongsheng@627 16352 "When you're using the <literal role=\"hg-ext\">inotify</literal> extension, "
dongsheng@627 16353 "you should notice <emphasis>no difference at all</emphasis> in Mercurial's "
dongsheng@627 16354 "behaviour, with the sole exception of status-related commands running a whole "
dongsheng@627 16355 "lot faster than they used to. You should specifically expect that commands "
dongsheng@627 16356 "will not print different output; neither should they give different results. "
dongsheng@627 16357 "If either of these situations occurs, please report a bug."
dongsheng@627 16358 msgstr ""
dongsheng@627 16359
dongsheng@627 16360 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 16361 #: ../en/ch13-hgext.xml:260
dongsheng@627 16362 msgid ""
dongsheng@627 16363 "Flexible diff support with the <literal role=\"hg-ext\">extdiff</literal> "
dongsheng@627 16364 "extension"
dongsheng@636 16365 msgstr "使用扩展 <literal role=\"hg-ext\">extdiff</literal> 以扩展差异支持"
dongsheng@627 16366
dongsheng@627 16367 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16368 #: ../en/ch13-hgext.xml:263
dongsheng@627 16369 msgid ""
dongsheng@627 16370 "Mercurial's built-in <command role=\"hg-cmd\">hg diff</command> command "
dongsheng@627 16371 "outputs plaintext unified diffs."
dongsheng@627 16372 msgstr ""
dongsheng@627 16373 "Mercurial 内置命令 <command role=\"hg-cmd\">hg diff</command> 的输出与统一差异"
dongsheng@627 16374 "不同。"
dongsheng@627 16375
dongsheng@627 16376 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16377 #: ../en/ch13-hgext.xml:268
dongsheng@627 16378 msgid ""
dongsheng@627 16379 "If you would like to use an external tool to display modifications, you'll "
dongsheng@627 16380 "want to use the <literal role=\"hg-ext\">extdiff</literal> extension. This "
dongsheng@627 16381 "will let you use, for example, a graphical diff tool."
dongsheng@627 16382 msgstr ""
dongsheng@627 16383
dongsheng@627 16384 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16385 #: ../en/ch13-hgext.xml:273
dongsheng@627 16386 msgid ""
dongsheng@627 16387 "The <literal role=\"hg-ext\">extdiff</literal> extension is bundled with "
dongsheng@627 16388 "Mercurial, so it's easy to set up. In the <literal role=\"rc-extensions"
dongsheng@650 16389 "\">extensions</literal> section of your <filename role=\"special\">~/.hgrc</"
dongsheng@627 16390 "filename>, simply add a one-line entry to enable the extension."
dongsheng@627 16391 msgstr ""
dongsheng@627 16392
dongsheng@627 16393 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16394 #: ../en/ch13-hgext.xml:280
dongsheng@627 16395 msgid ""
dongsheng@627 16396 "This introduces a command named <command role=\"hg-ext-extdiff\">extdiff</"
dongsheng@627 16397 "command>, which by default uses your system's <command>diff</command> command "
dongsheng@627 16398 "to generate a unified diff in the same form as the built-in <command role="
dongsheng@627 16399 "\"hg-cmd\">hg diff</command> command."
dongsheng@627 16400 msgstr ""
dongsheng@627 16401
dongsheng@627 16402 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16403 #: ../en/ch13-hgext.xml:288
dongsheng@627 16404 msgid ""
dongsheng@627 16405 "The result won't be exactly the same as with the built-in <command role=\"hg-"
dongsheng@627 16406 "cmd\">hg diff</command> variations, because the output of <command>diff</"
dongsheng@627 16407 "command> varies from one system to another, even when passed the same options."
dongsheng@627 16408 msgstr ""
dongsheng@627 16409
dongsheng@627 16410 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16411 #: ../en/ch13-hgext.xml:293
dongsheng@627 16412 msgid ""
dongsheng@627 16413 "As the <quote><literal>making snapshot</literal></quote> lines of output "
dongsheng@627 16414 "above imply, the <command role=\"hg-ext-extdiff\">extdiff</command> command "
dongsheng@627 16415 "works by creating two snapshots of your source tree. The first snapshot is "
dongsheng@627 16416 "of the source revision; the second, of the target revision or working "
dongsheng@627 16417 "directory. The <command role=\"hg-ext-extdiff\">extdiff</command> command "
dongsheng@627 16418 "generates these snapshots in a temporary directory, passes the name of each "
dongsheng@627 16419 "directory to an external diff viewer, then deletes the temporary directory. "
dongsheng@627 16420 "For efficiency, it only snapshots the directories and files that have changed "
dongsheng@627 16421 "between the two revisions."
dongsheng@627 16422 msgstr ""
dongsheng@627 16423
dongsheng@627 16424 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16425 #: ../en/ch13-hgext.xml:306
dongsheng@627 16426 msgid ""
dongsheng@627 16427 "Snapshot directory names have the same base name as your repository. If your "
dongsheng@627 16428 "repository path is <filename class=\"directory\">/quux/bar/foo</filename>, "
dongsheng@627 16429 "then <filename class=\"directory\">foo</filename> will be the name of each "
dongsheng@627 16430 "snapshot directory. Each snapshot directory name has its changeset ID "
dongsheng@627 16431 "appended, if appropriate. If a snapshot is of revision "
dongsheng@627 16432 "<literal>a631aca1083f</literal>, the directory will be named <filename class="
dongsheng@627 16433 "\"directory\">foo.a631aca1083f</filename>. A snapshot of the working "
dongsheng@627 16434 "directory won't have a changeset ID appended, so it would just be <filename "
dongsheng@627 16435 "class=\"directory\">foo</filename> in this example. To see what this looks "
dongsheng@627 16436 "like in practice, look again at the <command role=\"hg-ext-extdiff\">extdiff</"
dongsheng@627 16437 "command> example above. Notice that the diff has the snapshot directory "
dongsheng@627 16438 "names embedded in its header."
dongsheng@627 16439 msgstr ""
dongsheng@627 16440
dongsheng@627 16441 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16442 #: ../en/ch13-hgext.xml:322
dongsheng@627 16443 msgid ""
dongsheng@627 16444 "The <command role=\"hg-ext-extdiff\">extdiff</command> command accepts two "
dongsheng@627 16445 "important options. The <option role=\"hg-ext-extdiff-cmd-extdiff-opt\">hg -p</"
dongsheng@627 16446 "option> option lets you choose a program to view differences with, instead of "
dongsheng@627 16447 "<command>diff</command>. With the <option role=\"hg-ext-extdiff-cmd-extdiff-"
dongsheng@627 16448 "opt\">hg -o</option> option, you can change the options that <command role="
dongsheng@627 16449 "\"hg-ext-extdiff\">extdiff</command> passes to the program (by default, these "
dongsheng@627 16450 "options are <quote><literal>-Npru</literal></quote>, which only make sense if "
dongsheng@627 16451 "you're running <command>diff</command>). In other respects, the <command "
dongsheng@627 16452 "role=\"hg-ext-extdiff\">extdiff</command> command acts similarly to the built-"
dongsheng@627 16453 "in <command role=\"hg-cmd\">hg diff</command> command: you use the same "
dongsheng@627 16454 "option names, syntax, and arguments to specify the revisions you want, the "
dongsheng@627 16455 "files you want, and so on."
dongsheng@627 16456 msgstr ""
dongsheng@627 16457
dongsheng@627 16458 #
dongsheng@627 16459 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16460 #: ../en/ch13-hgext.xml:339
dongsheng@627 16461 msgid ""
dongsheng@627 16462 "As an example, here's how to run the normal system <command>diff</command> "
dongsheng@627 16463 "command, getting it to generate context diffs (using the <option role=\"cmd-"
dongsheng@627 16464 "opt-diff\">-c</option> option) instead of unified diffs, and five lines of "
dongsheng@627 16465 "context instead of the default three (passing <literal>5</literal> as the "
dongsheng@627 16466 "argument to the <option role=\"cmd-opt-diff\">-C</option> option)."
dongsheng@627 16467 msgstr ""
dongsheng@627 16468
dongsheng@627 16469 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16470 #: ../en/ch13-hgext.xml:348
dongsheng@627 16471 msgid ""
dongsheng@627 16472 "Launching a visual diff tool is just as easy. Here's how to launch the "
dongsheng@627 16473 "<command>kdiff3</command> viewer."
dongsheng@627 16474 msgstr ""
dongsheng@627 16475
dongsheng@627 16476 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16477 #: ../en/ch13-hgext.xml:352
dongsheng@627 16478 msgid ""
dongsheng@627 16479 "If your diff viewing command can't deal with directories, you can easily work "
dongsheng@627 16480 "around this with a little scripting. For an example of such scripting in "
dongsheng@627 16481 "action with the <literal role=\"hg-ext\">mq</literal> extension and the "
songdongsheng@658 16482 "<command>interdiff</command> command, see <xref linkend=\"mq-collab:tips:"
songdongsheng@658 16483 "interdiff\"/>."
dongsheng@627 16484 msgstr ""
dongsheng@627 16485
dongsheng@627 16486 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 16487 #: ../en/ch13-hgext.xml:360
dongsheng@627 16488 msgid "Defining command aliases"
dongsheng@636 16489 msgstr "定义命令的别名"
dongsheng@627 16490
dongsheng@627 16491 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16492 #: ../en/ch13-hgext.xml:362
dongsheng@627 16493 msgid ""
dongsheng@627 16494 "It can be cumbersome to remember the options to both the <command role=\"hg-"
dongsheng@627 16495 "ext-extdiff\">extdiff</command> command and the diff viewer you want to use, "
dongsheng@627 16496 "so the <literal role=\"hg-ext\">extdiff</literal> extension lets you define "
dongsheng@627 16497 "<emphasis>new</emphasis> commands that will invoke your diff viewer with "
dongsheng@627 16498 "exactly the right options."
dongsheng@627 16499 msgstr ""
dongsheng@627 16500
dongsheng@627 16501 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16502 #: ../en/ch13-hgext.xml:369
dongsheng@650 16503 msgid ""
dongsheng@650 16504 "All you need to do is edit your <filename role=\"special\">~/.hgrc</"
dongsheng@627 16505 "filename>, and add a section named <literal role=\"rc-extdiff\">extdiff</"
dongsheng@627 16506 "literal>. Inside this section, you can define multiple commands. Here's how "
dongsheng@627 16507 "to add a <literal>kdiff3</literal> command. Once you've defined this, you "
dongsheng@627 16508 "can type <quote><literal>hg kdiff3</literal></quote> and the <literal role="
dongsheng@627 16509 "\"hg-ext\">extdiff</literal> extension will run <command>kdiff3</command> for "
dongsheng@627 16510 "you."
dongsheng@627 16511 msgstr ""
dongsheng@627 16512
dongsheng@627 16513 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16514 #: ../en/ch13-hgext.xml:379
dongsheng@627 16515 msgid ""
dongsheng@627 16516 "If you leave the right hand side of the definition empty, as above, the "
dongsheng@627 16517 "<literal role=\"hg-ext\">extdiff</literal> extension uses the name of the "
dongsheng@627 16518 "command you defined as the name of the external program to run. But these "
dongsheng@627 16519 "names don't have to be the same. Here, we define a command named "
dongsheng@627 16520 "<quote><literal>hg wibble</literal></quote>, which runs <command>kdiff3</"
dongsheng@627 16521 "command>."
dongsheng@627 16522 msgstr ""
dongsheng@627 16523
dongsheng@627 16524 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16525 #: ../en/ch13-hgext.xml:389
dongsheng@627 16526 msgid ""
dongsheng@627 16527 "You can also specify the default options that you want to invoke your diff "
dongsheng@627 16528 "viewing program with. The prefix to use is <quote><literal>opts.</literal></"
dongsheng@627 16529 "quote>, followed by the name of the command to which the options apply. This "
dongsheng@627 16530 "example defines a <quote><literal>hg vimdiff</literal></quote> command that "
dongsheng@627 16531 "runs the <command>vim</command> editor's <literal>DirDiff</literal> extension."
dongsheng@627 16532 msgstr ""
dongsheng@627 16533
dongsheng@627 16534 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 16535 #: ../en/ch13-hgext.xml:403
dongsheng@627 16536 msgid ""
dongsheng@627 16537 "Cherrypicking changes with the <literal role=\"hg-ext\">transplant</literal> "
dongsheng@627 16538 "extension"
dongsheng@636 16539 msgstr "使用扩展 <literal role=\"hg-ext\">transplant</literal> 以挑选修改"
dongsheng@627 16540
dongsheng@627 16541 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16542 #: ../en/ch13-hgext.xml:406
dongsheng@627 16543 msgid "Need to have a long chat with Brendan about this."
dongsheng@627 16544 msgstr ""
dongsheng@627 16545
dongsheng@627 16546 #. type: Content of: <book><chapter><sect1><title>
dongsheng@650 16547 #: ../en/ch13-hgext.xml:410
dongsheng@627 16548 msgid ""
dongsheng@627 16549 "Send changes via email with the <literal role=\"hg-ext\">patchbomb</literal> "
dongsheng@627 16550 "extension"
dongsheng@627 16551 msgstr ""
dongsheng@636 16552 "使用扩展 <literal role=\"hg-ext\">patchbomb</literal> 通过 email 发送修改"
dongsheng@627 16553
dongsheng@627 16554 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16555 #: ../en/ch13-hgext.xml:413
dongsheng@627 16556 msgid ""
dongsheng@627 16557 "Many projects have a culture of <quote>change review</quote>, in which people "
dongsheng@627 16558 "send their modifications to a mailing list for others to read and comment on "
dongsheng@627 16559 "before they commit the final version to a shared repository. Some projects "
dongsheng@627 16560 "have people who act as gatekeepers; they apply changes from other people to a "
dongsheng@627 16561 "repository to which those others don't have access."
dongsheng@627 16562 msgstr ""
dongsheng@627 16563
dongsheng@627 16564 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16565 #: ../en/ch13-hgext.xml:421
dongsheng@627 16566 msgid ""
dongsheng@627 16567 "Mercurial makes it easy to send changes over email for review or application, "
dongsheng@627 16568 "via its <literal role=\"hg-ext\">patchbomb</literal> extension. The "
dongsheng@627 16569 "extension is so named because changes are formatted as patches, and it's "
dongsheng@627 16570 "usual to send one changeset per email message. Sending a long series of "
dongsheng@627 16571 "changes by email is thus much like <quote>bombing</quote> the recipient's "
dongsheng@627 16572 "inbox, hence <quote>patchbomb</quote>."
dongsheng@627 16573 msgstr ""
dongsheng@627 16574
dongsheng@627 16575 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16576 #: ../en/ch13-hgext.xml:429
dongsheng@627 16577 msgid ""
dongsheng@627 16578 "As usual, the basic configuration of the <literal role=\"hg-ext\">patchbomb</"
dongsheng@627 16579 "literal> extension takes just one or two lines in your <filename role="
dongsheng@627 16580 "\"special\"> /.hgrc</filename>."
dongsheng@627 16581 msgstr ""
dongsheng@627 16582
dongsheng@627 16583 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16584 #: ../en/ch13-hgext.xml:435
dongsheng@627 16585 msgid ""
dongsheng@627 16586 "Once you've enabled the extension, you will have a new command available, "
dongsheng@627 16587 "named <command role=\"hg-ext-patchbomb\">email</command>."
dongsheng@627 16588 msgstr ""
dongsheng@627 16589
dongsheng@627 16590 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16591 #: ../en/ch13-hgext.xml:439
dongsheng@627 16592 msgid ""
dongsheng@627 16593 "The safest and best way to invoke the <command role=\"hg-ext-patchbomb"
dongsheng@627 16594 "\">email</command> command is to <emphasis>always</emphasis> run it first "
dongsheng@627 16595 "with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</option> "
dongsheng@627 16596 "option. This will show you what the command <emphasis>would</emphasis> send, "
dongsheng@627 16597 "without actually sending anything. Once you've had a quick glance over the "
dongsheng@627 16598 "changes and verified that you are sending the right ones, you can rerun the "
dongsheng@627 16599 "same command, with the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -n</"
dongsheng@627 16600 "option> option removed."
dongsheng@627 16601 msgstr ""
dongsheng@627 16602
dongsheng@627 16603 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16604 #: ../en/ch13-hgext.xml:450
dongsheng@627 16605 msgid ""
dongsheng@627 16606 "The <command role=\"hg-ext-patchbomb\">email</command> command accepts the "
dongsheng@627 16607 "same kind of revision syntax as every other Mercurial command. For example, "
dongsheng@627 16608 "this command will send every revision between 7 and <literal>tip</literal>, "
dongsheng@627 16609 "inclusive."
dongsheng@627 16610 msgstr ""
dongsheng@627 16611
dongsheng@627 16612 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16613 #: ../en/ch13-hgext.xml:455
dongsheng@627 16614 msgid ""
dongsheng@627 16615 "You can also specify a <emphasis>repository</emphasis> to compare with. If "
dongsheng@627 16616 "you provide a repository but no revisions, the <command role=\"hg-ext-"
dongsheng@627 16617 "patchbomb\">email</command> command will send all revisions in the local "
dongsheng@627 16618 "repository that are not present in the remote repository. If you "
dongsheng@627 16619 "additionally specify revisions or a branch name (the latter using the <option "
dongsheng@627 16620 "role=\"hg-ext-patchbomb-cmd-email-opt\">hg -b</option> option), this will "
dongsheng@627 16621 "constrain the revisions sent."
dongsheng@627 16622 msgstr ""
dongsheng@627 16623
dongsheng@627 16624 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16625 #: ../en/ch13-hgext.xml:464
dongsheng@627 16626 msgid ""
dongsheng@627 16627 "It's perfectly safe to run the <command role=\"hg-ext-patchbomb\">email</"
dongsheng@627 16628 "command> command without the names of the people you want to send to: if you "
dongsheng@627 16629 "do this, it will just prompt you for those values interactively. (If you're "
dongsheng@627 16630 "using a Linux or Unix-like system, you should have enhanced "
dongsheng@627 16631 "<literal>readline</literal>-style editing capabilities when entering those "
dongsheng@627 16632 "headers, too, which is useful.)"
dongsheng@627 16633 msgstr ""
dongsheng@627 16634
dongsheng@627 16635 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16636 #: ../en/ch13-hgext.xml:472
dongsheng@627 16637 msgid ""
dongsheng@627 16638 "When you are sending just one revision, the <command role=\"hg-ext-patchbomb"
dongsheng@627 16639 "\">email</command> command will by default use the first line of the "
dongsheng@627 16640 "changeset description as the subject of the single email message it sends."
dongsheng@627 16641 msgstr ""
dongsheng@627 16642
dongsheng@627 16643 #. type: Content of: <book><chapter><sect1><para>
dongsheng@650 16644 #: ../en/ch13-hgext.xml:477
dongsheng@627 16645 msgid ""
dongsheng@627 16646 "If you send multiple revisions, the <command role=\"hg-ext-patchbomb\">email</"
dongsheng@627 16647 "command> command will usually send one message per changeset. It will "
dongsheng@627 16648 "preface the series with an introductory message, in which you should describe "
dongsheng@627 16649 "the purpose of the series of changes you're sending."
dongsheng@627 16650 msgstr ""
dongsheng@627 16651
dongsheng@627 16652 #. type: Content of: <book><chapter><sect1><sect2><title>
dongsheng@650 16653 #: ../en/ch13-hgext.xml:484
dongsheng@627 16654 msgid "Changing the behaviour of patchbombs"
dongsheng@636 16655 msgstr "修改 patchbomb 的行为"
dongsheng@627 16656
dongsheng@627 16657 #. type: Content of: <book><chapter><sect1><sect2><para>
dongsheng@650 16658 #: ../en/ch13-hgext.xml:486
dongsheng@627 16659 msgid ""
dongsheng@627 16660 "Not every project has exactly the same conventions for sending changes in "
dongsheng@627 16661 "email; the <literal role=\"hg-ext\">patchbomb</literal> extension tries to "
dongsheng@627 16662 "accommodate a number of variations through command line options."
dongsheng@627 16663 msgstr ""
dongsheng@627 16664
dongsheng@627 16665 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16666 #: ../en/ch13-hgext.xml:492
dongsheng@627 16667 msgid ""
dongsheng@627 16668 "You can write a subject for the introductory message on the command line "
dongsheng@627 16669 "using the <option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -s</option> "
dongsheng@627 16670 "option. This takes one argument, the text of the subject to use."
dongsheng@627 16671 msgstr ""
dongsheng@627 16672
dongsheng@627 16673 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16674 #: ../en/ch13-hgext.xml:498
dongsheng@627 16675 msgid ""
dongsheng@627 16676 "To change the email address from which the messages originate, use the "
dongsheng@627 16677 "<option role=\"hg-ext-patchbomb-cmd-email-opt\">hg -f</option> option. This "
dongsheng@627 16678 "takes one argument, the email address to use."
dongsheng@627 16679 msgstr ""
dongsheng@627 16680
dongsheng@627 16681 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16682 #: ../en/ch13-hgext.xml:504
dongsheng@627 16683 msgid ""
songdongsheng@658 16684 "The default behaviour is to send unified diffs (see <xref linkend=\"sec:mq:"
songdongsheng@658 16685 "patch\"/> for a description of the format), one per message. You can send a "
songdongsheng@658 16686 "binary bundle instead with the <option role=\"hg-ext-patchbomb-cmd-email-opt"
songdongsheng@658 16687 "\">hg -b</option> option."
dongsheng@627 16688 msgstr ""
dongsheng@627 16689
dongsheng@627 16690 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16691 #: ../en/ch13-hgext.xml:512
dongsheng@627 16692 msgid ""
dongsheng@627 16693 "Unified diffs are normally prefaced with a metadata header. You can omit "
dongsheng@627 16694 "this, and send unadorned diffs, with the <option role=\"hg-ext-patchbomb-cmd-"
dongsheng@627 16695 "email-opt\">hg --plain</option> option."
dongsheng@627 16696 msgstr ""
dongsheng@627 16697
dongsheng@627 16698 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16699 #: ../en/ch13-hgext.xml:518
dongsheng@627 16700 msgid ""
dongsheng@627 16701 "Diffs are normally sent <quote>inline</quote>, in the same body part as the "
dongsheng@627 16702 "description of a patch. This makes it easiest for the largest number of "
dongsheng@627 16703 "readers to quote and respond to parts of a diff, as some mail clients will "
dongsheng@627 16704 "only quote the first MIME body part in a message. If you'd prefer to send the "
dongsheng@627 16705 "description and the diff in separate body parts, use the <option role=\"hg-"
dongsheng@627 16706 "ext-patchbomb-cmd-email-opt\">hg -a</option> option."
dongsheng@627 16707 msgstr ""
dongsheng@627 16708
dongsheng@627 16709 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16710 #: ../en/ch13-hgext.xml:528
dongsheng@627 16711 msgid ""
dongsheng@627 16712 "Instead of sending mail messages, you can write them to an <literal>mbox</"
dongsheng@627 16713 "literal>-format mail folder using the <option role=\"hg-ext-patchbomb-cmd-"
dongsheng@627 16714 "email-opt\">hg -m</option> option. That option takes one argument, the name "
dongsheng@627 16715 "of the file to write to."
dongsheng@627 16716 msgstr ""
dongsheng@627 16717
dongsheng@627 16718 #. type: Content of: <book><chapter><sect1><sect2><itemizedlist><listitem><para>
dongsheng@650 16719 #: ../en/ch13-hgext.xml:535
dongsheng@627 16720 msgid ""
dongsheng@627 16721 "If you would like to add a <command>diffstat</command>-format summary to each "
dongsheng@627 16722 "patch, and one to the introductory message, use the <option role=\"hg-ext-"
dongsheng@627 16723 "patchbomb-cmd-email-opt\">hg -d</option> option. The <command>diffstat</"
dongsheng@627 16724 "command> command displays a table containing the name of each file patched, "
dongsheng@627 16725 "the number of lines affected, and a histogram showing how much each file is "
dongsheng@627 16726 "modified. This gives readers a qualitative glance at how complex a patch is."
dongsheng@627 16727 msgstr ""