##// END OF EJS Templates
sparserevlog: document the config option...
Boris Feld -
r41524:261d37b9 stable
parent child Browse files
Show More
@@ -1,2766 +1,2776 b''
1 1 The Mercurial system uses a set of configuration files to control
2 2 aspects of its behavior.
3 3
4 4 Troubleshooting
5 5 ===============
6 6
7 7 If you're having problems with your configuration,
8 8 :hg:`config --debug` can help you understand what is introducing
9 9 a setting into your environment.
10 10
11 11 See :hg:`help config.syntax` and :hg:`help config.files`
12 12 for information about how and where to override things.
13 13
14 14 Structure
15 15 =========
16 16
17 17 The configuration files use a simple ini-file format. A configuration
18 18 file consists of sections, led by a ``[section]`` header and followed
19 19 by ``name = value`` entries::
20 20
21 21 [ui]
22 22 username = Firstname Lastname <firstname.lastname@example.net>
23 23 verbose = True
24 24
25 25 The above entries will be referred to as ``ui.username`` and
26 26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27 27
28 28 Files
29 29 =====
30 30
31 31 Mercurial reads configuration data from several files, if they exist.
32 32 These files do not exist by default and you will have to create the
33 33 appropriate configuration files yourself:
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 ``resolve.confirm``
442 442 Confirm before performing action if no filename is passed.
443 443 (default: False)
444 444
445 445 ``resolve.explicit-re-merge``
446 446 Require uses of ``hg resolve`` to specify which action it should perform,
447 447 instead of re-merging files by default.
448 448 (default: False)
449 449
450 450 ``resolve.mark-check``
451 451 Determines what level of checking :hg:`resolve --mark` will perform before
452 452 marking files as resolved. Valid values are ``none`, ``warn``, and
453 453 ``abort``. ``warn`` will output a warning listing the file(s) that still
454 454 have conflict markers in them, but will still mark everything resolved.
455 455 ``abort`` will output the same warning but will not mark things as resolved.
456 456 If --all is passed and this is set to ``abort``, only a warning will be
457 457 shown (an error will not be raised).
458 458 (default: ``none``)
459 459
460 460 ``status.relative``
461 461 Make paths in :hg:`status` output relative to the current directory.
462 462 (default: False)
463 463
464 464 ``status.terse``
465 465 Default value for the --terse flag, which condenses status output.
466 466 (default: empty)
467 467
468 468 ``update.check``
469 469 Determines what level of checking :hg:`update` will perform before moving
470 470 to a destination revision. Valid values are ``abort``, ``none``,
471 471 ``linear``, and ``noconflict``. ``abort`` always fails if the working
472 472 directory has uncommitted changes. ``none`` performs no checking, and may
473 473 result in a merge with uncommitted changes. ``linear`` allows any update
474 474 as long as it follows a straight line in the revision history, and may
475 475 trigger a merge with uncommitted changes. ``noconflict`` will allow any
476 476 update which would not trigger a merge with uncommitted changes, if any
477 477 are present.
478 478 (default: ``linear``)
479 479
480 480 ``update.requiredest``
481 481 Require that the user pass a destination when running :hg:`update`.
482 482 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
483 483 will be disallowed.
484 484 (default: False)
485 485
486 486 ``committemplate``
487 487 ------------------
488 488
489 489 ``changeset``
490 490 String: configuration in this section is used as the template to
491 491 customize the text shown in the editor when committing.
492 492
493 493 In addition to pre-defined template keywords, commit log specific one
494 494 below can be used for customization:
495 495
496 496 ``extramsg``
497 497 String: Extra message (typically 'Leave message empty to abort
498 498 commit.'). This may be changed by some commands or extensions.
499 499
500 500 For example, the template configuration below shows as same text as
501 501 one shown by default::
502 502
503 503 [committemplate]
504 504 changeset = {desc}\n\n
505 505 HG: Enter commit message. Lines beginning with 'HG:' are removed.
506 506 HG: {extramsg}
507 507 HG: --
508 508 HG: user: {author}\n{ifeq(p2rev, "-1", "",
509 509 "HG: branch merge\n")
510 510 }HG: branch '{branch}'\n{if(activebookmark,
511 511 "HG: bookmark '{activebookmark}'\n") }{subrepos %
512 512 "HG: subrepo {subrepo}\n" }{file_adds %
513 513 "HG: added {file}\n" }{file_mods %
514 514 "HG: changed {file}\n" }{file_dels %
515 515 "HG: removed {file}\n" }{if(files, "",
516 516 "HG: no files changed\n")}
517 517
518 518 ``diff()``
519 519 String: show the diff (see :hg:`help templates` for detail)
520 520
521 521 Sometimes it is helpful to show the diff of the changeset in the editor without
522 522 having to prefix 'HG: ' to each line so that highlighting works correctly. For
523 523 this, Mercurial provides a special string which will ignore everything below
524 524 it::
525 525
526 526 HG: ------------------------ >8 ------------------------
527 527
528 528 For example, the template configuration below will show the diff below the
529 529 extra message::
530 530
531 531 [committemplate]
532 532 changeset = {desc}\n\n
533 533 HG: Enter commit message. Lines beginning with 'HG:' are removed.
534 534 HG: {extramsg}
535 535 HG: ------------------------ >8 ------------------------
536 536 HG: Do not touch the line above.
537 537 HG: Everything below will be removed.
538 538 {diff()}
539 539
540 540 .. note::
541 541
542 542 For some problematic encodings (see :hg:`help win32mbcs` for
543 543 detail), this customization should be configured carefully, to
544 544 avoid showing broken characters.
545 545
546 546 For example, if a multibyte character ending with backslash (0x5c) is
547 547 followed by the ASCII character 'n' in the customized template,
548 548 the sequence of backslash and 'n' is treated as line-feed unexpectedly
549 549 (and the multibyte character is broken, too).
550 550
551 551 Customized template is used for commands below (``--edit`` may be
552 552 required):
553 553
554 554 - :hg:`backout`
555 555 - :hg:`commit`
556 556 - :hg:`fetch` (for merge commit only)
557 557 - :hg:`graft`
558 558 - :hg:`histedit`
559 559 - :hg:`import`
560 560 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
561 561 - :hg:`rebase`
562 562 - :hg:`shelve`
563 563 - :hg:`sign`
564 564 - :hg:`tag`
565 565 - :hg:`transplant`
566 566
567 567 Configuring items below instead of ``changeset`` allows showing
568 568 customized message only for specific actions, or showing different
569 569 messages for each action.
570 570
571 571 - ``changeset.backout`` for :hg:`backout`
572 572 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
573 573 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
574 574 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
575 575 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
576 576 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
577 577 - ``changeset.gpg.sign`` for :hg:`sign`
578 578 - ``changeset.graft`` for :hg:`graft`
579 579 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
580 580 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
581 581 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
582 582 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
583 583 - ``changeset.import.bypass`` for :hg:`import --bypass`
584 584 - ``changeset.import.normal.merge`` for :hg:`import` on merges
585 585 - ``changeset.import.normal.normal`` for :hg:`import` on other
586 586 - ``changeset.mq.qnew`` for :hg:`qnew`
587 587 - ``changeset.mq.qfold`` for :hg:`qfold`
588 588 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
589 589 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
590 590 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
591 591 - ``changeset.rebase.normal`` for :hg:`rebase` on other
592 592 - ``changeset.shelve.shelve`` for :hg:`shelve`
593 593 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
594 594 - ``changeset.tag.remove`` for :hg:`tag --remove`
595 595 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
596 596 - ``changeset.transplant.normal`` for :hg:`transplant` on other
597 597
598 598 These dot-separated lists of names are treated as hierarchical ones.
599 599 For example, ``changeset.tag.remove`` customizes the commit message
600 600 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
601 601 commit message for :hg:`tag` regardless of ``--remove`` option.
602 602
603 603 When the external editor is invoked for a commit, the corresponding
604 604 dot-separated list of names without the ``changeset.`` prefix
605 605 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
606 606 variable.
607 607
608 608 In this section, items other than ``changeset`` can be referred from
609 609 others. For example, the configuration to list committed files up
610 610 below can be referred as ``{listupfiles}``::
611 611
612 612 [committemplate]
613 613 listupfiles = {file_adds %
614 614 "HG: added {file}\n" }{file_mods %
615 615 "HG: changed {file}\n" }{file_dels %
616 616 "HG: removed {file}\n" }{if(files, "",
617 617 "HG: no files changed\n")}
618 618
619 619 ``decode/encode``
620 620 -----------------
621 621
622 622 Filters for transforming files on checkout/checkin. This would
623 623 typically be used for newline processing or other
624 624 localization/canonicalization of files.
625 625
626 626 Filters consist of a filter pattern followed by a filter command.
627 627 Filter patterns are globs by default, rooted at the repository root.
628 628 For example, to match any file ending in ``.txt`` in the root
629 629 directory only, use the pattern ``*.txt``. To match any file ending
630 630 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
631 631 For each file only the first matching filter applies.
632 632
633 633 The filter command can start with a specifier, either ``pipe:`` or
634 634 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
635 635
636 636 A ``pipe:`` command must accept data on stdin and return the transformed
637 637 data on stdout.
638 638
639 639 Pipe example::
640 640
641 641 [encode]
642 642 # uncompress gzip files on checkin to improve delta compression
643 643 # note: not necessarily a good idea, just an example
644 644 *.gz = pipe: gunzip
645 645
646 646 [decode]
647 647 # recompress gzip files when writing them to the working dir (we
648 648 # can safely omit "pipe:", because it's the default)
649 649 *.gz = gzip
650 650
651 651 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
652 652 with the name of a temporary file that contains the data to be
653 653 filtered by the command. The string ``OUTFILE`` is replaced with the name
654 654 of an empty temporary file, where the filtered data must be written by
655 655 the command.
656 656
657 657 .. container:: windows
658 658
659 659 .. note::
660 660
661 661 The tempfile mechanism is recommended for Windows systems,
662 662 where the standard shell I/O redirection operators often have
663 663 strange effects and may corrupt the contents of your files.
664 664
665 665 This filter mechanism is used internally by the ``eol`` extension to
666 666 translate line ending characters between Windows (CRLF) and Unix (LF)
667 667 format. We suggest you use the ``eol`` extension for convenience.
668 668
669 669
670 670 ``defaults``
671 671 ------------
672 672
673 673 (defaults are deprecated. Don't use them. Use aliases instead.)
674 674
675 675 Use the ``[defaults]`` section to define command defaults, i.e. the
676 676 default options/arguments to pass to the specified commands.
677 677
678 678 The following example makes :hg:`log` run in verbose mode, and
679 679 :hg:`status` show only the modified files, by default::
680 680
681 681 [defaults]
682 682 log = -v
683 683 status = -m
684 684
685 685 The actual commands, instead of their aliases, must be used when
686 686 defining command defaults. The command defaults will also be applied
687 687 to the aliases of the commands defined.
688 688
689 689
690 690 ``diff``
691 691 --------
692 692
693 693 Settings used when displaying diffs. Everything except for ``unified``
694 694 is a Boolean and defaults to False. See :hg:`help config.annotate`
695 695 for related options for the annotate command.
696 696
697 697 ``git``
698 698 Use git extended diff format.
699 699
700 700 ``nobinary``
701 701 Omit git binary patches.
702 702
703 703 ``nodates``
704 704 Don't include dates in diff headers.
705 705
706 706 ``noprefix``
707 707 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
708 708
709 709 ``showfunc``
710 710 Show which function each change is in.
711 711
712 712 ``ignorews``
713 713 Ignore white space when comparing lines.
714 714
715 715 ``ignorewsamount``
716 716 Ignore changes in the amount of white space.
717 717
718 718 ``ignoreblanklines``
719 719 Ignore changes whose lines are all blank.
720 720
721 721 ``unified``
722 722 Number of lines of context to show.
723 723
724 724 ``word-diff``
725 725 Highlight changed words.
726 726
727 727 ``email``
728 728 ---------
729 729
730 730 Settings for extensions that send email messages.
731 731
732 732 ``from``
733 733 Optional. Email address to use in "From" header and SMTP envelope
734 734 of outgoing messages.
735 735
736 736 ``to``
737 737 Optional. Comma-separated list of recipients' email addresses.
738 738
739 739 ``cc``
740 740 Optional. Comma-separated list of carbon copy recipients'
741 741 email addresses.
742 742
743 743 ``bcc``
744 744 Optional. Comma-separated list of blind carbon copy recipients'
745 745 email addresses.
746 746
747 747 ``method``
748 748 Optional. Method to use to send email messages. If value is ``smtp``
749 749 (default), use SMTP (see the ``[smtp]`` section for configuration).
750 750 Otherwise, use as name of program to run that acts like sendmail
751 751 (takes ``-f`` option for sender, list of recipients on command line,
752 752 message on stdin). Normally, setting this to ``sendmail`` or
753 753 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
754 754
755 755 ``charsets``
756 756 Optional. Comma-separated list of character sets considered
757 757 convenient for recipients. Addresses, headers, and parts not
758 758 containing patches of outgoing messages will be encoded in the
759 759 first character set to which conversion from local encoding
760 760 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
761 761 conversion fails, the text in question is sent as is.
762 762 (default: '')
763 763
764 764 Order of outgoing email character sets:
765 765
766 766 1. ``us-ascii``: always first, regardless of settings
767 767 2. ``email.charsets``: in order given by user
768 768 3. ``ui.fallbackencoding``: if not in email.charsets
769 769 4. ``$HGENCODING``: if not in email.charsets
770 770 5. ``utf-8``: always last, regardless of settings
771 771
772 772 Email example::
773 773
774 774 [email]
775 775 from = Joseph User <joe.user@example.com>
776 776 method = /usr/sbin/sendmail
777 777 # charsets for western Europeans
778 778 # us-ascii, utf-8 omitted, as they are tried first and last
779 779 charsets = iso-8859-1, iso-8859-15, windows-1252
780 780
781 781
782 782 ``extensions``
783 783 --------------
784 784
785 785 Mercurial has an extension mechanism for adding new features. To
786 786 enable an extension, create an entry for it in this section.
787 787
788 788 If you know that the extension is already in Python's search path,
789 789 you can give the name of the module, followed by ``=``, with nothing
790 790 after the ``=``.
791 791
792 792 Otherwise, give a name that you choose, followed by ``=``, followed by
793 793 the path to the ``.py`` file (including the file name extension) that
794 794 defines the extension.
795 795
796 796 To explicitly disable an extension that is enabled in an hgrc of
797 797 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
798 798 or ``foo = !`` when path is not supplied.
799 799
800 800 Example for ``~/.hgrc``::
801 801
802 802 [extensions]
803 803 # (the churn extension will get loaded from Mercurial's path)
804 804 churn =
805 805 # (this extension will get loaded from the file specified)
806 806 myfeature = ~/.hgext/myfeature.py
807 807
808 808
809 809 ``format``
810 810 ----------
811 811
812 812 Configuration that controls the repository format. Newer format options are more
813 813 powerful but incompatible with some older versions of Mercurial. Format options
814 814 are considered at repository initialization only. You need to make a new clone
815 815 for config change to be taken into account.
816 816
817 817 For more details about repository format and version compatibility, see
818 818 https://www.mercurial-scm.org/wiki/MissingRequirement
819 819
820 820 ``usegeneraldelta``
821 821 Enable or disable the "generaldelta" repository format which improves
822 822 repository compression by allowing "revlog" to store delta against arbitrary
823 823 revision instead of the previous stored one. This provides significant
824 824 improvement for repositories with branches.
825 825
826 826 Repositories with this on-disk format require Mercurial version 1.9.
827 827
828 828 Enabled by default.
829 829
830 830 ``dotencode``
831 831 Enable or disable the "dotencode" repository format which enhances
832 832 the "fncache" repository format (which has to be enabled to use
833 833 dotencode) to avoid issues with filenames starting with ._ on
834 834 Mac OS X and spaces on Windows.
835 835
836 836 Repositories with this on-disk format require Mercurial version 1.7.
837 837
838 838 Enabled by default.
839 839
840 840 ``usefncache``
841 841 Enable or disable the "fncache" repository format which enhances
842 842 the "store" repository format (which has to be enabled to use
843 843 fncache) to allow longer filenames and avoids using Windows
844 844 reserved names, e.g. "nul".
845 845
846 846 Repositories with this on-disk format require Mercurial version 1.1.
847 847
848 848 Enabled by default.
849 849
850 850 ``usestore``
851 851 Enable or disable the "store" repository format which improves
852 852 compatibility with systems that fold case or otherwise mangle
853 853 filenames. Disabling this option will allow you to store longer filenames
854 854 in some situations at the expense of compatibility.
855 855
856 856 Repositories with this on-disk format require Mercurial version 0.9.4.
857 857
858 858 Enabled by default.
859 859
860 ``sparse-revlog``
861 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
862 delta re-use inside revlog. For very branchy repositories, it results in a
863 smaller store. For repositories with many revisions, it also helps
864 performance (by using shortened delta chains.)
865
866 Repositories with this on-disk format require Mercurial version 4.7
867
868 Enabled by default.
869
860 870 ``graph``
861 871 ---------
862 872
863 873 Web graph view configuration. This section let you change graph
864 874 elements display properties by branches, for instance to make the
865 875 ``default`` branch stand out.
866 876
867 877 Each line has the following format::
868 878
869 879 <branch>.<argument> = <value>
870 880
871 881 where ``<branch>`` is the name of the branch being
872 882 customized. Example::
873 883
874 884 [graph]
875 885 # 2px width
876 886 default.width = 2
877 887 # red color
878 888 default.color = FF0000
879 889
880 890 Supported arguments:
881 891
882 892 ``width``
883 893 Set branch edges width in pixels.
884 894
885 895 ``color``
886 896 Set branch edges color in hexadecimal RGB notation.
887 897
888 898 ``hooks``
889 899 ---------
890 900
891 901 Commands or Python functions that get automatically executed by
892 902 various actions such as starting or finishing a commit. Multiple
893 903 hooks can be run for the same action by appending a suffix to the
894 904 action. Overriding a site-wide hook can be done by changing its
895 905 value or setting it to an empty string. Hooks can be prioritized
896 906 by adding a prefix of ``priority.`` to the hook name on a new line
897 907 and setting the priority. The default priority is 0.
898 908
899 909 Example ``.hg/hgrc``::
900 910
901 911 [hooks]
902 912 # update working directory after adding changesets
903 913 changegroup.update = hg update
904 914 # do not use the site-wide hook
905 915 incoming =
906 916 incoming.email = /my/email/hook
907 917 incoming.autobuild = /my/build/hook
908 918 # force autobuild hook to run before other incoming hooks
909 919 priority.incoming.autobuild = 1
910 920
911 921 Most hooks are run with environment variables set that give useful
912 922 additional information. For each hook below, the environment variables
913 923 it is passed are listed with names in the form ``$HG_foo``. The
914 924 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
915 925 They contain the type of hook which triggered the run and the full name
916 926 of the hook in the config, respectively. In the example above, this will
917 927 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
918 928
919 929 .. container:: windows
920 930
921 931 Some basic Unix syntax can be enabled for portability, including ``$VAR``
922 932 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
923 933 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
924 934 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
925 935 slash or inside of a strong quote. Strong quotes will be replaced by
926 936 double quotes after processing.
927 937
928 938 This feature is enabled by adding a prefix of ``tonative.`` to the hook
929 939 name on a new line, and setting it to ``True``. For example::
930 940
931 941 [hooks]
932 942 incoming.autobuild = /my/build/hook
933 943 # enable translation to cmd.exe syntax for autobuild hook
934 944 tonative.incoming.autobuild = True
935 945
936 946 ``changegroup``
937 947 Run after a changegroup has been added via push, pull or unbundle. The ID of
938 948 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
939 949 The URL from which changes came is in ``$HG_URL``.
940 950
941 951 ``commit``
942 952 Run after a changeset has been created in the local repository. The ID
943 953 of the newly created changeset is in ``$HG_NODE``. Parent changeset
944 954 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
945 955
946 956 ``incoming``
947 957 Run after a changeset has been pulled, pushed, or unbundled into
948 958 the local repository. The ID of the newly arrived changeset is in
949 959 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
950 960
951 961 ``outgoing``
952 962 Run after sending changes from the local repository to another. The ID of
953 963 first changeset sent is in ``$HG_NODE``. The source of operation is in
954 964 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
955 965
956 966 ``post-<command>``
957 967 Run after successful invocations of the associated command. The
958 968 contents of the command line are passed as ``$HG_ARGS`` and the result
959 969 code in ``$HG_RESULT``. Parsed command line arguments are passed as
960 970 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
961 971 the python data internally passed to <command>. ``$HG_OPTS`` is a
962 972 dictionary of options (with unspecified options set to their defaults).
963 973 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
964 974
965 975 ``fail-<command>``
966 976 Run after a failed invocation of an associated command. The contents
967 977 of the command line are passed as ``$HG_ARGS``. Parsed command line
968 978 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
969 979 string representations of the python data internally passed to
970 980 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
971 981 options set to their defaults). ``$HG_PATS`` is a list of arguments.
972 982 Hook failure is ignored.
973 983
974 984 ``pre-<command>``
975 985 Run before executing the associated command. The contents of the
976 986 command line are passed as ``$HG_ARGS``. Parsed command line arguments
977 987 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
978 988 representations of the data internally passed to <command>. ``$HG_OPTS``
979 989 is a dictionary of options (with unspecified options set to their
980 990 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
981 991 failure, the command doesn't execute and Mercurial returns the failure
982 992 code.
983 993
984 994 ``prechangegroup``
985 995 Run before a changegroup is added via push, pull or unbundle. Exit
986 996 status 0 allows the changegroup to proceed. A non-zero status will
987 997 cause the push, pull or unbundle to fail. The URL from which changes
988 998 will come is in ``$HG_URL``.
989 999
990 1000 ``precommit``
991 1001 Run before starting a local commit. Exit status 0 allows the
992 1002 commit to proceed. A non-zero status will cause the commit to fail.
993 1003 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
994 1004
995 1005 ``prelistkeys``
996 1006 Run before listing pushkeys (like bookmarks) in the
997 1007 repository. A non-zero status will cause failure. The key namespace is
998 1008 in ``$HG_NAMESPACE``.
999 1009
1000 1010 ``preoutgoing``
1001 1011 Run before collecting changes to send from the local repository to
1002 1012 another. A non-zero status will cause failure. This lets you prevent
1003 1013 pull over HTTP or SSH. It can also prevent propagating commits (via
1004 1014 local pull, push (outbound) or bundle commands), but not completely,
1005 1015 since you can just copy files instead. The source of operation is in
1006 1016 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1007 1017 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1008 1018 is happening on behalf of a repository on same system.
1009 1019
1010 1020 ``prepushkey``
1011 1021 Run before a pushkey (like a bookmark) is added to the
1012 1022 repository. A non-zero status will cause the key to be rejected. The
1013 1023 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1014 1024 the old value (if any) is in ``$HG_OLD``, and the new value is in
1015 1025 ``$HG_NEW``.
1016 1026
1017 1027 ``pretag``
1018 1028 Run before creating a tag. Exit status 0 allows the tag to be
1019 1029 created. A non-zero status will cause the tag to fail. The ID of the
1020 1030 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1021 1031 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1022 1032
1023 1033 ``pretxnopen``
1024 1034 Run before any new repository transaction is open. The reason for the
1025 1035 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1026 1036 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
1027 1037 transaction from being opened.
1028 1038
1029 1039 ``pretxnclose``
1030 1040 Run right before the transaction is actually finalized. Any repository change
1031 1041 will be visible to the hook program. This lets you validate the transaction
1032 1042 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1033 1043 status will cause the transaction to be rolled back. The reason for the
1034 1044 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1035 1045 the transaction will be in ``HG_TXNID``. The rest of the available data will
1036 1046 vary according the transaction type. New changesets will add ``$HG_NODE``
1037 1047 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1038 1048 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1039 1049 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1040 1050 respectively, etc.
1041 1051
1042 1052 ``pretxnclose-bookmark``
1043 1053 Run right before a bookmark change is actually finalized. Any repository
1044 1054 change will be visible to the hook program. This lets you validate the
1045 1055 transaction content or change it. Exit status 0 allows the commit to
1046 1056 proceed. A non-zero status will cause the transaction to be rolled back.
1047 1057 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1048 1058 bookmark location will be available in ``$HG_NODE`` while the previous
1049 1059 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1050 1060 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1051 1061 will be empty.
1052 1062 In addition, the reason for the transaction opening will be in
1053 1063 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1054 1064 ``HG_TXNID``.
1055 1065
1056 1066 ``pretxnclose-phase``
1057 1067 Run right before a phase change is actually finalized. Any repository change
1058 1068 will be visible to the hook program. This lets you validate the transaction
1059 1069 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1060 1070 status will cause the transaction to be rolled back. The hook is called
1061 1071 multiple times, once for each revision affected by a phase change.
1062 1072 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1063 1073 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1064 1074 will be empty. In addition, the reason for the transaction opening will be in
1065 1075 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1066 1076 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1067 1077 the ``$HG_OLDPHASE`` entry will be empty.
1068 1078
1069 1079 ``txnclose``
1070 1080 Run after any repository transaction has been committed. At this
1071 1081 point, the transaction can no longer be rolled back. The hook will run
1072 1082 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1073 1083 details about available variables.
1074 1084
1075 1085 ``txnclose-bookmark``
1076 1086 Run after any bookmark change has been committed. At this point, the
1077 1087 transaction can no longer be rolled back. The hook will run after the lock
1078 1088 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1079 1089 about available variables.
1080 1090
1081 1091 ``txnclose-phase``
1082 1092 Run after any phase change has been committed. At this point, the
1083 1093 transaction can no longer be rolled back. The hook will run after the lock
1084 1094 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1085 1095 available variables.
1086 1096
1087 1097 ``txnabort``
1088 1098 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1089 1099 for details about available variables.
1090 1100
1091 1101 ``pretxnchangegroup``
1092 1102 Run after a changegroup has been added via push, pull or unbundle, but before
1093 1103 the transaction has been committed. The changegroup is visible to the hook
1094 1104 program. This allows validation of incoming changes before accepting them.
1095 1105 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1096 1106 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1097 1107 status will cause the transaction to be rolled back, and the push, pull or
1098 1108 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1099 1109
1100 1110 ``pretxncommit``
1101 1111 Run after a changeset has been created, but before the transaction is
1102 1112 committed. The changeset is visible to the hook program. This allows
1103 1113 validation of the commit message and changes. Exit status 0 allows the
1104 1114 commit to proceed. A non-zero status will cause the transaction to
1105 1115 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1106 1116 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1107 1117
1108 1118 ``preupdate``
1109 1119 Run before updating the working directory. Exit status 0 allows
1110 1120 the update to proceed. A non-zero status will prevent the update.
1111 1121 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1112 1122 merge, the ID of second new parent is in ``$HG_PARENT2``.
1113 1123
1114 1124 ``listkeys``
1115 1125 Run after listing pushkeys (like bookmarks) in the repository. The
1116 1126 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1117 1127 dictionary containing the keys and values.
1118 1128
1119 1129 ``pushkey``
1120 1130 Run after a pushkey (like a bookmark) is added to the
1121 1131 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1122 1132 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1123 1133 value is in ``$HG_NEW``.
1124 1134
1125 1135 ``tag``
1126 1136 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1127 1137 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1128 1138 the repository if ``$HG_LOCAL=0``.
1129 1139
1130 1140 ``update``
1131 1141 Run after updating the working directory. The changeset ID of first
1132 1142 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1133 1143 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1134 1144 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1135 1145
1136 1146 .. note::
1137 1147
1138 1148 It is generally better to use standard hooks rather than the
1139 1149 generic pre- and post- command hooks, as they are guaranteed to be
1140 1150 called in the appropriate contexts for influencing transactions.
1141 1151 Also, hooks like "commit" will be called in all contexts that
1142 1152 generate a commit (e.g. tag) and not just the commit command.
1143 1153
1144 1154 .. note::
1145 1155
1146 1156 Environment variables with empty values may not be passed to
1147 1157 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1148 1158 will have an empty value under Unix-like platforms for non-merge
1149 1159 changesets, while it will not be available at all under Windows.
1150 1160
1151 1161 The syntax for Python hooks is as follows::
1152 1162
1153 1163 hookname = python:modulename.submodule.callable
1154 1164 hookname = python:/path/to/python/module.py:callable
1155 1165
1156 1166 Python hooks are run within the Mercurial process. Each hook is
1157 1167 called with at least three keyword arguments: a ui object (keyword
1158 1168 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1159 1169 keyword that tells what kind of hook is used. Arguments listed as
1160 1170 environment variables above are passed as keyword arguments, with no
1161 1171 ``HG_`` prefix, and names in lower case.
1162 1172
1163 1173 If a Python hook returns a "true" value or raises an exception, this
1164 1174 is treated as a failure.
1165 1175
1166 1176
1167 1177 ``hostfingerprints``
1168 1178 --------------------
1169 1179
1170 1180 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1171 1181
1172 1182 Fingerprints of the certificates of known HTTPS servers.
1173 1183
1174 1184 A HTTPS connection to a server with a fingerprint configured here will
1175 1185 only succeed if the servers certificate matches the fingerprint.
1176 1186 This is very similar to how ssh known hosts works.
1177 1187
1178 1188 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1179 1189 Multiple values can be specified (separated by spaces or commas). This can
1180 1190 be used to define both old and new fingerprints while a host transitions
1181 1191 to a new certificate.
1182 1192
1183 1193 The CA chain and web.cacerts is not used for servers with a fingerprint.
1184 1194
1185 1195 For example::
1186 1196
1187 1197 [hostfingerprints]
1188 1198 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1189 1199 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1190 1200
1191 1201 ``hostsecurity``
1192 1202 ----------------
1193 1203
1194 1204 Used to specify global and per-host security settings for connecting to
1195 1205 other machines.
1196 1206
1197 1207 The following options control default behavior for all hosts.
1198 1208
1199 1209 ``ciphers``
1200 1210 Defines the cryptographic ciphers to use for connections.
1201 1211
1202 1212 Value must be a valid OpenSSL Cipher List Format as documented at
1203 1213 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1204 1214
1205 1215 This setting is for advanced users only. Setting to incorrect values
1206 1216 can significantly lower connection security or decrease performance.
1207 1217 You have been warned.
1208 1218
1209 1219 This option requires Python 2.7.
1210 1220
1211 1221 ``minimumprotocol``
1212 1222 Defines the minimum channel encryption protocol to use.
1213 1223
1214 1224 By default, the highest version of TLS supported by both client and server
1215 1225 is used.
1216 1226
1217 1227 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1218 1228
1219 1229 When running on an old Python version, only ``tls1.0`` is allowed since
1220 1230 old versions of Python only support up to TLS 1.0.
1221 1231
1222 1232 When running a Python that supports modern TLS versions, the default is
1223 1233 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1224 1234 weakens security and should only be used as a feature of last resort if
1225 1235 a server does not support TLS 1.1+.
1226 1236
1227 1237 Options in the ``[hostsecurity]`` section can have the form
1228 1238 ``hostname``:``setting``. This allows multiple settings to be defined on a
1229 1239 per-host basis.
1230 1240
1231 1241 The following per-host settings can be defined.
1232 1242
1233 1243 ``ciphers``
1234 1244 This behaves like ``ciphers`` as described above except it only applies
1235 1245 to the host on which it is defined.
1236 1246
1237 1247 ``fingerprints``
1238 1248 A list of hashes of the DER encoded peer/remote certificate. Values have
1239 1249 the form ``algorithm``:``fingerprint``. e.g.
1240 1250 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1241 1251 In addition, colons (``:``) can appear in the fingerprint part.
1242 1252
1243 1253 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1244 1254 ``sha512``.
1245 1255
1246 1256 Use of ``sha256`` or ``sha512`` is preferred.
1247 1257
1248 1258 If a fingerprint is specified, the CA chain is not validated for this
1249 1259 host and Mercurial will require the remote certificate to match one
1250 1260 of the fingerprints specified. This means if the server updates its
1251 1261 certificate, Mercurial will abort until a new fingerprint is defined.
1252 1262 This can provide stronger security than traditional CA-based validation
1253 1263 at the expense of convenience.
1254 1264
1255 1265 This option takes precedence over ``verifycertsfile``.
1256 1266
1257 1267 ``minimumprotocol``
1258 1268 This behaves like ``minimumprotocol`` as described above except it
1259 1269 only applies to the host on which it is defined.
1260 1270
1261 1271 ``verifycertsfile``
1262 1272 Path to file a containing a list of PEM encoded certificates used to
1263 1273 verify the server certificate. Environment variables and ``~user``
1264 1274 constructs are expanded in the filename.
1265 1275
1266 1276 The server certificate or the certificate's certificate authority (CA)
1267 1277 must match a certificate from this file or certificate verification
1268 1278 will fail and connections to the server will be refused.
1269 1279
1270 1280 If defined, only certificates provided by this file will be used:
1271 1281 ``web.cacerts`` and any system/default certificates will not be
1272 1282 used.
1273 1283
1274 1284 This option has no effect if the per-host ``fingerprints`` option
1275 1285 is set.
1276 1286
1277 1287 The format of the file is as follows::
1278 1288
1279 1289 -----BEGIN CERTIFICATE-----
1280 1290 ... (certificate in base64 PEM encoding) ...
1281 1291 -----END CERTIFICATE-----
1282 1292 -----BEGIN CERTIFICATE-----
1283 1293 ... (certificate in base64 PEM encoding) ...
1284 1294 -----END CERTIFICATE-----
1285 1295
1286 1296 For example::
1287 1297
1288 1298 [hostsecurity]
1289 1299 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1290 1300 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
1291 1301 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
1292 1302 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1293 1303
1294 1304 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1295 1305 when connecting to ``hg.example.com``::
1296 1306
1297 1307 [hostsecurity]
1298 1308 minimumprotocol = tls1.2
1299 1309 hg.example.com:minimumprotocol = tls1.1
1300 1310
1301 1311 ``http_proxy``
1302 1312 --------------
1303 1313
1304 1314 Used to access web-based Mercurial repositories through a HTTP
1305 1315 proxy.
1306 1316
1307 1317 ``host``
1308 1318 Host name and (optional) port of the proxy server, for example
1309 1319 "myproxy:8000".
1310 1320
1311 1321 ``no``
1312 1322 Optional. Comma-separated list of host names that should bypass
1313 1323 the proxy.
1314 1324
1315 1325 ``passwd``
1316 1326 Optional. Password to authenticate with at the proxy server.
1317 1327
1318 1328 ``user``
1319 1329 Optional. User name to authenticate with at the proxy server.
1320 1330
1321 1331 ``always``
1322 1332 Optional. Always use the proxy, even for localhost and any entries
1323 1333 in ``http_proxy.no``. (default: False)
1324 1334
1325 1335 ``http``
1326 1336 ----------
1327 1337
1328 1338 Used to configure access to Mercurial repositories via HTTP.
1329 1339
1330 1340 ``timeout``
1331 1341 If set, blocking operations will timeout after that many seconds.
1332 1342 (default: None)
1333 1343
1334 1344 ``merge``
1335 1345 ---------
1336 1346
1337 1347 This section specifies behavior during merges and updates.
1338 1348
1339 1349 ``checkignored``
1340 1350 Controls behavior when an ignored file on disk has the same name as a tracked
1341 1351 file in the changeset being merged or updated to, and has different
1342 1352 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1343 1353 abort on such files. With ``warn``, warn on such files and back them up as
1344 1354 ``.orig``. With ``ignore``, don't print a warning and back them up as
1345 1355 ``.orig``. (default: ``abort``)
1346 1356
1347 1357 ``checkunknown``
1348 1358 Controls behavior when an unknown file that isn't ignored has the same name
1349 1359 as a tracked file in the changeset being merged or updated to, and has
1350 1360 different contents. Similar to ``merge.checkignored``, except for files that
1351 1361 are not ignored. (default: ``abort``)
1352 1362
1353 1363 ``on-failure``
1354 1364 When set to ``continue`` (the default), the merge process attempts to
1355 1365 merge all unresolved files using the merge chosen tool, regardless of
1356 1366 whether previous file merge attempts during the process succeeded or not.
1357 1367 Setting this to ``prompt`` will prompt after any merge failure continue
1358 1368 or halt the merge process. Setting this to ``halt`` will automatically
1359 1369 halt the merge process on any merge tool failure. The merge process
1360 1370 can be restarted by using the ``resolve`` command. When a merge is
1361 1371 halted, the repository is left in a normal ``unresolved`` merge state.
1362 1372 (default: ``continue``)
1363 1373
1364 1374 ``strict-capability-check``
1365 1375 Whether capabilities of internal merge tools are checked strictly
1366 1376 or not, while examining rules to decide merge tool to be used.
1367 1377 (default: False)
1368 1378
1369 1379 ``merge-patterns``
1370 1380 ------------------
1371 1381
1372 1382 This section specifies merge tools to associate with particular file
1373 1383 patterns. Tools matched here will take precedence over the default
1374 1384 merge tool. Patterns are globs by default, rooted at the repository
1375 1385 root.
1376 1386
1377 1387 Example::
1378 1388
1379 1389 [merge-patterns]
1380 1390 **.c = kdiff3
1381 1391 **.jpg = myimgmerge
1382 1392
1383 1393 ``merge-tools``
1384 1394 ---------------
1385 1395
1386 1396 This section configures external merge tools to use for file-level
1387 1397 merges. This section has likely been preconfigured at install time.
1388 1398 Use :hg:`config merge-tools` to check the existing configuration.
1389 1399 Also see :hg:`help merge-tools` for more details.
1390 1400
1391 1401 Example ``~/.hgrc``::
1392 1402
1393 1403 [merge-tools]
1394 1404 # Override stock tool location
1395 1405 kdiff3.executable = ~/bin/kdiff3
1396 1406 # Specify command line
1397 1407 kdiff3.args = $base $local $other -o $output
1398 1408 # Give higher priority
1399 1409 kdiff3.priority = 1
1400 1410
1401 1411 # Changing the priority of preconfigured tool
1402 1412 meld.priority = 0
1403 1413
1404 1414 # Disable a preconfigured tool
1405 1415 vimdiff.disabled = yes
1406 1416
1407 1417 # Define new tool
1408 1418 myHtmlTool.args = -m $local $other $base $output
1409 1419 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1410 1420 myHtmlTool.priority = 1
1411 1421
1412 1422 Supported arguments:
1413 1423
1414 1424 ``priority``
1415 1425 The priority in which to evaluate this tool.
1416 1426 (default: 0)
1417 1427
1418 1428 ``executable``
1419 1429 Either just the name of the executable or its pathname.
1420 1430
1421 1431 .. container:: windows
1422 1432
1423 1433 On Windows, the path can use environment variables with ${ProgramFiles}
1424 1434 syntax.
1425 1435
1426 1436 (default: the tool name)
1427 1437
1428 1438 ``args``
1429 1439 The arguments to pass to the tool executable. You can refer to the
1430 1440 files being merged as well as the output file through these
1431 1441 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1432 1442
1433 1443 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1434 1444 being performed. During an update or merge, ``$local`` represents the original
1435 1445 state of the file, while ``$other`` represents the commit you are updating to or
1436 1446 the commit you are merging with. During a rebase, ``$local`` represents the
1437 1447 destination of the rebase, and ``$other`` represents the commit being rebased.
1438 1448
1439 1449 Some operations define custom labels to assist with identifying the revisions,
1440 1450 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1441 1451 labels are not available, these will be ``local``, ``other``, and ``base``,
1442 1452 respectively.
1443 1453 (default: ``$local $base $other``)
1444 1454
1445 1455 ``premerge``
1446 1456 Attempt to run internal non-interactive 3-way merge tool before
1447 1457 launching external tool. Options are ``true``, ``false``, ``keep`` or
1448 1458 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1449 1459 premerge fails. The ``keep-merge3`` will do the same but include information
1450 1460 about the base of the merge in the marker (see internal :merge3 in
1451 1461 :hg:`help merge-tools`).
1452 1462 (default: True)
1453 1463
1454 1464 ``binary``
1455 1465 This tool can merge binary files. (default: False, unless tool
1456 1466 was selected by file pattern match)
1457 1467
1458 1468 ``symlink``
1459 1469 This tool can merge symlinks. (default: False)
1460 1470
1461 1471 ``check``
1462 1472 A list of merge success-checking options:
1463 1473
1464 1474 ``changed``
1465 1475 Ask whether merge was successful when the merged file shows no changes.
1466 1476 ``conflicts``
1467 1477 Check whether there are conflicts even though the tool reported success.
1468 1478 ``prompt``
1469 1479 Always prompt for merge success, regardless of success reported by tool.
1470 1480
1471 1481 ``fixeol``
1472 1482 Attempt to fix up EOL changes caused by the merge tool.
1473 1483 (default: False)
1474 1484
1475 1485 ``gui``
1476 1486 This tool requires a graphical interface to run. (default: False)
1477 1487
1478 1488 ``mergemarkers``
1479 1489 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1480 1490 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1481 1491 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1482 1492 markers generated during premerge will be ``detailed`` if either this option or
1483 1493 the corresponding option in the ``[ui]`` section is ``detailed``.
1484 1494 (default: ``basic``)
1485 1495
1486 1496 ``mergemarkertemplate``
1487 1497 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1488 1498 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1489 1499 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1490 1500 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1491 1501 information.
1492 1502
1493 1503 .. container:: windows
1494 1504
1495 1505 ``regkey``
1496 1506 Windows registry key which describes install location of this
1497 1507 tool. Mercurial will search for this key first under
1498 1508 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1499 1509 (default: None)
1500 1510
1501 1511 ``regkeyalt``
1502 1512 An alternate Windows registry key to try if the first key is not
1503 1513 found. The alternate key uses the same ``regname`` and ``regappend``
1504 1514 semantics of the primary key. The most common use for this key
1505 1515 is to search for 32bit applications on 64bit operating systems.
1506 1516 (default: None)
1507 1517
1508 1518 ``regname``
1509 1519 Name of value to read from specified registry key.
1510 1520 (default: the unnamed (default) value)
1511 1521
1512 1522 ``regappend``
1513 1523 String to append to the value read from the registry, typically
1514 1524 the executable name of the tool.
1515 1525 (default: None)
1516 1526
1517 1527 ``pager``
1518 1528 ---------
1519 1529
1520 1530 Setting used to control when to paginate and with what external tool. See
1521 1531 :hg:`help pager` for details.
1522 1532
1523 1533 ``pager``
1524 1534 Define the external tool used as pager.
1525 1535
1526 1536 If no pager is set, Mercurial uses the environment variable $PAGER.
1527 1537 If neither pager.pager, nor $PAGER is set, a default pager will be
1528 1538 used, typically `less` on Unix and `more` on Windows. Example::
1529 1539
1530 1540 [pager]
1531 1541 pager = less -FRX
1532 1542
1533 1543 ``ignore``
1534 1544 List of commands to disable the pager for. Example::
1535 1545
1536 1546 [pager]
1537 1547 ignore = version, help, update
1538 1548
1539 1549 ``patch``
1540 1550 ---------
1541 1551
1542 1552 Settings used when applying patches, for instance through the 'import'
1543 1553 command or with Mercurial Queues extension.
1544 1554
1545 1555 ``eol``
1546 1556 When set to 'strict' patch content and patched files end of lines
1547 1557 are preserved. When set to ``lf`` or ``crlf``, both files end of
1548 1558 lines are ignored when patching and the result line endings are
1549 1559 normalized to either LF (Unix) or CRLF (Windows). When set to
1550 1560 ``auto``, end of lines are again ignored while patching but line
1551 1561 endings in patched files are normalized to their original setting
1552 1562 on a per-file basis. If target file does not exist or has no end
1553 1563 of line, patch line endings are preserved.
1554 1564 (default: strict)
1555 1565
1556 1566 ``fuzz``
1557 1567 The number of lines of 'fuzz' to allow when applying patches. This
1558 1568 controls how much context the patcher is allowed to ignore when
1559 1569 trying to apply a patch.
1560 1570 (default: 2)
1561 1571
1562 1572 ``paths``
1563 1573 ---------
1564 1574
1565 1575 Assigns symbolic names and behavior to repositories.
1566 1576
1567 1577 Options are symbolic names defining the URL or directory that is the
1568 1578 location of the repository. Example::
1569 1579
1570 1580 [paths]
1571 1581 my_server = https://example.com/my_repo
1572 1582 local_path = /home/me/repo
1573 1583
1574 1584 These symbolic names can be used from the command line. To pull
1575 1585 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1576 1586 :hg:`push local_path`.
1577 1587
1578 1588 Options containing colons (``:``) denote sub-options that can influence
1579 1589 behavior for that specific path. Example::
1580 1590
1581 1591 [paths]
1582 1592 my_server = https://example.com/my_path
1583 1593 my_server:pushurl = ssh://example.com/my_path
1584 1594
1585 1595 The following sub-options can be defined:
1586 1596
1587 1597 ``pushurl``
1588 1598 The URL to use for push operations. If not defined, the location
1589 1599 defined by the path's main entry is used.
1590 1600
1591 1601 ``pushrev``
1592 1602 A revset defining which revisions to push by default.
1593 1603
1594 1604 When :hg:`push` is executed without a ``-r`` argument, the revset
1595 1605 defined by this sub-option is evaluated to determine what to push.
1596 1606
1597 1607 For example, a value of ``.`` will push the working directory's
1598 1608 revision by default.
1599 1609
1600 1610 Revsets specifying bookmarks will not result in the bookmark being
1601 1611 pushed.
1602 1612
1603 1613 The following special named paths exist:
1604 1614
1605 1615 ``default``
1606 1616 The URL or directory to use when no source or remote is specified.
1607 1617
1608 1618 :hg:`clone` will automatically define this path to the location the
1609 1619 repository was cloned from.
1610 1620
1611 1621 ``default-push``
1612 1622 (deprecated) The URL or directory for the default :hg:`push` location.
1613 1623 ``default:pushurl`` should be used instead.
1614 1624
1615 1625 ``phases``
1616 1626 ----------
1617 1627
1618 1628 Specifies default handling of phases. See :hg:`help phases` for more
1619 1629 information about working with phases.
1620 1630
1621 1631 ``publish``
1622 1632 Controls draft phase behavior when working as a server. When true,
1623 1633 pushed changesets are set to public in both client and server and
1624 1634 pulled or cloned changesets are set to public in the client.
1625 1635 (default: True)
1626 1636
1627 1637 ``new-commit``
1628 1638 Phase of newly-created commits.
1629 1639 (default: draft)
1630 1640
1631 1641 ``checksubrepos``
1632 1642 Check the phase of the current revision of each subrepository. Allowed
1633 1643 values are "ignore", "follow" and "abort". For settings other than
1634 1644 "ignore", the phase of the current revision of each subrepository is
1635 1645 checked before committing the parent repository. If any of those phases is
1636 1646 greater than the phase of the parent repository (e.g. if a subrepo is in a
1637 1647 "secret" phase while the parent repo is in "draft" phase), the commit is
1638 1648 either aborted (if checksubrepos is set to "abort") or the higher phase is
1639 1649 used for the parent repository commit (if set to "follow").
1640 1650 (default: follow)
1641 1651
1642 1652
1643 1653 ``profiling``
1644 1654 -------------
1645 1655
1646 1656 Specifies profiling type, format, and file output. Two profilers are
1647 1657 supported: an instrumenting profiler (named ``ls``), and a sampling
1648 1658 profiler (named ``stat``).
1649 1659
1650 1660 In this section description, 'profiling data' stands for the raw data
1651 1661 collected during profiling, while 'profiling report' stands for a
1652 1662 statistical text report generated from the profiling data.
1653 1663
1654 1664 ``enabled``
1655 1665 Enable the profiler.
1656 1666 (default: false)
1657 1667
1658 1668 This is equivalent to passing ``--profile`` on the command line.
1659 1669
1660 1670 ``type``
1661 1671 The type of profiler to use.
1662 1672 (default: stat)
1663 1673
1664 1674 ``ls``
1665 1675 Use Python's built-in instrumenting profiler. This profiler
1666 1676 works on all platforms, but each line number it reports is the
1667 1677 first line of a function. This restriction makes it difficult to
1668 1678 identify the expensive parts of a non-trivial function.
1669 1679 ``stat``
1670 1680 Use a statistical profiler, statprof. This profiler is most
1671 1681 useful for profiling commands that run for longer than about 0.1
1672 1682 seconds.
1673 1683
1674 1684 ``format``
1675 1685 Profiling format. Specific to the ``ls`` instrumenting profiler.
1676 1686 (default: text)
1677 1687
1678 1688 ``text``
1679 1689 Generate a profiling report. When saving to a file, it should be
1680 1690 noted that only the report is saved, and the profiling data is
1681 1691 not kept.
1682 1692 ``kcachegrind``
1683 1693 Format profiling data for kcachegrind use: when saving to a
1684 1694 file, the generated file can directly be loaded into
1685 1695 kcachegrind.
1686 1696
1687 1697 ``statformat``
1688 1698 Profiling format for the ``stat`` profiler.
1689 1699 (default: hotpath)
1690 1700
1691 1701 ``hotpath``
1692 1702 Show a tree-based display containing the hot path of execution (where
1693 1703 most time was spent).
1694 1704 ``bymethod``
1695 1705 Show a table of methods ordered by how frequently they are active.
1696 1706 ``byline``
1697 1707 Show a table of lines in files ordered by how frequently they are active.
1698 1708 ``json``
1699 1709 Render profiling data as JSON.
1700 1710
1701 1711 ``frequency``
1702 1712 Sampling frequency. Specific to the ``stat`` sampling profiler.
1703 1713 (default: 1000)
1704 1714
1705 1715 ``output``
1706 1716 File path where profiling data or report should be saved. If the
1707 1717 file exists, it is replaced. (default: None, data is printed on
1708 1718 stderr)
1709 1719
1710 1720 ``sort``
1711 1721 Sort field. Specific to the ``ls`` instrumenting profiler.
1712 1722 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1713 1723 ``inlinetime``.
1714 1724 (default: inlinetime)
1715 1725
1716 1726 ``time-track``
1717 1727 Control if the stat profiler track ``cpu`` or ``real`` time.
1718 1728 (default: ``cpu`` on Windows, otherwise ``real``)
1719 1729
1720 1730 ``limit``
1721 1731 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1722 1732 (default: 30)
1723 1733
1724 1734 ``nested``
1725 1735 Show at most this number of lines of drill-down info after each main entry.
1726 1736 This can help explain the difference between Total and Inline.
1727 1737 Specific to the ``ls`` instrumenting profiler.
1728 1738 (default: 0)
1729 1739
1730 1740 ``showmin``
1731 1741 Minimum fraction of samples an entry must have for it to be displayed.
1732 1742 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1733 1743 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1734 1744
1735 1745 Only used by the ``stat`` profiler.
1736 1746
1737 1747 For the ``hotpath`` format, default is ``0.05``.
1738 1748 For the ``chrome`` format, default is ``0.005``.
1739 1749
1740 1750 The option is unused on other formats.
1741 1751
1742 1752 ``showmax``
1743 1753 Maximum fraction of samples an entry can have before it is ignored in
1744 1754 display. Values format is the same as ``showmin``.
1745 1755
1746 1756 Only used by the ``stat`` profiler.
1747 1757
1748 1758 For the ``chrome`` format, default is ``0.999``.
1749 1759
1750 1760 The option is unused on other formats.
1751 1761
1752 1762 ``progress``
1753 1763 ------------
1754 1764
1755 1765 Mercurial commands can draw progress bars that are as informative as
1756 1766 possible. Some progress bars only offer indeterminate information, while others
1757 1767 have a definite end point.
1758 1768
1759 1769 ``debug``
1760 1770 Whether to print debug info when updating the progress bar. (default: False)
1761 1771
1762 1772 ``delay``
1763 1773 Number of seconds (float) before showing the progress bar. (default: 3)
1764 1774
1765 1775 ``changedelay``
1766 1776 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1767 1777 that value will be used instead. (default: 1)
1768 1778
1769 1779 ``estimateinterval``
1770 1780 Maximum sampling interval in seconds for speed and estimated time
1771 1781 calculation. (default: 60)
1772 1782
1773 1783 ``refresh``
1774 1784 Time in seconds between refreshes of the progress bar. (default: 0.1)
1775 1785
1776 1786 ``format``
1777 1787 Format of the progress bar.
1778 1788
1779 1789 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1780 1790 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1781 1791 last 20 characters of the item, but this can be changed by adding either
1782 1792 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1783 1793 first num characters.
1784 1794
1785 1795 (default: topic bar number estimate)
1786 1796
1787 1797 ``width``
1788 1798 If set, the maximum width of the progress information (that is, min(width,
1789 1799 term width) will be used).
1790 1800
1791 1801 ``clear-complete``
1792 1802 Clear the progress bar after it's done. (default: True)
1793 1803
1794 1804 ``disable``
1795 1805 If true, don't show a progress bar.
1796 1806
1797 1807 ``assume-tty``
1798 1808 If true, ALWAYS show a progress bar, unless disable is given.
1799 1809
1800 1810 ``rebase``
1801 1811 ----------
1802 1812
1803 1813 ``evolution.allowdivergence``
1804 1814 Default to False, when True allow creating divergence when performing
1805 1815 rebase of obsolete changesets.
1806 1816
1807 1817 ``revsetalias``
1808 1818 ---------------
1809 1819
1810 1820 Alias definitions for revsets. See :hg:`help revsets` for details.
1811 1821
1812 1822 ``rewrite``
1813 1823 -----------
1814 1824
1815 1825 ``backup-bundle``
1816 1826 Whether to save stripped changesets to a bundle file. (default: True)
1817 1827
1818 1828 ``update-timestamp``
1819 1829 If true, updates the date and time of the changeset to current. It is only
1820 1830 applicable for hg amend in current version.
1821 1831
1822 1832 ``storage``
1823 1833 -----------
1824 1834
1825 1835 Control the strategy Mercurial uses internally to store history. Options in this
1826 1836 category impact performance and repository size.
1827 1837
1828 1838 ``revlog.optimize-delta-parent-choice``
1829 1839 When storing a merge revision, both parents will be equally considered as
1830 1840 a possible delta base. This results in better delta selection and improved
1831 1841 revlog compression. This option is enabled by default.
1832 1842
1833 1843 Turning this option off can result in large increase of repository size for
1834 1844 repository with many merges.
1835 1845
1836 1846 ``server``
1837 1847 ----------
1838 1848
1839 1849 Controls generic server settings.
1840 1850
1841 1851 ``bookmarks-pushkey-compat``
1842 1852 Trigger pushkey hook when being pushed bookmark updates. This config exist
1843 1853 for compatibility purpose (default to True)
1844 1854
1845 1855 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1846 1856 movement we recommend you migrate them to ``txnclose-bookmark`` and
1847 1857 ``pretxnclose-bookmark``.
1848 1858
1849 1859 ``compressionengines``
1850 1860 List of compression engines and their relative priority to advertise
1851 1861 to clients.
1852 1862
1853 1863 The order of compression engines determines their priority, the first
1854 1864 having the highest priority. If a compression engine is not listed
1855 1865 here, it won't be advertised to clients.
1856 1866
1857 1867 If not set (the default), built-in defaults are used. Run
1858 1868 :hg:`debuginstall` to list available compression engines and their
1859 1869 default wire protocol priority.
1860 1870
1861 1871 Older Mercurial clients only support zlib compression and this setting
1862 1872 has no effect for legacy clients.
1863 1873
1864 1874 ``uncompressed``
1865 1875 Whether to allow clients to clone a repository using the
1866 1876 uncompressed streaming protocol. This transfers about 40% more
1867 1877 data than a regular clone, but uses less memory and CPU on both
1868 1878 server and client. Over a LAN (100 Mbps or better) or a very fast
1869 1879 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1870 1880 regular clone. Over most WAN connections (anything slower than
1871 1881 about 6 Mbps), uncompressed streaming is slower, because of the
1872 1882 extra data transfer overhead. This mode will also temporarily hold
1873 1883 the write lock while determining what data to transfer.
1874 1884 (default: True)
1875 1885
1876 1886 ``uncompressedallowsecret``
1877 1887 Whether to allow stream clones when the repository contains secret
1878 1888 changesets. (default: False)
1879 1889
1880 1890 ``preferuncompressed``
1881 1891 When set, clients will try to use the uncompressed streaming
1882 1892 protocol. (default: False)
1883 1893
1884 1894 ``disablefullbundle``
1885 1895 When set, servers will refuse attempts to do pull-based clones.
1886 1896 If this option is set, ``preferuncompressed`` and/or clone bundles
1887 1897 are highly recommended. Partial clones will still be allowed.
1888 1898 (default: False)
1889 1899
1890 1900 ``streamunbundle``
1891 1901 When set, servers will apply data sent from the client directly,
1892 1902 otherwise it will be written to a temporary file first. This option
1893 1903 effectively prevents concurrent pushes.
1894 1904
1895 1905 ``pullbundle``
1896 1906 When set, the server will check pullbundle.manifest for bundles
1897 1907 covering the requested heads and common nodes. The first matching
1898 1908 entry will be streamed to the client.
1899 1909
1900 1910 For HTTP transport, the stream will still use zlib compression
1901 1911 for older clients.
1902 1912
1903 1913 ``concurrent-push-mode``
1904 1914 Level of allowed race condition between two pushing clients.
1905 1915
1906 1916 - 'strict': push is abort if another client touched the repository
1907 1917 while the push was preparing. (default)
1908 1918 - 'check-related': push is only aborted if it affects head that got also
1909 1919 affected while the push was preparing.
1910 1920
1911 1921 This requires compatible client (version 4.3 and later). Old client will
1912 1922 use 'strict'.
1913 1923
1914 1924 ``validate``
1915 1925 Whether to validate the completeness of pushed changesets by
1916 1926 checking that all new file revisions specified in manifests are
1917 1927 present. (default: False)
1918 1928
1919 1929 ``maxhttpheaderlen``
1920 1930 Instruct HTTP clients not to send request headers longer than this
1921 1931 many bytes. (default: 1024)
1922 1932
1923 1933 ``bundle1``
1924 1934 Whether to allow clients to push and pull using the legacy bundle1
1925 1935 exchange format. (default: True)
1926 1936
1927 1937 ``bundle1gd``
1928 1938 Like ``bundle1`` but only used if the repository is using the
1929 1939 *generaldelta* storage format. (default: True)
1930 1940
1931 1941 ``bundle1.push``
1932 1942 Whether to allow clients to push using the legacy bundle1 exchange
1933 1943 format. (default: True)
1934 1944
1935 1945 ``bundle1gd.push``
1936 1946 Like ``bundle1.push`` but only used if the repository is using the
1937 1947 *generaldelta* storage format. (default: True)
1938 1948
1939 1949 ``bundle1.pull``
1940 1950 Whether to allow clients to pull using the legacy bundle1 exchange
1941 1951 format. (default: True)
1942 1952
1943 1953 ``bundle1gd.pull``
1944 1954 Like ``bundle1.pull`` but only used if the repository is using the
1945 1955 *generaldelta* storage format. (default: True)
1946 1956
1947 1957 Large repositories using the *generaldelta* storage format should
1948 1958 consider setting this option because converting *generaldelta*
1949 1959 repositories to the exchange format required by the bundle1 data
1950 1960 format can consume a lot of CPU.
1951 1961
1952 1962 ``bundle2.stream``
1953 1963 Whether to allow clients to pull using the bundle2 streaming protocol.
1954 1964 (default: True)
1955 1965
1956 1966 ``zliblevel``
1957 1967 Integer between ``-1`` and ``9`` that controls the zlib compression level
1958 1968 for wire protocol commands that send zlib compressed output (notably the
1959 1969 commands that send repository history data).
1960 1970
1961 1971 The default (``-1``) uses the default zlib compression level, which is
1962 1972 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1963 1973 maximum compression.
1964 1974
1965 1975 Setting this option allows server operators to make trade-offs between
1966 1976 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1967 1977 but sends more bytes to clients.
1968 1978
1969 1979 This option only impacts the HTTP server.
1970 1980
1971 1981 ``zstdlevel``
1972 1982 Integer between ``1`` and ``22`` that controls the zstd compression level
1973 1983 for wire protocol commands. ``1`` is the minimal amount of compression and
1974 1984 ``22`` is the highest amount of compression.
1975 1985
1976 1986 The default (``3``) should be significantly faster than zlib while likely
1977 1987 delivering better compression ratios.
1978 1988
1979 1989 This option only impacts the HTTP server.
1980 1990
1981 1991 See also ``server.zliblevel``.
1982 1992
1983 1993 ``smtp``
1984 1994 --------
1985 1995
1986 1996 Configuration for extensions that need to send email messages.
1987 1997
1988 1998 ``host``
1989 1999 Host name of mail server, e.g. "mail.example.com".
1990 2000
1991 2001 ``port``
1992 2002 Optional. Port to connect to on mail server. (default: 465 if
1993 2003 ``tls`` is smtps; 25 otherwise)
1994 2004
1995 2005 ``tls``
1996 2006 Optional. Method to enable TLS when connecting to mail server: starttls,
1997 2007 smtps or none. (default: none)
1998 2008
1999 2009 ``username``
2000 2010 Optional. User name for authenticating with the SMTP server.
2001 2011 (default: None)
2002 2012
2003 2013 ``password``
2004 2014 Optional. Password for authenticating with the SMTP server. If not
2005 2015 specified, interactive sessions will prompt the user for a
2006 2016 password; non-interactive sessions will fail. (default: None)
2007 2017
2008 2018 ``local_hostname``
2009 2019 Optional. The hostname that the sender can use to identify
2010 2020 itself to the MTA.
2011 2021
2012 2022
2013 2023 ``subpaths``
2014 2024 ------------
2015 2025
2016 2026 Subrepository source URLs can go stale if a remote server changes name
2017 2027 or becomes temporarily unavailable. This section lets you define
2018 2028 rewrite rules of the form::
2019 2029
2020 2030 <pattern> = <replacement>
2021 2031
2022 2032 where ``pattern`` is a regular expression matching a subrepository
2023 2033 source URL and ``replacement`` is the replacement string used to
2024 2034 rewrite it. Groups can be matched in ``pattern`` and referenced in
2025 2035 ``replacements``. For instance::
2026 2036
2027 2037 http://server/(.*)-hg/ = http://hg.server/\1/
2028 2038
2029 2039 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2030 2040
2031 2041 Relative subrepository paths are first made absolute, and the
2032 2042 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2033 2043 doesn't match the full path, an attempt is made to apply it on the
2034 2044 relative path alone. The rules are applied in definition order.
2035 2045
2036 2046 ``subrepos``
2037 2047 ------------
2038 2048
2039 2049 This section contains options that control the behavior of the
2040 2050 subrepositories feature. See also :hg:`help subrepos`.
2041 2051
2042 2052 Security note: auditing in Mercurial is known to be insufficient to
2043 2053 prevent clone-time code execution with carefully constructed Git
2044 2054 subrepos. It is unknown if a similar detect is present in Subversion
2045 2055 subrepos. Both Git and Subversion subrepos are disabled by default
2046 2056 out of security concerns. These subrepo types can be enabled using
2047 2057 the respective options below.
2048 2058
2049 2059 ``allowed``
2050 2060 Whether subrepositories are allowed in the working directory.
2051 2061
2052 2062 When false, commands involving subrepositories (like :hg:`update`)
2053 2063 will fail for all subrepository types.
2054 2064 (default: true)
2055 2065
2056 2066 ``hg:allowed``
2057 2067 Whether Mercurial subrepositories are allowed in the working
2058 2068 directory. This option only has an effect if ``subrepos.allowed``
2059 2069 is true.
2060 2070 (default: true)
2061 2071
2062 2072 ``git:allowed``
2063 2073 Whether Git subrepositories are allowed in the working directory.
2064 2074 This option only has an effect if ``subrepos.allowed`` is true.
2065 2075
2066 2076 See the security note above before enabling Git subrepos.
2067 2077 (default: false)
2068 2078
2069 2079 ``svn:allowed``
2070 2080 Whether Subversion subrepositories are allowed in the working
2071 2081 directory. This option only has an effect if ``subrepos.allowed``
2072 2082 is true.
2073 2083
2074 2084 See the security note above before enabling Subversion subrepos.
2075 2085 (default: false)
2076 2086
2077 2087 ``templatealias``
2078 2088 -----------------
2079 2089
2080 2090 Alias definitions for templates. See :hg:`help templates` for details.
2081 2091
2082 2092 ``templates``
2083 2093 -------------
2084 2094
2085 2095 Use the ``[templates]`` section to define template strings.
2086 2096 See :hg:`help templates` for details.
2087 2097
2088 2098 ``trusted``
2089 2099 -----------
2090 2100
2091 2101 Mercurial will not use the settings in the
2092 2102 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2093 2103 user or to a trusted group, as various hgrc features allow arbitrary
2094 2104 commands to be run. This issue is often encountered when configuring
2095 2105 hooks or extensions for shared repositories or servers. However,
2096 2106 the web interface will use some safe settings from the ``[web]``
2097 2107 section.
2098 2108
2099 2109 This section specifies what users and groups are trusted. The
2100 2110 current user is always trusted. To trust everybody, list a user or a
2101 2111 group with name ``*``. These settings must be placed in an
2102 2112 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2103 2113 user or service running Mercurial.
2104 2114
2105 2115 ``users``
2106 2116 Comma-separated list of trusted users.
2107 2117
2108 2118 ``groups``
2109 2119 Comma-separated list of trusted groups.
2110 2120
2111 2121
2112 2122 ``ui``
2113 2123 ------
2114 2124
2115 2125 User interface controls.
2116 2126
2117 2127 ``archivemeta``
2118 2128 Whether to include the .hg_archival.txt file containing meta data
2119 2129 (hashes for the repository base and for tip) in archives created
2120 2130 by the :hg:`archive` command or downloaded via hgweb.
2121 2131 (default: True)
2122 2132
2123 2133 ``askusername``
2124 2134 Whether to prompt for a username when committing. If True, and
2125 2135 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2126 2136 be prompted to enter a username. If no username is entered, the
2127 2137 default ``USER@HOST`` is used instead.
2128 2138 (default: False)
2129 2139
2130 2140 ``clonebundles``
2131 2141 Whether the "clone bundles" feature is enabled.
2132 2142
2133 2143 When enabled, :hg:`clone` may download and apply a server-advertised
2134 2144 bundle file from a URL instead of using the normal exchange mechanism.
2135 2145
2136 2146 This can likely result in faster and more reliable clones.
2137 2147
2138 2148 (default: True)
2139 2149
2140 2150 ``clonebundlefallback``
2141 2151 Whether failure to apply an advertised "clone bundle" from a server
2142 2152 should result in fallback to a regular clone.
2143 2153
2144 2154 This is disabled by default because servers advertising "clone
2145 2155 bundles" often do so to reduce server load. If advertised bundles
2146 2156 start mass failing and clients automatically fall back to a regular
2147 2157 clone, this would add significant and unexpected load to the server
2148 2158 since the server is expecting clone operations to be offloaded to
2149 2159 pre-generated bundles. Failing fast (the default behavior) ensures
2150 2160 clients don't overwhelm the server when "clone bundle" application
2151 2161 fails.
2152 2162
2153 2163 (default: False)
2154 2164
2155 2165 ``clonebundleprefers``
2156 2166 Defines preferences for which "clone bundles" to use.
2157 2167
2158 2168 Servers advertising "clone bundles" may advertise multiple available
2159 2169 bundles. Each bundle may have different attributes, such as the bundle
2160 2170 type and compression format. This option is used to prefer a particular
2161 2171 bundle over another.
2162 2172
2163 2173 The following keys are defined by Mercurial:
2164 2174
2165 2175 BUNDLESPEC
2166 2176 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2167 2177 e.g. ``gzip-v2`` or ``bzip2-v1``.
2168 2178
2169 2179 COMPRESSION
2170 2180 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2171 2181
2172 2182 Server operators may define custom keys.
2173 2183
2174 2184 Example values: ``COMPRESSION=bzip2``,
2175 2185 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2176 2186
2177 2187 By default, the first bundle advertised by the server is used.
2178 2188
2179 2189 ``color``
2180 2190 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2181 2191 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2182 2192 seems possible. See :hg:`help color` for details.
2183 2193
2184 2194 ``commitsubrepos``
2185 2195 Whether to commit modified subrepositories when committing the
2186 2196 parent repository. If False and one subrepository has uncommitted
2187 2197 changes, abort the commit.
2188 2198 (default: False)
2189 2199
2190 2200 ``debug``
2191 2201 Print debugging information. (default: False)
2192 2202
2193 2203 ``editor``
2194 2204 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2195 2205
2196 2206 ``fallbackencoding``
2197 2207 Encoding to try if it's not possible to decode the changelog using
2198 2208 UTF-8. (default: ISO-8859-1)
2199 2209
2200 2210 ``graphnodetemplate``
2201 2211 The template used to print changeset nodes in an ASCII revision graph.
2202 2212 (default: ``{graphnode}``)
2203 2213
2204 2214 ``ignore``
2205 2215 A file to read per-user ignore patterns from. This file should be
2206 2216 in the same format as a repository-wide .hgignore file. Filenames
2207 2217 are relative to the repository root. This option supports hook syntax,
2208 2218 so if you want to specify multiple ignore files, you can do so by
2209 2219 setting something like ``ignore.other = ~/.hgignore2``. For details
2210 2220 of the ignore file format, see the ``hgignore(5)`` man page.
2211 2221
2212 2222 ``interactive``
2213 2223 Allow to prompt the user. (default: True)
2214 2224
2215 2225 ``interface``
2216 2226 Select the default interface for interactive features (default: text).
2217 2227 Possible values are 'text' and 'curses'.
2218 2228
2219 2229 ``interface.chunkselector``
2220 2230 Select the interface for change recording (e.g. :hg:`commit -i`).
2221 2231 Possible values are 'text' and 'curses'.
2222 2232 This config overrides the interface specified by ui.interface.
2223 2233
2224 2234 ``large-file-limit``
2225 2235 Largest file size that gives no memory use warning.
2226 2236 Possible values are integers or 0 to disable the check.
2227 2237 (default: 10000000)
2228 2238
2229 2239 ``logtemplate``
2230 2240 Template string for commands that print changesets.
2231 2241
2232 2242 ``merge``
2233 2243 The conflict resolution program to use during a manual merge.
2234 2244 For more information on merge tools see :hg:`help merge-tools`.
2235 2245 For configuring merge tools see the ``[merge-tools]`` section.
2236 2246
2237 2247 ``mergemarkers``
2238 2248 Sets the merge conflict marker label styling. The ``detailed``
2239 2249 style uses the ``mergemarkertemplate`` setting to style the labels.
2240 2250 The ``basic`` style just uses 'local' and 'other' as the marker label.
2241 2251 One of ``basic`` or ``detailed``.
2242 2252 (default: ``basic``)
2243 2253
2244 2254 ``mergemarkertemplate``
2245 2255 The template used to print the commit description next to each conflict
2246 2256 marker during merge conflicts. See :hg:`help templates` for the template
2247 2257 format.
2248 2258
2249 2259 Defaults to showing the hash, tags, branches, bookmarks, author, and
2250 2260 the first line of the commit description.
2251 2261
2252 2262 If you use non-ASCII characters in names for tags, branches, bookmarks,
2253 2263 authors, and/or commit descriptions, you must pay attention to encodings of
2254 2264 managed files. At template expansion, non-ASCII characters use the encoding
2255 2265 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2256 2266 environment variables that govern your locale. If the encoding of the merge
2257 2267 markers is different from the encoding of the merged files,
2258 2268 serious problems may occur.
2259 2269
2260 2270 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2261 2271
2262 2272 ``message-output``
2263 2273 Where to write status and error messages. (default: ``stdio``)
2264 2274
2265 2275 ``stderr``
2266 2276 Everything to stderr.
2267 2277 ``stdio``
2268 2278 Status to stdout, and error to stderr.
2269 2279
2270 2280 ``origbackuppath``
2271 2281 The path to a directory used to store generated .orig files. If the path is
2272 2282 not a directory, one will be created. If set, files stored in this
2273 2283 directory have the same name as the original file and do not have a .orig
2274 2284 suffix.
2275 2285
2276 2286 ``paginate``
2277 2287 Control the pagination of command output (default: True). See :hg:`help pager`
2278 2288 for details.
2279 2289
2280 2290 ``patch``
2281 2291 An optional external tool that ``hg import`` and some extensions
2282 2292 will use for applying patches. By default Mercurial uses an
2283 2293 internal patch utility. The external tool must work as the common
2284 2294 Unix ``patch`` program. In particular, it must accept a ``-p``
2285 2295 argument to strip patch headers, a ``-d`` argument to specify the
2286 2296 current directory, a file name to patch, and a patch file to take
2287 2297 from stdin.
2288 2298
2289 2299 It is possible to specify a patch tool together with extra
2290 2300 arguments. For example, setting this option to ``patch --merge``
2291 2301 will use the ``patch`` program with its 2-way merge option.
2292 2302
2293 2303 ``portablefilenames``
2294 2304 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2295 2305 (default: ``warn``)
2296 2306
2297 2307 ``warn``
2298 2308 Print a warning message on POSIX platforms, if a file with a non-portable
2299 2309 filename is added (e.g. a file with a name that can't be created on
2300 2310 Windows because it contains reserved parts like ``AUX``, reserved
2301 2311 characters like ``:``, or would cause a case collision with an existing
2302 2312 file).
2303 2313
2304 2314 ``ignore``
2305 2315 Don't print a warning.
2306 2316
2307 2317 ``abort``
2308 2318 The command is aborted.
2309 2319
2310 2320 ``true``
2311 2321 Alias for ``warn``.
2312 2322
2313 2323 ``false``
2314 2324 Alias for ``ignore``.
2315 2325
2316 2326 .. container:: windows
2317 2327
2318 2328 On Windows, this configuration option is ignored and the command aborted.
2319 2329
2320 2330 ``pre-merge-tool-output-template``
2321 2331 A template that is printed before executing an external merge tool. This can
2322 2332 be used to print out additional context that might be useful to have during
2323 2333 the conflict resolution, such as the description of the various commits
2324 2334 involved or bookmarks/tags.
2325 2335
2326 2336 Additional information is available in the ``local`, ``base``, and ``other``
2327 2337 dicts. For example: ``{local.label}``, ``{base.name}``, or
2328 2338 ``{other.islink}``.
2329 2339
2330 2340 ``quiet``
2331 2341 Reduce the amount of output printed.
2332 2342 (default: False)
2333 2343
2334 2344 ``remotecmd``
2335 2345 Remote command to use for clone/push/pull operations.
2336 2346 (default: ``hg``)
2337 2347
2338 2348 ``report_untrusted``
2339 2349 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2340 2350 trusted user or group.
2341 2351 (default: True)
2342 2352
2343 2353 ``slash``
2344 2354 (Deprecated. Use ``slashpath`` template filter instead.)
2345 2355
2346 2356 Display paths using a slash (``/``) as the path separator. This
2347 2357 only makes a difference on systems where the default path
2348 2358 separator is not the slash character (e.g. Windows uses the
2349 2359 backslash character (``\``)).
2350 2360 (default: False)
2351 2361
2352 2362 ``statuscopies``
2353 2363 Display copies in the status command.
2354 2364
2355 2365 ``ssh``
2356 2366 Command to use for SSH connections. (default: ``ssh``)
2357 2367
2358 2368 ``ssherrorhint``
2359 2369 A hint shown to the user in the case of SSH error (e.g.
2360 2370 ``Please see http://company/internalwiki/ssh.html``)
2361 2371
2362 2372 ``strict``
2363 2373 Require exact command names, instead of allowing unambiguous
2364 2374 abbreviations. (default: False)
2365 2375
2366 2376 ``style``
2367 2377 Name of style to use for command output.
2368 2378
2369 2379 ``supportcontact``
2370 2380 A URL where users should report a Mercurial traceback. Use this if you are a
2371 2381 large organisation with its own Mercurial deployment process and crash
2372 2382 reports should be addressed to your internal support.
2373 2383
2374 2384 ``textwidth``
2375 2385 Maximum width of help text. A longer line generated by ``hg help`` or
2376 2386 ``hg subcommand --help`` will be broken after white space to get this
2377 2387 width or the terminal width, whichever comes first.
2378 2388 A non-positive value will disable this and the terminal width will be
2379 2389 used. (default: 78)
2380 2390
2381 2391 ``timeout``
2382 2392 The timeout used when a lock is held (in seconds), a negative value
2383 2393 means no timeout. (default: 600)
2384 2394
2385 2395 ``timeout.warn``
2386 2396 Time (in seconds) before a warning is printed about held lock. A negative
2387 2397 value means no warning. (default: 0)
2388 2398
2389 2399 ``traceback``
2390 2400 Mercurial always prints a traceback when an unknown exception
2391 2401 occurs. Setting this to True will make Mercurial print a traceback
2392 2402 on all exceptions, even those recognized by Mercurial (such as
2393 2403 IOError or MemoryError). (default: False)
2394 2404
2395 2405 ``tweakdefaults``
2396 2406
2397 2407 By default Mercurial's behavior changes very little from release
2398 2408 to release, but over time the recommended config settings
2399 2409 shift. Enable this config to opt in to get automatic tweaks to
2400 2410 Mercurial's behavior over time. This config setting will have no
2401 2411 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2402 2412 not include ``tweakdefaults``. (default: False)
2403 2413
2404 2414 It currently means::
2405 2415
2406 2416 .. tweakdefaultsmarker
2407 2417
2408 2418 ``username``
2409 2419 The committer of a changeset created when running "commit".
2410 2420 Typically a person's name and email address, e.g. ``Fred Widget
2411 2421 <fred@example.com>``. Environment variables in the
2412 2422 username are expanded.
2413 2423
2414 2424 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2415 2425 hgrc is empty, e.g. if the system admin set ``username =`` in the
2416 2426 system hgrc, it has to be specified manually or in a different
2417 2427 hgrc file)
2418 2428
2419 2429 ``verbose``
2420 2430 Increase the amount of output printed. (default: False)
2421 2431
2422 2432
2423 2433 ``web``
2424 2434 -------
2425 2435
2426 2436 Web interface configuration. The settings in this section apply to
2427 2437 both the builtin webserver (started by :hg:`serve`) and the script you
2428 2438 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2429 2439 and WSGI).
2430 2440
2431 2441 The Mercurial webserver does no authentication (it does not prompt for
2432 2442 usernames and passwords to validate *who* users are), but it does do
2433 2443 authorization (it grants or denies access for *authenticated users*
2434 2444 based on settings in this section). You must either configure your
2435 2445 webserver to do authentication for you, or disable the authorization
2436 2446 checks.
2437 2447
2438 2448 For a quick setup in a trusted environment, e.g., a private LAN, where
2439 2449 you want it to accept pushes from anybody, you can use the following
2440 2450 command line::
2441 2451
2442 2452 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2443 2453
2444 2454 Note that this will allow anybody to push anything to the server and
2445 2455 that this should not be used for public servers.
2446 2456
2447 2457 The full set of options is:
2448 2458
2449 2459 ``accesslog``
2450 2460 Where to output the access log. (default: stdout)
2451 2461
2452 2462 ``address``
2453 2463 Interface address to bind to. (default: all)
2454 2464
2455 2465 ``allow-archive``
2456 2466 List of archive format (bz2, gz, zip) allowed for downloading.
2457 2467 (default: empty)
2458 2468
2459 2469 ``allowbz2``
2460 2470 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2461 2471 revisions.
2462 2472 (default: False)
2463 2473
2464 2474 ``allowgz``
2465 2475 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2466 2476 revisions.
2467 2477 (default: False)
2468 2478
2469 2479 ``allow-pull``
2470 2480 Whether to allow pulling from the repository. (default: True)
2471 2481
2472 2482 ``allow-push``
2473 2483 Whether to allow pushing to the repository. If empty or not set,
2474 2484 pushing is not allowed. If the special value ``*``, any remote
2475 2485 user can push, including unauthenticated users. Otherwise, the
2476 2486 remote user must have been authenticated, and the authenticated
2477 2487 user name must be present in this list. The contents of the
2478 2488 allow-push list are examined after the deny_push list.
2479 2489
2480 2490 ``allow_read``
2481 2491 If the user has not already been denied repository access due to
2482 2492 the contents of deny_read, this list determines whether to grant
2483 2493 repository access to the user. If this list is not empty, and the
2484 2494 user is unauthenticated or not present in the list, then access is
2485 2495 denied for the user. If the list is empty or not set, then access
2486 2496 is permitted to all users by default. Setting allow_read to the
2487 2497 special value ``*`` is equivalent to it not being set (i.e. access
2488 2498 is permitted to all users). The contents of the allow_read list are
2489 2499 examined after the deny_read list.
2490 2500
2491 2501 ``allowzip``
2492 2502 (DEPRECATED) Whether to allow .zip downloading of repository
2493 2503 revisions. This feature creates temporary files.
2494 2504 (default: False)
2495 2505
2496 2506 ``archivesubrepos``
2497 2507 Whether to recurse into subrepositories when archiving.
2498 2508 (default: False)
2499 2509
2500 2510 ``baseurl``
2501 2511 Base URL to use when publishing URLs in other locations, so
2502 2512 third-party tools like email notification hooks can construct
2503 2513 URLs. Example: ``http://hgserver/repos/``.
2504 2514
2505 2515 ``cacerts``
2506 2516 Path to file containing a list of PEM encoded certificate
2507 2517 authority certificates. Environment variables and ``~user``
2508 2518 constructs are expanded in the filename. If specified on the
2509 2519 client, then it will verify the identity of remote HTTPS servers
2510 2520 with these certificates.
2511 2521
2512 2522 To disable SSL verification temporarily, specify ``--insecure`` from
2513 2523 command line.
2514 2524
2515 2525 You can use OpenSSL's CA certificate file if your platform has
2516 2526 one. On most Linux systems this will be
2517 2527 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2518 2528 generate this file manually. The form must be as follows::
2519 2529
2520 2530 -----BEGIN CERTIFICATE-----
2521 2531 ... (certificate in base64 PEM encoding) ...
2522 2532 -----END CERTIFICATE-----
2523 2533 -----BEGIN CERTIFICATE-----
2524 2534 ... (certificate in base64 PEM encoding) ...
2525 2535 -----END CERTIFICATE-----
2526 2536
2527 2537 ``cache``
2528 2538 Whether to support caching in hgweb. (default: True)
2529 2539
2530 2540 ``certificate``
2531 2541 Certificate to use when running :hg:`serve`.
2532 2542
2533 2543 ``collapse``
2534 2544 With ``descend`` enabled, repositories in subdirectories are shown at
2535 2545 a single level alongside repositories in the current path. With
2536 2546 ``collapse`` also enabled, repositories residing at a deeper level than
2537 2547 the current path are grouped behind navigable directory entries that
2538 2548 lead to the locations of these repositories. In effect, this setting
2539 2549 collapses each collection of repositories found within a subdirectory
2540 2550 into a single entry for that subdirectory. (default: False)
2541 2551
2542 2552 ``comparisoncontext``
2543 2553 Number of lines of context to show in side-by-side file comparison. If
2544 2554 negative or the value ``full``, whole files are shown. (default: 5)
2545 2555
2546 2556 This setting can be overridden by a ``context`` request parameter to the
2547 2557 ``comparison`` command, taking the same values.
2548 2558
2549 2559 ``contact``
2550 2560 Name or email address of the person in charge of the repository.
2551 2561 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2552 2562
2553 2563 ``csp``
2554 2564 Send a ``Content-Security-Policy`` HTTP header with this value.
2555 2565
2556 2566 The value may contain a special string ``%nonce%``, which will be replaced
2557 2567 by a randomly-generated one-time use value. If the value contains
2558 2568 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2559 2569 one-time property of the nonce. This nonce will also be inserted into
2560 2570 ``<script>`` elements containing inline JavaScript.
2561 2571
2562 2572 Note: lots of HTML content sent by the server is derived from repository
2563 2573 data. Please consider the potential for malicious repository data to
2564 2574 "inject" itself into generated HTML content as part of your security
2565 2575 threat model.
2566 2576
2567 2577 ``deny_push``
2568 2578 Whether to deny pushing to the repository. If empty or not set,
2569 2579 push is not denied. If the special value ``*``, all remote users are
2570 2580 denied push. Otherwise, unauthenticated users are all denied, and
2571 2581 any authenticated user name present in this list is also denied. The
2572 2582 contents of the deny_push list are examined before the allow-push list.
2573 2583
2574 2584 ``deny_read``
2575 2585 Whether to deny reading/viewing of the repository. If this list is
2576 2586 not empty, unauthenticated users are all denied, and any
2577 2587 authenticated user name present in this list is also denied access to
2578 2588 the repository. If set to the special value ``*``, all remote users
2579 2589 are denied access (rarely needed ;). If deny_read is empty or not set,
2580 2590 the determination of repository access depends on the presence and
2581 2591 content of the allow_read list (see description). If both
2582 2592 deny_read and allow_read are empty or not set, then access is
2583 2593 permitted to all users by default. If the repository is being
2584 2594 served via hgwebdir, denied users will not be able to see it in
2585 2595 the list of repositories. The contents of the deny_read list have
2586 2596 priority over (are examined before) the contents of the allow_read
2587 2597 list.
2588 2598
2589 2599 ``descend``
2590 2600 hgwebdir indexes will not descend into subdirectories. Only repositories
2591 2601 directly in the current path will be shown (other repositories are still
2592 2602 available from the index corresponding to their containing path).
2593 2603
2594 2604 ``description``
2595 2605 Textual description of the repository's purpose or contents.
2596 2606 (default: "unknown")
2597 2607
2598 2608 ``encoding``
2599 2609 Character encoding name. (default: the current locale charset)
2600 2610 Example: "UTF-8".
2601 2611
2602 2612 ``errorlog``
2603 2613 Where to output the error log. (default: stderr)
2604 2614
2605 2615 ``guessmime``
2606 2616 Control MIME types for raw download of file content.
2607 2617 Set to True to let hgweb guess the content type from the file
2608 2618 extension. This will serve HTML files as ``text/html`` and might
2609 2619 allow cross-site scripting attacks when serving untrusted
2610 2620 repositories. (default: False)
2611 2621
2612 2622 ``hidden``
2613 2623 Whether to hide the repository in the hgwebdir index.
2614 2624 (default: False)
2615 2625
2616 2626 ``ipv6``
2617 2627 Whether to use IPv6. (default: False)
2618 2628
2619 2629 ``labels``
2620 2630 List of string *labels* associated with the repository.
2621 2631
2622 2632 Labels are exposed as a template keyword and can be used to customize
2623 2633 output. e.g. the ``index`` template can group or filter repositories
2624 2634 by labels and the ``summary`` template can display additional content
2625 2635 if a specific label is present.
2626 2636
2627 2637 ``logoimg``
2628 2638 File name of the logo image that some templates display on each page.
2629 2639 The file name is relative to ``staticurl``. That is, the full path to
2630 2640 the logo image is "staticurl/logoimg".
2631 2641 If unset, ``hglogo.png`` will be used.
2632 2642
2633 2643 ``logourl``
2634 2644 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2635 2645 will be used.
2636 2646
2637 2647 ``maxchanges``
2638 2648 Maximum number of changes to list on the changelog. (default: 10)
2639 2649
2640 2650 ``maxfiles``
2641 2651 Maximum number of files to list per changeset. (default: 10)
2642 2652
2643 2653 ``maxshortchanges``
2644 2654 Maximum number of changes to list on the shortlog, graph or filelog
2645 2655 pages. (default: 60)
2646 2656
2647 2657 ``name``
2648 2658 Repository name to use in the web interface.
2649 2659 (default: current working directory)
2650 2660
2651 2661 ``port``
2652 2662 Port to listen on. (default: 8000)
2653 2663
2654 2664 ``prefix``
2655 2665 Prefix path to serve from. (default: '' (server root))
2656 2666
2657 2667 ``push_ssl``
2658 2668 Whether to require that inbound pushes be transported over SSL to
2659 2669 prevent password sniffing. (default: True)
2660 2670
2661 2671 ``refreshinterval``
2662 2672 How frequently directory listings re-scan the filesystem for new
2663 2673 repositories, in seconds. This is relevant when wildcards are used
2664 2674 to define paths. Depending on how much filesystem traversal is
2665 2675 required, refreshing may negatively impact performance.
2666 2676
2667 2677 Values less than or equal to 0 always refresh.
2668 2678 (default: 20)
2669 2679
2670 2680 ``server-header``
2671 2681 Value for HTTP ``Server`` response header.
2672 2682
2673 2683 ``static``
2674 2684 Directory where static files are served from.
2675 2685
2676 2686 ``staticurl``
2677 2687 Base URL to use for static files. If unset, static files (e.g. the
2678 2688 hgicon.png favicon) will be served by the CGI script itself. Use
2679 2689 this setting to serve them directly with the HTTP server.
2680 2690 Example: ``http://hgserver/static/``.
2681 2691
2682 2692 ``stripes``
2683 2693 How many lines a "zebra stripe" should span in multi-line output.
2684 2694 Set to 0 to disable. (default: 1)
2685 2695
2686 2696 ``style``
2687 2697 Which template map style to use. The available options are the names of
2688 2698 subdirectories in the HTML templates path. (default: ``paper``)
2689 2699 Example: ``monoblue``.
2690 2700
2691 2701 ``templates``
2692 2702 Where to find the HTML templates. The default path to the HTML templates
2693 2703 can be obtained from ``hg debuginstall``.
2694 2704
2695 2705 ``websub``
2696 2706 ----------
2697 2707
2698 2708 Web substitution filter definition. You can use this section to
2699 2709 define a set of regular expression substitution patterns which
2700 2710 let you automatically modify the hgweb server output.
2701 2711
2702 2712 The default hgweb templates only apply these substitution patterns
2703 2713 on the revision description fields. You can apply them anywhere
2704 2714 you want when you create your own templates by adding calls to the
2705 2715 "websub" filter (usually after calling the "escape" filter).
2706 2716
2707 2717 This can be used, for example, to convert issue references to links
2708 2718 to your issue tracker, or to convert "markdown-like" syntax into
2709 2719 HTML (see the examples below).
2710 2720
2711 2721 Each entry in this section names a substitution filter.
2712 2722 The value of each entry defines the substitution expression itself.
2713 2723 The websub expressions follow the old interhg extension syntax,
2714 2724 which in turn imitates the Unix sed replacement syntax::
2715 2725
2716 2726 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2717 2727
2718 2728 You can use any separator other than "/". The final "i" is optional
2719 2729 and indicates that the search must be case insensitive.
2720 2730
2721 2731 Examples::
2722 2732
2723 2733 [websub]
2724 2734 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2725 2735 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2726 2736 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2727 2737
2728 2738 ``worker``
2729 2739 ----------
2730 2740
2731 2741 Parallel master/worker configuration. We currently perform working
2732 2742 directory updates in parallel on Unix-like systems, which greatly
2733 2743 helps performance.
2734 2744
2735 2745 ``enabled``
2736 2746 Whether to enable workers code to be used.
2737 2747 (default: true)
2738 2748
2739 2749 ``numcpus``
2740 2750 Number of CPUs to use for parallel operations. A zero or
2741 2751 negative value is treated as ``use the default``.
2742 2752 (default: 4 or the number of CPUs on the system, whichever is larger)
2743 2753
2744 2754 ``backgroundclose``
2745 2755 Whether to enable closing file handles on background threads during certain
2746 2756 operations. Some platforms aren't very efficient at closing file
2747 2757 handles that have been written or appended to. By performing file closing
2748 2758 on background threads, file write rate can increase substantially.
2749 2759 (default: true on Windows, false elsewhere)
2750 2760
2751 2761 ``backgroundcloseminfilecount``
2752 2762 Minimum number of files required to trigger background file closing.
2753 2763 Operations not writing this many files won't start background close
2754 2764 threads.
2755 2765 (default: 2048)
2756 2766
2757 2767 ``backgroundclosemaxqueue``
2758 2768 The maximum number of opened file handles waiting to be closed in the
2759 2769 background. This option only has an effect if ``backgroundclose`` is
2760 2770 enabled.
2761 2771 (default: 384)
2762 2772
2763 2773 ``backgroundclosethreadcount``
2764 2774 Number of threads to process background file closes. Only relevant if
2765 2775 ``backgroundclose`` is enabled.
2766 2776 (default: 4)
@@ -1,3090 +1,3089 b''
1 1 # localrepo.py - read/write repository class for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import errno
11 11 import hashlib
12 12 import os
13 13 import random
14 14 import sys
15 15 import time
16 16 import weakref
17 17
18 18 from .i18n import _
19 19 from .node import (
20 20 bin,
21 21 hex,
22 22 nullid,
23 23 nullrev,
24 24 short,
25 25 )
26 26 from . import (
27 27 bookmarks,
28 28 branchmap,
29 29 bundle2,
30 30 changegroup,
31 31 changelog,
32 32 color,
33 33 context,
34 34 dirstate,
35 35 dirstateguard,
36 36 discovery,
37 37 encoding,
38 38 error,
39 39 exchange,
40 40 extensions,
41 41 filelog,
42 42 hook,
43 43 lock as lockmod,
44 44 manifest,
45 45 match as matchmod,
46 46 merge as mergemod,
47 47 mergeutil,
48 48 namespaces,
49 49 narrowspec,
50 50 obsolete,
51 51 pathutil,
52 52 phases,
53 53 pushkey,
54 54 pycompat,
55 55 repository,
56 56 repoview,
57 57 revset,
58 58 revsetlang,
59 59 scmutil,
60 60 sparse,
61 61 store as storemod,
62 62 subrepoutil,
63 63 tags as tagsmod,
64 64 transaction,
65 65 txnutil,
66 66 util,
67 67 vfs as vfsmod,
68 68 )
69 69 from .utils import (
70 70 interfaceutil,
71 71 procutil,
72 72 stringutil,
73 73 )
74 74
75 75 from .revlogutils import (
76 76 constants as revlogconst,
77 77 )
78 78
79 79 release = lockmod.release
80 80 urlerr = util.urlerr
81 81 urlreq = util.urlreq
82 82
83 83 # set of (path, vfs-location) tuples. vfs-location is:
84 84 # - 'plain for vfs relative paths
85 85 # - '' for svfs relative paths
86 86 _cachedfiles = set()
87 87
88 88 class _basefilecache(scmutil.filecache):
89 89 """All filecache usage on repo are done for logic that should be unfiltered
90 90 """
91 91 def __get__(self, repo, type=None):
92 92 if repo is None:
93 93 return self
94 94 # proxy to unfiltered __dict__ since filtered repo has no entry
95 95 unfi = repo.unfiltered()
96 96 try:
97 97 return unfi.__dict__[self.sname]
98 98 except KeyError:
99 99 pass
100 100 return super(_basefilecache, self).__get__(unfi, type)
101 101
102 102 def set(self, repo, value):
103 103 return super(_basefilecache, self).set(repo.unfiltered(), value)
104 104
105 105 class repofilecache(_basefilecache):
106 106 """filecache for files in .hg but outside of .hg/store"""
107 107 def __init__(self, *paths):
108 108 super(repofilecache, self).__init__(*paths)
109 109 for path in paths:
110 110 _cachedfiles.add((path, 'plain'))
111 111
112 112 def join(self, obj, fname):
113 113 return obj.vfs.join(fname)
114 114
115 115 class storecache(_basefilecache):
116 116 """filecache for files in the store"""
117 117 def __init__(self, *paths):
118 118 super(storecache, self).__init__(*paths)
119 119 for path in paths:
120 120 _cachedfiles.add((path, ''))
121 121
122 122 def join(self, obj, fname):
123 123 return obj.sjoin(fname)
124 124
125 125 def isfilecached(repo, name):
126 126 """check if a repo has already cached "name" filecache-ed property
127 127
128 128 This returns (cachedobj-or-None, iscached) tuple.
129 129 """
130 130 cacheentry = repo.unfiltered()._filecache.get(name, None)
131 131 if not cacheentry:
132 132 return None, False
133 133 return cacheentry.obj, True
134 134
135 135 class unfilteredpropertycache(util.propertycache):
136 136 """propertycache that apply to unfiltered repo only"""
137 137
138 138 def __get__(self, repo, type=None):
139 139 unfi = repo.unfiltered()
140 140 if unfi is repo:
141 141 return super(unfilteredpropertycache, self).__get__(unfi)
142 142 return getattr(unfi, self.name)
143 143
144 144 class filteredpropertycache(util.propertycache):
145 145 """propertycache that must take filtering in account"""
146 146
147 147 def cachevalue(self, obj, value):
148 148 object.__setattr__(obj, self.name, value)
149 149
150 150
151 151 def hasunfilteredcache(repo, name):
152 152 """check if a repo has an unfilteredpropertycache value for <name>"""
153 153 return name in vars(repo.unfiltered())
154 154
155 155 def unfilteredmethod(orig):
156 156 """decorate method that always need to be run on unfiltered version"""
157 157 def wrapper(repo, *args, **kwargs):
158 158 return orig(repo.unfiltered(), *args, **kwargs)
159 159 return wrapper
160 160
161 161 moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
162 162 'unbundle'}
163 163 legacycaps = moderncaps.union({'changegroupsubset'})
164 164
165 165 @interfaceutil.implementer(repository.ipeercommandexecutor)
166 166 class localcommandexecutor(object):
167 167 def __init__(self, peer):
168 168 self._peer = peer
169 169 self._sent = False
170 170 self._closed = False
171 171
172 172 def __enter__(self):
173 173 return self
174 174
175 175 def __exit__(self, exctype, excvalue, exctb):
176 176 self.close()
177 177
178 178 def callcommand(self, command, args):
179 179 if self._sent:
180 180 raise error.ProgrammingError('callcommand() cannot be used after '
181 181 'sendcommands()')
182 182
183 183 if self._closed:
184 184 raise error.ProgrammingError('callcommand() cannot be used after '
185 185 'close()')
186 186
187 187 # We don't need to support anything fancy. Just call the named
188 188 # method on the peer and return a resolved future.
189 189 fn = getattr(self._peer, pycompat.sysstr(command))
190 190
191 191 f = pycompat.futures.Future()
192 192
193 193 try:
194 194 result = fn(**pycompat.strkwargs(args))
195 195 except Exception:
196 196 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
197 197 else:
198 198 f.set_result(result)
199 199
200 200 return f
201 201
202 202 def sendcommands(self):
203 203 self._sent = True
204 204
205 205 def close(self):
206 206 self._closed = True
207 207
208 208 @interfaceutil.implementer(repository.ipeercommands)
209 209 class localpeer(repository.peer):
210 210 '''peer for a local repo; reflects only the most recent API'''
211 211
212 212 def __init__(self, repo, caps=None):
213 213 super(localpeer, self).__init__()
214 214
215 215 if caps is None:
216 216 caps = moderncaps.copy()
217 217 self._repo = repo.filtered('served')
218 218 self.ui = repo.ui
219 219 self._caps = repo._restrictcapabilities(caps)
220 220
221 221 # Begin of _basepeer interface.
222 222
223 223 def url(self):
224 224 return self._repo.url()
225 225
226 226 def local(self):
227 227 return self._repo
228 228
229 229 def peer(self):
230 230 return self
231 231
232 232 def canpush(self):
233 233 return True
234 234
235 235 def close(self):
236 236 self._repo.close()
237 237
238 238 # End of _basepeer interface.
239 239
240 240 # Begin of _basewirecommands interface.
241 241
242 242 def branchmap(self):
243 243 return self._repo.branchmap()
244 244
245 245 def capabilities(self):
246 246 return self._caps
247 247
248 248 def clonebundles(self):
249 249 return self._repo.tryread('clonebundles.manifest')
250 250
251 251 def debugwireargs(self, one, two, three=None, four=None, five=None):
252 252 """Used to test argument passing over the wire"""
253 253 return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
254 254 pycompat.bytestr(four),
255 255 pycompat.bytestr(five))
256 256
257 257 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
258 258 **kwargs):
259 259 chunks = exchange.getbundlechunks(self._repo, source, heads=heads,
260 260 common=common, bundlecaps=bundlecaps,
261 261 **kwargs)[1]
262 262 cb = util.chunkbuffer(chunks)
263 263
264 264 if exchange.bundle2requested(bundlecaps):
265 265 # When requesting a bundle2, getbundle returns a stream to make the
266 266 # wire level function happier. We need to build a proper object
267 267 # from it in local peer.
268 268 return bundle2.getunbundler(self.ui, cb)
269 269 else:
270 270 return changegroup.getunbundler('01', cb, None)
271 271
272 272 def heads(self):
273 273 return self._repo.heads()
274 274
275 275 def known(self, nodes):
276 276 return self._repo.known(nodes)
277 277
278 278 def listkeys(self, namespace):
279 279 return self._repo.listkeys(namespace)
280 280
281 281 def lookup(self, key):
282 282 return self._repo.lookup(key)
283 283
284 284 def pushkey(self, namespace, key, old, new):
285 285 return self._repo.pushkey(namespace, key, old, new)
286 286
287 287 def stream_out(self):
288 288 raise error.Abort(_('cannot perform stream clone against local '
289 289 'peer'))
290 290
291 291 def unbundle(self, bundle, heads, url):
292 292 """apply a bundle on a repo
293 293
294 294 This function handles the repo locking itself."""
295 295 try:
296 296 try:
297 297 bundle = exchange.readbundle(self.ui, bundle, None)
298 298 ret = exchange.unbundle(self._repo, bundle, heads, 'push', url)
299 299 if util.safehasattr(ret, 'getchunks'):
300 300 # This is a bundle20 object, turn it into an unbundler.
301 301 # This little dance should be dropped eventually when the
302 302 # API is finally improved.
303 303 stream = util.chunkbuffer(ret.getchunks())
304 304 ret = bundle2.getunbundler(self.ui, stream)
305 305 return ret
306 306 except Exception as exc:
307 307 # If the exception contains output salvaged from a bundle2
308 308 # reply, we need to make sure it is printed before continuing
309 309 # to fail. So we build a bundle2 with such output and consume
310 310 # it directly.
311 311 #
312 312 # This is not very elegant but allows a "simple" solution for
313 313 # issue4594
314 314 output = getattr(exc, '_bundle2salvagedoutput', ())
315 315 if output:
316 316 bundler = bundle2.bundle20(self._repo.ui)
317 317 for out in output:
318 318 bundler.addpart(out)
319 319 stream = util.chunkbuffer(bundler.getchunks())
320 320 b = bundle2.getunbundler(self.ui, stream)
321 321 bundle2.processbundle(self._repo, b)
322 322 raise
323 323 except error.PushRaced as exc:
324 324 raise error.ResponseError(_('push failed:'),
325 325 stringutil.forcebytestr(exc))
326 326
327 327 # End of _basewirecommands interface.
328 328
329 329 # Begin of peer interface.
330 330
331 331 def commandexecutor(self):
332 332 return localcommandexecutor(self)
333 333
334 334 # End of peer interface.
335 335
336 336 @interfaceutil.implementer(repository.ipeerlegacycommands)
337 337 class locallegacypeer(localpeer):
338 338 '''peer extension which implements legacy methods too; used for tests with
339 339 restricted capabilities'''
340 340
341 341 def __init__(self, repo):
342 342 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
343 343
344 344 # Begin of baselegacywirecommands interface.
345 345
346 346 def between(self, pairs):
347 347 return self._repo.between(pairs)
348 348
349 349 def branches(self, nodes):
350 350 return self._repo.branches(nodes)
351 351
352 352 def changegroup(self, nodes, source):
353 353 outgoing = discovery.outgoing(self._repo, missingroots=nodes,
354 354 missingheads=self._repo.heads())
355 355 return changegroup.makechangegroup(self._repo, outgoing, '01', source)
356 356
357 357 def changegroupsubset(self, bases, heads, source):
358 358 outgoing = discovery.outgoing(self._repo, missingroots=bases,
359 359 missingheads=heads)
360 360 return changegroup.makechangegroup(self._repo, outgoing, '01', source)
361 361
362 362 # End of baselegacywirecommands interface.
363 363
364 364 # Increment the sub-version when the revlog v2 format changes to lock out old
365 365 # clients.
366 366 REVLOGV2_REQUIREMENT = 'exp-revlogv2.1'
367 367
368 368 # A repository with the sparserevlog feature will have delta chains that
369 369 # can spread over a larger span. Sparse reading cuts these large spans into
370 370 # pieces, so that each piece isn't too big.
371 371 # Without the sparserevlog capability, reading from the repository could use
372 372 # huge amounts of memory, because the whole span would be read at once,
373 373 # including all the intermediate revisions that aren't pertinent for the chain.
374 374 # This is why once a repository has enabled sparse-read, it becomes required.
375 375 SPARSEREVLOG_REQUIREMENT = 'sparserevlog'
376 376
377 377 # Functions receiving (ui, features) that extensions can register to impact
378 378 # the ability to load repositories with custom requirements. Only
379 379 # functions defined in loaded extensions are called.
380 380 #
381 381 # The function receives a set of requirement strings that the repository
382 382 # is capable of opening. Functions will typically add elements to the
383 383 # set to reflect that the extension knows how to handle that requirements.
384 384 featuresetupfuncs = set()
385 385
386 386 def makelocalrepository(baseui, path, intents=None):
387 387 """Create a local repository object.
388 388
389 389 Given arguments needed to construct a local repository, this function
390 390 performs various early repository loading functionality (such as
391 391 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
392 392 the repository can be opened, derives a type suitable for representing
393 393 that repository, and returns an instance of it.
394 394
395 395 The returned object conforms to the ``repository.completelocalrepository``
396 396 interface.
397 397
398 398 The repository type is derived by calling a series of factory functions
399 399 for each aspect/interface of the final repository. These are defined by
400 400 ``REPO_INTERFACES``.
401 401
402 402 Each factory function is called to produce a type implementing a specific
403 403 interface. The cumulative list of returned types will be combined into a
404 404 new type and that type will be instantiated to represent the local
405 405 repository.
406 406
407 407 The factory functions each receive various state that may be consulted
408 408 as part of deriving a type.
409 409
410 410 Extensions should wrap these factory functions to customize repository type
411 411 creation. Note that an extension's wrapped function may be called even if
412 412 that extension is not loaded for the repo being constructed. Extensions
413 413 should check if their ``__name__`` appears in the
414 414 ``extensionmodulenames`` set passed to the factory function and no-op if
415 415 not.
416 416 """
417 417 ui = baseui.copy()
418 418 # Prevent copying repo configuration.
419 419 ui.copy = baseui.copy
420 420
421 421 # Working directory VFS rooted at repository root.
422 422 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
423 423
424 424 # Main VFS for .hg/ directory.
425 425 hgpath = wdirvfs.join(b'.hg')
426 426 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
427 427
428 428 # The .hg/ path should exist and should be a directory. All other
429 429 # cases are errors.
430 430 if not hgvfs.isdir():
431 431 try:
432 432 hgvfs.stat()
433 433 except OSError as e:
434 434 if e.errno != errno.ENOENT:
435 435 raise
436 436
437 437 raise error.RepoError(_(b'repository %s not found') % path)
438 438
439 439 # .hg/requires file contains a newline-delimited list of
440 440 # features/capabilities the opener (us) must have in order to use
441 441 # the repository. This file was introduced in Mercurial 0.9.2,
442 442 # which means very old repositories may not have one. We assume
443 443 # a missing file translates to no requirements.
444 444 try:
445 445 requirements = set(hgvfs.read(b'requires').splitlines())
446 446 except IOError as e:
447 447 if e.errno != errno.ENOENT:
448 448 raise
449 449 requirements = set()
450 450
451 451 # The .hg/hgrc file may load extensions or contain config options
452 452 # that influence repository construction. Attempt to load it and
453 453 # process any new extensions that it may have pulled in.
454 454 if loadhgrc(ui, wdirvfs, hgvfs, requirements):
455 455 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
456 456 extensions.loadall(ui)
457 457 extensions.populateui(ui)
458 458
459 459 # Set of module names of extensions loaded for this repository.
460 460 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
461 461
462 462 supportedrequirements = gathersupportedrequirements(ui)
463 463
464 464 # We first validate the requirements are known.
465 465 ensurerequirementsrecognized(requirements, supportedrequirements)
466 466
467 467 # Then we validate that the known set is reasonable to use together.
468 468 ensurerequirementscompatible(ui, requirements)
469 469
470 470 # TODO there are unhandled edge cases related to opening repositories with
471 471 # shared storage. If storage is shared, we should also test for requirements
472 472 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
473 473 # that repo, as that repo may load extensions needed to open it. This is a
474 474 # bit complicated because we don't want the other hgrc to overwrite settings
475 475 # in this hgrc.
476 476 #
477 477 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
478 478 # file when sharing repos. But if a requirement is added after the share is
479 479 # performed, thereby introducing a new requirement for the opener, we may
480 480 # will not see that and could encounter a run-time error interacting with
481 481 # that shared store since it has an unknown-to-us requirement.
482 482
483 483 # At this point, we know we should be capable of opening the repository.
484 484 # Now get on with doing that.
485 485
486 486 features = set()
487 487
488 488 # The "store" part of the repository holds versioned data. How it is
489 489 # accessed is determined by various requirements. The ``shared`` or
490 490 # ``relshared`` requirements indicate the store lives in the path contained
491 491 # in the ``.hg/sharedpath`` file. This is an absolute path for
492 492 # ``shared`` and relative to ``.hg/`` for ``relshared``.
493 493 if b'shared' in requirements or b'relshared' in requirements:
494 494 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
495 495 if b'relshared' in requirements:
496 496 sharedpath = hgvfs.join(sharedpath)
497 497
498 498 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
499 499
500 500 if not sharedvfs.exists():
501 501 raise error.RepoError(_(b'.hg/sharedpath points to nonexistent '
502 502 b'directory %s') % sharedvfs.base)
503 503
504 504 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
505 505
506 506 storebasepath = sharedvfs.base
507 507 cachepath = sharedvfs.join(b'cache')
508 508 else:
509 509 storebasepath = hgvfs.base
510 510 cachepath = hgvfs.join(b'cache')
511 511 wcachepath = hgvfs.join(b'wcache')
512 512
513 513
514 514 # The store has changed over time and the exact layout is dictated by
515 515 # requirements. The store interface abstracts differences across all
516 516 # of them.
517 517 store = makestore(requirements, storebasepath,
518 518 lambda base: vfsmod.vfs(base, cacheaudited=True))
519 519 hgvfs.createmode = store.createmode
520 520
521 521 storevfs = store.vfs
522 522 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
523 523
524 524 # The cache vfs is used to manage cache files.
525 525 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
526 526 cachevfs.createmode = store.createmode
527 527 # The cache vfs is used to manage cache files related to the working copy
528 528 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
529 529 wcachevfs.createmode = store.createmode
530 530
531 531 # Now resolve the type for the repository object. We do this by repeatedly
532 532 # calling a factory function to produces types for specific aspects of the
533 533 # repo's operation. The aggregate returned types are used as base classes
534 534 # for a dynamically-derived type, which will represent our new repository.
535 535
536 536 bases = []
537 537 extrastate = {}
538 538
539 539 for iface, fn in REPO_INTERFACES:
540 540 # We pass all potentially useful state to give extensions tons of
541 541 # flexibility.
542 542 typ = fn()(ui=ui,
543 543 intents=intents,
544 544 requirements=requirements,
545 545 features=features,
546 546 wdirvfs=wdirvfs,
547 547 hgvfs=hgvfs,
548 548 store=store,
549 549 storevfs=storevfs,
550 550 storeoptions=storevfs.options,
551 551 cachevfs=cachevfs,
552 552 wcachevfs=wcachevfs,
553 553 extensionmodulenames=extensionmodulenames,
554 554 extrastate=extrastate,
555 555 baseclasses=bases)
556 556
557 557 if not isinstance(typ, type):
558 558 raise error.ProgrammingError('unable to construct type for %s' %
559 559 iface)
560 560
561 561 bases.append(typ)
562 562
563 563 # type() allows you to use characters in type names that wouldn't be
564 564 # recognized as Python symbols in source code. We abuse that to add
565 565 # rich information about our constructed repo.
566 566 name = pycompat.sysstr(b'derivedrepo:%s<%s>' % (
567 567 wdirvfs.base,
568 568 b','.join(sorted(requirements))))
569 569
570 570 cls = type(name, tuple(bases), {})
571 571
572 572 return cls(
573 573 baseui=baseui,
574 574 ui=ui,
575 575 origroot=path,
576 576 wdirvfs=wdirvfs,
577 577 hgvfs=hgvfs,
578 578 requirements=requirements,
579 579 supportedrequirements=supportedrequirements,
580 580 sharedpath=storebasepath,
581 581 store=store,
582 582 cachevfs=cachevfs,
583 583 wcachevfs=wcachevfs,
584 584 features=features,
585 585 intents=intents)
586 586
587 587 def loadhgrc(ui, wdirvfs, hgvfs, requirements):
588 588 """Load hgrc files/content into a ui instance.
589 589
590 590 This is called during repository opening to load any additional
591 591 config files or settings relevant to the current repository.
592 592
593 593 Returns a bool indicating whether any additional configs were loaded.
594 594
595 595 Extensions should monkeypatch this function to modify how per-repo
596 596 configs are loaded. For example, an extension may wish to pull in
597 597 configs from alternate files or sources.
598 598 """
599 599 try:
600 600 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
601 601 return True
602 602 except IOError:
603 603 return False
604 604
605 605 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
606 606 """Perform additional actions after .hg/hgrc is loaded.
607 607
608 608 This function is called during repository loading immediately after
609 609 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
610 610
611 611 The function can be used to validate configs, automatically add
612 612 options (including extensions) based on requirements, etc.
613 613 """
614 614
615 615 # Map of requirements to list of extensions to load automatically when
616 616 # requirement is present.
617 617 autoextensions = {
618 618 b'largefiles': [b'largefiles'],
619 619 b'lfs': [b'lfs'],
620 620 }
621 621
622 622 for requirement, names in sorted(autoextensions.items()):
623 623 if requirement not in requirements:
624 624 continue
625 625
626 626 for name in names:
627 627 if not ui.hasconfig(b'extensions', name):
628 628 ui.setconfig(b'extensions', name, b'', source='autoload')
629 629
630 630 def gathersupportedrequirements(ui):
631 631 """Determine the complete set of recognized requirements."""
632 632 # Start with all requirements supported by this file.
633 633 supported = set(localrepository._basesupported)
634 634
635 635 # Execute ``featuresetupfuncs`` entries if they belong to an extension
636 636 # relevant to this ui instance.
637 637 modules = {m.__name__ for n, m in extensions.extensions(ui)}
638 638
639 639 for fn in featuresetupfuncs:
640 640 if fn.__module__ in modules:
641 641 fn(ui, supported)
642 642
643 643 # Add derived requirements from registered compression engines.
644 644 for name in util.compengines:
645 645 engine = util.compengines[name]
646 646 if engine.revlogheader():
647 647 supported.add(b'exp-compression-%s' % name)
648 648
649 649 return supported
650 650
651 651 def ensurerequirementsrecognized(requirements, supported):
652 652 """Validate that a set of local requirements is recognized.
653 653
654 654 Receives a set of requirements. Raises an ``error.RepoError`` if there
655 655 exists any requirement in that set that currently loaded code doesn't
656 656 recognize.
657 657
658 658 Returns a set of supported requirements.
659 659 """
660 660 missing = set()
661 661
662 662 for requirement in requirements:
663 663 if requirement in supported:
664 664 continue
665 665
666 666 if not requirement or not requirement[0:1].isalnum():
667 667 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
668 668
669 669 missing.add(requirement)
670 670
671 671 if missing:
672 672 raise error.RequirementError(
673 673 _(b'repository requires features unknown to this Mercurial: %s') %
674 674 b' '.join(sorted(missing)),
675 675 hint=_(b'see https://mercurial-scm.org/wiki/MissingRequirement '
676 676 b'for more information'))
677 677
678 678 def ensurerequirementscompatible(ui, requirements):
679 679 """Validates that a set of recognized requirements is mutually compatible.
680 680
681 681 Some requirements may not be compatible with others or require
682 682 config options that aren't enabled. This function is called during
683 683 repository opening to ensure that the set of requirements needed
684 684 to open a repository is sane and compatible with config options.
685 685
686 686 Extensions can monkeypatch this function to perform additional
687 687 checking.
688 688
689 689 ``error.RepoError`` should be raised on failure.
690 690 """
691 691 if b'exp-sparse' in requirements and not sparse.enabled:
692 692 raise error.RepoError(_(b'repository is using sparse feature but '
693 693 b'sparse is not enabled; enable the '
694 694 b'"sparse" extensions to access'))
695 695
696 696 def makestore(requirements, path, vfstype):
697 697 """Construct a storage object for a repository."""
698 698 if b'store' in requirements:
699 699 if b'fncache' in requirements:
700 700 return storemod.fncachestore(path, vfstype,
701 701 b'dotencode' in requirements)
702 702
703 703 return storemod.encodedstore(path, vfstype)
704 704
705 705 return storemod.basicstore(path, vfstype)
706 706
707 707 def resolvestorevfsoptions(ui, requirements, features):
708 708 """Resolve the options to pass to the store vfs opener.
709 709
710 710 The returned dict is used to influence behavior of the storage layer.
711 711 """
712 712 options = {}
713 713
714 714 if b'treemanifest' in requirements:
715 715 options[b'treemanifest'] = True
716 716
717 717 # experimental config: format.manifestcachesize
718 718 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
719 719 if manifestcachesize is not None:
720 720 options[b'manifestcachesize'] = manifestcachesize
721 721
722 722 # In the absence of another requirement superseding a revlog-related
723 723 # requirement, we have to assume the repo is using revlog version 0.
724 724 # This revlog format is super old and we don't bother trying to parse
725 725 # opener options for it because those options wouldn't do anything
726 726 # meaningful on such old repos.
727 727 if b'revlogv1' in requirements or REVLOGV2_REQUIREMENT in requirements:
728 728 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
729 729
730 730 return options
731 731
732 732 def resolverevlogstorevfsoptions(ui, requirements, features):
733 733 """Resolve opener options specific to revlogs."""
734 734
735 735 options = {}
736 736 options[b'flagprocessors'] = {}
737 737
738 738 if b'revlogv1' in requirements:
739 739 options[b'revlogv1'] = True
740 740 if REVLOGV2_REQUIREMENT in requirements:
741 741 options[b'revlogv2'] = True
742 742
743 743 if b'generaldelta' in requirements:
744 744 options[b'generaldelta'] = True
745 745
746 746 # experimental config: format.chunkcachesize
747 747 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
748 748 if chunkcachesize is not None:
749 749 options[b'chunkcachesize'] = chunkcachesize
750 750
751 751 deltabothparents = ui.configbool(b'storage',
752 752 b'revlog.optimize-delta-parent-choice')
753 753 options[b'deltabothparents'] = deltabothparents
754 754
755 755 options[b'lazydeltabase'] = not scmutil.gddeltaconfig(ui)
756 756
757 757 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
758 758 if 0 <= chainspan:
759 759 options[b'maxdeltachainspan'] = chainspan
760 760
761 761 mmapindexthreshold = ui.configbytes(b'experimental',
762 762 b'mmapindexthreshold')
763 763 if mmapindexthreshold is not None:
764 764 options[b'mmapindexthreshold'] = mmapindexthreshold
765 765
766 766 withsparseread = ui.configbool(b'experimental', b'sparse-read')
767 767 srdensitythres = float(ui.config(b'experimental',
768 768 b'sparse-read.density-threshold'))
769 769 srmingapsize = ui.configbytes(b'experimental',
770 770 b'sparse-read.min-gap-size')
771 771 options[b'with-sparse-read'] = withsparseread
772 772 options[b'sparse-read-density-threshold'] = srdensitythres
773 773 options[b'sparse-read-min-gap-size'] = srmingapsize
774 774
775 775 sparserevlog = SPARSEREVLOG_REQUIREMENT in requirements
776 776 options[b'sparse-revlog'] = sparserevlog
777 777 if sparserevlog:
778 778 options[b'generaldelta'] = True
779 779
780 780 maxchainlen = None
781 781 if sparserevlog:
782 782 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
783 783 # experimental config: format.maxchainlen
784 784 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
785 785 if maxchainlen is not None:
786 786 options[b'maxchainlen'] = maxchainlen
787 787
788 788 for r in requirements:
789 789 if r.startswith(b'exp-compression-'):
790 790 options[b'compengine'] = r[len(b'exp-compression-'):]
791 791
792 792 if repository.NARROW_REQUIREMENT in requirements:
793 793 options[b'enableellipsis'] = True
794 794
795 795 return options
796 796
797 797 def makemain(**kwargs):
798 798 """Produce a type conforming to ``ilocalrepositorymain``."""
799 799 return localrepository
800 800
801 801 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
802 802 class revlogfilestorage(object):
803 803 """File storage when using revlogs."""
804 804
805 805 def file(self, path):
806 806 if path[0] == b'/':
807 807 path = path[1:]
808 808
809 809 return filelog.filelog(self.svfs, path)
810 810
811 811 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
812 812 class revlognarrowfilestorage(object):
813 813 """File storage when using revlogs and narrow files."""
814 814
815 815 def file(self, path):
816 816 if path[0] == b'/':
817 817 path = path[1:]
818 818
819 819 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
820 820
821 821 def makefilestorage(requirements, features, **kwargs):
822 822 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
823 823 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
824 824 features.add(repository.REPO_FEATURE_STREAM_CLONE)
825 825
826 826 if repository.NARROW_REQUIREMENT in requirements:
827 827 return revlognarrowfilestorage
828 828 else:
829 829 return revlogfilestorage
830 830
831 831 # List of repository interfaces and factory functions for them. Each
832 832 # will be called in order during ``makelocalrepository()`` to iteratively
833 833 # derive the final type for a local repository instance. We capture the
834 834 # function as a lambda so we don't hold a reference and the module-level
835 835 # functions can be wrapped.
836 836 REPO_INTERFACES = [
837 837 (repository.ilocalrepositorymain, lambda: makemain),
838 838 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
839 839 ]
840 840
841 841 @interfaceutil.implementer(repository.ilocalrepositorymain)
842 842 class localrepository(object):
843 843 """Main class for representing local repositories.
844 844
845 845 All local repositories are instances of this class.
846 846
847 847 Constructed on its own, instances of this class are not usable as
848 848 repository objects. To obtain a usable repository object, call
849 849 ``hg.repository()``, ``localrepo.instance()``, or
850 850 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
851 851 ``instance()`` adds support for creating new repositories.
852 852 ``hg.repository()`` adds more extension integration, including calling
853 853 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
854 854 used.
855 855 """
856 856
857 857 # obsolete experimental requirements:
858 858 # - manifestv2: An experimental new manifest format that allowed
859 859 # for stem compression of long paths. Experiment ended up not
860 860 # being successful (repository sizes went up due to worse delta
861 861 # chains), and the code was deleted in 4.6.
862 862 supportedformats = {
863 863 'revlogv1',
864 864 'generaldelta',
865 865 'treemanifest',
866 866 REVLOGV2_REQUIREMENT,
867 867 SPARSEREVLOG_REQUIREMENT,
868 868 }
869 869 _basesupported = supportedformats | {
870 870 'store',
871 871 'fncache',
872 872 'shared',
873 873 'relshared',
874 874 'dotencode',
875 875 'exp-sparse',
876 876 'internal-phase'
877 877 }
878 878
879 879 # list of prefix for file which can be written without 'wlock'
880 880 # Extensions should extend this list when needed
881 881 _wlockfreeprefix = {
882 882 # We migh consider requiring 'wlock' for the next
883 883 # two, but pretty much all the existing code assume
884 884 # wlock is not needed so we keep them excluded for
885 885 # now.
886 886 'hgrc',
887 887 'requires',
888 888 # XXX cache is a complicatged business someone
889 889 # should investigate this in depth at some point
890 890 'cache/',
891 891 # XXX shouldn't be dirstate covered by the wlock?
892 892 'dirstate',
893 893 # XXX bisect was still a bit too messy at the time
894 894 # this changeset was introduced. Someone should fix
895 895 # the remainig bit and drop this line
896 896 'bisect.state',
897 897 }
898 898
899 899 def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, requirements,
900 900 supportedrequirements, sharedpath, store, cachevfs, wcachevfs,
901 901 features, intents=None):
902 902 """Create a new local repository instance.
903 903
904 904 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
905 905 or ``localrepo.makelocalrepository()`` for obtaining a new repository
906 906 object.
907 907
908 908 Arguments:
909 909
910 910 baseui
911 911 ``ui.ui`` instance that ``ui`` argument was based off of.
912 912
913 913 ui
914 914 ``ui.ui`` instance for use by the repository.
915 915
916 916 origroot
917 917 ``bytes`` path to working directory root of this repository.
918 918
919 919 wdirvfs
920 920 ``vfs.vfs`` rooted at the working directory.
921 921
922 922 hgvfs
923 923 ``vfs.vfs`` rooted at .hg/
924 924
925 925 requirements
926 926 ``set`` of bytestrings representing repository opening requirements.
927 927
928 928 supportedrequirements
929 929 ``set`` of bytestrings representing repository requirements that we
930 930 know how to open. May be a supetset of ``requirements``.
931 931
932 932 sharedpath
933 933 ``bytes`` Defining path to storage base directory. Points to a
934 934 ``.hg/`` directory somewhere.
935 935
936 936 store
937 937 ``store.basicstore`` (or derived) instance providing access to
938 938 versioned storage.
939 939
940 940 cachevfs
941 941 ``vfs.vfs`` used for cache files.
942 942
943 943 wcachevfs
944 944 ``vfs.vfs`` used for cache files related to the working copy.
945 945
946 946 features
947 947 ``set`` of bytestrings defining features/capabilities of this
948 948 instance.
949 949
950 950 intents
951 951 ``set`` of system strings indicating what this repo will be used
952 952 for.
953 953 """
954 954 self.baseui = baseui
955 955 self.ui = ui
956 956 self.origroot = origroot
957 957 # vfs rooted at working directory.
958 958 self.wvfs = wdirvfs
959 959 self.root = wdirvfs.base
960 960 # vfs rooted at .hg/. Used to access most non-store paths.
961 961 self.vfs = hgvfs
962 962 self.path = hgvfs.base
963 963 self.requirements = requirements
964 964 self.supported = supportedrequirements
965 965 self.sharedpath = sharedpath
966 966 self.store = store
967 967 self.cachevfs = cachevfs
968 968 self.wcachevfs = wcachevfs
969 969 self.features = features
970 970
971 971 self.filtername = None
972 972
973 973 if (self.ui.configbool('devel', 'all-warnings') or
974 974 self.ui.configbool('devel', 'check-locks')):
975 975 self.vfs.audit = self._getvfsward(self.vfs.audit)
976 976 # A list of callback to shape the phase if no data were found.
977 977 # Callback are in the form: func(repo, roots) --> processed root.
978 978 # This list it to be filled by extension during repo setup
979 979 self._phasedefaults = []
980 980
981 981 color.setup(self.ui)
982 982
983 983 self.spath = self.store.path
984 984 self.svfs = self.store.vfs
985 985 self.sjoin = self.store.join
986 986 if (self.ui.configbool('devel', 'all-warnings') or
987 987 self.ui.configbool('devel', 'check-locks')):
988 988 if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs
989 989 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
990 990 else: # standard vfs
991 991 self.svfs.audit = self._getsvfsward(self.svfs.audit)
992 992
993 993 self._dirstatevalidatewarned = False
994 994
995 995 self._branchcaches = {}
996 996 self._revbranchcache = None
997 997 self._filterpats = {}
998 998 self._datafilters = {}
999 999 self._transref = self._lockref = self._wlockref = None
1000 1000
1001 1001 # A cache for various files under .hg/ that tracks file changes,
1002 1002 # (used by the filecache decorator)
1003 1003 #
1004 1004 # Maps a property name to its util.filecacheentry
1005 1005 self._filecache = {}
1006 1006
1007 1007 # hold sets of revision to be filtered
1008 1008 # should be cleared when something might have changed the filter value:
1009 1009 # - new changesets,
1010 1010 # - phase change,
1011 1011 # - new obsolescence marker,
1012 1012 # - working directory parent change,
1013 1013 # - bookmark changes
1014 1014 self.filteredrevcache = {}
1015 1015
1016 1016 # post-dirstate-status hooks
1017 1017 self._postdsstatus = []
1018 1018
1019 1019 # generic mapping between names and nodes
1020 1020 self.names = namespaces.namespaces()
1021 1021
1022 1022 # Key to signature value.
1023 1023 self._sparsesignaturecache = {}
1024 1024 # Signature to cached matcher instance.
1025 1025 self._sparsematchercache = {}
1026 1026
1027 1027 def _getvfsward(self, origfunc):
1028 1028 """build a ward for self.vfs"""
1029 1029 rref = weakref.ref(self)
1030 1030 def checkvfs(path, mode=None):
1031 1031 ret = origfunc(path, mode=mode)
1032 1032 repo = rref()
1033 1033 if (repo is None
1034 1034 or not util.safehasattr(repo, '_wlockref')
1035 1035 or not util.safehasattr(repo, '_lockref')):
1036 1036 return
1037 1037 if mode in (None, 'r', 'rb'):
1038 1038 return
1039 1039 if path.startswith(repo.path):
1040 1040 # truncate name relative to the repository (.hg)
1041 1041 path = path[len(repo.path) + 1:]
1042 1042 if path.startswith('cache/'):
1043 1043 msg = 'accessing cache with vfs instead of cachevfs: "%s"'
1044 1044 repo.ui.develwarn(msg % path, stacklevel=3, config="cache-vfs")
1045 1045 if path.startswith('journal.') or path.startswith('undo.'):
1046 1046 # journal is covered by 'lock'
1047 1047 if repo._currentlock(repo._lockref) is None:
1048 1048 repo.ui.develwarn('write with no lock: "%s"' % path,
1049 1049 stacklevel=3, config='check-locks')
1050 1050 elif repo._currentlock(repo._wlockref) is None:
1051 1051 # rest of vfs files are covered by 'wlock'
1052 1052 #
1053 1053 # exclude special files
1054 1054 for prefix in self._wlockfreeprefix:
1055 1055 if path.startswith(prefix):
1056 1056 return
1057 1057 repo.ui.develwarn('write with no wlock: "%s"' % path,
1058 1058 stacklevel=3, config='check-locks')
1059 1059 return ret
1060 1060 return checkvfs
1061 1061
1062 1062 def _getsvfsward(self, origfunc):
1063 1063 """build a ward for self.svfs"""
1064 1064 rref = weakref.ref(self)
1065 1065 def checksvfs(path, mode=None):
1066 1066 ret = origfunc(path, mode=mode)
1067 1067 repo = rref()
1068 1068 if repo is None or not util.safehasattr(repo, '_lockref'):
1069 1069 return
1070 1070 if mode in (None, 'r', 'rb'):
1071 1071 return
1072 1072 if path.startswith(repo.sharedpath):
1073 1073 # truncate name relative to the repository (.hg)
1074 1074 path = path[len(repo.sharedpath) + 1:]
1075 1075 if repo._currentlock(repo._lockref) is None:
1076 1076 repo.ui.develwarn('write with no lock: "%s"' % path,
1077 1077 stacklevel=4)
1078 1078 return ret
1079 1079 return checksvfs
1080 1080
1081 1081 def close(self):
1082 1082 self._writecaches()
1083 1083
1084 1084 def _writecaches(self):
1085 1085 if self._revbranchcache:
1086 1086 self._revbranchcache.write()
1087 1087
1088 1088 def _restrictcapabilities(self, caps):
1089 1089 if self.ui.configbool('experimental', 'bundle2-advertise'):
1090 1090 caps = set(caps)
1091 1091 capsblob = bundle2.encodecaps(bundle2.getrepocaps(self,
1092 1092 role='client'))
1093 1093 caps.add('bundle2=' + urlreq.quote(capsblob))
1094 1094 return caps
1095 1095
1096 1096 def _writerequirements(self):
1097 1097 scmutil.writerequires(self.vfs, self.requirements)
1098 1098
1099 1099 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1100 1100 # self -> auditor -> self._checknested -> self
1101 1101
1102 1102 @property
1103 1103 def auditor(self):
1104 1104 # This is only used by context.workingctx.match in order to
1105 1105 # detect files in subrepos.
1106 1106 return pathutil.pathauditor(self.root, callback=self._checknested)
1107 1107
1108 1108 @property
1109 1109 def nofsauditor(self):
1110 1110 # This is only used by context.basectx.match in order to detect
1111 1111 # files in subrepos.
1112 1112 return pathutil.pathauditor(self.root, callback=self._checknested,
1113 1113 realfs=False, cached=True)
1114 1114
1115 1115 def _checknested(self, path):
1116 1116 """Determine if path is a legal nested repository."""
1117 1117 if not path.startswith(self.root):
1118 1118 return False
1119 1119 subpath = path[len(self.root) + 1:]
1120 1120 normsubpath = util.pconvert(subpath)
1121 1121
1122 1122 # XXX: Checking against the current working copy is wrong in
1123 1123 # the sense that it can reject things like
1124 1124 #
1125 1125 # $ hg cat -r 10 sub/x.txt
1126 1126 #
1127 1127 # if sub/ is no longer a subrepository in the working copy
1128 1128 # parent revision.
1129 1129 #
1130 1130 # However, it can of course also allow things that would have
1131 1131 # been rejected before, such as the above cat command if sub/
1132 1132 # is a subrepository now, but was a normal directory before.
1133 1133 # The old path auditor would have rejected by mistake since it
1134 1134 # panics when it sees sub/.hg/.
1135 1135 #
1136 1136 # All in all, checking against the working copy seems sensible
1137 1137 # since we want to prevent access to nested repositories on
1138 1138 # the filesystem *now*.
1139 1139 ctx = self[None]
1140 1140 parts = util.splitpath(subpath)
1141 1141 while parts:
1142 1142 prefix = '/'.join(parts)
1143 1143 if prefix in ctx.substate:
1144 1144 if prefix == normsubpath:
1145 1145 return True
1146 1146 else:
1147 1147 sub = ctx.sub(prefix)
1148 1148 return sub.checknested(subpath[len(prefix) + 1:])
1149 1149 else:
1150 1150 parts.pop()
1151 1151 return False
1152 1152
1153 1153 def peer(self):
1154 1154 return localpeer(self) # not cached to avoid reference cycle
1155 1155
1156 1156 def unfiltered(self):
1157 1157 """Return unfiltered version of the repository
1158 1158
1159 1159 Intended to be overwritten by filtered repo."""
1160 1160 return self
1161 1161
1162 1162 def filtered(self, name, visibilityexceptions=None):
1163 1163 """Return a filtered version of a repository"""
1164 1164 cls = repoview.newtype(self.unfiltered().__class__)
1165 1165 return cls(self, name, visibilityexceptions)
1166 1166
1167 1167 @repofilecache('bookmarks', 'bookmarks.current')
1168 1168 def _bookmarks(self):
1169 1169 return bookmarks.bmstore(self)
1170 1170
1171 1171 @property
1172 1172 def _activebookmark(self):
1173 1173 return self._bookmarks.active
1174 1174
1175 1175 # _phasesets depend on changelog. what we need is to call
1176 1176 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1177 1177 # can't be easily expressed in filecache mechanism.
1178 1178 @storecache('phaseroots', '00changelog.i')
1179 1179 def _phasecache(self):
1180 1180 return phases.phasecache(self, self._phasedefaults)
1181 1181
1182 1182 @storecache('obsstore')
1183 1183 def obsstore(self):
1184 1184 return obsolete.makestore(self.ui, self)
1185 1185
1186 1186 @storecache('00changelog.i')
1187 1187 def changelog(self):
1188 1188 return changelog.changelog(self.svfs,
1189 1189 trypending=txnutil.mayhavepending(self.root))
1190 1190
1191 1191 @storecache('00manifest.i')
1192 1192 def manifestlog(self):
1193 1193 rootstore = manifest.manifestrevlog(self.svfs)
1194 1194 return manifest.manifestlog(self.svfs, self, rootstore,
1195 1195 self._storenarrowmatch)
1196 1196
1197 1197 @repofilecache('dirstate')
1198 1198 def dirstate(self):
1199 1199 return self._makedirstate()
1200 1200
1201 1201 def _makedirstate(self):
1202 1202 """Extension point for wrapping the dirstate per-repo."""
1203 1203 sparsematchfn = lambda: sparse.matcher(self)
1204 1204
1205 1205 return dirstate.dirstate(self.vfs, self.ui, self.root,
1206 1206 self._dirstatevalidate, sparsematchfn)
1207 1207
1208 1208 def _dirstatevalidate(self, node):
1209 1209 try:
1210 1210 self.changelog.rev(node)
1211 1211 return node
1212 1212 except error.LookupError:
1213 1213 if not self._dirstatevalidatewarned:
1214 1214 self._dirstatevalidatewarned = True
1215 1215 self.ui.warn(_("warning: ignoring unknown"
1216 1216 " working parent %s!\n") % short(node))
1217 1217 return nullid
1218 1218
1219 1219 @storecache(narrowspec.FILENAME)
1220 1220 def narrowpats(self):
1221 1221 """matcher patterns for this repository's narrowspec
1222 1222
1223 1223 A tuple of (includes, excludes).
1224 1224 """
1225 1225 return narrowspec.load(self)
1226 1226
1227 1227 @storecache(narrowspec.FILENAME)
1228 1228 def _storenarrowmatch(self):
1229 1229 if repository.NARROW_REQUIREMENT not in self.requirements:
1230 1230 return matchmod.always(self.root, '')
1231 1231 include, exclude = self.narrowpats
1232 1232 return narrowspec.match(self.root, include=include, exclude=exclude)
1233 1233
1234 1234 @storecache(narrowspec.FILENAME)
1235 1235 def _narrowmatch(self):
1236 1236 if repository.NARROW_REQUIREMENT not in self.requirements:
1237 1237 return matchmod.always(self.root, '')
1238 1238 narrowspec.checkworkingcopynarrowspec(self)
1239 1239 include, exclude = self.narrowpats
1240 1240 return narrowspec.match(self.root, include=include, exclude=exclude)
1241 1241
1242 1242 def narrowmatch(self, match=None, includeexact=False):
1243 1243 """matcher corresponding the the repo's narrowspec
1244 1244
1245 1245 If `match` is given, then that will be intersected with the narrow
1246 1246 matcher.
1247 1247
1248 1248 If `includeexact` is True, then any exact matches from `match` will
1249 1249 be included even if they're outside the narrowspec.
1250 1250 """
1251 1251 if match:
1252 1252 if includeexact and not self._narrowmatch.always():
1253 1253 # do not exclude explicitly-specified paths so that they can
1254 1254 # be warned later on
1255 1255 em = matchmod.exact(match._root, match._cwd, match.files())
1256 1256 nm = matchmod.unionmatcher([self._narrowmatch, em])
1257 1257 return matchmod.intersectmatchers(match, nm)
1258 1258 return matchmod.intersectmatchers(match, self._narrowmatch)
1259 1259 return self._narrowmatch
1260 1260
1261 1261 def setnarrowpats(self, newincludes, newexcludes):
1262 1262 narrowspec.save(self, newincludes, newexcludes)
1263 1263 self.invalidate(clearfilecache=True)
1264 1264
1265 1265 def __getitem__(self, changeid):
1266 1266 if changeid is None:
1267 1267 return context.workingctx(self)
1268 1268 if isinstance(changeid, context.basectx):
1269 1269 return changeid
1270 1270 if isinstance(changeid, slice):
1271 1271 # wdirrev isn't contiguous so the slice shouldn't include it
1272 1272 return [self[i]
1273 1273 for i in pycompat.xrange(*changeid.indices(len(self)))
1274 1274 if i not in self.changelog.filteredrevs]
1275 1275 try:
1276 1276 if isinstance(changeid, int):
1277 1277 node = self.changelog.node(changeid)
1278 1278 rev = changeid
1279 1279 elif changeid == 'null':
1280 1280 node = nullid
1281 1281 rev = nullrev
1282 1282 elif changeid == 'tip':
1283 1283 node = self.changelog.tip()
1284 1284 rev = self.changelog.rev(node)
1285 1285 elif changeid == '.':
1286 1286 # this is a hack to delay/avoid loading obsmarkers
1287 1287 # when we know that '.' won't be hidden
1288 1288 node = self.dirstate.p1()
1289 1289 rev = self.unfiltered().changelog.rev(node)
1290 1290 elif len(changeid) == 20:
1291 1291 try:
1292 1292 node = changeid
1293 1293 rev = self.changelog.rev(changeid)
1294 1294 except error.FilteredLookupError:
1295 1295 changeid = hex(changeid) # for the error message
1296 1296 raise
1297 1297 except LookupError:
1298 1298 # check if it might have come from damaged dirstate
1299 1299 #
1300 1300 # XXX we could avoid the unfiltered if we had a recognizable
1301 1301 # exception for filtered changeset access
1302 1302 if (self.local()
1303 1303 and changeid in self.unfiltered().dirstate.parents()):
1304 1304 msg = _("working directory has unknown parent '%s'!")
1305 1305 raise error.Abort(msg % short(changeid))
1306 1306 changeid = hex(changeid) # for the error message
1307 1307 raise
1308 1308
1309 1309 elif len(changeid) == 40:
1310 1310 node = bin(changeid)
1311 1311 rev = self.changelog.rev(node)
1312 1312 else:
1313 1313 raise error.ProgrammingError(
1314 1314 "unsupported changeid '%s' of type %s" %
1315 1315 (changeid, type(changeid)))
1316 1316
1317 1317 return context.changectx(self, rev, node)
1318 1318
1319 1319 except (error.FilteredIndexError, error.FilteredLookupError):
1320 1320 raise error.FilteredRepoLookupError(_("filtered revision '%s'")
1321 1321 % pycompat.bytestr(changeid))
1322 1322 except (IndexError, LookupError):
1323 1323 raise error.RepoLookupError(
1324 1324 _("unknown revision '%s'") % pycompat.bytestr(changeid))
1325 1325 except error.WdirUnsupported:
1326 1326 return context.workingctx(self)
1327 1327
1328 1328 def __contains__(self, changeid):
1329 1329 """True if the given changeid exists
1330 1330
1331 1331 error.AmbiguousPrefixLookupError is raised if an ambiguous node
1332 1332 specified.
1333 1333 """
1334 1334 try:
1335 1335 self[changeid]
1336 1336 return True
1337 1337 except error.RepoLookupError:
1338 1338 return False
1339 1339
1340 1340 def __nonzero__(self):
1341 1341 return True
1342 1342
1343 1343 __bool__ = __nonzero__
1344 1344
1345 1345 def __len__(self):
1346 1346 # no need to pay the cost of repoview.changelog
1347 1347 unfi = self.unfiltered()
1348 1348 return len(unfi.changelog)
1349 1349
1350 1350 def __iter__(self):
1351 1351 return iter(self.changelog)
1352 1352
1353 1353 def revs(self, expr, *args):
1354 1354 '''Find revisions matching a revset.
1355 1355
1356 1356 The revset is specified as a string ``expr`` that may contain
1357 1357 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1358 1358
1359 1359 Revset aliases from the configuration are not expanded. To expand
1360 1360 user aliases, consider calling ``scmutil.revrange()`` or
1361 1361 ``repo.anyrevs([expr], user=True)``.
1362 1362
1363 1363 Returns a revset.abstractsmartset, which is a list-like interface
1364 1364 that contains integer revisions.
1365 1365 '''
1366 1366 tree = revsetlang.spectree(expr, *args)
1367 1367 return revset.makematcher(tree)(self)
1368 1368
1369 1369 def set(self, expr, *args):
1370 1370 '''Find revisions matching a revset and emit changectx instances.
1371 1371
1372 1372 This is a convenience wrapper around ``revs()`` that iterates the
1373 1373 result and is a generator of changectx instances.
1374 1374
1375 1375 Revset aliases from the configuration are not expanded. To expand
1376 1376 user aliases, consider calling ``scmutil.revrange()``.
1377 1377 '''
1378 1378 for r in self.revs(expr, *args):
1379 1379 yield self[r]
1380 1380
1381 1381 def anyrevs(self, specs, user=False, localalias=None):
1382 1382 '''Find revisions matching one of the given revsets.
1383 1383
1384 1384 Revset aliases from the configuration are not expanded by default. To
1385 1385 expand user aliases, specify ``user=True``. To provide some local
1386 1386 definitions overriding user aliases, set ``localalias`` to
1387 1387 ``{name: definitionstring}``.
1388 1388 '''
1389 1389 if user:
1390 1390 m = revset.matchany(self.ui, specs,
1391 1391 lookup=revset.lookupfn(self),
1392 1392 localalias=localalias)
1393 1393 else:
1394 1394 m = revset.matchany(None, specs, localalias=localalias)
1395 1395 return m(self)
1396 1396
1397 1397 def url(self):
1398 1398 return 'file:' + self.root
1399 1399
1400 1400 def hook(self, name, throw=False, **args):
1401 1401 """Call a hook, passing this repo instance.
1402 1402
1403 1403 This a convenience method to aid invoking hooks. Extensions likely
1404 1404 won't call this unless they have registered a custom hook or are
1405 1405 replacing code that is expected to call a hook.
1406 1406 """
1407 1407 return hook.hook(self.ui, self, name, throw, **args)
1408 1408
1409 1409 @filteredpropertycache
1410 1410 def _tagscache(self):
1411 1411 '''Returns a tagscache object that contains various tags related
1412 1412 caches.'''
1413 1413
1414 1414 # This simplifies its cache management by having one decorated
1415 1415 # function (this one) and the rest simply fetch things from it.
1416 1416 class tagscache(object):
1417 1417 def __init__(self):
1418 1418 # These two define the set of tags for this repository. tags
1419 1419 # maps tag name to node; tagtypes maps tag name to 'global' or
1420 1420 # 'local'. (Global tags are defined by .hgtags across all
1421 1421 # heads, and local tags are defined in .hg/localtags.)
1422 1422 # They constitute the in-memory cache of tags.
1423 1423 self.tags = self.tagtypes = None
1424 1424
1425 1425 self.nodetagscache = self.tagslist = None
1426 1426
1427 1427 cache = tagscache()
1428 1428 cache.tags, cache.tagtypes = self._findtags()
1429 1429
1430 1430 return cache
1431 1431
1432 1432 def tags(self):
1433 1433 '''return a mapping of tag to node'''
1434 1434 t = {}
1435 1435 if self.changelog.filteredrevs:
1436 1436 tags, tt = self._findtags()
1437 1437 else:
1438 1438 tags = self._tagscache.tags
1439 1439 rev = self.changelog.rev
1440 1440 for k, v in tags.iteritems():
1441 1441 try:
1442 1442 # ignore tags to unknown nodes
1443 1443 rev(v)
1444 1444 t[k] = v
1445 1445 except (error.LookupError, ValueError):
1446 1446 pass
1447 1447 return t
1448 1448
1449 1449 def _findtags(self):
1450 1450 '''Do the hard work of finding tags. Return a pair of dicts
1451 1451 (tags, tagtypes) where tags maps tag name to node, and tagtypes
1452 1452 maps tag name to a string like \'global\' or \'local\'.
1453 1453 Subclasses or extensions are free to add their own tags, but
1454 1454 should be aware that the returned dicts will be retained for the
1455 1455 duration of the localrepo object.'''
1456 1456
1457 1457 # XXX what tagtype should subclasses/extensions use? Currently
1458 1458 # mq and bookmarks add tags, but do not set the tagtype at all.
1459 1459 # Should each extension invent its own tag type? Should there
1460 1460 # be one tagtype for all such "virtual" tags? Or is the status
1461 1461 # quo fine?
1462 1462
1463 1463
1464 1464 # map tag name to (node, hist)
1465 1465 alltags = tagsmod.findglobaltags(self.ui, self)
1466 1466 # map tag name to tag type
1467 1467 tagtypes = dict((tag, 'global') for tag in alltags)
1468 1468
1469 1469 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
1470 1470
1471 1471 # Build the return dicts. Have to re-encode tag names because
1472 1472 # the tags module always uses UTF-8 (in order not to lose info
1473 1473 # writing to the cache), but the rest of Mercurial wants them in
1474 1474 # local encoding.
1475 1475 tags = {}
1476 1476 for (name, (node, hist)) in alltags.iteritems():
1477 1477 if node != nullid:
1478 1478 tags[encoding.tolocal(name)] = node
1479 1479 tags['tip'] = self.changelog.tip()
1480 1480 tagtypes = dict([(encoding.tolocal(name), value)
1481 1481 for (name, value) in tagtypes.iteritems()])
1482 1482 return (tags, tagtypes)
1483 1483
1484 1484 def tagtype(self, tagname):
1485 1485 '''
1486 1486 return the type of the given tag. result can be:
1487 1487
1488 1488 'local' : a local tag
1489 1489 'global' : a global tag
1490 1490 None : tag does not exist
1491 1491 '''
1492 1492
1493 1493 return self._tagscache.tagtypes.get(tagname)
1494 1494
1495 1495 def tagslist(self):
1496 1496 '''return a list of tags ordered by revision'''
1497 1497 if not self._tagscache.tagslist:
1498 1498 l = []
1499 1499 for t, n in self.tags().iteritems():
1500 1500 l.append((self.changelog.rev(n), t, n))
1501 1501 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
1502 1502
1503 1503 return self._tagscache.tagslist
1504 1504
1505 1505 def nodetags(self, node):
1506 1506 '''return the tags associated with a node'''
1507 1507 if not self._tagscache.nodetagscache:
1508 1508 nodetagscache = {}
1509 1509 for t, n in self._tagscache.tags.iteritems():
1510 1510 nodetagscache.setdefault(n, []).append(t)
1511 1511 for tags in nodetagscache.itervalues():
1512 1512 tags.sort()
1513 1513 self._tagscache.nodetagscache = nodetagscache
1514 1514 return self._tagscache.nodetagscache.get(node, [])
1515 1515
1516 1516 def nodebookmarks(self, node):
1517 1517 """return the list of bookmarks pointing to the specified node"""
1518 1518 return self._bookmarks.names(node)
1519 1519
1520 1520 def branchmap(self):
1521 1521 '''returns a dictionary {branch: [branchheads]} with branchheads
1522 1522 ordered by increasing revision number'''
1523 1523 branchmap.updatecache(self)
1524 1524 return self._branchcaches[self.filtername]
1525 1525
1526 1526 @unfilteredmethod
1527 1527 def revbranchcache(self):
1528 1528 if not self._revbranchcache:
1529 1529 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
1530 1530 return self._revbranchcache
1531 1531
1532 1532 def branchtip(self, branch, ignoremissing=False):
1533 1533 '''return the tip node for a given branch
1534 1534
1535 1535 If ignoremissing is True, then this method will not raise an error.
1536 1536 This is helpful for callers that only expect None for a missing branch
1537 1537 (e.g. namespace).
1538 1538
1539 1539 '''
1540 1540 try:
1541 1541 return self.branchmap().branchtip(branch)
1542 1542 except KeyError:
1543 1543 if not ignoremissing:
1544 1544 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
1545 1545 else:
1546 1546 pass
1547 1547
1548 1548 def lookup(self, key):
1549 1549 return scmutil.revsymbol(self, key).node()
1550 1550
1551 1551 def lookupbranch(self, key):
1552 1552 if key in self.branchmap():
1553 1553 return key
1554 1554
1555 1555 return scmutil.revsymbol(self, key).branch()
1556 1556
1557 1557 def known(self, nodes):
1558 1558 cl = self.changelog
1559 1559 nm = cl.nodemap
1560 1560 filtered = cl.filteredrevs
1561 1561 result = []
1562 1562 for n in nodes:
1563 1563 r = nm.get(n)
1564 1564 resp = not (r is None or r in filtered)
1565 1565 result.append(resp)
1566 1566 return result
1567 1567
1568 1568 def local(self):
1569 1569 return self
1570 1570
1571 1571 def publishing(self):
1572 1572 # it's safe (and desirable) to trust the publish flag unconditionally
1573 1573 # so that we don't finalize changes shared between users via ssh or nfs
1574 1574 return self.ui.configbool('phases', 'publish', untrusted=True)
1575 1575
1576 1576 def cancopy(self):
1577 1577 # so statichttprepo's override of local() works
1578 1578 if not self.local():
1579 1579 return False
1580 1580 if not self.publishing():
1581 1581 return True
1582 1582 # if publishing we can't copy if there is filtered content
1583 1583 return not self.filtered('visible').changelog.filteredrevs
1584 1584
1585 1585 def shared(self):
1586 1586 '''the type of shared repository (None if not shared)'''
1587 1587 if self.sharedpath != self.path:
1588 1588 return 'store'
1589 1589 return None
1590 1590
1591 1591 def wjoin(self, f, *insidef):
1592 1592 return self.vfs.reljoin(self.root, f, *insidef)
1593 1593
1594 1594 def setparents(self, p1, p2=nullid):
1595 1595 with self.dirstate.parentchange():
1596 1596 copies = self.dirstate.setparents(p1, p2)
1597 1597 pctx = self[p1]
1598 1598 if copies:
1599 1599 # Adjust copy records, the dirstate cannot do it, it
1600 1600 # requires access to parents manifests. Preserve them
1601 1601 # only for entries added to first parent.
1602 1602 for f in copies:
1603 1603 if f not in pctx and copies[f] in pctx:
1604 1604 self.dirstate.copy(copies[f], f)
1605 1605 if p2 == nullid:
1606 1606 for f, s in sorted(self.dirstate.copies().items()):
1607 1607 if f not in pctx and s not in pctx:
1608 1608 self.dirstate.copy(None, f)
1609 1609
1610 1610 def filectx(self, path, changeid=None, fileid=None, changectx=None):
1611 1611 """changeid must be a changeset revision, if specified.
1612 1612 fileid can be a file revision or node."""
1613 1613 return context.filectx(self, path, changeid, fileid,
1614 1614 changectx=changectx)
1615 1615
1616 1616 def getcwd(self):
1617 1617 return self.dirstate.getcwd()
1618 1618
1619 1619 def pathto(self, f, cwd=None):
1620 1620 return self.dirstate.pathto(f, cwd)
1621 1621
1622 1622 def _loadfilter(self, filter):
1623 1623 if filter not in self._filterpats:
1624 1624 l = []
1625 1625 for pat, cmd in self.ui.configitems(filter):
1626 1626 if cmd == '!':
1627 1627 continue
1628 1628 mf = matchmod.match(self.root, '', [pat])
1629 1629 fn = None
1630 1630 params = cmd
1631 1631 for name, filterfn in self._datafilters.iteritems():
1632 1632 if cmd.startswith(name):
1633 1633 fn = filterfn
1634 1634 params = cmd[len(name):].lstrip()
1635 1635 break
1636 1636 if not fn:
1637 1637 fn = lambda s, c, **kwargs: procutil.filter(s, c)
1638 1638 # Wrap old filters not supporting keyword arguments
1639 1639 if not pycompat.getargspec(fn)[2]:
1640 1640 oldfn = fn
1641 1641 fn = lambda s, c, **kwargs: oldfn(s, c)
1642 1642 l.append((mf, fn, params))
1643 1643 self._filterpats[filter] = l
1644 1644 return self._filterpats[filter]
1645 1645
1646 1646 def _filter(self, filterpats, filename, data):
1647 1647 for mf, fn, cmd in filterpats:
1648 1648 if mf(filename):
1649 1649 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
1650 1650 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
1651 1651 break
1652 1652
1653 1653 return data
1654 1654
1655 1655 @unfilteredpropertycache
1656 1656 def _encodefilterpats(self):
1657 1657 return self._loadfilter('encode')
1658 1658
1659 1659 @unfilteredpropertycache
1660 1660 def _decodefilterpats(self):
1661 1661 return self._loadfilter('decode')
1662 1662
1663 1663 def adddatafilter(self, name, filter):
1664 1664 self._datafilters[name] = filter
1665 1665
1666 1666 def wread(self, filename):
1667 1667 if self.wvfs.islink(filename):
1668 1668 data = self.wvfs.readlink(filename)
1669 1669 else:
1670 1670 data = self.wvfs.read(filename)
1671 1671 return self._filter(self._encodefilterpats, filename, data)
1672 1672
1673 1673 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
1674 1674 """write ``data`` into ``filename`` in the working directory
1675 1675
1676 1676 This returns length of written (maybe decoded) data.
1677 1677 """
1678 1678 data = self._filter(self._decodefilterpats, filename, data)
1679 1679 if 'l' in flags:
1680 1680 self.wvfs.symlink(data, filename)
1681 1681 else:
1682 1682 self.wvfs.write(filename, data, backgroundclose=backgroundclose,
1683 1683 **kwargs)
1684 1684 if 'x' in flags:
1685 1685 self.wvfs.setflags(filename, False, True)
1686 1686 else:
1687 1687 self.wvfs.setflags(filename, False, False)
1688 1688 return len(data)
1689 1689
1690 1690 def wwritedata(self, filename, data):
1691 1691 return self._filter(self._decodefilterpats, filename, data)
1692 1692
1693 1693 def currenttransaction(self):
1694 1694 """return the current transaction or None if non exists"""
1695 1695 if self._transref:
1696 1696 tr = self._transref()
1697 1697 else:
1698 1698 tr = None
1699 1699
1700 1700 if tr and tr.running():
1701 1701 return tr
1702 1702 return None
1703 1703
1704 1704 def transaction(self, desc, report=None):
1705 1705 if (self.ui.configbool('devel', 'all-warnings')
1706 1706 or self.ui.configbool('devel', 'check-locks')):
1707 1707 if self._currentlock(self._lockref) is None:
1708 1708 raise error.ProgrammingError('transaction requires locking')
1709 1709 tr = self.currenttransaction()
1710 1710 if tr is not None:
1711 1711 return tr.nest(name=desc)
1712 1712
1713 1713 # abort here if the journal already exists
1714 1714 if self.svfs.exists("journal"):
1715 1715 raise error.RepoError(
1716 1716 _("abandoned transaction found"),
1717 1717 hint=_("run 'hg recover' to clean up transaction"))
1718 1718
1719 1719 idbase = "%.40f#%f" % (random.random(), time.time())
1720 1720 ha = hex(hashlib.sha1(idbase).digest())
1721 1721 txnid = 'TXN:' + ha
1722 1722 self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
1723 1723
1724 1724 self._writejournal(desc)
1725 1725 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
1726 1726 if report:
1727 1727 rp = report
1728 1728 else:
1729 1729 rp = self.ui.warn
1730 1730 vfsmap = {'plain': self.vfs, 'store': self.svfs} # root of .hg/
1731 1731 # we must avoid cyclic reference between repo and transaction.
1732 1732 reporef = weakref.ref(self)
1733 1733 # Code to track tag movement
1734 1734 #
1735 1735 # Since tags are all handled as file content, it is actually quite hard
1736 1736 # to track these movement from a code perspective. So we fallback to a
1737 1737 # tracking at the repository level. One could envision to track changes
1738 1738 # to the '.hgtags' file through changegroup apply but that fails to
1739 1739 # cope with case where transaction expose new heads without changegroup
1740 1740 # being involved (eg: phase movement).
1741 1741 #
1742 1742 # For now, We gate the feature behind a flag since this likely comes
1743 1743 # with performance impacts. The current code run more often than needed
1744 1744 # and do not use caches as much as it could. The current focus is on
1745 1745 # the behavior of the feature so we disable it by default. The flag
1746 1746 # will be removed when we are happy with the performance impact.
1747 1747 #
1748 1748 # Once this feature is no longer experimental move the following
1749 1749 # documentation to the appropriate help section:
1750 1750 #
1751 1751 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
1752 1752 # tags (new or changed or deleted tags). In addition the details of
1753 1753 # these changes are made available in a file at:
1754 1754 # ``REPOROOT/.hg/changes/tags.changes``.
1755 1755 # Make sure you check for HG_TAG_MOVED before reading that file as it
1756 1756 # might exist from a previous transaction even if no tag were touched
1757 1757 # in this one. Changes are recorded in a line base format::
1758 1758 #
1759 1759 # <action> <hex-node> <tag-name>\n
1760 1760 #
1761 1761 # Actions are defined as follow:
1762 1762 # "-R": tag is removed,
1763 1763 # "+A": tag is added,
1764 1764 # "-M": tag is moved (old value),
1765 1765 # "+M": tag is moved (new value),
1766 1766 tracktags = lambda x: None
1767 1767 # experimental config: experimental.hook-track-tags
1768 1768 shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags')
1769 1769 if desc != 'strip' and shouldtracktags:
1770 1770 oldheads = self.changelog.headrevs()
1771 1771 def tracktags(tr2):
1772 1772 repo = reporef()
1773 1773 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
1774 1774 newheads = repo.changelog.headrevs()
1775 1775 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
1776 1776 # notes: we compare lists here.
1777 1777 # As we do it only once buiding set would not be cheaper
1778 1778 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
1779 1779 if changes:
1780 1780 tr2.hookargs['tag_moved'] = '1'
1781 1781 with repo.vfs('changes/tags.changes', 'w',
1782 1782 atomictemp=True) as changesfile:
1783 1783 # note: we do not register the file to the transaction
1784 1784 # because we needs it to still exist on the transaction
1785 1785 # is close (for txnclose hooks)
1786 1786 tagsmod.writediff(changesfile, changes)
1787 1787 def validate(tr2):
1788 1788 """will run pre-closing hooks"""
1789 1789 # XXX the transaction API is a bit lacking here so we take a hacky
1790 1790 # path for now
1791 1791 #
1792 1792 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
1793 1793 # dict is copied before these run. In addition we needs the data
1794 1794 # available to in memory hooks too.
1795 1795 #
1796 1796 # Moreover, we also need to make sure this runs before txnclose
1797 1797 # hooks and there is no "pending" mechanism that would execute
1798 1798 # logic only if hooks are about to run.
1799 1799 #
1800 1800 # Fixing this limitation of the transaction is also needed to track
1801 1801 # other families of changes (bookmarks, phases, obsolescence).
1802 1802 #
1803 1803 # This will have to be fixed before we remove the experimental
1804 1804 # gating.
1805 1805 tracktags(tr2)
1806 1806 repo = reporef()
1807 1807 if repo.ui.configbool('experimental', 'single-head-per-branch'):
1808 1808 scmutil.enforcesinglehead(repo, tr2, desc)
1809 1809 if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
1810 1810 for name, (old, new) in sorted(tr.changes['bookmarks'].items()):
1811 1811 args = tr.hookargs.copy()
1812 1812 args.update(bookmarks.preparehookargs(name, old, new))
1813 1813 repo.hook('pretxnclose-bookmark', throw=True,
1814 1814 txnname=desc,
1815 1815 **pycompat.strkwargs(args))
1816 1816 if hook.hashook(repo.ui, 'pretxnclose-phase'):
1817 1817 cl = repo.unfiltered().changelog
1818 1818 for rev, (old, new) in tr.changes['phases'].items():
1819 1819 args = tr.hookargs.copy()
1820 1820 node = hex(cl.node(rev))
1821 1821 args.update(phases.preparehookargs(node, old, new))
1822 1822 repo.hook('pretxnclose-phase', throw=True, txnname=desc,
1823 1823 **pycompat.strkwargs(args))
1824 1824
1825 1825 repo.hook('pretxnclose', throw=True,
1826 1826 txnname=desc, **pycompat.strkwargs(tr.hookargs))
1827 1827 def releasefn(tr, success):
1828 1828 repo = reporef()
1829 1829 if success:
1830 1830 # this should be explicitly invoked here, because
1831 1831 # in-memory changes aren't written out at closing
1832 1832 # transaction, if tr.addfilegenerator (via
1833 1833 # dirstate.write or so) isn't invoked while
1834 1834 # transaction running
1835 1835 repo.dirstate.write(None)
1836 1836 else:
1837 1837 # discard all changes (including ones already written
1838 1838 # out) in this transaction
1839 1839 narrowspec.restorebackup(self, 'journal.narrowspec')
1840 1840 narrowspec.restorewcbackup(self, 'journal.narrowspec.dirstate')
1841 1841 repo.dirstate.restorebackup(None, 'journal.dirstate')
1842 1842
1843 1843 repo.invalidate(clearfilecache=True)
1844 1844
1845 1845 tr = transaction.transaction(rp, self.svfs, vfsmap,
1846 1846 "journal",
1847 1847 "undo",
1848 1848 aftertrans(renames),
1849 1849 self.store.createmode,
1850 1850 validator=validate,
1851 1851 releasefn=releasefn,
1852 1852 checkambigfiles=_cachedfiles,
1853 1853 name=desc)
1854 1854 tr.changes['origrepolen'] = len(self)
1855 1855 tr.changes['obsmarkers'] = set()
1856 1856 tr.changes['phases'] = {}
1857 1857 tr.changes['bookmarks'] = {}
1858 1858
1859 1859 tr.hookargs['txnid'] = txnid
1860 1860 # note: writing the fncache only during finalize mean that the file is
1861 1861 # outdated when running hooks. As fncache is used for streaming clone,
1862 1862 # this is not expected to break anything that happen during the hooks.
1863 1863 tr.addfinalize('flush-fncache', self.store.write)
1864 1864 def txnclosehook(tr2):
1865 1865 """To be run if transaction is successful, will schedule a hook run
1866 1866 """
1867 1867 # Don't reference tr2 in hook() so we don't hold a reference.
1868 1868 # This reduces memory consumption when there are multiple
1869 1869 # transactions per lock. This can likely go away if issue5045
1870 1870 # fixes the function accumulation.
1871 1871 hookargs = tr2.hookargs
1872 1872
1873 1873 def hookfunc():
1874 1874 repo = reporef()
1875 1875 if hook.hashook(repo.ui, 'txnclose-bookmark'):
1876 1876 bmchanges = sorted(tr.changes['bookmarks'].items())
1877 1877 for name, (old, new) in bmchanges:
1878 1878 args = tr.hookargs.copy()
1879 1879 args.update(bookmarks.preparehookargs(name, old, new))
1880 1880 repo.hook('txnclose-bookmark', throw=False,
1881 1881 txnname=desc, **pycompat.strkwargs(args))
1882 1882
1883 1883 if hook.hashook(repo.ui, 'txnclose-phase'):
1884 1884 cl = repo.unfiltered().changelog
1885 1885 phasemv = sorted(tr.changes['phases'].items())
1886 1886 for rev, (old, new) in phasemv:
1887 1887 args = tr.hookargs.copy()
1888 1888 node = hex(cl.node(rev))
1889 1889 args.update(phases.preparehookargs(node, old, new))
1890 1890 repo.hook('txnclose-phase', throw=False, txnname=desc,
1891 1891 **pycompat.strkwargs(args))
1892 1892
1893 1893 repo.hook('txnclose', throw=False, txnname=desc,
1894 1894 **pycompat.strkwargs(hookargs))
1895 1895 reporef()._afterlock(hookfunc)
1896 1896 tr.addfinalize('txnclose-hook', txnclosehook)
1897 1897 # Include a leading "-" to make it happen before the transaction summary
1898 1898 # reports registered via scmutil.registersummarycallback() whose names
1899 1899 # are 00-txnreport etc. That way, the caches will be warm when the
1900 1900 # callbacks run.
1901 1901 tr.addpostclose('-warm-cache', self._buildcacheupdater(tr))
1902 1902 def txnaborthook(tr2):
1903 1903 """To be run if transaction is aborted
1904 1904 """
1905 1905 reporef().hook('txnabort', throw=False, txnname=desc,
1906 1906 **pycompat.strkwargs(tr2.hookargs))
1907 1907 tr.addabort('txnabort-hook', txnaborthook)
1908 1908 # avoid eager cache invalidation. in-memory data should be identical
1909 1909 # to stored data if transaction has no error.
1910 1910 tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats)
1911 1911 self._transref = weakref.ref(tr)
1912 1912 scmutil.registersummarycallback(self, tr, desc)
1913 1913 return tr
1914 1914
1915 1915 def _journalfiles(self):
1916 1916 return ((self.svfs, 'journal'),
1917 1917 (self.svfs, 'journal.narrowspec'),
1918 1918 (self.vfs, 'journal.narrowspec.dirstate'),
1919 1919 (self.vfs, 'journal.dirstate'),
1920 1920 (self.vfs, 'journal.branch'),
1921 1921 (self.vfs, 'journal.desc'),
1922 1922 (self.vfs, 'journal.bookmarks'),
1923 1923 (self.svfs, 'journal.phaseroots'))
1924 1924
1925 1925 def undofiles(self):
1926 1926 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
1927 1927
1928 1928 @unfilteredmethod
1929 1929 def _writejournal(self, desc):
1930 1930 self.dirstate.savebackup(None, 'journal.dirstate')
1931 1931 narrowspec.savewcbackup(self, 'journal.narrowspec.dirstate')
1932 1932 narrowspec.savebackup(self, 'journal.narrowspec')
1933 1933 self.vfs.write("journal.branch",
1934 1934 encoding.fromlocal(self.dirstate.branch()))
1935 1935 self.vfs.write("journal.desc",
1936 1936 "%d\n%s\n" % (len(self), desc))
1937 1937 self.vfs.write("journal.bookmarks",
1938 1938 self.vfs.tryread("bookmarks"))
1939 1939 self.svfs.write("journal.phaseroots",
1940 1940 self.svfs.tryread("phaseroots"))
1941 1941
1942 1942 def recover(self):
1943 1943 with self.lock():
1944 1944 if self.svfs.exists("journal"):
1945 1945 self.ui.status(_("rolling back interrupted transaction\n"))
1946 1946 vfsmap = {'': self.svfs,
1947 1947 'plain': self.vfs,}
1948 1948 transaction.rollback(self.svfs, vfsmap, "journal",
1949 1949 self.ui.warn,
1950 1950 checkambigfiles=_cachedfiles)
1951 1951 self.invalidate()
1952 1952 return True
1953 1953 else:
1954 1954 self.ui.warn(_("no interrupted transaction available\n"))
1955 1955 return False
1956 1956
1957 1957 def rollback(self, dryrun=False, force=False):
1958 1958 wlock = lock = dsguard = None
1959 1959 try:
1960 1960 wlock = self.wlock()
1961 1961 lock = self.lock()
1962 1962 if self.svfs.exists("undo"):
1963 1963 dsguard = dirstateguard.dirstateguard(self, 'rollback')
1964 1964
1965 1965 return self._rollback(dryrun, force, dsguard)
1966 1966 else:
1967 1967 self.ui.warn(_("no rollback information available\n"))
1968 1968 return 1
1969 1969 finally:
1970 1970 release(dsguard, lock, wlock)
1971 1971
1972 1972 @unfilteredmethod # Until we get smarter cache management
1973 1973 def _rollback(self, dryrun, force, dsguard):
1974 1974 ui = self.ui
1975 1975 try:
1976 1976 args = self.vfs.read('undo.desc').splitlines()
1977 1977 (oldlen, desc, detail) = (int(args[0]), args[1], None)
1978 1978 if len(args) >= 3:
1979 1979 detail = args[2]
1980 1980 oldtip = oldlen - 1
1981 1981
1982 1982 if detail and ui.verbose:
1983 1983 msg = (_('repository tip rolled back to revision %d'
1984 1984 ' (undo %s: %s)\n')
1985 1985 % (oldtip, desc, detail))
1986 1986 else:
1987 1987 msg = (_('repository tip rolled back to revision %d'
1988 1988 ' (undo %s)\n')
1989 1989 % (oldtip, desc))
1990 1990 except IOError:
1991 1991 msg = _('rolling back unknown transaction\n')
1992 1992 desc = None
1993 1993
1994 1994 if not force and self['.'] != self['tip'] and desc == 'commit':
1995 1995 raise error.Abort(
1996 1996 _('rollback of last commit while not checked out '
1997 1997 'may lose data'), hint=_('use -f to force'))
1998 1998
1999 1999 ui.status(msg)
2000 2000 if dryrun:
2001 2001 return 0
2002 2002
2003 2003 parents = self.dirstate.parents()
2004 2004 self.destroying()
2005 2005 vfsmap = {'plain': self.vfs, '': self.svfs}
2006 2006 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn,
2007 2007 checkambigfiles=_cachedfiles)
2008 2008 if self.vfs.exists('undo.bookmarks'):
2009 2009 self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True)
2010 2010 if self.svfs.exists('undo.phaseroots'):
2011 2011 self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True)
2012 2012 self.invalidate()
2013 2013
2014 2014 parentgone = (parents[0] not in self.changelog.nodemap or
2015 2015 parents[1] not in self.changelog.nodemap)
2016 2016 if parentgone:
2017 2017 # prevent dirstateguard from overwriting already restored one
2018 2018 dsguard.close()
2019 2019
2020 2020 narrowspec.restorebackup(self, 'undo.narrowspec')
2021 2021 narrowspec.restorewcbackup(self, 'undo.narrowspec.dirstate')
2022 2022 self.dirstate.restorebackup(None, 'undo.dirstate')
2023 2023 try:
2024 2024 branch = self.vfs.read('undo.branch')
2025 2025 self.dirstate.setbranch(encoding.tolocal(branch))
2026 2026 except IOError:
2027 2027 ui.warn(_('named branch could not be reset: '
2028 2028 'current branch is still \'%s\'\n')
2029 2029 % self.dirstate.branch())
2030 2030
2031 2031 parents = tuple([p.rev() for p in self[None].parents()])
2032 2032 if len(parents) > 1:
2033 2033 ui.status(_('working directory now based on '
2034 2034 'revisions %d and %d\n') % parents)
2035 2035 else:
2036 2036 ui.status(_('working directory now based on '
2037 2037 'revision %d\n') % parents)
2038 2038 mergemod.mergestate.clean(self, self['.'].node())
2039 2039
2040 2040 # TODO: if we know which new heads may result from this rollback, pass
2041 2041 # them to destroy(), which will prevent the branchhead cache from being
2042 2042 # invalidated.
2043 2043 self.destroyed()
2044 2044 return 0
2045 2045
2046 2046 def _buildcacheupdater(self, newtransaction):
2047 2047 """called during transaction to build the callback updating cache
2048 2048
2049 2049 Lives on the repository to help extension who might want to augment
2050 2050 this logic. For this purpose, the created transaction is passed to the
2051 2051 method.
2052 2052 """
2053 2053 # we must avoid cyclic reference between repo and transaction.
2054 2054 reporef = weakref.ref(self)
2055 2055 def updater(tr):
2056 2056 repo = reporef()
2057 2057 repo.updatecaches(tr)
2058 2058 return updater
2059 2059
2060 2060 @unfilteredmethod
2061 2061 def updatecaches(self, tr=None, full=False):
2062 2062 """warm appropriate caches
2063 2063
2064 2064 If this function is called after a transaction closed. The transaction
2065 2065 will be available in the 'tr' argument. This can be used to selectively
2066 2066 update caches relevant to the changes in that transaction.
2067 2067
2068 2068 If 'full' is set, make sure all caches the function knows about have
2069 2069 up-to-date data. Even the ones usually loaded more lazily.
2070 2070 """
2071 2071 if tr is not None and tr.hookargs.get('source') == 'strip':
2072 2072 # During strip, many caches are invalid but
2073 2073 # later call to `destroyed` will refresh them.
2074 2074 return
2075 2075
2076 2076 if tr is None or tr.changes['origrepolen'] < len(self):
2077 2077 # updating the unfiltered branchmap should refresh all the others,
2078 2078 self.ui.debug('updating the branch cache\n')
2079 2079 branchmap.updatecache(self.filtered('served'))
2080 2080
2081 2081 if full:
2082 2082 rbc = self.revbranchcache()
2083 2083 for r in self.changelog:
2084 2084 rbc.branchinfo(r)
2085 2085 rbc.write()
2086 2086
2087 2087 # ensure the working copy parents are in the manifestfulltextcache
2088 2088 for ctx in self['.'].parents():
2089 2089 ctx.manifest() # accessing the manifest is enough
2090 2090
2091 2091 def invalidatecaches(self):
2092 2092
2093 2093 if r'_tagscache' in vars(self):
2094 2094 # can't use delattr on proxy
2095 2095 del self.__dict__[r'_tagscache']
2096 2096
2097 2097 self.unfiltered()._branchcaches.clear()
2098 2098 self.invalidatevolatilesets()
2099 2099 self._sparsesignaturecache.clear()
2100 2100
2101 2101 def invalidatevolatilesets(self):
2102 2102 self.filteredrevcache.clear()
2103 2103 obsolete.clearobscaches(self)
2104 2104
2105 2105 def invalidatedirstate(self):
2106 2106 '''Invalidates the dirstate, causing the next call to dirstate
2107 2107 to check if it was modified since the last time it was read,
2108 2108 rereading it if it has.
2109 2109
2110 2110 This is different to dirstate.invalidate() that it doesn't always
2111 2111 rereads the dirstate. Use dirstate.invalidate() if you want to
2112 2112 explicitly read the dirstate again (i.e. restoring it to a previous
2113 2113 known good state).'''
2114 2114 if hasunfilteredcache(self, r'dirstate'):
2115 2115 for k in self.dirstate._filecache:
2116 2116 try:
2117 2117 delattr(self.dirstate, k)
2118 2118 except AttributeError:
2119 2119 pass
2120 2120 delattr(self.unfiltered(), r'dirstate')
2121 2121
2122 2122 def invalidate(self, clearfilecache=False):
2123 2123 '''Invalidates both store and non-store parts other than dirstate
2124 2124
2125 2125 If a transaction is running, invalidation of store is omitted,
2126 2126 because discarding in-memory changes might cause inconsistency
2127 2127 (e.g. incomplete fncache causes unintentional failure, but
2128 2128 redundant one doesn't).
2129 2129 '''
2130 2130 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2131 2131 for k in list(self._filecache.keys()):
2132 2132 # dirstate is invalidated separately in invalidatedirstate()
2133 2133 if k == 'dirstate':
2134 2134 continue
2135 2135 if (k == 'changelog' and
2136 2136 self.currenttransaction() and
2137 2137 self.changelog._delayed):
2138 2138 # The changelog object may store unwritten revisions. We don't
2139 2139 # want to lose them.
2140 2140 # TODO: Solve the problem instead of working around it.
2141 2141 continue
2142 2142
2143 2143 if clearfilecache:
2144 2144 del self._filecache[k]
2145 2145 try:
2146 2146 delattr(unfiltered, k)
2147 2147 except AttributeError:
2148 2148 pass
2149 2149 self.invalidatecaches()
2150 2150 if not self.currenttransaction():
2151 2151 # TODO: Changing contents of store outside transaction
2152 2152 # causes inconsistency. We should make in-memory store
2153 2153 # changes detectable, and abort if changed.
2154 2154 self.store.invalidatecaches()
2155 2155
2156 2156 def invalidateall(self):
2157 2157 '''Fully invalidates both store and non-store parts, causing the
2158 2158 subsequent operation to reread any outside changes.'''
2159 2159 # extension should hook this to invalidate its caches
2160 2160 self.invalidate()
2161 2161 self.invalidatedirstate()
2162 2162
2163 2163 @unfilteredmethod
2164 2164 def _refreshfilecachestats(self, tr):
2165 2165 """Reload stats of cached files so that they are flagged as valid"""
2166 2166 for k, ce in self._filecache.items():
2167 2167 k = pycompat.sysstr(k)
2168 2168 if k == r'dirstate' or k not in self.__dict__:
2169 2169 continue
2170 2170 ce.refresh()
2171 2171
2172 2172 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc,
2173 2173 inheritchecker=None, parentenvvar=None):
2174 2174 parentlock = None
2175 2175 # the contents of parentenvvar are used by the underlying lock to
2176 2176 # determine whether it can be inherited
2177 2177 if parentenvvar is not None:
2178 2178 parentlock = encoding.environ.get(parentenvvar)
2179 2179
2180 2180 timeout = 0
2181 2181 warntimeout = 0
2182 2182 if wait:
2183 2183 timeout = self.ui.configint("ui", "timeout")
2184 2184 warntimeout = self.ui.configint("ui", "timeout.warn")
2185 2185 # internal config: ui.signal-safe-lock
2186 2186 signalsafe = self.ui.configbool('ui', 'signal-safe-lock')
2187 2187
2188 2188 l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout,
2189 2189 releasefn=releasefn,
2190 2190 acquirefn=acquirefn, desc=desc,
2191 2191 inheritchecker=inheritchecker,
2192 2192 parentlock=parentlock,
2193 2193 signalsafe=signalsafe)
2194 2194 return l
2195 2195
2196 2196 def _afterlock(self, callback):
2197 2197 """add a callback to be run when the repository is fully unlocked
2198 2198
2199 2199 The callback will be executed when the outermost lock is released
2200 2200 (with wlock being higher level than 'lock')."""
2201 2201 for ref in (self._wlockref, self._lockref):
2202 2202 l = ref and ref()
2203 2203 if l and l.held:
2204 2204 l.postrelease.append(callback)
2205 2205 break
2206 2206 else: # no lock have been found.
2207 2207 callback()
2208 2208
2209 2209 def lock(self, wait=True):
2210 2210 '''Lock the repository store (.hg/store) and return a weak reference
2211 2211 to the lock. Use this before modifying the store (e.g. committing or
2212 2212 stripping). If you are opening a transaction, get a lock as well.)
2213 2213
2214 2214 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2215 2215 'wlock' first to avoid a dead-lock hazard.'''
2216 2216 l = self._currentlock(self._lockref)
2217 2217 if l is not None:
2218 2218 l.lock()
2219 2219 return l
2220 2220
2221 2221 l = self._lock(self.svfs, "lock", wait, None,
2222 2222 self.invalidate, _('repository %s') % self.origroot)
2223 2223 self._lockref = weakref.ref(l)
2224 2224 return l
2225 2225
2226 2226 def _wlockchecktransaction(self):
2227 2227 if self.currenttransaction() is not None:
2228 2228 raise error.LockInheritanceContractViolation(
2229 2229 'wlock cannot be inherited in the middle of a transaction')
2230 2230
2231 2231 def wlock(self, wait=True):
2232 2232 '''Lock the non-store parts of the repository (everything under
2233 2233 .hg except .hg/store) and return a weak reference to the lock.
2234 2234
2235 2235 Use this before modifying files in .hg.
2236 2236
2237 2237 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2238 2238 'wlock' first to avoid a dead-lock hazard.'''
2239 2239 l = self._wlockref and self._wlockref()
2240 2240 if l is not None and l.held:
2241 2241 l.lock()
2242 2242 return l
2243 2243
2244 2244 # We do not need to check for non-waiting lock acquisition. Such
2245 2245 # acquisition would not cause dead-lock as they would just fail.
2246 2246 if wait and (self.ui.configbool('devel', 'all-warnings')
2247 2247 or self.ui.configbool('devel', 'check-locks')):
2248 2248 if self._currentlock(self._lockref) is not None:
2249 2249 self.ui.develwarn('"wlock" acquired after "lock"')
2250 2250
2251 2251 def unlock():
2252 2252 if self.dirstate.pendingparentchange():
2253 2253 self.dirstate.invalidate()
2254 2254 else:
2255 2255 self.dirstate.write(None)
2256 2256
2257 2257 self._filecache['dirstate'].refresh()
2258 2258
2259 2259 l = self._lock(self.vfs, "wlock", wait, unlock,
2260 2260 self.invalidatedirstate, _('working directory of %s') %
2261 2261 self.origroot,
2262 2262 inheritchecker=self._wlockchecktransaction,
2263 2263 parentenvvar='HG_WLOCK_LOCKER')
2264 2264 self._wlockref = weakref.ref(l)
2265 2265 return l
2266 2266
2267 2267 def _currentlock(self, lockref):
2268 2268 """Returns the lock if it's held, or None if it's not."""
2269 2269 if lockref is None:
2270 2270 return None
2271 2271 l = lockref()
2272 2272 if l is None or not l.held:
2273 2273 return None
2274 2274 return l
2275 2275
2276 2276 def currentwlock(self):
2277 2277 """Returns the wlock if it's held, or None if it's not."""
2278 2278 return self._currentlock(self._wlockref)
2279 2279
2280 2280 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
2281 2281 """
2282 2282 commit an individual file as part of a larger transaction
2283 2283 """
2284 2284
2285 2285 fname = fctx.path()
2286 2286 fparent1 = manifest1.get(fname, nullid)
2287 2287 fparent2 = manifest2.get(fname, nullid)
2288 2288 if isinstance(fctx, context.filectx):
2289 2289 node = fctx.filenode()
2290 2290 if node in [fparent1, fparent2]:
2291 2291 self.ui.debug('reusing %s filelog entry\n' % fname)
2292 2292 if manifest1.flags(fname) != fctx.flags():
2293 2293 changelist.append(fname)
2294 2294 return node
2295 2295
2296 2296 flog = self.file(fname)
2297 2297 meta = {}
2298 2298 copy = fctx.renamed()
2299 2299 if copy and copy[0] != fname:
2300 2300 # Mark the new revision of this file as a copy of another
2301 2301 # file. This copy data will effectively act as a parent
2302 2302 # of this new revision. If this is a merge, the first
2303 2303 # parent will be the nullid (meaning "look up the copy data")
2304 2304 # and the second one will be the other parent. For example:
2305 2305 #
2306 2306 # 0 --- 1 --- 3 rev1 changes file foo
2307 2307 # \ / rev2 renames foo to bar and changes it
2308 2308 # \- 2 -/ rev3 should have bar with all changes and
2309 2309 # should record that bar descends from
2310 2310 # bar in rev2 and foo in rev1
2311 2311 #
2312 2312 # this allows this merge to succeed:
2313 2313 #
2314 2314 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
2315 2315 # \ / merging rev3 and rev4 should use bar@rev2
2316 2316 # \- 2 --- 4 as the merge base
2317 2317 #
2318 2318
2319 2319 cfname = copy[0]
2320 2320 crev = manifest1.get(cfname)
2321 2321 newfparent = fparent2
2322 2322
2323 2323 if manifest2: # branch merge
2324 2324 if fparent2 == nullid or crev is None: # copied on remote side
2325 2325 if cfname in manifest2:
2326 2326 crev = manifest2[cfname]
2327 2327 newfparent = fparent1
2328 2328
2329 2329 # Here, we used to search backwards through history to try to find
2330 2330 # where the file copy came from if the source of a copy was not in
2331 2331 # the parent directory. However, this doesn't actually make sense to
2332 2332 # do (what does a copy from something not in your working copy even
2333 2333 # mean?) and it causes bugs (eg, issue4476). Instead, we will warn
2334 2334 # the user that copy information was dropped, so if they didn't
2335 2335 # expect this outcome it can be fixed, but this is the correct
2336 2336 # behavior in this circumstance.
2337 2337
2338 2338 if crev:
2339 2339 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
2340 2340 meta["copy"] = cfname
2341 2341 meta["copyrev"] = hex(crev)
2342 2342 fparent1, fparent2 = nullid, newfparent
2343 2343 else:
2344 2344 self.ui.warn(_("warning: can't find ancestor for '%s' "
2345 2345 "copied from '%s'!\n") % (fname, cfname))
2346 2346
2347 2347 elif fparent1 == nullid:
2348 2348 fparent1, fparent2 = fparent2, nullid
2349 2349 elif fparent2 != nullid:
2350 2350 # is one parent an ancestor of the other?
2351 2351 fparentancestors = flog.commonancestorsheads(fparent1, fparent2)
2352 2352 if fparent1 in fparentancestors:
2353 2353 fparent1, fparent2 = fparent2, nullid
2354 2354 elif fparent2 in fparentancestors:
2355 2355 fparent2 = nullid
2356 2356
2357 2357 # is the file changed?
2358 2358 text = fctx.data()
2359 2359 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
2360 2360 changelist.append(fname)
2361 2361 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
2362 2362 # are just the flags changed during merge?
2363 2363 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags():
2364 2364 changelist.append(fname)
2365 2365
2366 2366 return fparent1
2367 2367
2368 2368 def checkcommitpatterns(self, wctx, vdirs, match, status, fail):
2369 2369 """check for commit arguments that aren't committable"""
2370 2370 if match.isexact() or match.prefix():
2371 2371 matched = set(status.modified + status.added + status.removed)
2372 2372
2373 2373 for f in match.files():
2374 2374 f = self.dirstate.normalize(f)
2375 2375 if f == '.' or f in matched or f in wctx.substate:
2376 2376 continue
2377 2377 if f in status.deleted:
2378 2378 fail(f, _('file not found!'))
2379 2379 if f in vdirs: # visited directory
2380 2380 d = f + '/'
2381 2381 for mf in matched:
2382 2382 if mf.startswith(d):
2383 2383 break
2384 2384 else:
2385 2385 fail(f, _("no match under directory!"))
2386 2386 elif f not in self.dirstate:
2387 2387 fail(f, _("file not tracked!"))
2388 2388
2389 2389 @unfilteredmethod
2390 2390 def commit(self, text="", user=None, date=None, match=None, force=False,
2391 2391 editor=False, extra=None):
2392 2392 """Add a new revision to current repository.
2393 2393
2394 2394 Revision information is gathered from the working directory,
2395 2395 match can be used to filter the committed files. If editor is
2396 2396 supplied, it is called to get a commit message.
2397 2397 """
2398 2398 if extra is None:
2399 2399 extra = {}
2400 2400
2401 2401 def fail(f, msg):
2402 2402 raise error.Abort('%s: %s' % (f, msg))
2403 2403
2404 2404 if not match:
2405 2405 match = matchmod.always(self.root, '')
2406 2406
2407 2407 if not force:
2408 2408 vdirs = []
2409 2409 match.explicitdir = vdirs.append
2410 2410 match.bad = fail
2411 2411
2412 2412 wlock = lock = tr = None
2413 2413 try:
2414 2414 wlock = self.wlock()
2415 2415 lock = self.lock() # for recent changelog (see issue4368)
2416 2416
2417 2417 wctx = self[None]
2418 2418 merge = len(wctx.parents()) > 1
2419 2419
2420 2420 if not force and merge and not match.always():
2421 2421 raise error.Abort(_('cannot partially commit a merge '
2422 2422 '(do not specify files or patterns)'))
2423 2423
2424 2424 status = self.status(match=match, clean=force)
2425 2425 if force:
2426 2426 status.modified.extend(status.clean) # mq may commit clean files
2427 2427
2428 2428 # check subrepos
2429 2429 subs, commitsubs, newstate = subrepoutil.precommit(
2430 2430 self.ui, wctx, status, match, force=force)
2431 2431
2432 2432 # make sure all explicit patterns are matched
2433 2433 if not force:
2434 2434 self.checkcommitpatterns(wctx, vdirs, match, status, fail)
2435 2435
2436 2436 cctx = context.workingcommitctx(self, status,
2437 2437 text, user, date, extra)
2438 2438
2439 2439 # internal config: ui.allowemptycommit
2440 2440 allowemptycommit = (wctx.branch() != wctx.p1().branch()
2441 2441 or extra.get('close') or merge or cctx.files()
2442 2442 or self.ui.configbool('ui', 'allowemptycommit'))
2443 2443 if not allowemptycommit:
2444 2444 return None
2445 2445
2446 2446 if merge and cctx.deleted():
2447 2447 raise error.Abort(_("cannot commit merge with missing files"))
2448 2448
2449 2449 ms = mergemod.mergestate.read(self)
2450 2450 mergeutil.checkunresolved(ms)
2451 2451
2452 2452 if editor:
2453 2453 cctx._text = editor(self, cctx, subs)
2454 2454 edited = (text != cctx._text)
2455 2455
2456 2456 # Save commit message in case this transaction gets rolled back
2457 2457 # (e.g. by a pretxncommit hook). Leave the content alone on
2458 2458 # the assumption that the user will use the same editor again.
2459 2459 msgfn = self.savecommitmessage(cctx._text)
2460 2460
2461 2461 # commit subs and write new state
2462 2462 if subs:
2463 2463 for s in sorted(commitsubs):
2464 2464 sub = wctx.sub(s)
2465 2465 self.ui.status(_('committing subrepository %s\n') %
2466 2466 subrepoutil.subrelpath(sub))
2467 2467 sr = sub.commit(cctx._text, user, date)
2468 2468 newstate[s] = (newstate[s][0], sr)
2469 2469 subrepoutil.writestate(self, newstate)
2470 2470
2471 2471 p1, p2 = self.dirstate.parents()
2472 2472 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
2473 2473 try:
2474 2474 self.hook("precommit", throw=True, parent1=hookp1,
2475 2475 parent2=hookp2)
2476 2476 tr = self.transaction('commit')
2477 2477 ret = self.commitctx(cctx, True)
2478 2478 except: # re-raises
2479 2479 if edited:
2480 2480 self.ui.write(
2481 2481 _('note: commit message saved in %s\n') % msgfn)
2482 2482 raise
2483 2483 # update bookmarks, dirstate and mergestate
2484 2484 bookmarks.update(self, [p1, p2], ret)
2485 2485 cctx.markcommitted(ret)
2486 2486 ms.reset()
2487 2487 tr.close()
2488 2488
2489 2489 finally:
2490 2490 lockmod.release(tr, lock, wlock)
2491 2491
2492 2492 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
2493 2493 # hack for command that use a temporary commit (eg: histedit)
2494 2494 # temporary commit got stripped before hook release
2495 2495 if self.changelog.hasnode(ret):
2496 2496 self.hook("commit", node=node, parent1=parent1,
2497 2497 parent2=parent2)
2498 2498 self._afterlock(commithook)
2499 2499 return ret
2500 2500
2501 2501 @unfilteredmethod
2502 2502 def commitctx(self, ctx, error=False):
2503 2503 """Add a new revision to current repository.
2504 2504 Revision information is passed via the context argument.
2505 2505
2506 2506 ctx.files() should list all files involved in this commit, i.e.
2507 2507 modified/added/removed files. On merge, it may be wider than the
2508 2508 ctx.files() to be committed, since any file nodes derived directly
2509 2509 from p1 or p2 are excluded from the committed ctx.files().
2510 2510 """
2511 2511
2512 2512 tr = None
2513 2513 p1, p2 = ctx.p1(), ctx.p2()
2514 2514 user = ctx.user()
2515 2515
2516 2516 lock = self.lock()
2517 2517 try:
2518 2518 tr = self.transaction("commit")
2519 2519 trp = weakref.proxy(tr)
2520 2520
2521 2521 if ctx.manifestnode():
2522 2522 # reuse an existing manifest revision
2523 2523 self.ui.debug('reusing known manifest\n')
2524 2524 mn = ctx.manifestnode()
2525 2525 files = ctx.files()
2526 2526 elif ctx.files():
2527 2527 m1ctx = p1.manifestctx()
2528 2528 m2ctx = p2.manifestctx()
2529 2529 mctx = m1ctx.copy()
2530 2530
2531 2531 m = mctx.read()
2532 2532 m1 = m1ctx.read()
2533 2533 m2 = m2ctx.read()
2534 2534
2535 2535 # check in files
2536 2536 added = []
2537 2537 changed = []
2538 2538 removed = list(ctx.removed())
2539 2539 linkrev = len(self)
2540 2540 self.ui.note(_("committing files:\n"))
2541 2541 for f in sorted(ctx.modified() + ctx.added()):
2542 2542 self.ui.note(f + "\n")
2543 2543 try:
2544 2544 fctx = ctx[f]
2545 2545 if fctx is None:
2546 2546 removed.append(f)
2547 2547 else:
2548 2548 added.append(f)
2549 2549 m[f] = self._filecommit(fctx, m1, m2, linkrev,
2550 2550 trp, changed)
2551 2551 m.setflag(f, fctx.flags())
2552 2552 except OSError as inst:
2553 2553 self.ui.warn(_("trouble committing %s!\n") % f)
2554 2554 raise
2555 2555 except IOError as inst:
2556 2556 errcode = getattr(inst, 'errno', errno.ENOENT)
2557 2557 if error or errcode and errcode != errno.ENOENT:
2558 2558 self.ui.warn(_("trouble committing %s!\n") % f)
2559 2559 raise
2560 2560
2561 2561 # update manifest
2562 2562 removed = [f for f in sorted(removed) if f in m1 or f in m2]
2563 2563 drop = [f for f in removed if f in m]
2564 2564 for f in drop:
2565 2565 del m[f]
2566 2566 files = changed + removed
2567 2567 md = None
2568 2568 if not files:
2569 2569 # if no "files" actually changed in terms of the changelog,
2570 2570 # try hard to detect unmodified manifest entry so that the
2571 2571 # exact same commit can be reproduced later on convert.
2572 2572 md = m1.diff(m, scmutil.matchfiles(self, ctx.files()))
2573 2573 if not files and md:
2574 2574 self.ui.debug('not reusing manifest (no file change in '
2575 2575 'changelog, but manifest differs)\n')
2576 2576 if files or md:
2577 2577 self.ui.note(_("committing manifest\n"))
2578 2578 # we're using narrowmatch here since it's already applied at
2579 2579 # other stages (such as dirstate.walk), so we're already
2580 2580 # ignoring things outside of narrowspec in most cases. The
2581 2581 # one case where we might have files outside the narrowspec
2582 2582 # at this point is merges, and we already error out in the
2583 2583 # case where the merge has files outside of the narrowspec,
2584 2584 # so this is safe.
2585 2585 mn = mctx.write(trp, linkrev,
2586 2586 p1.manifestnode(), p2.manifestnode(),
2587 2587 added, drop, match=self.narrowmatch())
2588 2588 else:
2589 2589 self.ui.debug('reusing manifest form p1 (listed files '
2590 2590 'actually unchanged)\n')
2591 2591 mn = p1.manifestnode()
2592 2592 else:
2593 2593 self.ui.debug('reusing manifest from p1 (no file change)\n')
2594 2594 mn = p1.manifestnode()
2595 2595 files = []
2596 2596
2597 2597 # update changelog
2598 2598 self.ui.note(_("committing changelog\n"))
2599 2599 self.changelog.delayupdate(tr)
2600 2600 n = self.changelog.add(mn, files, ctx.description(),
2601 2601 trp, p1.node(), p2.node(),
2602 2602 user, ctx.date(), ctx.extra().copy())
2603 2603 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
2604 2604 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
2605 2605 parent2=xp2)
2606 2606 # set the new commit is proper phase
2607 2607 targetphase = subrepoutil.newcommitphase(self.ui, ctx)
2608 2608 if targetphase:
2609 2609 # retract boundary do not alter parent changeset.
2610 2610 # if a parent have higher the resulting phase will
2611 2611 # be compliant anyway
2612 2612 #
2613 2613 # if minimal phase was 0 we don't need to retract anything
2614 2614 phases.registernew(self, tr, targetphase, [n])
2615 2615 tr.close()
2616 2616 return n
2617 2617 finally:
2618 2618 if tr:
2619 2619 tr.release()
2620 2620 lock.release()
2621 2621
2622 2622 @unfilteredmethod
2623 2623 def destroying(self):
2624 2624 '''Inform the repository that nodes are about to be destroyed.
2625 2625 Intended for use by strip and rollback, so there's a common
2626 2626 place for anything that has to be done before destroying history.
2627 2627
2628 2628 This is mostly useful for saving state that is in memory and waiting
2629 2629 to be flushed when the current lock is released. Because a call to
2630 2630 destroyed is imminent, the repo will be invalidated causing those
2631 2631 changes to stay in memory (waiting for the next unlock), or vanish
2632 2632 completely.
2633 2633 '''
2634 2634 # When using the same lock to commit and strip, the phasecache is left
2635 2635 # dirty after committing. Then when we strip, the repo is invalidated,
2636 2636 # causing those changes to disappear.
2637 2637 if '_phasecache' in vars(self):
2638 2638 self._phasecache.write()
2639 2639
2640 2640 @unfilteredmethod
2641 2641 def destroyed(self):
2642 2642 '''Inform the repository that nodes have been destroyed.
2643 2643 Intended for use by strip and rollback, so there's a common
2644 2644 place for anything that has to be done after destroying history.
2645 2645 '''
2646 2646 # When one tries to:
2647 2647 # 1) destroy nodes thus calling this method (e.g. strip)
2648 2648 # 2) use phasecache somewhere (e.g. commit)
2649 2649 #
2650 2650 # then 2) will fail because the phasecache contains nodes that were
2651 2651 # removed. We can either remove phasecache from the filecache,
2652 2652 # causing it to reload next time it is accessed, or simply filter
2653 2653 # the removed nodes now and write the updated cache.
2654 2654 self._phasecache.filterunknown(self)
2655 2655 self._phasecache.write()
2656 2656
2657 2657 # refresh all repository caches
2658 2658 self.updatecaches()
2659 2659
2660 2660 # Ensure the persistent tag cache is updated. Doing it now
2661 2661 # means that the tag cache only has to worry about destroyed
2662 2662 # heads immediately after a strip/rollback. That in turn
2663 2663 # guarantees that "cachetip == currenttip" (comparing both rev
2664 2664 # and node) always means no nodes have been added or destroyed.
2665 2665
2666 2666 # XXX this is suboptimal when qrefresh'ing: we strip the current
2667 2667 # head, refresh the tag cache, then immediately add a new head.
2668 2668 # But I think doing it this way is necessary for the "instant
2669 2669 # tag cache retrieval" case to work.
2670 2670 self.invalidate()
2671 2671
2672 2672 def status(self, node1='.', node2=None, match=None,
2673 2673 ignored=False, clean=False, unknown=False,
2674 2674 listsubrepos=False):
2675 2675 '''a convenience method that calls node1.status(node2)'''
2676 2676 return self[node1].status(node2, match, ignored, clean, unknown,
2677 2677 listsubrepos)
2678 2678
2679 2679 def addpostdsstatus(self, ps):
2680 2680 """Add a callback to run within the wlock, at the point at which status
2681 2681 fixups happen.
2682 2682
2683 2683 On status completion, callback(wctx, status) will be called with the
2684 2684 wlock held, unless the dirstate has changed from underneath or the wlock
2685 2685 couldn't be grabbed.
2686 2686
2687 2687 Callbacks should not capture and use a cached copy of the dirstate --
2688 2688 it might change in the meanwhile. Instead, they should access the
2689 2689 dirstate via wctx.repo().dirstate.
2690 2690
2691 2691 This list is emptied out after each status run -- extensions should
2692 2692 make sure it adds to this list each time dirstate.status is called.
2693 2693 Extensions should also make sure they don't call this for statuses
2694 2694 that don't involve the dirstate.
2695 2695 """
2696 2696
2697 2697 # The list is located here for uniqueness reasons -- it is actually
2698 2698 # managed by the workingctx, but that isn't unique per-repo.
2699 2699 self._postdsstatus.append(ps)
2700 2700
2701 2701 def postdsstatus(self):
2702 2702 """Used by workingctx to get the list of post-dirstate-status hooks."""
2703 2703 return self._postdsstatus
2704 2704
2705 2705 def clearpostdsstatus(self):
2706 2706 """Used by workingctx to clear post-dirstate-status hooks."""
2707 2707 del self._postdsstatus[:]
2708 2708
2709 2709 def heads(self, start=None):
2710 2710 if start is None:
2711 2711 cl = self.changelog
2712 2712 headrevs = reversed(cl.headrevs())
2713 2713 return [cl.node(rev) for rev in headrevs]
2714 2714
2715 2715 heads = self.changelog.heads(start)
2716 2716 # sort the output in rev descending order
2717 2717 return sorted(heads, key=self.changelog.rev, reverse=True)
2718 2718
2719 2719 def branchheads(self, branch=None, start=None, closed=False):
2720 2720 '''return a (possibly filtered) list of heads for the given branch
2721 2721
2722 2722 Heads are returned in topological order, from newest to oldest.
2723 2723 If branch is None, use the dirstate branch.
2724 2724 If start is not None, return only heads reachable from start.
2725 2725 If closed is True, return heads that are marked as closed as well.
2726 2726 '''
2727 2727 if branch is None:
2728 2728 branch = self[None].branch()
2729 2729 branches = self.branchmap()
2730 2730 if branch not in branches:
2731 2731 return []
2732 2732 # the cache returns heads ordered lowest to highest
2733 2733 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
2734 2734 if start is not None:
2735 2735 # filter out the heads that cannot be reached from startrev
2736 2736 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
2737 2737 bheads = [h for h in bheads if h in fbheads]
2738 2738 return bheads
2739 2739
2740 2740 def branches(self, nodes):
2741 2741 if not nodes:
2742 2742 nodes = [self.changelog.tip()]
2743 2743 b = []
2744 2744 for n in nodes:
2745 2745 t = n
2746 2746 while True:
2747 2747 p = self.changelog.parents(n)
2748 2748 if p[1] != nullid or p[0] == nullid:
2749 2749 b.append((t, n, p[0], p[1]))
2750 2750 break
2751 2751 n = p[0]
2752 2752 return b
2753 2753
2754 2754 def between(self, pairs):
2755 2755 r = []
2756 2756
2757 2757 for top, bottom in pairs:
2758 2758 n, l, i = top, [], 0
2759 2759 f = 1
2760 2760
2761 2761 while n != bottom and n != nullid:
2762 2762 p = self.changelog.parents(n)[0]
2763 2763 if i == f:
2764 2764 l.append(n)
2765 2765 f = f * 2
2766 2766 n = p
2767 2767 i += 1
2768 2768
2769 2769 r.append(l)
2770 2770
2771 2771 return r
2772 2772
2773 2773 def checkpush(self, pushop):
2774 2774 """Extensions can override this function if additional checks have
2775 2775 to be performed before pushing, or call it if they override push
2776 2776 command.
2777 2777 """
2778 2778
2779 2779 @unfilteredpropertycache
2780 2780 def prepushoutgoinghooks(self):
2781 2781 """Return util.hooks consists of a pushop with repo, remote, outgoing
2782 2782 methods, which are called before pushing changesets.
2783 2783 """
2784 2784 return util.hooks()
2785 2785
2786 2786 def pushkey(self, namespace, key, old, new):
2787 2787 try:
2788 2788 tr = self.currenttransaction()
2789 2789 hookargs = {}
2790 2790 if tr is not None:
2791 2791 hookargs.update(tr.hookargs)
2792 2792 hookargs = pycompat.strkwargs(hookargs)
2793 2793 hookargs[r'namespace'] = namespace
2794 2794 hookargs[r'key'] = key
2795 2795 hookargs[r'old'] = old
2796 2796 hookargs[r'new'] = new
2797 2797 self.hook('prepushkey', throw=True, **hookargs)
2798 2798 except error.HookAbort as exc:
2799 2799 self.ui.write_err(_("pushkey-abort: %s\n") % exc)
2800 2800 if exc.hint:
2801 2801 self.ui.write_err(_("(%s)\n") % exc.hint)
2802 2802 return False
2803 2803 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
2804 2804 ret = pushkey.push(self, namespace, key, old, new)
2805 2805 def runhook():
2806 2806 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
2807 2807 ret=ret)
2808 2808 self._afterlock(runhook)
2809 2809 return ret
2810 2810
2811 2811 def listkeys(self, namespace):
2812 2812 self.hook('prelistkeys', throw=True, namespace=namespace)
2813 2813 self.ui.debug('listing keys for "%s"\n' % namespace)
2814 2814 values = pushkey.list(self, namespace)
2815 2815 self.hook('listkeys', namespace=namespace, values=values)
2816 2816 return values
2817 2817
2818 2818 def debugwireargs(self, one, two, three=None, four=None, five=None):
2819 2819 '''used to test argument passing over the wire'''
2820 2820 return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
2821 2821 pycompat.bytestr(four),
2822 2822 pycompat.bytestr(five))
2823 2823
2824 2824 def savecommitmessage(self, text):
2825 2825 fp = self.vfs('last-message.txt', 'wb')
2826 2826 try:
2827 2827 fp.write(text)
2828 2828 finally:
2829 2829 fp.close()
2830 2830 return self.pathto(fp.name[len(self.root) + 1:])
2831 2831
2832 2832 # used to avoid circular references so destructors work
2833 2833 def aftertrans(files):
2834 2834 renamefiles = [tuple(t) for t in files]
2835 2835 def a():
2836 2836 for vfs, src, dest in renamefiles:
2837 2837 # if src and dest refer to a same file, vfs.rename is a no-op,
2838 2838 # leaving both src and dest on disk. delete dest to make sure
2839 2839 # the rename couldn't be such a no-op.
2840 2840 vfs.tryunlink(dest)
2841 2841 try:
2842 2842 vfs.rename(src, dest)
2843 2843 except OSError: # journal file does not yet exist
2844 2844 pass
2845 2845 return a
2846 2846
2847 2847 def undoname(fn):
2848 2848 base, name = os.path.split(fn)
2849 2849 assert name.startswith('journal')
2850 2850 return os.path.join(base, name.replace('journal', 'undo', 1))
2851 2851
2852 2852 def instance(ui, path, create, intents=None, createopts=None):
2853 2853 localpath = util.urllocalpath(path)
2854 2854 if create:
2855 2855 createrepository(ui, localpath, createopts=createopts)
2856 2856
2857 2857 return makelocalrepository(ui, localpath, intents=intents)
2858 2858
2859 2859 def islocal(path):
2860 2860 return True
2861 2861
2862 2862 def defaultcreateopts(ui, createopts=None):
2863 2863 """Populate the default creation options for a repository.
2864 2864
2865 2865 A dictionary of explicitly requested creation options can be passed
2866 2866 in. Missing keys will be populated.
2867 2867 """
2868 2868 createopts = dict(createopts or {})
2869 2869
2870 2870 if 'backend' not in createopts:
2871 2871 # experimental config: storage.new-repo-backend
2872 2872 createopts['backend'] = ui.config('storage', 'new-repo-backend')
2873 2873
2874 2874 return createopts
2875 2875
2876 2876 def newreporequirements(ui, createopts):
2877 2877 """Determine the set of requirements for a new local repository.
2878 2878
2879 2879 Extensions can wrap this function to specify custom requirements for
2880 2880 new repositories.
2881 2881 """
2882 2882 # If the repo is being created from a shared repository, we copy
2883 2883 # its requirements.
2884 2884 if 'sharedrepo' in createopts:
2885 2885 requirements = set(createopts['sharedrepo'].requirements)
2886 2886 if createopts.get('sharedrelative'):
2887 2887 requirements.add('relshared')
2888 2888 else:
2889 2889 requirements.add('shared')
2890 2890
2891 2891 return requirements
2892 2892
2893 2893 if 'backend' not in createopts:
2894 2894 raise error.ProgrammingError('backend key not present in createopts; '
2895 2895 'was defaultcreateopts() called?')
2896 2896
2897 2897 if createopts['backend'] != 'revlogv1':
2898 2898 raise error.Abort(_('unable to determine repository requirements for '
2899 2899 'storage backend: %s') % createopts['backend'])
2900 2900
2901 2901 requirements = {'revlogv1'}
2902 2902 if ui.configbool('format', 'usestore'):
2903 2903 requirements.add('store')
2904 2904 if ui.configbool('format', 'usefncache'):
2905 2905 requirements.add('fncache')
2906 2906 if ui.configbool('format', 'dotencode'):
2907 2907 requirements.add('dotencode')
2908 2908
2909 2909 compengine = ui.config('experimental', 'format.compression')
2910 2910 if compengine not in util.compengines:
2911 2911 raise error.Abort(_('compression engine %s defined by '
2912 2912 'experimental.format.compression not available') %
2913 2913 compengine,
2914 2914 hint=_('run "hg debuginstall" to list available '
2915 2915 'compression engines'))
2916 2916
2917 2917 # zlib is the historical default and doesn't need an explicit requirement.
2918 2918 if compengine != 'zlib':
2919 2919 requirements.add('exp-compression-%s' % compengine)
2920 2920
2921 2921 if scmutil.gdinitconfig(ui):
2922 2922 requirements.add('generaldelta')
2923 # experimental config: format.sparse-revlog
2924 2923 if ui.configbool('format', 'sparse-revlog'):
2925 2924 requirements.add(SPARSEREVLOG_REQUIREMENT)
2926 2925 if ui.configbool('experimental', 'treemanifest'):
2927 2926 requirements.add('treemanifest')
2928 2927
2929 2928 revlogv2 = ui.config('experimental', 'revlogv2')
2930 2929 if revlogv2 == 'enable-unstable-format-and-corrupt-my-data':
2931 2930 requirements.remove('revlogv1')
2932 2931 # generaldelta is implied by revlogv2.
2933 2932 requirements.discard('generaldelta')
2934 2933 requirements.add(REVLOGV2_REQUIREMENT)
2935 2934 # experimental config: format.internal-phase
2936 2935 if ui.configbool('format', 'internal-phase'):
2937 2936 requirements.add('internal-phase')
2938 2937
2939 2938 if createopts.get('narrowfiles'):
2940 2939 requirements.add(repository.NARROW_REQUIREMENT)
2941 2940
2942 2941 if createopts.get('lfs'):
2943 2942 requirements.add('lfs')
2944 2943
2945 2944 return requirements
2946 2945
2947 2946 def filterknowncreateopts(ui, createopts):
2948 2947 """Filters a dict of repo creation options against options that are known.
2949 2948
2950 2949 Receives a dict of repo creation options and returns a dict of those
2951 2950 options that we don't know how to handle.
2952 2951
2953 2952 This function is called as part of repository creation. If the
2954 2953 returned dict contains any items, repository creation will not
2955 2954 be allowed, as it means there was a request to create a repository
2956 2955 with options not recognized by loaded code.
2957 2956
2958 2957 Extensions can wrap this function to filter out creation options
2959 2958 they know how to handle.
2960 2959 """
2961 2960 known = {
2962 2961 'backend',
2963 2962 'lfs',
2964 2963 'narrowfiles',
2965 2964 'sharedrepo',
2966 2965 'sharedrelative',
2967 2966 'shareditems',
2968 2967 'shallowfilestore',
2969 2968 }
2970 2969
2971 2970 return {k: v for k, v in createopts.items() if k not in known}
2972 2971
2973 2972 def createrepository(ui, path, createopts=None):
2974 2973 """Create a new repository in a vfs.
2975 2974
2976 2975 ``path`` path to the new repo's working directory.
2977 2976 ``createopts`` options for the new repository.
2978 2977
2979 2978 The following keys for ``createopts`` are recognized:
2980 2979
2981 2980 backend
2982 2981 The storage backend to use.
2983 2982 lfs
2984 2983 Repository will be created with ``lfs`` requirement. The lfs extension
2985 2984 will automatically be loaded when the repository is accessed.
2986 2985 narrowfiles
2987 2986 Set up repository to support narrow file storage.
2988 2987 sharedrepo
2989 2988 Repository object from which storage should be shared.
2990 2989 sharedrelative
2991 2990 Boolean indicating if the path to the shared repo should be
2992 2991 stored as relative. By default, the pointer to the "parent" repo
2993 2992 is stored as an absolute path.
2994 2993 shareditems
2995 2994 Set of items to share to the new repository (in addition to storage).
2996 2995 shallowfilestore
2997 2996 Indicates that storage for files should be shallow (not all ancestor
2998 2997 revisions are known).
2999 2998 """
3000 2999 createopts = defaultcreateopts(ui, createopts=createopts)
3001 3000
3002 3001 unknownopts = filterknowncreateopts(ui, createopts)
3003 3002
3004 3003 if not isinstance(unknownopts, dict):
3005 3004 raise error.ProgrammingError('filterknowncreateopts() did not return '
3006 3005 'a dict')
3007 3006
3008 3007 if unknownopts:
3009 3008 raise error.Abort(_('unable to create repository because of unknown '
3010 3009 'creation option: %s') %
3011 3010 ', '.join(sorted(unknownopts)),
3012 3011 hint=_('is a required extension not loaded?'))
3013 3012
3014 3013 requirements = newreporequirements(ui, createopts=createopts)
3015 3014
3016 3015 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3017 3016
3018 3017 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3019 3018 if hgvfs.exists():
3020 3019 raise error.RepoError(_('repository %s already exists') % path)
3021 3020
3022 3021 if 'sharedrepo' in createopts:
3023 3022 sharedpath = createopts['sharedrepo'].sharedpath
3024 3023
3025 3024 if createopts.get('sharedrelative'):
3026 3025 try:
3027 3026 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3028 3027 except (IOError, ValueError) as e:
3029 3028 # ValueError is raised on Windows if the drive letters differ
3030 3029 # on each path.
3031 3030 raise error.Abort(_('cannot calculate relative path'),
3032 3031 hint=stringutil.forcebytestr(e))
3033 3032
3034 3033 if not wdirvfs.exists():
3035 3034 wdirvfs.makedirs()
3036 3035
3037 3036 hgvfs.makedir(notindexed=True)
3038 3037 if 'sharedrepo' not in createopts:
3039 3038 hgvfs.mkdir(b'cache')
3040 3039 hgvfs.mkdir(b'wcache')
3041 3040
3042 3041 if b'store' in requirements and 'sharedrepo' not in createopts:
3043 3042 hgvfs.mkdir(b'store')
3044 3043
3045 3044 # We create an invalid changelog outside the store so very old
3046 3045 # Mercurial versions (which didn't know about the requirements
3047 3046 # file) encounter an error on reading the changelog. This
3048 3047 # effectively locks out old clients and prevents them from
3049 3048 # mucking with a repo in an unknown format.
3050 3049 #
3051 3050 # The revlog header has version 2, which won't be recognized by
3052 3051 # such old clients.
3053 3052 hgvfs.append(b'00changelog.i',
3054 3053 b'\0\0\0\2 dummy changelog to prevent using the old repo '
3055 3054 b'layout')
3056 3055
3057 3056 scmutil.writerequires(hgvfs, requirements)
3058 3057
3059 3058 # Write out file telling readers where to find the shared store.
3060 3059 if 'sharedrepo' in createopts:
3061 3060 hgvfs.write(b'sharedpath', sharedpath)
3062 3061
3063 3062 if createopts.get('shareditems'):
3064 3063 shared = b'\n'.join(sorted(createopts['shareditems'])) + b'\n'
3065 3064 hgvfs.write(b'shared', shared)
3066 3065
3067 3066 def poisonrepository(repo):
3068 3067 """Poison a repository instance so it can no longer be used."""
3069 3068 # Perform any cleanup on the instance.
3070 3069 repo.close()
3071 3070
3072 3071 # Our strategy is to replace the type of the object with one that
3073 3072 # has all attribute lookups result in error.
3074 3073 #
3075 3074 # But we have to allow the close() method because some constructors
3076 3075 # of repos call close() on repo references.
3077 3076 class poisonedrepository(object):
3078 3077 def __getattribute__(self, item):
3079 3078 if item == r'close':
3080 3079 return object.__getattribute__(self, item)
3081 3080
3082 3081 raise error.ProgrammingError('repo instances should not be used '
3083 3082 'after unshare')
3084 3083
3085 3084 def close(self):
3086 3085 pass
3087 3086
3088 3087 # We may have a repoview, which intercepts __setattr__. So be sure
3089 3088 # we operate at the lowest level possible.
3090 3089 object.__setattr__(repo, r'__class__', poisonedrepository)
@@ -1,3826 +1,3828 b''
1 1 Short help:
2 2
3 3 $ hg
4 4 Mercurial Distributed SCM
5 5
6 6 basic commands:
7 7
8 8 add add the specified files on the next commit
9 9 annotate show changeset information by line for each file
10 10 clone make a copy of an existing repository
11 11 commit commit the specified files or all outstanding changes
12 12 diff diff repository (or selected files)
13 13 export dump the header and diffs for one or more changesets
14 14 forget forget the specified files on the next commit
15 15 init create a new repository in the given directory
16 16 log show revision history of entire repository or files
17 17 merge merge another revision into working directory
18 18 pull pull changes from the specified source
19 19 push push changes to the specified destination
20 20 remove remove the specified files on the next commit
21 21 serve start stand-alone webserver
22 22 status show changed files in the working directory
23 23 summary summarize working directory state
24 24 update update working directory (or switch revisions)
25 25
26 26 (use 'hg help' for the full list of commands or 'hg -v' for details)
27 27
28 28 $ hg -q
29 29 add add the specified files on the next commit
30 30 annotate show changeset information by line for each file
31 31 clone make a copy of an existing repository
32 32 commit commit the specified files or all outstanding changes
33 33 diff diff repository (or selected files)
34 34 export dump the header and diffs for one or more changesets
35 35 forget forget the specified files on the next commit
36 36 init create a new repository in the given directory
37 37 log show revision history of entire repository or files
38 38 merge merge another revision into working directory
39 39 pull pull changes from the specified source
40 40 push push changes to the specified destination
41 41 remove remove the specified files on the next commit
42 42 serve start stand-alone webserver
43 43 status show changed files in the working directory
44 44 summary summarize working directory state
45 45 update update working directory (or switch revisions)
46 46
47 47 Extra extensions will be printed in help output in a non-reliable order since
48 48 the extension is unknown.
49 49 #if no-extraextensions
50 50
51 51 $ hg help
52 52 Mercurial Distributed SCM
53 53
54 54 list of commands:
55 55
56 56 Repository creation:
57 57
58 58 clone make a copy of an existing repository
59 59 init create a new repository in the given directory
60 60
61 61 Remote repository management:
62 62
63 63 incoming show new changesets found in source
64 64 outgoing show changesets not found in the destination
65 65 paths show aliases for remote repositories
66 66 pull pull changes from the specified source
67 67 push push changes to the specified destination
68 68 serve start stand-alone webserver
69 69
70 70 Change creation:
71 71
72 72 commit commit the specified files or all outstanding changes
73 73
74 74 Change manipulation:
75 75
76 76 backout reverse effect of earlier changeset
77 77 graft copy changes from other branches onto the current branch
78 78 merge merge another revision into working directory
79 79
80 80 Change organization:
81 81
82 82 bookmarks create a new bookmark or list existing bookmarks
83 83 branch set or show the current branch name
84 84 branches list repository named branches
85 85 phase set or show the current phase name
86 86 tag add one or more tags for the current or given revision
87 87 tags list repository tags
88 88
89 89 File content management:
90 90
91 91 annotate show changeset information by line for each file
92 92 cat output the current or given revision of files
93 93 copy mark files as copied for the next commit
94 94 diff diff repository (or selected files)
95 95 grep search revision history for a pattern in specified files
96 96
97 97 Change navigation:
98 98
99 99 bisect subdivision search of changesets
100 100 heads show branch heads
101 101 identify identify the working directory or specified revision
102 102 log show revision history of entire repository or files
103 103
104 104 Working directory management:
105 105
106 106 add add the specified files on the next commit
107 107 addremove add all new files, delete all missing files
108 108 files list tracked files
109 109 forget forget the specified files on the next commit
110 110 remove remove the specified files on the next commit
111 111 rename rename files; equivalent of copy + remove
112 112 resolve redo merges or set/view the merge status of files
113 113 revert restore files to their checkout state
114 114 root print the root (top) of the current working directory
115 115 status show changed files in the working directory
116 116 summary summarize working directory state
117 117 update update working directory (or switch revisions)
118 118
119 119 Change import/export:
120 120
121 121 archive create an unversioned archive of a repository revision
122 122 bundle create a bundle file
123 123 export dump the header and diffs for one or more changesets
124 124 import import an ordered set of patches
125 125 unbundle apply one or more bundle files
126 126
127 127 Repository maintenance:
128 128
129 129 manifest output the current or given revision of the project manifest
130 130 recover roll back an interrupted transaction
131 131 verify verify the integrity of the repository
132 132
133 133 Help:
134 134
135 135 config show combined config settings from all hgrc files
136 136 help show help for a given topic or a help overview
137 137 version output version and copyright information
138 138
139 139 additional help topics:
140 140
141 141 Mercurial identifiers:
142 142
143 143 filesets Specifying File Sets
144 144 hgignore Syntax for Mercurial Ignore Files
145 145 patterns File Name Patterns
146 146 revisions Specifying Revisions
147 147 urls URL Paths
148 148
149 149 Mercurial output:
150 150
151 151 color Colorizing Outputs
152 152 dates Date Formats
153 153 diffs Diff Formats
154 154 templating Template Usage
155 155
156 156 Mercurial configuration:
157 157
158 158 config Configuration Files
159 159 environment Environment Variables
160 160 extensions Using Additional Features
161 161 flags Command-line flags
162 162 hgweb Configuring hgweb
163 163 merge-tools Merge Tools
164 164 pager Pager Support
165 165
166 166 Concepts:
167 167
168 168 bundlespec Bundle File Formats
169 169 glossary Glossary
170 170 phases Working with Phases
171 171 subrepos Subrepositories
172 172
173 173 Miscellaneous:
174 174
175 175 deprecated Deprecated Features
176 176 internals Technical implementation topics
177 177 scripting Using Mercurial from scripts and automation
178 178
179 179 (use 'hg help -v' to show built-in aliases and global options)
180 180
181 181 $ hg -q help
182 182 Repository creation:
183 183
184 184 clone make a copy of an existing repository
185 185 init create a new repository in the given directory
186 186
187 187 Remote repository management:
188 188
189 189 incoming show new changesets found in source
190 190 outgoing show changesets not found in the destination
191 191 paths show aliases for remote repositories
192 192 pull pull changes from the specified source
193 193 push push changes to the specified destination
194 194 serve start stand-alone webserver
195 195
196 196 Change creation:
197 197
198 198 commit commit the specified files or all outstanding changes
199 199
200 200 Change manipulation:
201 201
202 202 backout reverse effect of earlier changeset
203 203 graft copy changes from other branches onto the current branch
204 204 merge merge another revision into working directory
205 205
206 206 Change organization:
207 207
208 208 bookmarks create a new bookmark or list existing bookmarks
209 209 branch set or show the current branch name
210 210 branches list repository named branches
211 211 phase set or show the current phase name
212 212 tag add one or more tags for the current or given revision
213 213 tags list repository tags
214 214
215 215 File content management:
216 216
217 217 annotate show changeset information by line for each file
218 218 cat output the current or given revision of files
219 219 copy mark files as copied for the next commit
220 220 diff diff repository (or selected files)
221 221 grep search revision history for a pattern in specified files
222 222
223 223 Change navigation:
224 224
225 225 bisect subdivision search of changesets
226 226 heads show branch heads
227 227 identify identify the working directory or specified revision
228 228 log show revision history of entire repository or files
229 229
230 230 Working directory management:
231 231
232 232 add add the specified files on the next commit
233 233 addremove add all new files, delete all missing files
234 234 files list tracked files
235 235 forget forget the specified files on the next commit
236 236 remove remove the specified files on the next commit
237 237 rename rename files; equivalent of copy + remove
238 238 resolve redo merges or set/view the merge status of files
239 239 revert restore files to their checkout state
240 240 root print the root (top) of the current working directory
241 241 status show changed files in the working directory
242 242 summary summarize working directory state
243 243 update update working directory (or switch revisions)
244 244
245 245 Change import/export:
246 246
247 247 archive create an unversioned archive of a repository revision
248 248 bundle create a bundle file
249 249 export dump the header and diffs for one or more changesets
250 250 import import an ordered set of patches
251 251 unbundle apply one or more bundle files
252 252
253 253 Repository maintenance:
254 254
255 255 manifest output the current or given revision of the project manifest
256 256 recover roll back an interrupted transaction
257 257 verify verify the integrity of the repository
258 258
259 259 Help:
260 260
261 261 config show combined config settings from all hgrc files
262 262 help show help for a given topic or a help overview
263 263 version output version and copyright information
264 264
265 265 additional help topics:
266 266
267 267 Mercurial identifiers:
268 268
269 269 filesets Specifying File Sets
270 270 hgignore Syntax for Mercurial Ignore Files
271 271 patterns File Name Patterns
272 272 revisions Specifying Revisions
273 273 urls URL Paths
274 274
275 275 Mercurial output:
276 276
277 277 color Colorizing Outputs
278 278 dates Date Formats
279 279 diffs Diff Formats
280 280 templating Template Usage
281 281
282 282 Mercurial configuration:
283 283
284 284 config Configuration Files
285 285 environment Environment Variables
286 286 extensions Using Additional Features
287 287 flags Command-line flags
288 288 hgweb Configuring hgweb
289 289 merge-tools Merge Tools
290 290 pager Pager Support
291 291
292 292 Concepts:
293 293
294 294 bundlespec Bundle File Formats
295 295 glossary Glossary
296 296 phases Working with Phases
297 297 subrepos Subrepositories
298 298
299 299 Miscellaneous:
300 300
301 301 deprecated Deprecated Features
302 302 internals Technical implementation topics
303 303 scripting Using Mercurial from scripts and automation
304 304
305 305 Test extension help:
306 306 $ hg help extensions --config extensions.rebase= --config extensions.children=
307 307 Using Additional Features
308 308 """""""""""""""""""""""""
309 309
310 310 Mercurial has the ability to add new features through the use of
311 311 extensions. Extensions may add new commands, add options to existing
312 312 commands, change the default behavior of commands, or implement hooks.
313 313
314 314 To enable the "foo" extension, either shipped with Mercurial or in the
315 315 Python search path, create an entry for it in your configuration file,
316 316 like this:
317 317
318 318 [extensions]
319 319 foo =
320 320
321 321 You may also specify the full path to an extension:
322 322
323 323 [extensions]
324 324 myfeature = ~/.hgext/myfeature.py
325 325
326 326 See 'hg help config' for more information on configuration files.
327 327
328 328 Extensions are not loaded by default for a variety of reasons: they can
329 329 increase startup overhead; they may be meant for advanced usage only; they
330 330 may provide potentially dangerous abilities (such as letting you destroy
331 331 or modify history); they might not be ready for prime time; or they may
332 332 alter some usual behaviors of stock Mercurial. It is thus up to the user
333 333 to activate extensions as needed.
334 334
335 335 To explicitly disable an extension enabled in a configuration file of
336 336 broader scope, prepend its path with !:
337 337
338 338 [extensions]
339 339 # disabling extension bar residing in /path/to/extension/bar.py
340 340 bar = !/path/to/extension/bar.py
341 341 # ditto, but no path was supplied for extension baz
342 342 baz = !
343 343
344 344 enabled extensions:
345 345
346 346 children command to display child changesets (DEPRECATED)
347 347 rebase command to move sets of revisions to a different ancestor
348 348
349 349 disabled extensions:
350 350
351 351 acl hooks for controlling repository access
352 352 blackbox log repository events to a blackbox for debugging
353 353 bugzilla hooks for integrating with the Bugzilla bug tracker
354 354 censor erase file content at a given revision
355 355 churn command to display statistics about repository history
356 356 clonebundles advertise pre-generated bundles to seed clones
357 357 closehead close arbitrary heads without checking them out first
358 358 convert import revisions from foreign VCS repositories into
359 359 Mercurial
360 360 eol automatically manage newlines in repository files
361 361 extdiff command to allow external programs to compare revisions
362 362 factotum http authentication with factotum
363 363 githelp try mapping git commands to Mercurial commands
364 364 gpg commands to sign and verify changesets
365 365 hgk browse the repository in a graphical way
366 366 highlight syntax highlighting for hgweb (requires Pygments)
367 367 histedit interactive history editing
368 368 keyword expand keywords in tracked files
369 369 largefiles track large binary files
370 370 mq manage a stack of patches
371 371 notify hooks for sending email push notifications
372 372 patchbomb command to send changesets as (a series of) patch emails
373 373 purge command to delete untracked files from the working
374 374 directory
375 375 relink recreates hardlinks between repository clones
376 376 schemes extend schemes with shortcuts to repository swarms
377 377 share share a common history between several working directories
378 378 shelve save and restore changes to the working directory
379 379 strip strip changesets and their descendants from history
380 380 transplant command to transplant changesets from another branch
381 381 win32mbcs allow the use of MBCS paths with problematic encodings
382 382 zeroconf discover and advertise repositories on the local network
383 383
384 384 #endif
385 385
386 386 Verify that deprecated extensions are included if --verbose:
387 387
388 388 $ hg -v help extensions | grep children
389 389 children command to display child changesets (DEPRECATED)
390 390
391 391 Verify that extension keywords appear in help templates
392 392
393 393 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
394 394
395 395 Test short command list with verbose option
396 396
397 397 $ hg -v help shortlist
398 398 Mercurial Distributed SCM
399 399
400 400 basic commands:
401 401
402 402 add add the specified files on the next commit
403 403 annotate, blame
404 404 show changeset information by line for each file
405 405 clone make a copy of an existing repository
406 406 commit, ci commit the specified files or all outstanding changes
407 407 diff diff repository (or selected files)
408 408 export dump the header and diffs for one or more changesets
409 409 forget forget the specified files on the next commit
410 410 init create a new repository in the given directory
411 411 log, history show revision history of entire repository or files
412 412 merge merge another revision into working directory
413 413 pull pull changes from the specified source
414 414 push push changes to the specified destination
415 415 remove, rm remove the specified files on the next commit
416 416 serve start stand-alone webserver
417 417 status, st show changed files in the working directory
418 418 summary, sum summarize working directory state
419 419 update, up, checkout, co
420 420 update working directory (or switch revisions)
421 421
422 422 global options ([+] can be repeated):
423 423
424 424 -R --repository REPO repository root directory or name of overlay bundle
425 425 file
426 426 --cwd DIR change working directory
427 427 -y --noninteractive do not prompt, automatically pick the first choice for
428 428 all prompts
429 429 -q --quiet suppress output
430 430 -v --verbose enable additional output
431 431 --color TYPE when to colorize (boolean, always, auto, never, or
432 432 debug)
433 433 --config CONFIG [+] set/override config option (use 'section.name=value')
434 434 --debug enable debugging output
435 435 --debugger start debugger
436 436 --encoding ENCODE set the charset encoding (default: ascii)
437 437 --encodingmode MODE set the charset encoding mode (default: strict)
438 438 --traceback always print a traceback on exception
439 439 --time time how long the command takes
440 440 --profile print command execution profile
441 441 --version output version information and exit
442 442 -h --help display help and exit
443 443 --hidden consider hidden changesets
444 444 --pager TYPE when to paginate (boolean, always, auto, or never)
445 445 (default: auto)
446 446
447 447 (use 'hg help' for the full list of commands)
448 448
449 449 $ hg add -h
450 450 hg add [OPTION]... [FILE]...
451 451
452 452 add the specified files on the next commit
453 453
454 454 Schedule files to be version controlled and added to the repository.
455 455
456 456 The files will be added to the repository at the next commit. To undo an
457 457 add before that, see 'hg forget'.
458 458
459 459 If no names are given, add all files to the repository (except files
460 460 matching ".hgignore").
461 461
462 462 Returns 0 if all files are successfully added.
463 463
464 464 options ([+] can be repeated):
465 465
466 466 -I --include PATTERN [+] include names matching the given patterns
467 467 -X --exclude PATTERN [+] exclude names matching the given patterns
468 468 -S --subrepos recurse into subrepositories
469 469 -n --dry-run do not perform actions, just print output
470 470
471 471 (some details hidden, use --verbose to show complete help)
472 472
473 473 Verbose help for add
474 474
475 475 $ hg add -hv
476 476 hg add [OPTION]... [FILE]...
477 477
478 478 add the specified files on the next commit
479 479
480 480 Schedule files to be version controlled and added to the repository.
481 481
482 482 The files will be added to the repository at the next commit. To undo an
483 483 add before that, see 'hg forget'.
484 484
485 485 If no names are given, add all files to the repository (except files
486 486 matching ".hgignore").
487 487
488 488 Examples:
489 489
490 490 - New (unknown) files are added automatically by 'hg add':
491 491
492 492 $ ls
493 493 foo.c
494 494 $ hg status
495 495 ? foo.c
496 496 $ hg add
497 497 adding foo.c
498 498 $ hg status
499 499 A foo.c
500 500
501 501 - Specific files to be added can be specified:
502 502
503 503 $ ls
504 504 bar.c foo.c
505 505 $ hg status
506 506 ? bar.c
507 507 ? foo.c
508 508 $ hg add bar.c
509 509 $ hg status
510 510 A bar.c
511 511 ? foo.c
512 512
513 513 Returns 0 if all files are successfully added.
514 514
515 515 options ([+] can be repeated):
516 516
517 517 -I --include PATTERN [+] include names matching the given patterns
518 518 -X --exclude PATTERN [+] exclude names matching the given patterns
519 519 -S --subrepos recurse into subrepositories
520 520 -n --dry-run do not perform actions, just print output
521 521
522 522 global options ([+] can be repeated):
523 523
524 524 -R --repository REPO repository root directory or name of overlay bundle
525 525 file
526 526 --cwd DIR change working directory
527 527 -y --noninteractive do not prompt, automatically pick the first choice for
528 528 all prompts
529 529 -q --quiet suppress output
530 530 -v --verbose enable additional output
531 531 --color TYPE when to colorize (boolean, always, auto, never, or
532 532 debug)
533 533 --config CONFIG [+] set/override config option (use 'section.name=value')
534 534 --debug enable debugging output
535 535 --debugger start debugger
536 536 --encoding ENCODE set the charset encoding (default: ascii)
537 537 --encodingmode MODE set the charset encoding mode (default: strict)
538 538 --traceback always print a traceback on exception
539 539 --time time how long the command takes
540 540 --profile print command execution profile
541 541 --version output version information and exit
542 542 -h --help display help and exit
543 543 --hidden consider hidden changesets
544 544 --pager TYPE when to paginate (boolean, always, auto, or never)
545 545 (default: auto)
546 546
547 547 Test the textwidth config option
548 548
549 549 $ hg root -h --config ui.textwidth=50
550 550 hg root
551 551
552 552 print the root (top) of the current working
553 553 directory
554 554
555 555 Print the root directory of the current
556 556 repository.
557 557
558 558 Returns 0 on success.
559 559
560 560 (some details hidden, use --verbose to show
561 561 complete help)
562 562
563 563 Test help option with version option
564 564
565 565 $ hg add -h --version
566 566 Mercurial Distributed SCM (version *) (glob)
567 567 (see https://mercurial-scm.org for more information)
568 568
569 569 Copyright (C) 2005-* Matt Mackall and others (glob)
570 570 This is free software; see the source for copying conditions. There is NO
571 571 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
572 572
573 573 $ hg add --skjdfks
574 574 hg add: option --skjdfks not recognized
575 575 hg add [OPTION]... [FILE]...
576 576
577 577 add the specified files on the next commit
578 578
579 579 options ([+] can be repeated):
580 580
581 581 -I --include PATTERN [+] include names matching the given patterns
582 582 -X --exclude PATTERN [+] exclude names matching the given patterns
583 583 -S --subrepos recurse into subrepositories
584 584 -n --dry-run do not perform actions, just print output
585 585
586 586 (use 'hg add -h' to show more help)
587 587 [255]
588 588
589 589 Test ambiguous command help
590 590
591 591 $ hg help ad
592 592 list of commands:
593 593
594 594 add add the specified files on the next commit
595 595 addremove add all new files, delete all missing files
596 596
597 597 (use 'hg help -v ad' to show built-in aliases and global options)
598 598
599 599 Test command without options
600 600
601 601 $ hg help verify
602 602 hg verify
603 603
604 604 verify the integrity of the repository
605 605
606 606 Verify the integrity of the current repository.
607 607
608 608 This will perform an extensive check of the repository's integrity,
609 609 validating the hashes and checksums of each entry in the changelog,
610 610 manifest, and tracked files, as well as the integrity of their crosslinks
611 611 and indices.
612 612
613 613 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
614 614 information about recovery from corruption of the repository.
615 615
616 616 Returns 0 on success, 1 if errors are encountered.
617 617
618 618 (some details hidden, use --verbose to show complete help)
619 619
620 620 $ hg help diff
621 621 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
622 622
623 623 diff repository (or selected files)
624 624
625 625 Show differences between revisions for the specified files.
626 626
627 627 Differences between files are shown using the unified diff format.
628 628
629 629 Note:
630 630 'hg diff' may generate unexpected results for merges, as it will
631 631 default to comparing against the working directory's first parent
632 632 changeset if no revisions are specified.
633 633
634 634 When two revision arguments are given, then changes are shown between
635 635 those revisions. If only one revision is specified then that revision is
636 636 compared to the working directory, and, when no revisions are specified,
637 637 the working directory files are compared to its first parent.
638 638
639 639 Alternatively you can specify -c/--change with a revision to see the
640 640 changes in that changeset relative to its first parent.
641 641
642 642 Without the -a/--text option, diff will avoid generating diffs of files it
643 643 detects as binary. With -a, diff will generate a diff anyway, probably
644 644 with undesirable results.
645 645
646 646 Use the -g/--git option to generate diffs in the git extended diff format.
647 647 For more information, read 'hg help diffs'.
648 648
649 649 Returns 0 on success.
650 650
651 651 options ([+] can be repeated):
652 652
653 653 -r --rev REV [+] revision
654 654 -c --change REV change made by revision
655 655 -a --text treat all files as text
656 656 -g --git use git extended diff format
657 657 --binary generate binary diffs in git mode (default)
658 658 --nodates omit dates from diff headers
659 659 --noprefix omit a/ and b/ prefixes from filenames
660 660 -p --show-function show which function each change is in
661 661 --reverse produce a diff that undoes the changes
662 662 -w --ignore-all-space ignore white space when comparing lines
663 663 -b --ignore-space-change ignore changes in the amount of white space
664 664 -B --ignore-blank-lines ignore changes whose lines are all blank
665 665 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
666 666 -U --unified NUM number of lines of context to show
667 667 --stat output diffstat-style summary of changes
668 668 --root DIR produce diffs relative to subdirectory
669 669 -I --include PATTERN [+] include names matching the given patterns
670 670 -X --exclude PATTERN [+] exclude names matching the given patterns
671 671 -S --subrepos recurse into subrepositories
672 672
673 673 (some details hidden, use --verbose to show complete help)
674 674
675 675 $ hg help status
676 676 hg status [OPTION]... [FILE]...
677 677
678 678 aliases: st
679 679
680 680 show changed files in the working directory
681 681
682 682 Show status of files in the repository. If names are given, only files
683 683 that match are shown. Files that are clean or ignored or the source of a
684 684 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
685 685 -C/--copies or -A/--all are given. Unless options described with "show
686 686 only ..." are given, the options -mardu are used.
687 687
688 688 Option -q/--quiet hides untracked (unknown and ignored) files unless
689 689 explicitly requested with -u/--unknown or -i/--ignored.
690 690
691 691 Note:
692 692 'hg status' may appear to disagree with diff if permissions have
693 693 changed or a merge has occurred. The standard diff format does not
694 694 report permission changes and diff only reports changes relative to one
695 695 merge parent.
696 696
697 697 If one revision is given, it is used as the base revision. If two
698 698 revisions are given, the differences between them are shown. The --change
699 699 option can also be used as a shortcut to list the changed files of a
700 700 revision from its first parent.
701 701
702 702 The codes used to show the status of files are:
703 703
704 704 M = modified
705 705 A = added
706 706 R = removed
707 707 C = clean
708 708 ! = missing (deleted by non-hg command, but still tracked)
709 709 ? = not tracked
710 710 I = ignored
711 711 = origin of the previous file (with --copies)
712 712
713 713 Returns 0 on success.
714 714
715 715 options ([+] can be repeated):
716 716
717 717 -A --all show status of all files
718 718 -m --modified show only modified files
719 719 -a --added show only added files
720 720 -r --removed show only removed files
721 721 -d --deleted show only deleted (but tracked) files
722 722 -c --clean show only files without changes
723 723 -u --unknown show only unknown (not tracked) files
724 724 -i --ignored show only ignored files
725 725 -n --no-status hide status prefix
726 726 -C --copies show source of copied files
727 727 -0 --print0 end filenames with NUL, for use with xargs
728 728 --rev REV [+] show difference from revision
729 729 --change REV list the changed files of a revision
730 730 -I --include PATTERN [+] include names matching the given patterns
731 731 -X --exclude PATTERN [+] exclude names matching the given patterns
732 732 -S --subrepos recurse into subrepositories
733 733 -T --template TEMPLATE display with template
734 734
735 735 (some details hidden, use --verbose to show complete help)
736 736
737 737 $ hg -q help status
738 738 hg status [OPTION]... [FILE]...
739 739
740 740 show changed files in the working directory
741 741
742 742 $ hg help foo
743 743 abort: no such help topic: foo
744 744 (try 'hg help --keyword foo')
745 745 [255]
746 746
747 747 $ hg skjdfks
748 748 hg: unknown command 'skjdfks'
749 749 (use 'hg help' for a list of commands)
750 750 [255]
751 751
752 752 Typoed command gives suggestion
753 753 $ hg puls
754 754 hg: unknown command 'puls'
755 755 (did you mean one of pull, push?)
756 756 [255]
757 757
758 758 Not enabled extension gets suggested
759 759
760 760 $ hg rebase
761 761 hg: unknown command 'rebase'
762 762 'rebase' is provided by the following extension:
763 763
764 764 rebase command to move sets of revisions to a different ancestor
765 765
766 766 (use 'hg help extensions' for information on enabling extensions)
767 767 [255]
768 768
769 769 Disabled extension gets suggested
770 770 $ hg --config extensions.rebase=! rebase
771 771 hg: unknown command 'rebase'
772 772 'rebase' is provided by the following extension:
773 773
774 774 rebase command to move sets of revisions to a different ancestor
775 775
776 776 (use 'hg help extensions' for information on enabling extensions)
777 777 [255]
778 778
779 779 Make sure that we don't run afoul of the help system thinking that
780 780 this is a section and erroring out weirdly.
781 781
782 782 $ hg .log
783 783 hg: unknown command '.log'
784 784 (did you mean log?)
785 785 [255]
786 786
787 787 $ hg log.
788 788 hg: unknown command 'log.'
789 789 (did you mean log?)
790 790 [255]
791 791 $ hg pu.lh
792 792 hg: unknown command 'pu.lh'
793 793 (did you mean one of pull, push?)
794 794 [255]
795 795
796 796 $ cat > helpext.py <<EOF
797 797 > import os
798 798 > from mercurial import commands, fancyopts, registrar
799 799 >
800 800 > def func(arg):
801 801 > return '%sfoo' % arg
802 802 > class customopt(fancyopts.customopt):
803 803 > def newstate(self, oldstate, newparam, abort):
804 804 > return '%sbar' % oldstate
805 805 > cmdtable = {}
806 806 > command = registrar.command(cmdtable)
807 807 >
808 808 > @command(b'nohelp',
809 809 > [(b'', b'longdesc', 3, b'x'*67),
810 810 > (b'n', b'', None, b'normal desc'),
811 811 > (b'', b'newline', b'', b'line1\nline2'),
812 812 > (b'', b'default-off', False, b'enable X'),
813 813 > (b'', b'default-on', True, b'enable Y'),
814 814 > (b'', b'callableopt', func, b'adds foo'),
815 815 > (b'', b'customopt', customopt(''), b'adds bar'),
816 816 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
817 817 > b'hg nohelp',
818 818 > norepo=True)
819 819 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
820 820 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
821 821 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
822 822 > def nohelp(ui, *args, **kwargs):
823 823 > pass
824 824 >
825 825 > @command(b'hashelp', [], b'hg hashelp', norepo=True)
826 826 > def hashelp(ui, *args, **kwargs):
827 827 > """Extension command's help"""
828 828 > pass
829 829 >
830 830 > def uisetup(ui):
831 831 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
832 832 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
833 833 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
834 834 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
835 835 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
836 836 >
837 837 > EOF
838 838 $ echo '[extensions]' >> $HGRCPATH
839 839 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
840 840
841 841 Test for aliases
842 842
843 843 $ hg help | grep hgalias
844 844 hgalias My doc
845 845
846 846 $ hg help hgalias
847 847 hg hgalias [--remote]
848 848
849 849 alias for: hg summary
850 850
851 851 My doc
852 852
853 853 defined by: helpext
854 854
855 855 options:
856 856
857 857 --remote check for push and pull
858 858
859 859 (some details hidden, use --verbose to show complete help)
860 860 $ hg help hgaliasnodoc
861 861 hg hgaliasnodoc [--remote]
862 862
863 863 alias for: hg summary
864 864
865 865 summarize working directory state
866 866
867 867 This generates a brief summary of the working directory state, including
868 868 parents, branch, commit status, phase and available updates.
869 869
870 870 With the --remote option, this will check the default paths for incoming
871 871 and outgoing changes. This can be time-consuming.
872 872
873 873 Returns 0 on success.
874 874
875 875 defined by: helpext
876 876
877 877 options:
878 878
879 879 --remote check for push and pull
880 880
881 881 (some details hidden, use --verbose to show complete help)
882 882
883 883 $ hg help shellalias
884 884 hg shellalias
885 885
886 886 shell alias for: echo hi
887 887
888 888 (no help text available)
889 889
890 890 defined by: helpext
891 891
892 892 (some details hidden, use --verbose to show complete help)
893 893
894 894 Test command with no help text
895 895
896 896 $ hg help nohelp
897 897 hg nohelp
898 898
899 899 (no help text available)
900 900
901 901 options:
902 902
903 903 --longdesc VALUE
904 904 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
905 905 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
906 906 -n -- normal desc
907 907 --newline VALUE line1 line2
908 908 --default-off enable X
909 909 --[no-]default-on enable Y (default: on)
910 910 --callableopt VALUE adds foo
911 911 --customopt VALUE adds bar
912 912 --customopt-withdefault VALUE adds bar (default: foo)
913 913
914 914 (some details hidden, use --verbose to show complete help)
915 915
916 916 Test that default list of commands includes extension commands that have help,
917 917 but not those that don't, except in verbose mode, when a keyword is passed, or
918 918 when help about the extension is requested.
919 919
920 920 #if no-extraextensions
921 921
922 922 $ hg help | grep hashelp
923 923 hashelp Extension command's help
924 924 $ hg help | grep nohelp
925 925 [1]
926 926 $ hg help -v | grep nohelp
927 927 nohelp (no help text available)
928 928
929 929 $ hg help -k nohelp
930 930 Commands:
931 931
932 932 nohelp hg nohelp
933 933
934 934 Extension Commands:
935 935
936 936 nohelp (no help text available)
937 937
938 938 $ hg help helpext
939 939 helpext extension - no help text available
940 940
941 941 list of commands:
942 942
943 943 hashelp Extension command's help
944 944 nohelp (no help text available)
945 945
946 946 (use 'hg help -v helpext' to show built-in aliases and global options)
947 947
948 948 #endif
949 949
950 950 Test list of internal help commands
951 951
952 952 $ hg help debug
953 953 debug commands (internal and unsupported):
954 954
955 955 debugancestor
956 956 find the ancestor revision of two revisions in a given index
957 957 debugapplystreamclonebundle
958 958 apply a stream clone bundle file
959 959 debugbuilddag
960 960 builds a repo with a given DAG from scratch in the current
961 961 empty repo
962 962 debugbundle lists the contents of a bundle
963 963 debugcapabilities
964 964 lists the capabilities of a remote peer
965 965 debugcheckstate
966 966 validate the correctness of the current dirstate
967 967 debugcolor show available color, effects or style
968 968 debugcommands
969 969 list all available commands and options
970 970 debugcomplete
971 971 returns the completion list associated with the given command
972 972 debugcreatestreamclonebundle
973 973 create a stream clone bundle file
974 974 debugdag format the changelog or an index DAG as a concise textual
975 975 description
976 976 debugdata dump the contents of a data file revision
977 977 debugdate parse and display a date
978 978 debugdeltachain
979 979 dump information about delta chains in a revlog
980 980 debugdirstate
981 981 show the contents of the current dirstate
982 982 debugdiscovery
983 983 runs the changeset discovery protocol in isolation
984 984 debugdownload
985 985 download a resource using Mercurial logic and config
986 986 debugextensions
987 987 show information about active extensions
988 988 debugfileset parse and apply a fileset specification
989 989 debugformat display format information about the current repository
990 990 debugfsinfo show information detected about current filesystem
991 991 debuggetbundle
992 992 retrieves a bundle from a repo
993 993 debugignore display the combined ignore pattern and information about
994 994 ignored files
995 995 debugindex dump index data for a storage primitive
996 996 debugindexdot
997 997 dump an index DAG as a graphviz dot file
998 998 debugindexstats
999 999 show stats related to the changelog index
1000 1000 debuginstall test Mercurial installation
1001 1001 debugknown test whether node ids are known to a repo
1002 1002 debuglocks show or modify state of locks
1003 1003 debugmanifestfulltextcache
1004 1004 show, clear or amend the contents of the manifest fulltext
1005 1005 cache
1006 1006 debugmergestate
1007 1007 print merge state
1008 1008 debugnamecomplete
1009 1009 complete "names" - tags, open branch names, bookmark names
1010 1010 debugobsolete
1011 1011 create arbitrary obsolete marker
1012 1012 debugoptADV (no help text available)
1013 1013 debugoptDEP (no help text available)
1014 1014 debugoptEXP (no help text available)
1015 1015 debugpathcomplete
1016 1016 complete part or all of a tracked path
1017 1017 debugpeer establish a connection to a peer repository
1018 1018 debugpickmergetool
1019 1019 examine which merge tool is chosen for specified file
1020 1020 debugpushkey access the pushkey key/value protocol
1021 1021 debugpvec (no help text available)
1022 1022 debugrebuilddirstate
1023 1023 rebuild the dirstate as it would look like for the given
1024 1024 revision
1025 1025 debugrebuildfncache
1026 1026 rebuild the fncache file
1027 1027 debugrename dump rename information
1028 1028 debugrevlog show data and statistics about a revlog
1029 1029 debugrevlogindex
1030 1030 dump the contents of a revlog index
1031 1031 debugrevspec parse and apply a revision specification
1032 1032 debugserve run a server with advanced settings
1033 1033 debugsetparents
1034 1034 manually set the parents of the current working directory
1035 1035 debugssl test a secure connection to a server
1036 1036 debugsub (no help text available)
1037 1037 debugsuccessorssets
1038 1038 show set of successors for revision
1039 1039 debugtemplate
1040 1040 parse and apply a template
1041 1041 debuguigetpass
1042 1042 show prompt to type password
1043 1043 debuguiprompt
1044 1044 show plain prompt
1045 1045 debugupdatecaches
1046 1046 warm all known caches in the repository
1047 1047 debugupgraderepo
1048 1048 upgrade a repository to use different features
1049 1049 debugwalk show how files match on given patterns
1050 1050 debugwhyunstable
1051 1051 explain instabilities of a changeset
1052 1052 debugwireargs
1053 1053 (no help text available)
1054 1054 debugwireproto
1055 1055 send wire protocol commands to a server
1056 1056
1057 1057 (use 'hg help -v debug' to show built-in aliases and global options)
1058 1058
1059 1059 internals topic renders index of available sub-topics
1060 1060
1061 1061 $ hg help internals
1062 1062 Technical implementation topics
1063 1063 """""""""""""""""""""""""""""""
1064 1064
1065 1065 To access a subtopic, use "hg help internals.{subtopic-name}"
1066 1066
1067 1067 bundle2 Bundle2
1068 1068 bundles Bundles
1069 1069 cbor CBOR
1070 1070 censor Censor
1071 1071 changegroups Changegroups
1072 1072 config Config Registrar
1073 1073 extensions Extension API
1074 1074 requirements Repository Requirements
1075 1075 revlogs Revision Logs
1076 1076 wireprotocol Wire Protocol
1077 1077 wireprotocolrpc
1078 1078 Wire Protocol RPC
1079 1079 wireprotocolv2
1080 1080 Wire Protocol Version 2
1081 1081
1082 1082 sub-topics can be accessed
1083 1083
1084 1084 $ hg help internals.changegroups
1085 1085 Changegroups
1086 1086 """"""""""""
1087 1087
1088 1088 Changegroups are representations of repository revlog data, specifically
1089 1089 the changelog data, root/flat manifest data, treemanifest data, and
1090 1090 filelogs.
1091 1091
1092 1092 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1093 1093 level, versions "1" and "2" are almost exactly the same, with the only
1094 1094 difference being an additional item in the *delta header*. Version "3"
1095 1095 adds support for storage flags in the *delta header* and optionally
1096 1096 exchanging treemanifests (enabled by setting an option on the
1097 1097 "changegroup" part in the bundle2).
1098 1098
1099 1099 Changegroups when not exchanging treemanifests consist of 3 logical
1100 1100 segments:
1101 1101
1102 1102 +---------------------------------+
1103 1103 | | | |
1104 1104 | changeset | manifest | filelogs |
1105 1105 | | | |
1106 1106 | | | |
1107 1107 +---------------------------------+
1108 1108
1109 1109 When exchanging treemanifests, there are 4 logical segments:
1110 1110
1111 1111 +-------------------------------------------------+
1112 1112 | | | | |
1113 1113 | changeset | root | treemanifests | filelogs |
1114 1114 | | manifest | | |
1115 1115 | | | | |
1116 1116 +-------------------------------------------------+
1117 1117
1118 1118 The principle building block of each segment is a *chunk*. A *chunk* is a
1119 1119 framed piece of data:
1120 1120
1121 1121 +---------------------------------------+
1122 1122 | | |
1123 1123 | length | data |
1124 1124 | (4 bytes) | (<length - 4> bytes) |
1125 1125 | | |
1126 1126 +---------------------------------------+
1127 1127
1128 1128 All integers are big-endian signed integers. Each chunk starts with a
1129 1129 32-bit integer indicating the length of the entire chunk (including the
1130 1130 length field itself).
1131 1131
1132 1132 There is a special case chunk that has a value of 0 for the length
1133 1133 ("0x00000000"). We call this an *empty chunk*.
1134 1134
1135 1135 Delta Groups
1136 1136 ============
1137 1137
1138 1138 A *delta group* expresses the content of a revlog as a series of deltas,
1139 1139 or patches against previous revisions.
1140 1140
1141 1141 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1142 1142 to signal the end of the delta group:
1143 1143
1144 1144 +------------------------------------------------------------------------+
1145 1145 | | | | | |
1146 1146 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1147 1147 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1148 1148 | | | | | |
1149 1149 +------------------------------------------------------------------------+
1150 1150
1151 1151 Each *chunk*'s data consists of the following:
1152 1152
1153 1153 +---------------------------------------+
1154 1154 | | |
1155 1155 | delta header | delta data |
1156 1156 | (various by version) | (various) |
1157 1157 | | |
1158 1158 +---------------------------------------+
1159 1159
1160 1160 The *delta data* is a series of *delta*s that describe a diff from an
1161 1161 existing entry (either that the recipient already has, or previously
1162 1162 specified in the bundle/changegroup).
1163 1163
1164 1164 The *delta header* is different between versions "1", "2", and "3" of the
1165 1165 changegroup format.
1166 1166
1167 1167 Version 1 (headerlen=80):
1168 1168
1169 1169 +------------------------------------------------------+
1170 1170 | | | | |
1171 1171 | node | p1 node | p2 node | link node |
1172 1172 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1173 1173 | | | | |
1174 1174 +------------------------------------------------------+
1175 1175
1176 1176 Version 2 (headerlen=100):
1177 1177
1178 1178 +------------------------------------------------------------------+
1179 1179 | | | | | |
1180 1180 | node | p1 node | p2 node | base node | link node |
1181 1181 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1182 1182 | | | | | |
1183 1183 +------------------------------------------------------------------+
1184 1184
1185 1185 Version 3 (headerlen=102):
1186 1186
1187 1187 +------------------------------------------------------------------------------+
1188 1188 | | | | | | |
1189 1189 | node | p1 node | p2 node | base node | link node | flags |
1190 1190 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1191 1191 | | | | | | |
1192 1192 +------------------------------------------------------------------------------+
1193 1193
1194 1194 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1195 1195 contain a series of *delta*s, densely packed (no separators). These deltas
1196 1196 describe a diff from an existing entry (either that the recipient already
1197 1197 has, or previously specified in the bundle/changegroup). The format is
1198 1198 described more fully in "hg help internals.bdiff", but briefly:
1199 1199
1200 1200 +---------------------------------------------------------------+
1201 1201 | | | | |
1202 1202 | start offset | end offset | new length | content |
1203 1203 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1204 1204 | | | | |
1205 1205 +---------------------------------------------------------------+
1206 1206
1207 1207 Please note that the length field in the delta data does *not* include
1208 1208 itself.
1209 1209
1210 1210 In version 1, the delta is always applied against the previous node from
1211 1211 the changegroup or the first parent if this is the first entry in the
1212 1212 changegroup.
1213 1213
1214 1214 In version 2 and up, the delta base node is encoded in the entry in the
1215 1215 changegroup. This allows the delta to be expressed against any parent,
1216 1216 which can result in smaller deltas and more efficient encoding of data.
1217 1217
1218 1218 The *flags* field holds bitwise flags affecting the processing of revision
1219 1219 data. The following flags are defined:
1220 1220
1221 1221 32768
1222 1222 Censored revision. The revision's fulltext has been replaced by censor
1223 1223 metadata. May only occur on file revisions.
1224 1224
1225 1225 16384
1226 1226 Ellipsis revision. Revision hash does not match data (likely due to
1227 1227 rewritten parents).
1228 1228
1229 1229 8192
1230 1230 Externally stored. The revision fulltext contains "key:value" "\n"
1231 1231 delimited metadata defining an object stored elsewhere. Used by the LFS
1232 1232 extension.
1233 1233
1234 1234 For historical reasons, the integer values are identical to revlog version
1235 1235 1 per-revision storage flags and correspond to bits being set in this
1236 1236 2-byte field. Bits were allocated starting from the most-significant bit,
1237 1237 hence the reverse ordering and allocation of these flags.
1238 1238
1239 1239 Changeset Segment
1240 1240 =================
1241 1241
1242 1242 The *changeset segment* consists of a single *delta group* holding
1243 1243 changelog data. The *empty chunk* at the end of the *delta group* denotes
1244 1244 the boundary to the *manifest segment*.
1245 1245
1246 1246 Manifest Segment
1247 1247 ================
1248 1248
1249 1249 The *manifest segment* consists of a single *delta group* holding manifest
1250 1250 data. If treemanifests are in use, it contains only the manifest for the
1251 1251 root directory of the repository. Otherwise, it contains the entire
1252 1252 manifest data. The *empty chunk* at the end of the *delta group* denotes
1253 1253 the boundary to the next segment (either the *treemanifests segment* or
1254 1254 the *filelogs segment*, depending on version and the request options).
1255 1255
1256 1256 Treemanifests Segment
1257 1257 ---------------------
1258 1258
1259 1259 The *treemanifests segment* only exists in changegroup version "3", and
1260 1260 only if the 'treemanifest' param is part of the bundle2 changegroup part
1261 1261 (it is not possible to use changegroup version 3 outside of bundle2).
1262 1262 Aside from the filenames in the *treemanifests segment* containing a
1263 1263 trailing "/" character, it behaves identically to the *filelogs segment*
1264 1264 (see below). The final sub-segment is followed by an *empty chunk*
1265 1265 (logically, a sub-segment with filename size 0). This denotes the boundary
1266 1266 to the *filelogs segment*.
1267 1267
1268 1268 Filelogs Segment
1269 1269 ================
1270 1270
1271 1271 The *filelogs segment* consists of multiple sub-segments, each
1272 1272 corresponding to an individual file whose data is being described:
1273 1273
1274 1274 +--------------------------------------------------+
1275 1275 | | | | | |
1276 1276 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1277 1277 | | | | | (4 bytes) |
1278 1278 | | | | | |
1279 1279 +--------------------------------------------------+
1280 1280
1281 1281 The final filelog sub-segment is followed by an *empty chunk* (logically,
1282 1282 a sub-segment with filename size 0). This denotes the end of the segment
1283 1283 and of the overall changegroup.
1284 1284
1285 1285 Each filelog sub-segment consists of the following:
1286 1286
1287 1287 +------------------------------------------------------+
1288 1288 | | | |
1289 1289 | filename length | filename | delta group |
1290 1290 | (4 bytes) | (<length - 4> bytes) | (various) |
1291 1291 | | | |
1292 1292 +------------------------------------------------------+
1293 1293
1294 1294 That is, a *chunk* consisting of the filename (not terminated or padded)
1295 1295 followed by N chunks constituting the *delta group* for this file. The
1296 1296 *empty chunk* at the end of each *delta group* denotes the boundary to the
1297 1297 next filelog sub-segment.
1298 1298
1299 1299 test advanced, deprecated and experimental options are hidden in command help
1300 1300 $ hg help debugoptADV
1301 1301 hg debugoptADV
1302 1302
1303 1303 (no help text available)
1304 1304
1305 1305 options:
1306 1306
1307 1307 (some details hidden, use --verbose to show complete help)
1308 1308 $ hg help debugoptDEP
1309 1309 hg debugoptDEP
1310 1310
1311 1311 (no help text available)
1312 1312
1313 1313 options:
1314 1314
1315 1315 (some details hidden, use --verbose to show complete help)
1316 1316
1317 1317 $ hg help debugoptEXP
1318 1318 hg debugoptEXP
1319 1319
1320 1320 (no help text available)
1321 1321
1322 1322 options:
1323 1323
1324 1324 (some details hidden, use --verbose to show complete help)
1325 1325
1326 1326 test advanced, deprecated and experimental options are shown with -v
1327 1327 $ hg help -v debugoptADV | grep aopt
1328 1328 --aopt option is (ADVANCED)
1329 1329 $ hg help -v debugoptDEP | grep dopt
1330 1330 --dopt option is (DEPRECATED)
1331 1331 $ hg help -v debugoptEXP | grep eopt
1332 1332 --eopt option is (EXPERIMENTAL)
1333 1333
1334 1334 #if gettext
1335 1335 test deprecated option is hidden with translation with untranslated description
1336 1336 (use many globy for not failing on changed transaction)
1337 1337 $ LANGUAGE=sv hg help debugoptDEP
1338 1338 hg debugoptDEP
1339 1339
1340 1340 (*) (glob)
1341 1341
1342 1342 options:
1343 1343
1344 1344 (some details hidden, use --verbose to show complete help)
1345 1345 #endif
1346 1346
1347 1347 Test commands that collide with topics (issue4240)
1348 1348
1349 1349 $ hg config -hq
1350 1350 hg config [-u] [NAME]...
1351 1351
1352 1352 show combined config settings from all hgrc files
1353 1353 $ hg showconfig -hq
1354 1354 hg config [-u] [NAME]...
1355 1355
1356 1356 show combined config settings from all hgrc files
1357 1357
1358 1358 Test a help topic
1359 1359
1360 1360 $ hg help dates
1361 1361 Date Formats
1362 1362 """"""""""""
1363 1363
1364 1364 Some commands allow the user to specify a date, e.g.:
1365 1365
1366 1366 - backout, commit, import, tag: Specify the commit date.
1367 1367 - log, revert, update: Select revision(s) by date.
1368 1368
1369 1369 Many date formats are valid. Here are some examples:
1370 1370
1371 1371 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1372 1372 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1373 1373 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1374 1374 - "Dec 6" (midnight)
1375 1375 - "13:18" (today assumed)
1376 1376 - "3:39" (3:39AM assumed)
1377 1377 - "3:39pm" (15:39)
1378 1378 - "2006-12-06 13:18:29" (ISO 8601 format)
1379 1379 - "2006-12-6 13:18"
1380 1380 - "2006-12-6"
1381 1381 - "12-6"
1382 1382 - "12/6"
1383 1383 - "12/6/6" (Dec 6 2006)
1384 1384 - "today" (midnight)
1385 1385 - "yesterday" (midnight)
1386 1386 - "now" - right now
1387 1387
1388 1388 Lastly, there is Mercurial's internal format:
1389 1389
1390 1390 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1391 1391
1392 1392 This is the internal representation format for dates. The first number is
1393 1393 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1394 1394 is the offset of the local timezone, in seconds west of UTC (negative if
1395 1395 the timezone is east of UTC).
1396 1396
1397 1397 The log command also accepts date ranges:
1398 1398
1399 1399 - "<DATE" - at or before a given date/time
1400 1400 - ">DATE" - on or after a given date/time
1401 1401 - "DATE to DATE" - a date range, inclusive
1402 1402 - "-DAYS" - within a given number of days of today
1403 1403
1404 1404 Test repeated config section name
1405 1405
1406 1406 $ hg help config.host
1407 1407 "http_proxy.host"
1408 1408 Host name and (optional) port of the proxy server, for example
1409 1409 "myproxy:8000".
1410 1410
1411 1411 "smtp.host"
1412 1412 Host name of mail server, e.g. "mail.example.com".
1413 1413
1414 1414
1415 1415 Test section name with dot
1416 1416
1417 1417 $ hg help config.ui.username
1418 1418 "ui.username"
1419 1419 The committer of a changeset created when running "commit". Typically
1420 1420 a person's name and email address, e.g. "Fred Widget
1421 1421 <fred@example.com>". Environment variables in the username are
1422 1422 expanded.
1423 1423
1424 1424 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1425 1425 empty, e.g. if the system admin set "username =" in the system hgrc,
1426 1426 it has to be specified manually or in a different hgrc file)
1427 1427
1428 1428
1429 1429 $ hg help config.annotate.git
1430 1430 abort: help section not found: config.annotate.git
1431 1431 [255]
1432 1432
1433 1433 $ hg help config.update.check
1434 1434 "commands.update.check"
1435 1435 Determines what level of checking 'hg update' will perform before
1436 1436 moving to a destination revision. Valid values are "abort", "none",
1437 1437 "linear", and "noconflict". "abort" always fails if the working
1438 1438 directory has uncommitted changes. "none" performs no checking, and
1439 1439 may result in a merge with uncommitted changes. "linear" allows any
1440 1440 update as long as it follows a straight line in the revision history,
1441 1441 and may trigger a merge with uncommitted changes. "noconflict" will
1442 1442 allow any update which would not trigger a merge with uncommitted
1443 1443 changes, if any are present. (default: "linear")
1444 1444
1445 1445
1446 1446 $ hg help config.commands.update.check
1447 1447 "commands.update.check"
1448 1448 Determines what level of checking 'hg update' will perform before
1449 1449 moving to a destination revision. Valid values are "abort", "none",
1450 1450 "linear", and "noconflict". "abort" always fails if the working
1451 1451 directory has uncommitted changes. "none" performs no checking, and
1452 1452 may result in a merge with uncommitted changes. "linear" allows any
1453 1453 update as long as it follows a straight line in the revision history,
1454 1454 and may trigger a merge with uncommitted changes. "noconflict" will
1455 1455 allow any update which would not trigger a merge with uncommitted
1456 1456 changes, if any are present. (default: "linear")
1457 1457
1458 1458
1459 1459 $ hg help config.ommands.update.check
1460 1460 abort: help section not found: config.ommands.update.check
1461 1461 [255]
1462 1462
1463 1463 Unrelated trailing paragraphs shouldn't be included
1464 1464
1465 1465 $ hg help config.extramsg | grep '^$'
1466 1466
1467 1467
1468 1468 Test capitalized section name
1469 1469
1470 1470 $ hg help scripting.HGPLAIN > /dev/null
1471 1471
1472 1472 Help subsection:
1473 1473
1474 1474 $ hg help config.charsets |grep "Email example:" > /dev/null
1475 1475 [1]
1476 1476
1477 1477 Show nested definitions
1478 1478 ("profiling.type"[break]"ls"[break]"stat"[break])
1479 1479
1480 1480 $ hg help config.type | egrep '^$'|wc -l
1481 1481 \s*3 (re)
1482 1482
1483 1483 $ hg help config.profiling.type.ls
1484 1484 "profiling.type.ls"
1485 1485 Use Python's built-in instrumenting profiler. This profiler works on
1486 1486 all platforms, but each line number it reports is the first line of
1487 1487 a function. This restriction makes it difficult to identify the
1488 1488 expensive parts of a non-trivial function.
1489 1489
1490 1490
1491 1491 Separate sections from subsections
1492 1492
1493 1493 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1494 1494 "format"
1495 1495 --------
1496 1496
1497 1497 "usegeneraldelta"
1498 1498
1499 1499 "dotencode"
1500 1500
1501 1501 "usefncache"
1502 1502
1503 1503 "usestore"
1504 1504
1505 "sparse-revlog"
1506
1505 1507 "profiling"
1506 1508 -----------
1507 1509
1508 1510 "format"
1509 1511
1510 1512 "progress"
1511 1513 ----------
1512 1514
1513 1515 "format"
1514 1516
1515 1517
1516 1518 Last item in help config.*:
1517 1519
1518 1520 $ hg help config.`hg help config|grep '^ "'| \
1519 1521 > tail -1|sed 's![ "]*!!g'`| \
1520 1522 > grep 'hg help -c config' > /dev/null
1521 1523 [1]
1522 1524
1523 1525 note to use help -c for general hg help config:
1524 1526
1525 1527 $ hg help config |grep 'hg help -c config' > /dev/null
1526 1528
1527 1529 Test templating help
1528 1530
1529 1531 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1530 1532 desc String. The text of the changeset description.
1531 1533 diffstat String. Statistics of changes with the following format:
1532 1534 firstline Any text. Returns the first line of text.
1533 1535 nonempty Any text. Returns '(none)' if the string is empty.
1534 1536
1535 1537 Test deprecated items
1536 1538
1537 1539 $ hg help -v templating | grep currentbookmark
1538 1540 currentbookmark
1539 1541 $ hg help templating | (grep currentbookmark || true)
1540 1542
1541 1543 Test help hooks
1542 1544
1543 1545 $ cat > helphook1.py <<EOF
1544 1546 > from mercurial import help
1545 1547 >
1546 1548 > def rewrite(ui, topic, doc):
1547 1549 > return doc + b'\nhelphook1\n'
1548 1550 >
1549 1551 > def extsetup(ui):
1550 1552 > help.addtopichook(b'revisions', rewrite)
1551 1553 > EOF
1552 1554 $ cat > helphook2.py <<EOF
1553 1555 > from mercurial import help
1554 1556 >
1555 1557 > def rewrite(ui, topic, doc):
1556 1558 > return doc + b'\nhelphook2\n'
1557 1559 >
1558 1560 > def extsetup(ui):
1559 1561 > help.addtopichook(b'revisions', rewrite)
1560 1562 > EOF
1561 1563 $ echo '[extensions]' >> $HGRCPATH
1562 1564 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1563 1565 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1564 1566 $ hg help revsets | grep helphook
1565 1567 helphook1
1566 1568 helphook2
1567 1569
1568 1570 help -c should only show debug --debug
1569 1571
1570 1572 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1571 1573 [1]
1572 1574
1573 1575 help -c should only show deprecated for -v
1574 1576
1575 1577 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1576 1578 [1]
1577 1579
1578 1580 Test -s / --system
1579 1581
1580 1582 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1581 1583 > wc -l | sed -e 's/ //g'
1582 1584 0
1583 1585 $ hg help config.files --system unix | grep 'USER' | \
1584 1586 > wc -l | sed -e 's/ //g'
1585 1587 0
1586 1588
1587 1589 Test -e / -c / -k combinations
1588 1590
1589 1591 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1590 1592 Commands:
1591 1593 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1592 1594 Extensions:
1593 1595 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1594 1596 Topics:
1595 1597 Commands:
1596 1598 Extensions:
1597 1599 Extension Commands:
1598 1600 $ hg help -c schemes
1599 1601 abort: no such help topic: schemes
1600 1602 (try 'hg help --keyword schemes')
1601 1603 [255]
1602 1604 $ hg help -e schemes |head -1
1603 1605 schemes extension - extend schemes with shortcuts to repository swarms
1604 1606 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1605 1607 Commands:
1606 1608 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1607 1609 Extensions:
1608 1610 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1609 1611 Extensions:
1610 1612 Commands:
1611 1613 $ hg help -c commit > /dev/null
1612 1614 $ hg help -e -c commit > /dev/null
1613 1615 $ hg help -e commit
1614 1616 abort: no such help topic: commit
1615 1617 (try 'hg help --keyword commit')
1616 1618 [255]
1617 1619
1618 1620 Test keyword search help
1619 1621
1620 1622 $ cat > prefixedname.py <<EOF
1621 1623 > '''matched against word "clone"
1622 1624 > '''
1623 1625 > EOF
1624 1626 $ echo '[extensions]' >> $HGRCPATH
1625 1627 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1626 1628 $ hg help -k clone
1627 1629 Topics:
1628 1630
1629 1631 config Configuration Files
1630 1632 extensions Using Additional Features
1631 1633 glossary Glossary
1632 1634 phases Working with Phases
1633 1635 subrepos Subrepositories
1634 1636 urls URL Paths
1635 1637
1636 1638 Commands:
1637 1639
1638 1640 bookmarks create a new bookmark or list existing bookmarks
1639 1641 clone make a copy of an existing repository
1640 1642 paths show aliases for remote repositories
1641 1643 pull pull changes from the specified source
1642 1644 update update working directory (or switch revisions)
1643 1645
1644 1646 Extensions:
1645 1647
1646 1648 clonebundles advertise pre-generated bundles to seed clones
1647 1649 narrow create clones which fetch history data for subset of files
1648 1650 (EXPERIMENTAL)
1649 1651 prefixedname matched against word "clone"
1650 1652 relink recreates hardlinks between repository clones
1651 1653
1652 1654 Extension Commands:
1653 1655
1654 1656 qclone clone main and patch repository at same time
1655 1657
1656 1658 Test unfound topic
1657 1659
1658 1660 $ hg help nonexistingtopicthatwillneverexisteverever
1659 1661 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1660 1662 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1661 1663 [255]
1662 1664
1663 1665 Test unfound keyword
1664 1666
1665 1667 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1666 1668 abort: no matches
1667 1669 (try 'hg help' for a list of topics)
1668 1670 [255]
1669 1671
1670 1672 Test omit indicating for help
1671 1673
1672 1674 $ cat > addverboseitems.py <<EOF
1673 1675 > '''extension to test omit indicating.
1674 1676 >
1675 1677 > This paragraph is never omitted (for extension)
1676 1678 >
1677 1679 > .. container:: verbose
1678 1680 >
1679 1681 > This paragraph is omitted,
1680 1682 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1681 1683 >
1682 1684 > This paragraph is never omitted, too (for extension)
1683 1685 > '''
1684 1686 > from __future__ import absolute_import
1685 1687 > from mercurial import commands, help
1686 1688 > testtopic = b"""This paragraph is never omitted (for topic).
1687 1689 >
1688 1690 > .. container:: verbose
1689 1691 >
1690 1692 > This paragraph is omitted,
1691 1693 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1692 1694 >
1693 1695 > This paragraph is never omitted, too (for topic)
1694 1696 > """
1695 1697 > def extsetup(ui):
1696 1698 > help.helptable.append(([b"topic-containing-verbose"],
1697 1699 > b"This is the topic to test omit indicating.",
1698 1700 > lambda ui: testtopic))
1699 1701 > EOF
1700 1702 $ echo '[extensions]' >> $HGRCPATH
1701 1703 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1702 1704 $ hg help addverboseitems
1703 1705 addverboseitems extension - extension to test omit indicating.
1704 1706
1705 1707 This paragraph is never omitted (for extension)
1706 1708
1707 1709 This paragraph is never omitted, too (for extension)
1708 1710
1709 1711 (some details hidden, use --verbose to show complete help)
1710 1712
1711 1713 no commands defined
1712 1714 $ hg help -v addverboseitems
1713 1715 addverboseitems extension - extension to test omit indicating.
1714 1716
1715 1717 This paragraph is never omitted (for extension)
1716 1718
1717 1719 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1718 1720 extension)
1719 1721
1720 1722 This paragraph is never omitted, too (for extension)
1721 1723
1722 1724 no commands defined
1723 1725 $ hg help topic-containing-verbose
1724 1726 This is the topic to test omit indicating.
1725 1727 """"""""""""""""""""""""""""""""""""""""""
1726 1728
1727 1729 This paragraph is never omitted (for topic).
1728 1730
1729 1731 This paragraph is never omitted, too (for topic)
1730 1732
1731 1733 (some details hidden, use --verbose to show complete help)
1732 1734 $ hg help -v topic-containing-verbose
1733 1735 This is the topic to test omit indicating.
1734 1736 """"""""""""""""""""""""""""""""""""""""""
1735 1737
1736 1738 This paragraph is never omitted (for topic).
1737 1739
1738 1740 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1739 1741 topic)
1740 1742
1741 1743 This paragraph is never omitted, too (for topic)
1742 1744
1743 1745 Test section lookup
1744 1746
1745 1747 $ hg help revset.merge
1746 1748 "merge()"
1747 1749 Changeset is a merge changeset.
1748 1750
1749 1751 $ hg help glossary.dag
1750 1752 DAG
1751 1753 The repository of changesets of a distributed version control system
1752 1754 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1753 1755 of nodes and edges, where nodes correspond to changesets and edges
1754 1756 imply a parent -> child relation. This graph can be visualized by
1755 1757 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1756 1758 limited by the requirement for children to have at most two parents.
1757 1759
1758 1760
1759 1761 $ hg help hgrc.paths
1760 1762 "paths"
1761 1763 -------
1762 1764
1763 1765 Assigns symbolic names and behavior to repositories.
1764 1766
1765 1767 Options are symbolic names defining the URL or directory that is the
1766 1768 location of the repository. Example:
1767 1769
1768 1770 [paths]
1769 1771 my_server = https://example.com/my_repo
1770 1772 local_path = /home/me/repo
1771 1773
1772 1774 These symbolic names can be used from the command line. To pull from
1773 1775 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1774 1776 local_path'.
1775 1777
1776 1778 Options containing colons (":") denote sub-options that can influence
1777 1779 behavior for that specific path. Example:
1778 1780
1779 1781 [paths]
1780 1782 my_server = https://example.com/my_path
1781 1783 my_server:pushurl = ssh://example.com/my_path
1782 1784
1783 1785 The following sub-options can be defined:
1784 1786
1785 1787 "pushurl"
1786 1788 The URL to use for push operations. If not defined, the location
1787 1789 defined by the path's main entry is used.
1788 1790
1789 1791 "pushrev"
1790 1792 A revset defining which revisions to push by default.
1791 1793
1792 1794 When 'hg push' is executed without a "-r" argument, the revset defined
1793 1795 by this sub-option is evaluated to determine what to push.
1794 1796
1795 1797 For example, a value of "." will push the working directory's revision
1796 1798 by default.
1797 1799
1798 1800 Revsets specifying bookmarks will not result in the bookmark being
1799 1801 pushed.
1800 1802
1801 1803 The following special named paths exist:
1802 1804
1803 1805 "default"
1804 1806 The URL or directory to use when no source or remote is specified.
1805 1807
1806 1808 'hg clone' will automatically define this path to the location the
1807 1809 repository was cloned from.
1808 1810
1809 1811 "default-push"
1810 1812 (deprecated) The URL or directory for the default 'hg push' location.
1811 1813 "default:pushurl" should be used instead.
1812 1814
1813 1815 $ hg help glossary.mcguffin
1814 1816 abort: help section not found: glossary.mcguffin
1815 1817 [255]
1816 1818
1817 1819 $ hg help glossary.mc.guffin
1818 1820 abort: help section not found: glossary.mc.guffin
1819 1821 [255]
1820 1822
1821 1823 $ hg help template.files
1822 1824 files List of strings. All files modified, added, or removed by
1823 1825 this changeset.
1824 1826 files(pattern)
1825 1827 All files of the current changeset matching the pattern. See
1826 1828 'hg help patterns'.
1827 1829
1828 1830 Test section lookup by translated message
1829 1831
1830 1832 str.lower() instead of encoding.lower(str) on translated message might
1831 1833 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1832 1834 as the second or later byte of multi-byte character.
1833 1835
1834 1836 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1835 1837 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1836 1838 replacement makes message meaningless.
1837 1839
1838 1840 This tests that section lookup by translated string isn't broken by
1839 1841 such str.lower().
1840 1842
1841 1843 $ "$PYTHON" <<EOF
1842 1844 > def escape(s):
1843 1845 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1844 1846 > # translation of "record" in ja_JP.cp932
1845 1847 > upper = b"\x8bL\x98^"
1846 1848 > # str.lower()-ed section name should be treated as different one
1847 1849 > lower = b"\x8bl\x98^"
1848 1850 > with open('ambiguous.py', 'wb') as fp:
1849 1851 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1850 1852 > u'''summary of extension
1851 1853 >
1852 1854 > %s
1853 1855 > ----
1854 1856 >
1855 1857 > Upper name should show only this message
1856 1858 >
1857 1859 > %s
1858 1860 > ----
1859 1861 >
1860 1862 > Lower name should show only this message
1861 1863 >
1862 1864 > subsequent section
1863 1865 > ------------------
1864 1866 >
1865 1867 > This should be hidden at 'hg help ambiguous' with section name.
1866 1868 > '''
1867 1869 > """ % (escape(upper), escape(lower)))
1868 1870 > EOF
1869 1871
1870 1872 $ cat >> $HGRCPATH <<EOF
1871 1873 > [extensions]
1872 1874 > ambiguous = ./ambiguous.py
1873 1875 > EOF
1874 1876
1875 1877 $ "$PYTHON" <<EOF | sh
1876 1878 > from mercurial import pycompat
1877 1879 > upper = b"\x8bL\x98^"
1878 1880 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1879 1881 > EOF
1880 1882 \x8bL\x98^ (esc)
1881 1883 ----
1882 1884
1883 1885 Upper name should show only this message
1884 1886
1885 1887
1886 1888 $ "$PYTHON" <<EOF | sh
1887 1889 > from mercurial import pycompat
1888 1890 > lower = b"\x8bl\x98^"
1889 1891 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
1890 1892 > EOF
1891 1893 \x8bl\x98^ (esc)
1892 1894 ----
1893 1895
1894 1896 Lower name should show only this message
1895 1897
1896 1898
1897 1899 $ cat >> $HGRCPATH <<EOF
1898 1900 > [extensions]
1899 1901 > ambiguous = !
1900 1902 > EOF
1901 1903
1902 1904 Show help content of disabled extensions
1903 1905
1904 1906 $ cat >> $HGRCPATH <<EOF
1905 1907 > [extensions]
1906 1908 > ambiguous = !./ambiguous.py
1907 1909 > EOF
1908 1910 $ hg help -e ambiguous
1909 1911 ambiguous extension - (no help text available)
1910 1912
1911 1913 (use 'hg help extensions' for information on enabling extensions)
1912 1914
1913 1915 Test dynamic list of merge tools only shows up once
1914 1916 $ hg help merge-tools
1915 1917 Merge Tools
1916 1918 """""""""""
1917 1919
1918 1920 To merge files Mercurial uses merge tools.
1919 1921
1920 1922 A merge tool combines two different versions of a file into a merged file.
1921 1923 Merge tools are given the two files and the greatest common ancestor of
1922 1924 the two file versions, so they can determine the changes made on both
1923 1925 branches.
1924 1926
1925 1927 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1926 1928 backout' and in several extensions.
1927 1929
1928 1930 Usually, the merge tool tries to automatically reconcile the files by
1929 1931 combining all non-overlapping changes that occurred separately in the two
1930 1932 different evolutions of the same initial base file. Furthermore, some
1931 1933 interactive merge programs make it easier to manually resolve conflicting
1932 1934 merges, either in a graphical way, or by inserting some conflict markers.
1933 1935 Mercurial does not include any interactive merge programs but relies on
1934 1936 external tools for that.
1935 1937
1936 1938 Available merge tools
1937 1939 =====================
1938 1940
1939 1941 External merge tools and their properties are configured in the merge-
1940 1942 tools configuration section - see hgrc(5) - but they can often just be
1941 1943 named by their executable.
1942 1944
1943 1945 A merge tool is generally usable if its executable can be found on the
1944 1946 system and if it can handle the merge. The executable is found if it is an
1945 1947 absolute or relative executable path or the name of an application in the
1946 1948 executable search path. The tool is assumed to be able to handle the merge
1947 1949 if it can handle symlinks if the file is a symlink, if it can handle
1948 1950 binary files if the file is binary, and if a GUI is available if the tool
1949 1951 requires a GUI.
1950 1952
1951 1953 There are some internal merge tools which can be used. The internal merge
1952 1954 tools are:
1953 1955
1954 1956 ":dump"
1955 1957 Creates three versions of the files to merge, containing the contents of
1956 1958 local, other and base. These files can then be used to perform a merge
1957 1959 manually. If the file to be merged is named "a.txt", these files will
1958 1960 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1959 1961 they will be placed in the same directory as "a.txt".
1960 1962
1961 1963 This implies premerge. Therefore, files aren't dumped, if premerge runs
1962 1964 successfully. Use :forcedump to forcibly write files out.
1963 1965
1964 1966 (actual capabilities: binary, symlink)
1965 1967
1966 1968 ":fail"
1967 1969 Rather than attempting to merge files that were modified on both
1968 1970 branches, it marks them as unresolved. The resolve command must be used
1969 1971 to resolve these conflicts.
1970 1972
1971 1973 (actual capabilities: binary, symlink)
1972 1974
1973 1975 ":forcedump"
1974 1976 Creates three versions of the files as same as :dump, but omits
1975 1977 premerge.
1976 1978
1977 1979 (actual capabilities: binary, symlink)
1978 1980
1979 1981 ":local"
1980 1982 Uses the local 'p1()' version of files as the merged version.
1981 1983
1982 1984 (actual capabilities: binary, symlink)
1983 1985
1984 1986 ":merge"
1985 1987 Uses the internal non-interactive simple merge algorithm for merging
1986 1988 files. It will fail if there are any conflicts and leave markers in the
1987 1989 partially merged file. Markers will have two sections, one for each side
1988 1990 of merge.
1989 1991
1990 1992 ":merge-local"
1991 1993 Like :merge, but resolve all conflicts non-interactively in favor of the
1992 1994 local 'p1()' changes.
1993 1995
1994 1996 ":merge-other"
1995 1997 Like :merge, but resolve all conflicts non-interactively in favor of the
1996 1998 other 'p2()' changes.
1997 1999
1998 2000 ":merge3"
1999 2001 Uses the internal non-interactive simple merge algorithm for merging
2000 2002 files. It will fail if there are any conflicts and leave markers in the
2001 2003 partially merged file. Marker will have three sections, one from each
2002 2004 side of the merge and one for the base content.
2003 2005
2004 2006 ":other"
2005 2007 Uses the other 'p2()' version of files as the merged version.
2006 2008
2007 2009 (actual capabilities: binary, symlink)
2008 2010
2009 2011 ":prompt"
2010 2012 Asks the user which of the local 'p1()' or the other 'p2()' version to
2011 2013 keep as the merged version.
2012 2014
2013 2015 (actual capabilities: binary, symlink)
2014 2016
2015 2017 ":tagmerge"
2016 2018 Uses the internal tag merge algorithm (experimental).
2017 2019
2018 2020 ":union"
2019 2021 Uses the internal non-interactive simple merge algorithm for merging
2020 2022 files. It will use both left and right sides for conflict regions. No
2021 2023 markers are inserted.
2022 2024
2023 2025 Internal tools are always available and do not require a GUI but will by
2024 2026 default not handle symlinks or binary files. See next section for detail
2025 2027 about "actual capabilities" described above.
2026 2028
2027 2029 Choosing a merge tool
2028 2030 =====================
2029 2031
2030 2032 Mercurial uses these rules when deciding which merge tool to use:
2031 2033
2032 2034 1. If a tool has been specified with the --tool option to merge or
2033 2035 resolve, it is used. If it is the name of a tool in the merge-tools
2034 2036 configuration, its configuration is used. Otherwise the specified tool
2035 2037 must be executable by the shell.
2036 2038 2. If the "HGMERGE" environment variable is present, its value is used and
2037 2039 must be executable by the shell.
2038 2040 3. If the filename of the file to be merged matches any of the patterns in
2039 2041 the merge-patterns configuration section, the first usable merge tool
2040 2042 corresponding to a matching pattern is used.
2041 2043 4. If ui.merge is set it will be considered next. If the value is not the
2042 2044 name of a configured tool, the specified value is used and must be
2043 2045 executable by the shell. Otherwise the named tool is used if it is
2044 2046 usable.
2045 2047 5. If any usable merge tools are present in the merge-tools configuration
2046 2048 section, the one with the highest priority is used.
2047 2049 6. If a program named "hgmerge" can be found on the system, it is used -
2048 2050 but it will by default not be used for symlinks and binary files.
2049 2051 7. If the file to be merged is not binary and is not a symlink, then
2050 2052 internal ":merge" is used.
2051 2053 8. Otherwise, ":prompt" is used.
2052 2054
2053 2055 For historical reason, Mercurial treats merge tools as below while
2054 2056 examining rules above.
2055 2057
2056 2058 step specified via binary symlink
2057 2059 ----------------------------------
2058 2060 1. --tool o/o o/o
2059 2061 2. HGMERGE o/o o/o
2060 2062 3. merge-patterns o/o(*) x/?(*)
2061 2063 4. ui.merge x/?(*) x/?(*)
2062 2064
2063 2065 Each capability column indicates Mercurial behavior for internal/external
2064 2066 merge tools at examining each rule.
2065 2067
2066 2068 - "o": "assume that a tool has capability"
2067 2069 - "x": "assume that a tool does not have capability"
2068 2070 - "?": "check actual capability of a tool"
2069 2071
2070 2072 If "merge.strict-capability-check" configuration is true, Mercurial checks
2071 2073 capabilities of merge tools strictly in (*) cases above (= each capability
2072 2074 column becomes "?/?"). It is false by default for backward compatibility.
2073 2075
2074 2076 Note:
2075 2077 After selecting a merge program, Mercurial will by default attempt to
2076 2078 merge the files using a simple merge algorithm first. Only if it
2077 2079 doesn't succeed because of conflicting changes will Mercurial actually
2078 2080 execute the merge program. Whether to use the simple merge algorithm
2079 2081 first can be controlled by the premerge setting of the merge tool.
2080 2082 Premerge is enabled by default unless the file is binary or a symlink.
2081 2083
2082 2084 See the merge-tools and ui sections of hgrc(5) for details on the
2083 2085 configuration of merge tools.
2084 2086
2085 2087 Compression engines listed in `hg help bundlespec`
2086 2088
2087 2089 $ hg help bundlespec | grep gzip
2088 2090 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2089 2091 An algorithm that produces smaller bundles than "gzip".
2090 2092 This engine will likely produce smaller bundles than "gzip" but will be
2091 2093 "gzip"
2092 2094 better compression than "gzip". It also frequently yields better (?)
2093 2095
2094 2096 Test usage of section marks in help documents
2095 2097
2096 2098 $ cd "$TESTDIR"/../doc
2097 2099 $ "$PYTHON" check-seclevel.py
2098 2100 $ cd $TESTTMP
2099 2101
2100 2102 #if serve
2101 2103
2102 2104 Test the help pages in hgweb.
2103 2105
2104 2106 Dish up an empty repo; serve it cold.
2105 2107
2106 2108 $ hg init "$TESTTMP/test"
2107 2109 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2108 2110 $ cat hg.pid >> $DAEMON_PIDS
2109 2111
2110 2112 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2111 2113 200 Script output follows
2112 2114
2113 2115 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2114 2116 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2115 2117 <head>
2116 2118 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2117 2119 <meta name="robots" content="index, nofollow" />
2118 2120 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2119 2121 <script type="text/javascript" src="/static/mercurial.js"></script>
2120 2122
2121 2123 <title>Help: Index</title>
2122 2124 </head>
2123 2125 <body>
2124 2126
2125 2127 <div class="container">
2126 2128 <div class="menu">
2127 2129 <div class="logo">
2128 2130 <a href="https://mercurial-scm.org/">
2129 2131 <img src="/static/hglogo.png" alt="mercurial" /></a>
2130 2132 </div>
2131 2133 <ul>
2132 2134 <li><a href="/shortlog">log</a></li>
2133 2135 <li><a href="/graph">graph</a></li>
2134 2136 <li><a href="/tags">tags</a></li>
2135 2137 <li><a href="/bookmarks">bookmarks</a></li>
2136 2138 <li><a href="/branches">branches</a></li>
2137 2139 </ul>
2138 2140 <ul>
2139 2141 <li class="active">help</li>
2140 2142 </ul>
2141 2143 </div>
2142 2144
2143 2145 <div class="main">
2144 2146 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2145 2147
2146 2148 <form class="search" action="/log">
2147 2149
2148 2150 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2149 2151 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2150 2152 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2151 2153 </form>
2152 2154 <table class="bigtable">
2153 2155 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2154 2156
2155 2157 <tr><td>
2156 2158 <a href="/help/bundlespec">
2157 2159 bundlespec
2158 2160 </a>
2159 2161 </td><td>
2160 2162 Bundle File Formats
2161 2163 </td></tr>
2162 2164 <tr><td>
2163 2165 <a href="/help/color">
2164 2166 color
2165 2167 </a>
2166 2168 </td><td>
2167 2169 Colorizing Outputs
2168 2170 </td></tr>
2169 2171 <tr><td>
2170 2172 <a href="/help/config">
2171 2173 config
2172 2174 </a>
2173 2175 </td><td>
2174 2176 Configuration Files
2175 2177 </td></tr>
2176 2178 <tr><td>
2177 2179 <a href="/help/dates">
2178 2180 dates
2179 2181 </a>
2180 2182 </td><td>
2181 2183 Date Formats
2182 2184 </td></tr>
2183 2185 <tr><td>
2184 2186 <a href="/help/deprecated">
2185 2187 deprecated
2186 2188 </a>
2187 2189 </td><td>
2188 2190 Deprecated Features
2189 2191 </td></tr>
2190 2192 <tr><td>
2191 2193 <a href="/help/diffs">
2192 2194 diffs
2193 2195 </a>
2194 2196 </td><td>
2195 2197 Diff Formats
2196 2198 </td></tr>
2197 2199 <tr><td>
2198 2200 <a href="/help/environment">
2199 2201 environment
2200 2202 </a>
2201 2203 </td><td>
2202 2204 Environment Variables
2203 2205 </td></tr>
2204 2206 <tr><td>
2205 2207 <a href="/help/extensions">
2206 2208 extensions
2207 2209 </a>
2208 2210 </td><td>
2209 2211 Using Additional Features
2210 2212 </td></tr>
2211 2213 <tr><td>
2212 2214 <a href="/help/filesets">
2213 2215 filesets
2214 2216 </a>
2215 2217 </td><td>
2216 2218 Specifying File Sets
2217 2219 </td></tr>
2218 2220 <tr><td>
2219 2221 <a href="/help/flags">
2220 2222 flags
2221 2223 </a>
2222 2224 </td><td>
2223 2225 Command-line flags
2224 2226 </td></tr>
2225 2227 <tr><td>
2226 2228 <a href="/help/glossary">
2227 2229 glossary
2228 2230 </a>
2229 2231 </td><td>
2230 2232 Glossary
2231 2233 </td></tr>
2232 2234 <tr><td>
2233 2235 <a href="/help/hgignore">
2234 2236 hgignore
2235 2237 </a>
2236 2238 </td><td>
2237 2239 Syntax for Mercurial Ignore Files
2238 2240 </td></tr>
2239 2241 <tr><td>
2240 2242 <a href="/help/hgweb">
2241 2243 hgweb
2242 2244 </a>
2243 2245 </td><td>
2244 2246 Configuring hgweb
2245 2247 </td></tr>
2246 2248 <tr><td>
2247 2249 <a href="/help/internals">
2248 2250 internals
2249 2251 </a>
2250 2252 </td><td>
2251 2253 Technical implementation topics
2252 2254 </td></tr>
2253 2255 <tr><td>
2254 2256 <a href="/help/merge-tools">
2255 2257 merge-tools
2256 2258 </a>
2257 2259 </td><td>
2258 2260 Merge Tools
2259 2261 </td></tr>
2260 2262 <tr><td>
2261 2263 <a href="/help/pager">
2262 2264 pager
2263 2265 </a>
2264 2266 </td><td>
2265 2267 Pager Support
2266 2268 </td></tr>
2267 2269 <tr><td>
2268 2270 <a href="/help/patterns">
2269 2271 patterns
2270 2272 </a>
2271 2273 </td><td>
2272 2274 File Name Patterns
2273 2275 </td></tr>
2274 2276 <tr><td>
2275 2277 <a href="/help/phases">
2276 2278 phases
2277 2279 </a>
2278 2280 </td><td>
2279 2281 Working with Phases
2280 2282 </td></tr>
2281 2283 <tr><td>
2282 2284 <a href="/help/revisions">
2283 2285 revisions
2284 2286 </a>
2285 2287 </td><td>
2286 2288 Specifying Revisions
2287 2289 </td></tr>
2288 2290 <tr><td>
2289 2291 <a href="/help/scripting">
2290 2292 scripting
2291 2293 </a>
2292 2294 </td><td>
2293 2295 Using Mercurial from scripts and automation
2294 2296 </td></tr>
2295 2297 <tr><td>
2296 2298 <a href="/help/subrepos">
2297 2299 subrepos
2298 2300 </a>
2299 2301 </td><td>
2300 2302 Subrepositories
2301 2303 </td></tr>
2302 2304 <tr><td>
2303 2305 <a href="/help/templating">
2304 2306 templating
2305 2307 </a>
2306 2308 </td><td>
2307 2309 Template Usage
2308 2310 </td></tr>
2309 2311 <tr><td>
2310 2312 <a href="/help/urls">
2311 2313 urls
2312 2314 </a>
2313 2315 </td><td>
2314 2316 URL Paths
2315 2317 </td></tr>
2316 2318 <tr><td>
2317 2319 <a href="/help/topic-containing-verbose">
2318 2320 topic-containing-verbose
2319 2321 </a>
2320 2322 </td><td>
2321 2323 This is the topic to test omit indicating.
2322 2324 </td></tr>
2323 2325
2324 2326
2325 2327 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2326 2328
2327 2329 <tr><td>
2328 2330 <a href="/help/add">
2329 2331 add
2330 2332 </a>
2331 2333 </td><td>
2332 2334 add the specified files on the next commit
2333 2335 </td></tr>
2334 2336 <tr><td>
2335 2337 <a href="/help/annotate">
2336 2338 annotate
2337 2339 </a>
2338 2340 </td><td>
2339 2341 show changeset information by line for each file
2340 2342 </td></tr>
2341 2343 <tr><td>
2342 2344 <a href="/help/clone">
2343 2345 clone
2344 2346 </a>
2345 2347 </td><td>
2346 2348 make a copy of an existing repository
2347 2349 </td></tr>
2348 2350 <tr><td>
2349 2351 <a href="/help/commit">
2350 2352 commit
2351 2353 </a>
2352 2354 </td><td>
2353 2355 commit the specified files or all outstanding changes
2354 2356 </td></tr>
2355 2357 <tr><td>
2356 2358 <a href="/help/diff">
2357 2359 diff
2358 2360 </a>
2359 2361 </td><td>
2360 2362 diff repository (or selected files)
2361 2363 </td></tr>
2362 2364 <tr><td>
2363 2365 <a href="/help/export">
2364 2366 export
2365 2367 </a>
2366 2368 </td><td>
2367 2369 dump the header and diffs for one or more changesets
2368 2370 </td></tr>
2369 2371 <tr><td>
2370 2372 <a href="/help/forget">
2371 2373 forget
2372 2374 </a>
2373 2375 </td><td>
2374 2376 forget the specified files on the next commit
2375 2377 </td></tr>
2376 2378 <tr><td>
2377 2379 <a href="/help/init">
2378 2380 init
2379 2381 </a>
2380 2382 </td><td>
2381 2383 create a new repository in the given directory
2382 2384 </td></tr>
2383 2385 <tr><td>
2384 2386 <a href="/help/log">
2385 2387 log
2386 2388 </a>
2387 2389 </td><td>
2388 2390 show revision history of entire repository or files
2389 2391 </td></tr>
2390 2392 <tr><td>
2391 2393 <a href="/help/merge">
2392 2394 merge
2393 2395 </a>
2394 2396 </td><td>
2395 2397 merge another revision into working directory
2396 2398 </td></tr>
2397 2399 <tr><td>
2398 2400 <a href="/help/pull">
2399 2401 pull
2400 2402 </a>
2401 2403 </td><td>
2402 2404 pull changes from the specified source
2403 2405 </td></tr>
2404 2406 <tr><td>
2405 2407 <a href="/help/push">
2406 2408 push
2407 2409 </a>
2408 2410 </td><td>
2409 2411 push changes to the specified destination
2410 2412 </td></tr>
2411 2413 <tr><td>
2412 2414 <a href="/help/remove">
2413 2415 remove
2414 2416 </a>
2415 2417 </td><td>
2416 2418 remove the specified files on the next commit
2417 2419 </td></tr>
2418 2420 <tr><td>
2419 2421 <a href="/help/serve">
2420 2422 serve
2421 2423 </a>
2422 2424 </td><td>
2423 2425 start stand-alone webserver
2424 2426 </td></tr>
2425 2427 <tr><td>
2426 2428 <a href="/help/status">
2427 2429 status
2428 2430 </a>
2429 2431 </td><td>
2430 2432 show changed files in the working directory
2431 2433 </td></tr>
2432 2434 <tr><td>
2433 2435 <a href="/help/summary">
2434 2436 summary
2435 2437 </a>
2436 2438 </td><td>
2437 2439 summarize working directory state
2438 2440 </td></tr>
2439 2441 <tr><td>
2440 2442 <a href="/help/update">
2441 2443 update
2442 2444 </a>
2443 2445 </td><td>
2444 2446 update working directory (or switch revisions)
2445 2447 </td></tr>
2446 2448
2447 2449
2448 2450
2449 2451 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2450 2452
2451 2453 <tr><td>
2452 2454 <a href="/help/addremove">
2453 2455 addremove
2454 2456 </a>
2455 2457 </td><td>
2456 2458 add all new files, delete all missing files
2457 2459 </td></tr>
2458 2460 <tr><td>
2459 2461 <a href="/help/archive">
2460 2462 archive
2461 2463 </a>
2462 2464 </td><td>
2463 2465 create an unversioned archive of a repository revision
2464 2466 </td></tr>
2465 2467 <tr><td>
2466 2468 <a href="/help/backout">
2467 2469 backout
2468 2470 </a>
2469 2471 </td><td>
2470 2472 reverse effect of earlier changeset
2471 2473 </td></tr>
2472 2474 <tr><td>
2473 2475 <a href="/help/bisect">
2474 2476 bisect
2475 2477 </a>
2476 2478 </td><td>
2477 2479 subdivision search of changesets
2478 2480 </td></tr>
2479 2481 <tr><td>
2480 2482 <a href="/help/bookmarks">
2481 2483 bookmarks
2482 2484 </a>
2483 2485 </td><td>
2484 2486 create a new bookmark or list existing bookmarks
2485 2487 </td></tr>
2486 2488 <tr><td>
2487 2489 <a href="/help/branch">
2488 2490 branch
2489 2491 </a>
2490 2492 </td><td>
2491 2493 set or show the current branch name
2492 2494 </td></tr>
2493 2495 <tr><td>
2494 2496 <a href="/help/branches">
2495 2497 branches
2496 2498 </a>
2497 2499 </td><td>
2498 2500 list repository named branches
2499 2501 </td></tr>
2500 2502 <tr><td>
2501 2503 <a href="/help/bundle">
2502 2504 bundle
2503 2505 </a>
2504 2506 </td><td>
2505 2507 create a bundle file
2506 2508 </td></tr>
2507 2509 <tr><td>
2508 2510 <a href="/help/cat">
2509 2511 cat
2510 2512 </a>
2511 2513 </td><td>
2512 2514 output the current or given revision of files
2513 2515 </td></tr>
2514 2516 <tr><td>
2515 2517 <a href="/help/config">
2516 2518 config
2517 2519 </a>
2518 2520 </td><td>
2519 2521 show combined config settings from all hgrc files
2520 2522 </td></tr>
2521 2523 <tr><td>
2522 2524 <a href="/help/copy">
2523 2525 copy
2524 2526 </a>
2525 2527 </td><td>
2526 2528 mark files as copied for the next commit
2527 2529 </td></tr>
2528 2530 <tr><td>
2529 2531 <a href="/help/files">
2530 2532 files
2531 2533 </a>
2532 2534 </td><td>
2533 2535 list tracked files
2534 2536 </td></tr>
2535 2537 <tr><td>
2536 2538 <a href="/help/graft">
2537 2539 graft
2538 2540 </a>
2539 2541 </td><td>
2540 2542 copy changes from other branches onto the current branch
2541 2543 </td></tr>
2542 2544 <tr><td>
2543 2545 <a href="/help/grep">
2544 2546 grep
2545 2547 </a>
2546 2548 </td><td>
2547 2549 search revision history for a pattern in specified files
2548 2550 </td></tr>
2549 2551 <tr><td>
2550 2552 <a href="/help/hashelp">
2551 2553 hashelp
2552 2554 </a>
2553 2555 </td><td>
2554 2556 Extension command's help
2555 2557 </td></tr>
2556 2558 <tr><td>
2557 2559 <a href="/help/heads">
2558 2560 heads
2559 2561 </a>
2560 2562 </td><td>
2561 2563 show branch heads
2562 2564 </td></tr>
2563 2565 <tr><td>
2564 2566 <a href="/help/help">
2565 2567 help
2566 2568 </a>
2567 2569 </td><td>
2568 2570 show help for a given topic or a help overview
2569 2571 </td></tr>
2570 2572 <tr><td>
2571 2573 <a href="/help/hgalias">
2572 2574 hgalias
2573 2575 </a>
2574 2576 </td><td>
2575 2577 My doc
2576 2578 </td></tr>
2577 2579 <tr><td>
2578 2580 <a href="/help/hgaliasnodoc">
2579 2581 hgaliasnodoc
2580 2582 </a>
2581 2583 </td><td>
2582 2584 summarize working directory state
2583 2585 </td></tr>
2584 2586 <tr><td>
2585 2587 <a href="/help/identify">
2586 2588 identify
2587 2589 </a>
2588 2590 </td><td>
2589 2591 identify the working directory or specified revision
2590 2592 </td></tr>
2591 2593 <tr><td>
2592 2594 <a href="/help/import">
2593 2595 import
2594 2596 </a>
2595 2597 </td><td>
2596 2598 import an ordered set of patches
2597 2599 </td></tr>
2598 2600 <tr><td>
2599 2601 <a href="/help/incoming">
2600 2602 incoming
2601 2603 </a>
2602 2604 </td><td>
2603 2605 show new changesets found in source
2604 2606 </td></tr>
2605 2607 <tr><td>
2606 2608 <a href="/help/manifest">
2607 2609 manifest
2608 2610 </a>
2609 2611 </td><td>
2610 2612 output the current or given revision of the project manifest
2611 2613 </td></tr>
2612 2614 <tr><td>
2613 2615 <a href="/help/nohelp">
2614 2616 nohelp
2615 2617 </a>
2616 2618 </td><td>
2617 2619 (no help text available)
2618 2620 </td></tr>
2619 2621 <tr><td>
2620 2622 <a href="/help/outgoing">
2621 2623 outgoing
2622 2624 </a>
2623 2625 </td><td>
2624 2626 show changesets not found in the destination
2625 2627 </td></tr>
2626 2628 <tr><td>
2627 2629 <a href="/help/paths">
2628 2630 paths
2629 2631 </a>
2630 2632 </td><td>
2631 2633 show aliases for remote repositories
2632 2634 </td></tr>
2633 2635 <tr><td>
2634 2636 <a href="/help/phase">
2635 2637 phase
2636 2638 </a>
2637 2639 </td><td>
2638 2640 set or show the current phase name
2639 2641 </td></tr>
2640 2642 <tr><td>
2641 2643 <a href="/help/recover">
2642 2644 recover
2643 2645 </a>
2644 2646 </td><td>
2645 2647 roll back an interrupted transaction
2646 2648 </td></tr>
2647 2649 <tr><td>
2648 2650 <a href="/help/rename">
2649 2651 rename
2650 2652 </a>
2651 2653 </td><td>
2652 2654 rename files; equivalent of copy + remove
2653 2655 </td></tr>
2654 2656 <tr><td>
2655 2657 <a href="/help/resolve">
2656 2658 resolve
2657 2659 </a>
2658 2660 </td><td>
2659 2661 redo merges or set/view the merge status of files
2660 2662 </td></tr>
2661 2663 <tr><td>
2662 2664 <a href="/help/revert">
2663 2665 revert
2664 2666 </a>
2665 2667 </td><td>
2666 2668 restore files to their checkout state
2667 2669 </td></tr>
2668 2670 <tr><td>
2669 2671 <a href="/help/root">
2670 2672 root
2671 2673 </a>
2672 2674 </td><td>
2673 2675 print the root (top) of the current working directory
2674 2676 </td></tr>
2675 2677 <tr><td>
2676 2678 <a href="/help/shellalias">
2677 2679 shellalias
2678 2680 </a>
2679 2681 </td><td>
2680 2682 (no help text available)
2681 2683 </td></tr>
2682 2684 <tr><td>
2683 2685 <a href="/help/tag">
2684 2686 tag
2685 2687 </a>
2686 2688 </td><td>
2687 2689 add one or more tags for the current or given revision
2688 2690 </td></tr>
2689 2691 <tr><td>
2690 2692 <a href="/help/tags">
2691 2693 tags
2692 2694 </a>
2693 2695 </td><td>
2694 2696 list repository tags
2695 2697 </td></tr>
2696 2698 <tr><td>
2697 2699 <a href="/help/unbundle">
2698 2700 unbundle
2699 2701 </a>
2700 2702 </td><td>
2701 2703 apply one or more bundle files
2702 2704 </td></tr>
2703 2705 <tr><td>
2704 2706 <a href="/help/verify">
2705 2707 verify
2706 2708 </a>
2707 2709 </td><td>
2708 2710 verify the integrity of the repository
2709 2711 </td></tr>
2710 2712 <tr><td>
2711 2713 <a href="/help/version">
2712 2714 version
2713 2715 </a>
2714 2716 </td><td>
2715 2717 output version and copyright information
2716 2718 </td></tr>
2717 2719
2718 2720
2719 2721 </table>
2720 2722 </div>
2721 2723 </div>
2722 2724
2723 2725
2724 2726
2725 2727 </body>
2726 2728 </html>
2727 2729
2728 2730
2729 2731 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2730 2732 200 Script output follows
2731 2733
2732 2734 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2733 2735 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2734 2736 <head>
2735 2737 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2736 2738 <meta name="robots" content="index, nofollow" />
2737 2739 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2738 2740 <script type="text/javascript" src="/static/mercurial.js"></script>
2739 2741
2740 2742 <title>Help: add</title>
2741 2743 </head>
2742 2744 <body>
2743 2745
2744 2746 <div class="container">
2745 2747 <div class="menu">
2746 2748 <div class="logo">
2747 2749 <a href="https://mercurial-scm.org/">
2748 2750 <img src="/static/hglogo.png" alt="mercurial" /></a>
2749 2751 </div>
2750 2752 <ul>
2751 2753 <li><a href="/shortlog">log</a></li>
2752 2754 <li><a href="/graph">graph</a></li>
2753 2755 <li><a href="/tags">tags</a></li>
2754 2756 <li><a href="/bookmarks">bookmarks</a></li>
2755 2757 <li><a href="/branches">branches</a></li>
2756 2758 </ul>
2757 2759 <ul>
2758 2760 <li class="active"><a href="/help">help</a></li>
2759 2761 </ul>
2760 2762 </div>
2761 2763
2762 2764 <div class="main">
2763 2765 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2764 2766 <h3>Help: add</h3>
2765 2767
2766 2768 <form class="search" action="/log">
2767 2769
2768 2770 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2769 2771 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2770 2772 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2771 2773 </form>
2772 2774 <div id="doc">
2773 2775 <p>
2774 2776 hg add [OPTION]... [FILE]...
2775 2777 </p>
2776 2778 <p>
2777 2779 add the specified files on the next commit
2778 2780 </p>
2779 2781 <p>
2780 2782 Schedule files to be version controlled and added to the
2781 2783 repository.
2782 2784 </p>
2783 2785 <p>
2784 2786 The files will be added to the repository at the next commit. To
2785 2787 undo an add before that, see 'hg forget'.
2786 2788 </p>
2787 2789 <p>
2788 2790 If no names are given, add all files to the repository (except
2789 2791 files matching &quot;.hgignore&quot;).
2790 2792 </p>
2791 2793 <p>
2792 2794 Examples:
2793 2795 </p>
2794 2796 <ul>
2795 2797 <li> New (unknown) files are added automatically by 'hg add':
2796 2798 <pre>
2797 2799 \$ ls (re)
2798 2800 foo.c
2799 2801 \$ hg status (re)
2800 2802 ? foo.c
2801 2803 \$ hg add (re)
2802 2804 adding foo.c
2803 2805 \$ hg status (re)
2804 2806 A foo.c
2805 2807 </pre>
2806 2808 <li> Specific files to be added can be specified:
2807 2809 <pre>
2808 2810 \$ ls (re)
2809 2811 bar.c foo.c
2810 2812 \$ hg status (re)
2811 2813 ? bar.c
2812 2814 ? foo.c
2813 2815 \$ hg add bar.c (re)
2814 2816 \$ hg status (re)
2815 2817 A bar.c
2816 2818 ? foo.c
2817 2819 </pre>
2818 2820 </ul>
2819 2821 <p>
2820 2822 Returns 0 if all files are successfully added.
2821 2823 </p>
2822 2824 <p>
2823 2825 options ([+] can be repeated):
2824 2826 </p>
2825 2827 <table>
2826 2828 <tr><td>-I</td>
2827 2829 <td>--include PATTERN [+]</td>
2828 2830 <td>include names matching the given patterns</td></tr>
2829 2831 <tr><td>-X</td>
2830 2832 <td>--exclude PATTERN [+]</td>
2831 2833 <td>exclude names matching the given patterns</td></tr>
2832 2834 <tr><td>-S</td>
2833 2835 <td>--subrepos</td>
2834 2836 <td>recurse into subrepositories</td></tr>
2835 2837 <tr><td>-n</td>
2836 2838 <td>--dry-run</td>
2837 2839 <td>do not perform actions, just print output</td></tr>
2838 2840 </table>
2839 2841 <p>
2840 2842 global options ([+] can be repeated):
2841 2843 </p>
2842 2844 <table>
2843 2845 <tr><td>-R</td>
2844 2846 <td>--repository REPO</td>
2845 2847 <td>repository root directory or name of overlay bundle file</td></tr>
2846 2848 <tr><td></td>
2847 2849 <td>--cwd DIR</td>
2848 2850 <td>change working directory</td></tr>
2849 2851 <tr><td>-y</td>
2850 2852 <td>--noninteractive</td>
2851 2853 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2852 2854 <tr><td>-q</td>
2853 2855 <td>--quiet</td>
2854 2856 <td>suppress output</td></tr>
2855 2857 <tr><td>-v</td>
2856 2858 <td>--verbose</td>
2857 2859 <td>enable additional output</td></tr>
2858 2860 <tr><td></td>
2859 2861 <td>--color TYPE</td>
2860 2862 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2861 2863 <tr><td></td>
2862 2864 <td>--config CONFIG [+]</td>
2863 2865 <td>set/override config option (use 'section.name=value')</td></tr>
2864 2866 <tr><td></td>
2865 2867 <td>--debug</td>
2866 2868 <td>enable debugging output</td></tr>
2867 2869 <tr><td></td>
2868 2870 <td>--debugger</td>
2869 2871 <td>start debugger</td></tr>
2870 2872 <tr><td></td>
2871 2873 <td>--encoding ENCODE</td>
2872 2874 <td>set the charset encoding (default: ascii)</td></tr>
2873 2875 <tr><td></td>
2874 2876 <td>--encodingmode MODE</td>
2875 2877 <td>set the charset encoding mode (default: strict)</td></tr>
2876 2878 <tr><td></td>
2877 2879 <td>--traceback</td>
2878 2880 <td>always print a traceback on exception</td></tr>
2879 2881 <tr><td></td>
2880 2882 <td>--time</td>
2881 2883 <td>time how long the command takes</td></tr>
2882 2884 <tr><td></td>
2883 2885 <td>--profile</td>
2884 2886 <td>print command execution profile</td></tr>
2885 2887 <tr><td></td>
2886 2888 <td>--version</td>
2887 2889 <td>output version information and exit</td></tr>
2888 2890 <tr><td>-h</td>
2889 2891 <td>--help</td>
2890 2892 <td>display help and exit</td></tr>
2891 2893 <tr><td></td>
2892 2894 <td>--hidden</td>
2893 2895 <td>consider hidden changesets</td></tr>
2894 2896 <tr><td></td>
2895 2897 <td>--pager TYPE</td>
2896 2898 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2897 2899 </table>
2898 2900
2899 2901 </div>
2900 2902 </div>
2901 2903 </div>
2902 2904
2903 2905
2904 2906
2905 2907 </body>
2906 2908 </html>
2907 2909
2908 2910
2909 2911 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2910 2912 200 Script output follows
2911 2913
2912 2914 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2913 2915 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2914 2916 <head>
2915 2917 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2916 2918 <meta name="robots" content="index, nofollow" />
2917 2919 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2918 2920 <script type="text/javascript" src="/static/mercurial.js"></script>
2919 2921
2920 2922 <title>Help: remove</title>
2921 2923 </head>
2922 2924 <body>
2923 2925
2924 2926 <div class="container">
2925 2927 <div class="menu">
2926 2928 <div class="logo">
2927 2929 <a href="https://mercurial-scm.org/">
2928 2930 <img src="/static/hglogo.png" alt="mercurial" /></a>
2929 2931 </div>
2930 2932 <ul>
2931 2933 <li><a href="/shortlog">log</a></li>
2932 2934 <li><a href="/graph">graph</a></li>
2933 2935 <li><a href="/tags">tags</a></li>
2934 2936 <li><a href="/bookmarks">bookmarks</a></li>
2935 2937 <li><a href="/branches">branches</a></li>
2936 2938 </ul>
2937 2939 <ul>
2938 2940 <li class="active"><a href="/help">help</a></li>
2939 2941 </ul>
2940 2942 </div>
2941 2943
2942 2944 <div class="main">
2943 2945 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2944 2946 <h3>Help: remove</h3>
2945 2947
2946 2948 <form class="search" action="/log">
2947 2949
2948 2950 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2949 2951 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2950 2952 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2951 2953 </form>
2952 2954 <div id="doc">
2953 2955 <p>
2954 2956 hg remove [OPTION]... FILE...
2955 2957 </p>
2956 2958 <p>
2957 2959 aliases: rm
2958 2960 </p>
2959 2961 <p>
2960 2962 remove the specified files on the next commit
2961 2963 </p>
2962 2964 <p>
2963 2965 Schedule the indicated files for removal from the current branch.
2964 2966 </p>
2965 2967 <p>
2966 2968 This command schedules the files to be removed at the next commit.
2967 2969 To undo a remove before that, see 'hg revert'. To undo added
2968 2970 files, see 'hg forget'.
2969 2971 </p>
2970 2972 <p>
2971 2973 -A/--after can be used to remove only files that have already
2972 2974 been deleted, -f/--force can be used to force deletion, and -Af
2973 2975 can be used to remove files from the next revision without
2974 2976 deleting them from the working directory.
2975 2977 </p>
2976 2978 <p>
2977 2979 The following table details the behavior of remove for different
2978 2980 file states (columns) and option combinations (rows). The file
2979 2981 states are Added [A], Clean [C], Modified [M] and Missing [!]
2980 2982 (as reported by 'hg status'). The actions are Warn, Remove
2981 2983 (from branch) and Delete (from disk):
2982 2984 </p>
2983 2985 <table>
2984 2986 <tr><td>opt/state</td>
2985 2987 <td>A</td>
2986 2988 <td>C</td>
2987 2989 <td>M</td>
2988 2990 <td>!</td></tr>
2989 2991 <tr><td>none</td>
2990 2992 <td>W</td>
2991 2993 <td>RD</td>
2992 2994 <td>W</td>
2993 2995 <td>R</td></tr>
2994 2996 <tr><td>-f</td>
2995 2997 <td>R</td>
2996 2998 <td>RD</td>
2997 2999 <td>RD</td>
2998 3000 <td>R</td></tr>
2999 3001 <tr><td>-A</td>
3000 3002 <td>W</td>
3001 3003 <td>W</td>
3002 3004 <td>W</td>
3003 3005 <td>R</td></tr>
3004 3006 <tr><td>-Af</td>
3005 3007 <td>R</td>
3006 3008 <td>R</td>
3007 3009 <td>R</td>
3008 3010 <td>R</td></tr>
3009 3011 </table>
3010 3012 <p>
3011 3013 <b>Note:</b>
3012 3014 </p>
3013 3015 <p>
3014 3016 'hg remove' never deletes files in Added [A] state from the
3015 3017 working directory, not even if &quot;--force&quot; is specified.
3016 3018 </p>
3017 3019 <p>
3018 3020 Returns 0 on success, 1 if any warnings encountered.
3019 3021 </p>
3020 3022 <p>
3021 3023 options ([+] can be repeated):
3022 3024 </p>
3023 3025 <table>
3024 3026 <tr><td>-A</td>
3025 3027 <td>--after</td>
3026 3028 <td>record delete for missing files</td></tr>
3027 3029 <tr><td>-f</td>
3028 3030 <td>--force</td>
3029 3031 <td>forget added files, delete modified files</td></tr>
3030 3032 <tr><td>-S</td>
3031 3033 <td>--subrepos</td>
3032 3034 <td>recurse into subrepositories</td></tr>
3033 3035 <tr><td>-I</td>
3034 3036 <td>--include PATTERN [+]</td>
3035 3037 <td>include names matching the given patterns</td></tr>
3036 3038 <tr><td>-X</td>
3037 3039 <td>--exclude PATTERN [+]</td>
3038 3040 <td>exclude names matching the given patterns</td></tr>
3039 3041 <tr><td>-n</td>
3040 3042 <td>--dry-run</td>
3041 3043 <td>do not perform actions, just print output</td></tr>
3042 3044 </table>
3043 3045 <p>
3044 3046 global options ([+] can be repeated):
3045 3047 </p>
3046 3048 <table>
3047 3049 <tr><td>-R</td>
3048 3050 <td>--repository REPO</td>
3049 3051 <td>repository root directory or name of overlay bundle file</td></tr>
3050 3052 <tr><td></td>
3051 3053 <td>--cwd DIR</td>
3052 3054 <td>change working directory</td></tr>
3053 3055 <tr><td>-y</td>
3054 3056 <td>--noninteractive</td>
3055 3057 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3056 3058 <tr><td>-q</td>
3057 3059 <td>--quiet</td>
3058 3060 <td>suppress output</td></tr>
3059 3061 <tr><td>-v</td>
3060 3062 <td>--verbose</td>
3061 3063 <td>enable additional output</td></tr>
3062 3064 <tr><td></td>
3063 3065 <td>--color TYPE</td>
3064 3066 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3065 3067 <tr><td></td>
3066 3068 <td>--config CONFIG [+]</td>
3067 3069 <td>set/override config option (use 'section.name=value')</td></tr>
3068 3070 <tr><td></td>
3069 3071 <td>--debug</td>
3070 3072 <td>enable debugging output</td></tr>
3071 3073 <tr><td></td>
3072 3074 <td>--debugger</td>
3073 3075 <td>start debugger</td></tr>
3074 3076 <tr><td></td>
3075 3077 <td>--encoding ENCODE</td>
3076 3078 <td>set the charset encoding (default: ascii)</td></tr>
3077 3079 <tr><td></td>
3078 3080 <td>--encodingmode MODE</td>
3079 3081 <td>set the charset encoding mode (default: strict)</td></tr>
3080 3082 <tr><td></td>
3081 3083 <td>--traceback</td>
3082 3084 <td>always print a traceback on exception</td></tr>
3083 3085 <tr><td></td>
3084 3086 <td>--time</td>
3085 3087 <td>time how long the command takes</td></tr>
3086 3088 <tr><td></td>
3087 3089 <td>--profile</td>
3088 3090 <td>print command execution profile</td></tr>
3089 3091 <tr><td></td>
3090 3092 <td>--version</td>
3091 3093 <td>output version information and exit</td></tr>
3092 3094 <tr><td>-h</td>
3093 3095 <td>--help</td>
3094 3096 <td>display help and exit</td></tr>
3095 3097 <tr><td></td>
3096 3098 <td>--hidden</td>
3097 3099 <td>consider hidden changesets</td></tr>
3098 3100 <tr><td></td>
3099 3101 <td>--pager TYPE</td>
3100 3102 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3101 3103 </table>
3102 3104
3103 3105 </div>
3104 3106 </div>
3105 3107 </div>
3106 3108
3107 3109
3108 3110
3109 3111 </body>
3110 3112 </html>
3111 3113
3112 3114
3113 3115 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3114 3116 200 Script output follows
3115 3117
3116 3118 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3117 3119 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3118 3120 <head>
3119 3121 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3120 3122 <meta name="robots" content="index, nofollow" />
3121 3123 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3122 3124 <script type="text/javascript" src="/static/mercurial.js"></script>
3123 3125
3124 3126 <title>Help: dates</title>
3125 3127 </head>
3126 3128 <body>
3127 3129
3128 3130 <div class="container">
3129 3131 <div class="menu">
3130 3132 <div class="logo">
3131 3133 <a href="https://mercurial-scm.org/">
3132 3134 <img src="/static/hglogo.png" alt="mercurial" /></a>
3133 3135 </div>
3134 3136 <ul>
3135 3137 <li><a href="/shortlog">log</a></li>
3136 3138 <li><a href="/graph">graph</a></li>
3137 3139 <li><a href="/tags">tags</a></li>
3138 3140 <li><a href="/bookmarks">bookmarks</a></li>
3139 3141 <li><a href="/branches">branches</a></li>
3140 3142 </ul>
3141 3143 <ul>
3142 3144 <li class="active"><a href="/help">help</a></li>
3143 3145 </ul>
3144 3146 </div>
3145 3147
3146 3148 <div class="main">
3147 3149 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3148 3150 <h3>Help: dates</h3>
3149 3151
3150 3152 <form class="search" action="/log">
3151 3153
3152 3154 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3153 3155 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3154 3156 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3155 3157 </form>
3156 3158 <div id="doc">
3157 3159 <h1>Date Formats</h1>
3158 3160 <p>
3159 3161 Some commands allow the user to specify a date, e.g.:
3160 3162 </p>
3161 3163 <ul>
3162 3164 <li> backout, commit, import, tag: Specify the commit date.
3163 3165 <li> log, revert, update: Select revision(s) by date.
3164 3166 </ul>
3165 3167 <p>
3166 3168 Many date formats are valid. Here are some examples:
3167 3169 </p>
3168 3170 <ul>
3169 3171 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3170 3172 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3171 3173 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3172 3174 <li> &quot;Dec 6&quot; (midnight)
3173 3175 <li> &quot;13:18&quot; (today assumed)
3174 3176 <li> &quot;3:39&quot; (3:39AM assumed)
3175 3177 <li> &quot;3:39pm&quot; (15:39)
3176 3178 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3177 3179 <li> &quot;2006-12-6 13:18&quot;
3178 3180 <li> &quot;2006-12-6&quot;
3179 3181 <li> &quot;12-6&quot;
3180 3182 <li> &quot;12/6&quot;
3181 3183 <li> &quot;12/6/6&quot; (Dec 6 2006)
3182 3184 <li> &quot;today&quot; (midnight)
3183 3185 <li> &quot;yesterday&quot; (midnight)
3184 3186 <li> &quot;now&quot; - right now
3185 3187 </ul>
3186 3188 <p>
3187 3189 Lastly, there is Mercurial's internal format:
3188 3190 </p>
3189 3191 <ul>
3190 3192 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3191 3193 </ul>
3192 3194 <p>
3193 3195 This is the internal representation format for dates. The first number
3194 3196 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3195 3197 second is the offset of the local timezone, in seconds west of UTC
3196 3198 (negative if the timezone is east of UTC).
3197 3199 </p>
3198 3200 <p>
3199 3201 The log command also accepts date ranges:
3200 3202 </p>
3201 3203 <ul>
3202 3204 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3203 3205 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3204 3206 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3205 3207 <li> &quot;-DAYS&quot; - within a given number of days of today
3206 3208 </ul>
3207 3209
3208 3210 </div>
3209 3211 </div>
3210 3212 </div>
3211 3213
3212 3214
3213 3215
3214 3216 </body>
3215 3217 </html>
3216 3218
3217 3219
3218 3220 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3219 3221 200 Script output follows
3220 3222
3221 3223 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3222 3224 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3223 3225 <head>
3224 3226 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3225 3227 <meta name="robots" content="index, nofollow" />
3226 3228 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3227 3229 <script type="text/javascript" src="/static/mercurial.js"></script>
3228 3230
3229 3231 <title>Help: pager</title>
3230 3232 </head>
3231 3233 <body>
3232 3234
3233 3235 <div class="container">
3234 3236 <div class="menu">
3235 3237 <div class="logo">
3236 3238 <a href="https://mercurial-scm.org/">
3237 3239 <img src="/static/hglogo.png" alt="mercurial" /></a>
3238 3240 </div>
3239 3241 <ul>
3240 3242 <li><a href="/shortlog">log</a></li>
3241 3243 <li><a href="/graph">graph</a></li>
3242 3244 <li><a href="/tags">tags</a></li>
3243 3245 <li><a href="/bookmarks">bookmarks</a></li>
3244 3246 <li><a href="/branches">branches</a></li>
3245 3247 </ul>
3246 3248 <ul>
3247 3249 <li class="active"><a href="/help">help</a></li>
3248 3250 </ul>
3249 3251 </div>
3250 3252
3251 3253 <div class="main">
3252 3254 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3253 3255 <h3>Help: pager</h3>
3254 3256
3255 3257 <form class="search" action="/log">
3256 3258
3257 3259 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3258 3260 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3259 3261 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3260 3262 </form>
3261 3263 <div id="doc">
3262 3264 <h1>Pager Support</h1>
3263 3265 <p>
3264 3266 Some Mercurial commands can produce a lot of output, and Mercurial will
3265 3267 attempt to use a pager to make those commands more pleasant.
3266 3268 </p>
3267 3269 <p>
3268 3270 To set the pager that should be used, set the application variable:
3269 3271 </p>
3270 3272 <pre>
3271 3273 [pager]
3272 3274 pager = less -FRX
3273 3275 </pre>
3274 3276 <p>
3275 3277 If no pager is set in the user or repository configuration, Mercurial uses the
3276 3278 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3277 3279 or system configuration is used. If none of these are set, a default pager will
3278 3280 be used, typically 'less' on Unix and 'more' on Windows.
3279 3281 </p>
3280 3282 <p>
3281 3283 You can disable the pager for certain commands by adding them to the
3282 3284 pager.ignore list:
3283 3285 </p>
3284 3286 <pre>
3285 3287 [pager]
3286 3288 ignore = version, help, update
3287 3289 </pre>
3288 3290 <p>
3289 3291 To ignore global commands like 'hg version' or 'hg help', you have
3290 3292 to specify them in your user configuration file.
3291 3293 </p>
3292 3294 <p>
3293 3295 To control whether the pager is used at all for an individual command,
3294 3296 you can use --pager=&lt;value&gt;:
3295 3297 </p>
3296 3298 <ul>
3297 3299 <li> use as needed: 'auto'.
3298 3300 <li> require the pager: 'yes' or 'on'.
3299 3301 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3300 3302 </ul>
3301 3303 <p>
3302 3304 To globally turn off all attempts to use a pager, set:
3303 3305 </p>
3304 3306 <pre>
3305 3307 [ui]
3306 3308 paginate = never
3307 3309 </pre>
3308 3310 <p>
3309 3311 which will prevent the pager from running.
3310 3312 </p>
3311 3313
3312 3314 </div>
3313 3315 </div>
3314 3316 </div>
3315 3317
3316 3318
3317 3319
3318 3320 </body>
3319 3321 </html>
3320 3322
3321 3323
3322 3324 Sub-topic indexes rendered properly
3323 3325
3324 3326 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3325 3327 200 Script output follows
3326 3328
3327 3329 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3328 3330 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3329 3331 <head>
3330 3332 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3331 3333 <meta name="robots" content="index, nofollow" />
3332 3334 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3333 3335 <script type="text/javascript" src="/static/mercurial.js"></script>
3334 3336
3335 3337 <title>Help: internals</title>
3336 3338 </head>
3337 3339 <body>
3338 3340
3339 3341 <div class="container">
3340 3342 <div class="menu">
3341 3343 <div class="logo">
3342 3344 <a href="https://mercurial-scm.org/">
3343 3345 <img src="/static/hglogo.png" alt="mercurial" /></a>
3344 3346 </div>
3345 3347 <ul>
3346 3348 <li><a href="/shortlog">log</a></li>
3347 3349 <li><a href="/graph">graph</a></li>
3348 3350 <li><a href="/tags">tags</a></li>
3349 3351 <li><a href="/bookmarks">bookmarks</a></li>
3350 3352 <li><a href="/branches">branches</a></li>
3351 3353 </ul>
3352 3354 <ul>
3353 3355 <li><a href="/help">help</a></li>
3354 3356 </ul>
3355 3357 </div>
3356 3358
3357 3359 <div class="main">
3358 3360 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3359 3361
3360 3362 <form class="search" action="/log">
3361 3363
3362 3364 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3363 3365 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3364 3366 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3365 3367 </form>
3366 3368 <table class="bigtable">
3367 3369 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3368 3370
3369 3371 <tr><td>
3370 3372 <a href="/help/internals.bundle2">
3371 3373 bundle2
3372 3374 </a>
3373 3375 </td><td>
3374 3376 Bundle2
3375 3377 </td></tr>
3376 3378 <tr><td>
3377 3379 <a href="/help/internals.bundles">
3378 3380 bundles
3379 3381 </a>
3380 3382 </td><td>
3381 3383 Bundles
3382 3384 </td></tr>
3383 3385 <tr><td>
3384 3386 <a href="/help/internals.cbor">
3385 3387 cbor
3386 3388 </a>
3387 3389 </td><td>
3388 3390 CBOR
3389 3391 </td></tr>
3390 3392 <tr><td>
3391 3393 <a href="/help/internals.censor">
3392 3394 censor
3393 3395 </a>
3394 3396 </td><td>
3395 3397 Censor
3396 3398 </td></tr>
3397 3399 <tr><td>
3398 3400 <a href="/help/internals.changegroups">
3399 3401 changegroups
3400 3402 </a>
3401 3403 </td><td>
3402 3404 Changegroups
3403 3405 </td></tr>
3404 3406 <tr><td>
3405 3407 <a href="/help/internals.config">
3406 3408 config
3407 3409 </a>
3408 3410 </td><td>
3409 3411 Config Registrar
3410 3412 </td></tr>
3411 3413 <tr><td>
3412 3414 <a href="/help/internals.extensions">
3413 3415 extensions
3414 3416 </a>
3415 3417 </td><td>
3416 3418 Extension API
3417 3419 </td></tr>
3418 3420 <tr><td>
3419 3421 <a href="/help/internals.requirements">
3420 3422 requirements
3421 3423 </a>
3422 3424 </td><td>
3423 3425 Repository Requirements
3424 3426 </td></tr>
3425 3427 <tr><td>
3426 3428 <a href="/help/internals.revlogs">
3427 3429 revlogs
3428 3430 </a>
3429 3431 </td><td>
3430 3432 Revision Logs
3431 3433 </td></tr>
3432 3434 <tr><td>
3433 3435 <a href="/help/internals.wireprotocol">
3434 3436 wireprotocol
3435 3437 </a>
3436 3438 </td><td>
3437 3439 Wire Protocol
3438 3440 </td></tr>
3439 3441 <tr><td>
3440 3442 <a href="/help/internals.wireprotocolrpc">
3441 3443 wireprotocolrpc
3442 3444 </a>
3443 3445 </td><td>
3444 3446 Wire Protocol RPC
3445 3447 </td></tr>
3446 3448 <tr><td>
3447 3449 <a href="/help/internals.wireprotocolv2">
3448 3450 wireprotocolv2
3449 3451 </a>
3450 3452 </td><td>
3451 3453 Wire Protocol Version 2
3452 3454 </td></tr>
3453 3455
3454 3456
3455 3457
3456 3458
3457 3459
3458 3460 </table>
3459 3461 </div>
3460 3462 </div>
3461 3463
3462 3464
3463 3465
3464 3466 </body>
3465 3467 </html>
3466 3468
3467 3469
3468 3470 Sub-topic topics rendered properly
3469 3471
3470 3472 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3471 3473 200 Script output follows
3472 3474
3473 3475 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3474 3476 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3475 3477 <head>
3476 3478 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3477 3479 <meta name="robots" content="index, nofollow" />
3478 3480 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3479 3481 <script type="text/javascript" src="/static/mercurial.js"></script>
3480 3482
3481 3483 <title>Help: internals.changegroups</title>
3482 3484 </head>
3483 3485 <body>
3484 3486
3485 3487 <div class="container">
3486 3488 <div class="menu">
3487 3489 <div class="logo">
3488 3490 <a href="https://mercurial-scm.org/">
3489 3491 <img src="/static/hglogo.png" alt="mercurial" /></a>
3490 3492 </div>
3491 3493 <ul>
3492 3494 <li><a href="/shortlog">log</a></li>
3493 3495 <li><a href="/graph">graph</a></li>
3494 3496 <li><a href="/tags">tags</a></li>
3495 3497 <li><a href="/bookmarks">bookmarks</a></li>
3496 3498 <li><a href="/branches">branches</a></li>
3497 3499 </ul>
3498 3500 <ul>
3499 3501 <li class="active"><a href="/help">help</a></li>
3500 3502 </ul>
3501 3503 </div>
3502 3504
3503 3505 <div class="main">
3504 3506 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3505 3507 <h3>Help: internals.changegroups</h3>
3506 3508
3507 3509 <form class="search" action="/log">
3508 3510
3509 3511 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3510 3512 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3511 3513 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3512 3514 </form>
3513 3515 <div id="doc">
3514 3516 <h1>Changegroups</h1>
3515 3517 <p>
3516 3518 Changegroups are representations of repository revlog data, specifically
3517 3519 the changelog data, root/flat manifest data, treemanifest data, and
3518 3520 filelogs.
3519 3521 </p>
3520 3522 <p>
3521 3523 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3522 3524 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3523 3525 only difference being an additional item in the *delta header*. Version
3524 3526 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3525 3527 exchanging treemanifests (enabled by setting an option on the
3526 3528 &quot;changegroup&quot; part in the bundle2).
3527 3529 </p>
3528 3530 <p>
3529 3531 Changegroups when not exchanging treemanifests consist of 3 logical
3530 3532 segments:
3531 3533 </p>
3532 3534 <pre>
3533 3535 +---------------------------------+
3534 3536 | | | |
3535 3537 | changeset | manifest | filelogs |
3536 3538 | | | |
3537 3539 | | | |
3538 3540 +---------------------------------+
3539 3541 </pre>
3540 3542 <p>
3541 3543 When exchanging treemanifests, there are 4 logical segments:
3542 3544 </p>
3543 3545 <pre>
3544 3546 +-------------------------------------------------+
3545 3547 | | | | |
3546 3548 | changeset | root | treemanifests | filelogs |
3547 3549 | | manifest | | |
3548 3550 | | | | |
3549 3551 +-------------------------------------------------+
3550 3552 </pre>
3551 3553 <p>
3552 3554 The principle building block of each segment is a *chunk*. A *chunk*
3553 3555 is a framed piece of data:
3554 3556 </p>
3555 3557 <pre>
3556 3558 +---------------------------------------+
3557 3559 | | |
3558 3560 | length | data |
3559 3561 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3560 3562 | | |
3561 3563 +---------------------------------------+
3562 3564 </pre>
3563 3565 <p>
3564 3566 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3565 3567 integer indicating the length of the entire chunk (including the length field
3566 3568 itself).
3567 3569 </p>
3568 3570 <p>
3569 3571 There is a special case chunk that has a value of 0 for the length
3570 3572 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3571 3573 </p>
3572 3574 <h2>Delta Groups</h2>
3573 3575 <p>
3574 3576 A *delta group* expresses the content of a revlog as a series of deltas,
3575 3577 or patches against previous revisions.
3576 3578 </p>
3577 3579 <p>
3578 3580 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3579 3581 to signal the end of the delta group:
3580 3582 </p>
3581 3583 <pre>
3582 3584 +------------------------------------------------------------------------+
3583 3585 | | | | | |
3584 3586 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3585 3587 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3586 3588 | | | | | |
3587 3589 +------------------------------------------------------------------------+
3588 3590 </pre>
3589 3591 <p>
3590 3592 Each *chunk*'s data consists of the following:
3591 3593 </p>
3592 3594 <pre>
3593 3595 +---------------------------------------+
3594 3596 | | |
3595 3597 | delta header | delta data |
3596 3598 | (various by version) | (various) |
3597 3599 | | |
3598 3600 +---------------------------------------+
3599 3601 </pre>
3600 3602 <p>
3601 3603 The *delta data* is a series of *delta*s that describe a diff from an existing
3602 3604 entry (either that the recipient already has, or previously specified in the
3603 3605 bundle/changegroup).
3604 3606 </p>
3605 3607 <p>
3606 3608 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3607 3609 &quot;3&quot; of the changegroup format.
3608 3610 </p>
3609 3611 <p>
3610 3612 Version 1 (headerlen=80):
3611 3613 </p>
3612 3614 <pre>
3613 3615 +------------------------------------------------------+
3614 3616 | | | | |
3615 3617 | node | p1 node | p2 node | link node |
3616 3618 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3617 3619 | | | | |
3618 3620 +------------------------------------------------------+
3619 3621 </pre>
3620 3622 <p>
3621 3623 Version 2 (headerlen=100):
3622 3624 </p>
3623 3625 <pre>
3624 3626 +------------------------------------------------------------------+
3625 3627 | | | | | |
3626 3628 | node | p1 node | p2 node | base node | link node |
3627 3629 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3628 3630 | | | | | |
3629 3631 +------------------------------------------------------------------+
3630 3632 </pre>
3631 3633 <p>
3632 3634 Version 3 (headerlen=102):
3633 3635 </p>
3634 3636 <pre>
3635 3637 +------------------------------------------------------------------------------+
3636 3638 | | | | | | |
3637 3639 | node | p1 node | p2 node | base node | link node | flags |
3638 3640 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3639 3641 | | | | | | |
3640 3642 +------------------------------------------------------------------------------+
3641 3643 </pre>
3642 3644 <p>
3643 3645 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3644 3646 series of *delta*s, densely packed (no separators). These deltas describe a diff
3645 3647 from an existing entry (either that the recipient already has, or previously
3646 3648 specified in the bundle/changegroup). The format is described more fully in
3647 3649 &quot;hg help internals.bdiff&quot;, but briefly:
3648 3650 </p>
3649 3651 <pre>
3650 3652 +---------------------------------------------------------------+
3651 3653 | | | | |
3652 3654 | start offset | end offset | new length | content |
3653 3655 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3654 3656 | | | | |
3655 3657 +---------------------------------------------------------------+
3656 3658 </pre>
3657 3659 <p>
3658 3660 Please note that the length field in the delta data does *not* include itself.
3659 3661 </p>
3660 3662 <p>
3661 3663 In version 1, the delta is always applied against the previous node from
3662 3664 the changegroup or the first parent if this is the first entry in the
3663 3665 changegroup.
3664 3666 </p>
3665 3667 <p>
3666 3668 In version 2 and up, the delta base node is encoded in the entry in the
3667 3669 changegroup. This allows the delta to be expressed against any parent,
3668 3670 which can result in smaller deltas and more efficient encoding of data.
3669 3671 </p>
3670 3672 <p>
3671 3673 The *flags* field holds bitwise flags affecting the processing of revision
3672 3674 data. The following flags are defined:
3673 3675 </p>
3674 3676 <dl>
3675 3677 <dt>32768
3676 3678 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3677 3679 <dt>16384
3678 3680 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3679 3681 <dt>8192
3680 3682 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3681 3683 </dl>
3682 3684 <p>
3683 3685 For historical reasons, the integer values are identical to revlog version 1
3684 3686 per-revision storage flags and correspond to bits being set in this 2-byte
3685 3687 field. Bits were allocated starting from the most-significant bit, hence the
3686 3688 reverse ordering and allocation of these flags.
3687 3689 </p>
3688 3690 <h2>Changeset Segment</h2>
3689 3691 <p>
3690 3692 The *changeset segment* consists of a single *delta group* holding
3691 3693 changelog data. The *empty chunk* at the end of the *delta group* denotes
3692 3694 the boundary to the *manifest segment*.
3693 3695 </p>
3694 3696 <h2>Manifest Segment</h2>
3695 3697 <p>
3696 3698 The *manifest segment* consists of a single *delta group* holding manifest
3697 3699 data. If treemanifests are in use, it contains only the manifest for the
3698 3700 root directory of the repository. Otherwise, it contains the entire
3699 3701 manifest data. The *empty chunk* at the end of the *delta group* denotes
3700 3702 the boundary to the next segment (either the *treemanifests segment* or the
3701 3703 *filelogs segment*, depending on version and the request options).
3702 3704 </p>
3703 3705 <h3>Treemanifests Segment</h3>
3704 3706 <p>
3705 3707 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3706 3708 only if the 'treemanifest' param is part of the bundle2 changegroup part
3707 3709 (it is not possible to use changegroup version 3 outside of bundle2).
3708 3710 Aside from the filenames in the *treemanifests segment* containing a
3709 3711 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3710 3712 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3711 3713 a sub-segment with filename size 0). This denotes the boundary to the
3712 3714 *filelogs segment*.
3713 3715 </p>
3714 3716 <h2>Filelogs Segment</h2>
3715 3717 <p>
3716 3718 The *filelogs segment* consists of multiple sub-segments, each
3717 3719 corresponding to an individual file whose data is being described:
3718 3720 </p>
3719 3721 <pre>
3720 3722 +--------------------------------------------------+
3721 3723 | | | | | |
3722 3724 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3723 3725 | | | | | (4 bytes) |
3724 3726 | | | | | |
3725 3727 +--------------------------------------------------+
3726 3728 </pre>
3727 3729 <p>
3728 3730 The final filelog sub-segment is followed by an *empty chunk* (logically,
3729 3731 a sub-segment with filename size 0). This denotes the end of the segment
3730 3732 and of the overall changegroup.
3731 3733 </p>
3732 3734 <p>
3733 3735 Each filelog sub-segment consists of the following:
3734 3736 </p>
3735 3737 <pre>
3736 3738 +------------------------------------------------------+
3737 3739 | | | |
3738 3740 | filename length | filename | delta group |
3739 3741 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3740 3742 | | | |
3741 3743 +------------------------------------------------------+
3742 3744 </pre>
3743 3745 <p>
3744 3746 That is, a *chunk* consisting of the filename (not terminated or padded)
3745 3747 followed by N chunks constituting the *delta group* for this file. The
3746 3748 *empty chunk* at the end of each *delta group* denotes the boundary to the
3747 3749 next filelog sub-segment.
3748 3750 </p>
3749 3751
3750 3752 </div>
3751 3753 </div>
3752 3754 </div>
3753 3755
3754 3756
3755 3757
3756 3758 </body>
3757 3759 </html>
3758 3760
3759 3761
3760 3762 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3761 3763 404 Not Found
3762 3764
3763 3765 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3764 3766 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3765 3767 <head>
3766 3768 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3767 3769 <meta name="robots" content="index, nofollow" />
3768 3770 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3769 3771 <script type="text/javascript" src="/static/mercurial.js"></script>
3770 3772
3771 3773 <title>test: error</title>
3772 3774 </head>
3773 3775 <body>
3774 3776
3775 3777 <div class="container">
3776 3778 <div class="menu">
3777 3779 <div class="logo">
3778 3780 <a href="https://mercurial-scm.org/">
3779 3781 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3780 3782 </div>
3781 3783 <ul>
3782 3784 <li><a href="/shortlog">log</a></li>
3783 3785 <li><a href="/graph">graph</a></li>
3784 3786 <li><a href="/tags">tags</a></li>
3785 3787 <li><a href="/bookmarks">bookmarks</a></li>
3786 3788 <li><a href="/branches">branches</a></li>
3787 3789 </ul>
3788 3790 <ul>
3789 3791 <li><a href="/help">help</a></li>
3790 3792 </ul>
3791 3793 </div>
3792 3794
3793 3795 <div class="main">
3794 3796
3795 3797 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3796 3798 <h3>error</h3>
3797 3799
3798 3800
3799 3801 <form class="search" action="/log">
3800 3802
3801 3803 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3802 3804 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3803 3805 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3804 3806 </form>
3805 3807
3806 3808 <div class="description">
3807 3809 <p>
3808 3810 An error occurred while processing your request:
3809 3811 </p>
3810 3812 <p>
3811 3813 Not Found
3812 3814 </p>
3813 3815 </div>
3814 3816 </div>
3815 3817 </div>
3816 3818
3817 3819
3818 3820
3819 3821 </body>
3820 3822 </html>
3821 3823
3822 3824 [1]
3823 3825
3824 3826 $ killdaemons.py
3825 3827
3826 3828 #endif
General Comments 0
You need to be logged in to leave comments. Login now