##// END OF EJS Templates
merge: introduce tool.check parameter...
David Champion -
r11148:a912f267 default
parent child Browse files
Show More
@@ -1,1003 +1,1009
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 ``checkconflicts``
467 Check whether there are conflicts even though the tool reported
468 success.
466 ``check``
467 A list of merge success-checking options:
468
469 ``changed``
470 Ask whether merge was successful when the merged file shows no changes.
471 ``conflicts``
472 Check whether there are conflicts even though the tool reported success.
473
474 ``checkchanged``
475 True is equivalent to ``check = changed``.
469 476 Default: False
470 ``checkchanged``
471 Check whether outputs were written even though the tool reported
472 success.
477 ``checkconflicts``
478 True is equivalent to ``check = conflicts``.
473 479 Default: False
474 480 ``fixeol``
475 481 Attempt to fix up EOL changes caused by the merge tool.
476 482 Default: False
477 483 ``gui``
478 484 This tool requires a graphical interface to run. Default: False
479 485 ``regkey``
480 486 Windows registry key which describes install location of this
481 487 tool. Mercurial will search for this key first under
482 488 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
483 489 Default: None
484 490 ``regname``
485 491 Name of value to read from specified registry key. Defaults to the
486 492 unnamed (default) value.
487 493 ``regappend``
488 494 String to append to the value read from the registry, typically
489 495 the executable name of the tool.
490 496 Default: None
491 497
492 498
493 499 ``hooks``
494 500 """""""""
495 501 Commands or Python functions that get automatically executed by
496 502 various actions such as starting or finishing a commit. Multiple
497 503 hooks can be run for the same action by appending a suffix to the
498 504 action. Overriding a site-wide hook can be done by changing its
499 505 value or setting it to an empty string.
500 506
501 507 Example ``.hg/hgrc``::
502 508
503 509 [hooks]
504 510 # update working directory after adding changesets
505 511 changegroup.update = hg update
506 512 # do not use the site-wide hook
507 513 incoming =
508 514 incoming.email = /my/email/hook
509 515 incoming.autobuild = /my/build/hook
510 516
511 517 Most hooks are run with environment variables set that give useful
512 518 additional information. For each hook below, the environment
513 519 variables it is passed are listed with names of the form ``$HG_foo``.
514 520
515 521 ``changegroup``
516 522 Run after a changegroup has been added via push, pull or unbundle.
517 523 ID of the first new changeset is in ``$HG_NODE``. URL from which
518 524 changes came is in ``$HG_URL``.
519 525 ``commit``
520 526 Run after a changeset has been created in the local repository. ID
521 527 of the newly created changeset is in ``$HG_NODE``. Parent changeset
522 528 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
523 529 ``incoming``
524 530 Run after a changeset has been pulled, pushed, or unbundled into
525 531 the local repository. The ID of the newly arrived changeset is in
526 532 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
527 533 ``outgoing``
528 534 Run after sending changes from local repository to another. ID of
529 535 first changeset sent is in ``$HG_NODE``. Source of operation is in
530 536 ``$HG_SOURCE``; see "preoutgoing" hook for description.
531 537 ``post-<command>``
532 538 Run after successful invocations of the associated command. The
533 539 contents of the command line are passed as ``$HG_ARGS`` and the result
534 540 code in ``$HG_RESULT``. Hook failure is ignored.
535 541 ``pre-<command>``
536 542 Run before executing the associated command. The contents of the
537 543 command line are passed as ``$HG_ARGS``. If the hook returns failure,
538 544 the command doesn't execute and Mercurial returns the failure
539 545 code.
540 546 ``prechangegroup``
541 547 Run before a changegroup is added via push, pull or unbundle. Exit
542 548 status 0 allows the changegroup to proceed. Non-zero status will
543 549 cause the push, pull or unbundle to fail. URL from which changes
544 550 will come is in ``$HG_URL``.
545 551 ``precommit``
546 552 Run before starting a local commit. Exit status 0 allows the
547 553 commit to proceed. Non-zero status will cause the commit to fail.
548 554 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
549 555 ``preoutgoing``
550 556 Run before collecting changes to send from the local repository to
551 557 another. Non-zero status will cause failure. This lets you prevent
552 558 pull over HTTP or SSH. Also prevents against local pull, push
553 559 (outbound) or bundle commands, but not effective, since you can
554 560 just copy files instead then. Source of operation is in
555 561 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
556 562 SSH or HTTP repository. If "push", "pull" or "bundle", operation
557 563 is happening on behalf of repository on same system.
558 564 ``pretag``
559 565 Run before creating a tag. Exit status 0 allows the tag to be
560 566 created. Non-zero status will cause the tag to fail. ID of
561 567 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
562 568 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
563 569 ``pretxnchangegroup``
564 570 Run after a changegroup has been added via push, pull or unbundle,
565 571 but before the transaction has been committed. Changegroup is
566 572 visible to hook program. This lets you validate incoming changes
567 573 before accepting them. Passed the ID of the first new changeset in
568 574 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
569 575 status will cause the transaction to be rolled back and the push,
570 576 pull or unbundle will fail. URL that was source of changes is in
571 577 ``$HG_URL``.
572 578 ``pretxncommit``
573 579 Run after a changeset has been created but the transaction not yet
574 580 committed. Changeset is visible to hook program. This lets you
575 581 validate commit message and changes. Exit status 0 allows the
576 582 commit to proceed. Non-zero status will cause the transaction to
577 583 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
578 584 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
579 585 ``preupdate``
580 586 Run before updating the working directory. Exit status 0 allows
581 587 the update to proceed. Non-zero status will prevent the update.
582 588 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
583 589 of second new parent is in ``$HG_PARENT2``.
584 590 ``tag``
585 591 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
586 592 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
587 593 repository if ``$HG_LOCAL=0``.
588 594 ``update``
589 595 Run after updating the working directory. Changeset ID of first
590 596 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
591 597 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
592 598 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
593 599
594 600 .. note:: It is generally better to use standard hooks rather than the
595 601 generic pre- and post- command hooks as they are guaranteed to be
596 602 called in the appropriate contexts for influencing transactions.
597 603 Also, hooks like "commit" will be called in all contexts that
598 604 generate a commit (e.g. tag) and not just the commit command.
599 605
600 606 .. note:: Environment variables with empty values may not be passed to
601 607 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
602 608 will have an empty value under Unix-like platforms for non-merge
603 609 changesets, while it will not be available at all under Windows.
604 610
605 611 The syntax for Python hooks is as follows::
606 612
607 613 hookname = python:modulename.submodule.callable
608 614 hookname = python:/path/to/python/module.py:callable
609 615
610 616 Python hooks are run within the Mercurial process. Each hook is
611 617 called with at least three keyword arguments: a ui object (keyword
612 618 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
613 619 keyword that tells what kind of hook is used. Arguments listed as
614 620 environment variables above are passed as keyword arguments, with no
615 621 ``HG_`` prefix, and names in lower case.
616 622
617 623 If a Python hook returns a "true" value or raises an exception, this
618 624 is treated as a failure.
619 625
620 626
621 627 ``http_proxy``
622 628 """"""""""""""
623 629 Used to access web-based Mercurial repositories through a HTTP
624 630 proxy.
625 631
626 632 ``host``
627 633 Host name and (optional) port of the proxy server, for example
628 634 "myproxy:8000".
629 635 ``no``
630 636 Optional. Comma-separated list of host names that should bypass
631 637 the proxy.
632 638 ``passwd``
633 639 Optional. Password to authenticate with at the proxy server.
634 640 ``user``
635 641 Optional. User name to authenticate with at the proxy server.
636 642 ``always``
637 643 Optional. Always use the proxy, even for localhost and any entries
638 644 in ``http_proxy.no``. True or False. Default: False.
639 645
640 646 ``smtp``
641 647 """"""""
642 648 Configuration for extensions that need to send email messages.
643 649
644 650 ``host``
645 651 Host name of mail server, e.g. "mail.example.com".
646 652 ``port``
647 653 Optional. Port to connect to on mail server. Default: 25.
648 654 ``tls``
649 655 Optional. Whether to connect to mail server using TLS. True or
650 656 False. Default: False.
651 657 ``username``
652 658 Optional. User name to authenticate to SMTP server with. If
653 659 username is specified, password must also be specified.
654 660 Default: none.
655 661 ``password``
656 662 Optional. Password to authenticate to SMTP server with. If
657 663 username is specified, password must also be specified.
658 664 Default: none.
659 665 ``local_hostname``
660 666 Optional. It's the hostname that the sender can use to identify
661 667 itself to the MTA.
662 668
663 669
664 670 ``patch``
665 671 """""""""
666 672 Settings used when applying patches, for instance through the 'import'
667 673 command or with Mercurial Queues extension.
668 674
669 675 ``eol``
670 676 When set to 'strict' patch content and patched files end of lines
671 677 are preserved. When set to ``lf`` or ``crlf``, both files end of
672 678 lines are ignored when patching and the result line endings are
673 679 normalized to either LF (Unix) or CRLF (Windows). When set to
674 680 ``auto``, end of lines are again ignored while patching but line
675 681 endings in patched files are normalized to their original setting
676 682 on a per-file basis. If target file does not exist or has no end
677 683 of line, patch line endings are preserved.
678 684 Default: strict.
679 685
680 686
681 687 ``paths``
682 688 """""""""
683 689 Assigns symbolic names to repositories. The left side is the
684 690 symbolic name, and the right gives the directory or URL that is the
685 691 location of the repository. Default paths can be declared by setting
686 692 the following entries.
687 693
688 694 ``default``
689 695 Directory or URL to use when pulling if no source is specified.
690 696 Default is set to repository from which the current repository was
691 697 cloned.
692 698 ``default-push``
693 699 Optional. Directory or URL to use when pushing if no destination
694 700 is specified.
695 701
696 702
697 703 ``profiling``
698 704 """""""""""""
699 705 Specifies profiling format and file output. In this section
700 706 description, 'profiling data' stands for the raw data collected
701 707 during profiling, while 'profiling report' stands for a statistical
702 708 text report generated from the profiling data. The profiling is done
703 709 using lsprof.
704 710
705 711 ``format``
706 712 Profiling format.
707 713 Default: text.
708 714
709 715 ``text``
710 716 Generate a profiling report. When saving to a file, it should be
711 717 noted that only the report is saved, and the profiling data is
712 718 not kept.
713 719 ``kcachegrind``
714 720 Format profiling data for kcachegrind use: when saving to a
715 721 file, the generated file can directly be loaded into
716 722 kcachegrind.
717 723 ``output``
718 724 File path where profiling data or report should be saved. If the
719 725 file exists, it is replaced. Default: None, data is printed on
720 726 stderr
721 727
722 728 ``server``
723 729 """"""""""
724 730 Controls generic server settings.
725 731
726 732 ``uncompressed``
727 733 Whether to allow clients to clone a repository using the
728 734 uncompressed streaming protocol. This transfers about 40% more
729 735 data than a regular clone, but uses less memory and CPU on both
730 736 server and client. Over a LAN (100 Mbps or better) or a very fast
731 737 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
732 738 regular clone. Over most WAN connections (anything slower than
733 739 about 6 Mbps), uncompressed streaming is slower, because of the
734 740 extra data transfer overhead. This mode will also temporarily hold
735 741 the write lock while determining what data to transfer.
736 742 Default is True.
737 743
738 744 ``validate``
739 745 Whether to validate the completeness of pushed changesets by
740 746 checking that all new file revisions specified in manifests are
741 747 present. Default is False.
742 748
743 749 ``trusted``
744 750 """""""""""
745 751 For security reasons, Mercurial will not use the settings in the
746 752 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
747 753 user or to a trusted group. The main exception is the web interface,
748 754 which automatically uses some safe settings, since it's common to
749 755 serve repositories from different users.
750 756
751 757 This section specifies what users and groups are trusted. The
752 758 current user is always trusted. To trust everybody, list a user or a
753 759 group with name ``*``.
754 760
755 761 ``users``
756 762 Comma-separated list of trusted users.
757 763 ``groups``
758 764 Comma-separated list of trusted groups.
759 765
760 766
761 767 ``ui``
762 768 """"""
763 769
764 770 User interface controls.
765 771
766 772 ``archivemeta``
767 773 Whether to include the .hg_archival.txt file containing meta data
768 774 (hashes for the repository base and for tip) in archives created
769 775 by the :hg:`archive` command or downloaded via hgweb.
770 776 Default is True.
771 777 ``askusername``
772 778 Whether to prompt for a username when committing. If True, and
773 779 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
774 780 be prompted to enter a username. If no username is entered, the
775 781 default ``USER@HOST`` is used instead.
776 782 Default is False.
777 783 ``debug``
778 784 Print debugging information. True or False. Default is False.
779 785 ``editor``
780 786 The editor to use during a commit. Default is ``$EDITOR`` or ``vi``.
781 787 ``fallbackencoding``
782 788 Encoding to try if it's not possible to decode the changelog using
783 789 UTF-8. Default is ISO-8859-1.
784 790 ``ignore``
785 791 A file to read per-user ignore patterns from. This file should be
786 792 in the same format as a repository-wide .hgignore file. This
787 793 option supports hook syntax, so if you want to specify multiple
788 794 ignore files, you can do so by setting something like
789 795 ``ignore.other = ~/.hgignore2``. For details of the ignore file
790 796 format, see the |hgignore(5)|_ man page.
791 797 ``interactive``
792 798 Allow to prompt the user. True or False. Default is True.
793 799 ``logtemplate``
794 800 Template string for commands that print changesets.
795 801 ``merge``
796 802 The conflict resolution program to use during a manual merge.
797 803 There are some internal tools available:
798 804
799 805 ``internal:local``
800 806 keep the local version
801 807 ``internal:other``
802 808 use the other version
803 809 ``internal:merge``
804 810 use the internal non-interactive merge tool
805 811 ``internal:fail``
806 812 fail to merge
807 813
808 814 For more information on configuring merge tools see the
809 815 merge-tools_ section.
810 816
811 817 ``patch``
812 818 command to use to apply patches. Look for ``gpatch`` or ``patch`` in
813 819 PATH if unset.
814 820 ``quiet``
815 821 Reduce the amount of output printed. True or False. Default is False.
816 822 ``remotecmd``
817 823 remote command to use for clone/push/pull operations. Default is ``hg``.
818 824 ``report_untrusted``
819 825 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
820 826 trusted user or group. True or False. Default is True.
821 827 ``slash``
822 828 Display paths using a slash (``/``) as the path separator. This
823 829 only makes a difference on systems where the default path
824 830 separator is not the slash character (e.g. Windows uses the
825 831 backslash character (``\``)).
826 832 Default is False.
827 833 ``ssh``
828 834 command to use for SSH connections. Default is ``ssh``.
829 835 ``strict``
830 836 Require exact command names, instead of allowing unambiguous
831 837 abbreviations. True or False. Default is False.
832 838 ``style``
833 839 Name of style to use for command output.
834 840 ``timeout``
835 841 The timeout used when a lock is held (in seconds), a negative value
836 842 means no timeout. Default is 600.
837 843 ``traceback``
838 844 Mercurial always prints a traceback when an unknown exception
839 845 occurs. Setting this to True will make Mercurial print a traceback
840 846 on all exceptions, even those recognized by Mercurial (such as
841 847 IOError or MemoryError). Default is False.
842 848 ``username``
843 849 The committer of a changeset created when running "commit".
844 850 Typically a person's name and email address, e.g. ``Fred Widget
845 851 <fred@example.com>``. Default is ``$EMAIL`` or ``username@hostname``. If
846 852 the username in hgrc is empty, it has to be specified manually or
847 853 in a different hgrc file (e.g. ``$HOME/.hgrc``, if the admin set
848 854 ``username =`` in the system hgrc).
849 855 ``verbose``
850 856 Increase the amount of output printed. True or False. Default is False.
851 857
852 858
853 859 ``web``
854 860 """""""
855 861 Web interface configuration.
856 862
857 863 ``accesslog``
858 864 Where to output the access log. Default is stdout.
859 865 ``address``
860 866 Interface address to bind to. Default is all.
861 867 ``allow_archive``
862 868 List of archive format (bz2, gz, zip) allowed for downloading.
863 869 Default is empty.
864 870 ``allowbz2``
865 871 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
866 872 revisions.
867 873 Default is False.
868 874 ``allowgz``
869 875 (DEPRECATED) Whether to allow .tar.gz downloading of repository
870 876 revisions.
871 877 Default is False.
872 878 ``allowpull``
873 879 Whether to allow pulling from the repository. Default is True.
874 880 ``allow_push``
875 881 Whether to allow pushing to the repository. If empty or not set,
876 882 push is not allowed. If the special value ``*``, any remote user can
877 883 push, including unauthenticated users. Otherwise, the remote user
878 884 must have been authenticated, and the authenticated user name must
879 885 be present in this list. The contents of the allow_push list are
880 886 examined after the deny_push list.
881 887 ``allow_read``
882 888 If the user has not already been denied repository access due to
883 889 the contents of deny_read, this list determines whether to grant
884 890 repository access to the user. If this list is not empty, and the
885 891 user is unauthenticated or not present in the list, then access is
886 892 denied for the user. If the list is empty or not set, then access
887 893 is permitted to all users by default. Setting allow_read to the
888 894 special value ``*`` is equivalent to it not being set (i.e. access
889 895 is permitted to all users). The contents of the allow_read list are
890 896 examined after the deny_read list.
891 897 ``allowzip``
892 898 (DEPRECATED) Whether to allow .zip downloading of repository
893 899 revisions. Default is False. This feature creates temporary files.
894 900 ``baseurl``
895 901 Base URL to use when publishing URLs in other locations, so
896 902 third-party tools like email notification hooks can construct
897 903 URLs. Example: ``http://hgserver/repos/``.
898 904 ``cacerts``
899 905 Path to file containing a list of PEM encoded certificate authorities
900 906 that may be used to verify an SSL server's identity. The form must be
901 907 as follows::
902 908
903 909 -----BEGIN CERTIFICATE-----
904 910 ... (certificate in base64 PEM encoding) ...
905 911 -----END CERTIFICATE-----
906 912 -----BEGIN CERTIFICATE-----
907 913 ... (certificate in base64 PEM encoding) ...
908 914 -----END CERTIFICATE-----
909 915
910 916 This feature is only supported when using Python 2.6. If you wish to
911 917 use it with earlier versions of Python, install the backported
912 918 version of the ssl library that is available from
913 919 ``http://pypi.python.org``.
914 920
915 921 You can use OpenSSL's CA certificate file if your platform has one.
916 922 On most Linux systems this will be ``/etc/ssl/certs/ca-certificates.crt``.
917 923 Otherwise you will have to generate this file manually.
918 924 ``contact``
919 925 Name or email address of the person in charge of the repository.
920 926 Defaults to ui.username or ``$EMAIL`` or "unknown" if unset or empty.
921 927 ``deny_push``
922 928 Whether to deny pushing to the repository. If empty or not set,
923 929 push is not denied. If the special value ``*``, all remote users are
924 930 denied push. Otherwise, unauthenticated users are all denied, and
925 931 any authenticated user name present in this list is also denied. The
926 932 contents of the deny_push list are examined before the allow_push list.
927 933 ``deny_read``
928 934 Whether to deny reading/viewing of the repository. If this list is
929 935 not empty, unauthenticated users are all denied, and any
930 936 authenticated user name present in this list is also denied access to
931 937 the repository. If set to the special value ``*``, all remote users
932 938 are denied access (rarely needed ;). If deny_read is empty or not set,
933 939 the determination of repository access depends on the presence and
934 940 content of the allow_read list (see description). If both
935 941 deny_read and allow_read are empty or not set, then access is
936 942 permitted to all users by default. If the repository is being
937 943 served via hgwebdir, denied users will not be able to see it in
938 944 the list of repositories. The contents of the deny_read list have
939 945 priority over (are examined before) the contents of the allow_read
940 946 list.
941 947 ``descend``
942 948 hgwebdir indexes will not descend into subdirectories. Only repositories
943 949 directly in the current path will be shown (other repositories are still
944 950 available from the index corresponding to their containing path).
945 951 ``description``
946 952 Textual description of the repository's purpose or contents.
947 953 Default is "unknown".
948 954 ``encoding``
949 955 Character encoding name. Default is the current locale charset.
950 956 Example: "UTF-8"
951 957 ``errorlog``
952 958 Where to output the error log. Default is stderr.
953 959 ``hidden``
954 960 Whether to hide the repository in the hgwebdir index.
955 961 Default is False.
956 962 ``ipv6``
957 963 Whether to use IPv6. Default is False.
958 964 ``name``
959 965 Repository name to use in the web interface. Default is current
960 966 working directory.
961 967 ``maxchanges``
962 968 Maximum number of changes to list on the changelog. Default is 10.
963 969 ``maxfiles``
964 970 Maximum number of files to list per changeset. Default is 10.
965 971 ``port``
966 972 Port to listen on. Default is 8000.
967 973 ``prefix``
968 974 Prefix path to serve from. Default is '' (server root).
969 975 ``push_ssl``
970 976 Whether to require that inbound pushes be transported over SSL to
971 977 prevent password sniffing. Default is True.
972 978 ``staticurl``
973 979 Base URL to use for static files. If unset, static files (e.g. the
974 980 hgicon.png favicon) will be served by the CGI script itself. Use
975 981 this setting to serve them directly with the HTTP server.
976 982 Example: ``http://hgserver/static/``.
977 983 ``stripes``
978 984 How many lines a "zebra stripe" should span in multiline output.
979 985 Default is 1; set to 0 to disable.
980 986 ``style``
981 987 Which template map style to use.
982 988 ``templates``
983 989 Where to find the HTML templates. Default is install path.
984 990
985 991
986 992 Author
987 993 ------
988 994 Bryan O'Sullivan <bos@serpentine.com>.
989 995
990 996 Mercurial was written by Matt Mackall <mpm@selenic.com>.
991 997
992 998 See Also
993 999 --------
994 1000 |hg(1)|_, |hgignore(5)|_
995 1001
996 1002 Copying
997 1003 -------
998 1004 This manual page is copyright 2005 Bryan O'Sullivan.
999 1005 Mercurial is copyright 2005-2010 Matt Mackall.
1000 1006 Free use of this software is granted under the terms of the GNU General
1001 1007 Public License version 2 or any later version.
1002 1008
1003 1009 .. include:: common.txt
@@ -1,247 +1,252
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 def _toollist(ui, tool, part, default=[]):
20 return ui.configlist("merge-tools", tool + "." + part, default)
21
19 22 _internal = ['internal:' + s
20 23 for s in 'fail local other merge prompt dump'.split()]
21 24
22 25 def _findtool(ui, tool):
23 26 if tool in _internal:
24 27 return tool
25 28 k = _toolstr(ui, tool, "regkey")
26 29 if k:
27 30 p = util.lookup_reg(k, _toolstr(ui, tool, "regname"))
28 31 if p:
29 32 p = util.find_exe(p + _toolstr(ui, tool, "regappend"))
30 33 if p:
31 34 return p
32 35 return util.find_exe(_toolstr(ui, tool, "executable", tool))
33 36
34 37 def _picktool(repo, ui, path, binary, symlink):
35 38 def check(tool, pat, symlink, binary):
36 39 tmsg = tool
37 40 if pat:
38 41 tmsg += " specified for " + pat
39 42 if not _findtool(ui, tool):
40 43 if pat: # explicitly requested tool deserves a warning
41 44 ui.warn(_("couldn't find merge tool %s\n") % tmsg)
42 45 else: # configured but non-existing tools are more silent
43 46 ui.note(_("couldn't find merge tool %s\n") % tmsg)
44 47 elif symlink and not _toolbool(ui, tool, "symlink"):
45 48 ui.warn(_("tool %s can't handle symlinks\n") % tmsg)
46 49 elif binary and not _toolbool(ui, tool, "binary"):
47 50 ui.warn(_("tool %s can't handle binary\n") % tmsg)
48 51 elif not util.gui() and _toolbool(ui, tool, "gui"):
49 52 ui.warn(_("tool %s requires a GUI\n") % tmsg)
50 53 else:
51 54 return True
52 55 return False
53 56
54 57 # HGMERGE takes precedence
55 58 hgmerge = os.environ.get("HGMERGE")
56 59 if hgmerge:
57 60 return (hgmerge, hgmerge)
58 61
59 62 # then patterns
60 63 for pat, tool in ui.configitems("merge-patterns"):
61 64 mf = match.match(repo.root, '', [pat])
62 65 if mf(path) and check(tool, pat, symlink, False):
63 66 toolpath = _findtool(ui, tool)
64 67 return (tool, '"' + toolpath + '"')
65 68
66 69 # then merge tools
67 70 tools = {}
68 71 for k, v in ui.configitems("merge-tools"):
69 72 t = k.split('.')[0]
70 73 if t not in tools:
71 74 tools[t] = int(_toolstr(ui, t, "priority", "0"))
72 75 names = tools.keys()
73 76 tools = sorted([(-p, t) for t, p in tools.items()])
74 77 uimerge = ui.config("ui", "merge")
75 78 if uimerge:
76 79 if uimerge not in names:
77 80 return (uimerge, uimerge)
78 81 tools.insert(0, (None, uimerge)) # highest priority
79 82 tools.append((None, "hgmerge")) # the old default, if found
80 83 for p, t in tools:
81 84 if check(t, None, symlink, binary):
82 85 toolpath = _findtool(ui, t)
83 86 return (t, '"' + toolpath + '"')
84 87 # internal merge as last resort
85 88 return (not (symlink or binary) and "internal:merge" or None, None)
86 89
87 90 def _eoltype(data):
88 91 "Guess the EOL type of a file"
89 92 if '\0' in data: # binary
90 93 return None
91 94 if '\r\n' in data: # Windows
92 95 return '\r\n'
93 96 if '\r' in data: # Old Mac
94 97 return '\r'
95 98 if '\n' in data: # UNIX
96 99 return '\n'
97 100 return None # unknown
98 101
99 102 def _matcheol(file, origfile):
100 103 "Convert EOL markers in a file to match origfile"
101 104 tostyle = _eoltype(open(origfile, "rb").read())
102 105 if tostyle:
103 106 data = open(file, "rb").read()
104 107 style = _eoltype(data)
105 108 if style:
106 109 newdata = data.replace(style, tostyle)
107 110 if newdata != data:
108 111 open(file, "wb").write(newdata)
109 112
110 113 def filemerge(repo, mynode, orig, fcd, fco, fca):
111 114 """perform a 3-way merge in the working directory
112 115
113 116 mynode = parent node before merge
114 117 orig = original local filename before merge
115 118 fco = other file context
116 119 fca = ancestor file context
117 120 fcd = local file context for current/destination file
118 121 """
119 122
120 123 def temp(prefix, ctx):
121 124 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
122 125 (fd, name) = tempfile.mkstemp(prefix=pre)
123 126 data = repo.wwritedata(ctx.path(), ctx.data())
124 127 f = os.fdopen(fd, "wb")
125 128 f.write(data)
126 129 f.close()
127 130 return name
128 131
129 132 def isbin(ctx):
130 133 try:
131 134 return util.binary(ctx.data())
132 135 except IOError:
133 136 return False
134 137
135 138 if not fco.cmp(fcd.data()): # files identical?
136 139 return None
137 140
138 141 if fca == fco: # backwards, use working dir parent as ancestor
139 142 fca = fcd.parents()[0]
140 143
141 144 ui = repo.ui
142 145 fd = fcd.path()
143 146 binary = isbin(fcd) or isbin(fco) or isbin(fca)
144 147 symlink = 'l' in fcd.flags() + fco.flags()
145 148 tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
146 149 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
147 150 (tool, fd, binary, symlink))
148 151
149 152 if not tool or tool == 'internal:prompt':
150 153 tool = "internal:local"
151 154 if ui.promptchoice(_(" no tool found to merge %s\n"
152 155 "keep (l)ocal or take (o)ther?") % fd,
153 156 (_("&Local"), _("&Other")), 0):
154 157 tool = "internal:other"
155 158 if tool == "internal:local":
156 159 return 0
157 160 if tool == "internal:other":
158 161 repo.wwrite(fd, fco.data(), fco.flags())
159 162 return 0
160 163 if tool == "internal:fail":
161 164 return 1
162 165
163 166 # do the actual merge
164 167 a = repo.wjoin(fd)
165 168 b = temp("base", fca)
166 169 c = temp("other", fco)
167 170 out = ""
168 171 back = a + ".orig"
169 172 util.copyfile(a, back)
170 173
171 174 if orig != fco.path():
172 175 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
173 176 else:
174 177 ui.status(_("merging %s\n") % fd)
175 178
176 179 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
177 180
178 181 # do we attempt to simplemerge first?
179 182 try:
180 183 premerge = _toolbool(ui, tool, "premerge", not (binary or symlink))
181 184 except error.ConfigError:
182 185 premerge = _toolstr(ui, tool, "premerge").lower()
183 186 valid = 'keep'.split()
184 187 if premerge not in valid:
185 188 _valid = ', '.join(["'" + v + "'" for v in valid])
186 189 raise error.ConfigError(_("%s.premerge not valid "
187 190 "('%s' is neither boolean nor %s)") %
188 191 (tool, premerge, _valid))
189 192
190 193 if premerge:
191 194 r = simplemerge.simplemerge(ui, a, b, c, quiet=True)
192 195 if not r:
193 196 ui.debug(" premerge successful\n")
194 197 os.unlink(back)
195 198 os.unlink(b)
196 199 os.unlink(c)
197 200 return 0
198 201 if premerge != 'keep':
199 202 util.copyfile(back, a) # restore from backup and try again
200 203
201 204 env = dict(HG_FILE=fd,
202 205 HG_MY_NODE=short(mynode),
203 206 HG_OTHER_NODE=str(fco.changectx()),
204 207 HG_BASE_NODE=str(fca.changectx()),
205 208 HG_MY_ISLINK='l' in fcd.flags(),
206 209 HG_OTHER_ISLINK='l' in fco.flags(),
207 210 HG_BASE_ISLINK='l' in fca.flags())
208 211
209 212 if tool == "internal:merge":
210 213 r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other'])
211 214 elif tool == 'internal:dump':
212 215 a = repo.wjoin(fd)
213 216 util.copyfile(a, a + ".local")
214 217 repo.wwrite(fd + ".other", fco.data(), fco.flags())
215 218 repo.wwrite(fd + ".base", fca.data(), fca.flags())
216 219 return 1 # unresolved
217 220 else:
218 221 args = _toolstr(ui, tool, "args", '$local $base $other')
219 222 if "$output" in args:
220 223 out, a = a, back # read input from backup, write to original
221 224 replace = dict(local=a, base=b, other=c, output=out)
222 225 args = re.sub("\$(local|base|other|output)",
223 226 lambda x: '"%s"' % util.localpath(replace[x.group()[1:]]), args)
224 227 r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env)
225 228
226 if not r and _toolbool(ui, tool, "checkconflicts"):
229 if not r and (_toolbool(ui, tool, "checkconflicts") or
230 'conflicts' in _toollist(ui, tool, "check")):
227 231 if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data()):
228 232 r = 1
229 233
230 if not r and _toolbool(ui, tool, "checkchanged"):
234 if not r and (_toolbool(ui, tool, "checkchanged") or
235 'changed' in _toollist(ui, tool, "check")):
231 236 if filecmp.cmp(repo.wjoin(fd), back):
232 237 if ui.promptchoice(_(" output file %s appears unchanged\n"
233 238 "was merge successful (yn)?") % fd,
234 239 (_("&Yes"), _("&No")), 1):
235 240 r = 1
236 241
237 242 if _toolbool(ui, tool, "fixeol"):
238 243 _matcheol(repo.wjoin(fd), back)
239 244
240 245 if r:
241 246 ui.warn(_("merging %s failed!\n") % fd)
242 247 else:
243 248 os.unlink(back)
244 249
245 250 os.unlink(b)
246 251 os.unlink(c)
247 252 return r
General Comments 0
You need to be logged in to leave comments. Login now