##// END OF EJS Templates
hook: add support for disabling the shell to native command translation...
Matt Harbison -
r38648:38dfd308 default
parent child Browse files
Show More
@@ -1,2658 +1,2665
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:
34 34
35 35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36 36
37 37 Global configuration like the username setting is typically put into:
38 38
39 39 .. container:: windows
40 40
41 41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42 42
43 43 .. container:: unix.plan9
44 44
45 45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46 46
47 47 The names of these files depend on the system on which Mercurial is
48 48 installed. ``*.rc`` files from a single directory are read in
49 49 alphabetical order, later ones overriding earlier ones. Where multiple
50 50 paths are given below, settings from earlier paths override later
51 51 ones.
52 52
53 53 .. container:: verbose.unix
54 54
55 55 On Unix, the following files are consulted:
56 56
57 57 - ``<repo>/.hg/hgrc`` (per-repository)
58 58 - ``$HOME/.hgrc`` (per-user)
59 59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 62 - ``/etc/mercurial/hgrc`` (per-system)
63 63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 64 - ``<internal>/default.d/*.rc`` (defaults)
65 65
66 66 .. container:: verbose.windows
67 67
68 68 On Windows, the following files are consulted:
69 69
70 70 - ``<repo>/.hg/hgrc`` (per-repository)
71 71 - ``%USERPROFILE%\.hgrc`` (per-user)
72 72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
73 73 - ``%HOME%\.hgrc`` (per-user)
74 74 - ``%HOME%\Mercurial.ini`` (per-user)
75 75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
76 76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
77 77 - ``<install-dir>\Mercurial.ini`` (per-installation)
78 78 - ``<internal>/default.d/*.rc`` (defaults)
79 79
80 80 .. note::
81 81
82 82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
83 83 is used when running 32-bit Python on 64-bit Windows.
84 84
85 85 .. container:: windows
86 86
87 87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
88 88
89 89 .. container:: verbose.plan9
90 90
91 91 On Plan9, the following files are consulted:
92 92
93 93 - ``<repo>/.hg/hgrc`` (per-repository)
94 94 - ``$home/lib/hgrc`` (per-user)
95 95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
96 96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
97 97 - ``/lib/mercurial/hgrc`` (per-system)
98 98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
99 99 - ``<internal>/default.d/*.rc`` (defaults)
100 100
101 101 Per-repository configuration options only apply in a
102 102 particular repository. This file is not version-controlled, and
103 103 will not get transferred during a "clone" operation. Options in
104 104 this file override options in all other configuration files.
105 105
106 106 .. container:: unix.plan9
107 107
108 108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
109 109 belong to a trusted user or to a trusted group. See
110 110 :hg:`help config.trusted` for more details.
111 111
112 112 Per-user configuration file(s) are for the user running Mercurial. Options
113 113 in these files apply to all Mercurial commands executed by this user in any
114 114 directory. Options in these files override per-system and per-installation
115 115 options.
116 116
117 117 Per-installation configuration files are searched for in the
118 118 directory where Mercurial is installed. ``<install-root>`` is the
119 119 parent directory of the **hg** executable (or symlink) being run.
120 120
121 121 .. container:: unix.plan9
122 122
123 123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
124 124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
125 125 files apply to all Mercurial commands executed by any user in any
126 126 directory.
127 127
128 128 Per-installation configuration files are for the system on
129 129 which Mercurial is running. Options in these files apply to all
130 130 Mercurial commands executed by any user in any directory. Registry
131 131 keys contain PATH-like strings, every part of which must reference
132 132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
133 133 be read. Mercurial checks each of these locations in the specified
134 134 order until one or more configuration files are detected.
135 135
136 136 Per-system configuration files are for the system on which Mercurial
137 137 is running. Options in these files apply to all Mercurial commands
138 138 executed by any user in any directory. Options in these files
139 139 override per-installation options.
140 140
141 141 Mercurial comes with some default configuration. The default configuration
142 142 files are installed with Mercurial and will be overwritten on upgrades. Default
143 143 configuration files should never be edited by users or administrators but can
144 144 be overridden in other configuration files. So far the directory only contains
145 145 merge tool configuration but packagers can also put other default configuration
146 146 there.
147 147
148 148 Syntax
149 149 ======
150 150
151 151 A configuration file consists of sections, led by a ``[section]`` header
152 152 and followed by ``name = value`` entries (sometimes called
153 153 ``configuration keys``)::
154 154
155 155 [spam]
156 156 eggs=ham
157 157 green=
158 158 eggs
159 159
160 160 Each line contains one entry. If the lines that follow are indented,
161 161 they are treated as continuations of that entry. Leading whitespace is
162 162 removed from values. Empty lines are skipped. Lines beginning with
163 163 ``#`` or ``;`` are ignored and may be used to provide comments.
164 164
165 165 Configuration keys can be set multiple times, in which case Mercurial
166 166 will use the value that was configured last. As an example::
167 167
168 168 [spam]
169 169 eggs=large
170 170 ham=serrano
171 171 eggs=small
172 172
173 173 This would set the configuration key named ``eggs`` to ``small``.
174 174
175 175 It is also possible to define a section multiple times. A section can
176 176 be redefined on the same and/or on different configuration files. For
177 177 example::
178 178
179 179 [foo]
180 180 eggs=large
181 181 ham=serrano
182 182 eggs=small
183 183
184 184 [bar]
185 185 eggs=ham
186 186 green=
187 187 eggs
188 188
189 189 [foo]
190 190 ham=prosciutto
191 191 eggs=medium
192 192 bread=toasted
193 193
194 194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
195 195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
196 196 respectively. As you can see there only thing that matters is the last
197 197 value that was set for each of the configuration keys.
198 198
199 199 If a configuration key is set multiple times in different
200 200 configuration files the final value will depend on the order in which
201 201 the different configuration files are read, with settings from earlier
202 202 paths overriding later ones as described on the ``Files`` section
203 203 above.
204 204
205 205 A line of the form ``%include file`` will include ``file`` into the
206 206 current configuration file. The inclusion is recursive, which means
207 207 that included files can include other files. Filenames are relative to
208 208 the configuration file in which the ``%include`` directive is found.
209 209 Environment variables and ``~user`` constructs are expanded in
210 210 ``file``. This lets you do something like::
211 211
212 212 %include ~/.hgrc.d/$HOST.rc
213 213
214 214 to include a different configuration file on each computer you use.
215 215
216 216 A line with ``%unset name`` will remove ``name`` from the current
217 217 section, if it has been set previously.
218 218
219 219 The values are either free-form text strings, lists of text strings,
220 220 or Boolean values. Boolean values can be set to true using any of "1",
221 221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
222 222 (all case insensitive).
223 223
224 224 List values are separated by whitespace or comma, except when values are
225 225 placed in double quotation marks::
226 226
227 227 allow_read = "John Doe, PhD", brian, betty
228 228
229 229 Quotation marks can be escaped by prefixing them with a backslash. Only
230 230 quotation marks at the beginning of a word is counted as a quotation
231 231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
232 232
233 233 Sections
234 234 ========
235 235
236 236 This section describes the different sections that may appear in a
237 237 Mercurial configuration file, the purpose of each section, its possible
238 238 keys, and their possible values.
239 239
240 240 ``alias``
241 241 ---------
242 242
243 243 Defines command aliases.
244 244
245 245 Aliases allow you to define your own commands in terms of other
246 246 commands (or aliases), optionally including arguments. Positional
247 247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
248 248 are expanded by Mercurial before execution. Positional arguments not
249 249 already used by ``$N`` in the definition are put at the end of the
250 250 command to be executed.
251 251
252 252 Alias definitions consist of lines of the form::
253 253
254 254 <alias> = <command> [<argument>]...
255 255
256 256 For example, this definition::
257 257
258 258 latest = log --limit 5
259 259
260 260 creates a new command ``latest`` that shows only the five most recent
261 261 changesets. You can define subsequent aliases using earlier ones::
262 262
263 263 stable5 = latest -b stable
264 264
265 265 .. note::
266 266
267 267 It is possible to create aliases with the same names as
268 268 existing commands, which will then override the original
269 269 definitions. This is almost always a bad idea!
270 270
271 271 An alias can start with an exclamation point (``!``) to make it a
272 272 shell alias. A shell alias is executed with the shell and will let you
273 273 run arbitrary commands. As an example, ::
274 274
275 275 echo = !echo $@
276 276
277 277 will let you do ``hg echo foo`` to have ``foo`` printed in your
278 278 terminal. A better example might be::
279 279
280 280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
281 281
282 282 which will make ``hg purge`` delete all unknown files in the
283 283 repository in the same manner as the purge extension.
284 284
285 285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
286 286 expand to the command arguments. Unmatched arguments are
287 287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
288 288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
289 289 arguments quoted individually and separated by a space. These expansions
290 290 happen before the command is passed to the shell.
291 291
292 292 Shell aliases are executed in an environment where ``$HG`` expands to
293 293 the path of the Mercurial that was used to execute the alias. This is
294 294 useful when you want to call further Mercurial commands in a shell
295 295 alias, as was done above for the purge alias. In addition,
296 296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
297 297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
298 298
299 299 .. note::
300 300
301 301 Some global configuration options such as ``-R`` are
302 302 processed before shell aliases and will thus not be passed to
303 303 aliases.
304 304
305 305
306 306 ``annotate``
307 307 ------------
308 308
309 309 Settings used when displaying file annotations. All values are
310 310 Booleans and default to False. See :hg:`help config.diff` for
311 311 related options for the diff command.
312 312
313 313 ``ignorews``
314 314 Ignore white space when comparing lines.
315 315
316 316 ``ignorewseol``
317 317 Ignore white space at the end of a line when comparing lines.
318 318
319 319 ``ignorewsamount``
320 320 Ignore changes in the amount of white space.
321 321
322 322 ``ignoreblanklines``
323 323 Ignore changes whose lines are all blank.
324 324
325 325
326 326 ``auth``
327 327 --------
328 328
329 329 Authentication credentials and other authentication-like configuration
330 330 for HTTP connections. This section allows you to store usernames and
331 331 passwords for use when logging *into* HTTP servers. See
332 332 :hg:`help config.web` if you want to configure *who* can login to
333 333 your HTTP server.
334 334
335 335 The following options apply to all hosts.
336 336
337 337 ``cookiefile``
338 338 Path to a file containing HTTP cookie lines. Cookies matching a
339 339 host will be sent automatically.
340 340
341 341 The file format uses the Mozilla cookies.txt format, which defines cookies
342 342 on their own lines. Each line contains 7 fields delimited by the tab
343 343 character (domain, is_domain_cookie, path, is_secure, expires, name,
344 344 value). For more info, do an Internet search for "Netscape cookies.txt
345 345 format."
346 346
347 347 Note: the cookies parser does not handle port numbers on domains. You
348 348 will need to remove ports from the domain for the cookie to be recognized.
349 349 This could result in a cookie being disclosed to an unwanted server.
350 350
351 351 The cookies file is read-only.
352 352
353 353 Other options in this section are grouped by name and have the following
354 354 format::
355 355
356 356 <name>.<argument> = <value>
357 357
358 358 where ``<name>`` is used to group arguments into authentication
359 359 entries. Example::
360 360
361 361 foo.prefix = hg.intevation.de/mercurial
362 362 foo.username = foo
363 363 foo.password = bar
364 364 foo.schemes = http https
365 365
366 366 bar.prefix = secure.example.org
367 367 bar.key = path/to/file.key
368 368 bar.cert = path/to/file.cert
369 369 bar.schemes = https
370 370
371 371 Supported arguments:
372 372
373 373 ``prefix``
374 374 Either ``*`` or a URI prefix with or without the scheme part.
375 375 The authentication entry with the longest matching prefix is used
376 376 (where ``*`` matches everything and counts as a match of length
377 377 1). If the prefix doesn't include a scheme, the match is performed
378 378 against the URI with its scheme stripped as well, and the schemes
379 379 argument, q.v., is then subsequently consulted.
380 380
381 381 ``username``
382 382 Optional. Username to authenticate with. If not given, and the
383 383 remote site requires basic or digest authentication, the user will
384 384 be prompted for it. Environment variables are expanded in the
385 385 username letting you do ``foo.username = $USER``. If the URI
386 386 includes a username, only ``[auth]`` entries with a matching
387 387 username or without a username will be considered.
388 388
389 389 ``password``
390 390 Optional. Password to authenticate with. If not given, and the
391 391 remote site requires basic or digest authentication, the user
392 392 will be prompted for it.
393 393
394 394 ``key``
395 395 Optional. PEM encoded client certificate key file. Environment
396 396 variables are expanded in the filename.
397 397
398 398 ``cert``
399 399 Optional. PEM encoded client certificate chain file. Environment
400 400 variables are expanded in the filename.
401 401
402 402 ``schemes``
403 403 Optional. Space separated list of URI schemes to use this
404 404 authentication entry with. Only used if the prefix doesn't include
405 405 a scheme. Supported schemes are http and https. They will match
406 406 static-http and static-https respectively, as well.
407 407 (default: https)
408 408
409 409 If no suitable authentication entry is found, the user is prompted
410 410 for credentials as usual if required by the remote.
411 411
412 412 ``color``
413 413 ---------
414 414
415 415 Configure the Mercurial color mode. For details about how to define your custom
416 416 effect and style see :hg:`help color`.
417 417
418 418 ``mode``
419 419 String: control the method used to output color. One of ``auto``, ``ansi``,
420 420 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
421 421 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
422 422 terminal. Any invalid value will disable color.
423 423
424 424 ``pagermode``
425 425 String: optional override of ``color.mode`` used with pager.
426 426
427 427 On some systems, terminfo mode may cause problems when using
428 428 color with ``less -R`` as a pager program. less with the -R option
429 429 will only display ECMA-48 color codes, and terminfo mode may sometimes
430 430 emit codes that less doesn't understand. You can work around this by
431 431 either using ansi mode (or auto mode), or by using less -r (which will
432 432 pass through all terminal control codes, not just color control
433 433 codes).
434 434
435 435 On some systems (such as MSYS in Windows), the terminal may support
436 436 a different color mode than the pager program.
437 437
438 438 ``commands``
439 439 ------------
440 440
441 441 ``status.relative``
442 442 Make paths in :hg:`status` output relative to the current directory.
443 443 (default: False)
444 444
445 445 ``status.terse``
446 446 Default value for the --terse flag, which condenes status output.
447 447 (default: empty)
448 448
449 449 ``update.check``
450 450 Determines what level of checking :hg:`update` will perform before moving
451 451 to a destination revision. Valid values are ``abort``, ``none``,
452 452 ``linear``, and ``noconflict``. ``abort`` always fails if the working
453 453 directory has uncommitted changes. ``none`` performs no checking, and may
454 454 result in a merge with uncommitted changes. ``linear`` allows any update
455 455 as long as it follows a straight line in the revision history, and may
456 456 trigger a merge with uncommitted changes. ``noconflict`` will allow any
457 457 update which would not trigger a merge with uncommitted changes, if any
458 458 are present.
459 459 (default: ``linear``)
460 460
461 461 ``update.requiredest``
462 462 Require that the user pass a destination when running :hg:`update`.
463 463 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
464 464 will be disallowed.
465 465 (default: False)
466 466
467 467 ``committemplate``
468 468 ------------------
469 469
470 470 ``changeset``
471 471 String: configuration in this section is used as the template to
472 472 customize the text shown in the editor when committing.
473 473
474 474 In addition to pre-defined template keywords, commit log specific one
475 475 below can be used for customization:
476 476
477 477 ``extramsg``
478 478 String: Extra message (typically 'Leave message empty to abort
479 479 commit.'). This may be changed by some commands or extensions.
480 480
481 481 For example, the template configuration below shows as same text as
482 482 one shown by default::
483 483
484 484 [committemplate]
485 485 changeset = {desc}\n\n
486 486 HG: Enter commit message. Lines beginning with 'HG:' are removed.
487 487 HG: {extramsg}
488 488 HG: --
489 489 HG: user: {author}\n{ifeq(p2rev, "-1", "",
490 490 "HG: branch merge\n")
491 491 }HG: branch '{branch}'\n{if(activebookmark,
492 492 "HG: bookmark '{activebookmark}'\n") }{subrepos %
493 493 "HG: subrepo {subrepo}\n" }{file_adds %
494 494 "HG: added {file}\n" }{file_mods %
495 495 "HG: changed {file}\n" }{file_dels %
496 496 "HG: removed {file}\n" }{if(files, "",
497 497 "HG: no files changed\n")}
498 498
499 499 ``diff()``
500 500 String: show the diff (see :hg:`help templates` for detail)
501 501
502 502 Sometimes it is helpful to show the diff of the changeset in the editor without
503 503 having to prefix 'HG: ' to each line so that highlighting works correctly. For
504 504 this, Mercurial provides a special string which will ignore everything below
505 505 it::
506 506
507 507 HG: ------------------------ >8 ------------------------
508 508
509 509 For example, the template configuration below will show the diff below the
510 510 extra message::
511 511
512 512 [committemplate]
513 513 changeset = {desc}\n\n
514 514 HG: Enter commit message. Lines beginning with 'HG:' are removed.
515 515 HG: {extramsg}
516 516 HG: ------------------------ >8 ------------------------
517 517 HG: Do not touch the line above.
518 518 HG: Everything below will be removed.
519 519 {diff()}
520 520
521 521 .. note::
522 522
523 523 For some problematic encodings (see :hg:`help win32mbcs` for
524 524 detail), this customization should be configured carefully, to
525 525 avoid showing broken characters.
526 526
527 527 For example, if a multibyte character ending with backslash (0x5c) is
528 528 followed by the ASCII character 'n' in the customized template,
529 529 the sequence of backslash and 'n' is treated as line-feed unexpectedly
530 530 (and the multibyte character is broken, too).
531 531
532 532 Customized template is used for commands below (``--edit`` may be
533 533 required):
534 534
535 535 - :hg:`backout`
536 536 - :hg:`commit`
537 537 - :hg:`fetch` (for merge commit only)
538 538 - :hg:`graft`
539 539 - :hg:`histedit`
540 540 - :hg:`import`
541 541 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
542 542 - :hg:`rebase`
543 543 - :hg:`shelve`
544 544 - :hg:`sign`
545 545 - :hg:`tag`
546 546 - :hg:`transplant`
547 547
548 548 Configuring items below instead of ``changeset`` allows showing
549 549 customized message only for specific actions, or showing different
550 550 messages for each action.
551 551
552 552 - ``changeset.backout`` for :hg:`backout`
553 553 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
554 554 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
555 555 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
556 556 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
557 557 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
558 558 - ``changeset.gpg.sign`` for :hg:`sign`
559 559 - ``changeset.graft`` for :hg:`graft`
560 560 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
561 561 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
562 562 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
563 563 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
564 564 - ``changeset.import.bypass`` for :hg:`import --bypass`
565 565 - ``changeset.import.normal.merge`` for :hg:`import` on merges
566 566 - ``changeset.import.normal.normal`` for :hg:`import` on other
567 567 - ``changeset.mq.qnew`` for :hg:`qnew`
568 568 - ``changeset.mq.qfold`` for :hg:`qfold`
569 569 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
570 570 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
571 571 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
572 572 - ``changeset.rebase.normal`` for :hg:`rebase` on other
573 573 - ``changeset.shelve.shelve`` for :hg:`shelve`
574 574 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
575 575 - ``changeset.tag.remove`` for :hg:`tag --remove`
576 576 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
577 577 - ``changeset.transplant.normal`` for :hg:`transplant` on other
578 578
579 579 These dot-separated lists of names are treated as hierarchical ones.
580 580 For example, ``changeset.tag.remove`` customizes the commit message
581 581 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
582 582 commit message for :hg:`tag` regardless of ``--remove`` option.
583 583
584 584 When the external editor is invoked for a commit, the corresponding
585 585 dot-separated list of names without the ``changeset.`` prefix
586 586 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
587 587 variable.
588 588
589 589 In this section, items other than ``changeset`` can be referred from
590 590 others. For example, the configuration to list committed files up
591 591 below can be referred as ``{listupfiles}``::
592 592
593 593 [committemplate]
594 594 listupfiles = {file_adds %
595 595 "HG: added {file}\n" }{file_mods %
596 596 "HG: changed {file}\n" }{file_dels %
597 597 "HG: removed {file}\n" }{if(files, "",
598 598 "HG: no files changed\n")}
599 599
600 600 ``decode/encode``
601 601 -----------------
602 602
603 603 Filters for transforming files on checkout/checkin. This would
604 604 typically be used for newline processing or other
605 605 localization/canonicalization of files.
606 606
607 607 Filters consist of a filter pattern followed by a filter command.
608 608 Filter patterns are globs by default, rooted at the repository root.
609 609 For example, to match any file ending in ``.txt`` in the root
610 610 directory only, use the pattern ``*.txt``. To match any file ending
611 611 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
612 612 For each file only the first matching filter applies.
613 613
614 614 The filter command can start with a specifier, either ``pipe:`` or
615 615 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
616 616
617 617 A ``pipe:`` command must accept data on stdin and return the transformed
618 618 data on stdout.
619 619
620 620 Pipe example::
621 621
622 622 [encode]
623 623 # uncompress gzip files on checkin to improve delta compression
624 624 # note: not necessarily a good idea, just an example
625 625 *.gz = pipe: gunzip
626 626
627 627 [decode]
628 628 # recompress gzip files when writing them to the working dir (we
629 629 # can safely omit "pipe:", because it's the default)
630 630 *.gz = gzip
631 631
632 632 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
633 633 with the name of a temporary file that contains the data to be
634 634 filtered by the command. The string ``OUTFILE`` is replaced with the name
635 635 of an empty temporary file, where the filtered data must be written by
636 636 the command.
637 637
638 638 .. container:: windows
639 639
640 640 .. note::
641 641
642 642 The tempfile mechanism is recommended for Windows systems,
643 643 where the standard shell I/O redirection operators often have
644 644 strange effects and may corrupt the contents of your files.
645 645
646 646 This filter mechanism is used internally by the ``eol`` extension to
647 647 translate line ending characters between Windows (CRLF) and Unix (LF)
648 648 format. We suggest you use the ``eol`` extension for convenience.
649 649
650 650
651 651 ``defaults``
652 652 ------------
653 653
654 654 (defaults are deprecated. Don't use them. Use aliases instead.)
655 655
656 656 Use the ``[defaults]`` section to define command defaults, i.e. the
657 657 default options/arguments to pass to the specified commands.
658 658
659 659 The following example makes :hg:`log` run in verbose mode, and
660 660 :hg:`status` show only the modified files, by default::
661 661
662 662 [defaults]
663 663 log = -v
664 664 status = -m
665 665
666 666 The actual commands, instead of their aliases, must be used when
667 667 defining command defaults. The command defaults will also be applied
668 668 to the aliases of the commands defined.
669 669
670 670
671 671 ``diff``
672 672 --------
673 673
674 674 Settings used when displaying diffs. Everything except for ``unified``
675 675 is a Boolean and defaults to False. See :hg:`help config.annotate`
676 676 for related options for the annotate command.
677 677
678 678 ``git``
679 679 Use git extended diff format.
680 680
681 681 ``nobinary``
682 682 Omit git binary patches.
683 683
684 684 ``nodates``
685 685 Don't include dates in diff headers.
686 686
687 687 ``noprefix``
688 688 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
689 689
690 690 ``showfunc``
691 691 Show which function each change is in.
692 692
693 693 ``ignorews``
694 694 Ignore white space when comparing lines.
695 695
696 696 ``ignorewsamount``
697 697 Ignore changes in the amount of white space.
698 698
699 699 ``ignoreblanklines``
700 700 Ignore changes whose lines are all blank.
701 701
702 702 ``unified``
703 703 Number of lines of context to show.
704 704
705 705 ``word-diff``
706 706 Highlight changed words.
707 707
708 708 ``email``
709 709 ---------
710 710
711 711 Settings for extensions that send email messages.
712 712
713 713 ``from``
714 714 Optional. Email address to use in "From" header and SMTP envelope
715 715 of outgoing messages.
716 716
717 717 ``to``
718 718 Optional. Comma-separated list of recipients' email addresses.
719 719
720 720 ``cc``
721 721 Optional. Comma-separated list of carbon copy recipients'
722 722 email addresses.
723 723
724 724 ``bcc``
725 725 Optional. Comma-separated list of blind carbon copy recipients'
726 726 email addresses.
727 727
728 728 ``method``
729 729 Optional. Method to use to send email messages. If value is ``smtp``
730 730 (default), use SMTP (see the ``[smtp]`` section for configuration).
731 731 Otherwise, use as name of program to run that acts like sendmail
732 732 (takes ``-f`` option for sender, list of recipients on command line,
733 733 message on stdin). Normally, setting this to ``sendmail`` or
734 734 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
735 735
736 736 ``charsets``
737 737 Optional. Comma-separated list of character sets considered
738 738 convenient for recipients. Addresses, headers, and parts not
739 739 containing patches of outgoing messages will be encoded in the
740 740 first character set to which conversion from local encoding
741 741 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
742 742 conversion fails, the text in question is sent as is.
743 743 (default: '')
744 744
745 745 Order of outgoing email character sets:
746 746
747 747 1. ``us-ascii``: always first, regardless of settings
748 748 2. ``email.charsets``: in order given by user
749 749 3. ``ui.fallbackencoding``: if not in email.charsets
750 750 4. ``$HGENCODING``: if not in email.charsets
751 751 5. ``utf-8``: always last, regardless of settings
752 752
753 753 Email example::
754 754
755 755 [email]
756 756 from = Joseph User <joe.user@example.com>
757 757 method = /usr/sbin/sendmail
758 758 # charsets for western Europeans
759 759 # us-ascii, utf-8 omitted, as they are tried first and last
760 760 charsets = iso-8859-1, iso-8859-15, windows-1252
761 761
762 762
763 763 ``extensions``
764 764 --------------
765 765
766 766 Mercurial has an extension mechanism for adding new features. To
767 767 enable an extension, create an entry for it in this section.
768 768
769 769 If you know that the extension is already in Python's search path,
770 770 you can give the name of the module, followed by ``=``, with nothing
771 771 after the ``=``.
772 772
773 773 Otherwise, give a name that you choose, followed by ``=``, followed by
774 774 the path to the ``.py`` file (including the file name extension) that
775 775 defines the extension.
776 776
777 777 To explicitly disable an extension that is enabled in an hgrc of
778 778 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
779 779 or ``foo = !`` when path is not supplied.
780 780
781 781 Example for ``~/.hgrc``::
782 782
783 783 [extensions]
784 784 # (the churn extension will get loaded from Mercurial's path)
785 785 churn =
786 786 # (this extension will get loaded from the file specified)
787 787 myfeature = ~/.hgext/myfeature.py
788 788
789 789
790 790 ``format``
791 791 ----------
792 792
793 793 ``usegeneraldelta``
794 794 Enable or disable the "generaldelta" repository format which improves
795 795 repository compression by allowing "revlog" to store delta against arbitrary
796 796 revision instead of the previous stored one. This provides significant
797 797 improvement for repositories with branches.
798 798
799 799 Repositories with this on-disk format require Mercurial version 1.9.
800 800
801 801 Enabled by default.
802 802
803 803 ``dotencode``
804 804 Enable or disable the "dotencode" repository format which enhances
805 805 the "fncache" repository format (which has to be enabled to use
806 806 dotencode) to avoid issues with filenames starting with ._ on
807 807 Mac OS X and spaces on Windows.
808 808
809 809 Repositories with this on-disk format require Mercurial version 1.7.
810 810
811 811 Enabled by default.
812 812
813 813 ``usefncache``
814 814 Enable or disable the "fncache" repository format which enhances
815 815 the "store" repository format (which has to be enabled to use
816 816 fncache) to allow longer filenames and avoids using Windows
817 817 reserved names, e.g. "nul".
818 818
819 819 Repositories with this on-disk format require Mercurial version 1.1.
820 820
821 821 Enabled by default.
822 822
823 823 ``usestore``
824 824 Enable or disable the "store" repository format which improves
825 825 compatibility with systems that fold case or otherwise mangle
826 826 filenames. Disabling this option will allow you to store longer filenames
827 827 in some situations at the expense of compatibility.
828 828
829 829 Repositories with this on-disk format require Mercurial version 0.9.4.
830 830
831 831 Enabled by default.
832 832
833 833 ``graph``
834 834 ---------
835 835
836 836 Web graph view configuration. This section let you change graph
837 837 elements display properties by branches, for instance to make the
838 838 ``default`` branch stand out.
839 839
840 840 Each line has the following format::
841 841
842 842 <branch>.<argument> = <value>
843 843
844 844 where ``<branch>`` is the name of the branch being
845 845 customized. Example::
846 846
847 847 [graph]
848 848 # 2px width
849 849 default.width = 2
850 850 # red color
851 851 default.color = FF0000
852 852
853 853 Supported arguments:
854 854
855 855 ``width``
856 856 Set branch edges width in pixels.
857 857
858 858 ``color``
859 859 Set branch edges color in hexadecimal RGB notation.
860 860
861 861 ``hooks``
862 862 ---------
863 863
864 864 Commands or Python functions that get automatically executed by
865 865 various actions such as starting or finishing a commit. Multiple
866 866 hooks can be run for the same action by appending a suffix to the
867 867 action. Overriding a site-wide hook can be done by changing its
868 868 value or setting it to an empty string. Hooks can be prioritized
869 869 by adding a prefix of ``priority.`` to the hook name on a new line
870 870 and setting the priority. The default priority is 0.
871 871
872 872 Example ``.hg/hgrc``::
873 873
874 874 [hooks]
875 875 # update working directory after adding changesets
876 876 changegroup.update = hg update
877 877 # do not use the site-wide hook
878 878 incoming =
879 879 incoming.email = /my/email/hook
880 880 incoming.autobuild = /my/build/hook
881 881 # force autobuild hook to run before other incoming hooks
882 882 priority.incoming.autobuild = 1
883 883
884 884 Most hooks are run with environment variables set that give useful
885 885 additional information. For each hook below, the environment variables
886 886 it is passed are listed with names in the form ``$HG_foo``. The
887 887 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
888 888 They contain the type of hook which triggered the run and the full name
889 889 of the hook in the config, respectively. In the example above, this will
890 890 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
891 891
892 892 .. container:: windows
893 893
894 894 Some basic Unix syntax is supported for portability, including ``$VAR``
895 895 and ``${VAR}`` style variables. To use a literal ``$``, it must be
896 escaped with a back slash or inside of a strong quote.
896 escaped with a back slash or inside of a strong quote. This can be
897 disabled by adding a prefix of ``tonative.`` to the hook name on a new
898 line, and setting it to ``False``. For example::
899
900 [hooks]
901 incoming.autobuild = /my/build/hook
902 # disable translation to cmd.exe syntax for autobuild hook
903 tonative.incoming.autobuild = False
897 904
898 905 ``changegroup``
899 906 Run after a changegroup has been added via push, pull or unbundle. The ID of
900 907 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
901 908 The URL from which changes came is in ``$HG_URL``.
902 909
903 910 ``commit``
904 911 Run after a changeset has been created in the local repository. The ID
905 912 of the newly created changeset is in ``$HG_NODE``. Parent changeset
906 913 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
907 914
908 915 ``incoming``
909 916 Run after a changeset has been pulled, pushed, or unbundled into
910 917 the local repository. The ID of the newly arrived changeset is in
911 918 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
912 919
913 920 ``outgoing``
914 921 Run after sending changes from the local repository to another. The ID of
915 922 first changeset sent is in ``$HG_NODE``. The source of operation is in
916 923 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
917 924
918 925 ``post-<command>``
919 926 Run after successful invocations of the associated command. The
920 927 contents of the command line are passed as ``$HG_ARGS`` and the result
921 928 code in ``$HG_RESULT``. Parsed command line arguments are passed as
922 929 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
923 930 the python data internally passed to <command>. ``$HG_OPTS`` is a
924 931 dictionary of options (with unspecified options set to their defaults).
925 932 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
926 933
927 934 ``fail-<command>``
928 935 Run after a failed invocation of an associated command. The contents
929 936 of the command line are passed as ``$HG_ARGS``. Parsed command line
930 937 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
931 938 string representations of the python data internally passed to
932 939 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
933 940 options set to their defaults). ``$HG_PATS`` is a list of arguments.
934 941 Hook failure is ignored.
935 942
936 943 ``pre-<command>``
937 944 Run before executing the associated command. The contents of the
938 945 command line are passed as ``$HG_ARGS``. Parsed command line arguments
939 946 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
940 947 representations of the data internally passed to <command>. ``$HG_OPTS``
941 948 is a dictionary of options (with unspecified options set to their
942 949 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
943 950 failure, the command doesn't execute and Mercurial returns the failure
944 951 code.
945 952
946 953 ``prechangegroup``
947 954 Run before a changegroup is added via push, pull or unbundle. Exit
948 955 status 0 allows the changegroup to proceed. A non-zero status will
949 956 cause the push, pull or unbundle to fail. The URL from which changes
950 957 will come is in ``$HG_URL``.
951 958
952 959 ``precommit``
953 960 Run before starting a local commit. Exit status 0 allows the
954 961 commit to proceed. A non-zero status will cause the commit to fail.
955 962 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
956 963
957 964 ``prelistkeys``
958 965 Run before listing pushkeys (like bookmarks) in the
959 966 repository. A non-zero status will cause failure. The key namespace is
960 967 in ``$HG_NAMESPACE``.
961 968
962 969 ``preoutgoing``
963 970 Run before collecting changes to send from the local repository to
964 971 another. A non-zero status will cause failure. This lets you prevent
965 972 pull over HTTP or SSH. It can also prevent propagating commits (via
966 973 local pull, push (outbound) or bundle commands), but not completely,
967 974 since you can just copy files instead. The source of operation is in
968 975 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
969 976 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
970 977 is happening on behalf of a repository on same system.
971 978
972 979 ``prepushkey``
973 980 Run before a pushkey (like a bookmark) is added to the
974 981 repository. A non-zero status will cause the key to be rejected. The
975 982 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
976 983 the old value (if any) is in ``$HG_OLD``, and the new value is in
977 984 ``$HG_NEW``.
978 985
979 986 ``pretag``
980 987 Run before creating a tag. Exit status 0 allows the tag to be
981 988 created. A non-zero status will cause the tag to fail. The ID of the
982 989 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
983 990 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
984 991
985 992 ``pretxnopen``
986 993 Run before any new repository transaction is open. The reason for the
987 994 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
988 995 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
989 996 transaction from being opened.
990 997
991 998 ``pretxnclose``
992 999 Run right before the transaction is actually finalized. Any repository change
993 1000 will be visible to the hook program. This lets you validate the transaction
994 1001 content or change it. Exit status 0 allows the commit to proceed. A non-zero
995 1002 status will cause the transaction to be rolled back. The reason for the
996 1003 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
997 1004 the transaction will be in ``HG_TXNID``. The rest of the available data will
998 1005 vary according the transaction type. New changesets will add ``$HG_NODE``
999 1006 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1000 1007 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1001 1008 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1002 1009 respectively, etc.
1003 1010
1004 1011 ``pretxnclose-bookmark``
1005 1012 Run right before a bookmark change is actually finalized. Any repository
1006 1013 change will be visible to the hook program. This lets you validate the
1007 1014 transaction content or change it. Exit status 0 allows the commit to
1008 1015 proceed. A non-zero status will cause the transaction to be rolled back.
1009 1016 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1010 1017 bookmark location will be available in ``$HG_NODE`` while the previous
1011 1018 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1012 1019 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1013 1020 will be empty.
1014 1021 In addition, the reason for the transaction opening will be in
1015 1022 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1016 1023 ``HG_TXNID``.
1017 1024
1018 1025 ``pretxnclose-phase``
1019 1026 Run right before a phase change is actually finalized. Any repository change
1020 1027 will be visible to the hook program. This lets you validate the transaction
1021 1028 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1022 1029 status will cause the transaction to be rolled back. The hook is called
1023 1030 multiple times, once for each revision affected by a phase change.
1024 1031 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1025 1032 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1026 1033 will be empty. In addition, the reason for the transaction opening will be in
1027 1034 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1028 1035 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1029 1036 the ``$HG_OLDPHASE`` entry will be empty.
1030 1037
1031 1038 ``txnclose``
1032 1039 Run after any repository transaction has been committed. At this
1033 1040 point, the transaction can no longer be rolled back. The hook will run
1034 1041 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1035 1042 details about available variables.
1036 1043
1037 1044 ``txnclose-bookmark``
1038 1045 Run after any bookmark change has been committed. At this point, the
1039 1046 transaction can no longer be rolled back. The hook will run after the lock
1040 1047 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1041 1048 about available variables.
1042 1049
1043 1050 ``txnclose-phase``
1044 1051 Run after any phase change has been committed. At this point, the
1045 1052 transaction can no longer be rolled back. The hook will run after the lock
1046 1053 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1047 1054 available variables.
1048 1055
1049 1056 ``txnabort``
1050 1057 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1051 1058 for details about available variables.
1052 1059
1053 1060 ``pretxnchangegroup``
1054 1061 Run after a changegroup has been added via push, pull or unbundle, but before
1055 1062 the transaction has been committed. The changegroup is visible to the hook
1056 1063 program. This allows validation of incoming changes before accepting them.
1057 1064 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1058 1065 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1059 1066 status will cause the transaction to be rolled back, and the push, pull or
1060 1067 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1061 1068
1062 1069 ``pretxncommit``
1063 1070 Run after a changeset has been created, but before the transaction is
1064 1071 committed. The changeset is visible to the hook program. This allows
1065 1072 validation of the commit message and changes. Exit status 0 allows the
1066 1073 commit to proceed. A non-zero status will cause the transaction to
1067 1074 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1068 1075 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1069 1076
1070 1077 ``preupdate``
1071 1078 Run before updating the working directory. Exit status 0 allows
1072 1079 the update to proceed. A non-zero status will prevent the update.
1073 1080 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1074 1081 merge, the ID of second new parent is in ``$HG_PARENT2``.
1075 1082
1076 1083 ``listkeys``
1077 1084 Run after listing pushkeys (like bookmarks) in the repository. The
1078 1085 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1079 1086 dictionary containing the keys and values.
1080 1087
1081 1088 ``pushkey``
1082 1089 Run after a pushkey (like a bookmark) is added to the
1083 1090 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1084 1091 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1085 1092 value is in ``$HG_NEW``.
1086 1093
1087 1094 ``tag``
1088 1095 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1089 1096 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1090 1097 the repository if ``$HG_LOCAL=0``.
1091 1098
1092 1099 ``update``
1093 1100 Run after updating the working directory. The changeset ID of first
1094 1101 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1095 1102 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1096 1103 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1097 1104
1098 1105 .. note::
1099 1106
1100 1107 It is generally better to use standard hooks rather than the
1101 1108 generic pre- and post- command hooks, as they are guaranteed to be
1102 1109 called in the appropriate contexts for influencing transactions.
1103 1110 Also, hooks like "commit" will be called in all contexts that
1104 1111 generate a commit (e.g. tag) and not just the commit command.
1105 1112
1106 1113 .. note::
1107 1114
1108 1115 Environment variables with empty values may not be passed to
1109 1116 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1110 1117 will have an empty value under Unix-like platforms for non-merge
1111 1118 changesets, while it will not be available at all under Windows.
1112 1119
1113 1120 The syntax for Python hooks is as follows::
1114 1121
1115 1122 hookname = python:modulename.submodule.callable
1116 1123 hookname = python:/path/to/python/module.py:callable
1117 1124
1118 1125 Python hooks are run within the Mercurial process. Each hook is
1119 1126 called with at least three keyword arguments: a ui object (keyword
1120 1127 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1121 1128 keyword that tells what kind of hook is used. Arguments listed as
1122 1129 environment variables above are passed as keyword arguments, with no
1123 1130 ``HG_`` prefix, and names in lower case.
1124 1131
1125 1132 If a Python hook returns a "true" value or raises an exception, this
1126 1133 is treated as a failure.
1127 1134
1128 1135
1129 1136 ``hostfingerprints``
1130 1137 --------------------
1131 1138
1132 1139 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1133 1140
1134 1141 Fingerprints of the certificates of known HTTPS servers.
1135 1142
1136 1143 A HTTPS connection to a server with a fingerprint configured here will
1137 1144 only succeed if the servers certificate matches the fingerprint.
1138 1145 This is very similar to how ssh known hosts works.
1139 1146
1140 1147 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1141 1148 Multiple values can be specified (separated by spaces or commas). This can
1142 1149 be used to define both old and new fingerprints while a host transitions
1143 1150 to a new certificate.
1144 1151
1145 1152 The CA chain and web.cacerts is not used for servers with a fingerprint.
1146 1153
1147 1154 For example::
1148 1155
1149 1156 [hostfingerprints]
1150 1157 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1151 1158 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1152 1159
1153 1160 ``hostsecurity``
1154 1161 ----------------
1155 1162
1156 1163 Used to specify global and per-host security settings for connecting to
1157 1164 other machines.
1158 1165
1159 1166 The following options control default behavior for all hosts.
1160 1167
1161 1168 ``ciphers``
1162 1169 Defines the cryptographic ciphers to use for connections.
1163 1170
1164 1171 Value must be a valid OpenSSL Cipher List Format as documented at
1165 1172 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1166 1173
1167 1174 This setting is for advanced users only. Setting to incorrect values
1168 1175 can significantly lower connection security or decrease performance.
1169 1176 You have been warned.
1170 1177
1171 1178 This option requires Python 2.7.
1172 1179
1173 1180 ``minimumprotocol``
1174 1181 Defines the minimum channel encryption protocol to use.
1175 1182
1176 1183 By default, the highest version of TLS supported by both client and server
1177 1184 is used.
1178 1185
1179 1186 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1180 1187
1181 1188 When running on an old Python version, only ``tls1.0`` is allowed since
1182 1189 old versions of Python only support up to TLS 1.0.
1183 1190
1184 1191 When running a Python that supports modern TLS versions, the default is
1185 1192 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1186 1193 weakens security and should only be used as a feature of last resort if
1187 1194 a server does not support TLS 1.1+.
1188 1195
1189 1196 Options in the ``[hostsecurity]`` section can have the form
1190 1197 ``hostname``:``setting``. This allows multiple settings to be defined on a
1191 1198 per-host basis.
1192 1199
1193 1200 The following per-host settings can be defined.
1194 1201
1195 1202 ``ciphers``
1196 1203 This behaves like ``ciphers`` as described above except it only applies
1197 1204 to the host on which it is defined.
1198 1205
1199 1206 ``fingerprints``
1200 1207 A list of hashes of the DER encoded peer/remote certificate. Values have
1201 1208 the form ``algorithm``:``fingerprint``. e.g.
1202 1209 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1203 1210 In addition, colons (``:``) can appear in the fingerprint part.
1204 1211
1205 1212 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1206 1213 ``sha512``.
1207 1214
1208 1215 Use of ``sha256`` or ``sha512`` is preferred.
1209 1216
1210 1217 If a fingerprint is specified, the CA chain is not validated for this
1211 1218 host and Mercurial will require the remote certificate to match one
1212 1219 of the fingerprints specified. This means if the server updates its
1213 1220 certificate, Mercurial will abort until a new fingerprint is defined.
1214 1221 This can provide stronger security than traditional CA-based validation
1215 1222 at the expense of convenience.
1216 1223
1217 1224 This option takes precedence over ``verifycertsfile``.
1218 1225
1219 1226 ``minimumprotocol``
1220 1227 This behaves like ``minimumprotocol`` as described above except it
1221 1228 only applies to the host on which it is defined.
1222 1229
1223 1230 ``verifycertsfile``
1224 1231 Path to file a containing a list of PEM encoded certificates used to
1225 1232 verify the server certificate. Environment variables and ``~user``
1226 1233 constructs are expanded in the filename.
1227 1234
1228 1235 The server certificate or the certificate's certificate authority (CA)
1229 1236 must match a certificate from this file or certificate verification
1230 1237 will fail and connections to the server will be refused.
1231 1238
1232 1239 If defined, only certificates provided by this file will be used:
1233 1240 ``web.cacerts`` and any system/default certificates will not be
1234 1241 used.
1235 1242
1236 1243 This option has no effect if the per-host ``fingerprints`` option
1237 1244 is set.
1238 1245
1239 1246 The format of the file is as follows::
1240 1247
1241 1248 -----BEGIN CERTIFICATE-----
1242 1249 ... (certificate in base64 PEM encoding) ...
1243 1250 -----END CERTIFICATE-----
1244 1251 -----BEGIN CERTIFICATE-----
1245 1252 ... (certificate in base64 PEM encoding) ...
1246 1253 -----END CERTIFICATE-----
1247 1254
1248 1255 For example::
1249 1256
1250 1257 [hostsecurity]
1251 1258 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1252 1259 hg2.example.com:fingerprints = sha1:914f1aff87249c09b6859b88b1906d30756491ca, sha1:fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1253 1260 hg3.example.com:fingerprints = sha256:9a:b0:dc:e2:75:ad:8a:b7:84:58:e5:1f:07:32:f1:87:e6:bd:24:22:af:b7:ce:8e:9c:b4:10:cf:b9:f4:0e:d2
1254 1261 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1255 1262
1256 1263 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1257 1264 when connecting to ``hg.example.com``::
1258 1265
1259 1266 [hostsecurity]
1260 1267 minimumprotocol = tls1.2
1261 1268 hg.example.com:minimumprotocol = tls1.1
1262 1269
1263 1270 ``http_proxy``
1264 1271 --------------
1265 1272
1266 1273 Used to access web-based Mercurial repositories through a HTTP
1267 1274 proxy.
1268 1275
1269 1276 ``host``
1270 1277 Host name and (optional) port of the proxy server, for example
1271 1278 "myproxy:8000".
1272 1279
1273 1280 ``no``
1274 1281 Optional. Comma-separated list of host names that should bypass
1275 1282 the proxy.
1276 1283
1277 1284 ``passwd``
1278 1285 Optional. Password to authenticate with at the proxy server.
1279 1286
1280 1287 ``user``
1281 1288 Optional. User name to authenticate with at the proxy server.
1282 1289
1283 1290 ``always``
1284 1291 Optional. Always use the proxy, even for localhost and any entries
1285 1292 in ``http_proxy.no``. (default: False)
1286 1293
1287 1294 ``merge``
1288 1295 ---------
1289 1296
1290 1297 This section specifies behavior during merges and updates.
1291 1298
1292 1299 ``checkignored``
1293 1300 Controls behavior when an ignored file on disk has the same name as a tracked
1294 1301 file in the changeset being merged or updated to, and has different
1295 1302 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1296 1303 abort on such files. With ``warn``, warn on such files and back them up as
1297 1304 ``.orig``. With ``ignore``, don't print a warning and back them up as
1298 1305 ``.orig``. (default: ``abort``)
1299 1306
1300 1307 ``checkunknown``
1301 1308 Controls behavior when an unknown file that isn't ignored has the same name
1302 1309 as a tracked file in the changeset being merged or updated to, and has
1303 1310 different contents. Similar to ``merge.checkignored``, except for files that
1304 1311 are not ignored. (default: ``abort``)
1305 1312
1306 1313 ``on-failure``
1307 1314 When set to ``continue`` (the default), the merge process attempts to
1308 1315 merge all unresolved files using the merge chosen tool, regardless of
1309 1316 whether previous file merge attempts during the process succeeded or not.
1310 1317 Setting this to ``prompt`` will prompt after any merge failure continue
1311 1318 or halt the merge process. Setting this to ``halt`` will automatically
1312 1319 halt the merge process on any merge tool failure. The merge process
1313 1320 can be restarted by using the ``resolve`` command. When a merge is
1314 1321 halted, the repository is left in a normal ``unresolved`` merge state.
1315 1322 (default: ``continue``)
1316 1323
1317 1324 ``merge-patterns``
1318 1325 ------------------
1319 1326
1320 1327 This section specifies merge tools to associate with particular file
1321 1328 patterns. Tools matched here will take precedence over the default
1322 1329 merge tool. Patterns are globs by default, rooted at the repository
1323 1330 root.
1324 1331
1325 1332 Example::
1326 1333
1327 1334 [merge-patterns]
1328 1335 **.c = kdiff3
1329 1336 **.jpg = myimgmerge
1330 1337
1331 1338 ``merge-tools``
1332 1339 ---------------
1333 1340
1334 1341 This section configures external merge tools to use for file-level
1335 1342 merges. This section has likely been preconfigured at install time.
1336 1343 Use :hg:`config merge-tools` to check the existing configuration.
1337 1344 Also see :hg:`help merge-tools` for more details.
1338 1345
1339 1346 Example ``~/.hgrc``::
1340 1347
1341 1348 [merge-tools]
1342 1349 # Override stock tool location
1343 1350 kdiff3.executable = ~/bin/kdiff3
1344 1351 # Specify command line
1345 1352 kdiff3.args = $base $local $other -o $output
1346 1353 # Give higher priority
1347 1354 kdiff3.priority = 1
1348 1355
1349 1356 # Changing the priority of preconfigured tool
1350 1357 meld.priority = 0
1351 1358
1352 1359 # Disable a preconfigured tool
1353 1360 vimdiff.disabled = yes
1354 1361
1355 1362 # Define new tool
1356 1363 myHtmlTool.args = -m $local $other $base $output
1357 1364 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1358 1365 myHtmlTool.priority = 1
1359 1366
1360 1367 Supported arguments:
1361 1368
1362 1369 ``priority``
1363 1370 The priority in which to evaluate this tool.
1364 1371 (default: 0)
1365 1372
1366 1373 ``executable``
1367 1374 Either just the name of the executable or its pathname.
1368 1375
1369 1376 .. container:: windows
1370 1377
1371 1378 On Windows, the path can use environment variables with ${ProgramFiles}
1372 1379 syntax.
1373 1380
1374 1381 (default: the tool name)
1375 1382
1376 1383 ``args``
1377 1384 The arguments to pass to the tool executable. You can refer to the
1378 1385 files being merged as well as the output file through these
1379 1386 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1380 1387
1381 1388 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1382 1389 being performed. During an update or merge, ``$local`` represents the original
1383 1390 state of the file, while ``$other`` represents the commit you are updating to or
1384 1391 the commit you are merging with. During a rebase, ``$local`` represents the
1385 1392 destination of the rebase, and ``$other`` represents the commit being rebased.
1386 1393
1387 1394 Some operations define custom labels to assist with identifying the revisions,
1388 1395 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1389 1396 labels are not available, these will be ``local``, ``other``, and ``base``,
1390 1397 respectively.
1391 1398 (default: ``$local $base $other``)
1392 1399
1393 1400 ``premerge``
1394 1401 Attempt to run internal non-interactive 3-way merge tool before
1395 1402 launching external tool. Options are ``true``, ``false``, ``keep`` or
1396 1403 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1397 1404 premerge fails. The ``keep-merge3`` will do the same but include information
1398 1405 about the base of the merge in the marker (see internal :merge3 in
1399 1406 :hg:`help merge-tools`).
1400 1407 (default: True)
1401 1408
1402 1409 ``binary``
1403 1410 This tool can merge binary files. (default: False, unless tool
1404 1411 was selected by file pattern match)
1405 1412
1406 1413 ``symlink``
1407 1414 This tool can merge symlinks. (default: False)
1408 1415
1409 1416 ``check``
1410 1417 A list of merge success-checking options:
1411 1418
1412 1419 ``changed``
1413 1420 Ask whether merge was successful when the merged file shows no changes.
1414 1421 ``conflicts``
1415 1422 Check whether there are conflicts even though the tool reported success.
1416 1423 ``prompt``
1417 1424 Always prompt for merge success, regardless of success reported by tool.
1418 1425
1419 1426 ``fixeol``
1420 1427 Attempt to fix up EOL changes caused by the merge tool.
1421 1428 (default: False)
1422 1429
1423 1430 ``gui``
1424 1431 This tool requires a graphical interface to run. (default: False)
1425 1432
1426 1433 ``mergemarkers``
1427 1434 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1428 1435 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1429 1436 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1430 1437 markers generated during premerge will be ``detailed`` if either this option or
1431 1438 the corresponding option in the ``[ui]`` section is ``detailed``.
1432 1439 (default: ``basic``)
1433 1440
1434 1441 ``mergemarkertemplate``
1435 1442 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1436 1443 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1437 1444 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1438 1445 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1439 1446 information.
1440 1447
1441 1448 .. container:: windows
1442 1449
1443 1450 ``regkey``
1444 1451 Windows registry key which describes install location of this
1445 1452 tool. Mercurial will search for this key first under
1446 1453 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1447 1454 (default: None)
1448 1455
1449 1456 ``regkeyalt``
1450 1457 An alternate Windows registry key to try if the first key is not
1451 1458 found. The alternate key uses the same ``regname`` and ``regappend``
1452 1459 semantics of the primary key. The most common use for this key
1453 1460 is to search for 32bit applications on 64bit operating systems.
1454 1461 (default: None)
1455 1462
1456 1463 ``regname``
1457 1464 Name of value to read from specified registry key.
1458 1465 (default: the unnamed (default) value)
1459 1466
1460 1467 ``regappend``
1461 1468 String to append to the value read from the registry, typically
1462 1469 the executable name of the tool.
1463 1470 (default: None)
1464 1471
1465 1472 ``pager``
1466 1473 ---------
1467 1474
1468 1475 Setting used to control when to paginate and with what external tool. See
1469 1476 :hg:`help pager` for details.
1470 1477
1471 1478 ``pager``
1472 1479 Define the external tool used as pager.
1473 1480
1474 1481 If no pager is set, Mercurial uses the environment variable $PAGER.
1475 1482 If neither pager.pager, nor $PAGER is set, a default pager will be
1476 1483 used, typically `less` on Unix and `more` on Windows. Example::
1477 1484
1478 1485 [pager]
1479 1486 pager = less -FRX
1480 1487
1481 1488 ``ignore``
1482 1489 List of commands to disable the pager for. Example::
1483 1490
1484 1491 [pager]
1485 1492 ignore = version, help, update
1486 1493
1487 1494 ``patch``
1488 1495 ---------
1489 1496
1490 1497 Settings used when applying patches, for instance through the 'import'
1491 1498 command or with Mercurial Queues extension.
1492 1499
1493 1500 ``eol``
1494 1501 When set to 'strict' patch content and patched files end of lines
1495 1502 are preserved. When set to ``lf`` or ``crlf``, both files end of
1496 1503 lines are ignored when patching and the result line endings are
1497 1504 normalized to either LF (Unix) or CRLF (Windows). When set to
1498 1505 ``auto``, end of lines are again ignored while patching but line
1499 1506 endings in patched files are normalized to their original setting
1500 1507 on a per-file basis. If target file does not exist or has no end
1501 1508 of line, patch line endings are preserved.
1502 1509 (default: strict)
1503 1510
1504 1511 ``fuzz``
1505 1512 The number of lines of 'fuzz' to allow when applying patches. This
1506 1513 controls how much context the patcher is allowed to ignore when
1507 1514 trying to apply a patch.
1508 1515 (default: 2)
1509 1516
1510 1517 ``paths``
1511 1518 ---------
1512 1519
1513 1520 Assigns symbolic names and behavior to repositories.
1514 1521
1515 1522 Options are symbolic names defining the URL or directory that is the
1516 1523 location of the repository. Example::
1517 1524
1518 1525 [paths]
1519 1526 my_server = https://example.com/my_repo
1520 1527 local_path = /home/me/repo
1521 1528
1522 1529 These symbolic names can be used from the command line. To pull
1523 1530 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1524 1531 :hg:`push local_path`.
1525 1532
1526 1533 Options containing colons (``:``) denote sub-options that can influence
1527 1534 behavior for that specific path. Example::
1528 1535
1529 1536 [paths]
1530 1537 my_server = https://example.com/my_path
1531 1538 my_server:pushurl = ssh://example.com/my_path
1532 1539
1533 1540 The following sub-options can be defined:
1534 1541
1535 1542 ``pushurl``
1536 1543 The URL to use for push operations. If not defined, the location
1537 1544 defined by the path's main entry is used.
1538 1545
1539 1546 ``pushrev``
1540 1547 A revset defining which revisions to push by default.
1541 1548
1542 1549 When :hg:`push` is executed without a ``-r`` argument, the revset
1543 1550 defined by this sub-option is evaluated to determine what to push.
1544 1551
1545 1552 For example, a value of ``.`` will push the working directory's
1546 1553 revision by default.
1547 1554
1548 1555 Revsets specifying bookmarks will not result in the bookmark being
1549 1556 pushed.
1550 1557
1551 1558 The following special named paths exist:
1552 1559
1553 1560 ``default``
1554 1561 The URL or directory to use when no source or remote is specified.
1555 1562
1556 1563 :hg:`clone` will automatically define this path to the location the
1557 1564 repository was cloned from.
1558 1565
1559 1566 ``default-push``
1560 1567 (deprecated) The URL or directory for the default :hg:`push` location.
1561 1568 ``default:pushurl`` should be used instead.
1562 1569
1563 1570 ``phases``
1564 1571 ----------
1565 1572
1566 1573 Specifies default handling of phases. See :hg:`help phases` for more
1567 1574 information about working with phases.
1568 1575
1569 1576 ``publish``
1570 1577 Controls draft phase behavior when working as a server. When true,
1571 1578 pushed changesets are set to public in both client and server and
1572 1579 pulled or cloned changesets are set to public in the client.
1573 1580 (default: True)
1574 1581
1575 1582 ``new-commit``
1576 1583 Phase of newly-created commits.
1577 1584 (default: draft)
1578 1585
1579 1586 ``checksubrepos``
1580 1587 Check the phase of the current revision of each subrepository. Allowed
1581 1588 values are "ignore", "follow" and "abort". For settings other than
1582 1589 "ignore", the phase of the current revision of each subrepository is
1583 1590 checked before committing the parent repository. If any of those phases is
1584 1591 greater than the phase of the parent repository (e.g. if a subrepo is in a
1585 1592 "secret" phase while the parent repo is in "draft" phase), the commit is
1586 1593 either aborted (if checksubrepos is set to "abort") or the higher phase is
1587 1594 used for the parent repository commit (if set to "follow").
1588 1595 (default: follow)
1589 1596
1590 1597
1591 1598 ``profiling``
1592 1599 -------------
1593 1600
1594 1601 Specifies profiling type, format, and file output. Two profilers are
1595 1602 supported: an instrumenting profiler (named ``ls``), and a sampling
1596 1603 profiler (named ``stat``).
1597 1604
1598 1605 In this section description, 'profiling data' stands for the raw data
1599 1606 collected during profiling, while 'profiling report' stands for a
1600 1607 statistical text report generated from the profiling data.
1601 1608
1602 1609 ``enabled``
1603 1610 Enable the profiler.
1604 1611 (default: false)
1605 1612
1606 1613 This is equivalent to passing ``--profile`` on the command line.
1607 1614
1608 1615 ``type``
1609 1616 The type of profiler to use.
1610 1617 (default: stat)
1611 1618
1612 1619 ``ls``
1613 1620 Use Python's built-in instrumenting profiler. This profiler
1614 1621 works on all platforms, but each line number it reports is the
1615 1622 first line of a function. This restriction makes it difficult to
1616 1623 identify the expensive parts of a non-trivial function.
1617 1624 ``stat``
1618 1625 Use a statistical profiler, statprof. This profiler is most
1619 1626 useful for profiling commands that run for longer than about 0.1
1620 1627 seconds.
1621 1628
1622 1629 ``format``
1623 1630 Profiling format. Specific to the ``ls`` instrumenting profiler.
1624 1631 (default: text)
1625 1632
1626 1633 ``text``
1627 1634 Generate a profiling report. When saving to a file, it should be
1628 1635 noted that only the report is saved, and the profiling data is
1629 1636 not kept.
1630 1637 ``kcachegrind``
1631 1638 Format profiling data for kcachegrind use: when saving to a
1632 1639 file, the generated file can directly be loaded into
1633 1640 kcachegrind.
1634 1641
1635 1642 ``statformat``
1636 1643 Profiling format for the ``stat`` profiler.
1637 1644 (default: hotpath)
1638 1645
1639 1646 ``hotpath``
1640 1647 Show a tree-based display containing the hot path of execution (where
1641 1648 most time was spent).
1642 1649 ``bymethod``
1643 1650 Show a table of methods ordered by how frequently they are active.
1644 1651 ``byline``
1645 1652 Show a table of lines in files ordered by how frequently they are active.
1646 1653 ``json``
1647 1654 Render profiling data as JSON.
1648 1655
1649 1656 ``frequency``
1650 1657 Sampling frequency. Specific to the ``stat`` sampling profiler.
1651 1658 (default: 1000)
1652 1659
1653 1660 ``output``
1654 1661 File path where profiling data or report should be saved. If the
1655 1662 file exists, it is replaced. (default: None, data is printed on
1656 1663 stderr)
1657 1664
1658 1665 ``sort``
1659 1666 Sort field. Specific to the ``ls`` instrumenting profiler.
1660 1667 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1661 1668 ``inlinetime``.
1662 1669 (default: inlinetime)
1663 1670
1664 1671 ``time-track``
1665 1672 Control if the stat profiler track ``cpu`` or ``real`` time.
1666 1673 (default: ``cpu``)
1667 1674
1668 1675 ``limit``
1669 1676 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1670 1677 (default: 30)
1671 1678
1672 1679 ``nested``
1673 1680 Show at most this number of lines of drill-down info after each main entry.
1674 1681 This can help explain the difference between Total and Inline.
1675 1682 Specific to the ``ls`` instrumenting profiler.
1676 1683 (default: 0)
1677 1684
1678 1685 ``showmin``
1679 1686 Minimum fraction of samples an entry must have for it to be displayed.
1680 1687 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1681 1688 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1682 1689
1683 1690 Only used by the ``stat`` profiler.
1684 1691
1685 1692 For the ``hotpath`` format, default is ``0.05``.
1686 1693 For the ``chrome`` format, default is ``0.005``.
1687 1694
1688 1695 The option is unused on other formats.
1689 1696
1690 1697 ``showmax``
1691 1698 Maximum fraction of samples an entry can have before it is ignored in
1692 1699 display. Values format is the same as ``showmin``.
1693 1700
1694 1701 Only used by the ``stat`` profiler.
1695 1702
1696 1703 For the ``chrome`` format, default is ``0.999``.
1697 1704
1698 1705 The option is unused on other formats.
1699 1706
1700 1707 ``progress``
1701 1708 ------------
1702 1709
1703 1710 Mercurial commands can draw progress bars that are as informative as
1704 1711 possible. Some progress bars only offer indeterminate information, while others
1705 1712 have a definite end point.
1706 1713
1707 1714 ``delay``
1708 1715 Number of seconds (float) before showing the progress bar. (default: 3)
1709 1716
1710 1717 ``changedelay``
1711 1718 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1712 1719 that value will be used instead. (default: 1)
1713 1720
1714 1721 ``estimateinterval``
1715 1722 Maximum sampling interval in seconds for speed and estimated time
1716 1723 calculation. (default: 60)
1717 1724
1718 1725 ``refresh``
1719 1726 Time in seconds between refreshes of the progress bar. (default: 0.1)
1720 1727
1721 1728 ``format``
1722 1729 Format of the progress bar.
1723 1730
1724 1731 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1725 1732 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1726 1733 last 20 characters of the item, but this can be changed by adding either
1727 1734 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1728 1735 first num characters.
1729 1736
1730 1737 (default: topic bar number estimate)
1731 1738
1732 1739 ``width``
1733 1740 If set, the maximum width of the progress information (that is, min(width,
1734 1741 term width) will be used).
1735 1742
1736 1743 ``clear-complete``
1737 1744 Clear the progress bar after it's done. (default: True)
1738 1745
1739 1746 ``disable``
1740 1747 If true, don't show a progress bar.
1741 1748
1742 1749 ``assume-tty``
1743 1750 If true, ALWAYS show a progress bar, unless disable is given.
1744 1751
1745 1752 ``rebase``
1746 1753 ----------
1747 1754
1748 1755 ``evolution.allowdivergence``
1749 1756 Default to False, when True allow creating divergence when performing
1750 1757 rebase of obsolete changesets.
1751 1758
1752 1759 ``revsetalias``
1753 1760 ---------------
1754 1761
1755 1762 Alias definitions for revsets. See :hg:`help revsets` for details.
1756 1763
1757 1764 ``server``
1758 1765 ----------
1759 1766
1760 1767 Controls generic server settings.
1761 1768
1762 1769 ``bookmarks-pushkey-compat``
1763 1770 Trigger pushkey hook when being pushed bookmark updates. This config exist
1764 1771 for compatibility purpose (default to True)
1765 1772
1766 1773 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1767 1774 movement we recommend you migrate them to ``txnclose-bookmark`` and
1768 1775 ``pretxnclose-bookmark``.
1769 1776
1770 1777 ``compressionengines``
1771 1778 List of compression engines and their relative priority to advertise
1772 1779 to clients.
1773 1780
1774 1781 The order of compression engines determines their priority, the first
1775 1782 having the highest priority. If a compression engine is not listed
1776 1783 here, it won't be advertised to clients.
1777 1784
1778 1785 If not set (the default), built-in defaults are used. Run
1779 1786 :hg:`debuginstall` to list available compression engines and their
1780 1787 default wire protocol priority.
1781 1788
1782 1789 Older Mercurial clients only support zlib compression and this setting
1783 1790 has no effect for legacy clients.
1784 1791
1785 1792 ``uncompressed``
1786 1793 Whether to allow clients to clone a repository using the
1787 1794 uncompressed streaming protocol. This transfers about 40% more
1788 1795 data than a regular clone, but uses less memory and CPU on both
1789 1796 server and client. Over a LAN (100 Mbps or better) or a very fast
1790 1797 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1791 1798 regular clone. Over most WAN connections (anything slower than
1792 1799 about 6 Mbps), uncompressed streaming is slower, because of the
1793 1800 extra data transfer overhead. This mode will also temporarily hold
1794 1801 the write lock while determining what data to transfer.
1795 1802 (default: True)
1796 1803
1797 1804 ``uncompressedallowsecret``
1798 1805 Whether to allow stream clones when the repository contains secret
1799 1806 changesets. (default: False)
1800 1807
1801 1808 ``preferuncompressed``
1802 1809 When set, clients will try to use the uncompressed streaming
1803 1810 protocol. (default: False)
1804 1811
1805 1812 ``disablefullbundle``
1806 1813 When set, servers will refuse attempts to do pull-based clones.
1807 1814 If this option is set, ``preferuncompressed`` and/or clone bundles
1808 1815 are highly recommended. Partial clones will still be allowed.
1809 1816 (default: False)
1810 1817
1811 1818 ``streamunbundle``
1812 1819 When set, servers will apply data sent from the client directly,
1813 1820 otherwise it will be written to a temporary file first. This option
1814 1821 effectively prevents concurrent pushes.
1815 1822
1816 1823 ``pullbundle``
1817 1824 When set, the server will check pullbundle.manifest for bundles
1818 1825 covering the requested heads and common nodes. The first matching
1819 1826 entry will be streamed to the client.
1820 1827
1821 1828 For HTTP transport, the stream will still use zlib compression
1822 1829 for older clients.
1823 1830
1824 1831 ``concurrent-push-mode``
1825 1832 Level of allowed race condition between two pushing clients.
1826 1833
1827 1834 - 'strict': push is abort if another client touched the repository
1828 1835 while the push was preparing. (default)
1829 1836 - 'check-related': push is only aborted if it affects head that got also
1830 1837 affected while the push was preparing.
1831 1838
1832 1839 This requires compatible client (version 4.3 and later). Old client will
1833 1840 use 'strict'.
1834 1841
1835 1842 ``validate``
1836 1843 Whether to validate the completeness of pushed changesets by
1837 1844 checking that all new file revisions specified in manifests are
1838 1845 present. (default: False)
1839 1846
1840 1847 ``maxhttpheaderlen``
1841 1848 Instruct HTTP clients not to send request headers longer than this
1842 1849 many bytes. (default: 1024)
1843 1850
1844 1851 ``bundle1``
1845 1852 Whether to allow clients to push and pull using the legacy bundle1
1846 1853 exchange format. (default: True)
1847 1854
1848 1855 ``bundle1gd``
1849 1856 Like ``bundle1`` but only used if the repository is using the
1850 1857 *generaldelta* storage format. (default: True)
1851 1858
1852 1859 ``bundle1.push``
1853 1860 Whether to allow clients to push using the legacy bundle1 exchange
1854 1861 format. (default: True)
1855 1862
1856 1863 ``bundle1gd.push``
1857 1864 Like ``bundle1.push`` but only used if the repository is using the
1858 1865 *generaldelta* storage format. (default: True)
1859 1866
1860 1867 ``bundle1.pull``
1861 1868 Whether to allow clients to pull using the legacy bundle1 exchange
1862 1869 format. (default: True)
1863 1870
1864 1871 ``bundle1gd.pull``
1865 1872 Like ``bundle1.pull`` but only used if the repository is using the
1866 1873 *generaldelta* storage format. (default: True)
1867 1874
1868 1875 Large repositories using the *generaldelta* storage format should
1869 1876 consider setting this option because converting *generaldelta*
1870 1877 repositories to the exchange format required by the bundle1 data
1871 1878 format can consume a lot of CPU.
1872 1879
1873 1880 ``zliblevel``
1874 1881 Integer between ``-1`` and ``9`` that controls the zlib compression level
1875 1882 for wire protocol commands that send zlib compressed output (notably the
1876 1883 commands that send repository history data).
1877 1884
1878 1885 The default (``-1``) uses the default zlib compression level, which is
1879 1886 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1880 1887 maximum compression.
1881 1888
1882 1889 Setting this option allows server operators to make trade-offs between
1883 1890 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1884 1891 but sends more bytes to clients.
1885 1892
1886 1893 This option only impacts the HTTP server.
1887 1894
1888 1895 ``zstdlevel``
1889 1896 Integer between ``1`` and ``22`` that controls the zstd compression level
1890 1897 for wire protocol commands. ``1`` is the minimal amount of compression and
1891 1898 ``22`` is the highest amount of compression.
1892 1899
1893 1900 The default (``3``) should be significantly faster than zlib while likely
1894 1901 delivering better compression ratios.
1895 1902
1896 1903 This option only impacts the HTTP server.
1897 1904
1898 1905 See also ``server.zliblevel``.
1899 1906
1900 1907 ``smtp``
1901 1908 --------
1902 1909
1903 1910 Configuration for extensions that need to send email messages.
1904 1911
1905 1912 ``host``
1906 1913 Host name of mail server, e.g. "mail.example.com".
1907 1914
1908 1915 ``port``
1909 1916 Optional. Port to connect to on mail server. (default: 465 if
1910 1917 ``tls`` is smtps; 25 otherwise)
1911 1918
1912 1919 ``tls``
1913 1920 Optional. Method to enable TLS when connecting to mail server: starttls,
1914 1921 smtps or none. (default: none)
1915 1922
1916 1923 ``username``
1917 1924 Optional. User name for authenticating with the SMTP server.
1918 1925 (default: None)
1919 1926
1920 1927 ``password``
1921 1928 Optional. Password for authenticating with the SMTP server. If not
1922 1929 specified, interactive sessions will prompt the user for a
1923 1930 password; non-interactive sessions will fail. (default: None)
1924 1931
1925 1932 ``local_hostname``
1926 1933 Optional. The hostname that the sender can use to identify
1927 1934 itself to the MTA.
1928 1935
1929 1936
1930 1937 ``subpaths``
1931 1938 ------------
1932 1939
1933 1940 Subrepository source URLs can go stale if a remote server changes name
1934 1941 or becomes temporarily unavailable. This section lets you define
1935 1942 rewrite rules of the form::
1936 1943
1937 1944 <pattern> = <replacement>
1938 1945
1939 1946 where ``pattern`` is a regular expression matching a subrepository
1940 1947 source URL and ``replacement`` is the replacement string used to
1941 1948 rewrite it. Groups can be matched in ``pattern`` and referenced in
1942 1949 ``replacements``. For instance::
1943 1950
1944 1951 http://server/(.*)-hg/ = http://hg.server/\1/
1945 1952
1946 1953 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1947 1954
1948 1955 Relative subrepository paths are first made absolute, and the
1949 1956 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1950 1957 doesn't match the full path, an attempt is made to apply it on the
1951 1958 relative path alone. The rules are applied in definition order.
1952 1959
1953 1960 ``subrepos``
1954 1961 ------------
1955 1962
1956 1963 This section contains options that control the behavior of the
1957 1964 subrepositories feature. See also :hg:`help subrepos`.
1958 1965
1959 1966 Security note: auditing in Mercurial is known to be insufficient to
1960 1967 prevent clone-time code execution with carefully constructed Git
1961 1968 subrepos. It is unknown if a similar detect is present in Subversion
1962 1969 subrepos. Both Git and Subversion subrepos are disabled by default
1963 1970 out of security concerns. These subrepo types can be enabled using
1964 1971 the respective options below.
1965 1972
1966 1973 ``allowed``
1967 1974 Whether subrepositories are allowed in the working directory.
1968 1975
1969 1976 When false, commands involving subrepositories (like :hg:`update`)
1970 1977 will fail for all subrepository types.
1971 1978 (default: true)
1972 1979
1973 1980 ``hg:allowed``
1974 1981 Whether Mercurial subrepositories are allowed in the working
1975 1982 directory. This option only has an effect if ``subrepos.allowed``
1976 1983 is true.
1977 1984 (default: true)
1978 1985
1979 1986 ``git:allowed``
1980 1987 Whether Git subrepositories are allowed in the working directory.
1981 1988 This option only has an effect if ``subrepos.allowed`` is true.
1982 1989
1983 1990 See the security note above before enabling Git subrepos.
1984 1991 (default: false)
1985 1992
1986 1993 ``svn:allowed``
1987 1994 Whether Subversion subrepositories are allowed in the working
1988 1995 directory. This option only has an effect if ``subrepos.allowed``
1989 1996 is true.
1990 1997
1991 1998 See the security note above before enabling Subversion subrepos.
1992 1999 (default: false)
1993 2000
1994 2001 ``templatealias``
1995 2002 -----------------
1996 2003
1997 2004 Alias definitions for templates. See :hg:`help templates` for details.
1998 2005
1999 2006 ``templates``
2000 2007 -------------
2001 2008
2002 2009 Use the ``[templates]`` section to define template strings.
2003 2010 See :hg:`help templates` for details.
2004 2011
2005 2012 ``trusted``
2006 2013 -----------
2007 2014
2008 2015 Mercurial will not use the settings in the
2009 2016 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2010 2017 user or to a trusted group, as various hgrc features allow arbitrary
2011 2018 commands to be run. This issue is often encountered when configuring
2012 2019 hooks or extensions for shared repositories or servers. However,
2013 2020 the web interface will use some safe settings from the ``[web]``
2014 2021 section.
2015 2022
2016 2023 This section specifies what users and groups are trusted. The
2017 2024 current user is always trusted. To trust everybody, list a user or a
2018 2025 group with name ``*``. These settings must be placed in an
2019 2026 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2020 2027 user or service running Mercurial.
2021 2028
2022 2029 ``users``
2023 2030 Comma-separated list of trusted users.
2024 2031
2025 2032 ``groups``
2026 2033 Comma-separated list of trusted groups.
2027 2034
2028 2035
2029 2036 ``ui``
2030 2037 ------
2031 2038
2032 2039 User interface controls.
2033 2040
2034 2041 ``archivemeta``
2035 2042 Whether to include the .hg_archival.txt file containing meta data
2036 2043 (hashes for the repository base and for tip) in archives created
2037 2044 by the :hg:`archive` command or downloaded via hgweb.
2038 2045 (default: True)
2039 2046
2040 2047 ``askusername``
2041 2048 Whether to prompt for a username when committing. If True, and
2042 2049 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2043 2050 be prompted to enter a username. If no username is entered, the
2044 2051 default ``USER@HOST`` is used instead.
2045 2052 (default: False)
2046 2053
2047 2054 ``clonebundles``
2048 2055 Whether the "clone bundles" feature is enabled.
2049 2056
2050 2057 When enabled, :hg:`clone` may download and apply a server-advertised
2051 2058 bundle file from a URL instead of using the normal exchange mechanism.
2052 2059
2053 2060 This can likely result in faster and more reliable clones.
2054 2061
2055 2062 (default: True)
2056 2063
2057 2064 ``clonebundlefallback``
2058 2065 Whether failure to apply an advertised "clone bundle" from a server
2059 2066 should result in fallback to a regular clone.
2060 2067
2061 2068 This is disabled by default because servers advertising "clone
2062 2069 bundles" often do so to reduce server load. If advertised bundles
2063 2070 start mass failing and clients automatically fall back to a regular
2064 2071 clone, this would add significant and unexpected load to the server
2065 2072 since the server is expecting clone operations to be offloaded to
2066 2073 pre-generated bundles. Failing fast (the default behavior) ensures
2067 2074 clients don't overwhelm the server when "clone bundle" application
2068 2075 fails.
2069 2076
2070 2077 (default: False)
2071 2078
2072 2079 ``clonebundleprefers``
2073 2080 Defines preferences for which "clone bundles" to use.
2074 2081
2075 2082 Servers advertising "clone bundles" may advertise multiple available
2076 2083 bundles. Each bundle may have different attributes, such as the bundle
2077 2084 type and compression format. This option is used to prefer a particular
2078 2085 bundle over another.
2079 2086
2080 2087 The following keys are defined by Mercurial:
2081 2088
2082 2089 BUNDLESPEC
2083 2090 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2084 2091 e.g. ``gzip-v2`` or ``bzip2-v1``.
2085 2092
2086 2093 COMPRESSION
2087 2094 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2088 2095
2089 2096 Server operators may define custom keys.
2090 2097
2091 2098 Example values: ``COMPRESSION=bzip2``,
2092 2099 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2093 2100
2094 2101 By default, the first bundle advertised by the server is used.
2095 2102
2096 2103 ``color``
2097 2104 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2098 2105 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2099 2106 seems possible. See :hg:`help color` for details.
2100 2107
2101 2108 ``commitsubrepos``
2102 2109 Whether to commit modified subrepositories when committing the
2103 2110 parent repository. If False and one subrepository has uncommitted
2104 2111 changes, abort the commit.
2105 2112 (default: False)
2106 2113
2107 2114 ``debug``
2108 2115 Print debugging information. (default: False)
2109 2116
2110 2117 ``editor``
2111 2118 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2112 2119
2113 2120 ``fallbackencoding``
2114 2121 Encoding to try if it's not possible to decode the changelog using
2115 2122 UTF-8. (default: ISO-8859-1)
2116 2123
2117 2124 ``graphnodetemplate``
2118 2125 The template used to print changeset nodes in an ASCII revision graph.
2119 2126 (default: ``{graphnode}``)
2120 2127
2121 2128 ``ignore``
2122 2129 A file to read per-user ignore patterns from. This file should be
2123 2130 in the same format as a repository-wide .hgignore file. Filenames
2124 2131 are relative to the repository root. This option supports hook syntax,
2125 2132 so if you want to specify multiple ignore files, you can do so by
2126 2133 setting something like ``ignore.other = ~/.hgignore2``. For details
2127 2134 of the ignore file format, see the ``hgignore(5)`` man page.
2128 2135
2129 2136 ``interactive``
2130 2137 Allow to prompt the user. (default: True)
2131 2138
2132 2139 ``interface``
2133 2140 Select the default interface for interactive features (default: text).
2134 2141 Possible values are 'text' and 'curses'.
2135 2142
2136 2143 ``interface.chunkselector``
2137 2144 Select the interface for change recording (e.g. :hg:`commit -i`).
2138 2145 Possible values are 'text' and 'curses'.
2139 2146 This config overrides the interface specified by ui.interface.
2140 2147
2141 2148 ``large-file-limit``
2142 2149 Largest file size that gives no memory use warning.
2143 2150 Possible values are integers or 0 to disable the check.
2144 2151 (default: 10000000)
2145 2152
2146 2153 ``logtemplate``
2147 2154 Template string for commands that print changesets.
2148 2155
2149 2156 ``merge``
2150 2157 The conflict resolution program to use during a manual merge.
2151 2158 For more information on merge tools see :hg:`help merge-tools`.
2152 2159 For configuring merge tools see the ``[merge-tools]`` section.
2153 2160
2154 2161 ``mergemarkers``
2155 2162 Sets the merge conflict marker label styling. The ``detailed``
2156 2163 style uses the ``mergemarkertemplate`` setting to style the labels.
2157 2164 The ``basic`` style just uses 'local' and 'other' as the marker label.
2158 2165 One of ``basic`` or ``detailed``.
2159 2166 (default: ``basic``)
2160 2167
2161 2168 ``mergemarkertemplate``
2162 2169 The template used to print the commit description next to each conflict
2163 2170 marker during merge conflicts. See :hg:`help templates` for the template
2164 2171 format.
2165 2172
2166 2173 Defaults to showing the hash, tags, branches, bookmarks, author, and
2167 2174 the first line of the commit description.
2168 2175
2169 2176 If you use non-ASCII characters in names for tags, branches, bookmarks,
2170 2177 authors, and/or commit descriptions, you must pay attention to encodings of
2171 2178 managed files. At template expansion, non-ASCII characters use the encoding
2172 2179 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2173 2180 environment variables that govern your locale. If the encoding of the merge
2174 2181 markers is different from the encoding of the merged files,
2175 2182 serious problems may occur.
2176 2183
2177 2184 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2178 2185
2179 2186 ``origbackuppath``
2180 2187 The path to a directory used to store generated .orig files. If the path is
2181 2188 not a directory, one will be created. If set, files stored in this
2182 2189 directory have the same name as the original file and do not have a .orig
2183 2190 suffix.
2184 2191
2185 2192 ``paginate``
2186 2193 Control the pagination of command output (default: True). See :hg:`help pager`
2187 2194 for details.
2188 2195
2189 2196 ``patch``
2190 2197 An optional external tool that ``hg import`` and some extensions
2191 2198 will use for applying patches. By default Mercurial uses an
2192 2199 internal patch utility. The external tool must work as the common
2193 2200 Unix ``patch`` program. In particular, it must accept a ``-p``
2194 2201 argument to strip patch headers, a ``-d`` argument to specify the
2195 2202 current directory, a file name to patch, and a patch file to take
2196 2203 from stdin.
2197 2204
2198 2205 It is possible to specify a patch tool together with extra
2199 2206 arguments. For example, setting this option to ``patch --merge``
2200 2207 will use the ``patch`` program with its 2-way merge option.
2201 2208
2202 2209 ``portablefilenames``
2203 2210 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2204 2211 (default: ``warn``)
2205 2212
2206 2213 ``warn``
2207 2214 Print a warning message on POSIX platforms, if a file with a non-portable
2208 2215 filename is added (e.g. a file with a name that can't be created on
2209 2216 Windows because it contains reserved parts like ``AUX``, reserved
2210 2217 characters like ``:``, or would cause a case collision with an existing
2211 2218 file).
2212 2219
2213 2220 ``ignore``
2214 2221 Don't print a warning.
2215 2222
2216 2223 ``abort``
2217 2224 The command is aborted.
2218 2225
2219 2226 ``true``
2220 2227 Alias for ``warn``.
2221 2228
2222 2229 ``false``
2223 2230 Alias for ``ignore``.
2224 2231
2225 2232 .. container:: windows
2226 2233
2227 2234 On Windows, this configuration option is ignored and the command aborted.
2228 2235
2229 2236 ``quiet``
2230 2237 Reduce the amount of output printed.
2231 2238 (default: False)
2232 2239
2233 2240 ``remotecmd``
2234 2241 Remote command to use for clone/push/pull operations.
2235 2242 (default: ``hg``)
2236 2243
2237 2244 ``report_untrusted``
2238 2245 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2239 2246 trusted user or group.
2240 2247 (default: True)
2241 2248
2242 2249 ``slash``
2243 2250 (Deprecated. Use ``slashpath`` template filter instead.)
2244 2251
2245 2252 Display paths using a slash (``/``) as the path separator. This
2246 2253 only makes a difference on systems where the default path
2247 2254 separator is not the slash character (e.g. Windows uses the
2248 2255 backslash character (``\``)).
2249 2256 (default: False)
2250 2257
2251 2258 ``statuscopies``
2252 2259 Display copies in the status command.
2253 2260
2254 2261 ``ssh``
2255 2262 Command to use for SSH connections. (default: ``ssh``)
2256 2263
2257 2264 ``ssherrorhint``
2258 2265 A hint shown to the user in the case of SSH error (e.g.
2259 2266 ``Please see http://company/internalwiki/ssh.html``)
2260 2267
2261 2268 ``strict``
2262 2269 Require exact command names, instead of allowing unambiguous
2263 2270 abbreviations. (default: False)
2264 2271
2265 2272 ``style``
2266 2273 Name of style to use for command output.
2267 2274
2268 2275 ``supportcontact``
2269 2276 A URL where users should report a Mercurial traceback. Use this if you are a
2270 2277 large organisation with its own Mercurial deployment process and crash
2271 2278 reports should be addressed to your internal support.
2272 2279
2273 2280 ``textwidth``
2274 2281 Maximum width of help text. A longer line generated by ``hg help`` or
2275 2282 ``hg subcommand --help`` will be broken after white space to get this
2276 2283 width or the terminal width, whichever comes first.
2277 2284 A non-positive value will disable this and the terminal width will be
2278 2285 used. (default: 78)
2279 2286
2280 2287 ``timeout``
2281 2288 The timeout used when a lock is held (in seconds), a negative value
2282 2289 means no timeout. (default: 600)
2283 2290
2284 2291 ``timeout.warn``
2285 2292 Time (in seconds) before a warning is printed about held lock. A negative
2286 2293 value means no warning. (default: 0)
2287 2294
2288 2295 ``traceback``
2289 2296 Mercurial always prints a traceback when an unknown exception
2290 2297 occurs. Setting this to True will make Mercurial print a traceback
2291 2298 on all exceptions, even those recognized by Mercurial (such as
2292 2299 IOError or MemoryError). (default: False)
2293 2300
2294 2301 ``tweakdefaults``
2295 2302
2296 2303 By default Mercurial's behavior changes very little from release
2297 2304 to release, but over time the recommended config settings
2298 2305 shift. Enable this config to opt in to get automatic tweaks to
2299 2306 Mercurial's behavior over time. This config setting will have no
2300 2307 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2301 2308 not include ``tweakdefaults``. (default: False)
2302 2309
2303 2310 ``username``
2304 2311 The committer of a changeset created when running "commit".
2305 2312 Typically a person's name and email address, e.g. ``Fred Widget
2306 2313 <fred@example.com>``. Environment variables in the
2307 2314 username are expanded.
2308 2315
2309 2316 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2310 2317 hgrc is empty, e.g. if the system admin set ``username =`` in the
2311 2318 system hgrc, it has to be specified manually or in a different
2312 2319 hgrc file)
2313 2320
2314 2321 ``verbose``
2315 2322 Increase the amount of output printed. (default: False)
2316 2323
2317 2324
2318 2325 ``web``
2319 2326 -------
2320 2327
2321 2328 Web interface configuration. The settings in this section apply to
2322 2329 both the builtin webserver (started by :hg:`serve`) and the script you
2323 2330 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2324 2331 and WSGI).
2325 2332
2326 2333 The Mercurial webserver does no authentication (it does not prompt for
2327 2334 usernames and passwords to validate *who* users are), but it does do
2328 2335 authorization (it grants or denies access for *authenticated users*
2329 2336 based on settings in this section). You must either configure your
2330 2337 webserver to do authentication for you, or disable the authorization
2331 2338 checks.
2332 2339
2333 2340 For a quick setup in a trusted environment, e.g., a private LAN, where
2334 2341 you want it to accept pushes from anybody, you can use the following
2335 2342 command line::
2336 2343
2337 2344 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2338 2345
2339 2346 Note that this will allow anybody to push anything to the server and
2340 2347 that this should not be used for public servers.
2341 2348
2342 2349 The full set of options is:
2343 2350
2344 2351 ``accesslog``
2345 2352 Where to output the access log. (default: stdout)
2346 2353
2347 2354 ``address``
2348 2355 Interface address to bind to. (default: all)
2349 2356
2350 2357 ``allow-archive``
2351 2358 List of archive format (bz2, gz, zip) allowed for downloading.
2352 2359 (default: empty)
2353 2360
2354 2361 ``allowbz2``
2355 2362 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2356 2363 revisions.
2357 2364 (default: False)
2358 2365
2359 2366 ``allowgz``
2360 2367 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2361 2368 revisions.
2362 2369 (default: False)
2363 2370
2364 2371 ``allow-pull``
2365 2372 Whether to allow pulling from the repository. (default: True)
2366 2373
2367 2374 ``allow-push``
2368 2375 Whether to allow pushing to the repository. If empty or not set,
2369 2376 pushing is not allowed. If the special value ``*``, any remote
2370 2377 user can push, including unauthenticated users. Otherwise, the
2371 2378 remote user must have been authenticated, and the authenticated
2372 2379 user name must be present in this list. The contents of the
2373 2380 allow-push list are examined after the deny_push list.
2374 2381
2375 2382 ``allow_read``
2376 2383 If the user has not already been denied repository access due to
2377 2384 the contents of deny_read, this list determines whether to grant
2378 2385 repository access to the user. If this list is not empty, and the
2379 2386 user is unauthenticated or not present in the list, then access is
2380 2387 denied for the user. If the list is empty or not set, then access
2381 2388 is permitted to all users by default. Setting allow_read to the
2382 2389 special value ``*`` is equivalent to it not being set (i.e. access
2383 2390 is permitted to all users). The contents of the allow_read list are
2384 2391 examined after the deny_read list.
2385 2392
2386 2393 ``allowzip``
2387 2394 (DEPRECATED) Whether to allow .zip downloading of repository
2388 2395 revisions. This feature creates temporary files.
2389 2396 (default: False)
2390 2397
2391 2398 ``archivesubrepos``
2392 2399 Whether to recurse into subrepositories when archiving.
2393 2400 (default: False)
2394 2401
2395 2402 ``baseurl``
2396 2403 Base URL to use when publishing URLs in other locations, so
2397 2404 third-party tools like email notification hooks can construct
2398 2405 URLs. Example: ``http://hgserver/repos/``.
2399 2406
2400 2407 ``cacerts``
2401 2408 Path to file containing a list of PEM encoded certificate
2402 2409 authority certificates. Environment variables and ``~user``
2403 2410 constructs are expanded in the filename. If specified on the
2404 2411 client, then it will verify the identity of remote HTTPS servers
2405 2412 with these certificates.
2406 2413
2407 2414 To disable SSL verification temporarily, specify ``--insecure`` from
2408 2415 command line.
2409 2416
2410 2417 You can use OpenSSL's CA certificate file if your platform has
2411 2418 one. On most Linux systems this will be
2412 2419 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2413 2420 generate this file manually. The form must be as follows::
2414 2421
2415 2422 -----BEGIN CERTIFICATE-----
2416 2423 ... (certificate in base64 PEM encoding) ...
2417 2424 -----END CERTIFICATE-----
2418 2425 -----BEGIN CERTIFICATE-----
2419 2426 ... (certificate in base64 PEM encoding) ...
2420 2427 -----END CERTIFICATE-----
2421 2428
2422 2429 ``cache``
2423 2430 Whether to support caching in hgweb. (default: True)
2424 2431
2425 2432 ``certificate``
2426 2433 Certificate to use when running :hg:`serve`.
2427 2434
2428 2435 ``collapse``
2429 2436 With ``descend`` enabled, repositories in subdirectories are shown at
2430 2437 a single level alongside repositories in the current path. With
2431 2438 ``collapse`` also enabled, repositories residing at a deeper level than
2432 2439 the current path are grouped behind navigable directory entries that
2433 2440 lead to the locations of these repositories. In effect, this setting
2434 2441 collapses each collection of repositories found within a subdirectory
2435 2442 into a single entry for that subdirectory. (default: False)
2436 2443
2437 2444 ``comparisoncontext``
2438 2445 Number of lines of context to show in side-by-side file comparison. If
2439 2446 negative or the value ``full``, whole files are shown. (default: 5)
2440 2447
2441 2448 This setting can be overridden by a ``context`` request parameter to the
2442 2449 ``comparison`` command, taking the same values.
2443 2450
2444 2451 ``contact``
2445 2452 Name or email address of the person in charge of the repository.
2446 2453 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2447 2454
2448 2455 ``csp``
2449 2456 Send a ``Content-Security-Policy`` HTTP header with this value.
2450 2457
2451 2458 The value may contain a special string ``%nonce%``, which will be replaced
2452 2459 by a randomly-generated one-time use value. If the value contains
2453 2460 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2454 2461 one-time property of the nonce. This nonce will also be inserted into
2455 2462 ``<script>`` elements containing inline JavaScript.
2456 2463
2457 2464 Note: lots of HTML content sent by the server is derived from repository
2458 2465 data. Please consider the potential for malicious repository data to
2459 2466 "inject" itself into generated HTML content as part of your security
2460 2467 threat model.
2461 2468
2462 2469 ``deny_push``
2463 2470 Whether to deny pushing to the repository. If empty or not set,
2464 2471 push is not denied. If the special value ``*``, all remote users are
2465 2472 denied push. Otherwise, unauthenticated users are all denied, and
2466 2473 any authenticated user name present in this list is also denied. The
2467 2474 contents of the deny_push list are examined before the allow-push list.
2468 2475
2469 2476 ``deny_read``
2470 2477 Whether to deny reading/viewing of the repository. If this list is
2471 2478 not empty, unauthenticated users are all denied, and any
2472 2479 authenticated user name present in this list is also denied access to
2473 2480 the repository. If set to the special value ``*``, all remote users
2474 2481 are denied access (rarely needed ;). If deny_read is empty or not set,
2475 2482 the determination of repository access depends on the presence and
2476 2483 content of the allow_read list (see description). If both
2477 2484 deny_read and allow_read are empty or not set, then access is
2478 2485 permitted to all users by default. If the repository is being
2479 2486 served via hgwebdir, denied users will not be able to see it in
2480 2487 the list of repositories. The contents of the deny_read list have
2481 2488 priority over (are examined before) the contents of the allow_read
2482 2489 list.
2483 2490
2484 2491 ``descend``
2485 2492 hgwebdir indexes will not descend into subdirectories. Only repositories
2486 2493 directly in the current path will be shown (other repositories are still
2487 2494 available from the index corresponding to their containing path).
2488 2495
2489 2496 ``description``
2490 2497 Textual description of the repository's purpose or contents.
2491 2498 (default: "unknown")
2492 2499
2493 2500 ``encoding``
2494 2501 Character encoding name. (default: the current locale charset)
2495 2502 Example: "UTF-8".
2496 2503
2497 2504 ``errorlog``
2498 2505 Where to output the error log. (default: stderr)
2499 2506
2500 2507 ``guessmime``
2501 2508 Control MIME types for raw download of file content.
2502 2509 Set to True to let hgweb guess the content type from the file
2503 2510 extension. This will serve HTML files as ``text/html`` and might
2504 2511 allow cross-site scripting attacks when serving untrusted
2505 2512 repositories. (default: False)
2506 2513
2507 2514 ``hidden``
2508 2515 Whether to hide the repository in the hgwebdir index.
2509 2516 (default: False)
2510 2517
2511 2518 ``ipv6``
2512 2519 Whether to use IPv6. (default: False)
2513 2520
2514 2521 ``labels``
2515 2522 List of string *labels* associated with the repository.
2516 2523
2517 2524 Labels are exposed as a template keyword and can be used to customize
2518 2525 output. e.g. the ``index`` template can group or filter repositories
2519 2526 by labels and the ``summary`` template can display additional content
2520 2527 if a specific label is present.
2521 2528
2522 2529 ``logoimg``
2523 2530 File name of the logo image that some templates display on each page.
2524 2531 The file name is relative to ``staticurl``. That is, the full path to
2525 2532 the logo image is "staticurl/logoimg".
2526 2533 If unset, ``hglogo.png`` will be used.
2527 2534
2528 2535 ``logourl``
2529 2536 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2530 2537 will be used.
2531 2538
2532 2539 ``maxchanges``
2533 2540 Maximum number of changes to list on the changelog. (default: 10)
2534 2541
2535 2542 ``maxfiles``
2536 2543 Maximum number of files to list per changeset. (default: 10)
2537 2544
2538 2545 ``maxshortchanges``
2539 2546 Maximum number of changes to list on the shortlog, graph or filelog
2540 2547 pages. (default: 60)
2541 2548
2542 2549 ``name``
2543 2550 Repository name to use in the web interface.
2544 2551 (default: current working directory)
2545 2552
2546 2553 ``port``
2547 2554 Port to listen on. (default: 8000)
2548 2555
2549 2556 ``prefix``
2550 2557 Prefix path to serve from. (default: '' (server root))
2551 2558
2552 2559 ``push_ssl``
2553 2560 Whether to require that inbound pushes be transported over SSL to
2554 2561 prevent password sniffing. (default: True)
2555 2562
2556 2563 ``refreshinterval``
2557 2564 How frequently directory listings re-scan the filesystem for new
2558 2565 repositories, in seconds. This is relevant when wildcards are used
2559 2566 to define paths. Depending on how much filesystem traversal is
2560 2567 required, refreshing may negatively impact performance.
2561 2568
2562 2569 Values less than or equal to 0 always refresh.
2563 2570 (default: 20)
2564 2571
2565 2572 ``server-header``
2566 2573 Value for HTTP ``Server`` response header.
2567 2574
2568 2575 ``staticurl``
2569 2576 Base URL to use for static files. If unset, static files (e.g. the
2570 2577 hgicon.png favicon) will be served by the CGI script itself. Use
2571 2578 this setting to serve them directly with the HTTP server.
2572 2579 Example: ``http://hgserver/static/``.
2573 2580
2574 2581 ``stripes``
2575 2582 How many lines a "zebra stripe" should span in multi-line output.
2576 2583 Set to 0 to disable. (default: 1)
2577 2584
2578 2585 ``style``
2579 2586 Which template map style to use. The available options are the names of
2580 2587 subdirectories in the HTML templates path. (default: ``paper``)
2581 2588 Example: ``monoblue``.
2582 2589
2583 2590 ``templates``
2584 2591 Where to find the HTML templates. The default path to the HTML templates
2585 2592 can be obtained from ``hg debuginstall``.
2586 2593
2587 2594 ``websub``
2588 2595 ----------
2589 2596
2590 2597 Web substitution filter definition. You can use this section to
2591 2598 define a set of regular expression substitution patterns which
2592 2599 let you automatically modify the hgweb server output.
2593 2600
2594 2601 The default hgweb templates only apply these substitution patterns
2595 2602 on the revision description fields. You can apply them anywhere
2596 2603 you want when you create your own templates by adding calls to the
2597 2604 "websub" filter (usually after calling the "escape" filter).
2598 2605
2599 2606 This can be used, for example, to convert issue references to links
2600 2607 to your issue tracker, or to convert "markdown-like" syntax into
2601 2608 HTML (see the examples below).
2602 2609
2603 2610 Each entry in this section names a substitution filter.
2604 2611 The value of each entry defines the substitution expression itself.
2605 2612 The websub expressions follow the old interhg extension syntax,
2606 2613 which in turn imitates the Unix sed replacement syntax::
2607 2614
2608 2615 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2609 2616
2610 2617 You can use any separator other than "/". The final "i" is optional
2611 2618 and indicates that the search must be case insensitive.
2612 2619
2613 2620 Examples::
2614 2621
2615 2622 [websub]
2616 2623 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2617 2624 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2618 2625 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2619 2626
2620 2627 ``worker``
2621 2628 ----------
2622 2629
2623 2630 Parallel master/worker configuration. We currently perform working
2624 2631 directory updates in parallel on Unix-like systems, which greatly
2625 2632 helps performance.
2626 2633
2627 2634 ``enabled``
2628 2635 Whether to enable workers code to be used.
2629 2636 (default: true)
2630 2637
2631 2638 ``numcpus``
2632 2639 Number of CPUs to use for parallel operations. A zero or
2633 2640 negative value is treated as ``use the default``.
2634 2641 (default: 4 or the number of CPUs on the system, whichever is larger)
2635 2642
2636 2643 ``backgroundclose``
2637 2644 Whether to enable closing file handles on background threads during certain
2638 2645 operations. Some platforms aren't very efficient at closing file
2639 2646 handles that have been written or appended to. By performing file closing
2640 2647 on background threads, file write rate can increase substantially.
2641 2648 (default: true on Windows, false elsewhere)
2642 2649
2643 2650 ``backgroundcloseminfilecount``
2644 2651 Minimum number of files required to trigger background file closing.
2645 2652 Operations not writing this many files won't start background close
2646 2653 threads.
2647 2654 (default: 2048)
2648 2655
2649 2656 ``backgroundclosemaxqueue``
2650 2657 The maximum number of opened file handles waiting to be closed in the
2651 2658 background. This option only has an effect if ``backgroundclose`` is
2652 2659 enabled.
2653 2660 (default: 384)
2654 2661
2655 2662 ``backgroundclosethreadcount``
2656 2663 Number of threads to process background file closes. Only relevant if
2657 2664 ``backgroundclose`` is enabled.
2658 2665 (default: 4)
@@ -1,281 +1,285
1 1 # hook.py - hook support for mercurial
2 2 #
3 3 # Copyright 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 os
11 11 import sys
12 12
13 13 from .i18n import _
14 14 from . import (
15 15 demandimport,
16 16 encoding,
17 17 error,
18 18 extensions,
19 19 pycompat,
20 20 util,
21 21 )
22 22 from .utils import (
23 23 procutil,
24 24 stringutil,
25 25 )
26 26
27 27 def pythonhook(ui, repo, htype, hname, funcname, args, throw):
28 28 '''call python hook. hook is callable object, looked up as
29 29 name in python module. if callable returns "true", hook
30 30 fails, else passes. if hook raises exception, treated as
31 31 hook failure. exception propagates if throw is "true".
32 32
33 33 reason for "true" meaning "hook failed" is so that
34 34 unmodified commands (e.g. mercurial.commands.update) can
35 35 be run as hooks without wrappers to convert return values.'''
36 36
37 37 if callable(funcname):
38 38 obj = funcname
39 39 funcname = pycompat.sysbytes(obj.__module__ + r"." + obj.__name__)
40 40 else:
41 41 d = funcname.rfind('.')
42 42 if d == -1:
43 43 raise error.HookLoadError(
44 44 _('%s hook is invalid: "%s" not in a module')
45 45 % (hname, funcname))
46 46 modname = funcname[:d]
47 47 oldpaths = sys.path
48 48 if procutil.mainfrozen():
49 49 # binary installs require sys.path manipulation
50 50 modpath, modfile = os.path.split(modname)
51 51 if modpath and modfile:
52 52 sys.path = sys.path[:] + [modpath]
53 53 modname = modfile
54 54 with demandimport.deactivated():
55 55 try:
56 56 obj = __import__(pycompat.sysstr(modname))
57 57 except (ImportError, SyntaxError):
58 58 e1 = sys.exc_info()
59 59 try:
60 60 # extensions are loaded with hgext_ prefix
61 61 obj = __import__(r"hgext_%s" % pycompat.sysstr(modname))
62 62 except (ImportError, SyntaxError):
63 63 e2 = sys.exc_info()
64 64 if ui.tracebackflag:
65 65 ui.warn(_('exception from first failed import '
66 66 'attempt:\n'))
67 67 ui.traceback(e1)
68 68 if ui.tracebackflag:
69 69 ui.warn(_('exception from second failed import '
70 70 'attempt:\n'))
71 71 ui.traceback(e2)
72 72
73 73 if not ui.tracebackflag:
74 74 tracebackhint = _(
75 75 'run with --traceback for stack trace')
76 76 else:
77 77 tracebackhint = None
78 78 raise error.HookLoadError(
79 79 _('%s hook is invalid: import of "%s" failed') %
80 80 (hname, modname), hint=tracebackhint)
81 81 sys.path = oldpaths
82 82 try:
83 83 for p in funcname.split('.')[1:]:
84 84 obj = getattr(obj, p)
85 85 except AttributeError:
86 86 raise error.HookLoadError(
87 87 _('%s hook is invalid: "%s" is not defined')
88 88 % (hname, funcname))
89 89 if not callable(obj):
90 90 raise error.HookLoadError(
91 91 _('%s hook is invalid: "%s" is not callable')
92 92 % (hname, funcname))
93 93
94 94 ui.note(_("calling hook %s: %s\n") % (hname, funcname))
95 95 starttime = util.timer()
96 96
97 97 try:
98 98 r = obj(ui=ui, repo=repo, hooktype=htype, **pycompat.strkwargs(args))
99 99 except Exception as exc:
100 100 if isinstance(exc, error.Abort):
101 101 ui.warn(_('error: %s hook failed: %s\n') %
102 102 (hname, exc.args[0]))
103 103 else:
104 104 ui.warn(_('error: %s hook raised an exception: '
105 105 '%s\n') % (hname, encoding.strtolocal(str(exc))))
106 106 if throw:
107 107 raise
108 108 if not ui.tracebackflag:
109 109 ui.warn(_('(run with --traceback for stack trace)\n'))
110 110 ui.traceback()
111 111 return True, True
112 112 finally:
113 113 duration = util.timer() - starttime
114 114 ui.log('pythonhook', 'pythonhook-%s: %s finished in %0.2f seconds\n',
115 115 htype, funcname, duration)
116 116 if r:
117 117 if throw:
118 118 raise error.HookAbort(_('%s hook failed') % hname)
119 119 ui.warn(_('warning: %s hook failed\n') % hname)
120 120 return r, False
121 121
122 122 def _exthook(ui, repo, htype, name, cmd, args, throw):
123 123 starttime = util.timer()
124 124 env = {}
125 125
126 126 # make in-memory changes visible to external process
127 127 if repo is not None:
128 128 tr = repo.currenttransaction()
129 129 repo.dirstate.write(tr)
130 130 if tr and tr.writepending():
131 131 env['HG_PENDING'] = repo.root
132 132 env['HG_HOOKTYPE'] = htype
133 133 env['HG_HOOKNAME'] = name
134 134
135 135 for k, v in args.iteritems():
136 136 if callable(v):
137 137 v = v()
138 138 if isinstance(v, (dict, list)):
139 139 v = stringutil.pprint(v)
140 140 env['HG_' + k.upper()] = v
141 141
142 if ui.configbool('hooks', 'tonative.%s' % name, pycompat.iswindows):
143 ui.note(_('converting hook "%s" to native\n') % name)
142 144 cmd = procutil.shelltonative(cmd, env)
143 145
144 146 ui.note(_("running hook %s: %s\n") % (name, cmd))
145 147
146 148 if repo:
147 149 cwd = repo.root
148 150 else:
149 151 cwd = pycompat.getcwd()
150 152 r = ui.system(cmd, environ=env, cwd=cwd, blockedtag='exthook-%s' % (name,))
151 153
152 154 duration = util.timer() - starttime
153 155 ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
154 156 name, cmd, duration)
155 157 if r:
156 158 desc = procutil.explainexit(r)
157 159 if throw:
158 160 raise error.HookAbort(_('%s hook %s') % (name, desc))
159 161 ui.warn(_('warning: %s hook %s\n') % (name, desc))
160 162 return r
161 163
162 164 # represent an untrusted hook command
163 165 _fromuntrusted = object()
164 166
165 167 def _allhooks(ui):
166 168 """return a list of (hook-id, cmd) pairs sorted by priority"""
167 169 hooks = _hookitems(ui)
168 170 # Be careful in this section, propagating the real commands from untrusted
169 171 # sources would create a security vulnerability, make sure anything altered
170 172 # in that section uses "_fromuntrusted" as its command.
171 173 untrustedhooks = _hookitems(ui, _untrusted=True)
172 174 for name, value in untrustedhooks.items():
173 175 trustedvalue = hooks.get(name, (None, None, name, _fromuntrusted))
174 176 if value != trustedvalue:
175 177 (lp, lo, lk, lv) = trustedvalue
176 178 hooks[name] = (lp, lo, lk, _fromuntrusted)
177 179 # (end of the security sensitive section)
178 180 return [(k, v) for p, o, k, v in sorted(hooks.values())]
179 181
180 182 def _hookitems(ui, _untrusted=False):
181 183 """return all hooks items ready to be sorted"""
182 184 hooks = {}
183 185 for name, cmd in ui.configitems('hooks', untrusted=_untrusted):
184 if not name.startswith('priority.'):
186 if name.startswith('priority.') or name.startswith('tonative.'):
187 continue
188
185 189 priority = ui.configint('hooks', 'priority.%s' % name, 0)
186 190 hooks[name] = (-priority, len(hooks), name, cmd)
187 191 return hooks
188 192
189 193 _redirect = False
190 194 def redirect(state):
191 195 global _redirect
192 196 _redirect = state
193 197
194 198 def hashook(ui, htype):
195 199 """return True if a hook is configured for 'htype'"""
196 200 if not ui.callhooks:
197 201 return False
198 202 for hname, cmd in _allhooks(ui):
199 203 if hname.split('.')[0] == htype and cmd:
200 204 return True
201 205 return False
202 206
203 207 def hook(ui, repo, htype, throw=False, **args):
204 208 if not ui.callhooks:
205 209 return False
206 210
207 211 hooks = []
208 212 for hname, cmd in _allhooks(ui):
209 213 if hname.split('.')[0] == htype and cmd:
210 214 hooks.append((hname, cmd))
211 215
212 216 res = runhooks(ui, repo, htype, hooks, throw=throw, **args)
213 217 r = False
214 218 for hname, cmd in hooks:
215 219 r = res[hname][0] or r
216 220 return r
217 221
218 222 def runhooks(ui, repo, htype, hooks, throw=False, **args):
219 223 args = pycompat.byteskwargs(args)
220 224 res = {}
221 225 oldstdout = -1
222 226
223 227 try:
224 228 for hname, cmd in hooks:
225 229 if oldstdout == -1 and _redirect:
226 230 try:
227 231 stdoutno = procutil.stdout.fileno()
228 232 stderrno = procutil.stderr.fileno()
229 233 # temporarily redirect stdout to stderr, if possible
230 234 if stdoutno >= 0 and stderrno >= 0:
231 235 procutil.stdout.flush()
232 236 oldstdout = os.dup(stdoutno)
233 237 os.dup2(stderrno, stdoutno)
234 238 except (OSError, AttributeError):
235 239 # files seem to be bogus, give up on redirecting (WSGI, etc)
236 240 pass
237 241
238 242 if cmd is _fromuntrusted:
239 243 if throw:
240 244 raise error.HookAbort(
241 245 _('untrusted hook %s not executed') % hname,
242 246 hint = _("see 'hg help config.trusted'"))
243 247 ui.warn(_('warning: untrusted hook %s not executed\n') % hname)
244 248 r = 1
245 249 raised = False
246 250 elif callable(cmd):
247 251 r, raised = pythonhook(ui, repo, htype, hname, cmd, args,
248 252 throw)
249 253 elif cmd.startswith('python:'):
250 254 if cmd.count(':') >= 2:
251 255 path, cmd = cmd[7:].rsplit(':', 1)
252 256 path = util.expandpath(path)
253 257 if repo:
254 258 path = os.path.join(repo.root, path)
255 259 try:
256 260 mod = extensions.loadpath(path, 'hghook.%s' % hname)
257 261 except Exception:
258 262 ui.write(_("loading %s hook failed:\n") % hname)
259 263 raise
260 264 hookfn = getattr(mod, cmd)
261 265 else:
262 266 hookfn = cmd[7:].strip()
263 267 r, raised = pythonhook(ui, repo, htype, hname, hookfn, args,
264 268 throw)
265 269 else:
266 270 r = _exthook(ui, repo, htype, hname, cmd, args, throw)
267 271 raised = False
268 272
269 273 res[hname] = r, raised
270 274 finally:
271 275 # The stderr is fully buffered on Windows when connected to a pipe.
272 276 # A forcible flush is required to make small stderr data in the
273 277 # remote side available to the client immediately.
274 278 procutil.stderr.flush()
275 279
276 280 if _redirect and oldstdout >= 0:
277 281 procutil.stdout.flush() # write hook output to stderr fd
278 282 os.dup2(oldstdout, stdoutno)
279 283 os.close(oldstdout)
280 284
281 285 return res
@@ -1,1277 +1,1279
1 1 #testcases b2-pushkey b2-binary
2 2
3 3 #if b2-pushkey
4 4 $ cat << EOF >> $HGRCPATH
5 5 > [devel]
6 6 > legacy.exchange=bookmarks
7 7 > EOF
8 8 #endif
9 9
10 10 #require serve
11 11
12 12 $ cat << EOF >> $HGRCPATH
13 13 > [ui]
14 14 > logtemplate={rev}:{node|short} {desc|firstline}
15 15 > [phases]
16 16 > publish=False
17 17 > [experimental]
18 18 > evolution.createmarkers=True
19 19 > evolution.exchange=True
20 20 > EOF
21 21
22 22 $ cat > $TESTTMP/hook.sh <<'EOF'
23 23 > echo "test-hook-bookmark: $HG_BOOKMARK: $HG_OLDNODE -> $HG_NODE"
24 24 > EOF
25 25 $ TESTHOOK="hooks.txnclose-bookmark.test=sh $TESTTMP/hook.sh"
26 26
27 27 initialize
28 28
29 29 $ hg init a
30 30 $ cd a
31 31 $ echo 'test' > test
32 32 $ hg commit -Am'test'
33 33 adding test
34 34
35 35 set bookmarks
36 36
37 37 $ hg bookmark X
38 38 $ hg bookmark Y
39 39 $ hg bookmark Z
40 40
41 41 import bookmark by name
42 42
43 43 $ hg init ../b
44 44 $ cd ../b
45 45 $ hg book Y
46 46 $ hg book
47 47 * Y -1:000000000000
48 48 $ hg pull ../a --config "$TESTHOOK"
49 49 pulling from ../a
50 50 requesting all changes
51 51 adding changesets
52 52 adding manifests
53 53 adding file changes
54 54 added 1 changesets with 1 changes to 1 files
55 55 adding remote bookmark X
56 56 updating bookmark Y
57 57 adding remote bookmark Z
58 58 new changesets 4e3505fd9583
59 59 test-hook-bookmark: X: -> 4e3505fd95835d721066b76e75dbb8cc554d7f77
60 60 test-hook-bookmark: Y: 0000000000000000000000000000000000000000 -> 4e3505fd95835d721066b76e75dbb8cc554d7f77
61 61 test-hook-bookmark: Z: -> 4e3505fd95835d721066b76e75dbb8cc554d7f77
62 62 (run 'hg update' to get a working copy)
63 63 $ hg bookmarks
64 64 X 0:4e3505fd9583
65 65 * Y 0:4e3505fd9583
66 66 Z 0:4e3505fd9583
67 67 $ hg debugpushkey ../a namespaces
68 68 bookmarks
69 69 namespaces
70 70 obsolete
71 71 phases
72 72 $ hg debugpushkey ../a bookmarks
73 73 X 4e3505fd95835d721066b76e75dbb8cc554d7f77
74 74 Y 4e3505fd95835d721066b76e75dbb8cc554d7f77
75 75 Z 4e3505fd95835d721066b76e75dbb8cc554d7f77
76 76
77 77 delete the bookmark to re-pull it
78 78
79 79 $ hg book -d X
80 80 $ hg pull -B X ../a
81 81 pulling from ../a
82 82 no changes found
83 83 adding remote bookmark X
84 84
85 85 finally no-op pull
86 86
87 87 $ hg pull -B X ../a
88 88 pulling from ../a
89 89 no changes found
90 90 $ hg bookmark
91 91 X 0:4e3505fd9583
92 92 * Y 0:4e3505fd9583
93 93 Z 0:4e3505fd9583
94 94
95 95 export bookmark by name
96 96
97 97 $ hg bookmark W
98 98 $ hg bookmark foo
99 99 $ hg bookmark foobar
100 100 $ hg push -B W ../a
101 101 pushing to ../a
102 102 searching for changes
103 103 no changes found
104 104 exporting bookmark W
105 105 [1]
106 106 $ hg -R ../a bookmarks
107 107 W -1:000000000000
108 108 X 0:4e3505fd9583
109 109 Y 0:4e3505fd9583
110 110 * Z 0:4e3505fd9583
111 111
112 112 delete a remote bookmark
113 113
114 114 $ hg book -d W
115 115
116 116 #if b2-pushkey
117 117
118 118 $ hg push -B W ../a --config "$TESTHOOK" --debug --config devel.bundle2.debug=yes
119 119 pushing to ../a
120 120 query 1; heads
121 121 searching for changes
122 122 all remote heads known locally
123 123 listing keys for "phases"
124 124 checking for updated bookmarks
125 125 listing keys for "bookmarks"
126 126 no changes found
127 127 bundle2-output-bundle: "HG20", 4 parts total
128 128 bundle2-output: start emission of HG20 stream
129 129 bundle2-output: bundle parameter:
130 130 bundle2-output: start of parts
131 131 bundle2-output: bundle part: "replycaps"
132 132 bundle2-output-part: "replycaps" 222 bytes payload
133 133 bundle2-output: part 0: "REPLYCAPS"
134 134 bundle2-output: header chunk size: 16
135 135 bundle2-output: payload chunk size: 222
136 136 bundle2-output: closing payload chunk
137 137 bundle2-output: bundle part: "check:bookmarks"
138 138 bundle2-output-part: "check:bookmarks" 23 bytes payload
139 139 bundle2-output: part 1: "CHECK:BOOKMARKS"
140 140 bundle2-output: header chunk size: 22
141 141 bundle2-output: payload chunk size: 23
142 142 bundle2-output: closing payload chunk
143 143 bundle2-output: bundle part: "check:phases"
144 144 bundle2-output-part: "check:phases" 48 bytes payload
145 145 bundle2-output: part 2: "CHECK:PHASES"
146 146 bundle2-output: header chunk size: 19
147 147 bundle2-output: payload chunk size: 48
148 148 bundle2-output: closing payload chunk
149 149 bundle2-output: bundle part: "pushkey"
150 150 bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload
151 151 bundle2-output: part 3: "PUSHKEY"
152 152 bundle2-output: header chunk size: 90
153 153 bundle2-output: closing payload chunk
154 154 bundle2-output: end of bundle
155 155 bundle2-input: start processing of HG20 stream
156 156 bundle2-input: reading bundle2 stream parameters
157 157 bundle2-input-bundle: with-transaction
158 158 bundle2-input: start extraction of bundle2 parts
159 159 bundle2-input: part header size: 16
160 160 bundle2-input: part type: "REPLYCAPS"
161 161 bundle2-input: part id: "0"
162 162 bundle2-input: part parameters: 0
163 163 bundle2-input: found a handler for part replycaps
164 164 bundle2-input-part: "replycaps" supported
165 165 bundle2-input: payload chunk size: 222
166 166 bundle2-input: payload chunk size: 0
167 167 bundle2-input-part: total payload size 222
168 168 bundle2-input: part header size: 22
169 169 bundle2-input: part type: "CHECK:BOOKMARKS"
170 170 bundle2-input: part id: "1"
171 171 bundle2-input: part parameters: 0
172 172 bundle2-input: found a handler for part check:bookmarks
173 173 bundle2-input-part: "check:bookmarks" supported
174 174 bundle2-input: payload chunk size: 23
175 175 bundle2-input: payload chunk size: 0
176 176 bundle2-input-part: total payload size 23
177 177 bundle2-input: part header size: 19
178 178 bundle2-input: part type: "CHECK:PHASES"
179 179 bundle2-input: part id: "2"
180 180 bundle2-input: part parameters: 0
181 181 bundle2-input: found a handler for part check:phases
182 182 bundle2-input-part: "check:phases" supported
183 183 bundle2-input: payload chunk size: 48
184 184 bundle2-input: payload chunk size: 0
185 185 bundle2-input-part: total payload size 48
186 186 bundle2-input: part header size: 90
187 187 bundle2-input: part type: "PUSHKEY"
188 188 bundle2-input: part id: "3"
189 189 bundle2-input: part parameters: 4
190 190 bundle2-input: found a handler for part pushkey
191 191 bundle2-input-part: "pushkey" (params: 4 mandatory) supported
192 192 pushing key for "bookmarks:W"
193 193 bundle2-input: payload chunk size: 0
194 194 bundle2-input: part header size: 0
195 195 bundle2-input: end of bundle2 stream
196 196 bundle2-input-bundle: 3 parts total
197 converting hook "txnclose-bookmark.test" to native (windows !)
197 198 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
198 199 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
199 200 bundle2-output-bundle: "HG20", 1 parts total
200 201 bundle2-output: start emission of HG20 stream
201 202 bundle2-output: bundle parameter:
202 203 bundle2-output: start of parts
203 204 bundle2-output: bundle part: "reply:pushkey"
204 205 bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload
205 206 bundle2-output: part 0: "REPLY:PUSHKEY"
206 207 bundle2-output: header chunk size: 43
207 208 bundle2-output: closing payload chunk
208 209 bundle2-output: end of bundle
209 210 bundle2-input: start processing of HG20 stream
210 211 bundle2-input: reading bundle2 stream parameters
211 212 bundle2-input-bundle: no-transaction
212 213 bundle2-input: start extraction of bundle2 parts
213 214 bundle2-input: part header size: 43
214 215 bundle2-input: part type: "REPLY:PUSHKEY"
215 216 bundle2-input: part id: "0"
216 217 bundle2-input: part parameters: 2
217 218 bundle2-input: found a handler for part reply:pushkey
218 219 bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported
219 220 bundle2-input: payload chunk size: 0
220 221 bundle2-input: part header size: 0
221 222 bundle2-input: end of bundle2 stream
222 223 bundle2-input-bundle: 0 parts total
223 224 deleting remote bookmark W
224 225 listing keys for "phases"
225 226 [1]
226 227
227 228 #endif
228 229 #if b2-binary
229 230
230 231 $ hg push -B W ../a --config "$TESTHOOK" --debug --config devel.bundle2.debug=yes
231 232 pushing to ../a
232 233 query 1; heads
233 234 searching for changes
234 235 all remote heads known locally
235 236 listing keys for "phases"
236 237 checking for updated bookmarks
237 238 listing keys for "bookmarks"
238 239 no changes found
239 240 bundle2-output-bundle: "HG20", 4 parts total
240 241 bundle2-output: start emission of HG20 stream
241 242 bundle2-output: bundle parameter:
242 243 bundle2-output: start of parts
243 244 bundle2-output: bundle part: "replycaps"
244 245 bundle2-output-part: "replycaps" 222 bytes payload
245 246 bundle2-output: part 0: "REPLYCAPS"
246 247 bundle2-output: header chunk size: 16
247 248 bundle2-output: payload chunk size: 222
248 249 bundle2-output: closing payload chunk
249 250 bundle2-output: bundle part: "check:bookmarks"
250 251 bundle2-output-part: "check:bookmarks" 23 bytes payload
251 252 bundle2-output: part 1: "CHECK:BOOKMARKS"
252 253 bundle2-output: header chunk size: 22
253 254 bundle2-output: payload chunk size: 23
254 255 bundle2-output: closing payload chunk
255 256 bundle2-output: bundle part: "check:phases"
256 257 bundle2-output-part: "check:phases" 48 bytes payload
257 258 bundle2-output: part 2: "CHECK:PHASES"
258 259 bundle2-output: header chunk size: 19
259 260 bundle2-output: payload chunk size: 48
260 261 bundle2-output: closing payload chunk
261 262 bundle2-output: bundle part: "bookmarks"
262 263 bundle2-output-part: "bookmarks" 23 bytes payload
263 264 bundle2-output: part 3: "BOOKMARKS"
264 265 bundle2-output: header chunk size: 16
265 266 bundle2-output: payload chunk size: 23
266 267 bundle2-output: closing payload chunk
267 268 bundle2-output: end of bundle
268 269 bundle2-input: start processing of HG20 stream
269 270 bundle2-input: reading bundle2 stream parameters
270 271 bundle2-input-bundle: with-transaction
271 272 bundle2-input: start extraction of bundle2 parts
272 273 bundle2-input: part header size: 16
273 274 bundle2-input: part type: "REPLYCAPS"
274 275 bundle2-input: part id: "0"
275 276 bundle2-input: part parameters: 0
276 277 bundle2-input: found a handler for part replycaps
277 278 bundle2-input-part: "replycaps" supported
278 279 bundle2-input: payload chunk size: 222
279 280 bundle2-input: payload chunk size: 0
280 281 bundle2-input-part: total payload size 222
281 282 bundle2-input: part header size: 22
282 283 bundle2-input: part type: "CHECK:BOOKMARKS"
283 284 bundle2-input: part id: "1"
284 285 bundle2-input: part parameters: 0
285 286 bundle2-input: found a handler for part check:bookmarks
286 287 bundle2-input-part: "check:bookmarks" supported
287 288 bundle2-input: payload chunk size: 23
288 289 bundle2-input: payload chunk size: 0
289 290 bundle2-input-part: total payload size 23
290 291 bundle2-input: part header size: 19
291 292 bundle2-input: part type: "CHECK:PHASES"
292 293 bundle2-input: part id: "2"
293 294 bundle2-input: part parameters: 0
294 295 bundle2-input: found a handler for part check:phases
295 296 bundle2-input-part: "check:phases" supported
296 297 bundle2-input: payload chunk size: 48
297 298 bundle2-input: payload chunk size: 0
298 299 bundle2-input-part: total payload size 48
299 300 bundle2-input: part header size: 16
300 301 bundle2-input: part type: "BOOKMARKS"
301 302 bundle2-input: part id: "3"
302 303 bundle2-input: part parameters: 0
303 304 bundle2-input: found a handler for part bookmarks
304 305 bundle2-input-part: "bookmarks" supported
305 306 bundle2-input: payload chunk size: 23
306 307 bundle2-input: payload chunk size: 0
307 308 bundle2-input-part: total payload size 23
308 309 bundle2-input: part header size: 0
309 310 bundle2-input: end of bundle2 stream
310 311 bundle2-input-bundle: 3 parts total
312 converting hook "txnclose-bookmark.test" to native (windows !)
311 313 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
312 314 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
313 315 bundle2-output-bundle: "HG20", 0 parts total
314 316 bundle2-output: start emission of HG20 stream
315 317 bundle2-output: bundle parameter:
316 318 bundle2-output: start of parts
317 319 bundle2-output: end of bundle
318 320 bundle2-input: start processing of HG20 stream
319 321 bundle2-input: reading bundle2 stream parameters
320 322 bundle2-input-bundle: no-transaction
321 323 bundle2-input: start extraction of bundle2 parts
322 324 bundle2-input: part header size: 0
323 325 bundle2-input: end of bundle2 stream
324 326 bundle2-input-bundle: 0 parts total
325 327 deleting remote bookmark W
326 328 listing keys for "phases"
327 329 [1]
328 330
329 331 #endif
330 332
331 333 export the active bookmark
332 334
333 335 $ hg bookmark V
334 336 $ hg push -B . ../a
335 337 pushing to ../a
336 338 searching for changes
337 339 no changes found
338 340 exporting bookmark V
339 341 [1]
340 342
341 343 exporting the active bookmark with 'push -B .'
342 344 demand that one of the bookmarks is activated
343 345
344 346 $ hg update -r default
345 347 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
346 348 (leaving bookmark V)
347 349 $ hg push -B . ../a
348 350 abort: no active bookmark
349 351 [255]
350 352 $ hg update -r V
351 353 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
352 354 (activating bookmark V)
353 355
354 356 delete the bookmark
355 357
356 358 $ hg book -d V
357 359 $ hg push -B V ../a
358 360 pushing to ../a
359 361 searching for changes
360 362 no changes found
361 363 deleting remote bookmark V
362 364 [1]
363 365 $ hg up foobar
364 366 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
365 367 (activating bookmark foobar)
366 368
367 369 push/pull name that doesn't exist
368 370
369 371 $ hg push -B badname ../a
370 372 pushing to ../a
371 373 searching for changes
372 374 bookmark badname does not exist on the local or remote repository!
373 375 no changes found
374 376 [2]
375 377 $ hg pull -B anotherbadname ../a
376 378 pulling from ../a
377 379 abort: remote bookmark anotherbadname not found!
378 380 [255]
379 381
380 382 divergent bookmarks
381 383
382 384 $ cd ../a
383 385 $ echo c1 > f1
384 386 $ hg ci -Am1
385 387 adding f1
386 388 $ hg book -f @
387 389 $ hg book -f X
388 390 $ hg book
389 391 @ 1:0d2164f0ce0d
390 392 * X 1:0d2164f0ce0d
391 393 Y 0:4e3505fd9583
392 394 Z 1:0d2164f0ce0d
393 395
394 396 $ cd ../b
395 397 $ hg up
396 398 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
397 399 updating bookmark foobar
398 400 $ echo c2 > f2
399 401 $ hg ci -Am2
400 402 adding f2
401 403 $ hg book -if @
402 404 $ hg book -if X
403 405 $ hg book
404 406 @ 1:9b140be10808
405 407 X 1:9b140be10808
406 408 Y 0:4e3505fd9583
407 409 Z 0:4e3505fd9583
408 410 foo -1:000000000000
409 411 * foobar 1:9b140be10808
410 412
411 413 $ hg pull --config paths.foo=../a foo --config "$TESTHOOK"
412 414 pulling from $TESTTMP/a
413 415 searching for changes
414 416 adding changesets
415 417 adding manifests
416 418 adding file changes
417 419 added 1 changesets with 1 changes to 1 files (+1 heads)
418 420 divergent bookmark @ stored as @foo
419 421 divergent bookmark X stored as X@foo
420 422 updating bookmark Z
421 423 new changesets 0d2164f0ce0d
422 424 test-hook-bookmark: @foo: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c
423 425 test-hook-bookmark: X@foo: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c
424 426 test-hook-bookmark: Z: 4e3505fd95835d721066b76e75dbb8cc554d7f77 -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c
425 427 (run 'hg heads' to see heads, 'hg merge' to merge)
426 428 $ hg book
427 429 @ 1:9b140be10808
428 430 @foo 2:0d2164f0ce0d
429 431 X 1:9b140be10808
430 432 X@foo 2:0d2164f0ce0d
431 433 Y 0:4e3505fd9583
432 434 Z 2:0d2164f0ce0d
433 435 foo -1:000000000000
434 436 * foobar 1:9b140be10808
435 437
436 438 (test that too many divergence of bookmark)
437 439
438 440 $ $PYTHON $TESTDIR/seq.py 1 100 | while read i; do hg bookmarks -r 000000000000 "X@${i}"; done
439 441 $ hg pull ../a
440 442 pulling from ../a
441 443 searching for changes
442 444 no changes found
443 445 warning: failed to assign numbered name to divergent bookmark X
444 446 divergent bookmark @ stored as @1
445 447 $ hg bookmarks | grep '^ X' | grep -v ':000000000000'
446 448 X 1:9b140be10808
447 449 X@foo 2:0d2164f0ce0d
448 450
449 451 (test that remotely diverged bookmarks are reused if they aren't changed)
450 452
451 453 $ hg bookmarks | grep '^ @'
452 454 @ 1:9b140be10808
453 455 @1 2:0d2164f0ce0d
454 456 @foo 2:0d2164f0ce0d
455 457 $ hg pull ../a
456 458 pulling from ../a
457 459 searching for changes
458 460 no changes found
459 461 warning: failed to assign numbered name to divergent bookmark X
460 462 divergent bookmark @ stored as @1
461 463 $ hg bookmarks | grep '^ @'
462 464 @ 1:9b140be10808
463 465 @1 2:0d2164f0ce0d
464 466 @foo 2:0d2164f0ce0d
465 467
466 468 $ $PYTHON $TESTDIR/seq.py 1 100 | while read i; do hg bookmarks -d "X@${i}"; done
467 469 $ hg bookmarks -d "@1"
468 470
469 471 $ hg push -f ../a
470 472 pushing to ../a
471 473 searching for changes
472 474 adding changesets
473 475 adding manifests
474 476 adding file changes
475 477 added 1 changesets with 1 changes to 1 files (+1 heads)
476 478 $ hg -R ../a book
477 479 @ 1:0d2164f0ce0d
478 480 * X 1:0d2164f0ce0d
479 481 Y 0:4e3505fd9583
480 482 Z 1:0d2164f0ce0d
481 483
482 484 explicit pull should overwrite the local version (issue4439)
483 485
484 486 $ hg update -r X
485 487 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
486 488 (activating bookmark X)
487 489 $ hg pull --config paths.foo=../a foo -B . --config "$TESTHOOK"
488 490 pulling from $TESTTMP/a
489 491 no changes found
490 492 divergent bookmark @ stored as @foo
491 493 importing bookmark X
492 494 test-hook-bookmark: @foo: 0d2164f0ce0d8f1d6f94351eba04b794909be66c -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c
493 495 test-hook-bookmark: X: 9b140be1080824d768c5a4691a564088eede71f9 -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c
494 496
495 497 reinstall state for further testing:
496 498
497 499 $ hg book -fr 9b140be10808 X
498 500
499 501 revsets should not ignore divergent bookmarks
500 502
501 503 $ hg bookmark -fr 1 Z
502 504 $ hg log -r 'bookmark()' --template '{rev}:{node|short} {bookmarks}\n'
503 505 0:4e3505fd9583 Y
504 506 1:9b140be10808 @ X Z foobar
505 507 2:0d2164f0ce0d @foo X@foo
506 508 $ hg log -r 'bookmark("X@foo")' --template '{rev}:{node|short} {bookmarks}\n'
507 509 2:0d2164f0ce0d @foo X@foo
508 510 $ hg log -r 'bookmark("re:X@foo")' --template '{rev}:{node|short} {bookmarks}\n'
509 511 2:0d2164f0ce0d @foo X@foo
510 512
511 513 update a remote bookmark from a non-head to a head
512 514
513 515 $ hg up -q Y
514 516 $ echo c3 > f2
515 517 $ hg ci -Am3
516 518 adding f2
517 519 created new head
518 520 $ hg push ../a --config "$TESTHOOK"
519 521 pushing to ../a
520 522 searching for changes
521 523 adding changesets
522 524 adding manifests
523 525 adding file changes
524 526 added 1 changesets with 1 changes to 1 files (+1 heads)
525 527 test-hook-bookmark: Y: 4e3505fd95835d721066b76e75dbb8cc554d7f77 -> f6fc62dde3c0771e29704af56ba4d8af77abcc2f
526 528 updating bookmark Y
527 529 $ hg -R ../a book
528 530 @ 1:0d2164f0ce0d
529 531 * X 1:0d2164f0ce0d
530 532 Y 3:f6fc62dde3c0
531 533 Z 1:0d2164f0ce0d
532 534
533 535 update a bookmark in the middle of a client pulling changes
534 536
535 537 $ cd ..
536 538 $ hg clone -q a pull-race
537 539
538 540 We want to use http because it is stateless and therefore more susceptible to
539 541 race conditions
540 542
541 543 $ hg serve -R pull-race -p $HGPORT -d --pid-file=pull-race.pid -E main-error.log
542 544 $ cat pull-race.pid >> $DAEMON_PIDS
543 545
544 546 $ cat <<EOF > $TESTTMP/out_makecommit.sh
545 547 > #!/bin/sh
546 548 > hg ci -Am5
547 549 > echo committed in pull-race
548 550 > EOF
549 551
550 552 $ hg clone -q http://localhost:$HGPORT/ pull-race2 --config "$TESTHOOK"
551 553 test-hook-bookmark: @: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c
552 554 test-hook-bookmark: X: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c
553 555 test-hook-bookmark: Y: -> f6fc62dde3c0771e29704af56ba4d8af77abcc2f
554 556 test-hook-bookmark: Z: -> 0d2164f0ce0d8f1d6f94351eba04b794909be66c
555 557 $ cd pull-race
556 558 $ hg up -q Y
557 559 $ echo c4 > f2
558 560 $ hg ci -Am4
559 561 $ echo c5 > f3
560 562 $ cat <<EOF > .hg/hgrc
561 563 > [hooks]
562 564 > outgoing.makecommit = sh $TESTTMP/out_makecommit.sh
563 565 > EOF
564 566
565 567 (new config needs a server restart)
566 568
567 569 $ cd ..
568 570 $ killdaemons.py
569 571 $ hg serve -R pull-race -p $HGPORT -d --pid-file=pull-race.pid -E main-error.log
570 572 $ cat pull-race.pid >> $DAEMON_PIDS
571 573 $ cd pull-race2
572 574 $ hg -R $TESTTMP/pull-race book
573 575 @ 1:0d2164f0ce0d
574 576 X 1:0d2164f0ce0d
575 577 * Y 4:b0a5eff05604
576 578 Z 1:0d2164f0ce0d
577 579 $ hg pull
578 580 pulling from http://localhost:$HGPORT/
579 581 searching for changes
580 582 adding changesets
581 583 adding manifests
582 584 adding file changes
583 585 added 1 changesets with 1 changes to 1 files
584 586 updating bookmark Y
585 587 new changesets b0a5eff05604
586 588 (run 'hg update' to get a working copy)
587 589 $ hg book
588 590 * @ 1:0d2164f0ce0d
589 591 X 1:0d2164f0ce0d
590 592 Y 4:b0a5eff05604
591 593 Z 1:0d2164f0ce0d
592 594
593 595 Update a bookmark right after the initial lookup -B (issue4689)
594 596
595 597 $ echo c6 > ../pull-race/f3 # to be committed during the race
596 598 $ cat <<EOF > $TESTTMP/listkeys_makecommit.sh
597 599 > #!/bin/sh
598 600 > if hg st | grep -q M; then
599 601 > hg commit -m race
600 602 > echo committed in pull-race
601 603 > else
602 604 > exit 0
603 605 > fi
604 606 > EOF
605 607 $ cat <<EOF > ../pull-race/.hg/hgrc
606 608 > [hooks]
607 609 > # If anything to commit, commit it right after the first key listing used
608 610 > # during lookup. This makes the commit appear before the actual getbundle
609 611 > # call.
610 612 > listkeys.makecommit= sh $TESTTMP/listkeys_makecommit.sh
611 613 > EOF
612 614
613 615 (new config need server restart)
614 616
615 617 $ killdaemons.py
616 618 $ hg serve -R ../pull-race -p $HGPORT -d --pid-file=../pull-race.pid -E main-error.log
617 619 $ cat ../pull-race.pid >> $DAEMON_PIDS
618 620
619 621 $ hg -R $TESTTMP/pull-race book
620 622 @ 1:0d2164f0ce0d
621 623 X 1:0d2164f0ce0d
622 624 * Y 5:35d1ef0a8d1b
623 625 Z 1:0d2164f0ce0d
624 626 $ hg update -r Y
625 627 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
626 628 (activating bookmark Y)
627 629 $ hg pull -B .
628 630 pulling from http://localhost:$HGPORT/
629 631 searching for changes
630 632 adding changesets
631 633 adding manifests
632 634 adding file changes
633 635 added 1 changesets with 1 changes to 1 files
634 636 updating bookmark Y
635 637 new changesets 35d1ef0a8d1b
636 638 (run 'hg update' to get a working copy)
637 639 $ hg book
638 640 @ 1:0d2164f0ce0d
639 641 X 1:0d2164f0ce0d
640 642 * Y 5:35d1ef0a8d1b
641 643 Z 1:0d2164f0ce0d
642 644
643 645 (done with this section of the test)
644 646
645 647 $ killdaemons.py
646 648 $ cd ../b
647 649
648 650 diverging a remote bookmark fails
649 651
650 652 $ hg up -q 4e3505fd9583
651 653 $ echo c4 > f2
652 654 $ hg ci -Am4
653 655 adding f2
654 656 created new head
655 657 $ echo c5 > f2
656 658 $ hg ci -Am5
657 659 $ hg log -G
658 660 @ 5:c922c0139ca0 5
659 661 |
660 662 o 4:4efff6d98829 4
661 663 |
662 664 | o 3:f6fc62dde3c0 3
663 665 |/
664 666 | o 2:0d2164f0ce0d 1
665 667 |/
666 668 | o 1:9b140be10808 2
667 669 |/
668 670 o 0:4e3505fd9583 test
669 671
670 672
671 673 $ hg book -f Y
672 674
673 675 $ cat <<EOF > ../a/.hg/hgrc
674 676 > [web]
675 677 > push_ssl = false
676 678 > allow_push = *
677 679 > EOF
678 680
679 681 $ hg serve -R ../a -p $HGPORT2 -d --pid-file=../hg2.pid
680 682 $ cat ../hg2.pid >> $DAEMON_PIDS
681 683
682 684 $ hg push http://localhost:$HGPORT2/
683 685 pushing to http://localhost:$HGPORT2/
684 686 searching for changes
685 687 abort: push creates new remote head c922c0139ca0 with bookmark 'Y'!
686 688 (merge or see 'hg help push' for details about pushing new heads)
687 689 [255]
688 690 $ hg -R ../a book
689 691 @ 1:0d2164f0ce0d
690 692 * X 1:0d2164f0ce0d
691 693 Y 3:f6fc62dde3c0
692 694 Z 1:0d2164f0ce0d
693 695
694 696
695 697 Unrelated marker does not alter the decision
696 698
697 699 $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
698 700 $ hg push http://localhost:$HGPORT2/
699 701 pushing to http://localhost:$HGPORT2/
700 702 searching for changes
701 703 abort: push creates new remote head c922c0139ca0 with bookmark 'Y'!
702 704 (merge or see 'hg help push' for details about pushing new heads)
703 705 [255]
704 706 $ hg -R ../a book
705 707 @ 1:0d2164f0ce0d
706 708 * X 1:0d2164f0ce0d
707 709 Y 3:f6fc62dde3c0
708 710 Z 1:0d2164f0ce0d
709 711
710 712 Update to a successor works
711 713
712 714 $ hg id --debug -r 3
713 715 f6fc62dde3c0771e29704af56ba4d8af77abcc2f
714 716 $ hg id --debug -r 4
715 717 4efff6d98829d9c824c621afd6e3f01865f5439f
716 718 $ hg id --debug -r 5
717 719 c922c0139ca03858f655e4a2af4dd02796a63969 tip Y
718 720 $ hg debugobsolete f6fc62dde3c0771e29704af56ba4d8af77abcc2f cccccccccccccccccccccccccccccccccccccccc
719 721 obsoleted 1 changesets
720 722 $ hg debugobsolete cccccccccccccccccccccccccccccccccccccccc 4efff6d98829d9c824c621afd6e3f01865f5439f
721 723 $ hg push http://localhost:$HGPORT2/
722 724 pushing to http://localhost:$HGPORT2/
723 725 searching for changes
724 726 remote: adding changesets
725 727 remote: adding manifests
726 728 remote: adding file changes
727 729 remote: added 2 changesets with 2 changes to 1 files (+1 heads)
728 730 remote: 2 new obsolescence markers
729 731 remote: obsoleted 1 changesets
730 732 updating bookmark Y
731 733 $ hg -R ../a book
732 734 @ 1:0d2164f0ce0d
733 735 * X 1:0d2164f0ce0d
734 736 Y 5:c922c0139ca0
735 737 Z 1:0d2164f0ce0d
736 738
737 739 hgweb
738 740
739 741 $ cat <<EOF > .hg/hgrc
740 742 > [web]
741 743 > push_ssl = false
742 744 > allow_push = *
743 745 > EOF
744 746
745 747 $ hg serve -p $HGPORT -d --pid-file=../hg.pid -E errors.log
746 748 $ cat ../hg.pid >> $DAEMON_PIDS
747 749 $ cd ../a
748 750
749 751 $ hg debugpushkey http://localhost:$HGPORT/ namespaces
750 752 bookmarks
751 753 namespaces
752 754 obsolete
753 755 phases
754 756 $ hg debugpushkey http://localhost:$HGPORT/ bookmarks
755 757 @ 9b140be1080824d768c5a4691a564088eede71f9
756 758 X 9b140be1080824d768c5a4691a564088eede71f9
757 759 Y c922c0139ca03858f655e4a2af4dd02796a63969
758 760 Z 9b140be1080824d768c5a4691a564088eede71f9
759 761 foo 0000000000000000000000000000000000000000
760 762 foobar 9b140be1080824d768c5a4691a564088eede71f9
761 763 $ hg out -B http://localhost:$HGPORT/
762 764 comparing with http://localhost:$HGPORT/
763 765 searching for changed bookmarks
764 766 @ 0d2164f0ce0d
765 767 X 0d2164f0ce0d
766 768 Z 0d2164f0ce0d
767 769 foo
768 770 foobar
769 771 $ hg push -B Z http://localhost:$HGPORT/
770 772 pushing to http://localhost:$HGPORT/
771 773 searching for changes
772 774 no changes found
773 775 updating bookmark Z
774 776 [1]
775 777 $ hg book -d Z
776 778 $ hg in -B http://localhost:$HGPORT/
777 779 comparing with http://localhost:$HGPORT/
778 780 searching for changed bookmarks
779 781 @ 9b140be10808
780 782 X 9b140be10808
781 783 Z 0d2164f0ce0d
782 784 foo 000000000000
783 785 foobar 9b140be10808
784 786 $ hg pull -B Z http://localhost:$HGPORT/
785 787 pulling from http://localhost:$HGPORT/
786 788 no changes found
787 789 divergent bookmark @ stored as @1
788 790 divergent bookmark X stored as X@1
789 791 adding remote bookmark Z
790 792 adding remote bookmark foo
791 793 adding remote bookmark foobar
792 794 $ hg clone http://localhost:$HGPORT/ cloned-bookmarks
793 795 requesting all changes
794 796 adding changesets
795 797 adding manifests
796 798 adding file changes
797 799 added 5 changesets with 5 changes to 3 files (+2 heads)
798 800 2 new obsolescence markers
799 801 new changesets 4e3505fd9583:c922c0139ca0
800 802 updating to bookmark @
801 803 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
802 804 $ hg -R cloned-bookmarks bookmarks
803 805 * @ 1:9b140be10808
804 806 X 1:9b140be10808
805 807 Y 4:c922c0139ca0
806 808 Z 2:0d2164f0ce0d
807 809 foo -1:000000000000
808 810 foobar 1:9b140be10808
809 811
810 812 $ cd ..
811 813
812 814 Test to show result of bookmarks comparison
813 815
814 816 $ mkdir bmcomparison
815 817 $ cd bmcomparison
816 818
817 819 $ hg init source
818 820 $ hg -R source debugbuilddag '+2*2*3*4'
819 821 $ hg -R source log -G --template '{rev}:{node|short}'
820 822 o 4:e7bd5218ca15
821 823 |
822 824 | o 3:6100d3090acf
823 825 |/
824 826 | o 2:fa942426a6fd
825 827 |/
826 828 | o 1:66f7d451a68b
827 829 |/
828 830 o 0:1ea73414a91b
829 831
830 832 $ hg -R source bookmarks -r 0 SAME
831 833 $ hg -R source bookmarks -r 0 ADV_ON_REPO1
832 834 $ hg -R source bookmarks -r 0 ADV_ON_REPO2
833 835 $ hg -R source bookmarks -r 0 DIFF_ADV_ON_REPO1
834 836 $ hg -R source bookmarks -r 0 DIFF_ADV_ON_REPO2
835 837 $ hg -R source bookmarks -r 1 DIVERGED
836 838
837 839 $ hg clone -U source repo1
838 840
839 841 (test that incoming/outgoing exit with 1, if there is no bookmark to
840 842 be exchanged)
841 843
842 844 $ hg -R repo1 incoming -B
843 845 comparing with $TESTTMP/bmcomparison/source
844 846 searching for changed bookmarks
845 847 no changed bookmarks found
846 848 [1]
847 849 $ hg -R repo1 outgoing -B
848 850 comparing with $TESTTMP/bmcomparison/source
849 851 searching for changed bookmarks
850 852 no changed bookmarks found
851 853 [1]
852 854
853 855 $ hg -R repo1 bookmarks -f -r 1 ADD_ON_REPO1
854 856 $ hg -R repo1 bookmarks -f -r 2 ADV_ON_REPO1
855 857 $ hg -R repo1 bookmarks -f -r 3 DIFF_ADV_ON_REPO1
856 858 $ hg -R repo1 bookmarks -f -r 3 DIFF_DIVERGED
857 859 $ hg -R repo1 -q --config extensions.mq= strip 4
858 860 $ hg -R repo1 log -G --template '{node|short} ({bookmarks})'
859 861 o 6100d3090acf (DIFF_ADV_ON_REPO1 DIFF_DIVERGED)
860 862 |
861 863 | o fa942426a6fd (ADV_ON_REPO1)
862 864 |/
863 865 | o 66f7d451a68b (ADD_ON_REPO1 DIVERGED)
864 866 |/
865 867 o 1ea73414a91b (ADV_ON_REPO2 DIFF_ADV_ON_REPO2 SAME)
866 868
867 869
868 870 $ hg clone -U source repo2
869 871 $ hg -R repo2 bookmarks -f -r 1 ADD_ON_REPO2
870 872 $ hg -R repo2 bookmarks -f -r 1 ADV_ON_REPO2
871 873 $ hg -R repo2 bookmarks -f -r 2 DIVERGED
872 874 $ hg -R repo2 bookmarks -f -r 4 DIFF_ADV_ON_REPO2
873 875 $ hg -R repo2 bookmarks -f -r 4 DIFF_DIVERGED
874 876 $ hg -R repo2 -q --config extensions.mq= strip 3
875 877 $ hg -R repo2 log -G --template '{node|short} ({bookmarks})'
876 878 o e7bd5218ca15 (DIFF_ADV_ON_REPO2 DIFF_DIVERGED)
877 879 |
878 880 | o fa942426a6fd (DIVERGED)
879 881 |/
880 882 | o 66f7d451a68b (ADD_ON_REPO2 ADV_ON_REPO2)
881 883 |/
882 884 o 1ea73414a91b (ADV_ON_REPO1 DIFF_ADV_ON_REPO1 SAME)
883 885
884 886
885 887 (test that difference of bookmarks between repositories are fully shown)
886 888
887 889 $ hg -R repo1 incoming -B repo2 -v
888 890 comparing with repo2
889 891 searching for changed bookmarks
890 892 ADD_ON_REPO2 66f7d451a68b added
891 893 ADV_ON_REPO2 66f7d451a68b advanced
892 894 DIFF_ADV_ON_REPO2 e7bd5218ca15 changed
893 895 DIFF_DIVERGED e7bd5218ca15 changed
894 896 DIVERGED fa942426a6fd diverged
895 897 $ hg -R repo1 outgoing -B repo2 -v
896 898 comparing with repo2
897 899 searching for changed bookmarks
898 900 ADD_ON_REPO1 66f7d451a68b added
899 901 ADD_ON_REPO2 deleted
900 902 ADV_ON_REPO1 fa942426a6fd advanced
901 903 DIFF_ADV_ON_REPO1 6100d3090acf advanced
902 904 DIFF_ADV_ON_REPO2 1ea73414a91b changed
903 905 DIFF_DIVERGED 6100d3090acf changed
904 906 DIVERGED 66f7d451a68b diverged
905 907
906 908 $ hg -R repo2 incoming -B repo1 -v
907 909 comparing with repo1
908 910 searching for changed bookmarks
909 911 ADD_ON_REPO1 66f7d451a68b added
910 912 ADV_ON_REPO1 fa942426a6fd advanced
911 913 DIFF_ADV_ON_REPO1 6100d3090acf changed
912 914 DIFF_DIVERGED 6100d3090acf changed
913 915 DIVERGED 66f7d451a68b diverged
914 916 $ hg -R repo2 outgoing -B repo1 -v
915 917 comparing with repo1
916 918 searching for changed bookmarks
917 919 ADD_ON_REPO1 deleted
918 920 ADD_ON_REPO2 66f7d451a68b added
919 921 ADV_ON_REPO2 66f7d451a68b advanced
920 922 DIFF_ADV_ON_REPO1 1ea73414a91b changed
921 923 DIFF_ADV_ON_REPO2 e7bd5218ca15 advanced
922 924 DIFF_DIVERGED e7bd5218ca15 changed
923 925 DIVERGED fa942426a6fd diverged
924 926
925 927 $ cd ..
926 928
927 929 Pushing a bookmark should only push the changes required by that
928 930 bookmark, not all outgoing changes:
929 931 $ hg clone http://localhost:$HGPORT/ addmarks
930 932 requesting all changes
931 933 adding changesets
932 934 adding manifests
933 935 adding file changes
934 936 added 5 changesets with 5 changes to 3 files (+2 heads)
935 937 2 new obsolescence markers
936 938 new changesets 4e3505fd9583:c922c0139ca0
937 939 updating to bookmark @
938 940 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
939 941 $ cd addmarks
940 942 $ echo foo > foo
941 943 $ hg add foo
942 944 $ hg commit -m 'add foo'
943 945 $ echo bar > bar
944 946 $ hg add bar
945 947 $ hg commit -m 'add bar'
946 948 $ hg co "tip^"
947 949 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
948 950 (leaving bookmark @)
949 951 $ hg book add-foo
950 952 $ hg book -r tip add-bar
951 953 Note: this push *must* push only a single changeset, as that's the point
952 954 of this test.
953 955 $ hg push -B add-foo --traceback
954 956 pushing to http://localhost:$HGPORT/
955 957 searching for changes
956 958 remote: adding changesets
957 959 remote: adding manifests
958 960 remote: adding file changes
959 961 remote: added 1 changesets with 1 changes to 1 files
960 962 exporting bookmark add-foo
961 963
962 964 pushing a new bookmark on a new head does not require -f if -B is specified
963 965
964 966 $ hg up -q X
965 967 $ hg book W
966 968 $ echo c5 > f2
967 969 $ hg ci -Am5
968 970 created new head
969 971 $ hg push -B .
970 972 pushing to http://localhost:$HGPORT/
971 973 searching for changes
972 974 remote: adding changesets
973 975 remote: adding manifests
974 976 remote: adding file changes
975 977 remote: added 1 changesets with 1 changes to 1 files (+1 heads)
976 978 exporting bookmark W
977 979 $ hg -R ../b id -r W
978 980 cc978a373a53 tip W
979 981
980 982 pushing an existing but divergent bookmark with -B still requires -f
981 983
982 984 $ hg clone -q . ../r
983 985 $ hg up -q X
984 986 $ echo 1 > f2
985 987 $ hg ci -qAml
986 988
987 989 $ cd ../r
988 990 $ hg up -q X
989 991 $ echo 2 > f2
990 992 $ hg ci -qAmr
991 993 $ hg push -B X
992 994 pushing to $TESTTMP/addmarks
993 995 searching for changes
994 996 remote has heads on branch 'default' that are not known locally: a2a606d9ff1b
995 997 abort: push creates new remote head 54694f811df9 with bookmark 'X'!
996 998 (pull and merge or see 'hg help push' for details about pushing new heads)
997 999 [255]
998 1000 $ cd ../addmarks
999 1001
1000 1002 Check summary output for incoming/outgoing bookmarks
1001 1003
1002 1004 $ hg bookmarks -d X
1003 1005 $ hg bookmarks -d Y
1004 1006 $ hg summary --remote | grep '^remote:'
1005 1007 remote: *, 2 incoming bookmarks, 1 outgoing bookmarks (glob)
1006 1008
1007 1009 $ cd ..
1008 1010
1009 1011 pushing an unchanged bookmark should result in no changes
1010 1012
1011 1013 $ hg init unchanged-a
1012 1014 $ hg init unchanged-b
1013 1015 $ cd unchanged-a
1014 1016 $ echo initial > foo
1015 1017 $ hg commit -A -m initial
1016 1018 adding foo
1017 1019 $ hg bookmark @
1018 1020 $ hg push -B @ ../unchanged-b
1019 1021 pushing to ../unchanged-b
1020 1022 searching for changes
1021 1023 adding changesets
1022 1024 adding manifests
1023 1025 adding file changes
1024 1026 added 1 changesets with 1 changes to 1 files
1025 1027 exporting bookmark @
1026 1028
1027 1029 $ hg push -B @ ../unchanged-b
1028 1030 pushing to ../unchanged-b
1029 1031 searching for changes
1030 1032 no changes found
1031 1033 [1]
1032 1034
1033 1035 Pushing a really long bookmark should work fine (issue5165)
1034 1036 ===============================================
1035 1037
1036 1038 #if b2-binary
1037 1039 >>> with open('longname', 'w') as f:
1038 1040 ... f.write('wat' * 100) and None
1039 1041 $ hg book `cat longname`
1040 1042 $ hg push -B `cat longname` ../unchanged-b
1041 1043 pushing to ../unchanged-b
1042 1044 searching for changes
1043 1045 no changes found
1044 1046 exporting bookmark (wat){100} (re)
1045 1047 [1]
1046 1048 $ hg -R ../unchanged-b book --delete `cat longname`
1047 1049
1048 1050 Test again but forcing bundle2 exchange to make sure that doesn't regress.
1049 1051
1050 1052 $ hg push -B `cat longname` ../unchanged-b --config devel.legacy.exchange=bundle1
1051 1053 pushing to ../unchanged-b
1052 1054 searching for changes
1053 1055 no changes found
1054 1056 exporting bookmark (wat){100} (re)
1055 1057 [1]
1056 1058 $ hg -R ../unchanged-b book --delete `cat longname`
1057 1059 $ hg book --delete `cat longname`
1058 1060 $ hg co @
1059 1061 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1060 1062 (activating bookmark @)
1061 1063 #endif
1062 1064
1063 1065 Check hook preventing push (issue4455)
1064 1066 ======================================
1065 1067
1066 1068 $ hg bookmarks
1067 1069 * @ 0:55482a6fb4b1
1068 1070 $ hg log -G
1069 1071 @ 0:55482a6fb4b1 initial
1070 1072
1071 1073 $ hg init ../issue4455-dest
1072 1074 $ hg push ../issue4455-dest # changesets only
1073 1075 pushing to ../issue4455-dest
1074 1076 searching for changes
1075 1077 adding changesets
1076 1078 adding manifests
1077 1079 adding file changes
1078 1080 added 1 changesets with 1 changes to 1 files
1079 1081 $ cat >> .hg/hgrc << EOF
1080 1082 > [paths]
1081 1083 > local=../issue4455-dest/
1082 1084 > ssh=ssh://user@dummy/issue4455-dest
1083 1085 > http=http://localhost:$HGPORT/
1084 1086 > [ui]
1085 1087 > ssh=$PYTHON "$TESTDIR/dummyssh"
1086 1088 > EOF
1087 1089 $ cat >> ../issue4455-dest/.hg/hgrc << EOF
1088 1090 > [hooks]
1089 1091 > prepushkey=false
1090 1092 > [web]
1091 1093 > push_ssl = false
1092 1094 > allow_push = *
1093 1095 > EOF
1094 1096 $ killdaemons.py
1095 1097 $ hg serve -R ../issue4455-dest -p $HGPORT -d --pid-file=../issue4455.pid -E ../issue4455-error.log
1096 1098 $ cat ../issue4455.pid >> $DAEMON_PIDS
1097 1099
1098 1100 Local push
1099 1101 ----------
1100 1102
1101 1103 #if b2-pushkey
1102 1104
1103 1105 $ hg push -B @ local
1104 1106 pushing to $TESTTMP/issue4455-dest
1105 1107 searching for changes
1106 1108 no changes found
1107 1109 pushkey-abort: prepushkey hook exited with status 1
1108 1110 abort: exporting bookmark @ failed!
1109 1111 [255]
1110 1112
1111 1113 #endif
1112 1114 #if b2-binary
1113 1115
1114 1116 $ hg push -B @ local
1115 1117 pushing to $TESTTMP/issue4455-dest
1116 1118 searching for changes
1117 1119 no changes found
1118 1120 abort: prepushkey hook exited with status 1
1119 1121 [255]
1120 1122
1121 1123 #endif
1122 1124
1123 1125 $ hg -R ../issue4455-dest/ bookmarks
1124 1126 no bookmarks set
1125 1127
1126 1128 Using ssh
1127 1129 ---------
1128 1130
1129 1131 #if b2-pushkey
1130 1132
1131 1133 $ hg push -B @ ssh # bundle2+
1132 1134 pushing to ssh://user@dummy/issue4455-dest
1133 1135 searching for changes
1134 1136 no changes found
1135 1137 remote: pushkey-abort: prepushkey hook exited with status 1
1136 1138 abort: exporting bookmark @ failed!
1137 1139 [255]
1138 1140
1139 1141 $ hg -R ../issue4455-dest/ bookmarks
1140 1142 no bookmarks set
1141 1143
1142 1144 $ hg push -B @ ssh --config devel.legacy.exchange=bundle1
1143 1145 pushing to ssh://user@dummy/issue4455-dest
1144 1146 searching for changes
1145 1147 no changes found
1146 1148 remote: pushkey-abort: prepushkey hook exited with status 1
1147 1149 exporting bookmark @ failed!
1148 1150 [1]
1149 1151
1150 1152 #endif
1151 1153 #if b2-binary
1152 1154
1153 1155 $ hg push -B @ ssh # bundle2+
1154 1156 pushing to ssh://user@dummy/issue4455-dest
1155 1157 searching for changes
1156 1158 no changes found
1157 1159 remote: prepushkey hook exited with status 1
1158 1160 abort: push failed on remote
1159 1161 [255]
1160 1162
1161 1163 #endif
1162 1164
1163 1165 $ hg -R ../issue4455-dest/ bookmarks
1164 1166 no bookmarks set
1165 1167
1166 1168 Using http
1167 1169 ----------
1168 1170
1169 1171 #if b2-pushkey
1170 1172 $ hg push -B @ http # bundle2+
1171 1173 pushing to http://localhost:$HGPORT/
1172 1174 searching for changes
1173 1175 no changes found
1174 1176 remote: pushkey-abort: prepushkey hook exited with status 1
1175 1177 abort: exporting bookmark @ failed!
1176 1178 [255]
1177 1179
1178 1180 $ hg -R ../issue4455-dest/ bookmarks
1179 1181 no bookmarks set
1180 1182
1181 1183 $ hg push -B @ http --config devel.legacy.exchange=bundle1
1182 1184 pushing to http://localhost:$HGPORT/
1183 1185 searching for changes
1184 1186 no changes found
1185 1187 remote: pushkey-abort: prepushkey hook exited with status 1
1186 1188 exporting bookmark @ failed!
1187 1189 [1]
1188 1190
1189 1191 #endif
1190 1192
1191 1193 #if b2-binary
1192 1194
1193 1195 $ hg push -B @ ssh # bundle2+
1194 1196 pushing to ssh://user@dummy/issue4455-dest
1195 1197 searching for changes
1196 1198 no changes found
1197 1199 remote: prepushkey hook exited with status 1
1198 1200 abort: push failed on remote
1199 1201 [255]
1200 1202
1201 1203 #endif
1202 1204
1203 1205 $ hg -R ../issue4455-dest/ bookmarks
1204 1206 no bookmarks set
1205 1207
1206 1208 $ cd ..
1207 1209
1208 1210 Test that pre-pushkey compat for bookmark works as expected (issue5777)
1209 1211
1210 1212 $ cat << EOF >> $HGRCPATH
1211 1213 > [ui]
1212 1214 > ssh="$PYTHON" "$TESTDIR/dummyssh"
1213 1215 > [server]
1214 1216 > bookmarks-pushkey-compat = yes
1215 1217 > EOF
1216 1218
1217 1219 $ hg init server
1218 1220 $ echo foo > server/a
1219 1221 $ hg -R server book foo
1220 1222 $ hg -R server commit -Am a
1221 1223 adding a
1222 1224 $ hg clone ssh://user@dummy/server client
1223 1225 requesting all changes
1224 1226 adding changesets
1225 1227 adding manifests
1226 1228 adding file changes
1227 1229 added 1 changesets with 1 changes to 1 files
1228 1230 new changesets 79513d0d7716
1229 1231 updating to branch default
1230 1232 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1231 1233
1232 1234 Forbid bookmark move on the server
1233 1235
1234 1236 $ cat << EOF >> $TESTDIR/no-bm-move.sh
1235 1237 > #!/bin/sh
1236 1238 > echo \$HG_NAMESPACE | grep -v bookmarks
1237 1239 > EOF
1238 1240 $ cat << EOF >> server/.hg/hgrc
1239 1241 > [hooks]
1240 1242 > prepushkey.no-bm-move= sh $TESTDIR/no-bm-move.sh
1241 1243 > EOF
1242 1244
1243 1245 pushing changeset is okay
1244 1246
1245 1247 $ echo bar >> client/a
1246 1248 $ hg -R client commit -m b
1247 1249 $ hg -R client push
1248 1250 pushing to ssh://user@dummy/server
1249 1251 searching for changes
1250 1252 remote: adding changesets
1251 1253 remote: adding manifests
1252 1254 remote: adding file changes
1253 1255 remote: added 1 changesets with 1 changes to 1 files
1254 1256
1255 1257 attempt to move the bookmark is rejected
1256 1258
1257 1259 $ hg -R client book foo -r .
1258 1260 moving bookmark 'foo' forward from 79513d0d7716
1259 1261
1260 1262 #if b2-pushkey
1261 1263 $ hg -R client push
1262 1264 pushing to ssh://user@dummy/server
1263 1265 searching for changes
1264 1266 no changes found
1265 1267 remote: pushkey-abort: prepushkey.no-bm-move hook exited with status 1
1266 1268 abort: updating bookmark foo failed!
1267 1269 [255]
1268 1270 #endif
1269 1271 #if b2-binary
1270 1272 $ hg -R client push
1271 1273 pushing to ssh://user@dummy/server
1272 1274 searching for changes
1273 1275 no changes found
1274 1276 remote: prepushkey.no-bm-move hook exited with status 1
1275 1277 abort: push failed on remote
1276 1278 [255]
1277 1279 #endif
@@ -1,1283 +1,1285
1 1 $ hg init
2 2
3 3 Setup:
4 4
5 5 $ echo a >> a
6 6 $ hg ci -Am 'base'
7 7 adding a
8 8
9 9 Refuse to amend public csets:
10 10
11 11 $ hg phase -r . -p
12 12 $ hg ci --amend
13 13 abort: cannot amend public changesets
14 14 (see 'hg help phases' for details)
15 15 [255]
16 16 $ hg phase -r . -f -d
17 17
18 18 $ echo a >> a
19 19 $ hg ci -Am 'base1'
20 20
21 21 Nothing to amend:
22 22
23 23 $ hg ci --amend -m 'base1'
24 24 nothing changed
25 25 [1]
26 26
27 27 $ cat >> $HGRCPATH <<EOF
28 28 > [hooks]
29 29 > pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE"
30 30 > EOF
31 31
32 32 Amending changeset with changes in working dir:
33 33 (and check that --message does not trigger an editor)
34 34
35 35 $ echo a >> a
36 36 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1'
37 37 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149
38 38 43f1ba15f28a tip
39 39 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-5ab4f721-amend.hg
40 40 $ echo 'pretxncommit.foo = ' >> $HGRCPATH
41 41 $ hg diff -c .
42 42 diff -r ad120869acf0 -r 43f1ba15f28a a
43 43 --- a/a Thu Jan 01 00:00:00 1970 +0000
44 44 +++ b/a Thu Jan 01 00:00:00 1970 +0000
45 45 @@ -1,1 +1,3 @@
46 46 a
47 47 +a
48 48 +a
49 49 $ hg log
50 50 changeset: 1:43f1ba15f28a
51 51 tag: tip
52 52 user: test
53 53 date: Thu Jan 01 00:00:00 1970 +0000
54 54 summary: amend base1
55 55
56 56 changeset: 0:ad120869acf0
57 57 user: test
58 58 date: Thu Jan 01 00:00:00 1970 +0000
59 59 summary: base
60 60
61 61
62 62 Check proper abort for empty message
63 63
64 64 $ cat > editor.sh << '__EOF__'
65 65 > #!/bin/sh
66 66 > echo "" > "$1"
67 67 > __EOF__
68 68
69 69 Update the existing file to ensure that the dirstate is not in pending state
70 70 (where the status of some files in the working copy is not known yet). This in
71 71 turn ensures that when the transaction is aborted due to an empty message during
72 72 the amend, there should be no rollback.
73 73 $ echo a >> a
74 74
75 75 $ echo b > b
76 76 $ hg add b
77 77 $ hg summary
78 78 parent: 1:43f1ba15f28a tip
79 79 amend base1
80 80 branch: default
81 81 commit: 1 modified, 1 added, 1 unknown
82 82 update: (current)
83 83 phases: 2 draft
84 84 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
85 85 abort: empty commit message
86 86 [255]
87 87 $ hg summary
88 88 parent: 1:43f1ba15f28a tip
89 89 amend base1
90 90 branch: default
91 91 commit: 1 modified, 1 added, 1 unknown
92 92 update: (current)
93 93 phases: 2 draft
94 94
95 95 Add new file along with modified existing file:
96 96 $ hg ci --amend -m 'amend base1 new file'
97 97 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-007467c2-amend.hg
98 98
99 99 Remove file that was added in amended commit:
100 100 (and test logfile option)
101 101 (and test that logfile option do not trigger an editor)
102 102
103 103 $ hg rm b
104 104 $ echo 'amend base1 remove new file' > ../logfile
105 105 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile
106 106 saved backup bundle to $TESTTMP/.hg/strip-backup/c16295aaf401-1ada9901-amend.hg
107 107
108 108 $ hg cat b
109 109 b: no such file in rev 47343646fa3d
110 110 [1]
111 111
112 112 No changes, just a different message:
113 113
114 114 $ hg ci -v --amend -m 'no changes, new message'
115 115 amending changeset 47343646fa3d
116 116 copying changeset 47343646fa3d to ad120869acf0
117 117 committing files:
118 118 a
119 119 committing manifest
120 120 committing changelog
121 121 1 changesets found
122 122 uncompressed size of bundle content:
123 123 254 (changelog)
124 124 163 (manifests)
125 125 131 a
126 126 saved backup bundle to $TESTTMP/.hg/strip-backup/47343646fa3d-c2758885-amend.hg
127 127 1 changesets found
128 128 uncompressed size of bundle content:
129 129 250 (changelog)
130 130 163 (manifests)
131 131 131 a
132 132 adding branch
133 133 adding changesets
134 134 adding manifests
135 135 adding file changes
136 136 added 1 changesets with 1 changes to 1 files
137 137 committed changeset 1:401431e913a1
138 138 $ hg diff -c .
139 139 diff -r ad120869acf0 -r 401431e913a1 a
140 140 --- a/a Thu Jan 01 00:00:00 1970 +0000
141 141 +++ b/a Thu Jan 01 00:00:00 1970 +0000
142 142 @@ -1,1 +1,4 @@
143 143 a
144 144 +a
145 145 +a
146 146 +a
147 147 $ hg log
148 148 changeset: 1:401431e913a1
149 149 tag: tip
150 150 user: test
151 151 date: Thu Jan 01 00:00:00 1970 +0000
152 152 summary: no changes, new message
153 153
154 154 changeset: 0:ad120869acf0
155 155 user: test
156 156 date: Thu Jan 01 00:00:00 1970 +0000
157 157 summary: base
158 158
159 159
160 160 Disable default date on commit so when -d isn't given, the old date is preserved:
161 161
162 162 $ echo '[defaults]' >> $HGRCPATH
163 163 $ echo 'commit=' >> $HGRCPATH
164 164
165 165 Test -u/-d:
166 166
167 167 $ cat > .hg/checkeditform.sh <<EOF
168 168 > env | grep HGEDITFORM
169 169 > true
170 170 > EOF
171 171 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0'
172 172 HGEDITFORM=commit.amend.normal
173 173 saved backup bundle to $TESTTMP/.hg/strip-backup/401431e913a1-5e8e532c-amend.hg
174 174 $ echo a >> a
175 175 $ hg ci --amend -u foo -d '1 0'
176 176 saved backup bundle to $TESTTMP/.hg/strip-backup/d96b1d28ae33-677e0afb-amend.hg
177 177 $ hg log -r .
178 178 changeset: 1:a9a13940fc03
179 179 tag: tip
180 180 user: foo
181 181 date: Thu Jan 01 00:00:01 1970 +0000
182 182 summary: no changes, new message
183 183
184 184
185 185 Open editor with old commit message if a message isn't given otherwise:
186 186
187 187 $ cat > editor.sh << '__EOF__'
188 188 > #!/bin/sh
189 189 > cat $1
190 190 > echo "another precious commit message" > "$1"
191 191 > __EOF__
192 192
193 193 at first, test saving last-message.txt
194 194
195 195 $ cat > .hg/hgrc << '__EOF__'
196 196 > [hooks]
197 197 > pretxncommit.test-saving-last-message = false
198 198 > __EOF__
199 199
200 200 $ rm -f .hg/last-message.txt
201 201 $ hg commit --amend -v -m "message given from command line"
202 202 amending changeset a9a13940fc03
203 203 copying changeset a9a13940fc03 to ad120869acf0
204 204 committing files:
205 205 a
206 206 committing manifest
207 207 committing changelog
208 converting hook "pretxncommit.test-saving-last-message" to native (windows !)
208 209 running hook pretxncommit.test-saving-last-message: false
209 210 transaction abort!
210 211 rollback completed
211 212 abort: pretxncommit.test-saving-last-message hook exited with status 1
212 213 [255]
213 214 $ cat .hg/last-message.txt
214 215 message given from command line (no-eol)
215 216
216 217 $ rm -f .hg/last-message.txt
217 218 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
218 219 amending changeset a9a13940fc03
219 220 copying changeset a9a13940fc03 to ad120869acf0
220 221 no changes, new message
221 222
222 223
223 224 HG: Enter commit message. Lines beginning with 'HG:' are removed.
224 225 HG: Leave message empty to abort commit.
225 226 HG: --
226 227 HG: user: foo
227 228 HG: branch 'default'
228 229 HG: changed a
229 230 committing files:
230 231 a
231 232 committing manifest
232 233 committing changelog
234 converting hook "pretxncommit.test-saving-last-message" to native (windows !)
233 235 running hook pretxncommit.test-saving-last-message: false
234 236 transaction abort!
235 237 rollback completed
236 238 abort: pretxncommit.test-saving-last-message hook exited with status 1
237 239 [255]
238 240
239 241 $ cat .hg/last-message.txt
240 242 another precious commit message
241 243
242 244 $ cat > .hg/hgrc << '__EOF__'
243 245 > [hooks]
244 246 > pretxncommit.test-saving-last-message =
245 247 > __EOF__
246 248
247 249 then, test editing custom commit message
248 250
249 251 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
250 252 amending changeset a9a13940fc03
251 253 copying changeset a9a13940fc03 to ad120869acf0
252 254 no changes, new message
253 255
254 256
255 257 HG: Enter commit message. Lines beginning with 'HG:' are removed.
256 258 HG: Leave message empty to abort commit.
257 259 HG: --
258 260 HG: user: foo
259 261 HG: branch 'default'
260 262 HG: changed a
261 263 committing files:
262 264 a
263 265 committing manifest
264 266 committing changelog
265 267 1 changesets found
266 268 uncompressed size of bundle content:
267 269 249 (changelog)
268 270 163 (manifests)
269 271 133 a
270 272 saved backup bundle to $TESTTMP/.hg/strip-backup/a9a13940fc03-7c2e8674-amend.hg
271 273 1 changesets found
272 274 uncompressed size of bundle content:
273 275 257 (changelog)
274 276 163 (manifests)
275 277 133 a
276 278 adding branch
277 279 adding changesets
278 280 adding manifests
279 281 adding file changes
280 282 added 1 changesets with 1 changes to 1 files
281 283 committed changeset 1:64a124ba1b44
282 284
283 285 Same, but with changes in working dir (different code path):
284 286
285 287 $ echo a >> a
286 288 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
287 289 amending changeset 64a124ba1b44
288 290 another precious commit message
289 291
290 292
291 293 HG: Enter commit message. Lines beginning with 'HG:' are removed.
292 294 HG: Leave message empty to abort commit.
293 295 HG: --
294 296 HG: user: foo
295 297 HG: branch 'default'
296 298 HG: changed a
297 299 committing files:
298 300 a
299 301 committing manifest
300 302 committing changelog
301 303 1 changesets found
302 304 uncompressed size of bundle content:
303 305 257 (changelog)
304 306 163 (manifests)
305 307 133 a
306 308 saved backup bundle to $TESTTMP/.hg/strip-backup/64a124ba1b44-10374b8f-amend.hg
307 309 1 changesets found
308 310 uncompressed size of bundle content:
309 311 257 (changelog)
310 312 163 (manifests)
311 313 135 a
312 314 adding branch
313 315 adding changesets
314 316 adding manifests
315 317 adding file changes
316 318 added 1 changesets with 1 changes to 1 files
317 319 committed changeset 1:7892795b8e38
318 320
319 321 $ rm editor.sh
320 322 $ hg log -r .
321 323 changeset: 1:7892795b8e38
322 324 tag: tip
323 325 user: foo
324 326 date: Thu Jan 01 00:00:01 1970 +0000
325 327 summary: another precious commit message
326 328
327 329
328 330 Moving bookmarks, preserve active bookmark:
329 331
330 332 $ hg book book1
331 333 $ hg book book2
332 334 $ hg ci --amend -m 'move bookmarks'
333 335 saved backup bundle to $TESTTMP/.hg/strip-backup/7892795b8e38-3fb46217-amend.hg
334 336 $ hg book
335 337 book1 1:8311f17e2616
336 338 * book2 1:8311f17e2616
337 339 $ echo a >> a
338 340 $ hg ci --amend -m 'move bookmarks'
339 341 saved backup bundle to $TESTTMP/.hg/strip-backup/8311f17e2616-f0504fe3-amend.hg
340 342 $ hg book
341 343 book1 1:a3b65065808c
342 344 * book2 1:a3b65065808c
343 345
344 346 abort does not loose bookmarks
345 347
346 348 $ cat > editor.sh << '__EOF__'
347 349 > #!/bin/sh
348 350 > echo "" > "$1"
349 351 > __EOF__
350 352 $ echo a >> a
351 353 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
352 354 abort: empty commit message
353 355 [255]
354 356 $ hg book
355 357 book1 1:a3b65065808c
356 358 * book2 1:a3b65065808c
357 359 $ hg revert -Caq
358 360 $ rm editor.sh
359 361
360 362 $ echo '[defaults]' >> $HGRCPATH
361 363 $ echo "commit=-d '0 0'" >> $HGRCPATH
362 364
363 365 Moving branches:
364 366
365 367 $ hg branch foo
366 368 marked working directory as branch foo
367 369 (branches are permanent and global, did you want a bookmark?)
368 370 $ echo a >> a
369 371 $ hg ci -m 'branch foo'
370 372 $ hg branch default -f
371 373 marked working directory as branch default
372 374 $ hg ci --amend -m 'back to default'
373 375 saved backup bundle to $TESTTMP/.hg/strip-backup/f8339a38efe1-c18453c9-amend.hg
374 376 $ hg branches
375 377 default 2:9c07515f2650
376 378
377 379 Close branch:
378 380
379 381 $ hg up -q 0
380 382 $ echo b >> b
381 383 $ hg branch foo
382 384 marked working directory as branch foo
383 385 (branches are permanent and global, did you want a bookmark?)
384 386 $ hg ci -Am 'fork'
385 387 adding b
386 388 $ echo b >> b
387 389 $ hg ci -mb
388 390 $ hg ci --amend --close-branch -m 'closing branch foo'
389 391 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-54245dc7-amend.hg
390 392
391 393 Same thing, different code path:
392 394
393 395 $ echo b >> b
394 396 $ hg ci -m 'reopen branch'
395 397 reopening closed branch head 4
396 398 $ echo b >> b
397 399 $ hg ci --amend --close-branch
398 400 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-b900d9fa-amend.hg
399 401 $ hg branches
400 402 default 2:9c07515f2650
401 403
402 404 Refuse to amend during a merge:
403 405
404 406 $ hg up -q default
405 407 $ hg merge foo
406 408 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
407 409 (branch merge, don't forget to commit)
408 410 $ hg ci --amend
409 411 abort: cannot amend while merging
410 412 [255]
411 413 $ hg ci -m 'merge'
412 414
413 415 Refuse to amend if there is a merge conflict (issue5805):
414 416
415 417 $ hg up -q foo
416 418 $ echo c > a
417 419 $ hg up default -t :fail
418 420 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
419 421 use 'hg resolve' to retry unresolved file merges
420 422 [1]
421 423 $ hg resolve -l
422 424 U a
423 425
424 426 $ hg ci --amend
425 427 abort: unresolved merge conflicts (see 'hg help resolve')
426 428 [255]
427 429
428 430 $ hg up -qC .
429 431
430 432 Follow copies/renames:
431 433
432 434 $ hg mv b c
433 435 $ hg ci -m 'b -> c'
434 436 $ hg mv c d
435 437 $ hg ci --amend -m 'b -> d'
436 438 saved backup bundle to $TESTTMP/.hg/strip-backup/42f3f27a067d-f23cc9f7-amend.hg
437 439 $ hg st --rev '.^' --copies d
438 440 A d
439 441 b
440 442 $ hg cp d e
441 443 $ hg ci -m 'e = d'
442 444 $ hg cp e f
443 445 $ hg ci --amend -m 'f = d'
444 446 saved backup bundle to $TESTTMP/.hg/strip-backup/9198f73182d5-251d584a-amend.hg
445 447 $ hg st --rev '.^' --copies f
446 448 A f
447 449 d
448 450
449 451 $ mv f f.orig
450 452 $ hg rm -A f
451 453 $ hg ci -m removef
452 454 $ hg cp a f
453 455 $ mv f.orig f
454 456 $ hg ci --amend -m replacef
455 457 saved backup bundle to $TESTTMP/.hg/strip-backup/f0993ab6b482-eda301bf-amend.hg
456 458 $ hg st --change . --copies
457 459 $ hg log -r . --template "{file_copies}\n"
458 460
459 461
460 462 Move added file (issue3410):
461 463
462 464 $ echo g >> g
463 465 $ hg ci -Am g
464 466 adding g
465 467 $ hg mv g h
466 468 $ hg ci --amend
467 469 saved backup bundle to $TESTTMP/.hg/strip-backup/58585e3f095c-0f5ebcda-amend.hg
468 470 $ hg st --change . --copies h
469 471 A h
470 472 $ hg log -r . --template "{file_copies}\n"
471 473
472 474
473 475 Can't rollback an amend:
474 476
475 477 $ hg rollback
476 478 no rollback information available
477 479 [1]
478 480
479 481 Preserve extra dict (issue3430):
480 482
481 483 $ hg branch a
482 484 marked working directory as branch a
483 485 (branches are permanent and global, did you want a bookmark?)
484 486 $ echo a >> a
485 487 $ hg ci -ma
486 488 $ hg ci --amend -m "a'"
487 489 saved backup bundle to $TESTTMP/.hg/strip-backup/39a162f1d65e-9dfe13d8-amend.hg
488 490 $ hg log -r . --template "{branch}\n"
489 491 a
490 492 $ hg ci --amend -m "a''"
491 493 saved backup bundle to $TESTTMP/.hg/strip-backup/d5ca7b1ac72b-0b4c1a34-amend.hg
492 494 $ hg log -r . --template "{branch}\n"
493 495 a
494 496
495 497 Also preserve other entries in the dict that are in the old commit,
496 498 first graft something so there's an additional entry:
497 499
498 500 $ hg up 0 -q
499 501 $ echo z > z
500 502 $ hg ci -Am 'fork'
501 503 adding z
502 504 created new head
503 505 $ hg up 11
504 506 5 files updated, 0 files merged, 1 files removed, 0 files unresolved
505 507 $ hg graft 12
506 508 grafting 12:2647734878ef "fork" (tip)
507 509 $ hg ci --amend -m 'graft amend'
508 510 saved backup bundle to $TESTTMP/.hg/strip-backup/fe8c6f7957ca-25638666-amend.hg
509 511 $ hg log -r . --debug | grep extra
510 512 extra: amend_source=fe8c6f7957ca1665ed77496ed7a07657d469ac60
511 513 extra: branch=a
512 514 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a
513 515
514 516 Preserve phase
515 517
516 518 $ hg phase '.^::.'
517 519 11: draft
518 520 13: draft
519 521 $ hg phase --secret --force .
520 522 $ hg phase '.^::.'
521 523 11: draft
522 524 13: secret
523 525 $ hg commit --amend -m 'amend for phase' -q
524 526 $ hg phase '.^::.'
525 527 11: draft
526 528 13: secret
527 529
528 530 Test amend with obsolete
529 531 ---------------------------
530 532
531 533 Enable obsolete
532 534
533 535 $ cat >> $HGRCPATH << EOF
534 536 > [experimental]
535 537 > evolution.createmarkers=True
536 538 > evolution.allowunstable=True
537 539 > EOF
538 540
539 541 Amend with no files changes
540 542
541 543 $ hg id -n
542 544 13
543 545 $ hg ci --amend -m 'babar'
544 546 $ hg id -n
545 547 14
546 548 $ hg log -Gl 3 --style=compact
547 549 @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test
548 550 | babar
549 551 |
550 552 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
551 553 | | fork
552 554 | ~
553 555 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test
554 556 | a''
555 557 ~
556 558 $ hg log -Gl 4 --hidden --style=compact
557 559 @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test
558 560 | babar
559 561 |
560 562 | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test
561 563 |/ amend for phase
562 564 |
563 565 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
564 566 | | fork
565 567 | ~
566 568 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test
567 569 | a''
568 570 ~
569 571
570 572 Amend with files changes
571 573
572 574 (note: the extra commit over 15 is a temporary junk I would be happy to get
573 575 ride of)
574 576
575 577 $ echo 'babar' >> a
576 578 $ hg commit --amend
577 579 $ hg log -Gl 6 --hidden --style=compact
578 580 @ 15[tip]:11 a5b42b49b0d5 1970-01-01 00:00 +0000 test
579 581 | babar
580 582 |
581 583 | x 14:11 682950e85999 1970-01-01 00:00 +0000 test
582 584 |/ babar
583 585 |
584 586 | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test
585 587 |/ amend for phase
586 588 |
587 589 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
588 590 | | fork
589 591 | ~
590 592 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test
591 593 | a''
592 594 |
593 595 o 10 5fa75032e226 1970-01-01 00:00 +0000 test
594 596 | g
595 597 ~
596 598
597 599
598 600 Test that amend does not make it easy to create obsolescence cycle
599 601 ---------------------------------------------------------------------
600 602
601 603 $ hg id -r 14 --hidden
602 604 682950e85999 (a)
603 605 $ hg revert -ar 14 --hidden
604 606 reverting a
605 607 $ hg commit --amend
606 608 $ hg id
607 609 37973c7e0b61 (a) tip
608 610
609 611 Test that rewriting leaving instability behind is allowed
610 612 ---------------------------------------------------------------------
611 613
612 614 $ hg up '.^'
613 615 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
614 616 $ echo 'b' >> a
615 617 $ hg log --style compact -r 'children(.)'
616 618 16[tip]:11 37973c7e0b61 1970-01-01 00:00 +0000 test
617 619 babar
618 620
619 621 $ hg commit --amend
620 622 1 new orphan changesets
621 623 $ hg log -r 'orphan()'
622 624 changeset: 16:37973c7e0b61
623 625 branch: a
624 626 parent: 11:0ddb275cfad1
625 627 user: test
626 628 date: Thu Jan 01 00:00:00 1970 +0000
627 629 instability: orphan
628 630 summary: babar
629 631
630 632
631 633 Amend a merge changeset (with renames and conflicts from the second parent):
632 634
633 635 $ hg up -q default
634 636 $ hg branch -q bar
635 637 $ hg cp a aa
636 638 $ hg mv z zz
637 639 $ echo cc > cc
638 640 $ hg add cc
639 641 $ hg ci -m aazzcc
640 642 $ hg up -q default
641 643 $ echo a >> a
642 644 $ echo dd > cc
643 645 $ hg add cc
644 646 $ hg ci -m aa
645 647 $ hg merge -q bar
646 648 warning: conflicts while merging cc! (edit, then use 'hg resolve --mark')
647 649 [1]
648 650 $ hg resolve -m cc
649 651 (no more unresolved files)
650 652 $ hg ci -m 'merge bar'
651 653 $ hg log --config diff.git=1 -pr .
652 654 changeset: 20:163cfd7219f7
653 655 tag: tip
654 656 parent: 19:30d96aeaf27b
655 657 parent: 18:1aa437659d19
656 658 user: test
657 659 date: Thu Jan 01 00:00:00 1970 +0000
658 660 summary: merge bar
659 661
660 662 diff --git a/a b/aa
661 663 copy from a
662 664 copy to aa
663 665 diff --git a/cc b/cc
664 666 --- a/cc
665 667 +++ b/cc
666 668 @@ -1,1 +1,5 @@
667 669 +<<<<<<< working copy: 30d96aeaf27b - test: aa
668 670 dd
669 671 +=======
670 672 +cc
671 673 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
672 674 diff --git a/z b/zz
673 675 rename from z
674 676 rename to zz
675 677
676 678 $ hg debugrename aa
677 679 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
678 680 $ hg debugrename zz
679 681 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
680 682 $ hg debugrename cc
681 683 cc not renamed
682 684 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit
683 685 HGEDITFORM=commit.amend.merge
684 686 $ hg log --config diff.git=1 -pr .
685 687 changeset: 21:bca52d4ed186
686 688 tag: tip
687 689 parent: 19:30d96aeaf27b
688 690 parent: 18:1aa437659d19
689 691 user: test
690 692 date: Thu Jan 01 00:00:00 1970 +0000
691 693 summary: merge bar (amend message)
692 694
693 695 diff --git a/a b/aa
694 696 copy from a
695 697 copy to aa
696 698 diff --git a/cc b/cc
697 699 --- a/cc
698 700 +++ b/cc
699 701 @@ -1,1 +1,5 @@
700 702 +<<<<<<< working copy: 30d96aeaf27b - test: aa
701 703 dd
702 704 +=======
703 705 +cc
704 706 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
705 707 diff --git a/z b/zz
706 708 rename from z
707 709 rename to zz
708 710
709 711 $ hg debugrename aa
710 712 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
711 713 $ hg debugrename zz
712 714 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
713 715 $ hg debugrename cc
714 716 cc not renamed
715 717 $ hg mv zz z
716 718 $ hg ci --amend -m 'merge bar (undo rename)'
717 719 $ hg log --config diff.git=1 -pr .
718 720 changeset: 22:12594a98ca3f
719 721 tag: tip
720 722 parent: 19:30d96aeaf27b
721 723 parent: 18:1aa437659d19
722 724 user: test
723 725 date: Thu Jan 01 00:00:00 1970 +0000
724 726 summary: merge bar (undo rename)
725 727
726 728 diff --git a/a b/aa
727 729 copy from a
728 730 copy to aa
729 731 diff --git a/cc b/cc
730 732 --- a/cc
731 733 +++ b/cc
732 734 @@ -1,1 +1,5 @@
733 735 +<<<<<<< working copy: 30d96aeaf27b - test: aa
734 736 dd
735 737 +=======
736 738 +cc
737 739 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
738 740
739 741 $ hg debugrename z
740 742 z not renamed
741 743
742 744 Amend a merge changeset (with renames during the merge):
743 745
744 746 $ hg up -q bar
745 747 $ echo x > x
746 748 $ hg add x
747 749 $ hg ci -m x
748 750 $ hg up -q default
749 751 $ hg merge -q bar
750 752 $ hg mv aa aaa
751 753 $ echo aa >> aaa
752 754 $ hg ci -m 'merge bar again'
753 755 $ hg log --config diff.git=1 -pr .
754 756 changeset: 24:dffde028b388
755 757 tag: tip
756 758 parent: 22:12594a98ca3f
757 759 parent: 23:4c94d5bc65f5
758 760 user: test
759 761 date: Thu Jan 01 00:00:00 1970 +0000
760 762 summary: merge bar again
761 763
762 764 diff --git a/aa b/aa
763 765 deleted file mode 100644
764 766 --- a/aa
765 767 +++ /dev/null
766 768 @@ -1,2 +0,0 @@
767 769 -a
768 770 -a
769 771 diff --git a/aaa b/aaa
770 772 new file mode 100644
771 773 --- /dev/null
772 774 +++ b/aaa
773 775 @@ -0,0 +1,3 @@
774 776 +a
775 777 +a
776 778 +aa
777 779 diff --git a/x b/x
778 780 new file mode 100644
779 781 --- /dev/null
780 782 +++ b/x
781 783 @@ -0,0 +1,1 @@
782 784 +x
783 785
784 786 $ hg debugrename aaa
785 787 aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980
786 788 $ hg mv aaa aa
787 789 $ hg ci --amend -m 'merge bar again (undo rename)'
788 790 $ hg log --config diff.git=1 -pr .
789 791 changeset: 25:18e3ba160489
790 792 tag: tip
791 793 parent: 22:12594a98ca3f
792 794 parent: 23:4c94d5bc65f5
793 795 user: test
794 796 date: Thu Jan 01 00:00:00 1970 +0000
795 797 summary: merge bar again (undo rename)
796 798
797 799 diff --git a/aa b/aa
798 800 --- a/aa
799 801 +++ b/aa
800 802 @@ -1,2 +1,3 @@
801 803 a
802 804 a
803 805 +aa
804 806 diff --git a/x b/x
805 807 new file mode 100644
806 808 --- /dev/null
807 809 +++ b/x
808 810 @@ -0,0 +1,1 @@
809 811 +x
810 812
811 813 $ hg debugrename aa
812 814 aa not renamed
813 815 $ hg debugrename -r '.^' aa
814 816 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
815 817
816 818 Amend a merge changeset (with manifest-level conflicts):
817 819
818 820 $ hg up -q bar
819 821 $ hg rm aa
820 822 $ hg ci -m 'rm aa'
821 823 $ hg up -q default
822 824 $ echo aa >> aa
823 825 $ hg ci -m aa
824 826 $ hg merge -q bar --config ui.interactive=True << EOF
825 827 > c
826 828 > EOF
827 829 local [working copy] changed aa which other [merge rev] deleted
828 830 use (c)hanged version, (d)elete, or leave (u)nresolved? c
829 831 $ hg ci -m 'merge bar (with conflicts)'
830 832 $ hg log --config diff.git=1 -pr .
831 833 changeset: 28:b4c3035e2544
832 834 tag: tip
833 835 parent: 27:4b216ca5ba97
834 836 parent: 26:67db8847a540
835 837 user: test
836 838 date: Thu Jan 01 00:00:00 1970 +0000
837 839 summary: merge bar (with conflicts)
838 840
839 841
840 842 $ hg rm aa
841 843 $ hg ci --amend -m 'merge bar (with conflicts, amended)'
842 844 $ hg log --config diff.git=1 -pr .
843 845 changeset: 29:1205ed810051
844 846 tag: tip
845 847 parent: 27:4b216ca5ba97
846 848 parent: 26:67db8847a540
847 849 user: test
848 850 date: Thu Jan 01 00:00:00 1970 +0000
849 851 summary: merge bar (with conflicts, amended)
850 852
851 853 diff --git a/aa b/aa
852 854 deleted file mode 100644
853 855 --- a/aa
854 856 +++ /dev/null
855 857 @@ -1,4 +0,0 @@
856 858 -a
857 859 -a
858 860 -aa
859 861 -aa
860 862
861 863 Issue 3445: amending with --close-branch a commit that created a new head should fail
862 864 This shouldn't be possible:
863 865
864 866 $ hg up -q default
865 867 $ hg branch closewithamend
866 868 marked working directory as branch closewithamend
867 869 $ echo foo > foo
868 870 $ hg add foo
869 871 $ hg ci -m..
870 872 $ hg ci --amend --close-branch -m 'closing'
871 873 abort: can only close branch heads
872 874 [255]
873 875
874 876 This silliness fails:
875 877
876 878 $ hg branch silliness
877 879 marked working directory as branch silliness
878 880 $ echo b >> b
879 881 $ hg ci --close-branch -m'open and close'
880 882 abort: can only close branch heads
881 883 [255]
882 884
883 885 Test that amend with --secret creates new secret changeset forcibly
884 886 ---------------------------------------------------------------------
885 887
886 888 $ hg phase '.^::.'
887 889 29: draft
888 890 30: draft
889 891 $ hg commit --amend --secret -m 'amend as secret' -q
890 892 $ hg phase '.^::.'
891 893 29: draft
892 894 31: secret
893 895
894 896 Test that amend with --edit invokes editor forcibly
895 897 ---------------------------------------------------
896 898
897 899 $ hg parents --template "{desc}\n"
898 900 amend as secret
899 901 $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
900 902 $ hg parents --template "{desc}\n"
901 903 editor should be suppressed
902 904
903 905 $ hg status --rev '.^1::.'
904 906 A foo
905 907 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
906 908 editor should be invoked
907 909
908 910
909 911 HG: Enter commit message. Lines beginning with 'HG:' are removed.
910 912 HG: Leave message empty to abort commit.
911 913 HG: --
912 914 HG: user: test
913 915 HG: branch 'silliness'
914 916 HG: added foo
915 917 $ hg parents --template "{desc}\n"
916 918 editor should be invoked
917 919
918 920 Test that "diff()" in committemplate works correctly for amending
919 921 -----------------------------------------------------------------
920 922
921 923 $ cat >> .hg/hgrc <<EOF
922 924 > [committemplate]
923 925 > changeset.commit.amend = {desc}\n
924 926 > HG: M: {file_mods}
925 927 > HG: A: {file_adds}
926 928 > HG: R: {file_dels}
927 929 > {splitlines(diff()) % 'HG: {line}\n'}
928 930 > EOF
929 931
930 932 $ hg parents --template "M: {file_mods}\nA: {file_adds}\nR: {file_dels}\n"
931 933 M:
932 934 A: foo
933 935 R:
934 936 $ hg status -amr
935 937 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo"
936 938 expecting diff of foo
937 939
938 940 HG: M:
939 941 HG: A: foo
940 942 HG: R:
941 943 HG: diff -r 1205ed810051 foo
942 944 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
943 945 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
944 946 HG: @@ -0,0 +1,1 @@
945 947 HG: +foo
946 948
947 949 $ echo y > y
948 950 $ hg add y
949 951 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo and y"
950 952 expecting diff of foo and y
951 953
952 954 HG: M:
953 955 HG: A: foo y
954 956 HG: R:
955 957 HG: diff -r 1205ed810051 foo
956 958 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
957 959 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
958 960 HG: @@ -0,0 +1,1 @@
959 961 HG: +foo
960 962 HG: diff -r 1205ed810051 y
961 963 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
962 964 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
963 965 HG: @@ -0,0 +1,1 @@
964 966 HG: +y
965 967
966 968 $ hg rm a
967 969 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y"
968 970 expecting diff of a, foo and y
969 971
970 972 HG: M:
971 973 HG: A: foo y
972 974 HG: R: a
973 975 HG: diff -r 1205ed810051 a
974 976 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
975 977 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
976 978 HG: @@ -1,2 +0,0 @@
977 979 HG: -a
978 980 HG: -a
979 981 HG: diff -r 1205ed810051 foo
980 982 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
981 983 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
982 984 HG: @@ -0,0 +1,1 @@
983 985 HG: +foo
984 986 HG: diff -r 1205ed810051 y
985 987 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
986 988 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
987 989 HG: @@ -0,0 +1,1 @@
988 990 HG: +y
989 991
990 992 $ hg rm x
991 993 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y"
992 994 expecting diff of a, foo, x and y
993 995
994 996 HG: M:
995 997 HG: A: foo y
996 998 HG: R: a x
997 999 HG: diff -r 1205ed810051 a
998 1000 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
999 1001 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1000 1002 HG: @@ -1,2 +0,0 @@
1001 1003 HG: -a
1002 1004 HG: -a
1003 1005 HG: diff -r 1205ed810051 foo
1004 1006 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1005 1007 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
1006 1008 HG: @@ -0,0 +1,1 @@
1007 1009 HG: +foo
1008 1010 HG: diff -r 1205ed810051 x
1009 1011 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
1010 1012 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1011 1013 HG: @@ -1,1 +0,0 @@
1012 1014 HG: -x
1013 1015 HG: diff -r 1205ed810051 y
1014 1016 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1015 1017 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1016 1018 HG: @@ -0,0 +1,1 @@
1017 1019 HG: +y
1018 1020
1019 1021 $ echo cccc >> cc
1020 1022 $ hg status -amr
1021 1023 M cc
1022 1024 $ HGEDITOR=cat hg commit --amend -e -m "cc should be excluded" -X cc
1023 1025 cc should be excluded
1024 1026
1025 1027 HG: M:
1026 1028 HG: A: foo y
1027 1029 HG: R: a x
1028 1030 HG: diff -r 1205ed810051 a
1029 1031 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
1030 1032 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1031 1033 HG: @@ -1,2 +0,0 @@
1032 1034 HG: -a
1033 1035 HG: -a
1034 1036 HG: diff -r 1205ed810051 foo
1035 1037 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1036 1038 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
1037 1039 HG: @@ -0,0 +1,1 @@
1038 1040 HG: +foo
1039 1041 HG: diff -r 1205ed810051 x
1040 1042 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
1041 1043 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1042 1044 HG: @@ -1,1 +0,0 @@
1043 1045 HG: -x
1044 1046 HG: diff -r 1205ed810051 y
1045 1047 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1046 1048 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1047 1049 HG: @@ -0,0 +1,1 @@
1048 1050 HG: +y
1049 1051
1050 1052 Check for issue4405
1051 1053 -------------------
1052 1054
1053 1055 Setup the repo with a file that gets moved in a second commit.
1054 1056 $ hg init repo
1055 1057 $ cd repo
1056 1058 $ touch a0
1057 1059 $ hg add a0
1058 1060 $ hg commit -m a0
1059 1061 $ hg mv a0 a1
1060 1062 $ hg commit -m a1
1061 1063 $ hg up -q 0
1062 1064 $ hg log -G --template '{rev} {desc}'
1063 1065 o 1 a1
1064 1066 |
1065 1067 @ 0 a0
1066 1068
1067 1069
1068 1070 Now we branch the repro, but re-use the file contents, so we have a divergence
1069 1071 in the file revlog topology and the changelog topology.
1070 1072 $ hg revert --rev 1 --all
1071 1073 removing a0
1072 1074 adding a1
1073 1075 $ hg ci -qm 'a1-amend'
1074 1076 $ hg log -G --template '{rev} {desc}'
1075 1077 @ 2 a1-amend
1076 1078 |
1077 1079 | o 1 a1
1078 1080 |/
1079 1081 o 0 a0
1080 1082
1081 1083
1082 1084 The way mercurial does amends is by folding the working copy and old commit
1083 1085 together into another commit (rev 3). During this process, _findlimit is called
1084 1086 to check how far back to look for the transitive closure of file copy
1085 1087 information, but due to the divergence of the filelog and changelog graph
1086 1088 topologies, before _findlimit was fixed, it returned a rev which was not far
1087 1089 enough back in this case.
1088 1090 $ hg mv a1 a2
1089 1091 $ hg status --copies --rev 0
1090 1092 A a2
1091 1093 a0
1092 1094 R a0
1093 1095 $ hg ci --amend -q
1094 1096 $ hg log -G --template '{rev} {desc}'
1095 1097 @ 3 a1-amend
1096 1098 |
1097 1099 | o 1 a1
1098 1100 |/
1099 1101 o 0 a0
1100 1102
1101 1103
1102 1104 Before the fix, the copy information was lost.
1103 1105 $ hg status --copies --rev 0
1104 1106 A a2
1105 1107 a0
1106 1108 R a0
1107 1109 $ cd ..
1108 1110
1109 1111 Check that amend properly preserve rename from directory rename (issue-4516)
1110 1112
1111 1113 If a parent of the merge renames a full directory, any files added to the old
1112 1114 directory in the other parent will be renamed to the new directory. For some
1113 1115 reason, the rename metadata was when amending such merge. This test ensure we
1114 1116 do not regress. We have a dedicated repo because it needs a setup with renamed
1115 1117 directory)
1116 1118
1117 1119 $ hg init issue4516
1118 1120 $ cd issue4516
1119 1121 $ mkdir olddirname
1120 1122 $ echo line1 > olddirname/commonfile.py
1121 1123 $ hg add olddirname/commonfile.py
1122 1124 $ hg ci -m first
1123 1125
1124 1126 $ hg branch newdirname
1125 1127 marked working directory as branch newdirname
1126 1128 (branches are permanent and global, did you want a bookmark?)
1127 1129 $ hg mv olddirname newdirname
1128 1130 moving olddirname/commonfile.py to newdirname/commonfile.py
1129 1131 $ hg ci -m rename
1130 1132
1131 1133 $ hg update default
1132 1134 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1133 1135 $ echo line1 > olddirname/newfile.py
1134 1136 $ hg add olddirname/newfile.py
1135 1137 $ hg ci -m log
1136 1138
1137 1139 $ hg up newdirname
1138 1140 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
1139 1141 $ # create newdirname/newfile.py
1140 1142 $ hg merge default
1141 1143 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1142 1144 (branch merge, don't forget to commit)
1143 1145 $ hg ci -m add
1144 1146 $
1145 1147 $ hg debugrename newdirname/newfile.py
1146 1148 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def
1147 1149 $ hg status -C --change .
1148 1150 A newdirname/newfile.py
1149 1151 $ hg status -C --rev 1
1150 1152 A newdirname/newfile.py
1151 1153 $ hg status -C --rev 2
1152 1154 A newdirname/commonfile.py
1153 1155 olddirname/commonfile.py
1154 1156 A newdirname/newfile.py
1155 1157 olddirname/newfile.py
1156 1158 R olddirname/commonfile.py
1157 1159 R olddirname/newfile.py
1158 1160 $ hg debugindex newdirname/newfile.py
1159 1161 rev linkrev nodeid p1 p2
1160 1162 0 3 34a4d536c0c0 000000000000 000000000000
1161 1163
1162 1164 $ echo a >> newdirname/commonfile.py
1163 1165 $ hg ci --amend -m bug
1164 1166 $ hg debugrename newdirname/newfile.py
1165 1167 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def
1166 1168 $ hg debugindex newdirname/newfile.py
1167 1169 rev linkrev nodeid p1 p2
1168 1170 0 3 34a4d536c0c0 000000000000 000000000000
1169 1171
1170 1172 #if execbit
1171 1173
1172 1174 Test if amend preserves executable bit changes
1173 1175 $ chmod +x newdirname/commonfile.py
1174 1176 $ hg ci -m chmod
1175 1177 $ hg ci --amend -m "chmod amended"
1176 1178 $ hg ci --amend -m "chmod amended second time"
1177 1179 $ hg log -p --git -r .
1178 1180 changeset: 7:b1326f52dddf
1179 1181 branch: newdirname
1180 1182 tag: tip
1181 1183 parent: 4:7fd235f7cb2f
1182 1184 user: test
1183 1185 date: Thu Jan 01 00:00:00 1970 +0000
1184 1186 summary: chmod amended second time
1185 1187
1186 1188 diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py
1187 1189 old mode 100644
1188 1190 new mode 100755
1189 1191
1190 1192 #endif
1191 1193
1192 1194 Test amend with file inclusion options
1193 1195 --------------------------------------
1194 1196
1195 1197 These tests ensure that we are always amending some files that were part of the
1196 1198 pre-amend commit. We want to test that the remaining files in the pre-amend
1197 1199 commit were not changed in the amended commit. We do so by performing a diff of
1198 1200 the amended commit against its parent commit.
1199 1201 $ cd ..
1200 1202 $ hg init testfileinclusions
1201 1203 $ cd testfileinclusions
1202 1204 $ echo a > a
1203 1205 $ echo b > b
1204 1206 $ hg commit -Aqm "Adding a and b"
1205 1207
1206 1208 Only add changes to a particular file
1207 1209 $ echo a >> a
1208 1210 $ echo b >> b
1209 1211 $ hg commit --amend -I a
1210 1212 $ hg diff --git -r null -r .
1211 1213 diff --git a/a b/a
1212 1214 new file mode 100644
1213 1215 --- /dev/null
1214 1216 +++ b/a
1215 1217 @@ -0,0 +1,2 @@
1216 1218 +a
1217 1219 +a
1218 1220 diff --git a/b b/b
1219 1221 new file mode 100644
1220 1222 --- /dev/null
1221 1223 +++ b/b
1222 1224 @@ -0,0 +1,1 @@
1223 1225 +b
1224 1226
1225 1227 $ echo a >> a
1226 1228 $ hg commit --amend b
1227 1229 $ hg diff --git -r null -r .
1228 1230 diff --git a/a b/a
1229 1231 new file mode 100644
1230 1232 --- /dev/null
1231 1233 +++ b/a
1232 1234 @@ -0,0 +1,2 @@
1233 1235 +a
1234 1236 +a
1235 1237 diff --git a/b b/b
1236 1238 new file mode 100644
1237 1239 --- /dev/null
1238 1240 +++ b/b
1239 1241 @@ -0,0 +1,2 @@
1240 1242 +b
1241 1243 +b
1242 1244
1243 1245 Exclude changes to a particular file
1244 1246 $ echo b >> b
1245 1247 $ hg commit --amend -X a
1246 1248 $ hg diff --git -r null -r .
1247 1249 diff --git a/a b/a
1248 1250 new file mode 100644
1249 1251 --- /dev/null
1250 1252 +++ b/a
1251 1253 @@ -0,0 +1,2 @@
1252 1254 +a
1253 1255 +a
1254 1256 diff --git a/b b/b
1255 1257 new file mode 100644
1256 1258 --- /dev/null
1257 1259 +++ b/b
1258 1260 @@ -0,0 +1,3 @@
1259 1261 +b
1260 1262 +b
1261 1263 +b
1262 1264
1263 1265 Check the addremove flag
1264 1266 $ echo c > c
1265 1267 $ rm a
1266 1268 $ hg commit --amend -A
1267 1269 removing a
1268 1270 adding c
1269 1271 $ hg diff --git -r null -r .
1270 1272 diff --git a/b b/b
1271 1273 new file mode 100644
1272 1274 --- /dev/null
1273 1275 +++ b/b
1274 1276 @@ -0,0 +1,3 @@
1275 1277 +b
1276 1278 +b
1277 1279 +b
1278 1280 diff --git a/c b/c
1279 1281 new file mode 100644
1280 1282 --- /dev/null
1281 1283 +++ b/c
1282 1284 @@ -0,0 +1,1 @@
1283 1285 +c
@@ -1,597 +1,599
1 1 Test histedit extension: Fold commands
2 2 ======================================
3 3
4 4 This test file is dedicated to testing the fold command in non conflicting
5 5 case.
6 6
7 7 Initialization
8 8 ---------------
9 9
10 10
11 11 $ . "$TESTDIR/histedit-helpers.sh"
12 12
13 13 $ cat >> $HGRCPATH <<EOF
14 14 > [alias]
15 15 > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
16 16 > [extensions]
17 17 > histedit=
18 18 > EOF
19 19
20 20
21 21 Simple folding
22 22 --------------------
23 23 $ addwithdate ()
24 24 > {
25 25 > echo $1 > $1
26 26 > hg add $1
27 27 > hg ci -m $1 -d "$2 0"
28 28 > }
29 29
30 30 $ initrepo ()
31 31 > {
32 32 > hg init r
33 33 > cd r
34 34 > addwithdate a 1
35 35 > addwithdate b 2
36 36 > addwithdate c 3
37 37 > addwithdate d 4
38 38 > addwithdate e 5
39 39 > addwithdate f 6
40 40 > }
41 41
42 42 $ initrepo
43 43
44 44 log before edit
45 45 $ hg logt --graph
46 46 @ 5:178e35e0ce73 f
47 47 |
48 48 o 4:1ddb6c90f2ee e
49 49 |
50 50 o 3:532247a8969b d
51 51 |
52 52 o 2:ff2c9fa2018b c
53 53 |
54 54 o 1:97d72e5f12c7 b
55 55 |
56 56 o 0:8580ff50825a a
57 57
58 58
59 59 $ hg histedit ff2c9fa2018b --commands - 2>&1 <<EOF | fixbundle
60 60 > pick 1ddb6c90f2ee e
61 61 > pick 178e35e0ce73 f
62 62 > fold ff2c9fa2018b c
63 63 > pick 532247a8969b d
64 64 > EOF
65 65
66 66 log after edit
67 67 $ hg logt --graph
68 68 @ 4:c4d7f3def76d d
69 69 |
70 70 o 3:575228819b7e f
71 71 |
72 72 o 2:505a591af19e e
73 73 |
74 74 o 1:97d72e5f12c7 b
75 75 |
76 76 o 0:8580ff50825a a
77 77
78 78
79 79 post-fold manifest
80 80 $ hg manifest
81 81 a
82 82 b
83 83 c
84 84 d
85 85 e
86 86 f
87 87
88 88
89 89 check histedit_source, including that it uses the later date, from the first changeset
90 90
91 91 $ hg log --debug --rev 3
92 92 changeset: 3:575228819b7e6ed69e8c0a6a383ee59a80db7358
93 93 phase: draft
94 94 parent: 2:505a591af19eed18f560af827b9e03d2076773dc
95 95 parent: -1:0000000000000000000000000000000000000000
96 96 manifest: 3:81eede616954057198ead0b2c73b41d1f392829a
97 97 user: test
98 98 date: Thu Jan 01 00:00:06 1970 +0000
99 99 files+: c f
100 100 extra: branch=default
101 101 extra: histedit_source=7cad1d7030207872dfd1c3a7cb430f24f2884086,ff2c9fa2018b15fa74b33363bda9527323e2a99f
102 102 description:
103 103 f
104 104 ***
105 105 c
106 106
107 107
108 108
109 109 rollup will fold without preserving the folded commit's message or date
110 110
111 111 $ OLDHGEDITOR=$HGEDITOR
112 112 $ HGEDITOR=false
113 113 $ hg histedit 97d72e5f12c7 --commands - 2>&1 <<EOF | fixbundle
114 114 > pick 97d72e5f12c7 b
115 115 > roll 505a591af19e e
116 116 > pick 575228819b7e f
117 117 > pick c4d7f3def76d d
118 118 > EOF
119 119
120 120 $ HGEDITOR=$OLDHGEDITOR
121 121
122 122 log after edit
123 123 $ hg logt --graph
124 124 @ 3:bab801520cec d
125 125 |
126 126 o 2:58c8f2bfc151 f
127 127 |
128 128 o 1:5d939c56c72e b
129 129 |
130 130 o 0:8580ff50825a a
131 131
132 132
133 133 description is taken from rollup target commit
134 134
135 135 $ hg log --debug --rev 1
136 136 changeset: 1:5d939c56c72e77e29f5167696218e2131a40f5cf
137 137 phase: draft
138 138 parent: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab
139 139 parent: -1:0000000000000000000000000000000000000000
140 140 manifest: 1:b5e112a3a8354e269b1524729f0918662d847c38
141 141 user: test
142 142 date: Thu Jan 01 00:00:02 1970 +0000
143 143 files+: b e
144 144 extra: branch=default
145 145 extra: histedit_source=97d72e5f12c7e84f85064aa72e5a297142c36ed9,505a591af19eed18f560af827b9e03d2076773dc
146 146 description:
147 147 b
148 148
149 149
150 150
151 151 check saving last-message.txt
152 152
153 153 $ cat > $TESTTMP/abortfolding.py <<EOF
154 154 > from mercurial import util
155 155 > def abortfolding(ui, repo, hooktype, **kwargs):
156 156 > ctx = repo[kwargs.get('node')]
157 157 > if set(ctx.files()) == {b'c', b'd', b'f'}:
158 158 > return True # abort folding commit only
159 159 > ui.warn(b'allow non-folding commit\\n')
160 160 > EOF
161 161 $ cat > .hg/hgrc <<EOF
162 162 > [hooks]
163 163 > pretxncommit.abortfolding = python:$TESTTMP/abortfolding.py:abortfolding
164 164 > EOF
165 165
166 166 $ cat > $TESTTMP/editor.sh << EOF
167 167 > echo "==== before editing"
168 168 > cat \$1
169 169 > echo "===="
170 170 > echo "check saving last-message.txt" >> \$1
171 171 > EOF
172 172
173 173 $ rm -f .hg/last-message.txt
174 174 $ hg status --rev '58c8f2bfc151^1::bab801520cec'
175 175 A c
176 176 A d
177 177 A f
178 178 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 58c8f2bfc151 --commands - 2>&1 <<EOF
179 179 > pick 58c8f2bfc151 f
180 180 > fold bab801520cec d
181 181 > EOF
182 182 allow non-folding commit
183 183 ==== before editing
184 184 f
185 185 ***
186 186 c
187 187 ***
188 188 d
189 189
190 190
191 191
192 192 HG: Enter commit message. Lines beginning with 'HG:' are removed.
193 193 HG: Leave message empty to abort commit.
194 194 HG: --
195 195 HG: user: test
196 196 HG: branch 'default'
197 197 HG: added c
198 198 HG: added d
199 199 HG: added f
200 200 ====
201 201 transaction abort!
202 202 rollback completed
203 203 abort: pretxncommit.abortfolding hook failed
204 204 [255]
205 205
206 206 $ cat .hg/last-message.txt
207 207 f
208 208 ***
209 209 c
210 210 ***
211 211 d
212 212
213 213
214 214
215 215 check saving last-message.txt
216 216
217 217 $ cd ..
218 218 $ rm -r r
219 219
220 220 folding preserves initial author but uses later date
221 221 ----------------------------------------------------
222 222
223 223 $ initrepo
224 224
225 225 $ hg ci -d '7 0' --user "someone else" --amend --quiet
226 226
227 227 tip before edit
228 228 $ hg log --rev .
229 229 changeset: 5:10c36dd37515
230 230 tag: tip
231 231 user: someone else
232 232 date: Thu Jan 01 00:00:07 1970 +0000
233 233 summary: f
234 234
235 235
236 236 $ hg --config progress.debug=1 --debug \
237 237 > histedit 1ddb6c90f2ee --commands - 2>&1 <<EOF | \
238 238 > egrep 'editing|unresolved'
239 239 > pick 1ddb6c90f2ee e
240 240 > fold 10c36dd37515 f
241 241 > EOF
242 242 editing: pick 1ddb6c90f2ee 4 e 1/2 changes (50.00%)
243 243 editing: fold 10c36dd37515 5 f 2/2 changes (100.00%)
244 244
245 245 tip after edit, which should use the later date, from the second changeset
246 246 $ hg log --rev .
247 247 changeset: 4:e4f3ec5d0b40
248 248 tag: tip
249 249 user: test
250 250 date: Thu Jan 01 00:00:07 1970 +0000
251 251 summary: e
252 252
253 253
254 254 $ cd ..
255 255 $ rm -r r
256 256
257 257 folding and creating no new change doesn't break:
258 258 -------------------------------------------------
259 259
260 260 folded content is dropped during a merge. The folded commit should properly disappear.
261 261
262 262 $ mkdir fold-to-empty-test
263 263 $ cd fold-to-empty-test
264 264 $ hg init
265 265 $ printf "1\n2\n3\n" > file
266 266 $ hg add file
267 267 $ hg commit -m '1+2+3'
268 268 $ echo 4 >> file
269 269 $ hg commit -m '+4'
270 270 $ echo 5 >> file
271 271 $ hg commit -m '+5'
272 272 $ echo 6 >> file
273 273 $ hg commit -m '+6'
274 274 $ hg logt --graph
275 275 @ 3:251d831eeec5 +6
276 276 |
277 277 o 2:888f9082bf99 +5
278 278 |
279 279 o 1:617f94f13c0f +4
280 280 |
281 281 o 0:0189ba417d34 1+2+3
282 282
283 283
284 284 $ hg histedit 1 --commands - << EOF
285 285 > pick 617f94f13c0f 1 +4
286 286 > drop 888f9082bf99 2 +5
287 287 > fold 251d831eeec5 3 +6
288 288 > EOF
289 289 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
290 290 merging file
291 291 warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
292 292 Fix up the change (fold 251d831eeec5)
293 293 (hg histedit --continue to resume)
294 294 [1]
295 295 There were conflicts, we keep P1 content. This
296 296 should effectively drop the changes from +6.
297 297
298 298 $ hg status -v
299 299 M file
300 300 ? file.orig
301 301 # The repository is in an unfinished *histedit* state.
302 302
303 303 # Unresolved merge conflicts:
304 304 #
305 305 # file
306 306 #
307 307 # To mark files as resolved: hg resolve --mark FILE
308 308
309 309 # To continue: hg histedit --continue
310 310 # To abort: hg histedit --abort
311 311
312 312 $ hg resolve -l
313 313 U file
314 314 $ hg revert -r 'p1()' file
315 315 $ hg resolve --mark file
316 316 (no more unresolved files)
317 317 continue: hg histedit --continue
318 318 $ hg histedit --continue
319 319 251d831eeec5: empty changeset
320 320 saved backup bundle to $TESTTMP/fold-to-empty-test/.hg/strip-backup/888f9082bf99-daa0b8b3-histedit.hg
321 321 $ hg logt --graph
322 322 @ 1:617f94f13c0f +4
323 323 |
324 324 o 0:0189ba417d34 1+2+3
325 325
326 326
327 327 $ cd ..
328 328
329 329
330 330 Test fold through dropped
331 331 -------------------------
332 332
333 333
334 334 Test corner case where folded revision is separated from its parent by a
335 335 dropped revision.
336 336
337 337
338 338 $ hg init fold-with-dropped
339 339 $ cd fold-with-dropped
340 340 $ printf "1\n2\n3\n" > file
341 341 $ hg commit -Am '1+2+3'
342 342 adding file
343 343 $ echo 4 >> file
344 344 $ hg commit -m '+4'
345 345 $ echo 5 >> file
346 346 $ hg commit -m '+5'
347 347 $ echo 6 >> file
348 348 $ hg commit -m '+6'
349 349 $ hg logt -G
350 350 @ 3:251d831eeec5 +6
351 351 |
352 352 o 2:888f9082bf99 +5
353 353 |
354 354 o 1:617f94f13c0f +4
355 355 |
356 356 o 0:0189ba417d34 1+2+3
357 357
358 358 $ hg histedit 1 --commands - << EOF
359 359 > pick 617f94f13c0f 1 +4
360 360 > drop 888f9082bf99 2 +5
361 361 > fold 251d831eeec5 3 +6
362 362 > EOF
363 363 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
364 364 merging file
365 365 warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
366 366 Fix up the change (fold 251d831eeec5)
367 367 (hg histedit --continue to resume)
368 368 [1]
369 369 $ cat > file << EOF
370 370 > 1
371 371 > 2
372 372 > 3
373 373 > 4
374 374 > 5
375 375 > EOF
376 376 $ hg resolve --mark file
377 377 (no more unresolved files)
378 378 continue: hg histedit --continue
379 379 $ hg commit -m '+5.2'
380 380 created new head
381 381 $ echo 6 >> file
382 382 $ HGEDITOR=cat hg histedit --continue
383 383 +4
384 384 ***
385 385 +5.2
386 386 ***
387 387 +6
388 388
389 389
390 390
391 391 HG: Enter commit message. Lines beginning with 'HG:' are removed.
392 392 HG: Leave message empty to abort commit.
393 393 HG: --
394 394 HG: user: test
395 395 HG: branch 'default'
396 396 HG: changed file
397 397 saved backup bundle to $TESTTMP/fold-with-dropped/.hg/strip-backup/617f94f13c0f-3d69522c-histedit.hg
398 398 $ hg logt -G
399 399 @ 1:10c647b2cdd5 +4
400 400 |
401 401 o 0:0189ba417d34 1+2+3
402 402
403 403 $ hg export tip
404 404 # HG changeset patch
405 405 # User test
406 406 # Date 0 0
407 407 # Thu Jan 01 00:00:00 1970 +0000
408 408 # Node ID 10c647b2cdd54db0603ecb99b2ff5ce66d5a5323
409 409 # Parent 0189ba417d34df9dda55f88b637dcae9917b5964
410 410 +4
411 411 ***
412 412 +5.2
413 413 ***
414 414 +6
415 415
416 416 diff -r 0189ba417d34 -r 10c647b2cdd5 file
417 417 --- a/file Thu Jan 01 00:00:00 1970 +0000
418 418 +++ b/file Thu Jan 01 00:00:00 1970 +0000
419 419 @@ -1,3 +1,6 @@
420 420 1
421 421 2
422 422 3
423 423 +4
424 424 +5
425 425 +6
426 426 $ cd ..
427 427
428 428
429 429 Folding with initial rename (issue3729)
430 430 ---------------------------------------
431 431
432 432 $ hg init fold-rename
433 433 $ cd fold-rename
434 434 $ echo a > a.txt
435 435 $ hg add a.txt
436 436 $ hg commit -m a
437 437 $ hg rename a.txt b.txt
438 438 $ hg commit -m rename
439 439 $ echo b >> b.txt
440 440 $ hg commit -m b
441 441
442 442 $ hg logt --follow b.txt
443 443 2:e0371e0426bc b
444 444 1:1c4f440a8085 rename
445 445 0:6c795aa153cb a
446 446
447 447 $ hg histedit 1c4f440a8085 --commands - 2>&1 << EOF | fixbundle
448 448 > pick 1c4f440a8085 rename
449 449 > fold e0371e0426bc b
450 450 > EOF
451 451
452 452 $ hg logt --follow b.txt
453 453 1:cf858d235c76 rename
454 454 0:6c795aa153cb a
455 455
456 456 $ cd ..
457 457
458 458 Folding with swapping
459 459 ---------------------
460 460
461 461 This is an excuse to test hook with histedit temporary commit (issue4422)
462 462
463 463
464 464 $ hg init issue4422
465 465 $ cd issue4422
466 466 $ echo a > a.txt
467 467 $ hg add a.txt
468 468 $ hg commit -m a
469 469 $ echo b > b.txt
470 470 $ hg add b.txt
471 471 $ hg commit -m b
472 472 $ echo c > c.txt
473 473 $ hg add c.txt
474 474 $ hg commit -m c
475 475
476 476 $ hg logt
477 477 2:a1a953ffb4b0 c
478 478 1:199b6bb90248 b
479 479 0:6c795aa153cb a
480 480
481 481 $ hg histedit 6c795aa153cb --config hooks.commit='echo commit $HG_NODE' --commands - 2>&1 << EOF | fixbundle
482 482 > pick 199b6bb90248 b
483 483 > fold a1a953ffb4b0 c
484 484 > pick 6c795aa153cb a
485 485 > EOF
486 486 commit 9599899f62c05f4377548c32bf1c9f1a39634b0c
487 487
488 488 $ hg logt
489 489 1:9599899f62c0 a
490 490 0:79b99e9c8e49 b
491 491
492 492 Test unix -> windows style variable substitution in external hooks.
493 493
494 494 $ cat > $TESTTMP/tmp.hgrc <<'EOF'
495 495 > [hooks]
496 496 > pre-add = echo no variables
497 > tonative.pre-add = False
497 498 > post-add = echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT
498 499 > EOF
499 500
500 501 TODO: Windows should output double quotes around "also $non-var"
501 502 $ echo "foo" > amended.txt
502 503 $ HGRCPATH=$TESTTMP/tmp.hgrc hg add -v amended.txt
503 504 running hook pre-add: echo no variables
504 505 no variables
505 506 adding amended.txt
507 converting hook "post-add" to native (windows !)
506 508 running hook post-add: echo ran %HG_ARGS%, literal $non-var, 'also $non-var', %HG_RESULT% (windows !)
507 509 running hook post-add: echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT (no-windows !)
508 510 ran add -v amended.txt, literal $non-var, 'also $non-var', 0 (windows !)
509 511 ran add -v amended.txt, literal $non-var, also $non-var, 0 (no-windows !)
510 512 $ hg ci -q --config extensions.largefiles= --amend -I amended.txt
511 513 The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !)
512 514
513 515 Test that folding multiple changes in a row doesn't show multiple
514 516 editors.
515 517
516 518 $ echo foo >> foo
517 519 $ hg add foo
518 520 $ hg ci -m foo1
519 521 $ echo foo >> foo
520 522 $ hg ci -m foo2
521 523 $ echo foo >> foo
522 524 $ hg ci -m foo3
523 525 $ hg logt
524 526 4:21679ff7675c foo3
525 527 3:b7389cc4d66e foo2
526 528 2:0e01aeef5fa8 foo1
527 529 1:578c7455730c a
528 530 0:79b99e9c8e49 b
529 531 $ cat > "$TESTTMP/editor.sh" <<EOF
530 532 > echo ran editor >> "$TESTTMP/editorlog.txt"
531 533 > cat \$1 >> "$TESTTMP/editorlog.txt"
532 534 > echo END >> "$TESTTMP/editorlog.txt"
533 535 > echo merged foos > \$1
534 536 > EOF
535 537 $ HGEDITOR="sh \"$TESTTMP/editor.sh\"" hg histedit 1 --commands - 2>&1 <<EOF | fixbundle
536 538 > pick 578c7455730c 1 a
537 539 > pick 0e01aeef5fa8 2 foo1
538 540 > fold b7389cc4d66e 3 foo2
539 541 > fold 21679ff7675c 4 foo3
540 542 > EOF
541 543 $ hg logt
542 544 2:e8bedbda72c1 merged foos
543 545 1:578c7455730c a
544 546 0:79b99e9c8e49 b
545 547 Editor should have run only once
546 548 $ cat $TESTTMP/editorlog.txt
547 549 ran editor
548 550 foo1
549 551 ***
550 552 foo2
551 553 ***
552 554 foo3
553 555
554 556
555 557
556 558 HG: Enter commit message. Lines beginning with 'HG:' are removed.
557 559 HG: Leave message empty to abort commit.
558 560 HG: --
559 561 HG: user: test
560 562 HG: branch 'default'
561 563 HG: added foo
562 564 END
563 565
564 566 $ cd ..
565 567
566 568 Test rolling into a commit with multiple children (issue5498)
567 569
568 570 $ hg init roll
569 571 $ cd roll
570 572 $ echo a > a
571 573 $ hg commit -qAm aa
572 574 $ echo b > b
573 575 $ hg commit -qAm bb
574 576 $ hg up -q ".^"
575 577 $ echo c > c
576 578 $ hg commit -qAm cc
577 579 $ hg log -G -T '{node|short} {desc}'
578 580 @ 5db65b93a12b cc
579 581 |
580 582 | o 301d76bdc3ae bb
581 583 |/
582 584 o 8f0162e483d0 aa
583 585
584 586
585 587 $ hg histedit . --commands - << EOF
586 588 > r 5db65b93a12b
587 589 > EOF
588 590 hg: parse error: first changeset cannot use verb "roll"
589 591 [255]
590 592 $ hg log -G -T '{node|short} {desc}'
591 593 @ 5db65b93a12b cc
592 594 |
593 595 | o 301d76bdc3ae bb
594 596 |/
595 597 o 8f0162e483d0 aa
596 598
597 599
@@ -1,1480 +1,1481
1 1 #require no-reposimplestore
2 2
3 3 Run kwdemo outside a repo
4 4 $ hg -q --config extensions.keyword= --config keywordmaps.Foo="{author|user}" kwdemo
5 5 [extensions]
6 6 keyword =
7 7 [keyword]
8 8 demo.txt =
9 9 [keywordset]
10 10 svn = False
11 11 [keywordmaps]
12 12 Foo = {author|user}
13 13 $Foo: test $
14 14
15 15 $ cat <<EOF >> $HGRCPATH
16 16 > [extensions]
17 17 > keyword =
18 18 > mq =
19 19 > notify =
20 20 > record =
21 21 > transplant =
22 22 > [ui]
23 23 > interactive = true
24 24 > EOF
25 25
26 26 hide outer repo
27 27 $ hg init
28 28
29 29 Run kwdemo before [keyword] files are set up
30 30 as it would succeed without uisetup otherwise
31 31
32 32 $ hg --quiet kwdemo
33 33 [extensions]
34 34 keyword =
35 35 [keyword]
36 36 demo.txt =
37 37 [keywordset]
38 38 svn = False
39 39 [keywordmaps]
40 40 Author = {author|user}
41 41 Date = {date|utcdate}
42 42 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
43 43 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
44 44 RCSFile = {file|basename},v
45 45 RCSfile = {file|basename},v
46 46 Revision = {node|short}
47 47 Source = {root}/{file},v
48 48 $Author: test $
49 49 $Date: ????/??/?? ??:??:?? $ (glob)
50 50 $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
51 51 $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
52 52 $RCSFile: demo.txt,v $
53 53 $RCSfile: demo.txt,v $
54 54 $Revision: ???????????? $ (glob)
55 55 $Source: */demo.txt,v $ (glob)
56 56
57 57 $ hg --quiet kwdemo "Branch = {branches}"
58 58 [extensions]
59 59 keyword =
60 60 [keyword]
61 61 demo.txt =
62 62 [keywordset]
63 63 svn = False
64 64 [keywordmaps]
65 65 Branch = {branches}
66 66 $Branch: demobranch $
67 67
68 68 (test template filter svnisodate and svnutcdate)
69 69
70 70 $ hg --quiet kwdemo --config keywordset.svn=True
71 71 [extensions]
72 72 keyword =
73 73 [keyword]
74 74 demo.txt =
75 75 [keywordset]
76 76 svn = True
77 77 [keywordmaps]
78 78 Author = {author|user}
79 79 Date = {date|svnisodate}
80 80 Id = {file|basename},v {node|short} {date|svnutcdate} {author|user}
81 81 LastChangedBy = {author|user}
82 82 LastChangedDate = {date|svnisodate}
83 83 LastChangedRevision = {node|short}
84 84 Revision = {node|short}
85 85 $Author: test $
86 86 $Date: ????-??-?? ??:??:?? ????? (???, ?? ??? ????) $ (glob)
87 87 $Id: demo.txt,v ???????????? ????-??-?? ??:??:??Z test $ (glob)
88 88 $LastChangedBy: test $
89 89 $LastChangedDate: ????-??-?? ??:??:?? ????? (???, ?? ??? ????) $ (glob)
90 90 $LastChangedRevision: ???????????? $ (glob)
91 91 $Revision: ???????????? $ (glob)
92 92
93 93 $ cat <<EOF >> $HGRCPATH
94 94 > [keyword]
95 95 > ** =
96 96 > b = ignore
97 97 > i = ignore
98 98 > [hooks]
99 99 > EOF
100 100 $ cp $HGRCPATH $HGRCPATH.nohooks
101 101 > cat <<EOF >> $HGRCPATH
102 102 > commit=
103 103 > commit.test=cp a hooktest
104 104 > EOF
105 105
106 106 $ hg init Test-bndl
107 107 $ cd Test-bndl
108 108
109 109 kwshrink should exit silently in empty/invalid repo
110 110
111 111 $ hg kwshrink
112 112
113 113 Symlinks cannot be created on Windows.
114 114 A bundle to test this was made with:
115 115 hg init t
116 116 cd t
117 117 echo a > a
118 118 ln -s a sym
119 119 hg add sym
120 120 hg ci -m addsym -u mercurial
121 121 hg bundle --base null ../test-keyword.hg
122 122
123 123 $ hg unbundle "$TESTDIR"/bundles/test-keyword.hg
124 124 adding changesets
125 125 adding manifests
126 126 adding file changes
127 127 added 1 changesets with 1 changes to 1 files
128 128 new changesets a2392c293916
129 129 (run 'hg update' to get a working copy)
130 130 $ hg up a2392c293916
131 131 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
132 132
133 133 $ echo 'expand $Id$' > a
134 134 $ echo 'do not process $Id:' >> a
135 135 $ echo 'xxx $' >> a
136 136 $ echo 'ignore $Id$' > b
137 137
138 138 Output files as they were created
139 139
140 140 $ cat a b
141 141 expand $Id$
142 142 do not process $Id:
143 143 xxx $
144 144 ignore $Id$
145 145
146 146 no kwfiles
147 147
148 148 $ hg kwfiles
149 149
150 150 untracked candidates
151 151
152 152 $ hg -v kwfiles --unknown
153 153 k a
154 154
155 155 Add files and check status
156 156
157 157 $ hg addremove
158 158 adding a
159 159 adding b
160 160 $ hg status
161 161 A a
162 162 A b
163 163
164 164
165 165 Default keyword expansion including commit hook
166 166 Interrupted commit should not change state or run commit hook
167 167
168 168 $ hg --debug commit
169 169 abort: empty commit message
170 170 [255]
171 171 $ hg status
172 172 A a
173 173 A b
174 174
175 175 Commit with several checks
176 176
177 177 $ hg --debug commit -mabsym -u 'User Name <user@example.com>'
178 178 committing files:
179 179 a
180 180 b
181 181 committing manifest
182 182 committing changelog
183 183 overwriting a expanding keywords
184 184 updating the branch cache
185 185 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
186 converting hook "commit.test" to native (windows !)
186 187 running hook commit.test: cp a hooktest
187 188 $ hg status
188 189 ? hooktest
189 190 $ hg debugrebuildstate
190 191 $ hg --quiet identify
191 192 ef63ca68695b
192 193
193 194 cat files in working directory with keywords expanded
194 195
195 196 $ cat a b
196 197 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
197 198 do not process $Id:
198 199 xxx $
199 200 ignore $Id$
200 201
201 202 hg cat files and symlink, no expansion
202 203
203 204 $ hg cat sym a b && echo
204 205 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
205 206 do not process $Id:
206 207 xxx $
207 208 ignore $Id$
208 209 a
209 210
210 211 $ diff a hooktest
211 212
212 213 $ cp $HGRCPATH.nohooks $HGRCPATH
213 214 $ rm hooktest
214 215
215 216 hg status of kw-ignored binary file starting with '\1\n'
216 217
217 218 >>> open("i", "wb").write("\1\nfoo")
218 219 $ hg -q commit -Am metasep i
219 220 $ hg status
220 221 >>> open("i", "wb").write("\1\nbar")
221 222 $ hg status
222 223 M i
223 224 $ hg -q commit -m "modify metasep" i
224 225 $ hg status --rev 2:3
225 226 M i
226 227 $ touch empty
227 228 $ hg -q commit -A -m "another file"
228 229 $ hg status -A --rev 3:4 i
229 230 C i
230 231
231 232 $ hg -q strip --no-backup 2
232 233
233 234 Test hook execution
234 235
235 236 bundle
236 237
237 238 $ hg bundle --base null ../kw.hg
238 239 2 changesets found
239 240 $ cd ..
240 241 $ hg init Test
241 242 $ cd Test
242 243
243 244 Notify on pull to check whether keywords stay as is in email
244 245 ie. if patch.diff wrapper acts as it should
245 246
246 247 $ cat <<EOF >> $HGRCPATH
247 248 > [hooks]
248 249 > incoming.notify = python:hgext.notify.hook
249 250 > [notify]
250 251 > sources = pull
251 252 > diffstat = False
252 253 > maxsubject = 15
253 254 > [reposubs]
254 255 > * = Test
255 256 > EOF
256 257
257 258 Pull from bundle and trigger notify
258 259
259 260 $ hg pull -u ../kw.hg
260 261 pulling from ../kw.hg
261 262 requesting all changes
262 263 adding changesets
263 264 adding manifests
264 265 adding file changes
265 266 added 2 changesets with 3 changes to 3 files
266 267 new changesets a2392c293916:ef63ca68695b
267 268 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
268 269 MIME-Version: 1.0
269 270 Content-Type: text/plain; charset="us-ascii"
270 271 Content-Transfer-Encoding: 7bit
271 272 Date: * (glob)
272 273 Subject: changeset in...
273 274 From: mercurial
274 275 X-Hg-Notification: changeset a2392c293916
275 276 Message-Id: <hg.a2392c293916*> (glob)
276 277 To: Test
277 278
278 279 changeset a2392c293916 in $TESTTMP/Test
279 280 details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
280 281 description:
281 282 addsym
282 283
283 284 diffs (6 lines):
284 285
285 286 diff -r 000000000000 -r a2392c293916 sym
286 287 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
287 288 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
288 289 @@ -0,0 +1,1 @@
289 290 +a
290 291 \ No newline at end of file
291 292 MIME-Version: 1.0
292 293 Content-Type: text/plain; charset="us-ascii"
293 294 Content-Transfer-Encoding: 7bit
294 295 Date:* (glob)
295 296 Subject: changeset in...
296 297 From: User Name <user@example.com>
297 298 X-Hg-Notification: changeset ef63ca68695b
298 299 Message-Id: <hg.ef63ca68695b*> (glob)
299 300 To: Test
300 301
301 302 changeset ef63ca68695b in $TESTTMP/Test
302 303 details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
303 304 description:
304 305 absym
305 306
306 307 diffs (12 lines):
307 308
308 309 diff -r a2392c293916 -r ef63ca68695b a
309 310 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
310 311 +++ b/a Thu Jan 01 00:00:00 1970 +0000
311 312 @@ -0,0 +1,3 @@
312 313 +expand $Id$
313 314 +do not process $Id:
314 315 +xxx $
315 316 diff -r a2392c293916 -r ef63ca68695b b
316 317 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
317 318 +++ b/b Thu Jan 01 00:00:00 1970 +0000
318 319 @@ -0,0 +1,1 @@
319 320 +ignore $Id$
320 321
321 322 $ cp $HGRCPATH.nohooks $HGRCPATH
322 323
323 324 Touch files and check with status
324 325
325 326 $ touch a b
326 327 $ hg status
327 328
328 329 Update and expand
329 330
330 331 $ rm sym a b
331 332 $ hg update -C
332 333 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
333 334 $ cat a b
334 335 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
335 336 do not process $Id:
336 337 xxx $
337 338 ignore $Id$
338 339
339 340 Check whether expansion is filewise and file mode is preserved
340 341
341 342 $ echo '$Id$' > c
342 343 $ echo 'tests for different changenodes' >> c
343 344 #if unix-permissions
344 345 $ chmod 600 c
345 346 $ ls -l c | cut -b 1-10
346 347 -rw-------
347 348 #endif
348 349
349 350 commit file c
350 351
351 352 $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
352 353 adding c
353 354 #if unix-permissions
354 355 $ ls -l c | cut -b 1-10
355 356 -rw-------
356 357 #endif
357 358
358 359 force expansion
359 360
360 361 $ hg -v kwexpand
361 362 overwriting a expanding keywords
362 363 overwriting c expanding keywords
363 364
364 365 compare changenodes in a and c
365 366
366 367 $ cat a c
367 368 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
368 369 do not process $Id:
369 370 xxx $
370 371 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
371 372 tests for different changenodes
372 373
373 374 record
374 375
375 376 $ echo '$Id$' > r
376 377 $ hg add r
377 378
378 379 record chunk
379 380
380 381 >>> lines = open('a', 'rb').readlines()
381 382 >>> lines.insert(1, 'foo\n')
382 383 >>> lines.append('bar\n')
383 384 >>> open('a', 'wb').writelines(lines)
384 385 $ hg record -d '10 1' -m rectest a<<EOF
385 386 > y
386 387 > y
387 388 > n
388 389 > EOF
389 390 diff --git a/a b/a
390 391 2 hunks, 2 lines changed
391 392 examine changes to 'a'? [Ynesfdaq?] y
392 393
393 394 @@ -1,3 +1,4 @@
394 395 expand $Id$
395 396 +foo
396 397 do not process $Id:
397 398 xxx $
398 399 record change 1/2 to 'a'? [Ynesfdaq?] y
399 400
400 401 @@ -2,2 +3,3 @@
401 402 do not process $Id:
402 403 xxx $
403 404 +bar
404 405 record change 2/2 to 'a'? [Ynesfdaq?] n
405 406
406 407
407 408 $ hg identify
408 409 5f5eb23505c3+ tip
409 410 $ hg status
410 411 M a
411 412 A r
412 413
413 414 Cat modified file a
414 415
415 416 $ cat a
416 417 expand $Id: a,v 5f5eb23505c3 1970/01/01 00:00:10 test $
417 418 foo
418 419 do not process $Id:
419 420 xxx $
420 421 bar
421 422
422 423 Diff remaining chunk
423 424
424 425 $ hg diff a
425 426 diff -r 5f5eb23505c3 a
426 427 --- a/a Thu Jan 01 00:00:09 1970 -0000
427 428 +++ b/a * (glob)
428 429 @@ -2,3 +2,4 @@
429 430 foo
430 431 do not process $Id:
431 432 xxx $
432 433 +bar
433 434
434 435 $ hg rollback
435 436 repository tip rolled back to revision 2 (undo commit)
436 437 working directory now based on revision 2
437 438
438 439 Record all chunks in file a
439 440
440 441 $ echo foo > msg
441 442
442 443 - do not use "hg record -m" here!
443 444
444 445 $ hg record -l msg -d '11 1' a<<EOF
445 446 > y
446 447 > y
447 448 > y
448 449 > EOF
449 450 diff --git a/a b/a
450 451 2 hunks, 2 lines changed
451 452 examine changes to 'a'? [Ynesfdaq?] y
452 453
453 454 @@ -1,3 +1,4 @@
454 455 expand $Id$
455 456 +foo
456 457 do not process $Id:
457 458 xxx $
458 459 record change 1/2 to 'a'? [Ynesfdaq?] y
459 460
460 461 @@ -2,2 +3,3 @@
461 462 do not process $Id:
462 463 xxx $
463 464 +bar
464 465 record change 2/2 to 'a'? [Ynesfdaq?] y
465 466
466 467
467 468 File a should be clean
468 469
469 470 $ hg status -A a
470 471 C a
471 472
472 473 rollback and revert expansion
473 474
474 475 $ cat a
475 476 expand $Id: a,v 78e0a02d76aa 1970/01/01 00:00:11 test $
476 477 foo
477 478 do not process $Id:
478 479 xxx $
479 480 bar
480 481 $ hg --verbose rollback
481 482 repository tip rolled back to revision 2 (undo commit)
482 483 working directory now based on revision 2
483 484 overwriting a expanding keywords
484 485 $ hg status a
485 486 M a
486 487 $ cat a
487 488 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
488 489 foo
489 490 do not process $Id:
490 491 xxx $
491 492 bar
492 493 $ echo '$Id$' > y
493 494 $ echo '$Id$' > z
494 495 $ hg add y
495 496 $ hg commit -Am "rollback only" z
496 497 $ cat z
497 498 $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
498 499 $ hg --verbose rollback
499 500 repository tip rolled back to revision 2 (undo commit)
500 501 working directory now based on revision 2
501 502 overwriting z shrinking keywords
502 503
503 504 Only z should be overwritten
504 505
505 506 $ hg status a y z
506 507 M a
507 508 A y
508 509 A z
509 510 $ cat z
510 511 $Id$
511 512 $ hg forget y z
512 513 $ rm y z
513 514
514 515 record added file alone
515 516
516 517 $ hg -v record -l msg -d '12 2' r<<EOF
517 518 > y
518 519 > y
519 520 > EOF
520 521 diff --git a/r b/r
521 522 new file mode 100644
522 523 examine changes to 'r'? [Ynesfdaq?] y
523 524
524 525 @@ -0,0 +1,1 @@
525 526 +$Id$
526 527 record this change to 'r'? [Ynesfdaq?] y
527 528
528 529 resolving manifests
529 530 patching file r
530 531 committing files:
531 532 r
532 533 committing manifest
533 534 committing changelog
534 535 committed changeset 3:82a2f715724d
535 536 overwriting r expanding keywords
536 537 $ hg status r
537 538 $ hg --verbose rollback
538 539 repository tip rolled back to revision 2 (undo commit)
539 540 working directory now based on revision 2
540 541 overwriting r shrinking keywords
541 542 $ hg forget r
542 543 $ rm msg r
543 544 $ hg update -C
544 545 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
545 546
546 547 record added keyword ignored file
547 548
548 549 $ echo '$Id$' > i
549 550 $ hg add i
550 551 $ hg --verbose record -d '13 1' -m recignored<<EOF
551 552 > y
552 553 > y
553 554 > EOF
554 555 diff --git a/i b/i
555 556 new file mode 100644
556 557 examine changes to 'i'? [Ynesfdaq?] y
557 558
558 559 @@ -0,0 +1,1 @@
559 560 +$Id$
560 561 record this change to 'i'? [Ynesfdaq?] y
561 562
562 563 resolving manifests
563 564 patching file i
564 565 committing files:
565 566 i
566 567 committing manifest
567 568 committing changelog
568 569 committed changeset 3:9f40ceb5a072
569 570 $ cat i
570 571 $Id$
571 572 $ hg -q rollback
572 573 $ hg forget i
573 574 $ rm i
574 575
575 576 amend
576 577
577 578 $ echo amend >> a
578 579 $ echo amend >> b
579 580 $ hg -q commit -d '14 1' -m 'prepare amend'
580 581
581 582 $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords
582 583 overwriting a expanding keywords
583 584 $ hg -q id
584 585 67d8c481a6be
585 586 $ head -1 a
586 587 expand $Id: a,v 67d8c481a6be 1970/01/01 00:00:15 test $
587 588
588 589 $ hg -q strip --no-backup tip
589 590
590 591 Test patch queue repo
591 592
592 593 $ hg init --mq
593 594 $ hg qimport -r tip -n mqtest.diff
594 595 $ hg commit --mq -m mqtest
595 596
596 597 Keywords should not be expanded in patch
597 598
598 599 $ cat .hg/patches/mqtest.diff
599 600 # HG changeset patch
600 601 # User User Name <user@example.com>
601 602 # Date 1 0
602 603 # Thu Jan 01 00:00:01 1970 +0000
603 604 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
604 605 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
605 606 cndiff
606 607
607 608 diff -r ef63ca68695b -r 40a904bbbe4c c
608 609 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
609 610 +++ b/c Thu Jan 01 00:00:01 1970 +0000
610 611 @@ -0,0 +1,2 @@
611 612 +$Id$
612 613 +tests for different changenodes
613 614
614 615 $ hg qpop
615 616 popping mqtest.diff
616 617 patch queue now empty
617 618
618 619 qgoto, implying qpush, should expand
619 620
620 621 $ hg qgoto mqtest.diff
621 622 applying mqtest.diff
622 623 now at: mqtest.diff
623 624 $ cat c
624 625 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
625 626 tests for different changenodes
626 627 $ hg cat c
627 628 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
628 629 tests for different changenodes
629 630
630 631 Keywords should not be expanded in filelog
631 632
632 633 $ hg --config 'extensions.keyword=!' cat c
633 634 $Id$
634 635 tests for different changenodes
635 636
636 637 qpop and move on
637 638
638 639 $ hg qpop
639 640 popping mqtest.diff
640 641 patch queue now empty
641 642
642 643 Copy and show added kwfiles
643 644
644 645 $ hg cp a c
645 646 $ hg kwfiles
646 647 a
647 648 c
648 649
649 650 Commit and show expansion in original and copy
650 651
651 652 $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
652 653 committing files:
653 654 c
654 655 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
655 656 committing manifest
656 657 committing changelog
657 658 overwriting c expanding keywords
658 659 updating the branch cache
659 660 committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
660 661 $ cat a c
661 662 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
662 663 do not process $Id:
663 664 xxx $
664 665 expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
665 666 do not process $Id:
666 667 xxx $
667 668
668 669 Touch copied c and check its status
669 670
670 671 $ touch c
671 672 $ hg status
672 673
673 674 Copy kwfile to keyword ignored file unexpanding keywords
674 675
675 676 $ hg --verbose copy a i
676 677 copying a to i
677 678 overwriting i shrinking keywords
678 679 $ head -n 1 i
679 680 expand $Id$
680 681 $ hg forget i
681 682 $ rm i
682 683
683 684 Copy ignored file to ignored file: no overwriting
684 685
685 686 $ hg --verbose copy b i
686 687 copying b to i
687 688 $ hg forget i
688 689 $ rm i
689 690
690 691 cp symlink file; hg cp -A symlink file (part1)
691 692 - copied symlink points to kwfile: overwrite
692 693
693 694 #if symlink
694 695 $ cp sym i
695 696 $ ls -l i
696 697 -rw-r--r--* (glob)
697 698 $ head -1 i
698 699 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
699 700 $ hg copy --after --verbose sym i
700 701 copying sym to i
701 702 overwriting i shrinking keywords
702 703 $ head -1 i
703 704 expand $Id$
704 705 $ hg forget i
705 706 $ rm i
706 707 #endif
707 708
708 709 Test different options of hg kwfiles
709 710
710 711 $ hg kwfiles
711 712 a
712 713 c
713 714 $ hg -v kwfiles --ignore
714 715 I b
715 716 I sym
716 717 $ hg kwfiles --all
717 718 K a
718 719 K c
719 720 I b
720 721 I sym
721 722
722 723 Diff specific revision
723 724
724 725 $ hg diff --rev 1
725 726 diff -r ef63ca68695b c
726 727 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
727 728 +++ b/c * (glob)
728 729 @@ -0,0 +1,3 @@
729 730 +expand $Id$
730 731 +do not process $Id:
731 732 +xxx $
732 733
733 734 Status after rollback:
734 735
735 736 $ hg rollback
736 737 repository tip rolled back to revision 1 (undo commit)
737 738 working directory now based on revision 1
738 739 $ hg status
739 740 A c
740 741 $ hg update --clean
741 742 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
742 743
743 744 #if symlink
744 745
745 746 cp symlink file; hg cp -A symlink file (part2)
746 747 - copied symlink points to kw ignored file: do not overwrite
747 748
748 749 $ cat a > i
749 750 $ ln -s i symignored
750 751 $ hg commit -Am 'fake expansion in ignored and symlink' i symignored
751 752 $ cp symignored x
752 753 $ hg copy --after --verbose symignored x
753 754 copying symignored to x
754 755 $ head -n 1 x
755 756 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
756 757 $ hg forget x
757 758 $ rm x
758 759
759 760 $ hg rollback
760 761 repository tip rolled back to revision 1 (undo commit)
761 762 working directory now based on revision 1
762 763 $ hg update --clean
763 764 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
764 765 $ rm i symignored
765 766
766 767 #endif
767 768
768 769 Custom keywordmaps as argument to kwdemo
769 770
770 771 $ hg --quiet kwdemo "Xinfo = {author}: {desc}"
771 772 [extensions]
772 773 keyword =
773 774 [keyword]
774 775 ** =
775 776 b = ignore
776 777 demo.txt =
777 778 i = ignore
778 779 [keywordset]
779 780 svn = False
780 781 [keywordmaps]
781 782 Xinfo = {author}: {desc}
782 783 $Xinfo: test: hg keyword configuration and expansion example $
783 784
784 785 Configure custom keywordmaps
785 786
786 787 $ cat <<EOF >>$HGRCPATH
787 788 > [keywordmaps]
788 789 > Id = {file} {node|short} {date|rfc822date} {author|user}
789 790 > Xinfo = {author}: {desc}
790 791 > EOF
791 792
792 793 Cat and hg cat files before custom expansion
793 794
794 795 $ cat a b
795 796 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
796 797 do not process $Id:
797 798 xxx $
798 799 ignore $Id$
799 800 $ hg cat sym a b && echo
800 801 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
801 802 do not process $Id:
802 803 xxx $
803 804 ignore $Id$
804 805 a
805 806
806 807 Write custom keyword and prepare multi-line commit message
807 808
808 809 $ echo '$Xinfo$' >> a
809 810 $ cat <<EOF >> log
810 811 > firstline
811 812 > secondline
812 813 > EOF
813 814
814 815 Interrupted commit should not change state
815 816
816 817 $ hg commit
817 818 abort: empty commit message
818 819 [255]
819 820 $ hg status
820 821 M a
821 822 ? c
822 823 ? log
823 824
824 825 Commit with multi-line message and custom expansion
825 826
826 827 $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
827 828 committing files:
828 829 a
829 830 committing manifest
830 831 committing changelog
831 832 overwriting a expanding keywords
832 833 updating the branch cache
833 834 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
834 835 $ rm log
835 836
836 837 Stat, verify and show custom expansion (firstline)
837 838
838 839 $ hg status
839 840 ? c
840 841 $ hg verify
841 842 checking changesets
842 843 checking manifests
843 844 crosschecking files in changesets and manifests
844 845 checking files
845 846 3 files, 3 changesets, 4 total revisions
846 847 $ cat a b
847 848 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
848 849 do not process $Id:
849 850 xxx $
850 851 $Xinfo: User Name <user@example.com>: firstline $
851 852 ignore $Id$
852 853 $ hg cat sym a b && echo
853 854 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
854 855 do not process $Id:
855 856 xxx $
856 857 $Xinfo: User Name <user@example.com>: firstline $
857 858 ignore $Id$
858 859 a
859 860
860 861 annotate
861 862
862 863 $ hg annotate a
863 864 1: expand $Id$
864 865 1: do not process $Id:
865 866 1: xxx $
866 867 2: $Xinfo$
867 868
868 869 remove with status checks
869 870
870 871 $ hg debugrebuildstate
871 872 $ hg remove a
872 873 $ hg --debug commit -m rma
873 874 committing files:
874 875 committing manifest
875 876 committing changelog
876 877 updating the branch cache
877 878 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
878 879 $ hg status
879 880 ? c
880 881
881 882 Rollback, revert, and check expansion
882 883
883 884 $ hg rollback
884 885 repository tip rolled back to revision 2 (undo commit)
885 886 working directory now based on revision 2
886 887 $ hg status
887 888 R a
888 889 ? c
889 890 $ hg revert --no-backup --rev tip a
890 891 $ cat a
891 892 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
892 893 do not process $Id:
893 894 xxx $
894 895 $Xinfo: User Name <user@example.com>: firstline $
895 896
896 897 Clone to test global and local configurations
897 898
898 899 $ cd ..
899 900
900 901 Expansion in destination with global configuration
901 902
902 903 $ hg --quiet clone Test globalconf
903 904 $ cat globalconf/a
904 905 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
905 906 do not process $Id:
906 907 xxx $
907 908 $Xinfo: User Name <user@example.com>: firstline $
908 909
909 910 No expansion in destination with local configuration in origin only
910 911
911 912 $ hg --quiet --config 'keyword.**=ignore' clone Test localconf
912 913 $ cat localconf/a
913 914 expand $Id$
914 915 do not process $Id:
915 916 xxx $
916 917 $Xinfo$
917 918
918 919 Clone to test incoming
919 920
920 921 $ hg clone -r1 Test Test-a
921 922 adding changesets
922 923 adding manifests
923 924 adding file changes
924 925 added 2 changesets with 3 changes to 3 files
925 926 new changesets a2392c293916:ef63ca68695b
926 927 updating to branch default
927 928 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
928 929 $ cd Test-a
929 930 $ cat <<EOF >> .hg/hgrc
930 931 > [paths]
931 932 > default = ../Test
932 933 > EOF
933 934 $ hg incoming
934 935 comparing with $TESTTMP/Test
935 936 searching for changes
936 937 changeset: 2:bb948857c743
937 938 tag: tip
938 939 user: User Name <user@example.com>
939 940 date: Thu Jan 01 00:00:02 1970 +0000
940 941 summary: firstline
941 942
942 943 Imported patch should not be rejected
943 944
944 945 >>> import re
945 946 >>> text = re.sub(r'(Id.*)', r'\1 rejecttest', open('a').read())
946 947 >>> open('a', 'wb').write(text)
947 948 $ hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
948 949 committing files:
949 950 a
950 951 committing manifest
951 952 committing changelog
952 953 overwriting a expanding keywords
953 954 updating the branch cache
954 955 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
955 956 $ hg export -o ../rejecttest.diff tip
956 957 $ cd ../Test
957 958 $ hg import ../rejecttest.diff
958 959 applying ../rejecttest.diff
959 960 $ cat a b
960 961 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
961 962 do not process $Id: rejecttest
962 963 xxx $
963 964 $Xinfo: User Name <user@example.com>: rejects? $
964 965 ignore $Id$
965 966
966 967 $ hg rollback
967 968 repository tip rolled back to revision 2 (undo import)
968 969 working directory now based on revision 2
969 970 $ hg update --clean
970 971 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
971 972
972 973 kwexpand/kwshrink on selected files
973 974
974 975 $ mkdir x
975 976 $ hg copy a x/a
976 977 $ hg --verbose kwshrink a
977 978 overwriting a shrinking keywords
978 979 - sleep required for dirstate.normal() check
979 980 $ sleep 1
980 981 $ hg status a
981 982 $ hg --verbose kwexpand a
982 983 overwriting a expanding keywords
983 984 $ hg status a
984 985
985 986 kwexpand x/a should abort
986 987
987 988 $ hg --verbose kwexpand x/a
988 989 abort: outstanding uncommitted changes
989 990 [255]
990 991 $ cd x
991 992 $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
992 993 committing files:
993 994 x/a
994 995 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
995 996 committing manifest
996 997 committing changelog
997 998 overwriting x/a expanding keywords
998 999 updating the branch cache
999 1000 committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
1000 1001 $ cat a
1001 1002 expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
1002 1003 do not process $Id:
1003 1004 xxx $
1004 1005 $Xinfo: User Name <user@example.com>: xa $
1005 1006
1006 1007 kwshrink a inside directory x
1007 1008
1008 1009 $ hg --verbose kwshrink a
1009 1010 overwriting x/a shrinking keywords
1010 1011 $ cat a
1011 1012 expand $Id$
1012 1013 do not process $Id:
1013 1014 xxx $
1014 1015 $Xinfo$
1015 1016 $ cd ..
1016 1017
1017 1018 kwexpand nonexistent
1018 1019
1019 1020 $ hg kwexpand nonexistent
1020 1021 nonexistent:* (glob)
1021 1022
1022 1023
1023 1024 #if serve
1024 1025 hg serve
1025 1026 - expand with hgweb file
1026 1027 - no expansion with hgweb annotate/changeset/filediff/comparison
1027 1028 - expand with hgweb file, again
1028 1029 - check errors
1029 1030
1030 1031 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1031 1032 $ cat hg.pid >> $DAEMON_PIDS
1032 1033 $ get-with-headers.py localhost:$HGPORT 'file/tip/a/?style=raw'
1033 1034 200 Script output follows
1034 1035
1035 1036 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1036 1037 do not process $Id:
1037 1038 xxx $
1038 1039 $Xinfo: User Name <user@example.com>: firstline $
1039 1040 $ get-with-headers.py localhost:$HGPORT 'annotate/tip/a/?style=raw'
1040 1041 200 Script output follows
1041 1042
1042 1043
1043 1044 user@1: expand $Id$
1044 1045 user@1: do not process $Id:
1045 1046 user@1: xxx $
1046 1047 user@2: $Xinfo$
1047 1048
1048 1049
1049 1050
1050 1051
1051 1052 $ get-with-headers.py localhost:$HGPORT 'rev/tip/?style=raw'
1052 1053 200 Script output follows
1053 1054
1054 1055
1055 1056 # HG changeset patch
1056 1057 # User User Name <user@example.com>
1057 1058 # Date 3 0
1058 1059 # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
1059 1060 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
1060 1061 xa
1061 1062
1062 1063 diff -r bb948857c743 -r b4560182a3f9 x/a
1063 1064 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1064 1065 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
1065 1066 @@ -0,0 +1,4 @@
1066 1067 +expand $Id$
1067 1068 +do not process $Id:
1068 1069 +xxx $
1069 1070 +$Xinfo$
1070 1071
1071 1072 $ get-with-headers.py localhost:$HGPORT 'diff/bb948857c743/a?style=raw'
1072 1073 200 Script output follows
1073 1074
1074 1075
1075 1076 diff -r ef63ca68695b -r bb948857c743 a
1076 1077 --- a/a Thu Jan 01 00:00:00 1970 +0000
1077 1078 +++ b/a Thu Jan 01 00:00:02 1970 +0000
1078 1079 @@ -1,3 +1,4 @@
1079 1080 expand $Id$
1080 1081 do not process $Id:
1081 1082 xxx $
1082 1083 +$Xinfo$
1083 1084
1084 1085
1085 1086
1086 1087
1087 1088 $ get-with-headers.py localhost:$HGPORT 'comparison/bb948857c743/a' | grep '\$[a-zA-Z]'
1088 1089 <td class="source equal"><a href="#l1r1"> 1</a> expand $Id$</td>
1089 1090 <td class="source equal"><a href="#l1r1"> 1</a> expand $Id$</td>
1090 1091 <td class="source equal"><a href="#l2r2"> 2</a> do not process $Id:</td>
1091 1092 <td class="source equal"><a href="#l2r2"> 2</a> do not process $Id:</td>
1092 1093 <td class="source insert"><a href="#r4"> 4</a> $Xinfo$</td>
1093 1094
1094 1095 (check "kwweb_skip"-ed webcommand doesn't suppress expanding keywords
1095 1096 at subsequent webcommands)
1096 1097
1097 1098 $ get-with-headers.py localhost:$HGPORT 'file/tip/a/?style=raw'
1098 1099 200 Script output follows
1099 1100
1100 1101 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1101 1102 do not process $Id:
1102 1103 xxx $
1103 1104 $Xinfo: User Name <user@example.com>: firstline $
1104 1105
1105 1106 $ killdaemons.py
1106 1107 $ cat errors.log
1107 1108 #endif
1108 1109
1109 1110 Prepare merge and resolve tests
1110 1111
1111 1112 $ echo '$Id$' > m
1112 1113 $ hg add m
1113 1114 $ hg commit -m 4kw
1114 1115 $ echo foo >> m
1115 1116 $ hg commit -m 5foo
1116 1117
1117 1118 simplemerge
1118 1119
1119 1120 $ hg update 4
1120 1121 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1121 1122 $ echo foo >> m
1122 1123 $ hg commit -m 6foo
1123 1124 created new head
1124 1125 $ hg merge
1125 1126 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1126 1127 (branch merge, don't forget to commit)
1127 1128 $ hg commit -m simplemerge
1128 1129 $ cat m
1129 1130 $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
1130 1131 foo
1131 1132
1132 1133 conflict: keyword should stay outside conflict zone
1133 1134
1134 1135 $ hg update 4
1135 1136 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1136 1137 $ echo bar >> m
1137 1138 $ hg commit -m 8bar
1138 1139 created new head
1139 1140 $ hg merge
1140 1141 merging m
1141 1142 warning: conflicts while merging m! (edit, then use 'hg resolve --mark')
1142 1143 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1143 1144 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1144 1145 [1]
1145 1146 $ cat m
1146 1147 $Id$
1147 1148 <<<<<<< working copy: 88a80c8d172e - test: 8bar
1148 1149 bar
1149 1150 =======
1150 1151 foo
1151 1152 >>>>>>> merge rev: 85d2d2d732a5 - test: simplemerge
1152 1153
1153 1154 resolve to local, m must contain hash of last change (local parent)
1154 1155
1155 1156 $ hg resolve -t internal:local -a
1156 1157 (no more unresolved files)
1157 1158 $ hg commit -m localresolve
1158 1159 $ cat m
1159 1160 $Id: m 88a80c8d172e Thu, 01 Jan 1970 00:00:00 +0000 test $
1160 1161 bar
1161 1162
1162 1163 Test restricted mode with transplant -b
1163 1164
1164 1165 $ hg update 6
1165 1166 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1166 1167 $ hg branch foo
1167 1168 marked working directory as branch foo
1168 1169 (branches are permanent and global, did you want a bookmark?)
1169 1170 $ mv a a.bak
1170 1171 $ echo foobranch > a
1171 1172 $ cat a.bak >> a
1172 1173 $ rm a.bak
1173 1174 $ hg commit -m 9foobranch
1174 1175 $ hg update default
1175 1176 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1176 1177 $ hg -y transplant -b foo tip
1177 1178 applying 4aa30d025d50
1178 1179 4aa30d025d50 transplanted to e00abbf63521
1179 1180
1180 1181 Expansion in changeset but not in file
1181 1182
1182 1183 $ hg tip -p
1183 1184 changeset: 11:e00abbf63521
1184 1185 tag: tip
1185 1186 parent: 9:800511b3a22d
1186 1187 user: test
1187 1188 date: Thu Jan 01 00:00:00 1970 +0000
1188 1189 summary: 9foobranch
1189 1190
1190 1191 diff -r 800511b3a22d -r e00abbf63521 a
1191 1192 --- a/a Thu Jan 01 00:00:00 1970 +0000
1192 1193 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1193 1194 @@ -1,3 +1,4 @@
1194 1195 +foobranch
1195 1196 expand $Id$
1196 1197 do not process $Id:
1197 1198 xxx $
1198 1199
1199 1200 $ head -n 2 a
1200 1201 foobranch
1201 1202 expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
1202 1203
1203 1204 Turn off expansion
1204 1205
1205 1206 $ hg -q rollback
1206 1207 $ hg -q update -C
1207 1208
1208 1209 kwshrink with unknown file u
1209 1210
1210 1211 $ cp a u
1211 1212 $ hg --verbose kwshrink
1212 1213 overwriting a shrinking keywords
1213 1214 overwriting m shrinking keywords
1214 1215 overwriting x/a shrinking keywords
1215 1216
1216 1217 Keywords shrunk in working directory, but not yet disabled
1217 1218 - cat shows unexpanded keywords
1218 1219 - hg cat shows expanded keywords
1219 1220
1220 1221 $ cat a b
1221 1222 expand $Id$
1222 1223 do not process $Id:
1223 1224 xxx $
1224 1225 $Xinfo$
1225 1226 ignore $Id$
1226 1227 $ hg cat sym a b && echo
1227 1228 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1228 1229 do not process $Id:
1229 1230 xxx $
1230 1231 $Xinfo: User Name <user@example.com>: firstline $
1231 1232 ignore $Id$
1232 1233 a
1233 1234
1234 1235 Now disable keyword expansion
1235 1236
1236 1237 $ cp $HGRCPATH $HGRCPATH.backup
1237 1238 $ rm "$HGRCPATH"
1238 1239 $ cat a b
1239 1240 expand $Id$
1240 1241 do not process $Id:
1241 1242 xxx $
1242 1243 $Xinfo$
1243 1244 ignore $Id$
1244 1245 $ hg cat sym a b && echo
1245 1246 expand $Id$
1246 1247 do not process $Id:
1247 1248 xxx $
1248 1249 $Xinfo$
1249 1250 ignore $Id$
1250 1251 a
1251 1252
1252 1253 enable keyword expansion again
1253 1254
1254 1255 $ cat $HGRCPATH.backup >> $HGRCPATH
1255 1256
1256 1257 Test restricted mode with unshelve
1257 1258
1258 1259 $ cat <<EOF >> $HGRCPATH
1259 1260 > [extensions]
1260 1261 > shelve =
1261 1262 > EOF
1262 1263
1263 1264 $ echo xxxx >> a
1264 1265 $ hg diff
1265 1266 diff -r 800511b3a22d a
1266 1267 --- a/a Thu Jan 01 00:00:00 1970 +0000
1267 1268 +++ b/a * (glob)
1268 1269 @@ -2,3 +2,4 @@
1269 1270 do not process $Id:
1270 1271 xxx $
1271 1272 $Xinfo$
1272 1273 +xxxx
1273 1274 $ hg shelve -q --name tmp
1274 1275 $ hg shelve --list --patch
1275 1276 tmp (*)* changes to: localresolve (glob)
1276 1277
1277 1278 diff --git a/a b/a
1278 1279 --- a/a
1279 1280 +++ b/a
1280 1281 @@ -2,3 +2,4 @@
1281 1282 do not process $Id:
1282 1283 xxx $
1283 1284 $Xinfo$
1284 1285 +xxxx
1285 1286
1286 1287 $ hg update -q -C 10
1287 1288 $ hg unshelve -q tmp
1288 1289 $ hg diff
1289 1290 diff -r 4aa30d025d50 a
1290 1291 --- a/a Thu Jan 01 00:00:00 1970 +0000
1291 1292 +++ b/a * (glob)
1292 1293 @@ -3,3 +3,4 @@
1293 1294 do not process $Id:
1294 1295 xxx $
1295 1296 $Xinfo$
1296 1297 +xxxx
1297 1298
1298 1299 Test restricted mode with rebase
1299 1300
1300 1301 $ cat <<EOF >> $HGRCPATH
1301 1302 > [extensions]
1302 1303 > rebase =
1303 1304 > EOF
1304 1305
1305 1306 $ hg update -q -C 9
1306 1307
1307 1308 $ echo xxxx >> a
1308 1309 $ hg commit -m '#11'
1309 1310 $ hg diff -c 11
1310 1311 diff -r 800511b3a22d -r b07670694489 a
1311 1312 --- a/a Thu Jan 01 00:00:00 1970 +0000
1312 1313 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1313 1314 @@ -2,3 +2,4 @@
1314 1315 do not process $Id:
1315 1316 xxx $
1316 1317 $Xinfo$
1317 1318 +xxxx
1318 1319
1319 1320 $ hg diff -c 10
1320 1321 diff -r 27d48ee14f67 -r 4aa30d025d50 a
1321 1322 --- a/a Thu Jan 01 00:00:00 1970 +0000
1322 1323 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1323 1324 @@ -1,3 +1,4 @@
1324 1325 +foobranch
1325 1326 expand $Id$
1326 1327 do not process $Id:
1327 1328 xxx $
1328 1329
1329 1330 $ hg rebase -q -s 10 -d 11 --keep
1330 1331 $ hg diff -r 9 -r 12 a
1331 1332 diff -r 800511b3a22d -r 1939b927726c a
1332 1333 --- a/a Thu Jan 01 00:00:00 1970 +0000
1333 1334 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1334 1335 @@ -1,4 +1,6 @@
1335 1336 +foobranch
1336 1337 expand $Id$
1337 1338 do not process $Id:
1338 1339 xxx $
1339 1340 $Xinfo$
1340 1341 +xxxx
1341 1342
1342 1343 Test restricted mode with graft
1343 1344
1344 1345 $ hg graft -q 10
1345 1346 $ hg diff -r 9 -r 13 a
1346 1347 diff -r 800511b3a22d -r 01a68de1003a a
1347 1348 --- a/a Thu Jan 01 00:00:00 1970 +0000
1348 1349 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1349 1350 @@ -1,4 +1,6 @@
1350 1351 +foobranch
1351 1352 expand $Id$
1352 1353 do not process $Id:
1353 1354 xxx $
1354 1355 $Xinfo$
1355 1356 +xxxx
1356 1357
1357 1358 Test restricted mode with backout
1358 1359
1359 1360 $ hg backout -q 11 --no-commit
1360 1361 $ hg diff a
1361 1362 diff -r 01a68de1003a a
1362 1363 --- a/a Thu Jan 01 00:00:00 1970 +0000
1363 1364 +++ b/a * (glob)
1364 1365 @@ -3,4 +3,3 @@
1365 1366 do not process $Id:
1366 1367 xxx $
1367 1368 $Xinfo$
1368 1369 -xxxx
1369 1370
1370 1371 Test restricted mode with histedit
1371 1372
1372 1373 $ cat <<EOF >> $HGRCPATH
1373 1374 > [extensions]
1374 1375 > histedit =
1375 1376 > EOF
1376 1377
1377 1378 $ hg commit -m 'backout #11'
1378 1379 $ hg histedit -q --command - 13 <<EOF
1379 1380 > pick 49f5f2d940c3 14 backout #11
1380 1381 > pick 01a68de1003a 13 9foobranch
1381 1382 > EOF
1382 1383
1383 1384 Test restricted mode with fetch (with merge)
1384 1385
1385 1386 $ cat <<EOF >> $HGRCPATH
1386 1387 > [extensions]
1387 1388 > fetch =
1388 1389 > EOF
1389 1390
1390 1391 $ hg clone -q -r 9 . ../fetch-merge
1391 1392 $ cd ../fetch-merge
1392 1393 $ hg -R ../Test export 10 | hg import -q -
1393 1394 $ hg fetch -q -r 11
1394 1395 $ hg diff -r 9 a
1395 1396 diff -r 800511b3a22d a
1396 1397 --- a/a Thu Jan 01 00:00:00 1970 +0000
1397 1398 +++ b/a * (glob)
1398 1399 @@ -1,4 +1,6 @@
1399 1400 +foobranch
1400 1401 expand $Id$
1401 1402 do not process $Id:
1402 1403 xxx $
1403 1404 $Xinfo$
1404 1405 +xxxx
1405 1406
1406 1407 Test that patch.diff(), which is implied by "hg diff" or so, doesn't
1407 1408 suppress expanding keywords at subsequent commands
1408 1409
1409 1410 #if windows
1410 1411 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
1411 1412 #else
1412 1413 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
1413 1414 #endif
1414 1415 $ export PYTHONPATH
1415 1416
1416 1417 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
1417 1418 $ mv $HGRCPATH.new $HGRCPATH
1418 1419
1419 1420 >>> from __future__ import print_function
1420 1421 >>> from hgclient import check, readchannel, runcommand
1421 1422 >>> @check
1422 1423 ... def check(server):
1423 1424 ... # hello block
1424 1425 ... readchannel(server)
1425 1426 ...
1426 1427 ... runcommand(server, ['cat', 'm'])
1427 1428 ... runcommand(server, ['diff', '-c', '.', 'm'])
1428 1429 ... runcommand(server, ['cat', 'm'])
1429 1430 *** runcommand cat m
1430 1431 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1431 1432 bar
1432 1433 *** runcommand diff -c . m
1433 1434 *** runcommand cat m
1434 1435 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1435 1436 bar
1436 1437
1437 1438 $ cd ..
1438 1439
1439 1440 #if serve
1440 1441
1441 1442 Test that keywords are expanded only in repositories, which enable
1442 1443 keyword extension, even if multiple repositories are served in a
1443 1444 process
1444 1445
1445 1446 $ cat >> fetch-merge/.hg/hgrc <<EOF
1446 1447 > [extensions]
1447 1448 > keyword = !
1448 1449 > EOF
1449 1450
1450 1451 $ cat > paths.conf <<EOF
1451 1452 > [paths]
1452 1453 > enabled=Test
1453 1454 > disabled=fetch-merge
1454 1455 > EOF
1455 1456
1456 1457 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E error.log --webdir-conf paths.conf
1457 1458 $ cat hg.pid >> $DAEMON_PIDS
1458 1459
1459 1460 $ get-with-headers.py localhost:$HGPORT 'enabled/file/tip/m/?style=raw'
1460 1461 200 Script output follows
1461 1462
1462 1463 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1463 1464 bar
1464 1465
1465 1466 $ get-with-headers.py localhost:$HGPORT 'disabled/file/tip/m/?style=raw'
1466 1467 200 Script output follows
1467 1468
1468 1469 $Id$
1469 1470 bar
1470 1471
1471 1472 (check expansion again, for safety)
1472 1473
1473 1474 $ get-with-headers.py localhost:$HGPORT 'enabled/file/tip/m/?style=raw'
1474 1475 200 Script output follows
1475 1476
1476 1477 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1477 1478 bar
1478 1479
1479 1480 $ killdaemons.py
1480 1481 #endif
@@ -1,426 +1,432
1 1 #require no-chg
2 2
3 3 #testcases bundle1 bundle2
4 4
5 5 #if bundle1
6 6 $ cat << EOF >> $HGRCPATH
7 7 > [devel]
8 8 > # This test is dedicated to interaction through old bundle
9 9 > legacy.exchange = bundle1
10 10 > EOF
11 11 #endif
12 12
13 13 $ hg init test
14 14 $ cd test
15 15 $ echo a > a
16 16 $ hg ci -Ama
17 17 adding a
18 18 $ cd ..
19 19 $ hg clone test test2
20 20 updating to branch default
21 21 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
22 22 $ cd test2
23 23 $ echo a >> a
24 24 $ hg ci -mb
25 25 $ req() {
26 26 > hg $1 serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
27 27 > cat hg.pid >> $DAEMON_PIDS
28 28 > hg --cwd ../test2 push http://localhost:$HGPORT/
29 29 > exitstatus=$?
30 30 > killdaemons.py
31 31 > echo % serve errors
32 32 > cat errors.log
33 33 > return $exitstatus
34 34 > }
35 35 $ cd ../test
36 36
37 37 expect ssl error
38 38
39 39 $ req
40 40 pushing to http://localhost:$HGPORT/
41 41 searching for changes
42 42 abort: HTTP Error 403: ssl required
43 43 % serve errors
44 44 [255]
45 45
46 46 expect authorization error
47 47
48 48 $ echo '[web]' > .hg/hgrc
49 49 $ echo 'push_ssl = false' >> .hg/hgrc
50 50 $ req
51 51 pushing to http://localhost:$HGPORT/
52 52 searching for changes
53 53 abort: authorization failed
54 54 % serve errors
55 55 [255]
56 56
57 57 expect authorization error: must have authorized user
58 58
59 59 $ echo 'allow_push = unperson' >> .hg/hgrc
60 60 $ req
61 61 pushing to http://localhost:$HGPORT/
62 62 searching for changes
63 63 abort: authorization failed
64 64 % serve errors
65 65 [255]
66 66
67 67 expect success
68 68
69 69 $ cat > $TESTTMP/hook.sh <<'EOF'
70 70 > echo "phase-move: $HG_NODE: $HG_OLDPHASE -> $HG_PHASE"
71 71 > EOF
72 72
73 73 #if bundle1
74 74 $ cat >> .hg/hgrc <<EOF
75 75 > allow_push = *
76 76 > [hooks]
77 77 > changegroup = sh -c "printenv.py changegroup 0"
78 78 > pushkey = sh -c "printenv.py pushkey 0"
79 79 > txnclose-phase.test = sh $TESTTMP/hook.sh
80 80 > EOF
81 81 $ req "--debug --config extensions.blackbox="
82 82 listening at http://*:$HGPORT/ (bound to $LOCALIP:$HGPORT) (glob) (?)
83 83 pushing to http://localhost:$HGPORT/
84 84 searching for changes
85 85 remote: redirecting incoming bundle to */hg-unbundle-* (glob)
86 86 remote: adding changesets
87 87 remote: add changeset ba677d0156c1
88 88 remote: adding manifests
89 89 remote: adding file changes
90 90 remote: adding a revisions
91 91 remote: added 1 changesets with 1 changes to 1 files
92 92 remote: updating the branch cache
93 remote: converting hook "txnclose-phase.test" to native (windows !)
93 94 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
94 95 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
96 remote: converting hook "txnclose-phase.test" to native (windows !)
95 97 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
96 98 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
99 remote: converting hook "changegroup" to native (windows !)
97 100 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
98 101 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
99 102 % serve errors
100 103 $ hg rollback
101 104 repository tip rolled back to revision 0 (undo serve)
102 105 $ req "--debug --config server.streamunbundle=True --config extensions.blackbox="
103 106 listening at http://*:$HGPORT/ (bound to $LOCALIP:$HGPORT) (glob) (?)
104 107 pushing to http://localhost:$HGPORT/
105 108 searching for changes
106 109 remote: adding changesets
107 110 remote: add changeset ba677d0156c1
108 111 remote: adding manifests
109 112 remote: adding file changes
110 113 remote: adding a revisions
111 114 remote: added 1 changesets with 1 changes to 1 files
112 115 remote: updating the branch cache
116 remote: converting hook "txnclose-phase.test" to native (windows !)
113 117 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
114 118 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
119 remote: converting hook "txnclose-phase.test" to native (windows !)
115 120 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
116 121 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
122 remote: converting hook "changegroup" to native (windows !)
117 123 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
118 124 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
119 125 % serve errors
120 126 $ hg rollback
121 127 repository tip rolled back to revision 0 (undo serve)
122 128 #endif
123 129
124 130 #if bundle2
125 131 $ cat >> .hg/hgrc <<EOF
126 132 > allow_push = *
127 133 > [hooks]
128 134 > changegroup = sh -c "printenv.py changegroup 0"
129 135 > pushkey = sh -c "printenv.py pushkey 0"
130 136 > txnclose-phase.test = sh $TESTTMP/hook.sh
131 137 > EOF
132 138 $ req
133 139 pushing to http://localhost:$HGPORT/
134 140 searching for changes
135 141 remote: adding changesets
136 142 remote: adding manifests
137 143 remote: adding file changes
138 144 remote: added 1 changesets with 1 changes to 1 files
139 145 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
140 146 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
141 147 remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
142 148 % serve errors
143 149 $ hg rollback
144 150 repository tip rolled back to revision 0 (undo serve)
145 151 #endif
146 152
147 153 expect success, server lacks the httpheader capability
148 154
149 155 $ CAP=httpheader
150 156 $ . "$TESTDIR/notcapable"
151 157 $ req
152 158 pushing to http://localhost:$HGPORT/
153 159 searching for changes
154 160 remote: adding changesets
155 161 remote: adding manifests
156 162 remote: adding file changes
157 163 remote: added 1 changesets with 1 changes to 1 files
158 164 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
159 165 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
160 166 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob) (bundle1 !)
161 167 remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob) (bundle2 !)
162 168 % serve errors
163 169 $ hg rollback
164 170 repository tip rolled back to revision 0 (undo serve)
165 171
166 172 expect success, server lacks the unbundlehash capability
167 173
168 174 $ CAP=unbundlehash
169 175 $ . "$TESTDIR/notcapable"
170 176 $ req
171 177 pushing to http://localhost:$HGPORT/
172 178 searching for changes
173 179 remote: adding changesets
174 180 remote: adding manifests
175 181 remote: adding file changes
176 182 remote: added 1 changesets with 1 changes to 1 files
177 183 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
178 184 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
179 185 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob) (bundle1 !)
180 186 remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob) (bundle2 !)
181 187 % serve errors
182 188 $ hg rollback
183 189 repository tip rolled back to revision 0 (undo serve)
184 190
185 191 expect success, pre-d1b16a746db6 server supports the unbundle capability, but
186 192 has no parameter
187 193
188 194 $ cat <<EOF > notcapable-unbundleparam.py
189 195 > from mercurial import extensions, httppeer
190 196 > def capable(orig, self, name):
191 197 > if name == 'unbundle':
192 198 > return True
193 199 > return orig(self, name)
194 200 > def uisetup(ui):
195 201 > extensions.wrapfunction(httppeer.httppeer, 'capable', capable)
196 202 > EOF
197 203 $ cp $HGRCPATH $HGRCPATH.orig
198 204 $ cat <<EOF >> $HGRCPATH
199 205 > [extensions]
200 206 > notcapable-unbundleparam = `pwd`/notcapable-unbundleparam.py
201 207 > EOF
202 208 $ req
203 209 pushing to http://localhost:$HGPORT/
204 210 searching for changes
205 211 remote: adding changesets
206 212 remote: adding manifests
207 213 remote: adding file changes
208 214 remote: added 1 changesets with 1 changes to 1 files
209 215 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
210 216 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
211 217 remote: changegroup hook: * (glob)
212 218 % serve errors
213 219 $ hg rollback
214 220 repository tip rolled back to revision 0 (undo serve)
215 221 $ mv $HGRCPATH.orig $HGRCPATH
216 222
217 223 Test pushing to a publishing repository with a failing prepushkey hook
218 224
219 225 $ cat > .hg/hgrc <<EOF
220 226 > [web]
221 227 > push_ssl = false
222 228 > allow_push = *
223 229 > [hooks]
224 230 > prepushkey = sh -c "printenv.py prepushkey 1"
225 231 > [devel]
226 232 > legacy.exchange=phases
227 233 > EOF
228 234
229 235 #if bundle1
230 236 Bundle1 works because a) phases are updated as part of changegroup application
231 237 and b) client checks phases after the "unbundle" command. Since it sees no
232 238 phase changes are necessary, it doesn't send the "pushkey" command and the
233 239 prepushkey hook never has to fire.
234 240
235 241 $ req
236 242 pushing to http://localhost:$HGPORT/
237 243 searching for changes
238 244 remote: adding changesets
239 245 remote: adding manifests
240 246 remote: adding file changes
241 247 remote: added 1 changesets with 1 changes to 1 files
242 248 % serve errors
243 249
244 250 #endif
245 251
246 252 #if bundle2
247 253 Bundle2 sends a "pushkey" bundle2 part. This runs as part of the transaction
248 254 and fails the entire push.
249 255 $ req
250 256 pushing to http://localhost:$HGPORT/
251 257 searching for changes
252 258 remote: adding changesets
253 259 remote: adding manifests
254 260 remote: adding file changes
255 261 remote: added 1 changesets with 1 changes to 1 files
256 262 remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
257 263 remote: pushkey-abort: prepushkey hook exited with status 1
258 264 remote: transaction abort!
259 265 remote: rollback completed
260 266 abort: updating ba677d0156c1 to public failed
261 267 % serve errors
262 268 [255]
263 269
264 270 #endif
265 271
266 272 Now remove the failing prepushkey hook.
267 273
268 274 $ cat >> .hg/hgrc <<EOF
269 275 > [hooks]
270 276 > prepushkey = sh -c "printenv.py prepushkey 0"
271 277 > EOF
272 278
273 279 We don't need to test bundle1 because it succeeded above.
274 280
275 281 #if bundle2
276 282 $ req
277 283 pushing to http://localhost:$HGPORT/
278 284 searching for changes
279 285 remote: adding changesets
280 286 remote: adding manifests
281 287 remote: adding file changes
282 288 remote: added 1 changesets with 1 changes to 1 files
283 289 remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
284 290 % serve errors
285 291 #endif
286 292
287 293 $ hg --config extensions.strip= strip -r 1:
288 294 saved backup bundle to $TESTTMP/test/.hg/strip-backup/ba677d0156c1-eea704d7-backup.hg
289 295
290 296 Now do a variant of the above, except on a non-publishing repository
291 297
292 298 $ cat >> .hg/hgrc <<EOF
293 299 > [phases]
294 300 > publish = false
295 301 > [hooks]
296 302 > prepushkey = sh -c "printenv.py prepushkey 1"
297 303 > EOF
298 304
299 305 #if bundle1
300 306 $ req
301 307 pushing to http://localhost:$HGPORT/
302 308 searching for changes
303 309 remote: adding changesets
304 310 remote: adding manifests
305 311 remote: adding file changes
306 312 remote: added 1 changesets with 1 changes to 1 files
307 313 remote: prepushkey hook: HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
308 314 remote: pushkey-abort: prepushkey hook exited with status 1
309 315 updating ba677d0156c1 to public failed!
310 316 % serve errors
311 317 #endif
312 318
313 319 #if bundle2
314 320 $ req
315 321 pushing to http://localhost:$HGPORT/
316 322 searching for changes
317 323 remote: adding changesets
318 324 remote: adding manifests
319 325 remote: adding file changes
320 326 remote: added 1 changesets with 1 changes to 1 files
321 327 remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
322 328 remote: pushkey-abort: prepushkey hook exited with status 1
323 329 remote: transaction abort!
324 330 remote: rollback completed
325 331 abort: updating ba677d0156c1 to public failed
326 332 % serve errors
327 333 [255]
328 334 #endif
329 335
330 336 Make phases updates work
331 337
332 338 $ cat >> .hg/hgrc <<EOF
333 339 > [hooks]
334 340 > prepushkey = sh -c "printenv.py prepushkey 0"
335 341 > EOF
336 342
337 343 #if bundle1
338 344 $ req
339 345 pushing to http://localhost:$HGPORT/
340 346 searching for changes
341 347 no changes found
342 348 remote: prepushkey hook: HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
343 349 % serve errors
344 350 [1]
345 351 #endif
346 352
347 353 #if bundle2
348 354 $ req
349 355 pushing to http://localhost:$HGPORT/
350 356 searching for changes
351 357 remote: adding changesets
352 358 remote: adding manifests
353 359 remote: adding file changes
354 360 remote: added 1 changesets with 1 changes to 1 files
355 361 remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
356 362 % serve errors
357 363 #endif
358 364
359 365 $ hg --config extensions.strip= strip -r 1:
360 366 saved backup bundle to $TESTTMP/test/.hg/strip-backup/ba677d0156c1-eea704d7-backup.hg
361 367
362 368 #if bundle2
363 369
364 370 $ cat > .hg/hgrc <<EOF
365 371 > [web]
366 372 > push_ssl = false
367 373 > allow_push = *
368 374 > [experimental]
369 375 > httppostargs=true
370 376 > EOF
371 377 $ req
372 378 pushing to http://localhost:$HGPORT/
373 379 searching for changes
374 380 remote: adding changesets
375 381 remote: adding manifests
376 382 remote: adding file changes
377 383 remote: added 1 changesets with 1 changes to 1 files
378 384 % serve errors
379 385
380 386 #endif
381 387
382 388 $ cd ..
383 389
384 390 Pushing via hgwebdir works
385 391
386 392 $ hg init hgwebdir
387 393 $ cd hgwebdir
388 394 $ echo 0 > a
389 395 $ hg -q commit -A -m initial
390 396 $ cd ..
391 397
392 398 $ cat > web.conf << EOF
393 399 > [paths]
394 400 > / = *
395 401 > [web]
396 402 > push_ssl = false
397 403 > allow_push = *
398 404 > EOF
399 405
400 406 $ hg serve --web-conf web.conf -p $HGPORT -d --pid-file hg.pid
401 407 $ cat hg.pid >> $DAEMON_PIDS
402 408
403 409 $ hg clone http://localhost:$HGPORT/hgwebdir hgwebdir-local
404 410 requesting all changes
405 411 adding changesets
406 412 adding manifests
407 413 adding file changes
408 414 added 1 changesets with 1 changes to 1 files
409 415 new changesets 98a3f8f02ba7
410 416 updating to branch default
411 417 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
412 418 $ cd hgwebdir-local
413 419 $ echo commit > a
414 420 $ hg commit -m 'local commit'
415 421
416 422 $ hg push
417 423 pushing to http://localhost:$HGPORT/hgwebdir
418 424 searching for changes
419 425 remote: adding changesets
420 426 remote: adding manifests
421 427 remote: adding file changes
422 428 remote: added 1 changesets with 1 changes to 1 files
423 429
424 430 $ killdaemons.py
425 431
426 432 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now