##// END OF EJS Templates
merge: tool.check = prompt will force an interactive merge check...
David Champion -
r11149:d3c1eddf default
parent child Browse files
Show More
@@ -1,1009 +1,1011
1 1 ======
2 2 hgrc
3 3 ======
4 4
5 5 ---------------------------------
6 6 configuration files for Mercurial
7 7 ---------------------------------
8 8
9 9 :Author: Bryan O'Sullivan <bos@serpentine.com>
10 10 :Organization: Mercurial
11 11 :Manual section: 5
12 12 :Manual group: Mercurial Manual
13 13
14 14 .. contents::
15 15 :backlinks: top
16 16 :class: htmlonly
17 17
18 18
19 19 Synopsis
20 20 --------
21 21
22 22 The Mercurial system uses a set of configuration files to control
23 23 aspects of its behavior.
24 24
25 25 Files
26 26 -----
27 27
28 28 Mercurial reads configuration data from several files, if they exist.
29 29 The names of these files depend on the system on which Mercurial is
30 30 installed. ``*.rc`` files from a single directory are read in
31 31 alphabetical order, later ones overriding earlier ones. Where multiple
32 32 paths are given below, settings from earlier paths override later
33 33 ones.
34 34
35 35 | (Unix, Windows) ``<repo>/.hg/hgrc``
36 36
37 37 Per-repository configuration options that only apply in a
38 38 particular repository. This file is not version-controlled, and
39 39 will not get transferred during a "clone" operation. Options in
40 40 this file override options in all other configuration files. On
41 41 Unix, most of this file will be ignored if it doesn't belong to a
42 42 trusted user or to a trusted group. See the documentation for the
43 43 trusted_ section below for more details.
44 44
45 45 | (Unix) ``$HOME/.hgrc``
46 46 | (Windows) ``%USERPROFILE%\.hgrc``
47 47 | (Windows) ``%USERPROFILE%\Mercurial.ini``
48 48 | (Windows) ``%HOME%\.hgrc``
49 49 | (Windows) ``%HOME%\Mercurial.ini``
50 50
51 51 Per-user configuration file(s), for the user running Mercurial. On
52 52 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
53 53 files apply to all Mercurial commands executed by this user in any
54 54 directory. Options in these files override per-system and per-installation
55 55 options.
56 56
57 57 | (Unix) ``/etc/mercurial/hgrc``
58 58 | (Unix) ``/etc/mercurial/hgrc.d/*.rc``
59 59
60 60 Per-system configuration files, for the system on which Mercurial
61 61 is running. Options in these files apply to all Mercurial commands
62 62 executed by any user in any directory. Options in these files
63 63 override per-installation options.
64 64
65 65 | (Unix) ``<install-root>/etc/mercurial/hgrc``
66 66 | (Unix) ``<install-root>/etc/mercurial/hgrc.d/*.rc``
67 67
68 68 Per-installation configuration files, searched for in the
69 69 directory where Mercurial is installed. ``<install-root>`` is the
70 70 parent directory of the **hg** executable (or symlink) being run. For
71 71 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
72 72 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
73 73 to all Mercurial commands executed by any user in any directory.
74 74
75 75 | (Windows) ``<install-dir>\Mercurial.ini``
76 76 | (Windows) ``<install-dir>\hgrc.d\*.rc``
77 77 | (Windows) ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial``
78 78
79 79 Per-installation/system configuration files, for the system on
80 80 which Mercurial is running. Options in these files apply to all
81 81 Mercurial commands executed by any user in any directory. Registry
82 82 keys contain PATH-like strings, every part of which must reference
83 83 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
84 84 be read. Mercurial checks each of these locations in the specified
85 85 order until one or more configuration files are detected. If the
86 86 pywin32 extensions are not installed, Mercurial will only look for
87 87 site-wide configuration in ``C:\Mercurial\Mercurial.ini``.
88 88
89 89 Syntax
90 90 ------
91 91
92 92 A configuration file consists of sections, led by a ``[section]`` header
93 93 and followed by ``name = value`` entries::
94 94
95 95 [spam]
96 96 eggs=ham
97 97 green=
98 98 eggs
99 99
100 100 Each line contains one entry. If the lines that follow are indented,
101 101 they are treated as continuations of that entry. Leading whitespace is
102 102 removed from values. Empty lines are skipped. Lines beginning with
103 103 ``#`` or ``;`` are ignored and may be used to provide comments.
104 104
105 105 A line of the form ``%include file`` will include ``file`` into the
106 106 current configuration file. The inclusion is recursive, which means
107 107 that included files can include other files. Filenames are relative to
108 108 the configuration file in which the ``%include`` directive is found.
109 109
110 110 A line with ``%unset name`` will remove ``name`` from the current
111 111 section, if it has been set previously.
112 112
113 113 The values are either free-form text strings, lists of text strings,
114 114 or Boolean values. Boolean values can be set to true using any of "1",
115 115 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
116 116 (all case insensitive).
117 117
118 118 List values are separated by whitespace or comma, except when values are
119 119 placed in double quotation marks::
120 120
121 121 allow_read = "John Doe, PhD", brian, betty
122 122
123 123 Quotation marks can be escaped by prefixing them with a backslash. Only
124 124 quotation marks at the beginning of a word is counted as a quotation
125 125 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
126 126
127 127 Sections
128 128 --------
129 129
130 130 This section describes the different sections that may appear in a
131 131 Mercurial "hgrc" file, the purpose of each section, its possible keys,
132 132 and their possible values.
133 133
134 134 ``alias``
135 135 """""""""
136 136 Defines command aliases.
137 137 Aliases allow you to define your own commands in terms of other
138 138 commands (or aliases), optionally including arguments.
139 139
140 140 Alias definitions consist of lines of the form::
141 141
142 142 <alias> = <command> [<argument]...
143 143
144 144 For example, this definition::
145 145
146 146 latest = log --limit 5
147 147
148 148 creates a new command ``latest`` that shows only the five most recent
149 149 changesets. You can define subsequent aliases using earlier ones::
150 150
151 151 stable5 = latest -b stable
152 152
153 153 .. note:: It is possible to create aliases with the same names as
154 154 existing commands, which will then override the original
155 155 definitions. This is almost always a bad idea!
156 156
157 157
158 158 ``auth``
159 159 """"""""
160 160 Authentication credentials for HTTP authentication. Each line has
161 161 the following format::
162 162
163 163 <name>.<argument> = <value>
164 164
165 165 where ``<name>`` is used to group arguments into authentication
166 166 entries. Example::
167 167
168 168 foo.prefix = hg.intevation.org/mercurial
169 169 foo.username = foo
170 170 foo.password = bar
171 171 foo.schemes = http https
172 172
173 173 bar.prefix = secure.example.org
174 174 bar.key = path/to/file.key
175 175 bar.cert = path/to/file.cert
176 176 bar.schemes = https
177 177
178 178 Supported arguments:
179 179
180 180 ``prefix``
181 181 Either ``*`` or a URI prefix with or without the scheme part.
182 182 The authentication entry with the longest matching prefix is used
183 183 (where ``*`` matches everything and counts as a match of length
184 184 1). If the prefix doesn't include a scheme, the match is performed
185 185 against the URI with its scheme stripped as well, and the schemes
186 186 argument, q.v., is then subsequently consulted.
187 187 ``username``
188 188 Optional. Username to authenticate with. If not given, and the
189 189 remote site requires basic or digest authentication, the user
190 190 will be prompted for it.
191 191 ``password``
192 192 Optional. Password to authenticate with. If not given, and the
193 193 remote site requires basic or digest authentication, the user
194 194 will be prompted for it.
195 195 ``key``
196 196 Optional. PEM encoded client certificate key file.
197 197 ``cert``
198 198 Optional. PEM encoded client certificate chain file.
199 199 ``schemes``
200 200 Optional. Space separated list of URI schemes to use this
201 201 authentication entry with. Only used if the prefix doesn't include
202 202 a scheme. Supported schemes are http and https. They will match
203 203 static-http and static-https respectively, as well.
204 204 Default: https.
205 205
206 206 If no suitable authentication entry is found, the user is prompted
207 207 for credentials as usual if required by the remote.
208 208
209 209
210 210 ``decode/encode``
211 211 """""""""""""""""
212 212 Filters for transforming files on checkout/checkin. This would
213 213 typically be used for newline processing or other
214 214 localization/canonicalization of files.
215 215
216 216 Filters consist of a filter pattern followed by a filter command.
217 217 Filter patterns are globs by default, rooted at the repository root.
218 218 For example, to match any file ending in ``.txt`` in the root
219 219 directory only, use the pattern ``*.txt``. To match any file ending
220 220 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
221 221 For each file only the first matching filter applies.
222 222
223 223 The filter command can start with a specifier, either ``pipe:`` or
224 224 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
225 225
226 226 A ``pipe:`` command must accept data on stdin and return the transformed
227 227 data on stdout.
228 228
229 229 Pipe example::
230 230
231 231 [encode]
232 232 # uncompress gzip files on checkin to improve delta compression
233 233 # note: not necessarily a good idea, just an example
234 234 *.gz = pipe: gunzip
235 235
236 236 [decode]
237 237 # recompress gzip files when writing them to the working dir (we
238 238 # can safely omit "pipe:", because it's the default)
239 239 *.gz = gzip
240 240
241 241 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
242 242 with the name of a temporary file that contains the data to be
243 243 filtered by the command. The string ``OUTFILE`` is replaced with the name
244 244 of an empty temporary file, where the filtered data must be written by
245 245 the command.
246 246
247 247 .. note:: The tempfile mechanism is recommended for Windows systems,
248 248 where the standard shell I/O redirection operators often have
249 249 strange effects and may corrupt the contents of your files.
250 250
251 251 The most common usage is for LF <-> CRLF translation on Windows. For
252 252 this, use the "smart" converters which check for binary files::
253 253
254 254 [extensions]
255 255 hgext.win32text =
256 256 [encode]
257 257 ** = cleverencode:
258 258 [decode]
259 259 ** = cleverdecode:
260 260
261 261 or if you only want to translate certain files::
262 262
263 263 [extensions]
264 264 hgext.win32text =
265 265 [encode]
266 266 **.txt = dumbencode:
267 267 [decode]
268 268 **.txt = dumbdecode:
269 269
270 270
271 271 ``defaults``
272 272 """"""""""""
273 273
274 274 (defaults are deprecated. Don't use them. Use aliases instead)
275 275
276 276 Use the ``[defaults]`` section to define command defaults, i.e. the
277 277 default options/arguments to pass to the specified commands.
278 278
279 279 The following example makes :hg:`log` run in verbose mode, and :hg:`hg
280 280 status` show only the modified files, by default::
281 281
282 282 [defaults]
283 283 log = -v
284 284 status = -m
285 285
286 286 The actual commands, instead of their aliases, must be used when
287 287 defining command defaults. The command defaults will also be applied
288 288 to the aliases of the commands defined.
289 289
290 290
291 291 ``diff``
292 292 """"""""
293 293
294 294 Settings used when displaying diffs. They are all Boolean and
295 295 defaults to False.
296 296
297 297 ``git``
298 298 Use git extended diff format.
299 299 ``nodates``
300 300 Don't include dates in diff headers.
301 301 ``showfunc``
302 302 Show which function each change is in.
303 303 ``ignorews``
304 304 Ignore white space when comparing lines.
305 305 ``ignorewsamount``
306 306 Ignore changes in the amount of white space.
307 307 ``ignoreblanklines``
308 308 Ignore changes whose lines are all blank.
309 309
310 310 ``email``
311 311 """""""""
312 312 Settings for extensions that send email messages.
313 313
314 314 ``from``
315 315 Optional. Email address to use in "From" header and SMTP envelope
316 316 of outgoing messages.
317 317 ``to``
318 318 Optional. Comma-separated list of recipients' email addresses.
319 319 ``cc``
320 320 Optional. Comma-separated list of carbon copy recipients'
321 321 email addresses.
322 322 ``bcc``
323 323 Optional. Comma-separated list of blind carbon copy recipients'
324 324 email addresses.
325 325 ``method``
326 326 Optional. Method to use to send email messages. If value is ``smtp``
327 327 (default), use SMTP (see the SMTP_ section for configuration).
328 328 Otherwise, use as name of program to run that acts like sendmail
329 329 (takes ``-f`` option for sender, list of recipients on command line,
330 330 message on stdin). Normally, setting this to ``sendmail`` or
331 331 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
332 332 ``charsets``
333 333 Optional. Comma-separated list of character sets considered
334 334 convenient for recipients. Addresses, headers, and parts not
335 335 containing patches of outgoing messages will be encoded in the
336 336 first character set to which conversion from local encoding
337 337 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
338 338 conversion fails, the text in question is sent as is. Defaults to
339 339 empty (explicit) list.
340 340
341 341 Order of outgoing email character sets:
342 342
343 343 1. ``us-ascii``: always first, regardless of settings
344 344 2. ``email.charsets``: in order given by user
345 345 3. ``ui.fallbackencoding``: if not in email.charsets
346 346 4. ``$HGENCODING``: if not in email.charsets
347 347 5. ``utf-8``: always last, regardless of settings
348 348
349 349 Email example::
350 350
351 351 [email]
352 352 from = Joseph User <joe.user@example.com>
353 353 method = /usr/sbin/sendmail
354 354 # charsets for western Europeans
355 355 # us-ascii, utf-8 omitted, as they are tried first and last
356 356 charsets = iso-8859-1, iso-8859-15, windows-1252
357 357
358 358
359 359 ``extensions``
360 360 """"""""""""""
361 361
362 362 Mercurial has an extension mechanism for adding new features. To
363 363 enable an extension, create an entry for it in this section.
364 364
365 365 If you know that the extension is already in Python's search path,
366 366 you can give the name of the module, followed by ``=``, with nothing
367 367 after the ``=``.
368 368
369 369 Otherwise, give a name that you choose, followed by ``=``, followed by
370 370 the path to the ``.py`` file (including the file name extension) that
371 371 defines the extension.
372 372
373 373 To explicitly disable an extension that is enabled in an hgrc of
374 374 broader scope, prepend its path with ``!``, as in
375 375 ``hgext.foo = !/ext/path`` or ``hgext.foo = !`` when path is not
376 376 supplied.
377 377
378 378 Example for ``~/.hgrc``::
379 379
380 380 [extensions]
381 381 # (the mq extension will get loaded from Mercurial's path)
382 382 hgext.mq =
383 383 # (this extension will get loaded from the file specified)
384 384 myfeature = ~/.hgext/myfeature.py
385 385
386 386
387 387 ``format``
388 388 """"""""""
389 389
390 390 ``usestore``
391 391 Enable or disable the "store" repository format which improves
392 392 compatibility with systems that fold case or otherwise mangle
393 393 filenames. Enabled by default. Disabling this option will allow
394 394 you to store longer filenames in some situations at the expense of
395 395 compatibility and ensures that the on-disk format of newly created
396 396 repositories will be compatible with Mercurial before version 0.9.4.
397 397
398 398 ``usefncache``
399 399 Enable or disable the "fncache" repository format which enhances
400 400 the "store" repository format (which has to be enabled to use
401 401 fncache) to allow longer filenames and avoids using Windows
402 402 reserved names, e.g. "nul". Enabled by default. Disabling this
403 403 option ensures that the on-disk format of newly created
404 404 repositories will be compatible with Mercurial before version 1.1.
405 405
406 406 ``merge-patterns``
407 407 """"""""""""""""""
408 408
409 409 This section specifies merge tools to associate with particular file
410 410 patterns. Tools matched here will take precedence over the default
411 411 merge tool. Patterns are globs by default, rooted at the repository
412 412 root.
413 413
414 414 Example::
415 415
416 416 [merge-patterns]
417 417 **.c = kdiff3
418 418 **.jpg = myimgmerge
419 419
420 420 ``merge-tools``
421 421 """""""""""""""
422 422
423 423 This section configures external merge tools to use for file-level
424 424 merges.
425 425
426 426 Example ``~/.hgrc``::
427 427
428 428 [merge-tools]
429 429 # Override stock tool location
430 430 kdiff3.executable = ~/bin/kdiff3
431 431 # Specify command line
432 432 kdiff3.args = $base $local $other -o $output
433 433 # Give higher priority
434 434 kdiff3.priority = 1
435 435
436 436 # Define new tool
437 437 myHtmlTool.args = -m $local $other $base $output
438 438 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
439 439 myHtmlTool.priority = 1
440 440
441 441 Supported arguments:
442 442
443 443 ``priority``
444 444 The priority in which to evaluate this tool.
445 445 Default: 0.
446 446 ``executable``
447 447 Either just the name of the executable or its pathname. On Windows,
448 448 the path can use environment variables with ${ProgramFiles} syntax.
449 449 Default: the tool name.
450 450 ``args``
451 451 The arguments to pass to the tool executable. You can refer to the
452 452 files being merged as well as the output file through these
453 453 variables: ``$base``, ``$local``, ``$other``, ``$output``.
454 454 Default: ``$local $base $other``
455 455 ``premerge``
456 456 Attempt to run internal non-interactive 3-way merge tool before
457 457 launching external tool. Options are ``true``, ``false``, or ``keep``
458 458 to leave markers in the file if the premerge fails.
459 459 Default: True
460 460 ``binary``
461 461 This tool can merge binary files. Defaults to False, unless tool
462 462 was selected by file pattern match.
463 463 ``symlink``
464 464 This tool can merge symlinks. Defaults to False, even if tool was
465 465 selected by file pattern match.
466 466 ``check``
467 467 A list of merge success-checking options:
468 468
469 469 ``changed``
470 470 Ask whether merge was successful when the merged file shows no changes.
471 471 ``conflicts``
472 472 Check whether there are conflicts even though the tool reported success.
473 ``prompt``
474 Always prompt for merge success, regardless of success reported by tool.
473 475
474 476 ``checkchanged``
475 477 True is equivalent to ``check = changed``.
476 478 Default: False
477 479 ``checkconflicts``
478 480 True is equivalent to ``check = conflicts``.
479 481 Default: False
480 482 ``fixeol``
481 483 Attempt to fix up EOL changes caused by the merge tool.
482 484 Default: False
483 485 ``gui``
484 486 This tool requires a graphical interface to run. Default: False
485 487 ``regkey``
486 488 Windows registry key which describes install location of this
487 489 tool. Mercurial will search for this key first under
488 490 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
489 491 Default: None
490 492 ``regname``
491 493 Name of value to read from specified registry key. Defaults to the
492 494 unnamed (default) value.
493 495 ``regappend``
494 496 String to append to the value read from the registry, typically
495 497 the executable name of the tool.
496 498 Default: None
497 499
498 500
499 501 ``hooks``
500 502 """""""""
501 503 Commands or Python functions that get automatically executed by
502 504 various actions such as starting or finishing a commit. Multiple
503 505 hooks can be run for the same action by appending a suffix to the
504 506 action. Overriding a site-wide hook can be done by changing its
505 507 value or setting it to an empty string.
506 508
507 509 Example ``.hg/hgrc``::
508 510
509 511 [hooks]
510 512 # update working directory after adding changesets
511 513 changegroup.update = hg update
512 514 # do not use the site-wide hook
513 515 incoming =
514 516 incoming.email = /my/email/hook
515 517 incoming.autobuild = /my/build/hook
516 518
517 519 Most hooks are run with environment variables set that give useful
518 520 additional information. For each hook below, the environment
519 521 variables it is passed are listed with names of the form ``$HG_foo``.
520 522
521 523 ``changegroup``
522 524 Run after a changegroup has been added via push, pull or unbundle.
523 525 ID of the first new changeset is in ``$HG_NODE``. URL from which
524 526 changes came is in ``$HG_URL``.
525 527 ``commit``
526 528 Run after a changeset has been created in the local repository. ID
527 529 of the newly created changeset is in ``$HG_NODE``. Parent changeset
528 530 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
529 531 ``incoming``
530 532 Run after a changeset has been pulled, pushed, or unbundled into
531 533 the local repository. The ID of the newly arrived changeset is in
532 534 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
533 535 ``outgoing``
534 536 Run after sending changes from local repository to another. ID of
535 537 first changeset sent is in ``$HG_NODE``. Source of operation is in
536 538 ``$HG_SOURCE``; see "preoutgoing" hook for description.
537 539 ``post-<command>``
538 540 Run after successful invocations of the associated command. The
539 541 contents of the command line are passed as ``$HG_ARGS`` and the result
540 542 code in ``$HG_RESULT``. Hook failure is ignored.
541 543 ``pre-<command>``
542 544 Run before executing the associated command. The contents of the
543 545 command line are passed as ``$HG_ARGS``. If the hook returns failure,
544 546 the command doesn't execute and Mercurial returns the failure
545 547 code.
546 548 ``prechangegroup``
547 549 Run before a changegroup is added via push, pull or unbundle. Exit
548 550 status 0 allows the changegroup to proceed. Non-zero status will
549 551 cause the push, pull or unbundle to fail. URL from which changes
550 552 will come is in ``$HG_URL``.
551 553 ``precommit``
552 554 Run before starting a local commit. Exit status 0 allows the
553 555 commit to proceed. Non-zero status will cause the commit to fail.
554 556 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
555 557 ``preoutgoing``
556 558 Run before collecting changes to send from the local repository to
557 559 another. Non-zero status will cause failure. This lets you prevent
558 560 pull over HTTP or SSH. Also prevents against local pull, push
559 561 (outbound) or bundle commands, but not effective, since you can
560 562 just copy files instead then. Source of operation is in
561 563 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
562 564 SSH or HTTP repository. If "push", "pull" or "bundle", operation
563 565 is happening on behalf of repository on same system.
564 566 ``pretag``
565 567 Run before creating a tag. Exit status 0 allows the tag to be
566 568 created. Non-zero status will cause the tag to fail. ID of
567 569 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
568 570 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
569 571 ``pretxnchangegroup``
570 572 Run after a changegroup has been added via push, pull or unbundle,
571 573 but before the transaction has been committed. Changegroup is
572 574 visible to hook program. This lets you validate incoming changes
573 575 before accepting them. Passed the ID of the first new changeset in
574 576 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
575 577 status will cause the transaction to be rolled back and the push,
576 578 pull or unbundle will fail. URL that was source of changes is in
577 579 ``$HG_URL``.
578 580 ``pretxncommit``
579 581 Run after a changeset has been created but the transaction not yet
580 582 committed. Changeset is visible to hook program. This lets you
581 583 validate commit message and changes. Exit status 0 allows the
582 584 commit to proceed. Non-zero status will cause the transaction to
583 585 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
584 586 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
585 587 ``preupdate``
586 588 Run before updating the working directory. Exit status 0 allows
587 589 the update to proceed. Non-zero status will prevent the update.
588 590 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
589 591 of second new parent is in ``$HG_PARENT2``.
590 592 ``tag``
591 593 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
592 594 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
593 595 repository if ``$HG_LOCAL=0``.
594 596 ``update``
595 597 Run after updating the working directory. Changeset ID of first
596 598 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
597 599 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
598 600 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
599 601
600 602 .. note:: It is generally better to use standard hooks rather than the
601 603 generic pre- and post- command hooks as they are guaranteed to be
602 604 called in the appropriate contexts for influencing transactions.
603 605 Also, hooks like "commit" will be called in all contexts that
604 606 generate a commit (e.g. tag) and not just the commit command.
605 607
606 608 .. note:: Environment variables with empty values may not be passed to
607 609 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
608 610 will have an empty value under Unix-like platforms for non-merge
609 611 changesets, while it will not be available at all under Windows.
610 612
611 613 The syntax for Python hooks is as follows::
612 614
613 615 hookname = python:modulename.submodule.callable
614 616 hookname = python:/path/to/python/module.py:callable
615 617
616 618 Python hooks are run within the Mercurial process. Each hook is
617 619 called with at least three keyword arguments: a ui object (keyword
618 620 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
619 621 keyword that tells what kind of hook is used. Arguments listed as
620 622 environment variables above are passed as keyword arguments, with no
621 623 ``HG_`` prefix, and names in lower case.
622 624
623 625 If a Python hook returns a "true" value or raises an exception, this
624 626 is treated as a failure.
625 627
626 628
627 629 ``http_proxy``
628 630 """"""""""""""
629 631 Used to access web-based Mercurial repositories through a HTTP
630 632 proxy.
631 633
632 634 ``host``
633 635 Host name and (optional) port of the proxy server, for example
634 636 "myproxy:8000".
635 637 ``no``
636 638 Optional. Comma-separated list of host names that should bypass
637 639 the proxy.
638 640 ``passwd``
639 641 Optional. Password to authenticate with at the proxy server.
640 642 ``user``
641 643 Optional. User name to authenticate with at the proxy server.
642 644 ``always``
643 645 Optional. Always use the proxy, even for localhost and any entries
644 646 in ``http_proxy.no``. True or False. Default: False.
645 647
646 648 ``smtp``
647 649 """"""""
648 650 Configuration for extensions that need to send email messages.
649 651
650 652 ``host``
651 653 Host name of mail server, e.g. "mail.example.com".
652 654 ``port``
653 655 Optional. Port to connect to on mail server. Default: 25.
654 656 ``tls``
655 657 Optional. Whether to connect to mail server using TLS. True or
656 658 False. Default: False.
657 659 ``username``
658 660 Optional. User name to authenticate to SMTP server with. If
659 661 username is specified, password must also be specified.
660 662 Default: none.
661 663 ``password``
662 664 Optional. Password to authenticate to SMTP server with. If
663 665 username is specified, password must also be specified.
664 666 Default: none.
665 667 ``local_hostname``
666 668 Optional. It's the hostname that the sender can use to identify
667 669 itself to the MTA.
668 670
669 671
670 672 ``patch``
671 673 """""""""
672 674 Settings used when applying patches, for instance through the 'import'
673 675 command or with Mercurial Queues extension.
674 676
675 677 ``eol``
676 678 When set to 'strict' patch content and patched files end of lines
677 679 are preserved. When set to ``lf`` or ``crlf``, both files end of
678 680 lines are ignored when patching and the result line endings are
679 681 normalized to either LF (Unix) or CRLF (Windows). When set to
680 682 ``auto``, end of lines are again ignored while patching but line
681 683 endings in patched files are normalized to their original setting
682 684 on a per-file basis. If target file does not exist or has no end
683 685 of line, patch line endings are preserved.
684 686 Default: strict.
685 687
686 688
687 689 ``paths``
688 690 """""""""
689 691 Assigns symbolic names to repositories. The left side is the
690 692 symbolic name, and the right gives the directory or URL that is the
691 693 location of the repository. Default paths can be declared by setting
692 694 the following entries.
693 695
694 696 ``default``
695 697 Directory or URL to use when pulling if no source is specified.
696 698 Default is set to repository from which the current repository was
697 699 cloned.
698 700 ``default-push``
699 701 Optional. Directory or URL to use when pushing if no destination
700 702 is specified.
701 703
702 704
703 705 ``profiling``
704 706 """""""""""""
705 707 Specifies profiling format and file output. In this section
706 708 description, 'profiling data' stands for the raw data collected
707 709 during profiling, while 'profiling report' stands for a statistical
708 710 text report generated from the profiling data. The profiling is done
709 711 using lsprof.
710 712
711 713 ``format``
712 714 Profiling format.
713 715 Default: text.
714 716
715 717 ``text``
716 718 Generate a profiling report. When saving to a file, it should be
717 719 noted that only the report is saved, and the profiling data is
718 720 not kept.
719 721 ``kcachegrind``
720 722 Format profiling data for kcachegrind use: when saving to a
721 723 file, the generated file can directly be loaded into
722 724 kcachegrind.
723 725 ``output``
724 726 File path where profiling data or report should be saved. If the
725 727 file exists, it is replaced. Default: None, data is printed on
726 728 stderr
727 729
728 730 ``server``
729 731 """"""""""
730 732 Controls generic server settings.
731 733
732 734 ``uncompressed``
733 735 Whether to allow clients to clone a repository using the
734 736 uncompressed streaming protocol. This transfers about 40% more
735 737 data than a regular clone, but uses less memory and CPU on both
736 738 server and client. Over a LAN (100 Mbps or better) or a very fast
737 739 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
738 740 regular clone. Over most WAN connections (anything slower than
739 741 about 6 Mbps), uncompressed streaming is slower, because of the
740 742 extra data transfer overhead. This mode will also temporarily hold
741 743 the write lock while determining what data to transfer.
742 744 Default is True.
743 745
744 746 ``validate``
745 747 Whether to validate the completeness of pushed changesets by
746 748 checking that all new file revisions specified in manifests are
747 749 present. Default is False.
748 750
749 751 ``trusted``
750 752 """""""""""
751 753 For security reasons, Mercurial will not use the settings in the
752 754 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
753 755 user or to a trusted group. The main exception is the web interface,
754 756 which automatically uses some safe settings, since it's common to
755 757 serve repositories from different users.
756 758
757 759 This section specifies what users and groups are trusted. The
758 760 current user is always trusted. To trust everybody, list a user or a
759 761 group with name ``*``.
760 762
761 763 ``users``
762 764 Comma-separated list of trusted users.
763 765 ``groups``
764 766 Comma-separated list of trusted groups.
765 767
766 768
767 769 ``ui``
768 770 """"""
769 771
770 772 User interface controls.
771 773
772 774 ``archivemeta``
773 775 Whether to include the .hg_archival.txt file containing meta data
774 776 (hashes for the repository base and for tip) in archives created
775 777 by the :hg:`archive` command or downloaded via hgweb.
776 778 Default is True.
777 779 ``askusername``
778 780 Whether to prompt for a username when committing. If True, and
779 781 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
780 782 be prompted to enter a username. If no username is entered, the
781 783 default ``USER@HOST`` is used instead.
782 784 Default is False.
783 785 ``debug``
784 786 Print debugging information. True or False. Default is False.
785 787 ``editor``
786 788 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
787 789 ``fallbackencoding``
788 790 Encoding to try if it's not possible to decode the changelog using
789 791 UTF-8. Default is ISO-8859-1.
790 792 ``ignore``
791 793 A file to read per-user ignore patterns from. This file should be
792 794 in the same format as a repository-wide .hgignore file. This
793 795 option supports hook syntax, so if you want to specify multiple
794 796 ignore files, you can do so by setting something like
795 797 ``ignore.other = ~/.hgignore2``. For details of the ignore file
796 798 format, see the |hgignore(5)|_ man page.
797 799 ``interactive``
798 800 Allow to prompt the user. True or False. Default is True.
799 801 ``logtemplate``
800 802 Template string for commands that print changesets.
801 803 ``merge``
802 804 The conflict resolution program to use during a manual merge.
803 805 There are some internal tools available:
804 806
805 807 ``internal:local``
806 808 keep the local version
807 809 ``internal:other``
808 810 use the other version
809 811 ``internal:merge``
810 812 use the internal non-interactive merge tool
811 813 ``internal:fail``
812 814 fail to merge
813 815
814 816 For more information on configuring merge tools see the
815 817 merge-tools_ section.
816 818
817 819 ``patch``
818 820 command to use to apply patches. Look for ``gpatch`` or ``patch`` in
819 821 PATH if unset.
820 822 ``quiet``
821 823 Reduce the amount of output printed. True or False. Default is False.
822 824 ``remotecmd``
823 825 remote command to use for clone/push/pull operations. Default is ``hg``.
824 826 ``report_untrusted``
825 827 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
826 828 trusted user or group. True or False. Default is True.
827 829 ``slash``
828 830 Display paths using a slash (``/``) as the path separator. This
829 831 only makes a difference on systems where the default path
830 832 separator is not the slash character (e.g. Windows uses the
831 833 backslash character (``\``)).
832 834 Default is False.
833 835 ``ssh``
834 836 command to use for SSH connections. Default is ``ssh``.
835 837 ``strict``
836 838 Require exact command names, instead of allowing unambiguous
837 839 abbreviations. True or False. Default is False.
838 840 ``style``
839 841 Name of style to use for command output.
840 842 ``timeout``
841 843 The timeout used when a lock is held (in seconds), a negative value
842 844 means no timeout. Default is 600.
843 845 ``traceback``
844 846 Mercurial always prints a traceback when an unknown exception
845 847 occurs. Setting this to True will make Mercurial print a traceback
846 848 on all exceptions, even those recognized by Mercurial (such as
847 849 IOError or MemoryError). Default is False.
848 850 ``username``
849 851 The committer of a changeset created when running "commit".
850 852 Typically a person's name and email address, e.g. ``Fred Widget
851 853 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
852 854 the username in hgrc is empty, it has to be specified manually or
853 855 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
854 856 ``username =`` in the system hgrc).
855 857 ``verbose``
856 858 Increase the amount of output printed. True or False. Default is False.
857 859
858 860
859 861 ``web``
860 862 """""""
861 863 Web interface configuration.
862 864
863 865 ``accesslog``
864 866 Where to output the access log. Default is stdout.
865 867 ``address``
866 868 Interface address to bind to. Default is all.
867 869 ``allow_archive``
868 870 List of archive format (bz2, gz, zip) allowed for downloading.
869 871 Default is empty.
870 872 ``allowbz2``
871 873 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
872 874 revisions.
873 875 Default is False.
874 876 ``allowgz``
875 877 (DEPRECATED) Whether to allow .tar.gz downloading of repository
876 878 revisions.
877 879 Default is False.
878 880 ``allowpull``
879 881 Whether to allow pulling from the repository. Default is True.
880 882 ``allow_push``
881 883 Whether to allow pushing to the repository. If empty or not set,
882 884 push is not allowed. If the special value ``*``, any remote user can
883 885 push, including unauthenticated users. Otherwise, the remote user
884 886 must have been authenticated, and the authenticated user name must
885 887 be present in this list. The contents of the allow_push list are
886 888 examined after the deny_push list.
887 889 ``allow_read``
888 890 If the user has not already been denied repository access due to
889 891 the contents of deny_read, this list determines whether to grant
890 892 repository access to the user. If this list is not empty, and the
891 893 user is unauthenticated or not present in the list, then access is
892 894 denied for the user. If the list is empty or not set, then access
893 895 is permitted to all users by default. Setting allow_read to the
894 896 special value ``*`` is equivalent to it not being set (i.e. access
895 897 is permitted to all users). The contents of the allow_read list are
896 898 examined after the deny_read list.
897 899 ``allowzip``
898 900 (DEPRECATED) Whether to allow .zip downloading of repository
899 901 revisions. Default is False. This feature creates temporary files.
900 902 ``baseurl``
901 903 Base URL to use when publishing URLs in other locations, so
902 904 third-party tools like email notification hooks can construct
903 905 URLs. Example: ``http://hgserver/repos/``.
904 906 ``cacerts``
905 907 Path to file containing a list of PEM encoded certificate authorities
906 908 that may be used to verify an SSL server's identity. The form must be
907 909 as follows::
908 910
909 911 -----BEGIN CERTIFICATE-----
910 912 ... (certificate in base64 PEM encoding) ...
911 913 -----END CERTIFICATE-----
912 914 -----BEGIN CERTIFICATE-----
913 915 ... (certificate in base64 PEM encoding) ...
914 916 -----END CERTIFICATE-----
915 917
916 918 This feature is only supported when using Python 2.6. If you wish to
917 919 use it with earlier versions of Python, install the backported
918 920 version of the ssl library that is available from
919 921 ``http://pypi.python.org``.
920 922
921 923 You can use OpenSSL's CA certificate file if your platform has one.
922 924 On most Linux systems this will be ``/etc/ssl/certs/ca-certificates.crt``.
923 925 Otherwise you will have to generate this file manually.
924 926 ``contact``
925 927 Name or email address of the person in charge of the repository.
926 928 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
927 929 ``deny_push``
928 930 Whether to deny pushing to the repository. If empty or not set,
929 931 push is not denied. If the special value ``*``, all remote users are
930 932 denied push. Otherwise, unauthenticated users are all denied, and
931 933 any authenticated user name present in this list is also denied. The
932 934 contents of the deny_push list are examined before the allow_push list.
933 935 ``deny_read``
934 936 Whether to deny reading/viewing of the repository. If this list is
935 937 not empty, unauthenticated users are all denied, and any
936 938 authenticated user name present in this list is also denied access to
937 939 the repository. If set to the special value ``*``, all remote users
938 940 are denied access (rarely needed ;). If deny_read is empty or not set,
939 941 the determination of repository access depends on the presence and
940 942 content of the allow_read list (see description). If both
941 943 deny_read and allow_read are empty or not set, then access is
942 944 permitted to all users by default. If the repository is being
943 945 served via hgwebdir, denied users will not be able to see it in
944 946 the list of repositories. The contents of the deny_read list have
945 947 priority over (are examined before) the contents of the allow_read
946 948 list.
947 949 ``descend``
948 950 hgwebdir indexes will not descend into subdirectories. Only repositories
949 951 directly in the current path will be shown (other repositories are still
950 952 available from the index corresponding to their containing path).
951 953 ``description``
952 954 Textual description of the repository's purpose or contents.
953 955 Default is "unknown".
954 956 ``encoding``
955 957 Character encoding name. Default is the current locale charset.
956 958 Example: "UTF-8"
957 959 ``errorlog``
958 960 Where to output the error log. Default is stderr.
959 961 ``hidden``
960 962 Whether to hide the repository in the hgwebdir index.
961 963 Default is False.
962 964 ``ipv6``
963 965 Whether to use IPv6. Default is False.
964 966 ``name``
965 967 Repository name to use in the web interface. Default is current
966 968 working directory.
967 969 ``maxchanges``
968 970 Maximum number of changes to list on the changelog. Default is 10.
969 971 ``maxfiles``
970 972 Maximum number of files to list per changeset. Default is 10.
971 973 ``port``
972 974 Port to listen on. Default is 8000.
973 975 ``prefix``
974 976 Prefix path to serve from. Default is '' (server root).
975 977 ``push_ssl``
976 978 Whether to require that inbound pushes be transported over SSL to
977 979 prevent password sniffing. Default is True.
978 980 ``staticurl``
979 981 Base URL to use for static files. If unset, static files (e.g. the
980 982 hgicon.png favicon) will be served by the CGI script itself. Use
981 983 this setting to serve them directly with the HTTP server.
982 984 Example: ``http://hgserver/static/``.
983 985 ``stripes``
984 986 How many lines a "zebra stripe" should span in multiline output.
985 987 Default is 1; set to 0 to disable.
986 988 ``style``
987 989 Which template map style to use.
988 990 ``templates``
989 991 Where to find the HTML templates. Default is install path.
990 992
991 993
992 994 Author
993 995 ------
994 996 Bryan O'Sullivan <bos@serpentine.com>.
995 997
996 998 Mercurial was written by Matt Mackall <mpm@selenic.com>.
997 999
998 1000 See Also
999 1001 --------
1000 1002 |hg(1)|_, |hgignore(5)|_
1001 1003
1002 1004 Copying
1003 1005 -------
1004 1006 This manual page is copyright 2005 Bryan O'Sullivan.
1005 1007 Mercurial is copyright 2005-2010 Matt Mackall.
1006 1008 Free use of this software is granted under the terms of the GNU General
1007 1009 Public License version 2 or any later version.
1008 1010
1009 1011 .. include:: common.txt
@@ -1,252 +1,259
1 1 # filemerge.py - file-level merge handling for Mercurial
2 2 #
3 3 # Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from node import short
9 9 from i18n import _
10 10 import util, simplemerge, match, error
11 11 import os, tempfile, re, filecmp
12 12
13 13 def _toolstr(ui, tool, part, default=""):
14 14 return ui.config("merge-tools", tool + "." + part, default)
15 15
16 16 def _toolbool(ui, tool, part, default=False):
17 17 return ui.configbool("merge-tools", tool + "." + part, default)
18 18
19 19 def _toollist(ui, tool, part, default=[]):
20 20 return ui.configlist("merge-tools", tool + "." + part, default)
21 21
22 22 _internal = ['internal:' + s
23 23 for s in 'fail local other merge prompt dump'.split()]
24 24
25 25 def _findtool(ui, tool):
26 26 if tool in _internal:
27 27 return tool
28 28 k = _toolstr(ui, tool, "regkey")
29 29 if k:
30 30 p = util.lookup_reg(k, _toolstr(ui, tool, "regname"))
31 31 if p:
32 32 p = util.find_exe(p + _toolstr(ui, tool, "regappend"))
33 33 if p:
34 34 return p
35 35 return util.find_exe(_toolstr(ui, tool, "executable", tool))
36 36
37 37 def _picktool(repo, ui, path, binary, symlink):
38 38 def check(tool, pat, symlink, binary):
39 39 tmsg = tool
40 40 if pat:
41 41 tmsg += " specified for " + pat
42 42 if not _findtool(ui, tool):
43 43 if pat: # explicitly requested tool deserves a warning
44 44 ui.warn(_("couldn't find merge tool %s\n") % tmsg)
45 45 else: # configured but non-existing tools are more silent
46 46 ui.note(_("couldn't find merge tool %s\n") % tmsg)
47 47 elif symlink and not _toolbool(ui, tool, "symlink"):
48 48 ui.warn(_("tool %s can't handle symlinks\n") % tmsg)
49 49 elif binary and not _toolbool(ui, tool, "binary"):
50 50 ui.warn(_("tool %s can't handle binary\n") % tmsg)
51 51 elif not util.gui() and _toolbool(ui, tool, "gui"):
52 52 ui.warn(_("tool %s requires a GUI\n") % tmsg)
53 53 else:
54 54 return True
55 55 return False
56 56
57 57 # HGMERGE takes precedence
58 58 hgmerge = os.environ.get("HGMERGE")
59 59 if hgmerge:
60 60 return (hgmerge, hgmerge)
61 61
62 62 # then patterns
63 63 for pat, tool in ui.configitems("merge-patterns"):
64 64 mf = match.match(repo.root, '', [pat])
65 65 if mf(path) and check(tool, pat, symlink, False):
66 66 toolpath = _findtool(ui, tool)
67 67 return (tool, '"' + toolpath + '"')
68 68
69 69 # then merge tools
70 70 tools = {}
71 71 for k, v in ui.configitems("merge-tools"):
72 72 t = k.split('.')[0]
73 73 if t not in tools:
74 74 tools[t] = int(_toolstr(ui, t, "priority", "0"))
75 75 names = tools.keys()
76 76 tools = sorted([(-p, t) for t, p in tools.items()])
77 77 uimerge = ui.config("ui", "merge")
78 78 if uimerge:
79 79 if uimerge not in names:
80 80 return (uimerge, uimerge)
81 81 tools.insert(0, (None, uimerge)) # highest priority
82 82 tools.append((None, "hgmerge")) # the old default, if found
83 83 for p, t in tools:
84 84 if check(t, None, symlink, binary):
85 85 toolpath = _findtool(ui, t)
86 86 return (t, '"' + toolpath + '"')
87 87 # internal merge as last resort
88 88 return (not (symlink or binary) and "internal:merge" or None, None)
89 89
90 90 def _eoltype(data):
91 91 "Guess the EOL type of a file"
92 92 if '\0' in data: # binary
93 93 return None
94 94 if '\r\n' in data: # Windows
95 95 return '\r\n'
96 96 if '\r' in data: # Old Mac
97 97 return '\r'
98 98 if '\n' in data: # UNIX
99 99 return '\n'
100 100 return None # unknown
101 101
102 102 def _matcheol(file, origfile):
103 103 "Convert EOL markers in a file to match origfile"
104 104 tostyle = _eoltype(open(origfile, "rb").read())
105 105 if tostyle:
106 106 data = open(file, "rb").read()
107 107 style = _eoltype(data)
108 108 if style:
109 109 newdata = data.replace(style, tostyle)
110 110 if newdata != data:
111 111 open(file, "wb").write(newdata)
112 112
113 113 def filemerge(repo, mynode, orig, fcd, fco, fca):
114 114 """perform a 3-way merge in the working directory
115 115
116 116 mynode = parent node before merge
117 117 orig = original local filename before merge
118 118 fco = other file context
119 119 fca = ancestor file context
120 120 fcd = local file context for current/destination file
121 121 """
122 122
123 123 def temp(prefix, ctx):
124 124 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
125 125 (fd, name) = tempfile.mkstemp(prefix=pre)
126 126 data = repo.wwritedata(ctx.path(), ctx.data())
127 127 f = os.fdopen(fd, "wb")
128 128 f.write(data)
129 129 f.close()
130 130 return name
131 131
132 132 def isbin(ctx):
133 133 try:
134 134 return util.binary(ctx.data())
135 135 except IOError:
136 136 return False
137 137
138 138 if not fco.cmp(fcd.data()): # files identical?
139 139 return None
140 140
141 141 if fca == fco: # backwards, use working dir parent as ancestor
142 142 fca = fcd.parents()[0]
143 143
144 144 ui = repo.ui
145 145 fd = fcd.path()
146 146 binary = isbin(fcd) or isbin(fco) or isbin(fca)
147 147 symlink = 'l' in fcd.flags() + fco.flags()
148 148 tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
149 149 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
150 150 (tool, fd, binary, symlink))
151 151
152 152 if not tool or tool == 'internal:prompt':
153 153 tool = "internal:local"
154 154 if ui.promptchoice(_(" no tool found to merge %s\n"
155 155 "keep (l)ocal or take (o)ther?") % fd,
156 156 (_("&Local"), _("&Other")), 0):
157 157 tool = "internal:other"
158 158 if tool == "internal:local":
159 159 return 0
160 160 if tool == "internal:other":
161 161 repo.wwrite(fd, fco.data(), fco.flags())
162 162 return 0
163 163 if tool == "internal:fail":
164 164 return 1
165 165
166 166 # do the actual merge
167 167 a = repo.wjoin(fd)
168 168 b = temp("base", fca)
169 169 c = temp("other", fco)
170 170 out = ""
171 171 back = a + ".orig"
172 172 util.copyfile(a, back)
173 173
174 174 if orig != fco.path():
175 175 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
176 176 else:
177 177 ui.status(_("merging %s\n") % fd)
178 178
179 179 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
180 180
181 181 # do we attempt to simplemerge first?
182 182 try:
183 183 premerge = _toolbool(ui, tool, "premerge", not (binary or symlink))
184 184 except error.ConfigError:
185 185 premerge = _toolstr(ui, tool, "premerge").lower()
186 186 valid = 'keep'.split()
187 187 if premerge not in valid:
188 188 _valid = ', '.join(["'" + v + "'" for v in valid])
189 189 raise error.ConfigError(_("%s.premerge not valid "
190 190 "('%s' is neither boolean nor %s)") %
191 191 (tool, premerge, _valid))
192 192
193 193 if premerge:
194 194 r = simplemerge.simplemerge(ui, a, b, c, quiet=True)
195 195 if not r:
196 196 ui.debug(" premerge successful\n")
197 197 os.unlink(back)
198 198 os.unlink(b)
199 199 os.unlink(c)
200 200 return 0
201 201 if premerge != 'keep':
202 202 util.copyfile(back, a) # restore from backup and try again
203 203
204 204 env = dict(HG_FILE=fd,
205 205 HG_MY_NODE=short(mynode),
206 206 HG_OTHER_NODE=str(fco.changectx()),
207 207 HG_BASE_NODE=str(fca.changectx()),
208 208 HG_MY_ISLINK='l' in fcd.flags(),
209 209 HG_OTHER_ISLINK='l' in fco.flags(),
210 210 HG_BASE_ISLINK='l' in fca.flags())
211 211
212 212 if tool == "internal:merge":
213 213 r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other'])
214 214 elif tool == 'internal:dump':
215 215 a = repo.wjoin(fd)
216 216 util.copyfile(a, a + ".local")
217 217 repo.wwrite(fd + ".other", fco.data(), fco.flags())
218 218 repo.wwrite(fd + ".base", fca.data(), fca.flags())
219 219 return 1 # unresolved
220 220 else:
221 221 args = _toolstr(ui, tool, "args", '$local $base $other')
222 222 if "$output" in args:
223 223 out, a = a, back # read input from backup, write to original
224 224 replace = dict(local=a, base=b, other=c, output=out)
225 225 args = re.sub("\$(local|base|other|output)",
226 226 lambda x: '"%s"' % util.localpath(replace[x.group()[1:]]), args)
227 227 r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env)
228 228
229 229 if not r and (_toolbool(ui, tool, "checkconflicts") or
230 230 'conflicts' in _toollist(ui, tool, "check")):
231 231 if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data()):
232 232 r = 1
233 233
234 if not r and (_toolbool(ui, tool, "checkchanged") or
234 checked = False
235 if 'prompt' in _toollist(ui, tool, "check"):
236 checked = True
237 if ui.promptchoice(_("was merge of '%s' successful (yn)?") % fd,
238 (_("&Yes"), _("&No")), 1):
239 r = 1
240
241 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
235 242 'changed' in _toollist(ui, tool, "check")):
236 243 if filecmp.cmp(repo.wjoin(fd), back):
237 244 if ui.promptchoice(_(" output file %s appears unchanged\n"
238 245 "was merge successful (yn)?") % fd,
239 246 (_("&Yes"), _("&No")), 1):
240 247 r = 1
241 248
242 249 if _toolbool(ui, tool, "fixeol"):
243 250 _matcheol(repo.wjoin(fd), back)
244 251
245 252 if r:
246 253 ui.warn(_("merging %s failed!\n") % fd)
247 254 else:
248 255 os.unlink(back)
249 256
250 257 os.unlink(b)
251 258 os.unlink(c)
252 259 return r
General Comments 0
You need to be logged in to leave comments. Login now