##// END OF EJS Templates
merge: add options to warn or ignore on colliding unknown files...
Siddharth Agarwal -
r27657:7b5c8c8a default
parent child Browse files
Show More
@@ -1,1935 +1,1948 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 Troubleshooting
5 5 ===============
6 6
7 7 If you're having problems with your configuration,
8 8 :hg:`config --debug` can help you understand what is introducing
9 9 a setting into your environment.
10 10
11 11 See :hg:`help config.syntax` and :hg:`help config.files`
12 12 for information about how and where to override things.
13 13
14 14 Structure
15 15 =========
16 16
17 17 The configuration files use a simple ini-file format. A configuration
18 18 file consists of sections, led by a ``[section]`` header and followed
19 19 by ``name = value`` entries::
20 20
21 21 [ui]
22 22 username = Firstname Lastname <firstname.lastname@example.net>
23 23 verbose = True
24 24
25 25 The above entries will be referred to as ``ui.username`` and
26 26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27 27
28 28 Files
29 29 =====
30 30
31 31 Mercurial reads configuration data from several files, if they exist.
32 32 These files do not exist by default and you will have to create the
33 33 appropriate configuration files yourself: global configuration like
34 34 the username setting is typically put into
35 35 ``%USERPROFILE%\mercurial.ini`` or ``$HOME/.hgrc`` and local
36 36 configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
37 37
38 38 The names of these files depend on the system on which Mercurial is
39 39 installed. ``*.rc`` files from a single directory are read in
40 40 alphabetical order, later ones overriding earlier ones. Where multiple
41 41 paths are given below, settings from earlier paths override later
42 42 ones.
43 43
44 44 .. container:: verbose.unix
45 45
46 46 On Unix, the following files are consulted:
47 47
48 48 - ``<repo>/.hg/hgrc`` (per-repository)
49 49 - ``$HOME/.hgrc`` (per-user)
50 50 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
51 51 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
52 52 - ``/etc/mercurial/hgrc`` (per-system)
53 53 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
54 54 - ``<internal>/default.d/*.rc`` (defaults)
55 55
56 56 .. container:: verbose.windows
57 57
58 58 On Windows, the following files are consulted:
59 59
60 60 - ``<repo>/.hg/hgrc`` (per-repository)
61 61 - ``%USERPROFILE%\.hgrc`` (per-user)
62 62 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
63 63 - ``%HOME%\.hgrc`` (per-user)
64 64 - ``%HOME%\Mercurial.ini`` (per-user)
65 65 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
66 66 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
67 67 - ``<install-dir>\Mercurial.ini`` (per-installation)
68 68 - ``<internal>/default.d/*.rc`` (defaults)
69 69
70 70 .. note::
71 71
72 72 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
73 73 is used when running 32-bit Python on 64-bit Windows.
74 74
75 75 .. container:: verbose.plan9
76 76
77 77 On Plan9, the following files are consulted:
78 78
79 79 - ``<repo>/.hg/hgrc`` (per-repository)
80 80 - ``$home/lib/hgrc`` (per-user)
81 81 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
82 82 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
83 83 - ``/lib/mercurial/hgrc`` (per-system)
84 84 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
85 85 - ``<internal>/default.d/*.rc`` (defaults)
86 86
87 87 Per-repository configuration options only apply in a
88 88 particular repository. This file is not version-controlled, and
89 89 will not get transferred during a "clone" operation. Options in
90 90 this file override options in all other configuration files. On
91 91 Plan 9 and Unix, most of this file will be ignored if it doesn't
92 92 belong to a trusted user or to a trusted group. See
93 93 :hg:`help config.trusted` for more details.
94 94
95 95 Per-user configuration file(s) are for the user running Mercurial. On
96 96 Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``. Options in these
97 97 files apply to all Mercurial commands executed by this user in any
98 98 directory. Options in these files override per-system and per-installation
99 99 options.
100 100
101 101 Per-installation configuration files are searched for in the
102 102 directory where Mercurial is installed. ``<install-root>`` is the
103 103 parent directory of the **hg** executable (or symlink) being run. For
104 104 example, if installed in ``/shared/tools/bin/hg``, Mercurial will look
105 105 in ``/shared/tools/etc/mercurial/hgrc``. Options in these files apply
106 106 to all Mercurial commands executed by any user in any directory.
107 107
108 108 Per-installation configuration files are for the system on
109 109 which Mercurial is running. Options in these files apply to all
110 110 Mercurial commands executed by any user in any directory. Registry
111 111 keys contain PATH-like strings, every part of which must reference
112 112 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
113 113 be read. Mercurial checks each of these locations in the specified
114 114 order until one or more configuration files are detected.
115 115
116 116 Per-system configuration files are for the system on which Mercurial
117 117 is running. Options in these files apply to all Mercurial commands
118 118 executed by any user in any directory. Options in these files
119 119 override per-installation options.
120 120
121 121 Mercurial comes with some default configuration. The default configuration
122 122 files are installed with Mercurial and will be overwritten on upgrades. Default
123 123 configuration files should never be edited by users or administrators but can
124 124 be overridden in other configuration files. So far the directory only contains
125 125 merge tool configuration but packagers can also put other default configuration
126 126 there.
127 127
128 128 Syntax
129 129 ======
130 130
131 131 A configuration file consists of sections, led by a ``[section]`` header
132 132 and followed by ``name = value`` entries (sometimes called
133 133 ``configuration keys``)::
134 134
135 135 [spam]
136 136 eggs=ham
137 137 green=
138 138 eggs
139 139
140 140 Each line contains one entry. If the lines that follow are indented,
141 141 they are treated as continuations of that entry. Leading whitespace is
142 142 removed from values. Empty lines are skipped. Lines beginning with
143 143 ``#`` or ``;`` are ignored and may be used to provide comments.
144 144
145 145 Configuration keys can be set multiple times, in which case Mercurial
146 146 will use the value that was configured last. As an example::
147 147
148 148 [spam]
149 149 eggs=large
150 150 ham=serrano
151 151 eggs=small
152 152
153 153 This would set the configuration key named ``eggs`` to ``small``.
154 154
155 155 It is also possible to define a section multiple times. A section can
156 156 be redefined on the same and/or on different configuration files. For
157 157 example::
158 158
159 159 [foo]
160 160 eggs=large
161 161 ham=serrano
162 162 eggs=small
163 163
164 164 [bar]
165 165 eggs=ham
166 166 green=
167 167 eggs
168 168
169 169 [foo]
170 170 ham=prosciutto
171 171 eggs=medium
172 172 bread=toasted
173 173
174 174 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
175 175 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
176 176 respectively. As you can see there only thing that matters is the last
177 177 value that was set for each of the configuration keys.
178 178
179 179 If a configuration key is set multiple times in different
180 180 configuration files the final value will depend on the order in which
181 181 the different configuration files are read, with settings from earlier
182 182 paths overriding later ones as described on the ``Files`` section
183 183 above.
184 184
185 185 A line of the form ``%include file`` will include ``file`` into the
186 186 current configuration file. The inclusion is recursive, which means
187 187 that included files can include other files. Filenames are relative to
188 188 the configuration file in which the ``%include`` directive is found.
189 189 Environment variables and ``~user`` constructs are expanded in
190 190 ``file``. This lets you do something like::
191 191
192 192 %include ~/.hgrc.d/$HOST.rc
193 193
194 194 to include a different configuration file on each computer you use.
195 195
196 196 A line with ``%unset name`` will remove ``name`` from the current
197 197 section, if it has been set previously.
198 198
199 199 The values are either free-form text strings, lists of text strings,
200 200 or Boolean values. Boolean values can be set to true using any of "1",
201 201 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
202 202 (all case insensitive).
203 203
204 204 List values are separated by whitespace or comma, except when values are
205 205 placed in double quotation marks::
206 206
207 207 allow_read = "John Doe, PhD", brian, betty
208 208
209 209 Quotation marks can be escaped by prefixing them with a backslash. Only
210 210 quotation marks at the beginning of a word is counted as a quotation
211 211 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
212 212
213 213 Sections
214 214 ========
215 215
216 216 This section describes the different sections that may appear in a
217 217 Mercurial configuration file, the purpose of each section, its possible
218 218 keys, and their possible values.
219 219
220 220 ``alias``
221 221 ---------
222 222
223 223 Defines command aliases.
224 224
225 225 Aliases allow you to define your own commands in terms of other
226 226 commands (or aliases), optionally including arguments. Positional
227 227 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
228 228 are expanded by Mercurial before execution. Positional arguments not
229 229 already used by ``$N`` in the definition are put at the end of the
230 230 command to be executed.
231 231
232 232 Alias definitions consist of lines of the form::
233 233
234 234 <alias> = <command> [<argument>]...
235 235
236 236 For example, this definition::
237 237
238 238 latest = log --limit 5
239 239
240 240 creates a new command ``latest`` that shows only the five most recent
241 241 changesets. You can define subsequent aliases using earlier ones::
242 242
243 243 stable5 = latest -b stable
244 244
245 245 .. note::
246 246
247 247 It is possible to create aliases with the same names as
248 248 existing commands, which will then override the original
249 249 definitions. This is almost always a bad idea!
250 250
251 251 An alias can start with an exclamation point (``!``) to make it a
252 252 shell alias. A shell alias is executed with the shell and will let you
253 253 run arbitrary commands. As an example, ::
254 254
255 255 echo = !echo $@
256 256
257 257 will let you do ``hg echo foo`` to have ``foo`` printed in your
258 258 terminal. A better example might be::
259 259
260 260 purge = !$HG status --no-status --unknown -0 | xargs -0 rm
261 261
262 262 which will make ``hg purge`` delete all unknown files in the
263 263 repository in the same manner as the purge extension.
264 264
265 265 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
266 266 expand to the command arguments. Unmatched arguments are
267 267 removed. ``$0`` expands to the alias name and ``$@`` expands to all
268 268 arguments separated by a space. ``"$@"`` (with quotes) expands to all
269 269 arguments quoted individually and separated by a space. These expansions
270 270 happen before the command is passed to the shell.
271 271
272 272 Shell aliases are executed in an environment where ``$HG`` expands to
273 273 the path of the Mercurial that was used to execute the alias. This is
274 274 useful when you want to call further Mercurial commands in a shell
275 275 alias, as was done above for the purge alias. In addition,
276 276 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
277 277 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
278 278
279 279 .. note::
280 280
281 281 Some global configuration options such as ``-R`` are
282 282 processed before shell aliases and will thus not be passed to
283 283 aliases.
284 284
285 285
286 286 ``annotate``
287 287 ------------
288 288
289 289 Settings used when displaying file annotations. All values are
290 290 Booleans and default to False. See :hg:`help config.diff` for
291 291 related options for the diff command.
292 292
293 293 ``ignorews``
294 294 Ignore white space when comparing lines.
295 295
296 296 ``ignorewsamount``
297 297 Ignore changes in the amount of white space.
298 298
299 299 ``ignoreblanklines``
300 300 Ignore changes whose lines are all blank.
301 301
302 302
303 303 ``auth``
304 304 --------
305 305
306 306 Authentication credentials for HTTP authentication. This section
307 307 allows you to store usernames and passwords for use when logging
308 308 *into* HTTP servers. See :hg:`help config.web` if
309 309 you want to configure *who* can login to your HTTP server.
310 310
311 311 Each line has the following format::
312 312
313 313 <name>.<argument> = <value>
314 314
315 315 where ``<name>`` is used to group arguments into authentication
316 316 entries. Example::
317 317
318 318 foo.prefix = hg.intevation.org/mercurial
319 319 foo.username = foo
320 320 foo.password = bar
321 321 foo.schemes = http https
322 322
323 323 bar.prefix = secure.example.org
324 324 bar.key = path/to/file.key
325 325 bar.cert = path/to/file.cert
326 326 bar.schemes = https
327 327
328 328 Supported arguments:
329 329
330 330 ``prefix``
331 331 Either ``*`` or a URI prefix with or without the scheme part.
332 332 The authentication entry with the longest matching prefix is used
333 333 (where ``*`` matches everything and counts as a match of length
334 334 1). If the prefix doesn't include a scheme, the match is performed
335 335 against the URI with its scheme stripped as well, and the schemes
336 336 argument, q.v., is then subsequently consulted.
337 337
338 338 ``username``
339 339 Optional. Username to authenticate with. If not given, and the
340 340 remote site requires basic or digest authentication, the user will
341 341 be prompted for it. Environment variables are expanded in the
342 342 username letting you do ``foo.username = $USER``. If the URI
343 343 includes a username, only ``[auth]`` entries with a matching
344 344 username or without a username will be considered.
345 345
346 346 ``password``
347 347 Optional. Password to authenticate with. If not given, and the
348 348 remote site requires basic or digest authentication, the user
349 349 will be prompted for it.
350 350
351 351 ``key``
352 352 Optional. PEM encoded client certificate key file. Environment
353 353 variables are expanded in the filename.
354 354
355 355 ``cert``
356 356 Optional. PEM encoded client certificate chain file. Environment
357 357 variables are expanded in the filename.
358 358
359 359 ``schemes``
360 360 Optional. Space separated list of URI schemes to use this
361 361 authentication entry with. Only used if the prefix doesn't include
362 362 a scheme. Supported schemes are http and https. They will match
363 363 static-http and static-https respectively, as well.
364 364 (default: https)
365 365
366 366 If no suitable authentication entry is found, the user is prompted
367 367 for credentials as usual if required by the remote.
368 368
369 369
370 370 ``committemplate``
371 371 ------------------
372 372
373 373 ``changeset``
374 374 String: configuration in this section is used as the template to
375 375 customize the text shown in the editor when committing.
376 376
377 377 In addition to pre-defined template keywords, commit log specific one
378 378 below can be used for customization:
379 379
380 380 ``extramsg``
381 381 String: Extra message (typically 'Leave message empty to abort
382 382 commit.'). This may be changed by some commands or extensions.
383 383
384 384 For example, the template configuration below shows as same text as
385 385 one shown by default::
386 386
387 387 [committemplate]
388 388 changeset = {desc}\n\n
389 389 HG: Enter commit message. Lines beginning with 'HG:' are removed.
390 390 HG: {extramsg}
391 391 HG: --
392 392 HG: user: {author}\n{ifeq(p2rev, "-1", "",
393 393 "HG: branch merge\n")
394 394 }HG: branch '{branch}'\n{if(activebookmark,
395 395 "HG: bookmark '{activebookmark}'\n") }{subrepos %
396 396 "HG: subrepo {subrepo}\n" }{file_adds %
397 397 "HG: added {file}\n" }{file_mods %
398 398 "HG: changed {file}\n" }{file_dels %
399 399 "HG: removed {file}\n" }{if(files, "",
400 400 "HG: no files changed\n")}
401 401
402 402 .. note::
403 403
404 404 For some problematic encodings (see :hg:`help win32mbcs` for
405 405 detail), this customization should be configured carefully, to
406 406 avoid showing broken characters.
407 407
408 408 For example, if a multibyte character ending with backslash (0x5c) is
409 409 followed by the ASCII character 'n' in the customized template,
410 410 the sequence of backslash and 'n' is treated as line-feed unexpectedly
411 411 (and the multibyte character is broken, too).
412 412
413 413 Customized template is used for commands below (``--edit`` may be
414 414 required):
415 415
416 416 - :hg:`backout`
417 417 - :hg:`commit`
418 418 - :hg:`fetch` (for merge commit only)
419 419 - :hg:`graft`
420 420 - :hg:`histedit`
421 421 - :hg:`import`
422 422 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
423 423 - :hg:`rebase`
424 424 - :hg:`shelve`
425 425 - :hg:`sign`
426 426 - :hg:`tag`
427 427 - :hg:`transplant`
428 428
429 429 Configuring items below instead of ``changeset`` allows showing
430 430 customized message only for specific actions, or showing different
431 431 messages for each action.
432 432
433 433 - ``changeset.backout`` for :hg:`backout`
434 434 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
435 435 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
436 436 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
437 437 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
438 438 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
439 439 - ``changeset.gpg.sign`` for :hg:`sign`
440 440 - ``changeset.graft`` for :hg:`graft`
441 441 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
442 442 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
443 443 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
444 444 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
445 445 - ``changeset.import.bypass`` for :hg:`import --bypass`
446 446 - ``changeset.import.normal.merge`` for :hg:`import` on merges
447 447 - ``changeset.import.normal.normal`` for :hg:`import` on other
448 448 - ``changeset.mq.qnew`` for :hg:`qnew`
449 449 - ``changeset.mq.qfold`` for :hg:`qfold`
450 450 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
451 451 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
452 452 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
453 453 - ``changeset.rebase.normal`` for :hg:`rebase` on other
454 454 - ``changeset.shelve.shelve`` for :hg:`shelve`
455 455 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
456 456 - ``changeset.tag.remove`` for :hg:`tag --remove`
457 457 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
458 458 - ``changeset.transplant.normal`` for :hg:`transplant` on other
459 459
460 460 These dot-separated lists of names are treated as hierarchical ones.
461 461 For example, ``changeset.tag.remove`` customizes the commit message
462 462 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
463 463 commit message for :hg:`tag` regardless of ``--remove`` option.
464 464
465 465 When the external editor is invoked for a commit, the corresponding
466 466 dot-separated list of names without the ``changeset.`` prefix
467 467 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
468 468 variable.
469 469
470 470 In this section, items other than ``changeset`` can be referred from
471 471 others. For example, the configuration to list committed files up
472 472 below can be referred as ``{listupfiles}``::
473 473
474 474 [committemplate]
475 475 listupfiles = {file_adds %
476 476 "HG: added {file}\n" }{file_mods %
477 477 "HG: changed {file}\n" }{file_dels %
478 478 "HG: removed {file}\n" }{if(files, "",
479 479 "HG: no files changed\n")}
480 480
481 481 ``decode/encode``
482 482 -----------------
483 483
484 484 Filters for transforming files on checkout/checkin. This would
485 485 typically be used for newline processing or other
486 486 localization/canonicalization of files.
487 487
488 488 Filters consist of a filter pattern followed by a filter command.
489 489 Filter patterns are globs by default, rooted at the repository root.
490 490 For example, to match any file ending in ``.txt`` in the root
491 491 directory only, use the pattern ``*.txt``. To match any file ending
492 492 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
493 493 For each file only the first matching filter applies.
494 494
495 495 The filter command can start with a specifier, either ``pipe:`` or
496 496 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
497 497
498 498 A ``pipe:`` command must accept data on stdin and return the transformed
499 499 data on stdout.
500 500
501 501 Pipe example::
502 502
503 503 [encode]
504 504 # uncompress gzip files on checkin to improve delta compression
505 505 # note: not necessarily a good idea, just an example
506 506 *.gz = pipe: gunzip
507 507
508 508 [decode]
509 509 # recompress gzip files when writing them to the working dir (we
510 510 # can safely omit "pipe:", because it's the default)
511 511 *.gz = gzip
512 512
513 513 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
514 514 with the name of a temporary file that contains the data to be
515 515 filtered by the command. The string ``OUTFILE`` is replaced with the name
516 516 of an empty temporary file, where the filtered data must be written by
517 517 the command.
518 518
519 519 .. note::
520 520
521 521 The tempfile mechanism is recommended for Windows systems,
522 522 where the standard shell I/O redirection operators often have
523 523 strange effects and may corrupt the contents of your files.
524 524
525 525 This filter mechanism is used internally by the ``eol`` extension to
526 526 translate line ending characters between Windows (CRLF) and Unix (LF)
527 527 format. We suggest you use the ``eol`` extension for convenience.
528 528
529 529
530 530 ``defaults``
531 531 ------------
532 532
533 533 (defaults are deprecated. Don't use them. Use aliases instead.)
534 534
535 535 Use the ``[defaults]`` section to define command defaults, i.e. the
536 536 default options/arguments to pass to the specified commands.
537 537
538 538 The following example makes :hg:`log` run in verbose mode, and
539 539 :hg:`status` show only the modified files, by default::
540 540
541 541 [defaults]
542 542 log = -v
543 543 status = -m
544 544
545 545 The actual commands, instead of their aliases, must be used when
546 546 defining command defaults. The command defaults will also be applied
547 547 to the aliases of the commands defined.
548 548
549 549
550 550 ``diff``
551 551 --------
552 552
553 553 Settings used when displaying diffs. Everything except for ``unified``
554 554 is a Boolean and defaults to False. See :hg:`help config.annotate`
555 555 for related options for the annotate command.
556 556
557 557 ``git``
558 558 Use git extended diff format.
559 559
560 560 ``nobinary``
561 561 Omit git binary patches.
562 562
563 563 ``nodates``
564 564 Don't include dates in diff headers.
565 565
566 566 ``noprefix``
567 567 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
568 568
569 569 ``showfunc``
570 570 Show which function each change is in.
571 571
572 572 ``ignorews``
573 573 Ignore white space when comparing lines.
574 574
575 575 ``ignorewsamount``
576 576 Ignore changes in the amount of white space.
577 577
578 578 ``ignoreblanklines``
579 579 Ignore changes whose lines are all blank.
580 580
581 581 ``unified``
582 582 Number of lines of context to show.
583 583
584 584 ``email``
585 585 ---------
586 586
587 587 Settings for extensions that send email messages.
588 588
589 589 ``from``
590 590 Optional. Email address to use in "From" header and SMTP envelope
591 591 of outgoing messages.
592 592
593 593 ``to``
594 594 Optional. Comma-separated list of recipients' email addresses.
595 595
596 596 ``cc``
597 597 Optional. Comma-separated list of carbon copy recipients'
598 598 email addresses.
599 599
600 600 ``bcc``
601 601 Optional. Comma-separated list of blind carbon copy recipients'
602 602 email addresses.
603 603
604 604 ``method``
605 605 Optional. Method to use to send email messages. If value is ``smtp``
606 606 (default), use SMTP (see the ``[smtp]`` section for configuration).
607 607 Otherwise, use as name of program to run that acts like sendmail
608 608 (takes ``-f`` option for sender, list of recipients on command line,
609 609 message on stdin). Normally, setting this to ``sendmail`` or
610 610 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
611 611
612 612 ``charsets``
613 613 Optional. Comma-separated list of character sets considered
614 614 convenient for recipients. Addresses, headers, and parts not
615 615 containing patches of outgoing messages will be encoded in the
616 616 first character set to which conversion from local encoding
617 617 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
618 618 conversion fails, the text in question is sent as is.
619 619 (default: '')
620 620
621 621 Order of outgoing email character sets:
622 622
623 623 1. ``us-ascii``: always first, regardless of settings
624 624 2. ``email.charsets``: in order given by user
625 625 3. ``ui.fallbackencoding``: if not in email.charsets
626 626 4. ``$HGENCODING``: if not in email.charsets
627 627 5. ``utf-8``: always last, regardless of settings
628 628
629 629 Email example::
630 630
631 631 [email]
632 632 from = Joseph User <joe.user@example.com>
633 633 method = /usr/sbin/sendmail
634 634 # charsets for western Europeans
635 635 # us-ascii, utf-8 omitted, as they are tried first and last
636 636 charsets = iso-8859-1, iso-8859-15, windows-1252
637 637
638 638
639 639 ``extensions``
640 640 --------------
641 641
642 642 Mercurial has an extension mechanism for adding new features. To
643 643 enable an extension, create an entry for it in this section.
644 644
645 645 If you know that the extension is already in Python's search path,
646 646 you can give the name of the module, followed by ``=``, with nothing
647 647 after the ``=``.
648 648
649 649 Otherwise, give a name that you choose, followed by ``=``, followed by
650 650 the path to the ``.py`` file (including the file name extension) that
651 651 defines the extension.
652 652
653 653 To explicitly disable an extension that is enabled in an hgrc of
654 654 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
655 655 or ``foo = !`` when path is not supplied.
656 656
657 657 Example for ``~/.hgrc``::
658 658
659 659 [extensions]
660 660 # (the color extension will get loaded from Mercurial's path)
661 661 color =
662 662 # (this extension will get loaded from the file specified)
663 663 myfeature = ~/.hgext/myfeature.py
664 664
665 665
666 666 ``format``
667 667 ----------
668 668
669 669 ``usegeneraldelta``
670 670 Enable or disable the "generaldelta" repository format which improves
671 671 repository compression by allowing "revlog" to store delta against arbitrary
672 672 revision instead of the previous stored one. This provides significant
673 673 improvement for repositories with branches.
674 674
675 675 Repositories with this on-disk format require Mercurial version 1.9.
676 676
677 677 Enabled by default.
678 678
679 679 ``dotencode``
680 680 Enable or disable the "dotencode" repository format which enhances
681 681 the "fncache" repository format (which has to be enabled to use
682 682 dotencode) to avoid issues with filenames starting with ._ on
683 683 Mac OS X and spaces on Windows.
684 684
685 685 Repositories with this on-disk format require Mercurial version 1.7.
686 686
687 687 Enabled by default.
688 688
689 689 ``usefncache``
690 690 Enable or disable the "fncache" repository format which enhances
691 691 the "store" repository format (which has to be enabled to use
692 692 fncache) to allow longer filenames and avoids using Windows
693 693 reserved names, e.g. "nul".
694 694
695 695 Repositories with this on-disk format require Mercurial version 1.1.
696 696
697 697 Enabled by default.
698 698
699 699 ``usestore``
700 700 Enable or disable the "store" repository format which improves
701 701 compatibility with systems that fold case or otherwise mangle
702 702 filenames. Disabling this option will allow you to store longer filenames
703 703 in some situations at the expense of compatibility.
704 704
705 705 Repositories with this on-disk format require Mercurial version 0.9.4.
706 706
707 707 Enabled by default.
708 708
709 709 ``graph``
710 710 ---------
711 711
712 712 Web graph view configuration. This section let you change graph
713 713 elements display properties by branches, for instance to make the
714 714 ``default`` branch stand out.
715 715
716 716 Each line has the following format::
717 717
718 718 <branch>.<argument> = <value>
719 719
720 720 where ``<branch>`` is the name of the branch being
721 721 customized. Example::
722 722
723 723 [graph]
724 724 # 2px width
725 725 default.width = 2
726 726 # red color
727 727 default.color = FF0000
728 728
729 729 Supported arguments:
730 730
731 731 ``width``
732 732 Set branch edges width in pixels.
733 733
734 734 ``color``
735 735 Set branch edges color in hexadecimal RGB notation.
736 736
737 737 ``hooks``
738 738 ---------
739 739
740 740 Commands or Python functions that get automatically executed by
741 741 various actions such as starting or finishing a commit. Multiple
742 742 hooks can be run for the same action by appending a suffix to the
743 743 action. Overriding a site-wide hook can be done by changing its
744 744 value or setting it to an empty string. Hooks can be prioritized
745 745 by adding a prefix of ``priority.`` to the hook name on a new line
746 746 and setting the priority. The default priority is 0.
747 747
748 748 Example ``.hg/hgrc``::
749 749
750 750 [hooks]
751 751 # update working directory after adding changesets
752 752 changegroup.update = hg update
753 753 # do not use the site-wide hook
754 754 incoming =
755 755 incoming.email = /my/email/hook
756 756 incoming.autobuild = /my/build/hook
757 757 # force autobuild hook to run before other incoming hooks
758 758 priority.incoming.autobuild = 1
759 759
760 760 Most hooks are run with environment variables set that give useful
761 761 additional information. For each hook below, the environment
762 762 variables it is passed are listed with names of the form ``$HG_foo``.
763 763
764 764 ``changegroup``
765 765 Run after a changegroup has been added via push, pull or unbundle.
766 766 ID of the first new changeset is in ``$HG_NODE``. URL from which
767 767 changes came is in ``$HG_URL``.
768 768
769 769 ``commit``
770 770 Run after a changeset has been created in the local repository. ID
771 771 of the newly created changeset is in ``$HG_NODE``. Parent changeset
772 772 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
773 773
774 774 ``incoming``
775 775 Run after a changeset has been pulled, pushed, or unbundled into
776 776 the local repository. The ID of the newly arrived changeset is in
777 777 ``$HG_NODE``. URL that was source of changes came is in ``$HG_URL``.
778 778
779 779 ``outgoing``
780 780 Run after sending changes from local repository to another. ID of
781 781 first changeset sent is in ``$HG_NODE``. Source of operation is in
782 782 ``$HG_SOURCE``; Also see :hg:`help config.preoutgoing` hook.
783 783
784 784 ``post-<command>``
785 785 Run after successful invocations of the associated command. The
786 786 contents of the command line are passed as ``$HG_ARGS`` and the result
787 787 code in ``$HG_RESULT``. Parsed command line arguments are passed as
788 788 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
789 789 the python data internally passed to <command>. ``$HG_OPTS`` is a
790 790 dictionary of options (with unspecified options set to their defaults).
791 791 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
792 792
793 793 ``pre-<command>``
794 794 Run before executing the associated command. The contents of the
795 795 command line are passed as ``$HG_ARGS``. Parsed command line arguments
796 796 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
797 797 representations of the data internally passed to <command>. ``$HG_OPTS``
798 798 is a dictionary of options (with unspecified options set to their
799 799 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
800 800 failure, the command doesn't execute and Mercurial returns the failure
801 801 code.
802 802
803 803 ``prechangegroup``
804 804 Run before a changegroup is added via push, pull or unbundle. Exit
805 805 status 0 allows the changegroup to proceed. Non-zero status will
806 806 cause the push, pull or unbundle to fail. URL from which changes
807 807 will come is in ``$HG_URL``.
808 808
809 809 ``precommit``
810 810 Run before starting a local commit. Exit status 0 allows the
811 811 commit to proceed. Non-zero status will cause the commit to fail.
812 812 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
813 813
814 814 ``prelistkeys``
815 815 Run before listing pushkeys (like bookmarks) in the
816 816 repository. Non-zero status will cause failure. The key namespace is
817 817 in ``$HG_NAMESPACE``.
818 818
819 819 ``preoutgoing``
820 820 Run before collecting changes to send from the local repository to
821 821 another. Non-zero status will cause failure. This lets you prevent
822 822 pull over HTTP or SSH. Also prevents against local pull, push
823 823 (outbound) or bundle commands, but not effective, since you can
824 824 just copy files instead then. Source of operation is in
825 825 ``$HG_SOURCE``. If "serve", operation is happening on behalf of remote
826 826 SSH or HTTP repository. If "push", "pull" or "bundle", operation
827 827 is happening on behalf of repository on same system.
828 828
829 829 ``prepushkey``
830 830 Run before a pushkey (like a bookmark) is added to the
831 831 repository. Non-zero status will cause the key to be rejected. The
832 832 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
833 833 the old value (if any) is in ``$HG_OLD``, and the new value is in
834 834 ``$HG_NEW``.
835 835
836 836 ``pretag``
837 837 Run before creating a tag. Exit status 0 allows the tag to be
838 838 created. Non-zero status will cause the tag to fail. ID of
839 839 changeset to tag is in ``$HG_NODE``. Name of tag is in ``$HG_TAG``. Tag is
840 840 local if ``$HG_LOCAL=1``, in repository if ``$HG_LOCAL=0``.
841 841
842 842 ``pretxnopen``
843 843 Run before any new repository transaction is open. The reason for the
844 844 transaction will be in ``$HG_TXNNAME`` and a unique identifier for the
845 845 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
846 846 transaction from being opened.
847 847
848 848 ``pretxnclose``
849 849 Run right before the transaction is actually finalized. Any
850 850 repository change will be visible to the hook program. This lets you
851 851 validate the transaction content or change it. Exit status 0 allows
852 852 the commit to proceed. Non-zero status will cause the transaction to
853 853 be rolled back. The reason for the transaction opening will be in
854 854 ``$HG_TXNNAME`` and a unique identifier for the transaction will be in
855 855 ``HG_TXNID``. The rest of the available data will vary according the
856 856 transaction type. New changesets will add ``$HG_NODE`` (id of the
857 857 first added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables,
858 858 bookmarks and phases changes will set ``HG_BOOKMARK_MOVED`` and
859 859 ``HG_PHASES_MOVED`` to ``1``, etc.
860 860
861 861 ``txnclose``
862 862 Run after any repository transaction has been committed. At this
863 863 point, the transaction can no longer be rolled back. The hook will run
864 864 after the lock is released. See :hg:`help config.pretxnclose` docs for
865 865 details about available variables.
866 866
867 867 ``txnabort``
868 868 Run when a transaction is aborted. See :hg:`help config.pretxnclose`
869 869 docs for details about available variables.
870 870
871 871 ``pretxnchangegroup``
872 872 Run after a changegroup has been added via push, pull or unbundle,
873 873 but before the transaction has been committed. Changegroup is
874 874 visible to hook program. This lets you validate incoming changes
875 875 before accepting them. Passed the ID of the first new changeset in
876 876 ``$HG_NODE``. Exit status 0 allows the transaction to commit. Non-zero
877 877 status will cause the transaction to be rolled back and the push,
878 878 pull or unbundle will fail. URL that was source of changes is in
879 879 ``$HG_URL``.
880 880
881 881 ``pretxncommit``
882 882 Run after a changeset has been created but the transaction not yet
883 883 committed. Changeset is visible to hook program. This lets you
884 884 validate commit message and changes. Exit status 0 allows the
885 885 commit to proceed. Non-zero status will cause the transaction to
886 886 be rolled back. ID of changeset is in ``$HG_NODE``. Parent changeset
887 887 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
888 888
889 889 ``preupdate``
890 890 Run before updating the working directory. Exit status 0 allows
891 891 the update to proceed. Non-zero status will prevent the update.
892 892 Changeset ID of first new parent is in ``$HG_PARENT1``. If merge, ID
893 893 of second new parent is in ``$HG_PARENT2``.
894 894
895 895 ``listkeys``
896 896 Run after listing pushkeys (like bookmarks) in the repository. The
897 897 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
898 898 dictionary containing the keys and values.
899 899
900 900 ``pushkey``
901 901 Run after a pushkey (like a bookmark) is added to the
902 902 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
903 903 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
904 904 value is in ``$HG_NEW``.
905 905
906 906 ``tag``
907 907 Run after a tag is created. ID of tagged changeset is in ``$HG_NODE``.
908 908 Name of tag is in ``$HG_TAG``. Tag is local if ``$HG_LOCAL=1``, in
909 909 repository if ``$HG_LOCAL=0``.
910 910
911 911 ``update``
912 912 Run after updating the working directory. Changeset ID of first
913 913 new parent is in ``$HG_PARENT1``. If merge, ID of second new parent is
914 914 in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
915 915 update failed (e.g. because conflicts not resolved), ``$HG_ERROR=1``.
916 916
917 917 .. note::
918 918
919 919 It is generally better to use standard hooks rather than the
920 920 generic pre- and post- command hooks as they are guaranteed to be
921 921 called in the appropriate contexts for influencing transactions.
922 922 Also, hooks like "commit" will be called in all contexts that
923 923 generate a commit (e.g. tag) and not just the commit command.
924 924
925 925 .. note::
926 926
927 927 Environment variables with empty values may not be passed to
928 928 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
929 929 will have an empty value under Unix-like platforms for non-merge
930 930 changesets, while it will not be available at all under Windows.
931 931
932 932 The syntax for Python hooks is as follows::
933 933
934 934 hookname = python:modulename.submodule.callable
935 935 hookname = python:/path/to/python/module.py:callable
936 936
937 937 Python hooks are run within the Mercurial process. Each hook is
938 938 called with at least three keyword arguments: a ui object (keyword
939 939 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
940 940 keyword that tells what kind of hook is used. Arguments listed as
941 941 environment variables above are passed as keyword arguments, with no
942 942 ``HG_`` prefix, and names in lower case.
943 943
944 944 If a Python hook returns a "true" value or raises an exception, this
945 945 is treated as a failure.
946 946
947 947
948 948 ``hostfingerprints``
949 949 --------------------
950 950
951 951 Fingerprints of the certificates of known HTTPS servers.
952 952 A HTTPS connection to a server with a fingerprint configured here will
953 953 only succeed if the servers certificate matches the fingerprint.
954 954 This is very similar to how ssh known hosts works.
955 955 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
956 956 The CA chain and web.cacerts is not used for servers with a fingerprint.
957 957
958 958 For example::
959 959
960 960 [hostfingerprints]
961 961 hg.intevation.org = fa:1f:d9:48:f1:e7:74:30:38:8d:d8:58:b6:94:b8:58:28:7d:8b:d0
962 962
963 963 This feature is only supported when using Python 2.6 or later.
964 964
965 965
966 966 ``http_proxy``
967 967 --------------
968 968
969 969 Used to access web-based Mercurial repositories through a HTTP
970 970 proxy.
971 971
972 972 ``host``
973 973 Host name and (optional) port of the proxy server, for example
974 974 "myproxy:8000".
975 975
976 976 ``no``
977 977 Optional. Comma-separated list of host names that should bypass
978 978 the proxy.
979 979
980 980 ``passwd``
981 981 Optional. Password to authenticate with at the proxy server.
982 982
983 983 ``user``
984 984 Optional. User name to authenticate with at the proxy server.
985 985
986 986 ``always``
987 987 Optional. Always use the proxy, even for localhost and any entries
988 988 in ``http_proxy.no``. (default: False)
989 989
990 ``merge``
991 ---------
992
993 This section specifies behavior during merges and updates.
994
995 ``checkunknown``
996 Controls behavior when an unknown file on disk has the same name as a tracked
997 file in the changeset being merged or updated to, and has different
998 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
999 abort on such files. With ``warn``, warn on such files and back them up as
1000 .orig. With ``ignore``, don't print a warning and back them up as
1001 .orig. (default: ``abort``)
1002
990 1003 ``merge-patterns``
991 1004 ------------------
992 1005
993 1006 This section specifies merge tools to associate with particular file
994 1007 patterns. Tools matched here will take precedence over the default
995 1008 merge tool. Patterns are globs by default, rooted at the repository
996 1009 root.
997 1010
998 1011 Example::
999 1012
1000 1013 [merge-patterns]
1001 1014 **.c = kdiff3
1002 1015 **.jpg = myimgmerge
1003 1016
1004 1017 ``merge-tools``
1005 1018 ---------------
1006 1019
1007 1020 This section configures external merge tools to use for file-level
1008 1021 merges. This section has likely been preconfigured at install time.
1009 1022 Use :hg:`config merge-tools` to check the existing configuration.
1010 1023 Also see :hg:`help merge-tools` for more details.
1011 1024
1012 1025 Example ``~/.hgrc``::
1013 1026
1014 1027 [merge-tools]
1015 1028 # Override stock tool location
1016 1029 kdiff3.executable = ~/bin/kdiff3
1017 1030 # Specify command line
1018 1031 kdiff3.args = $base $local $other -o $output
1019 1032 # Give higher priority
1020 1033 kdiff3.priority = 1
1021 1034
1022 1035 # Changing the priority of preconfigured tool
1023 1036 meld.priority = 0
1024 1037
1025 1038 # Disable a preconfigured tool
1026 1039 vimdiff.disabled = yes
1027 1040
1028 1041 # Define new tool
1029 1042 myHtmlTool.args = -m $local $other $base $output
1030 1043 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1031 1044 myHtmlTool.priority = 1
1032 1045
1033 1046 Supported arguments:
1034 1047
1035 1048 ``priority``
1036 1049 The priority in which to evaluate this tool.
1037 1050 (default: 0)
1038 1051
1039 1052 ``executable``
1040 1053 Either just the name of the executable or its pathname. On Windows,
1041 1054 the path can use environment variables with ${ProgramFiles} syntax.
1042 1055 (default: the tool name)
1043 1056
1044 1057 ``args``
1045 1058 The arguments to pass to the tool executable. You can refer to the
1046 1059 files being merged as well as the output file through these
1047 1060 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
1048 1061 of ``$local`` and ``$other`` can vary depending on which action is being
1049 1062 performed. During and update or merge, ``$local`` represents the original
1050 1063 state of the file, while ``$other`` represents the commit you are updating
1051 1064 to or the commit you are merging with. During a rebase ``$local``
1052 1065 represents the destination of the rebase, and ``$other`` represents the
1053 1066 commit being rebased.
1054 1067 (default: ``$local $base $other``)
1055 1068
1056 1069 ``premerge``
1057 1070 Attempt to run internal non-interactive 3-way merge tool before
1058 1071 launching external tool. Options are ``true``, ``false``, ``keep`` or
1059 1072 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1060 1073 premerge fails. The ``keep-merge3`` will do the same but include information
1061 1074 about the base of the merge in the marker (see internal :merge3 in
1062 1075 :hg:`help merge-tools`).
1063 1076 (default: True)
1064 1077
1065 1078 ``binary``
1066 1079 This tool can merge binary files. (default: False, unless tool
1067 1080 was selected by file pattern match)
1068 1081
1069 1082 ``symlink``
1070 1083 This tool can merge symlinks. (default: False)
1071 1084
1072 1085 ``check``
1073 1086 A list of merge success-checking options:
1074 1087
1075 1088 ``changed``
1076 1089 Ask whether merge was successful when the merged file shows no changes.
1077 1090 ``conflicts``
1078 1091 Check whether there are conflicts even though the tool reported success.
1079 1092 ``prompt``
1080 1093 Always prompt for merge success, regardless of success reported by tool.
1081 1094
1082 1095 ``fixeol``
1083 1096 Attempt to fix up EOL changes caused by the merge tool.
1084 1097 (default: False)
1085 1098
1086 1099 ``gui``
1087 1100 This tool requires a graphical interface to run. (default: False)
1088 1101
1089 1102 ``regkey``
1090 1103 Windows registry key which describes install location of this
1091 1104 tool. Mercurial will search for this key first under
1092 1105 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1093 1106 (default: None)
1094 1107
1095 1108 ``regkeyalt``
1096 1109 An alternate Windows registry key to try if the first key is not
1097 1110 found. The alternate key uses the same ``regname`` and ``regappend``
1098 1111 semantics of the primary key. The most common use for this key
1099 1112 is to search for 32bit applications on 64bit operating systems.
1100 1113 (default: None)
1101 1114
1102 1115 ``regname``
1103 1116 Name of value to read from specified registry key.
1104 1117 (default: the unnamed (default) value)
1105 1118
1106 1119 ``regappend``
1107 1120 String to append to the value read from the registry, typically
1108 1121 the executable name of the tool.
1109 1122 (default: None)
1110 1123
1111 1124
1112 1125 ``patch``
1113 1126 ---------
1114 1127
1115 1128 Settings used when applying patches, for instance through the 'import'
1116 1129 command or with Mercurial Queues extension.
1117 1130
1118 1131 ``eol``
1119 1132 When set to 'strict' patch content and patched files end of lines
1120 1133 are preserved. When set to ``lf`` or ``crlf``, both files end of
1121 1134 lines are ignored when patching and the result line endings are
1122 1135 normalized to either LF (Unix) or CRLF (Windows). When set to
1123 1136 ``auto``, end of lines are again ignored while patching but line
1124 1137 endings in patched files are normalized to their original setting
1125 1138 on a per-file basis. If target file does not exist or has no end
1126 1139 of line, patch line endings are preserved.
1127 1140 (default: strict)
1128 1141
1129 1142 ``fuzz``
1130 1143 The number of lines of 'fuzz' to allow when applying patches. This
1131 1144 controls how much context the patcher is allowed to ignore when
1132 1145 trying to apply a patch.
1133 1146 (default: 2)
1134 1147
1135 1148 ``paths``
1136 1149 ---------
1137 1150
1138 1151 Assigns symbolic names and behavior to repositories.
1139 1152
1140 1153 Options are symbolic names defining the URL or directory that is the
1141 1154 location of the repository. Example::
1142 1155
1143 1156 [paths]
1144 1157 my_server = https://example.com/my_repo
1145 1158 local_path = /home/me/repo
1146 1159
1147 1160 These symbolic names can be used from the command line. To pull
1148 1161 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1149 1162 :hg:`push local_path`.
1150 1163
1151 1164 Options containing colons (``:``) denote sub-options that can influence
1152 1165 behavior for that specific path. Example::
1153 1166
1154 1167 [paths]
1155 1168 my_server = https://example.com/my_path
1156 1169 my_server:pushurl = ssh://example.com/my_path
1157 1170
1158 1171 The following sub-options can be defined:
1159 1172
1160 1173 ``pushurl``
1161 1174 The URL to use for push operations. If not defined, the location
1162 1175 defined by the path's main entry is used.
1163 1176
1164 1177 The following special named paths exist:
1165 1178
1166 1179 ``default``
1167 1180 The URL or directory to use when no source or remote is specified.
1168 1181
1169 1182 :hg:`clone` will automatically define this path to the location the
1170 1183 repository was cloned from.
1171 1184
1172 1185 ``default-push``
1173 1186 (deprecated) The URL or directory for the default :hg:`push` location.
1174 1187 ``default:pushurl`` should be used instead.
1175 1188
1176 1189 ``phases``
1177 1190 ----------
1178 1191
1179 1192 Specifies default handling of phases. See :hg:`help phases` for more
1180 1193 information about working with phases.
1181 1194
1182 1195 ``publish``
1183 1196 Controls draft phase behavior when working as a server. When true,
1184 1197 pushed changesets are set to public in both client and server and
1185 1198 pulled or cloned changesets are set to public in the client.
1186 1199 (default: True)
1187 1200
1188 1201 ``new-commit``
1189 1202 Phase of newly-created commits.
1190 1203 (default: draft)
1191 1204
1192 1205 ``checksubrepos``
1193 1206 Check the phase of the current revision of each subrepository. Allowed
1194 1207 values are "ignore", "follow" and "abort". For settings other than
1195 1208 "ignore", the phase of the current revision of each subrepository is
1196 1209 checked before committing the parent repository. If any of those phases is
1197 1210 greater than the phase of the parent repository (e.g. if a subrepo is in a
1198 1211 "secret" phase while the parent repo is in "draft" phase), the commit is
1199 1212 either aborted (if checksubrepos is set to "abort") or the higher phase is
1200 1213 used for the parent repository commit (if set to "follow").
1201 1214 (default: follow)
1202 1215
1203 1216
1204 1217 ``profiling``
1205 1218 -------------
1206 1219
1207 1220 Specifies profiling type, format, and file output. Two profilers are
1208 1221 supported: an instrumenting profiler (named ``ls``), and a sampling
1209 1222 profiler (named ``stat``).
1210 1223
1211 1224 In this section description, 'profiling data' stands for the raw data
1212 1225 collected during profiling, while 'profiling report' stands for a
1213 1226 statistical text report generated from the profiling data. The
1214 1227 profiling is done using lsprof.
1215 1228
1216 1229 ``type``
1217 1230 The type of profiler to use.
1218 1231 (default: ls)
1219 1232
1220 1233 ``ls``
1221 1234 Use Python's built-in instrumenting profiler. This profiler
1222 1235 works on all platforms, but each line number it reports is the
1223 1236 first line of a function. This restriction makes it difficult to
1224 1237 identify the expensive parts of a non-trivial function.
1225 1238 ``stat``
1226 1239 Use a third-party statistical profiler, statprof. This profiler
1227 1240 currently runs only on Unix systems, and is most useful for
1228 1241 profiling commands that run for longer than about 0.1 seconds.
1229 1242
1230 1243 ``format``
1231 1244 Profiling format. Specific to the ``ls`` instrumenting profiler.
1232 1245 (default: text)
1233 1246
1234 1247 ``text``
1235 1248 Generate a profiling report. When saving to a file, it should be
1236 1249 noted that only the report is saved, and the profiling data is
1237 1250 not kept.
1238 1251 ``kcachegrind``
1239 1252 Format profiling data for kcachegrind use: when saving to a
1240 1253 file, the generated file can directly be loaded into
1241 1254 kcachegrind.
1242 1255
1243 1256 ``frequency``
1244 1257 Sampling frequency. Specific to the ``stat`` sampling profiler.
1245 1258 (default: 1000)
1246 1259
1247 1260 ``output``
1248 1261 File path where profiling data or report should be saved. If the
1249 1262 file exists, it is replaced. (default: None, data is printed on
1250 1263 stderr)
1251 1264
1252 1265 ``sort``
1253 1266 Sort field. Specific to the ``ls`` instrumenting profiler.
1254 1267 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1255 1268 ``inlinetime``.
1256 1269 (default: inlinetime)
1257 1270
1258 1271 ``limit``
1259 1272 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1260 1273 (default: 30)
1261 1274
1262 1275 ``nested``
1263 1276 Show at most this number of lines of drill-down info after each main entry.
1264 1277 This can help explain the difference between Total and Inline.
1265 1278 Specific to the ``ls`` instrumenting profiler.
1266 1279 (default: 5)
1267 1280
1268 1281 ``progress``
1269 1282 ------------
1270 1283
1271 1284 Mercurial commands can draw progress bars that are as informative as
1272 1285 possible. Some progress bars only offer indeterminate information, while others
1273 1286 have a definite end point.
1274 1287
1275 1288 ``delay``
1276 1289 Number of seconds (float) before showing the progress bar. (default: 3)
1277 1290
1278 1291 ``changedelay``
1279 1292 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1280 1293 that value will be used instead. (default: 1)
1281 1294
1282 1295 ``refresh``
1283 1296 Time in seconds between refreshes of the progress bar. (default: 0.1)
1284 1297
1285 1298 ``format``
1286 1299 Format of the progress bar.
1287 1300
1288 1301 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1289 1302 ``unit``, ``estimate``, speed, and item. item defaults to the last 20
1290 1303 characters of the item, but this can be changed by adding either ``-<num>``
1291 1304 which would take the last num characters, or ``+<num>`` for the first num
1292 1305 characters.
1293 1306
1294 1307 (default: Topic bar number estimate)
1295 1308
1296 1309 ``width``
1297 1310 If set, the maximum width of the progress information (that is, min(width,
1298 1311 term width) will be used).
1299 1312
1300 1313 ``clear-complete``
1301 1314 Clear the progress bar after it's done. (default: True)
1302 1315
1303 1316 ``disable``
1304 1317 If true, don't show a progress bar.
1305 1318
1306 1319 ``assume-tty``
1307 1320 If true, ALWAYS show a progress bar, unless disable is given.
1308 1321
1309 1322 ``revsetalias``
1310 1323 ---------------
1311 1324
1312 1325 Alias definitions for revsets. See :hg:`help revsets` for details.
1313 1326
1314 1327 ``server``
1315 1328 ----------
1316 1329
1317 1330 Controls generic server settings.
1318 1331
1319 1332 ``uncompressed``
1320 1333 Whether to allow clients to clone a repository using the
1321 1334 uncompressed streaming protocol. This transfers about 40% more
1322 1335 data than a regular clone, but uses less memory and CPU on both
1323 1336 server and client. Over a LAN (100 Mbps or better) or a very fast
1324 1337 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1325 1338 regular clone. Over most WAN connections (anything slower than
1326 1339 about 6 Mbps), uncompressed streaming is slower, because of the
1327 1340 extra data transfer overhead. This mode will also temporarily hold
1328 1341 the write lock while determining what data to transfer.
1329 1342 (default: True)
1330 1343
1331 1344 ``preferuncompressed``
1332 1345 When set, clients will try to use the uncompressed streaming
1333 1346 protocol. (default: False)
1334 1347
1335 1348 ``validate``
1336 1349 Whether to validate the completeness of pushed changesets by
1337 1350 checking that all new file revisions specified in manifests are
1338 1351 present. (default: False)
1339 1352
1340 1353 ``maxhttpheaderlen``
1341 1354 Instruct HTTP clients not to send request headers longer than this
1342 1355 many bytes. (default: 1024)
1343 1356
1344 1357 ``bundle1``
1345 1358 Whether to allow clients to push and pull using the legacy bundle1
1346 1359 exchange format. (default: True)
1347 1360
1348 1361 ``bundle1gd``
1349 1362 Like ``bundle1` but only used if the repository is using the
1350 1363 *generaldelta* storage format. (default: True)
1351 1364
1352 1365 ``bundle1.push``
1353 1366 Whether to allow clients to push using the legacy bundle1 exchange
1354 1367 format. (default: True)
1355 1368
1356 1369 ``bundle1gd.push``
1357 1370 Like ``bundle1.push` but only used if the repository is using the
1358 1371 *generaldelta* storage format. (default: True)
1359 1372
1360 1373 ``bundle1.pull``
1361 1374 Whether to allow clients to pull using the legacy bundle1 exchange
1362 1375 format. (default: True)
1363 1376
1364 1377 ``bundle1gd.pull``
1365 1378 Like ``bundle1.pull` but only used if the repository is using the
1366 1379 *generaldelta* storage format. (default: True)
1367 1380
1368 1381 Large repositories using the *generaldelta* storage format should
1369 1382 consider setting this option because converting *generaldelta*
1370 1383 repositories to the exchange format required by the bundle1 data
1371 1384 format can consume a lot of CPU.
1372 1385
1373 1386 ``smtp``
1374 1387 --------
1375 1388
1376 1389 Configuration for extensions that need to send email messages.
1377 1390
1378 1391 ``host``
1379 1392 Host name of mail server, e.g. "mail.example.com".
1380 1393
1381 1394 ``port``
1382 1395 Optional. Port to connect to on mail server. (default: 465 if
1383 1396 ``tls`` is smtps; 25 otherwise)
1384 1397
1385 1398 ``tls``
1386 1399 Optional. Method to enable TLS when connecting to mail server: starttls,
1387 1400 smtps or none. (default: none)
1388 1401
1389 1402 ``verifycert``
1390 1403 Optional. Verification for the certificate of mail server, when
1391 1404 ``tls`` is starttls or smtps. "strict", "loose" or False. For
1392 1405 "strict" or "loose", the certificate is verified as same as the
1393 1406 verification for HTTPS connections (see ``[hostfingerprints]`` and
1394 1407 ``[web] cacerts`` also). For "strict", sending email is also
1395 1408 aborted, if there is no configuration for mail server in
1396 1409 ``[hostfingerprints]`` and ``[web] cacerts``. --insecure for
1397 1410 :hg:`email` overwrites this as "loose". (default: strict)
1398 1411
1399 1412 ``username``
1400 1413 Optional. User name for authenticating with the SMTP server.
1401 1414 (default: None)
1402 1415
1403 1416 ``password``
1404 1417 Optional. Password for authenticating with the SMTP server. If not
1405 1418 specified, interactive sessions will prompt the user for a
1406 1419 password; non-interactive sessions will fail. (default: None)
1407 1420
1408 1421 ``local_hostname``
1409 1422 Optional. The hostname that the sender can use to identify
1410 1423 itself to the MTA.
1411 1424
1412 1425
1413 1426 ``subpaths``
1414 1427 ------------
1415 1428
1416 1429 Subrepository source URLs can go stale if a remote server changes name
1417 1430 or becomes temporarily unavailable. This section lets you define
1418 1431 rewrite rules of the form::
1419 1432
1420 1433 <pattern> = <replacement>
1421 1434
1422 1435 where ``pattern`` is a regular expression matching a subrepository
1423 1436 source URL and ``replacement`` is the replacement string used to
1424 1437 rewrite it. Groups can be matched in ``pattern`` and referenced in
1425 1438 ``replacements``. For instance::
1426 1439
1427 1440 http://server/(.*)-hg/ = http://hg.server/\1/
1428 1441
1429 1442 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1430 1443
1431 1444 Relative subrepository paths are first made absolute, and the
1432 1445 rewrite rules are then applied on the full (absolute) path. The rules
1433 1446 are applied in definition order.
1434 1447
1435 1448 ``trusted``
1436 1449 -----------
1437 1450
1438 1451 Mercurial will not use the settings in the
1439 1452 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1440 1453 user or to a trusted group, as various hgrc features allow arbitrary
1441 1454 commands to be run. This issue is often encountered when configuring
1442 1455 hooks or extensions for shared repositories or servers. However,
1443 1456 the web interface will use some safe settings from the ``[web]``
1444 1457 section.
1445 1458
1446 1459 This section specifies what users and groups are trusted. The
1447 1460 current user is always trusted. To trust everybody, list a user or a
1448 1461 group with name ``*``. These settings must be placed in an
1449 1462 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1450 1463 user or service running Mercurial.
1451 1464
1452 1465 ``users``
1453 1466 Comma-separated list of trusted users.
1454 1467
1455 1468 ``groups``
1456 1469 Comma-separated list of trusted groups.
1457 1470
1458 1471
1459 1472 ``ui``
1460 1473 ------
1461 1474
1462 1475 User interface controls.
1463 1476
1464 1477 ``archivemeta``
1465 1478 Whether to include the .hg_archival.txt file containing meta data
1466 1479 (hashes for the repository base and for tip) in archives created
1467 1480 by the :hg:`archive` command or downloaded via hgweb.
1468 1481 (default: True)
1469 1482
1470 1483 ``askusername``
1471 1484 Whether to prompt for a username when committing. If True, and
1472 1485 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1473 1486 be prompted to enter a username. If no username is entered, the
1474 1487 default ``USER@HOST`` is used instead.
1475 1488 (default: False)
1476 1489
1477 1490 ``clonebundlefallback``
1478 1491 Whether failure to apply an advertised "clone bundle" from a server
1479 1492 should result in fallback to a regular clone.
1480 1493
1481 1494 This is disabled by default because servers advertising "clone
1482 1495 bundles" often do so to reduce server load. If advertised bundles
1483 1496 start mass failing and clients automatically fall back to a regular
1484 1497 clone, this would add significant and unexpected load to the server
1485 1498 since the server is expecting clone operations to be offloaded to
1486 1499 pre-generated bundles. Failing fast (the default behavior) ensures
1487 1500 clients don't overwhelm the server when "clone bundle" application
1488 1501 fails.
1489 1502
1490 1503 (default: False)
1491 1504
1492 1505 ``commitsubrepos``
1493 1506 Whether to commit modified subrepositories when committing the
1494 1507 parent repository. If False and one subrepository has uncommitted
1495 1508 changes, abort the commit.
1496 1509 (default: False)
1497 1510
1498 1511 ``debug``
1499 1512 Print debugging information. (default: False)
1500 1513
1501 1514 ``editor``
1502 1515 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
1503 1516
1504 1517 ``fallbackencoding``
1505 1518 Encoding to try if it's not possible to decode the changelog using
1506 1519 UTF-8. (default: ISO-8859-1)
1507 1520
1508 1521 ``graphnodetemplate``
1509 1522 The template used to print changeset nodes in an ASCII revision graph.
1510 1523 (default: ``{graphnode}``)
1511 1524
1512 1525 ``ignore``
1513 1526 A file to read per-user ignore patterns from. This file should be
1514 1527 in the same format as a repository-wide .hgignore file. Filenames
1515 1528 are relative to the repository root. This option supports hook syntax,
1516 1529 so if you want to specify multiple ignore files, you can do so by
1517 1530 setting something like ``ignore.other = ~/.hgignore2``. For details
1518 1531 of the ignore file format, see the ``hgignore(5)`` man page.
1519 1532
1520 1533 ``interactive``
1521 1534 Allow to prompt the user. (default: True)
1522 1535
1523 1536 ``logtemplate``
1524 1537 Template string for commands that print changesets.
1525 1538
1526 1539 ``merge``
1527 1540 The conflict resolution program to use during a manual merge.
1528 1541 For more information on merge tools see :hg:`help merge-tools`.
1529 1542 For configuring merge tools see the ``[merge-tools]`` section.
1530 1543
1531 1544 ``mergemarkers``
1532 1545 Sets the merge conflict marker label styling. The ``detailed``
1533 1546 style uses the ``mergemarkertemplate`` setting to style the labels.
1534 1547 The ``basic`` style just uses 'local' and 'other' as the marker label.
1535 1548 One of ``basic`` or ``detailed``.
1536 1549 (default: ``basic``)
1537 1550
1538 1551 ``mergemarkertemplate``
1539 1552 The template used to print the commit description next to each conflict
1540 1553 marker during merge conflicts. See :hg:`help templates` for the template
1541 1554 format.
1542 1555
1543 1556 Defaults to showing the hash, tags, branches, bookmarks, author, and
1544 1557 the first line of the commit description.
1545 1558
1546 1559 If you use non-ASCII characters in names for tags, branches, bookmarks,
1547 1560 authors, and/or commit descriptions, you must pay attention to encodings of
1548 1561 managed files. At template expansion, non-ASCII characters use the encoding
1549 1562 specified by the ``--encoding`` global option, ``HGENCODING`` or other
1550 1563 environment variables that govern your locale. If the encoding of the merge
1551 1564 markers is different from the encoding of the merged files,
1552 1565 serious problems may occur.
1553 1566
1554 1567 ``origbackuppath``
1555 1568 The path to a directory used to store generated .orig files. If the path is
1556 1569 not a directory, one will be created.
1557 1570
1558 1571 ``patch``
1559 1572 An optional external tool that ``hg import`` and some extensions
1560 1573 will use for applying patches. By default Mercurial uses an
1561 1574 internal patch utility. The external tool must work as the common
1562 1575 Unix ``patch`` program. In particular, it must accept a ``-p``
1563 1576 argument to strip patch headers, a ``-d`` argument to specify the
1564 1577 current directory, a file name to patch, and a patch file to take
1565 1578 from stdin.
1566 1579
1567 1580 It is possible to specify a patch tool together with extra
1568 1581 arguments. For example, setting this option to ``patch --merge``
1569 1582 will use the ``patch`` program with its 2-way merge option.
1570 1583
1571 1584 ``portablefilenames``
1572 1585 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
1573 1586 (default: ``warn``)
1574 1587 If set to ``warn`` (or ``true``), a warning message is printed on POSIX
1575 1588 platforms, if a file with a non-portable filename is added (e.g. a file
1576 1589 with a name that can't be created on Windows because it contains reserved
1577 1590 parts like ``AUX``, reserved characters like ``:``, or would cause a case
1578 1591 collision with an existing file).
1579 1592 If set to ``ignore`` (or ``false``), no warning is printed.
1580 1593 If set to ``abort``, the command is aborted.
1581 1594 On Windows, this configuration option is ignored and the command aborted.
1582 1595
1583 1596 ``quiet``
1584 1597 Reduce the amount of output printed. (default: False)
1585 1598
1586 1599 ``remotecmd``
1587 1600 Remote command to use for clone/push/pull operations. (default: ``hg``)
1588 1601
1589 1602 ``report_untrusted``
1590 1603 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
1591 1604 trusted user or group. (default: True)
1592 1605
1593 1606 ``slash``
1594 1607 Display paths using a slash (``/``) as the path separator. This
1595 1608 only makes a difference on systems where the default path
1596 1609 separator is not the slash character (e.g. Windows uses the
1597 1610 backslash character (``\``)).
1598 1611 (default: False)
1599 1612
1600 1613 ``statuscopies``
1601 1614 Display copies in the status command.
1602 1615
1603 1616 ``ssh``
1604 1617 Command to use for SSH connections. (default: ``ssh``)
1605 1618
1606 1619 ``strict``
1607 1620 Require exact command names, instead of allowing unambiguous
1608 1621 abbreviations. (default: False)
1609 1622
1610 1623 ``style``
1611 1624 Name of style to use for command output.
1612 1625
1613 1626 ``supportcontact``
1614 1627 A URL where users should report a Mercurial traceback. Use this if you are a
1615 1628 large organisation with its own Mercurial deployment process and crash
1616 1629 reports should be addressed to your internal support.
1617 1630
1618 1631 ``timeout``
1619 1632 The timeout used when a lock is held (in seconds), a negative value
1620 1633 means no timeout. (default: 600)
1621 1634
1622 1635 ``traceback``
1623 1636 Mercurial always prints a traceback when an unknown exception
1624 1637 occurs. Setting this to True will make Mercurial print a traceback
1625 1638 on all exceptions, even those recognized by Mercurial (such as
1626 1639 IOError or MemoryError). (default: False)
1627 1640
1628 1641 ``username``
1629 1642 The committer of a changeset created when running "commit".
1630 1643 Typically a person's name and email address, e.g. ``Fred Widget
1631 1644 <fred@example.com>``. Environment variables in the
1632 1645 username are expanded.
1633 1646
1634 1647 (default: ``$EMAIL`` or ``username@hostname``. If the username in
1635 1648 hgrc is empty, e.g. if the system admin set ``username =`` in the
1636 1649 system hgrc, it has to be specified manually or in a different
1637 1650 hgrc file)
1638 1651
1639 1652 ``verbose``
1640 1653 Increase the amount of output printed. (default: False)
1641 1654
1642 1655
1643 1656 ``web``
1644 1657 -------
1645 1658
1646 1659 Web interface configuration. The settings in this section apply to
1647 1660 both the builtin webserver (started by :hg:`serve`) and the script you
1648 1661 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
1649 1662 and WSGI).
1650 1663
1651 1664 The Mercurial webserver does no authentication (it does not prompt for
1652 1665 usernames and passwords to validate *who* users are), but it does do
1653 1666 authorization (it grants or denies access for *authenticated users*
1654 1667 based on settings in this section). You must either configure your
1655 1668 webserver to do authentication for you, or disable the authorization
1656 1669 checks.
1657 1670
1658 1671 For a quick setup in a trusted environment, e.g., a private LAN, where
1659 1672 you want it to accept pushes from anybody, you can use the following
1660 1673 command line::
1661 1674
1662 1675 $ hg --config web.allow_push=* --config web.push_ssl=False serve
1663 1676
1664 1677 Note that this will allow anybody to push anything to the server and
1665 1678 that this should not be used for public servers.
1666 1679
1667 1680 The full set of options is:
1668 1681
1669 1682 ``accesslog``
1670 1683 Where to output the access log. (default: stdout)
1671 1684
1672 1685 ``address``
1673 1686 Interface address to bind to. (default: all)
1674 1687
1675 1688 ``allow_archive``
1676 1689 List of archive format (bz2, gz, zip) allowed for downloading.
1677 1690 (default: empty)
1678 1691
1679 1692 ``allowbz2``
1680 1693 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
1681 1694 revisions.
1682 1695 (default: False)
1683 1696
1684 1697 ``allowgz``
1685 1698 (DEPRECATED) Whether to allow .tar.gz downloading of repository
1686 1699 revisions.
1687 1700 (default: False)
1688 1701
1689 1702 ``allowpull``
1690 1703 Whether to allow pulling from the repository. (default: True)
1691 1704
1692 1705 ``allow_push``
1693 1706 Whether to allow pushing to the repository. If empty or not set,
1694 1707 pushing is not allowed. If the special value ``*``, any remote
1695 1708 user can push, including unauthenticated users. Otherwise, the
1696 1709 remote user must have been authenticated, and the authenticated
1697 1710 user name must be present in this list. The contents of the
1698 1711 allow_push list are examined after the deny_push list.
1699 1712
1700 1713 ``allow_read``
1701 1714 If the user has not already been denied repository access due to
1702 1715 the contents of deny_read, this list determines whether to grant
1703 1716 repository access to the user. If this list is not empty, and the
1704 1717 user is unauthenticated or not present in the list, then access is
1705 1718 denied for the user. If the list is empty or not set, then access
1706 1719 is permitted to all users by default. Setting allow_read to the
1707 1720 special value ``*`` is equivalent to it not being set (i.e. access
1708 1721 is permitted to all users). The contents of the allow_read list are
1709 1722 examined after the deny_read list.
1710 1723
1711 1724 ``allowzip``
1712 1725 (DEPRECATED) Whether to allow .zip downloading of repository
1713 1726 revisions. This feature creates temporary files.
1714 1727 (default: False)
1715 1728
1716 1729 ``archivesubrepos``
1717 1730 Whether to recurse into subrepositories when archiving.
1718 1731 (default: False)
1719 1732
1720 1733 ``baseurl``
1721 1734 Base URL to use when publishing URLs in other locations, so
1722 1735 third-party tools like email notification hooks can construct
1723 1736 URLs. Example: ``http://hgserver/repos/``.
1724 1737
1725 1738 ``cacerts``
1726 1739 Path to file containing a list of PEM encoded certificate
1727 1740 authority certificates. Environment variables and ``~user``
1728 1741 constructs are expanded in the filename. If specified on the
1729 1742 client, then it will verify the identity of remote HTTPS servers
1730 1743 with these certificates.
1731 1744
1732 1745 This feature is only supported when using Python 2.6 or later. If you wish
1733 1746 to use it with earlier versions of Python, install the backported
1734 1747 version of the ssl library that is available from
1735 1748 ``http://pypi.python.org``.
1736 1749
1737 1750 To disable SSL verification temporarily, specify ``--insecure`` from
1738 1751 command line.
1739 1752
1740 1753 You can use OpenSSL's CA certificate file if your platform has
1741 1754 one. On most Linux systems this will be
1742 1755 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
1743 1756 generate this file manually. The form must be as follows::
1744 1757
1745 1758 -----BEGIN CERTIFICATE-----
1746 1759 ... (certificate in base64 PEM encoding) ...
1747 1760 -----END CERTIFICATE-----
1748 1761 -----BEGIN CERTIFICATE-----
1749 1762 ... (certificate in base64 PEM encoding) ...
1750 1763 -----END CERTIFICATE-----
1751 1764
1752 1765 ``cache``
1753 1766 Whether to support caching in hgweb. (default: True)
1754 1767
1755 1768 ``certificate``
1756 1769 Certificate to use when running :hg:`serve`.
1757 1770
1758 1771 ``collapse``
1759 1772 With ``descend`` enabled, repositories in subdirectories are shown at
1760 1773 a single level alongside repositories in the current path. With
1761 1774 ``collapse`` also enabled, repositories residing at a deeper level than
1762 1775 the current path are grouped behind navigable directory entries that
1763 1776 lead to the locations of these repositories. In effect, this setting
1764 1777 collapses each collection of repositories found within a subdirectory
1765 1778 into a single entry for that subdirectory. (default: False)
1766 1779
1767 1780 ``comparisoncontext``
1768 1781 Number of lines of context to show in side-by-side file comparison. If
1769 1782 negative or the value ``full``, whole files are shown. (default: 5)
1770 1783
1771 1784 This setting can be overridden by a ``context`` request parameter to the
1772 1785 ``comparison`` command, taking the same values.
1773 1786
1774 1787 ``contact``
1775 1788 Name or email address of the person in charge of the repository.
1776 1789 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
1777 1790
1778 1791 ``deny_push``
1779 1792 Whether to deny pushing to the repository. If empty or not set,
1780 1793 push is not denied. If the special value ``*``, all remote users are
1781 1794 denied push. Otherwise, unauthenticated users are all denied, and
1782 1795 any authenticated user name present in this list is also denied. The
1783 1796 contents of the deny_push list are examined before the allow_push list.
1784 1797
1785 1798 ``deny_read``
1786 1799 Whether to deny reading/viewing of the repository. If this list is
1787 1800 not empty, unauthenticated users are all denied, and any
1788 1801 authenticated user name present in this list is also denied access to
1789 1802 the repository. If set to the special value ``*``, all remote users
1790 1803 are denied access (rarely needed ;). If deny_read is empty or not set,
1791 1804 the determination of repository access depends on the presence and
1792 1805 content of the allow_read list (see description). If both
1793 1806 deny_read and allow_read are empty or not set, then access is
1794 1807 permitted to all users by default. If the repository is being
1795 1808 served via hgwebdir, denied users will not be able to see it in
1796 1809 the list of repositories. The contents of the deny_read list have
1797 1810 priority over (are examined before) the contents of the allow_read
1798 1811 list.
1799 1812
1800 1813 ``descend``
1801 1814 hgwebdir indexes will not descend into subdirectories. Only repositories
1802 1815 directly in the current path will be shown (other repositories are still
1803 1816 available from the index corresponding to their containing path).
1804 1817
1805 1818 ``description``
1806 1819 Textual description of the repository's purpose or contents.
1807 1820 (default: "unknown")
1808 1821
1809 1822 ``encoding``
1810 1823 Character encoding name. (default: the current locale charset)
1811 1824 Example: "UTF-8".
1812 1825
1813 1826 ``errorlog``
1814 1827 Where to output the error log. (default: stderr)
1815 1828
1816 1829 ``guessmime``
1817 1830 Control MIME types for raw download of file content.
1818 1831 Set to True to let hgweb guess the content type from the file
1819 1832 extension. This will serve HTML files as ``text/html`` and might
1820 1833 allow cross-site scripting attacks when serving untrusted
1821 1834 repositories. (default: False)
1822 1835
1823 1836 ``hidden``
1824 1837 Whether to hide the repository in the hgwebdir index.
1825 1838 (default: False)
1826 1839
1827 1840 ``ipv6``
1828 1841 Whether to use IPv6. (default: False)
1829 1842
1830 1843 ``logoimg``
1831 1844 File name of the logo image that some templates display on each page.
1832 1845 The file name is relative to ``staticurl``. That is, the full path to
1833 1846 the logo image is "staticurl/logoimg".
1834 1847 If unset, ``hglogo.png`` will be used.
1835 1848
1836 1849 ``logourl``
1837 1850 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
1838 1851 will be used.
1839 1852
1840 1853 ``maxchanges``
1841 1854 Maximum number of changes to list on the changelog. (default: 10)
1842 1855
1843 1856 ``maxfiles``
1844 1857 Maximum number of files to list per changeset. (default: 10)
1845 1858
1846 1859 ``maxshortchanges``
1847 1860 Maximum number of changes to list on the shortlog, graph or filelog
1848 1861 pages. (default: 60)
1849 1862
1850 1863 ``name``
1851 1864 Repository name to use in the web interface.
1852 1865 (default: current working directory)
1853 1866
1854 1867 ``port``
1855 1868 Port to listen on. (default: 8000)
1856 1869
1857 1870 ``prefix``
1858 1871 Prefix path to serve from. (default: '' (server root))
1859 1872
1860 1873 ``push_ssl``
1861 1874 Whether to require that inbound pushes be transported over SSL to
1862 1875 prevent password sniffing. (default: True)
1863 1876
1864 1877 ``refreshinterval``
1865 1878 How frequently directory listings re-scan the filesystem for new
1866 1879 repositories, in seconds. This is relevant when wildcards are used
1867 1880 to define paths. Depending on how much filesystem traversal is
1868 1881 required, refreshing may negatively impact performance.
1869 1882
1870 1883 Values less than or equal to 0 always refresh.
1871 1884 (default: 20)
1872 1885
1873 1886 ``staticurl``
1874 1887 Base URL to use for static files. If unset, static files (e.g. the
1875 1888 hgicon.png favicon) will be served by the CGI script itself. Use
1876 1889 this setting to serve them directly with the HTTP server.
1877 1890 Example: ``http://hgserver/static/``.
1878 1891
1879 1892 ``stripes``
1880 1893 How many lines a "zebra stripe" should span in multi-line output.
1881 1894 Set to 0 to disable. (default: 1)
1882 1895
1883 1896 ``style``
1884 1897 Which template map style to use. The available options are the names of
1885 1898 subdirectories in the HTML templates path. (default: ``paper``)
1886 1899 Example: ``monoblue``.
1887 1900
1888 1901 ``templates``
1889 1902 Where to find the HTML templates. The default path to the HTML templates
1890 1903 can be obtained from ``hg debuginstall``.
1891 1904
1892 1905 ``websub``
1893 1906 ----------
1894 1907
1895 1908 Web substitution filter definition. You can use this section to
1896 1909 define a set of regular expression substitution patterns which
1897 1910 let you automatically modify the hgweb server output.
1898 1911
1899 1912 The default hgweb templates only apply these substitution patterns
1900 1913 on the revision description fields. You can apply them anywhere
1901 1914 you want when you create your own templates by adding calls to the
1902 1915 "websub" filter (usually after calling the "escape" filter).
1903 1916
1904 1917 This can be used, for example, to convert issue references to links
1905 1918 to your issue tracker, or to convert "markdown-like" syntax into
1906 1919 HTML (see the examples below).
1907 1920
1908 1921 Each entry in this section names a substitution filter.
1909 1922 The value of each entry defines the substitution expression itself.
1910 1923 The websub expressions follow the old interhg extension syntax,
1911 1924 which in turn imitates the Unix sed replacement syntax::
1912 1925
1913 1926 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
1914 1927
1915 1928 You can use any separator other than "/". The final "i" is optional
1916 1929 and indicates that the search must be case insensitive.
1917 1930
1918 1931 Examples::
1919 1932
1920 1933 [websub]
1921 1934 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
1922 1935 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
1923 1936 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
1924 1937
1925 1938 ``worker``
1926 1939 ----------
1927 1940
1928 1941 Parallel master/worker configuration. We currently perform working
1929 1942 directory updates in parallel on Unix-like systems, which greatly
1930 1943 helps performance.
1931 1944
1932 1945 ``numcpus``
1933 1946 Number of CPUs to use for parallel operations. A zero or
1934 1947 negative value is treated as ``use the default``.
1935 1948 (default: 4 or the number of CPUs on the system, whichever is larger)
@@ -1,1560 +1,1573 b''
1 1 # merge.py - directory-level update/merge handling for Mercurial
2 2 #
3 3 # Copyright 2006, 2007 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 __future__ import absolute_import
9 9
10 10 import errno
11 11 import os
12 12 import shutil
13 13 import struct
14 14
15 15 from .i18n import _
16 16 from .node import (
17 17 bin,
18 18 hex,
19 19 nullhex,
20 20 nullid,
21 21 nullrev,
22 22 )
23 23 from . import (
24 24 copies,
25 25 destutil,
26 26 error,
27 27 filemerge,
28 28 obsolete,
29 29 scmutil,
30 30 subrepo,
31 31 util,
32 32 worker,
33 33 )
34 34
35 35 _pack = struct.pack
36 36 _unpack = struct.unpack
37 37
38 38 def _droponode(data):
39 39 # used for compatibility for v1
40 40 bits = data.split('\0')
41 41 bits = bits[:-2] + bits[-1:]
42 42 return '\0'.join(bits)
43 43
44 44 class mergestate(object):
45 45 '''track 3-way merge state of individual files
46 46
47 47 The merge state is stored on disk when needed. Two files are used: one with
48 48 an old format (version 1), and one with a new format (version 2). Version 2
49 49 stores a superset of the data in version 1, including new kinds of records
50 50 in the future. For more about the new format, see the documentation for
51 51 `_readrecordsv2`.
52 52
53 53 Each record can contain arbitrary content, and has an associated type. This
54 54 `type` should be a letter. If `type` is uppercase, the record is mandatory:
55 55 versions of Mercurial that don't support it should abort. If `type` is
56 56 lowercase, the record can be safely ignored.
57 57
58 58 Currently known records:
59 59
60 60 L: the node of the "local" part of the merge (hexified version)
61 61 O: the node of the "other" part of the merge (hexified version)
62 62 F: a file to be merged entry
63 63 C: a change/delete or delete/change conflict
64 64 D: a file that the external merge driver will merge internally
65 65 (experimental)
66 66 m: the external merge driver defined for this merge plus its run state
67 67 (experimental)
68 68 X: unsupported mandatory record type (used in tests)
69 69 x: unsupported advisory record type (used in tests)
70 70
71 71 Merge driver run states (experimental):
72 72 u: driver-resolved files unmarked -- needs to be run next time we're about
73 73 to resolve or commit
74 74 m: driver-resolved files marked -- only needs to be run before commit
75 75 s: success/skipped -- does not need to be run any more
76 76
77 77 '''
78 78 statepathv1 = 'merge/state'
79 79 statepathv2 = 'merge/state2'
80 80
81 81 @staticmethod
82 82 def clean(repo, node=None, other=None):
83 83 """Initialize a brand new merge state, removing any existing state on
84 84 disk."""
85 85 ms = mergestate(repo)
86 86 ms.reset(node, other)
87 87 return ms
88 88
89 89 @staticmethod
90 90 def read(repo):
91 91 """Initialize the merge state, reading it from disk."""
92 92 ms = mergestate(repo)
93 93 ms._read()
94 94 return ms
95 95
96 96 def __init__(self, repo):
97 97 """Initialize the merge state.
98 98
99 99 Do not use this directly! Instead call read() or clean()."""
100 100 self._repo = repo
101 101 self._dirty = False
102 102
103 103 def reset(self, node=None, other=None):
104 104 self._state = {}
105 105 self._local = None
106 106 self._other = None
107 107 for var in ('localctx', 'otherctx'):
108 108 if var in vars(self):
109 109 delattr(self, var)
110 110 if node:
111 111 self._local = node
112 112 self._other = other
113 113 self._readmergedriver = None
114 114 if self.mergedriver:
115 115 self._mdstate = 's'
116 116 else:
117 117 self._mdstate = 'u'
118 118 shutil.rmtree(self._repo.join('merge'), True)
119 119 self._results = {}
120 120 self._dirty = False
121 121
122 122 def _read(self):
123 123 """Analyse each record content to restore a serialized state from disk
124 124
125 125 This function process "record" entry produced by the de-serialization
126 126 of on disk file.
127 127 """
128 128 self._state = {}
129 129 self._local = None
130 130 self._other = None
131 131 for var in ('localctx', 'otherctx'):
132 132 if var in vars(self):
133 133 delattr(self, var)
134 134 self._readmergedriver = None
135 135 self._mdstate = 's'
136 136 unsupported = set()
137 137 records = self._readrecords()
138 138 for rtype, record in records:
139 139 if rtype == 'L':
140 140 self._local = bin(record)
141 141 elif rtype == 'O':
142 142 self._other = bin(record)
143 143 elif rtype == 'm':
144 144 bits = record.split('\0', 1)
145 145 mdstate = bits[1]
146 146 if len(mdstate) != 1 or mdstate not in 'ums':
147 147 # the merge driver should be idempotent, so just rerun it
148 148 mdstate = 'u'
149 149
150 150 self._readmergedriver = bits[0]
151 151 self._mdstate = mdstate
152 152 elif rtype in 'FDC':
153 153 bits = record.split('\0')
154 154 self._state[bits[0]] = bits[1:]
155 155 elif not rtype.islower():
156 156 unsupported.add(rtype)
157 157 self._results = {}
158 158 self._dirty = False
159 159
160 160 if unsupported:
161 161 raise error.UnsupportedMergeRecords(unsupported)
162 162
163 163 def _readrecords(self):
164 164 """Read merge state from disk and return a list of record (TYPE, data)
165 165
166 166 We read data from both v1 and v2 files and decide which one to use.
167 167
168 168 V1 has been used by version prior to 2.9.1 and contains less data than
169 169 v2. We read both versions and check if no data in v2 contradicts
170 170 v1. If there is not contradiction we can safely assume that both v1
171 171 and v2 were written at the same time and use the extract data in v2. If
172 172 there is contradiction we ignore v2 content as we assume an old version
173 173 of Mercurial has overwritten the mergestate file and left an old v2
174 174 file around.
175 175
176 176 returns list of record [(TYPE, data), ...]"""
177 177 v1records = self._readrecordsv1()
178 178 v2records = self._readrecordsv2()
179 179 if self._v1v2match(v1records, v2records):
180 180 return v2records
181 181 else:
182 182 # v1 file is newer than v2 file, use it
183 183 # we have to infer the "other" changeset of the merge
184 184 # we cannot do better than that with v1 of the format
185 185 mctx = self._repo[None].parents()[-1]
186 186 v1records.append(('O', mctx.hex()))
187 187 # add place holder "other" file node information
188 188 # nobody is using it yet so we do no need to fetch the data
189 189 # if mctx was wrong `mctx[bits[-2]]` may fails.
190 190 for idx, r in enumerate(v1records):
191 191 if r[0] == 'F':
192 192 bits = r[1].split('\0')
193 193 bits.insert(-2, '')
194 194 v1records[idx] = (r[0], '\0'.join(bits))
195 195 return v1records
196 196
197 197 def _v1v2match(self, v1records, v2records):
198 198 oldv2 = set() # old format version of v2 record
199 199 for rec in v2records:
200 200 if rec[0] == 'L':
201 201 oldv2.add(rec)
202 202 elif rec[0] == 'F':
203 203 # drop the onode data (not contained in v1)
204 204 oldv2.add(('F', _droponode(rec[1])))
205 205 for rec in v1records:
206 206 if rec not in oldv2:
207 207 return False
208 208 else:
209 209 return True
210 210
211 211 def _readrecordsv1(self):
212 212 """read on disk merge state for version 1 file
213 213
214 214 returns list of record [(TYPE, data), ...]
215 215
216 216 Note: the "F" data from this file are one entry short
217 217 (no "other file node" entry)
218 218 """
219 219 records = []
220 220 try:
221 221 f = self._repo.vfs(self.statepathv1)
222 222 for i, l in enumerate(f):
223 223 if i == 0:
224 224 records.append(('L', l[:-1]))
225 225 else:
226 226 records.append(('F', l[:-1]))
227 227 f.close()
228 228 except IOError as err:
229 229 if err.errno != errno.ENOENT:
230 230 raise
231 231 return records
232 232
233 233 def _readrecordsv2(self):
234 234 """read on disk merge state for version 2 file
235 235
236 236 This format is a list of arbitrary records of the form:
237 237
238 238 [type][length][content]
239 239
240 240 `type` is a single character, `length` is a 4 byte integer, and
241 241 `content` is an arbitrary byte sequence of length `length`.
242 242
243 243 Mercurial versions prior to 3.7 have a bug where if there are
244 244 unsupported mandatory merge records, attempting to clear out the merge
245 245 state with hg update --clean or similar aborts. The 't' record type
246 246 works around that by writing out what those versions treat as an
247 247 advisory record, but later versions interpret as special: the first
248 248 character is the 'real' record type and everything onwards is the data.
249 249
250 250 Returns list of records [(TYPE, data), ...]."""
251 251 records = []
252 252 try:
253 253 f = self._repo.vfs(self.statepathv2)
254 254 data = f.read()
255 255 off = 0
256 256 end = len(data)
257 257 while off < end:
258 258 rtype = data[off]
259 259 off += 1
260 260 length = _unpack('>I', data[off:(off + 4)])[0]
261 261 off += 4
262 262 record = data[off:(off + length)]
263 263 off += length
264 264 if rtype == 't':
265 265 rtype, record = record[0], record[1:]
266 266 records.append((rtype, record))
267 267 f.close()
268 268 except IOError as err:
269 269 if err.errno != errno.ENOENT:
270 270 raise
271 271 return records
272 272
273 273 @util.propertycache
274 274 def mergedriver(self):
275 275 # protect against the following:
276 276 # - A configures a malicious merge driver in their hgrc, then
277 277 # pauses the merge
278 278 # - A edits their hgrc to remove references to the merge driver
279 279 # - A gives a copy of their entire repo, including .hg, to B
280 280 # - B inspects .hgrc and finds it to be clean
281 281 # - B then continues the merge and the malicious merge driver
282 282 # gets invoked
283 283 configmergedriver = self._repo.ui.config('experimental', 'mergedriver')
284 284 if (self._readmergedriver is not None
285 285 and self._readmergedriver != configmergedriver):
286 286 raise error.ConfigError(
287 287 _("merge driver changed since merge started"),
288 288 hint=_("revert merge driver change or abort merge"))
289 289
290 290 return configmergedriver
291 291
292 292 @util.propertycache
293 293 def localctx(self):
294 294 if self._local is None:
295 295 raise RuntimeError("localctx accessed but self._local isn't set")
296 296 return self._repo[self._local]
297 297
298 298 @util.propertycache
299 299 def otherctx(self):
300 300 if self._other is None:
301 301 raise RuntimeError("localctx accessed but self._local isn't set")
302 302 return self._repo[self._other]
303 303
304 304 def active(self):
305 305 """Whether mergestate is active.
306 306
307 307 Returns True if there appears to be mergestate. This is a rough proxy
308 308 for "is a merge in progress."
309 309 """
310 310 # Check local variables before looking at filesystem for performance
311 311 # reasons.
312 312 return bool(self._local) or bool(self._state) or \
313 313 self._repo.vfs.exists(self.statepathv1) or \
314 314 self._repo.vfs.exists(self.statepathv2)
315 315
316 316 def commit(self):
317 317 """Write current state on disk (if necessary)"""
318 318 if self._dirty:
319 319 records = self._makerecords()
320 320 self._writerecords(records)
321 321 self._dirty = False
322 322
323 323 def _makerecords(self):
324 324 records = []
325 325 records.append(('L', hex(self._local)))
326 326 records.append(('O', hex(self._other)))
327 327 if self.mergedriver:
328 328 records.append(('m', '\0'.join([
329 329 self.mergedriver, self._mdstate])))
330 330 for d, v in self._state.iteritems():
331 331 if v[0] == 'd':
332 332 records.append(('D', '\0'.join([d] + v)))
333 333 # v[1] == local ('cd'), v[6] == other ('dc') -- not supported by
334 334 # older versions of Mercurial
335 335 elif v[1] == nullhex or v[6] == nullhex:
336 336 records.append(('C', '\0'.join([d] + v)))
337 337 else:
338 338 records.append(('F', '\0'.join([d] + v)))
339 339 return records
340 340
341 341 def _writerecords(self, records):
342 342 """Write current state on disk (both v1 and v2)"""
343 343 self._writerecordsv1(records)
344 344 self._writerecordsv2(records)
345 345
346 346 def _writerecordsv1(self, records):
347 347 """Write current state on disk in a version 1 file"""
348 348 f = self._repo.vfs(self.statepathv1, 'w')
349 349 irecords = iter(records)
350 350 lrecords = irecords.next()
351 351 assert lrecords[0] == 'L'
352 352 f.write(hex(self._local) + '\n')
353 353 for rtype, data in irecords:
354 354 if rtype == 'F':
355 355 f.write('%s\n' % _droponode(data))
356 356 f.close()
357 357
358 358 def _writerecordsv2(self, records):
359 359 """Write current state on disk in a version 2 file
360 360
361 361 See the docstring for _readrecordsv2 for why we use 't'."""
362 362 # these are the records that all version 2 clients can read
363 363 whitelist = 'LOF'
364 364 f = self._repo.vfs(self.statepathv2, 'w')
365 365 for key, data in records:
366 366 assert len(key) == 1
367 367 if key not in whitelist:
368 368 key, data = 't', '%s%s' % (key, data)
369 369 format = '>sI%is' % len(data)
370 370 f.write(_pack(format, key, len(data), data))
371 371 f.close()
372 372
373 373 def add(self, fcl, fco, fca, fd):
374 374 """add a new (potentially?) conflicting file the merge state
375 375 fcl: file context for local,
376 376 fco: file context for remote,
377 377 fca: file context for ancestors,
378 378 fd: file path of the resulting merge.
379 379
380 380 note: also write the local version to the `.hg/merge` directory.
381 381 """
382 382 if fcl.isabsent():
383 383 hash = nullhex
384 384 else:
385 385 hash = util.sha1(fcl.path()).hexdigest()
386 386 self._repo.vfs.write('merge/' + hash, fcl.data())
387 387 self._state[fd] = ['u', hash, fcl.path(),
388 388 fca.path(), hex(fca.filenode()),
389 389 fco.path(), hex(fco.filenode()),
390 390 fcl.flags()]
391 391 self._dirty = True
392 392
393 393 def __contains__(self, dfile):
394 394 return dfile in self._state
395 395
396 396 def __getitem__(self, dfile):
397 397 return self._state[dfile][0]
398 398
399 399 def __iter__(self):
400 400 return iter(sorted(self._state))
401 401
402 402 def files(self):
403 403 return self._state.keys()
404 404
405 405 def mark(self, dfile, state):
406 406 self._state[dfile][0] = state
407 407 self._dirty = True
408 408
409 409 def mdstate(self):
410 410 return self._mdstate
411 411
412 412 def unresolved(self):
413 413 """Obtain the paths of unresolved files."""
414 414
415 415 for f, entry in self._state.items():
416 416 if entry[0] == 'u':
417 417 yield f
418 418
419 419 def driverresolved(self):
420 420 """Obtain the paths of driver-resolved files."""
421 421
422 422 for f, entry in self._state.items():
423 423 if entry[0] == 'd':
424 424 yield f
425 425
426 426 def _resolve(self, preresolve, dfile, wctx, labels=None):
427 427 """rerun merge process for file path `dfile`"""
428 428 if self[dfile] in 'rd':
429 429 return True, 0
430 430 stateentry = self._state[dfile]
431 431 state, hash, lfile, afile, anode, ofile, onode, flags = stateentry
432 432 octx = self._repo[self._other]
433 433 fcd = self._filectxorabsent(hash, wctx, dfile)
434 434 fco = self._filectxorabsent(onode, octx, ofile)
435 435 # TODO: move this to filectxorabsent
436 436 fca = self._repo.filectx(afile, fileid=anode)
437 437 # "premerge" x flags
438 438 flo = fco.flags()
439 439 fla = fca.flags()
440 440 if 'x' in flags + flo + fla and 'l' not in flags + flo + fla:
441 441 if fca.node() == nullid:
442 442 if preresolve:
443 443 self._repo.ui.warn(
444 444 _('warning: cannot merge flags for %s\n') % afile)
445 445 elif flags == fla:
446 446 flags = flo
447 447 if preresolve:
448 448 # restore local
449 449 if hash != nullhex:
450 450 f = self._repo.vfs('merge/' + hash)
451 451 self._repo.wwrite(dfile, f.read(), flags)
452 452 f.close()
453 453 else:
454 454 self._repo.wvfs.unlinkpath(dfile, ignoremissing=True)
455 455 complete, r, deleted = filemerge.premerge(self._repo, self._local,
456 456 lfile, fcd, fco, fca,
457 457 labels=labels)
458 458 else:
459 459 complete, r, deleted = filemerge.filemerge(self._repo, self._local,
460 460 lfile, fcd, fco, fca,
461 461 labels=labels)
462 462 if r is None:
463 463 # no real conflict
464 464 del self._state[dfile]
465 465 self._dirty = True
466 466 elif not r:
467 467 self.mark(dfile, 'r')
468 468
469 469 if complete:
470 470 action = None
471 471 if deleted:
472 472 if fcd.isabsent():
473 473 # dc: local picked. Need to drop if present, which may
474 474 # happen on re-resolves.
475 475 action = 'f'
476 476 else:
477 477 # cd: remote picked (or otherwise deleted)
478 478 action = 'r'
479 479 else:
480 480 if fcd.isabsent(): # dc: remote picked
481 481 action = 'g'
482 482 elif fco.isabsent(): # cd: local picked
483 483 if dfile in self.localctx:
484 484 action = 'am'
485 485 else:
486 486 action = 'a'
487 487 # else: regular merges (no action necessary)
488 488 self._results[dfile] = r, action
489 489
490 490 return complete, r
491 491
492 492 def _filectxorabsent(self, hexnode, ctx, f):
493 493 if hexnode == nullhex:
494 494 return filemerge.absentfilectx(ctx, f)
495 495 else:
496 496 return ctx[f]
497 497
498 498 def preresolve(self, dfile, wctx, labels=None):
499 499 """run premerge process for dfile
500 500
501 501 Returns whether the merge is complete, and the exit code."""
502 502 return self._resolve(True, dfile, wctx, labels=labels)
503 503
504 504 def resolve(self, dfile, wctx, labels=None):
505 505 """run merge process (assuming premerge was run) for dfile
506 506
507 507 Returns the exit code of the merge."""
508 508 return self._resolve(False, dfile, wctx, labels=labels)[1]
509 509
510 510 def counts(self):
511 511 """return counts for updated, merged and removed files in this
512 512 session"""
513 513 updated, merged, removed = 0, 0, 0
514 514 for r, action in self._results.itervalues():
515 515 if r is None:
516 516 updated += 1
517 517 elif r == 0:
518 518 if action == 'r':
519 519 removed += 1
520 520 else:
521 521 merged += 1
522 522 return updated, merged, removed
523 523
524 524 def unresolvedcount(self):
525 525 """get unresolved count for this merge (persistent)"""
526 526 return len([True for f, entry in self._state.iteritems()
527 527 if entry[0] == 'u'])
528 528
529 529 def actions(self):
530 530 """return lists of actions to perform on the dirstate"""
531 531 actions = {'r': [], 'f': [], 'a': [], 'am': [], 'g': []}
532 532 for f, (r, action) in self._results.iteritems():
533 533 if action is not None:
534 534 actions[action].append((f, None, "merge result"))
535 535 return actions
536 536
537 537 def recordactions(self):
538 538 """record remove/add/get actions in the dirstate"""
539 539 branchmerge = self._repo.dirstate.p2() != nullid
540 540 recordupdates(self._repo, self.actions(), branchmerge)
541 541
542 542 def queueremove(self, f):
543 543 """queues a file to be removed from the dirstate
544 544
545 545 Meant for use by custom merge drivers."""
546 546 self._results[f] = 0, 'r'
547 547
548 548 def queueadd(self, f):
549 549 """queues a file to be added to the dirstate
550 550
551 551 Meant for use by custom merge drivers."""
552 552 self._results[f] = 0, 'a'
553 553
554 554 def queueget(self, f):
555 555 """queues a file to be marked modified in the dirstate
556 556
557 557 Meant for use by custom merge drivers."""
558 558 self._results[f] = 0, 'g'
559 559
560 560 def _checkunknownfile(repo, wctx, mctx, f, f2=None):
561 561 if f2 is None:
562 562 f2 = f
563 563 return (repo.wvfs.isfileorlink(f)
564 564 and repo.wvfs.audit.check(f)
565 565 and repo.dirstate.normalize(f) not in repo.dirstate
566 566 and mctx[f2].cmp(wctx[f]))
567 567
568 568 def _checkunknownfiles(repo, wctx, mctx, force, actions):
569 569 """
570 570 Considers any actions that care about the presence of conflicting unknown
571 571 files. For some actions, the result is to abort; for others, it is to
572 572 choose a different action.
573 573 """
574 574 conflicts = set()
575 575 if not force:
576 config = repo.ui.config('merge', 'checkunknown', default='abort')
577 valid = ['abort', 'ignore', 'warn']
578 if config not in valid:
579 validstr = ', '.join(["'" + v + "'" for v in valid])
580 raise error.ConfigError(_("merge.checkunknown not valid "
581 "('%s' is none of %s)")
582 % (config, validstr))
583
576 584 for f, (m, args, msg) in actions.iteritems():
577 585 if m in ('c', 'dc'):
578 586 if _checkunknownfile(repo, wctx, mctx, f):
579 587 conflicts.add(f)
580 588 elif m == 'dg':
581 589 if _checkunknownfile(repo, wctx, mctx, f, args[0]):
582 590 conflicts.add(f)
583 591
584 for f in sorted(conflicts):
585 repo.ui.warn(_("%s: untracked file differs\n") % f)
586 if conflicts:
587 raise error.Abort(_("untracked files in working directory differ "
588 "from files in requested revision"))
592 if config == 'abort':
593 for f in sorted(conflicts):
594 repo.ui.warn(_("%s: untracked file differs\n") % f)
595 if conflicts:
596 raise error.Abort(_("untracked files in working directory "
597 "differ from files in requested revision"))
598 elif config == 'warn':
599 for f in sorted(conflicts):
600 repo.ui.warn(_("%s: replacing untracked file\n") % f)
589 601
590 602 for f, (m, args, msg) in actions.iteritems():
603 backup = f in conflicts
591 604 if m == 'c':
592 605 flags, = args
593 actions[f] = ('g', (flags, False), msg)
606 actions[f] = ('g', (flags, backup), msg)
594 607 elif m == 'cm':
595 608 fl2, anc = args
596 609 different = _checkunknownfile(repo, wctx, mctx, f)
597 610 if different:
598 611 actions[f] = ('m', (f, f, None, False, anc),
599 612 "remote differs from untracked local")
600 613 else:
601 actions[f] = ('g', (fl2, False), "remote created")
614 actions[f] = ('g', (fl2, backup), "remote created")
602 615
603 616 def _forgetremoved(wctx, mctx, branchmerge):
604 617 """
605 618 Forget removed files
606 619
607 620 If we're jumping between revisions (as opposed to merging), and if
608 621 neither the working directory nor the target rev has the file,
609 622 then we need to remove it from the dirstate, to prevent the
610 623 dirstate from listing the file when it is no longer in the
611 624 manifest.
612 625
613 626 If we're merging, and the other revision has removed a file
614 627 that is not present in the working directory, we need to mark it
615 628 as removed.
616 629 """
617 630
618 631 actions = {}
619 632 m = 'f'
620 633 if branchmerge:
621 634 m = 'r'
622 635 for f in wctx.deleted():
623 636 if f not in mctx:
624 637 actions[f] = m, None, "forget deleted"
625 638
626 639 if not branchmerge:
627 640 for f in wctx.removed():
628 641 if f not in mctx:
629 642 actions[f] = 'f', None, "forget removed"
630 643
631 644 return actions
632 645
633 646 def _checkcollision(repo, wmf, actions):
634 647 # build provisional merged manifest up
635 648 pmmf = set(wmf)
636 649
637 650 if actions:
638 651 # k, dr, e and rd are no-op
639 652 for m in 'a', 'am', 'f', 'g', 'cd', 'dc':
640 653 for f, args, msg in actions[m]:
641 654 pmmf.add(f)
642 655 for f, args, msg in actions['r']:
643 656 pmmf.discard(f)
644 657 for f, args, msg in actions['dm']:
645 658 f2, flags = args
646 659 pmmf.discard(f2)
647 660 pmmf.add(f)
648 661 for f, args, msg in actions['dg']:
649 662 pmmf.add(f)
650 663 for f, args, msg in actions['m']:
651 664 f1, f2, fa, move, anc = args
652 665 if move:
653 666 pmmf.discard(f1)
654 667 pmmf.add(f)
655 668
656 669 # check case-folding collision in provisional merged manifest
657 670 foldmap = {}
658 671 for f in sorted(pmmf):
659 672 fold = util.normcase(f)
660 673 if fold in foldmap:
661 674 raise error.Abort(_("case-folding collision between %s and %s")
662 675 % (f, foldmap[fold]))
663 676 foldmap[fold] = f
664 677
665 678 # check case-folding of directories
666 679 foldprefix = unfoldprefix = lastfull = ''
667 680 for fold, f in sorted(foldmap.items()):
668 681 if fold.startswith(foldprefix) and not f.startswith(unfoldprefix):
669 682 # the folded prefix matches but actual casing is different
670 683 raise error.Abort(_("case-folding collision between "
671 684 "%s and directory of %s") % (lastfull, f))
672 685 foldprefix = fold + '/'
673 686 unfoldprefix = f + '/'
674 687 lastfull = f
675 688
676 689 def driverpreprocess(repo, ms, wctx, labels=None):
677 690 """run the preprocess step of the merge driver, if any
678 691
679 692 This is currently not implemented -- it's an extension point."""
680 693 return True
681 694
682 695 def driverconclude(repo, ms, wctx, labels=None):
683 696 """run the conclude step of the merge driver, if any
684 697
685 698 This is currently not implemented -- it's an extension point."""
686 699 return True
687 700
688 701 def manifestmerge(repo, wctx, p2, pa, branchmerge, force, matcher,
689 702 acceptremote, followcopies):
690 703 """
691 704 Merge p1 and p2 with ancestor pa and generate merge action list
692 705
693 706 branchmerge and force are as passed in to update
694 707 matcher = matcher to filter file lists
695 708 acceptremote = accept the incoming changes without prompting
696 709 """
697 710 if matcher is not None and matcher.always():
698 711 matcher = None
699 712
700 713 copy, movewithdir, diverge, renamedelete = {}, {}, {}, {}
701 714
702 715 # manifests fetched in order are going to be faster, so prime the caches
703 716 [x.manifest() for x in
704 717 sorted(wctx.parents() + [p2, pa], key=lambda x: x.rev())]
705 718
706 719 if followcopies:
707 720 ret = copies.mergecopies(repo, wctx, p2, pa)
708 721 copy, movewithdir, diverge, renamedelete = ret
709 722
710 723 repo.ui.note(_("resolving manifests\n"))
711 724 repo.ui.debug(" branchmerge: %s, force: %s, partial: %s\n"
712 725 % (bool(branchmerge), bool(force), bool(matcher)))
713 726 repo.ui.debug(" ancestor: %s, local: %s, remote: %s\n" % (pa, wctx, p2))
714 727
715 728 m1, m2, ma = wctx.manifest(), p2.manifest(), pa.manifest()
716 729 copied = set(copy.values())
717 730 copied.update(movewithdir.values())
718 731
719 732 if '.hgsubstate' in m1:
720 733 # check whether sub state is modified
721 734 for s in sorted(wctx.substate):
722 735 if wctx.sub(s).dirty():
723 736 m1['.hgsubstate'] += '+'
724 737 break
725 738
726 739 # Compare manifests
727 740 if matcher is not None:
728 741 m1 = m1.matches(matcher)
729 742 m2 = m2.matches(matcher)
730 743 diff = m1.diff(m2)
731 744
732 745 actions = {}
733 746 for f, ((n1, fl1), (n2, fl2)) in diff.iteritems():
734 747 if n1 and n2: # file exists on both local and remote side
735 748 if f not in ma:
736 749 fa = copy.get(f, None)
737 750 if fa is not None:
738 751 actions[f] = ('m', (f, f, fa, False, pa.node()),
739 752 "both renamed from " + fa)
740 753 else:
741 754 actions[f] = ('m', (f, f, None, False, pa.node()),
742 755 "both created")
743 756 else:
744 757 a = ma[f]
745 758 fla = ma.flags(f)
746 759 nol = 'l' not in fl1 + fl2 + fla
747 760 if n2 == a and fl2 == fla:
748 761 actions[f] = ('k' , (), "remote unchanged")
749 762 elif n1 == a and fl1 == fla: # local unchanged - use remote
750 763 if n1 == n2: # optimization: keep local content
751 764 actions[f] = ('e', (fl2,), "update permissions")
752 765 else:
753 766 actions[f] = ('g', (fl2, False), "remote is newer")
754 767 elif nol and n2 == a: # remote only changed 'x'
755 768 actions[f] = ('e', (fl2,), "update permissions")
756 769 elif nol and n1 == a: # local only changed 'x'
757 770 actions[f] = ('g', (fl1, False), "remote is newer")
758 771 else: # both changed something
759 772 actions[f] = ('m', (f, f, f, False, pa.node()),
760 773 "versions differ")
761 774 elif n1: # file exists only on local side
762 775 if f in copied:
763 776 pass # we'll deal with it on m2 side
764 777 elif f in movewithdir: # directory rename, move local
765 778 f2 = movewithdir[f]
766 779 if f2 in m2:
767 780 actions[f2] = ('m', (f, f2, None, True, pa.node()),
768 781 "remote directory rename, both created")
769 782 else:
770 783 actions[f2] = ('dm', (f, fl1),
771 784 "remote directory rename - move from " + f)
772 785 elif f in copy:
773 786 f2 = copy[f]
774 787 actions[f] = ('m', (f, f2, f2, False, pa.node()),
775 788 "local copied/moved from " + f2)
776 789 elif f in ma: # clean, a different, no remote
777 790 if n1 != ma[f]:
778 791 if acceptremote:
779 792 actions[f] = ('r', None, "remote delete")
780 793 else:
781 794 actions[f] = ('cd', (f, None, f, False, pa.node()),
782 795 "prompt changed/deleted")
783 796 elif n1[20:] == 'a':
784 797 # This extra 'a' is added by working copy manifest to mark
785 798 # the file as locally added. We should forget it instead of
786 799 # deleting it.
787 800 actions[f] = ('f', None, "remote deleted")
788 801 else:
789 802 actions[f] = ('r', None, "other deleted")
790 803 elif n2: # file exists only on remote side
791 804 if f in copied:
792 805 pass # we'll deal with it on m1 side
793 806 elif f in movewithdir:
794 807 f2 = movewithdir[f]
795 808 if f2 in m1:
796 809 actions[f2] = ('m', (f2, f, None, False, pa.node()),
797 810 "local directory rename, both created")
798 811 else:
799 812 actions[f2] = ('dg', (f, fl2),
800 813 "local directory rename - get from " + f)
801 814 elif f in copy:
802 815 f2 = copy[f]
803 816 if f2 in m2:
804 817 actions[f] = ('m', (f2, f, f2, False, pa.node()),
805 818 "remote copied from " + f2)
806 819 else:
807 820 actions[f] = ('m', (f2, f, f2, True, pa.node()),
808 821 "remote moved from " + f2)
809 822 elif f not in ma:
810 823 # local unknown, remote created: the logic is described by the
811 824 # following table:
812 825 #
813 826 # force branchmerge different | action
814 827 # n * * | create
815 828 # y n * | create
816 829 # y y n | create
817 830 # y y y | merge
818 831 #
819 832 # Checking whether the files are different is expensive, so we
820 833 # don't do that when we can avoid it.
821 834 if not force:
822 835 actions[f] = ('c', (fl2,), "remote created")
823 836 elif not branchmerge:
824 837 actions[f] = ('c', (fl2,), "remote created")
825 838 else:
826 839 actions[f] = ('cm', (fl2, pa.node()),
827 840 "remote created, get or merge")
828 841 elif n2 != ma[f]:
829 842 if acceptremote:
830 843 actions[f] = ('c', (fl2,), "remote recreating")
831 844 else:
832 845 actions[f] = ('dc', (None, f, f, False, pa.node()),
833 846 "prompt deleted/changed")
834 847
835 848 return actions, diverge, renamedelete
836 849
837 850 def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
838 851 """Resolves false conflicts where the nodeid changed but the content
839 852 remained the same."""
840 853
841 854 for f, (m, args, msg) in actions.items():
842 855 if m == 'cd' and f in ancestor and not wctx[f].cmp(ancestor[f]):
843 856 # local did change but ended up with same content
844 857 actions[f] = 'r', None, "prompt same"
845 858 elif m == 'dc' and f in ancestor and not mctx[f].cmp(ancestor[f]):
846 859 # remote did change but ended up with same content
847 860 del actions[f] # don't get = keep local deleted
848 861
849 862 def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force,
850 863 acceptremote, followcopies, matcher=None):
851 864 "Calculate the actions needed to merge mctx into wctx using ancestors"
852 865 if len(ancestors) == 1: # default
853 866 actions, diverge, renamedelete = manifestmerge(
854 867 repo, wctx, mctx, ancestors[0], branchmerge, force, matcher,
855 868 acceptremote, followcopies)
856 869 _checkunknownfiles(repo, wctx, mctx, force, actions)
857 870
858 871 else: # only when merge.preferancestor=* - the default
859 872 repo.ui.note(
860 873 _("note: merging %s and %s using bids from ancestors %s\n") %
861 874 (wctx, mctx, _(' and ').join(str(anc) for anc in ancestors)))
862 875
863 876 # Call for bids
864 877 fbids = {} # mapping filename to bids (action method to list af actions)
865 878 diverge, renamedelete = None, None
866 879 for ancestor in ancestors:
867 880 repo.ui.note(_('\ncalculating bids for ancestor %s\n') % ancestor)
868 881 actions, diverge1, renamedelete1 = manifestmerge(
869 882 repo, wctx, mctx, ancestor, branchmerge, force, matcher,
870 883 acceptremote, followcopies)
871 884 _checkunknownfiles(repo, wctx, mctx, force, actions)
872 885
873 886 # Track the shortest set of warning on the theory that bid
874 887 # merge will correctly incorporate more information
875 888 if diverge is None or len(diverge1) < len(diverge):
876 889 diverge = diverge1
877 890 if renamedelete is None or len(renamedelete) < len(renamedelete1):
878 891 renamedelete = renamedelete1
879 892
880 893 for f, a in sorted(actions.iteritems()):
881 894 m, args, msg = a
882 895 repo.ui.debug(' %s: %s -> %s\n' % (f, msg, m))
883 896 if f in fbids:
884 897 d = fbids[f]
885 898 if m in d:
886 899 d[m].append(a)
887 900 else:
888 901 d[m] = [a]
889 902 else:
890 903 fbids[f] = {m: [a]}
891 904
892 905 # Pick the best bid for each file
893 906 repo.ui.note(_('\nauction for merging merge bids\n'))
894 907 actions = {}
895 908 for f, bids in sorted(fbids.items()):
896 909 # bids is a mapping from action method to list af actions
897 910 # Consensus?
898 911 if len(bids) == 1: # all bids are the same kind of method
899 912 m, l = bids.items()[0]
900 913 if all(a == l[0] for a in l[1:]): # len(bids) is > 1
901 914 repo.ui.note(" %s: consensus for %s\n" % (f, m))
902 915 actions[f] = l[0]
903 916 continue
904 917 # If keep is an option, just do it.
905 918 if 'k' in bids:
906 919 repo.ui.note(" %s: picking 'keep' action\n" % f)
907 920 actions[f] = bids['k'][0]
908 921 continue
909 922 # If there are gets and they all agree [how could they not?], do it.
910 923 if 'g' in bids:
911 924 ga0 = bids['g'][0]
912 925 if all(a == ga0 for a in bids['g'][1:]):
913 926 repo.ui.note(" %s: picking 'get' action\n" % f)
914 927 actions[f] = ga0
915 928 continue
916 929 # TODO: Consider other simple actions such as mode changes
917 930 # Handle inefficient democrazy.
918 931 repo.ui.note(_(' %s: multiple bids for merge action:\n') % f)
919 932 for m, l in sorted(bids.items()):
920 933 for _f, args, msg in l:
921 934 repo.ui.note(' %s -> %s\n' % (msg, m))
922 935 # Pick random action. TODO: Instead, prompt user when resolving
923 936 m, l = bids.items()[0]
924 937 repo.ui.warn(_(' %s: ambiguous merge - picked %s action\n') %
925 938 (f, m))
926 939 actions[f] = l[0]
927 940 continue
928 941 repo.ui.note(_('end of auction\n\n'))
929 942
930 943 _resolvetrivial(repo, wctx, mctx, ancestors[0], actions)
931 944
932 945 if wctx.rev() is None:
933 946 fractions = _forgetremoved(wctx, mctx, branchmerge)
934 947 actions.update(fractions)
935 948
936 949 return actions, diverge, renamedelete
937 950
938 951 def batchremove(repo, actions):
939 952 """apply removes to the working directory
940 953
941 954 yields tuples for progress updates
942 955 """
943 956 verbose = repo.ui.verbose
944 957 unlink = util.unlinkpath
945 958 wjoin = repo.wjoin
946 959 audit = repo.wvfs.audit
947 960 i = 0
948 961 for f, args, msg in actions:
949 962 repo.ui.debug(" %s: %s -> r\n" % (f, msg))
950 963 if verbose:
951 964 repo.ui.note(_("removing %s\n") % f)
952 965 audit(f)
953 966 try:
954 967 unlink(wjoin(f), ignoremissing=True)
955 968 except OSError as inst:
956 969 repo.ui.warn(_("update failed to remove %s: %s!\n") %
957 970 (f, inst.strerror))
958 971 if i == 100:
959 972 yield i, f
960 973 i = 0
961 974 i += 1
962 975 if i > 0:
963 976 yield i, f
964 977
965 978 def batchget(repo, mctx, actions):
966 979 """apply gets to the working directory
967 980
968 981 mctx is the context to get from
969 982
970 983 yields tuples for progress updates
971 984 """
972 985 verbose = repo.ui.verbose
973 986 fctx = mctx.filectx
974 987 wwrite = repo.wwrite
975 988 ui = repo.ui
976 989 i = 0
977 990 for f, (flags, backup), msg in actions:
978 991 repo.ui.debug(" %s: %s -> g\n" % (f, msg))
979 992 if verbose:
980 993 repo.ui.note(_("getting %s\n") % f)
981 994
982 995 if backup:
983 996 absf = repo.wjoin(f)
984 997 orig = scmutil.origpath(ui, repo, absf)
985 998 try:
986 999 # TODO Mercurial has always aborted if an untracked directory
987 1000 # is replaced by a tracked file, or generally with
988 1001 # file/directory merges. This needs to be sorted out.
989 1002 if repo.wvfs.isfileorlink(f):
990 1003 util.rename(absf, orig)
991 1004 except OSError as e:
992 1005 if e.errno != errno.ENOENT:
993 1006 raise
994 1007
995 1008 wwrite(f, fctx(f).data(), flags)
996 1009 if i == 100:
997 1010 yield i, f
998 1011 i = 0
999 1012 i += 1
1000 1013 if i > 0:
1001 1014 yield i, f
1002 1015
1003 1016 def applyupdates(repo, actions, wctx, mctx, overwrite, labels=None):
1004 1017 """apply the merge action list to the working directory
1005 1018
1006 1019 wctx is the working copy context
1007 1020 mctx is the context to be merged into the working copy
1008 1021
1009 1022 Return a tuple of counts (updated, merged, removed, unresolved) that
1010 1023 describes how many files were affected by the update.
1011 1024 """
1012 1025
1013 1026 updated, merged, removed = 0, 0, 0
1014 1027 ms = mergestate.clean(repo, wctx.p1().node(), mctx.node())
1015 1028 moves = []
1016 1029 for m, l in actions.items():
1017 1030 l.sort()
1018 1031
1019 1032 # 'cd' and 'dc' actions are treated like other merge conflicts
1020 1033 mergeactions = sorted(actions['cd'])
1021 1034 mergeactions.extend(sorted(actions['dc']))
1022 1035 mergeactions.extend(actions['m'])
1023 1036 for f, args, msg in mergeactions:
1024 1037 f1, f2, fa, move, anc = args
1025 1038 if f == '.hgsubstate': # merged internally
1026 1039 continue
1027 1040 if f1 is None:
1028 1041 fcl = filemerge.absentfilectx(wctx, fa)
1029 1042 else:
1030 1043 repo.ui.debug(" preserving %s for resolve of %s\n" % (f1, f))
1031 1044 fcl = wctx[f1]
1032 1045 if f2 is None:
1033 1046 fco = filemerge.absentfilectx(mctx, fa)
1034 1047 else:
1035 1048 fco = mctx[f2]
1036 1049 actx = repo[anc]
1037 1050 if fa in actx:
1038 1051 fca = actx[fa]
1039 1052 else:
1040 1053 # TODO: move to absentfilectx
1041 1054 fca = repo.filectx(f1, fileid=nullrev)
1042 1055 ms.add(fcl, fco, fca, f)
1043 1056 if f1 != f and move:
1044 1057 moves.append(f1)
1045 1058
1046 1059 audit = repo.wvfs.audit
1047 1060 _updating = _('updating')
1048 1061 _files = _('files')
1049 1062 progress = repo.ui.progress
1050 1063
1051 1064 # remove renamed files after safely stored
1052 1065 for f in moves:
1053 1066 if os.path.lexists(repo.wjoin(f)):
1054 1067 repo.ui.debug("removing %s\n" % f)
1055 1068 audit(f)
1056 1069 util.unlinkpath(repo.wjoin(f))
1057 1070
1058 1071 numupdates = sum(len(l) for m, l in actions.items() if m != 'k')
1059 1072
1060 1073 if [a for a in actions['r'] if a[0] == '.hgsubstate']:
1061 1074 subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
1062 1075
1063 1076 # remove in parallel (must come first)
1064 1077 z = 0
1065 1078 prog = worker.worker(repo.ui, 0.001, batchremove, (repo,), actions['r'])
1066 1079 for i, item in prog:
1067 1080 z += i
1068 1081 progress(_updating, z, item=item, total=numupdates, unit=_files)
1069 1082 removed = len(actions['r'])
1070 1083
1071 1084 # get in parallel
1072 1085 prog = worker.worker(repo.ui, 0.001, batchget, (repo, mctx), actions['g'])
1073 1086 for i, item in prog:
1074 1087 z += i
1075 1088 progress(_updating, z, item=item, total=numupdates, unit=_files)
1076 1089 updated = len(actions['g'])
1077 1090
1078 1091 if [a for a in actions['g'] if a[0] == '.hgsubstate']:
1079 1092 subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
1080 1093
1081 1094 # forget (manifest only, just log it) (must come first)
1082 1095 for f, args, msg in actions['f']:
1083 1096 repo.ui.debug(" %s: %s -> f\n" % (f, msg))
1084 1097 z += 1
1085 1098 progress(_updating, z, item=f, total=numupdates, unit=_files)
1086 1099
1087 1100 # re-add (manifest only, just log it)
1088 1101 for f, args, msg in actions['a']:
1089 1102 repo.ui.debug(" %s: %s -> a\n" % (f, msg))
1090 1103 z += 1
1091 1104 progress(_updating, z, item=f, total=numupdates, unit=_files)
1092 1105
1093 1106 # re-add/mark as modified (manifest only, just log it)
1094 1107 for f, args, msg in actions['am']:
1095 1108 repo.ui.debug(" %s: %s -> am\n" % (f, msg))
1096 1109 z += 1
1097 1110 progress(_updating, z, item=f, total=numupdates, unit=_files)
1098 1111
1099 1112 # keep (noop, just log it)
1100 1113 for f, args, msg in actions['k']:
1101 1114 repo.ui.debug(" %s: %s -> k\n" % (f, msg))
1102 1115 # no progress
1103 1116
1104 1117 # directory rename, move local
1105 1118 for f, args, msg in actions['dm']:
1106 1119 repo.ui.debug(" %s: %s -> dm\n" % (f, msg))
1107 1120 z += 1
1108 1121 progress(_updating, z, item=f, total=numupdates, unit=_files)
1109 1122 f0, flags = args
1110 1123 repo.ui.note(_("moving %s to %s\n") % (f0, f))
1111 1124 audit(f)
1112 1125 repo.wwrite(f, wctx.filectx(f0).data(), flags)
1113 1126 util.unlinkpath(repo.wjoin(f0))
1114 1127 updated += 1
1115 1128
1116 1129 # local directory rename, get
1117 1130 for f, args, msg in actions['dg']:
1118 1131 repo.ui.debug(" %s: %s -> dg\n" % (f, msg))
1119 1132 z += 1
1120 1133 progress(_updating, z, item=f, total=numupdates, unit=_files)
1121 1134 f0, flags = args
1122 1135 repo.ui.note(_("getting %s to %s\n") % (f0, f))
1123 1136 repo.wwrite(f, mctx.filectx(f0).data(), flags)
1124 1137 updated += 1
1125 1138
1126 1139 # exec
1127 1140 for f, args, msg in actions['e']:
1128 1141 repo.ui.debug(" %s: %s -> e\n" % (f, msg))
1129 1142 z += 1
1130 1143 progress(_updating, z, item=f, total=numupdates, unit=_files)
1131 1144 flags, = args
1132 1145 audit(f)
1133 1146 util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags)
1134 1147 updated += 1
1135 1148
1136 1149 # the ordering is important here -- ms.mergedriver will raise if the merge
1137 1150 # driver has changed, and we want to be able to bypass it when overwrite is
1138 1151 # True
1139 1152 usemergedriver = not overwrite and mergeactions and ms.mergedriver
1140 1153
1141 1154 if usemergedriver:
1142 1155 ms.commit()
1143 1156 proceed = driverpreprocess(repo, ms, wctx, labels=labels)
1144 1157 # the driver might leave some files unresolved
1145 1158 unresolvedf = set(ms.unresolved())
1146 1159 if not proceed:
1147 1160 # XXX setting unresolved to at least 1 is a hack to make sure we
1148 1161 # error out
1149 1162 return updated, merged, removed, max(len(unresolvedf), 1)
1150 1163 newactions = []
1151 1164 for f, args, msg in mergeactions:
1152 1165 if f in unresolvedf:
1153 1166 newactions.append((f, args, msg))
1154 1167 mergeactions = newactions
1155 1168
1156 1169 # premerge
1157 1170 tocomplete = []
1158 1171 for f, args, msg in mergeactions:
1159 1172 repo.ui.debug(" %s: %s -> m (premerge)\n" % (f, msg))
1160 1173 z += 1
1161 1174 progress(_updating, z, item=f, total=numupdates, unit=_files)
1162 1175 if f == '.hgsubstate': # subrepo states need updating
1163 1176 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx),
1164 1177 overwrite)
1165 1178 continue
1166 1179 audit(f)
1167 1180 complete, r = ms.preresolve(f, wctx, labels=labels)
1168 1181 if not complete:
1169 1182 numupdates += 1
1170 1183 tocomplete.append((f, args, msg))
1171 1184
1172 1185 # merge
1173 1186 for f, args, msg in tocomplete:
1174 1187 repo.ui.debug(" %s: %s -> m (merge)\n" % (f, msg))
1175 1188 z += 1
1176 1189 progress(_updating, z, item=f, total=numupdates, unit=_files)
1177 1190 ms.resolve(f, wctx, labels=labels)
1178 1191
1179 1192 ms.commit()
1180 1193
1181 1194 unresolved = ms.unresolvedcount()
1182 1195
1183 1196 if usemergedriver and not unresolved and ms.mdstate() != 's':
1184 1197 if not driverconclude(repo, ms, wctx, labels=labels):
1185 1198 # XXX setting unresolved to at least 1 is a hack to make sure we
1186 1199 # error out
1187 1200 unresolved = max(unresolved, 1)
1188 1201
1189 1202 ms.commit()
1190 1203
1191 1204 msupdated, msmerged, msremoved = ms.counts()
1192 1205 updated += msupdated
1193 1206 merged += msmerged
1194 1207 removed += msremoved
1195 1208
1196 1209 extraactions = ms.actions()
1197 1210 for k, acts in extraactions.iteritems():
1198 1211 actions[k].extend(acts)
1199 1212
1200 1213 progress(_updating, None, total=numupdates, unit=_files)
1201 1214
1202 1215 return updated, merged, removed, unresolved
1203 1216
1204 1217 def recordupdates(repo, actions, branchmerge):
1205 1218 "record merge actions to the dirstate"
1206 1219 # remove (must come first)
1207 1220 for f, args, msg in actions.get('r', []):
1208 1221 if branchmerge:
1209 1222 repo.dirstate.remove(f)
1210 1223 else:
1211 1224 repo.dirstate.drop(f)
1212 1225
1213 1226 # forget (must come first)
1214 1227 for f, args, msg in actions.get('f', []):
1215 1228 repo.dirstate.drop(f)
1216 1229
1217 1230 # re-add
1218 1231 for f, args, msg in actions.get('a', []):
1219 1232 repo.dirstate.add(f)
1220 1233
1221 1234 # re-add/mark as modified
1222 1235 for f, args, msg in actions.get('am', []):
1223 1236 if branchmerge:
1224 1237 repo.dirstate.normallookup(f)
1225 1238 else:
1226 1239 repo.dirstate.add(f)
1227 1240
1228 1241 # exec change
1229 1242 for f, args, msg in actions.get('e', []):
1230 1243 repo.dirstate.normallookup(f)
1231 1244
1232 1245 # keep
1233 1246 for f, args, msg in actions.get('k', []):
1234 1247 pass
1235 1248
1236 1249 # get
1237 1250 for f, args, msg in actions.get('g', []):
1238 1251 if branchmerge:
1239 1252 repo.dirstate.otherparent(f)
1240 1253 else:
1241 1254 repo.dirstate.normal(f)
1242 1255
1243 1256 # merge
1244 1257 for f, args, msg in actions.get('m', []):
1245 1258 f1, f2, fa, move, anc = args
1246 1259 if branchmerge:
1247 1260 # We've done a branch merge, mark this file as merged
1248 1261 # so that we properly record the merger later
1249 1262 repo.dirstate.merge(f)
1250 1263 if f1 != f2: # copy/rename
1251 1264 if move:
1252 1265 repo.dirstate.remove(f1)
1253 1266 if f1 != f:
1254 1267 repo.dirstate.copy(f1, f)
1255 1268 else:
1256 1269 repo.dirstate.copy(f2, f)
1257 1270 else:
1258 1271 # We've update-merged a locally modified file, so
1259 1272 # we set the dirstate to emulate a normal checkout
1260 1273 # of that file some time in the past. Thus our
1261 1274 # merge will appear as a normal local file
1262 1275 # modification.
1263 1276 if f2 == f: # file not locally copied/moved
1264 1277 repo.dirstate.normallookup(f)
1265 1278 if move:
1266 1279 repo.dirstate.drop(f1)
1267 1280
1268 1281 # directory rename, move local
1269 1282 for f, args, msg in actions.get('dm', []):
1270 1283 f0, flag = args
1271 1284 if branchmerge:
1272 1285 repo.dirstate.add(f)
1273 1286 repo.dirstate.remove(f0)
1274 1287 repo.dirstate.copy(f0, f)
1275 1288 else:
1276 1289 repo.dirstate.normal(f)
1277 1290 repo.dirstate.drop(f0)
1278 1291
1279 1292 # directory rename, get
1280 1293 for f, args, msg in actions.get('dg', []):
1281 1294 f0, flag = args
1282 1295 if branchmerge:
1283 1296 repo.dirstate.add(f)
1284 1297 repo.dirstate.copy(f0, f)
1285 1298 else:
1286 1299 repo.dirstate.normal(f)
1287 1300
1288 1301 def update(repo, node, branchmerge, force, ancestor=None,
1289 1302 mergeancestor=False, labels=None, matcher=None):
1290 1303 """
1291 1304 Perform a merge between the working directory and the given node
1292 1305
1293 1306 node = the node to update to, or None if unspecified
1294 1307 branchmerge = whether to merge between branches
1295 1308 force = whether to force branch merging or file overwriting
1296 1309 matcher = a matcher to filter file lists (dirstate not updated)
1297 1310 mergeancestor = whether it is merging with an ancestor. If true,
1298 1311 we should accept the incoming changes for any prompts that occur.
1299 1312 If false, merging with an ancestor (fast-forward) is only allowed
1300 1313 between different named branches. This flag is used by rebase extension
1301 1314 as a temporary fix and should be avoided in general.
1302 1315
1303 1316 The table below shows all the behaviors of the update command
1304 1317 given the -c and -C or no options, whether the working directory
1305 1318 is dirty, whether a revision is specified, and the relationship of
1306 1319 the parent rev to the target rev (linear, on the same named
1307 1320 branch, or on another named branch).
1308 1321
1309 1322 This logic is tested by test-update-branches.t.
1310 1323
1311 1324 -c -C dirty rev | linear same cross
1312 1325 n n n n | ok (1) x
1313 1326 n n n y | ok ok ok
1314 1327 n n y n | merge (2) (2)
1315 1328 n n y y | merge (3) (3)
1316 1329 n y * * | discard discard discard
1317 1330 y n y * | (4) (4) (4)
1318 1331 y n n * | ok ok ok
1319 1332 y y * * | (5) (5) (5)
1320 1333
1321 1334 x = can't happen
1322 1335 * = don't-care
1323 1336 1 = abort: not a linear update (merge or update --check to force update)
1324 1337 2 = abort: uncommitted changes (commit and merge, or update --clean to
1325 1338 discard changes)
1326 1339 3 = abort: uncommitted changes (commit or update --clean to discard changes)
1327 1340 4 = abort: uncommitted changes (checked in commands.py)
1328 1341 5 = incompatible options (checked in commands.py)
1329 1342
1330 1343 Return the same tuple as applyupdates().
1331 1344 """
1332 1345
1333 1346 onode = node
1334 1347 wlock = repo.wlock()
1335 1348 # If we're doing a partial update, we need to skip updating
1336 1349 # the dirstate, so make a note of any partial-ness to the
1337 1350 # update here.
1338 1351 if matcher is None or matcher.always():
1339 1352 partial = False
1340 1353 else:
1341 1354 partial = True
1342 1355 try:
1343 1356 wc = repo[None]
1344 1357 pl = wc.parents()
1345 1358 p1 = pl[0]
1346 1359 pas = [None]
1347 1360 if ancestor is not None:
1348 1361 pas = [repo[ancestor]]
1349 1362
1350 1363 if node is None:
1351 1364 if (repo.ui.configbool('devel', 'all-warnings')
1352 1365 or repo.ui.configbool('devel', 'oldapi')):
1353 1366 repo.ui.develwarn('update with no target')
1354 1367 rev, _mark, _act = destutil.destupdate(repo)
1355 1368 node = repo[rev].node()
1356 1369
1357 1370 overwrite = force and not branchmerge
1358 1371
1359 1372 p2 = repo[node]
1360 1373 if pas[0] is None:
1361 1374 if repo.ui.configlist('merge', 'preferancestor', ['*']) == ['*']:
1362 1375 cahs = repo.changelog.commonancestorsheads(p1.node(), p2.node())
1363 1376 pas = [repo[anc] for anc in (sorted(cahs) or [nullid])]
1364 1377 else:
1365 1378 pas = [p1.ancestor(p2, warn=branchmerge)]
1366 1379
1367 1380 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
1368 1381
1369 1382 ### check phase
1370 1383 if not overwrite:
1371 1384 if len(pl) > 1:
1372 1385 raise error.Abort(_("outstanding uncommitted merge"))
1373 1386 ms = mergestate.read(repo)
1374 1387 if list(ms.unresolved()):
1375 1388 raise error.Abort(_("outstanding merge conflicts"))
1376 1389 if branchmerge:
1377 1390 if pas == [p2]:
1378 1391 raise error.Abort(_("merging with a working directory ancestor"
1379 1392 " has no effect"))
1380 1393 elif pas == [p1]:
1381 1394 if not mergeancestor and p1.branch() == p2.branch():
1382 1395 raise error.Abort(_("nothing to merge"),
1383 1396 hint=_("use 'hg update' "
1384 1397 "or check 'hg heads'"))
1385 1398 if not force and (wc.files() or wc.deleted()):
1386 1399 raise error.Abort(_("uncommitted changes"),
1387 1400 hint=_("use 'hg status' to list changes"))
1388 1401 for s in sorted(wc.substate):
1389 1402 wc.sub(s).bailifchanged()
1390 1403
1391 1404 elif not overwrite:
1392 1405 if p1 == p2: # no-op update
1393 1406 # call the hooks and exit early
1394 1407 repo.hook('preupdate', throw=True, parent1=xp2, parent2='')
1395 1408 repo.hook('update', parent1=xp2, parent2='', error=0)
1396 1409 return 0, 0, 0, 0
1397 1410
1398 1411 if pas not in ([p1], [p2]): # nonlinear
1399 1412 dirty = wc.dirty(missing=True)
1400 1413 if dirty or onode is None:
1401 1414 # Branching is a bit strange to ensure we do the minimal
1402 1415 # amount of call to obsolete.background.
1403 1416 foreground = obsolete.foreground(repo, [p1.node()])
1404 1417 # note: the <node> variable contains a random identifier
1405 1418 if repo[node].node() in foreground:
1406 1419 pas = [p1] # allow updating to successors
1407 1420 elif dirty:
1408 1421 msg = _("uncommitted changes")
1409 1422 if onode is None:
1410 1423 hint = _("commit and merge, or update --clean to"
1411 1424 " discard changes")
1412 1425 else:
1413 1426 hint = _("commit or update --clean to discard"
1414 1427 " changes")
1415 1428 raise error.Abort(msg, hint=hint)
1416 1429 else: # node is none
1417 1430 msg = _("not a linear update")
1418 1431 hint = _("merge or update --check to force update")
1419 1432 raise error.Abort(msg, hint=hint)
1420 1433 else:
1421 1434 # Allow jumping branches if clean and specific rev given
1422 1435 pas = [p1]
1423 1436
1424 1437 # deprecated config: merge.followcopies
1425 1438 followcopies = False
1426 1439 if overwrite:
1427 1440 pas = [wc]
1428 1441 elif pas == [p2]: # backwards
1429 1442 pas = [wc.p1()]
1430 1443 elif not branchmerge and not wc.dirty(missing=True):
1431 1444 pass
1432 1445 elif pas[0] and repo.ui.configbool('merge', 'followcopies', True):
1433 1446 followcopies = True
1434 1447
1435 1448 ### calculate phase
1436 1449 actionbyfile, diverge, renamedelete = calculateupdates(
1437 1450 repo, wc, p2, pas, branchmerge, force, mergeancestor,
1438 1451 followcopies, matcher=matcher)
1439 1452 # Convert to dictionary-of-lists format
1440 1453 actions = dict((m, []) for m in 'a am f g cd dc r dm dg m e k'.split())
1441 1454 for f, (m, args, msg) in actionbyfile.iteritems():
1442 1455 if m not in actions:
1443 1456 actions[m] = []
1444 1457 actions[m].append((f, args, msg))
1445 1458
1446 1459 if not util.checkcase(repo.path):
1447 1460 # check collision between files only in p2 for clean update
1448 1461 if (not branchmerge and
1449 1462 (force or not wc.dirty(missing=True, branch=False))):
1450 1463 _checkcollision(repo, p2.manifest(), None)
1451 1464 else:
1452 1465 _checkcollision(repo, wc.manifest(), actions)
1453 1466
1454 1467 # Prompt and create actions. Most of this is in the resolve phase
1455 1468 # already, but we can't handle .hgsubstate in filemerge or
1456 1469 # subrepo.submerge yet so we have to keep prompting for it.
1457 1470 for f, args, msg in sorted(actions['cd']):
1458 1471 if f != '.hgsubstate':
1459 1472 continue
1460 1473 if repo.ui.promptchoice(
1461 1474 _("local changed %s which remote deleted\n"
1462 1475 "use (c)hanged version or (d)elete?"
1463 1476 "$$ &Changed $$ &Delete") % f, 0):
1464 1477 actions['r'].append((f, None, "prompt delete"))
1465 1478 elif f in p1:
1466 1479 actions['am'].append((f, None, "prompt keep"))
1467 1480 else:
1468 1481 actions['a'].append((f, None, "prompt keep"))
1469 1482
1470 1483 for f, args, msg in sorted(actions['dc']):
1471 1484 if f != '.hgsubstate':
1472 1485 continue
1473 1486 f1, f2, fa, move, anc = args
1474 1487 flags = p2[f2].flags()
1475 1488 if repo.ui.promptchoice(
1476 1489 _("remote changed %s which local deleted\n"
1477 1490 "use (c)hanged version or leave (d)eleted?"
1478 1491 "$$ &Changed $$ &Deleted") % f, 0) == 0:
1479 1492 actions['g'].append((f, (flags, False), "prompt recreating"))
1480 1493
1481 1494 # divergent renames
1482 1495 for f, fl in sorted(diverge.iteritems()):
1483 1496 repo.ui.warn(_("note: possible conflict - %s was renamed "
1484 1497 "multiple times to:\n") % f)
1485 1498 for nf in fl:
1486 1499 repo.ui.warn(" %s\n" % nf)
1487 1500
1488 1501 # rename and delete
1489 1502 for f, fl in sorted(renamedelete.iteritems()):
1490 1503 repo.ui.warn(_("note: possible conflict - %s was deleted "
1491 1504 "and renamed to:\n") % f)
1492 1505 for nf in fl:
1493 1506 repo.ui.warn(" %s\n" % nf)
1494 1507
1495 1508 ### apply phase
1496 1509 if not branchmerge: # just jump to the new rev
1497 1510 fp1, fp2, xp1, xp2 = fp2, nullid, xp2, ''
1498 1511 if not partial:
1499 1512 repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2)
1500 1513 # note that we're in the middle of an update
1501 1514 repo.vfs.write('updatestate', p2.hex())
1502 1515
1503 1516 stats = applyupdates(repo, actions, wc, p2, overwrite, labels=labels)
1504 1517
1505 1518 if not partial:
1506 1519 repo.dirstate.beginparentchange()
1507 1520 repo.setparents(fp1, fp2)
1508 1521 recordupdates(repo, actions, branchmerge)
1509 1522 # update completed, clear state
1510 1523 util.unlink(repo.join('updatestate'))
1511 1524
1512 1525 if not branchmerge:
1513 1526 repo.dirstate.setbranch(p2.branch())
1514 1527 repo.dirstate.endparentchange()
1515 1528 finally:
1516 1529 wlock.release()
1517 1530
1518 1531 if not partial:
1519 1532 repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3])
1520 1533 return stats
1521 1534
1522 1535 def graft(repo, ctx, pctx, labels, keepparent=False):
1523 1536 """Do a graft-like merge.
1524 1537
1525 1538 This is a merge where the merge ancestor is chosen such that one
1526 1539 or more changesets are grafted onto the current changeset. In
1527 1540 addition to the merge, this fixes up the dirstate to include only
1528 1541 a single parent (if keepparent is False) and tries to duplicate any
1529 1542 renames/copies appropriately.
1530 1543
1531 1544 ctx - changeset to rebase
1532 1545 pctx - merge base, usually ctx.p1()
1533 1546 labels - merge labels eg ['local', 'graft']
1534 1547 keepparent - keep second parent if any
1535 1548
1536 1549 """
1537 1550 # If we're grafting a descendant onto an ancestor, be sure to pass
1538 1551 # mergeancestor=True to update. This does two things: 1) allows the merge if
1539 1552 # the destination is the same as the parent of the ctx (so we can use graft
1540 1553 # to copy commits), and 2) informs update that the incoming changes are
1541 1554 # newer than the destination so it doesn't prompt about "remote changed foo
1542 1555 # which local deleted".
1543 1556 mergeancestor = repo.changelog.isancestor(repo['.'].node(), ctx.node())
1544 1557
1545 1558 stats = update(repo, ctx.node(), True, True, pctx.node(),
1546 1559 mergeancestor=mergeancestor, labels=labels)
1547 1560
1548 1561 pother = nullid
1549 1562 parents = ctx.parents()
1550 1563 if keepparent and len(parents) == 2 and pctx in parents:
1551 1564 parents.remove(pctx)
1552 1565 pother = parents[0].node()
1553 1566
1554 1567 repo.dirstate.beginparentchange()
1555 1568 repo.setparents(repo['.'].node(), pother)
1556 1569 repo.dirstate.write(repo.currenttransaction())
1557 1570 # fix up dirstate for copies and renames
1558 1571 copies.duplicatecopies(repo, ctx.rev(), pctx.rev())
1559 1572 repo.dirstate.endparentchange()
1560 1573 return stats
@@ -1,318 +1,354 b''
1 1 $ cat <<EOF > merge
2 2 > import sys, os
3 3 >
4 4 > try:
5 5 > import msvcrt
6 6 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
7 7 > msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
8 8 > except ImportError:
9 9 > pass
10 10 >
11 11 > print "merging for", os.path.basename(sys.argv[1])
12 12 > EOF
13 13 $ HGMERGE="python ../merge"; export HGMERGE
14 14
15 15 $ hg init t
16 16 $ cd t
17 17 $ echo This is file a1 > a
18 18 $ hg add a
19 19 $ hg commit -m "commit #0"
20 20 $ echo This is file b1 > b
21 21 $ hg add b
22 22 $ hg commit -m "commit #1"
23 23
24 24 $ hg update 0
25 25 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
26 26
27 27 Test interrupted updates by exploiting our non-handling of directory collisions
28 28
29 29 $ mkdir b
30 30 $ hg up
31 31 abort: *: '$TESTTMP/t/b' (glob)
32 32 [255]
33 33 $ hg ci
34 34 abort: last update was interrupted
35 35 (use 'hg update' to get a consistent checkout)
36 36 [255]
37 37 $ hg sum
38 38 parent: 0:538afb845929
39 39 commit #0
40 40 branch: default
41 41 commit: (interrupted update)
42 42 update: 1 new changesets (update)
43 43 phases: 2 draft
44 44 $ rmdir b
45 45 $ hg up
46 46 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
47 47 $ hg sum
48 48 parent: 1:b8bb4a988f25 tip
49 49 commit #1
50 50 branch: default
51 51 commit: (clean)
52 52 update: (current)
53 53 phases: 2 draft
54 54
55 55 Prepare a basic merge
56 56
57 57 $ hg up 0
58 58 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
59 59 $ echo This is file c1 > c
60 60 $ hg add c
61 61 $ hg commit -m "commit #2"
62 62 created new head
63 63 $ echo This is file b1 > b
64 64 no merges expected
65 65 $ hg merge -P 1
66 66 changeset: 1:b8bb4a988f25
67 67 user: test
68 68 date: Thu Jan 01 00:00:00 1970 +0000
69 69 summary: commit #1
70 70
71 71 $ hg merge 1
72 72 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
73 73 (branch merge, don't forget to commit)
74 74 $ hg diff --nodates
75 75 diff -r 49035e18a8e6 b
76 76 --- /dev/null
77 77 +++ b/b
78 78 @@ -0,0 +1,1 @@
79 79 +This is file b1
80 80 $ hg status
81 81 M b
82 82 $ cd ..; rm -r t
83 83
84 84 $ hg init t
85 85 $ cd t
86 86 $ echo This is file a1 > a
87 87 $ hg add a
88 88 $ hg commit -m "commit #0"
89 89 $ echo This is file b1 > b
90 90 $ hg add b
91 91 $ hg commit -m "commit #1"
92 92
93 93 $ hg update 0
94 94 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
95 95 $ echo This is file c1 > c
96 96 $ hg add c
97 97 $ hg commit -m "commit #2"
98 98 created new head
99 99 $ echo This is file b2 > b
100 100 merge should fail
101 101 $ hg merge 1
102 102 b: untracked file differs
103 103 abort: untracked files in working directory differ from files in requested revision
104 104 [255]
105 105
106 106 #if symlink
107 107 symlinks to directories should be treated as regular files (issue5027)
108 108 $ rm b
109 109 $ ln -s 'This is file b2' b
110 110 $ hg merge 1
111 111 b: untracked file differs
112 112 abort: untracked files in working directory differ from files in requested revision
113 113 [255]
114 114 symlinks shouldn't be followed
115 115 $ rm b
116 116 $ echo This is file b1 > .hg/b
117 117 $ ln -s .hg/b b
118 118 $ hg merge 1
119 119 b: untracked file differs
120 120 abort: untracked files in working directory differ from files in requested revision
121 121 [255]
122 122
123 123 $ rm b
124 124 $ echo This is file b2 > b
125 125 #endif
126 126
127 merge of b expected
127 bad config
128 $ hg merge 1 --config merge.checkunknown=x
129 abort: merge.checkunknown not valid ('x' is none of 'abort', 'ignore', 'warn')
130 [255]
131 this merge should fail
132 $ hg merge 1 --config merge.checkunknown=abort
133 b: untracked file differs
134 abort: untracked files in working directory differ from files in requested revision
135 [255]
136
137 this merge should warn
138 $ hg merge 1 --config merge.checkunknown=warn
139 b: replacing untracked file
140 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 (branch merge, don't forget to commit)
142 $ cat b.orig
143 This is file b2
144 $ hg up --clean 2
145 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
146 $ mv b.orig b
147
148 this merge should silently ignore
149 $ cat b
150 This is file b2
151 $ hg merge 1 --config merge.checkunknown=ignore
152 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
153 (branch merge, don't forget to commit)
154
155 $ cat b.orig
156 This is file b2
157 $ hg up --clean 2
158 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
159 $ mv b.orig b
160
161 this merge of b should work
162 $ cat b
163 This is file b2
128 164 $ hg merge -f 1
129 165 merging b
130 166 merging for b
131 167 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
132 168 (branch merge, don't forget to commit)
133 169 $ hg diff --nodates
134 170 diff -r 49035e18a8e6 b
135 171 --- /dev/null
136 172 +++ b/b
137 173 @@ -0,0 +1,1 @@
138 174 +This is file b2
139 175 $ hg status
140 176 M b
141 177 $ cd ..; rm -r t
142 178
143 179 $ hg init t
144 180 $ cd t
145 181 $ echo This is file a1 > a
146 182 $ hg add a
147 183 $ hg commit -m "commit #0"
148 184 $ echo This is file b1 > b
149 185 $ hg add b
150 186 $ hg commit -m "commit #1"
151 187 $ echo This is file b22 > b
152 188 $ hg commit -m "commit #2"
153 189 $ hg update 1
154 190 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
155 191 $ echo This is file c1 > c
156 192 $ hg add c
157 193 $ hg commit -m "commit #3"
158 194 created new head
159 195
160 196 Contents of b should be "this is file b1"
161 197 $ cat b
162 198 This is file b1
163 199
164 200 $ echo This is file b22 > b
165 201 merge fails
166 202 $ hg merge 2
167 203 abort: uncommitted changes
168 204 (use 'hg status' to list changes)
169 205 [255]
170 206 merge expected!
171 207 $ hg merge -f 2
172 208 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
173 209 (branch merge, don't forget to commit)
174 210 $ hg diff --nodates
175 211 diff -r 85de557015a8 b
176 212 --- a/b
177 213 +++ b/b
178 214 @@ -1,1 +1,1 @@
179 215 -This is file b1
180 216 +This is file b22
181 217 $ hg status
182 218 M b
183 219 $ cd ..; rm -r t
184 220
185 221 $ hg init t
186 222 $ cd t
187 223 $ echo This is file a1 > a
188 224 $ hg add a
189 225 $ hg commit -m "commit #0"
190 226 $ echo This is file b1 > b
191 227 $ hg add b
192 228 $ hg commit -m "commit #1"
193 229 $ echo This is file b22 > b
194 230 $ hg commit -m "commit #2"
195 231 $ hg update 1
196 232 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
197 233 $ echo This is file c1 > c
198 234 $ hg add c
199 235 $ hg commit -m "commit #3"
200 236 created new head
201 237 $ echo This is file b33 > b
202 238 merge of b should fail
203 239 $ hg merge 2
204 240 abort: uncommitted changes
205 241 (use 'hg status' to list changes)
206 242 [255]
207 243 merge of b expected
208 244 $ hg merge -f 2
209 245 merging b
210 246 merging for b
211 247 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
212 248 (branch merge, don't forget to commit)
213 249 $ hg diff --nodates
214 250 diff -r 85de557015a8 b
215 251 --- a/b
216 252 +++ b/b
217 253 @@ -1,1 +1,1 @@
218 254 -This is file b1
219 255 +This is file b33
220 256 $ hg status
221 257 M b
222 258
223 259 Test for issue2364
224 260
225 261 $ hg up -qC .
226 262 $ hg rm b
227 263 $ hg ci -md
228 264 $ hg revert -r -2 b
229 265 $ hg up -q -- -2
230 266
231 267 Test that updated files are treated as "modified", when
232 268 'merge.update()' is aborted before 'merge.recordupdates()' (= parents
233 269 aren't changed), even if none of mode, size and timestamp of them
234 270 isn't changed on the filesystem (see also issue4583).
235 271
236 272 $ cat > $TESTTMP/abort.py <<EOF
237 273 > # emulate aborting before "recordupdates()". in this case, files
238 274 > # are changed without updating dirstate
239 275 > from mercurial import extensions, merge, error
240 276 > def applyupdates(orig, *args, **kwargs):
241 277 > orig(*args, **kwargs)
242 278 > raise error.Abort('intentional aborting')
243 279 > def extsetup(ui):
244 280 > extensions.wrapfunction(merge, "applyupdates", applyupdates)
245 281 > EOF
246 282
247 283 $ cat >> .hg/hgrc <<EOF
248 284 > [fakedirstatewritetime]
249 285 > # emulate invoking dirstate.write() via repo.status()
250 286 > # at 2000-01-01 00:00
251 287 > fakenow = 200001010000
252 288 > EOF
253 289
254 290 (file gotten from other revision)
255 291
256 292 $ hg update -q -C 2
257 293 $ echo 'THIS IS FILE B5' > b
258 294 $ hg commit -m 'commit #5'
259 295
260 296 $ hg update -q -C 3
261 297 $ cat b
262 298 This is file b1
263 299 $ touch -t 200001010000 b
264 300 $ hg debugrebuildstate
265 301
266 302 $ cat >> .hg/hgrc <<EOF
267 303 > [extensions]
268 304 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
269 305 > abort = $TESTTMP/abort.py
270 306 > EOF
271 307 $ hg merge 5
272 308 abort: intentional aborting
273 309 [255]
274 310 $ cat >> .hg/hgrc <<EOF
275 311 > [extensions]
276 312 > fakedirstatewritetime = !
277 313 > abort = !
278 314 > EOF
279 315
280 316 $ cat b
281 317 THIS IS FILE B5
282 318 $ touch -t 200001010000 b
283 319 $ hg status -A b
284 320 M b
285 321
286 322 (file merged from other revision)
287 323
288 324 $ hg update -q -C 3
289 325 $ echo 'this is file b6' > b
290 326 $ hg commit -m 'commit #6'
291 327 created new head
292 328
293 329 $ cat b
294 330 this is file b6
295 331 $ touch -t 200001010000 b
296 332 $ hg debugrebuildstate
297 333
298 334 $ cat >> .hg/hgrc <<EOF
299 335 > [extensions]
300 336 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
301 337 > abort = $TESTTMP/abort.py
302 338 > EOF
303 339 $ hg merge --tool internal:other 5
304 340 abort: intentional aborting
305 341 [255]
306 342 $ cat >> .hg/hgrc <<EOF
307 343 > [extensions]
308 344 > fakedirstatewritetime = !
309 345 > abort = !
310 346 > EOF
311 347
312 348 $ cat b
313 349 THIS IS FILE B5
314 350 $ touch -t 200001010000 b
315 351 $ hg status -A b
316 352 M b
317 353
318 354 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now