##// END OF EJS Templates
config: rename `revlog` section into `storage`...
Boris Feld -
r38767:ae17555e @89 stable
parent child Browse files
Show More
@@ -1,1383 +1,1383 b''
1 1 # configitems.py - centralized declaration of configuration option
2 2 #
3 3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
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 functools
11 11 import re
12 12
13 13 from . import (
14 14 encoding,
15 15 error,
16 16 )
17 17
18 18 def loadconfigtable(ui, extname, configtable):
19 19 """update config item known to the ui with the extension ones"""
20 20 for section, items in sorted(configtable.items()):
21 21 knownitems = ui._knownconfig.setdefault(section, itemregister())
22 22 knownkeys = set(knownitems)
23 23 newkeys = set(items)
24 24 for key in sorted(knownkeys & newkeys):
25 25 msg = "extension '%s' overwrite config item '%s.%s'"
26 26 msg %= (extname, section, key)
27 27 ui.develwarn(msg, config='warn-config')
28 28
29 29 knownitems.update(items)
30 30
31 31 class configitem(object):
32 32 """represent a known config item
33 33
34 34 :section: the official config section where to find this item,
35 35 :name: the official name within the section,
36 36 :default: default value for this item,
37 37 :alias: optional list of tuples as alternatives,
38 38 :generic: this is a generic definition, match name using regular expression.
39 39 """
40 40
41 41 def __init__(self, section, name, default=None, alias=(),
42 42 generic=False, priority=0):
43 43 self.section = section
44 44 self.name = name
45 45 self.default = default
46 46 self.alias = list(alias)
47 47 self.generic = generic
48 48 self.priority = priority
49 49 self._re = None
50 50 if generic:
51 51 self._re = re.compile(self.name)
52 52
53 53 class itemregister(dict):
54 54 """A specialized dictionary that can handle wild-card selection"""
55 55
56 56 def __init__(self):
57 57 super(itemregister, self).__init__()
58 58 self._generics = set()
59 59
60 60 def update(self, other):
61 61 super(itemregister, self).update(other)
62 62 self._generics.update(other._generics)
63 63
64 64 def __setitem__(self, key, item):
65 65 super(itemregister, self).__setitem__(key, item)
66 66 if item.generic:
67 67 self._generics.add(item)
68 68
69 69 def get(self, key):
70 70 baseitem = super(itemregister, self).get(key)
71 71 if baseitem is not None and not baseitem.generic:
72 72 return baseitem
73 73
74 74 # search for a matching generic item
75 75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
76 76 for item in generics:
77 77 # we use 'match' instead of 'search' to make the matching simpler
78 78 # for people unfamiliar with regular expression. Having the match
79 79 # rooted to the start of the string will produce less surprising
80 80 # result for user writing simple regex for sub-attribute.
81 81 #
82 82 # For example using "color\..*" match produces an unsurprising
83 83 # result, while using search could suddenly match apparently
84 84 # unrelated configuration that happens to contains "color."
85 85 # anywhere. This is a tradeoff where we favor requiring ".*" on
86 86 # some match to avoid the need to prefix most pattern with "^".
87 87 # The "^" seems more error prone.
88 88 if item._re.match(key):
89 89 return item
90 90
91 91 return None
92 92
93 93 coreitems = {}
94 94
95 95 def _register(configtable, *args, **kwargs):
96 96 item = configitem(*args, **kwargs)
97 97 section = configtable.setdefault(item.section, itemregister())
98 98 if item.name in section:
99 99 msg = "duplicated config item registration for '%s.%s'"
100 100 raise error.ProgrammingError(msg % (item.section, item.name))
101 101 section[item.name] = item
102 102
103 103 # special value for case where the default is derived from other values
104 104 dynamicdefault = object()
105 105
106 106 # Registering actual config items
107 107
108 108 def getitemregister(configtable):
109 109 f = functools.partial(_register, configtable)
110 110 # export pseudo enum as configitem.*
111 111 f.dynamicdefault = dynamicdefault
112 112 return f
113 113
114 114 coreconfigitem = getitemregister(coreitems)
115 115
116 116 coreconfigitem('alias', '.*',
117 117 default=dynamicdefault,
118 118 generic=True,
119 119 )
120 120 coreconfigitem('annotate', 'nodates',
121 121 default=False,
122 122 )
123 123 coreconfigitem('annotate', 'showfunc',
124 124 default=False,
125 125 )
126 126 coreconfigitem('annotate', 'unified',
127 127 default=None,
128 128 )
129 129 coreconfigitem('annotate', 'git',
130 130 default=False,
131 131 )
132 132 coreconfigitem('annotate', 'ignorews',
133 133 default=False,
134 134 )
135 135 coreconfigitem('annotate', 'ignorewsamount',
136 136 default=False,
137 137 )
138 138 coreconfigitem('annotate', 'ignoreblanklines',
139 139 default=False,
140 140 )
141 141 coreconfigitem('annotate', 'ignorewseol',
142 142 default=False,
143 143 )
144 144 coreconfigitem('annotate', 'nobinary',
145 145 default=False,
146 146 )
147 147 coreconfigitem('annotate', 'noprefix',
148 148 default=False,
149 149 )
150 150 coreconfigitem('annotate', 'word-diff',
151 151 default=False,
152 152 )
153 153 coreconfigitem('auth', 'cookiefile',
154 154 default=None,
155 155 )
156 156 # bookmarks.pushing: internal hack for discovery
157 157 coreconfigitem('bookmarks', 'pushing',
158 158 default=list,
159 159 )
160 160 # bundle.mainreporoot: internal hack for bundlerepo
161 161 coreconfigitem('bundle', 'mainreporoot',
162 162 default='',
163 163 )
164 164 # bundle.reorder: experimental config
165 165 coreconfigitem('bundle', 'reorder',
166 166 default='auto',
167 167 )
168 168 coreconfigitem('censor', 'policy',
169 169 default='abort',
170 170 )
171 171 coreconfigitem('chgserver', 'idletimeout',
172 172 default=3600,
173 173 )
174 174 coreconfigitem('chgserver', 'skiphash',
175 175 default=False,
176 176 )
177 177 coreconfigitem('cmdserver', 'log',
178 178 default=None,
179 179 )
180 180 coreconfigitem('color', '.*',
181 181 default=None,
182 182 generic=True,
183 183 )
184 184 coreconfigitem('color', 'mode',
185 185 default='auto',
186 186 )
187 187 coreconfigitem('color', 'pagermode',
188 188 default=dynamicdefault,
189 189 )
190 190 coreconfigitem('commands', 'grep.all-files',
191 191 default=False,
192 192 )
193 193 coreconfigitem('commands', 'show.aliasprefix',
194 194 default=list,
195 195 )
196 196 coreconfigitem('commands', 'status.relative',
197 197 default=False,
198 198 )
199 199 coreconfigitem('commands', 'status.skipstates',
200 200 default=[],
201 201 )
202 202 coreconfigitem('commands', 'status.terse',
203 203 default='',
204 204 )
205 205 coreconfigitem('commands', 'status.verbose',
206 206 default=False,
207 207 )
208 208 coreconfigitem('commands', 'update.check',
209 209 default=None,
210 210 )
211 211 coreconfigitem('commands', 'update.requiredest',
212 212 default=False,
213 213 )
214 214 coreconfigitem('committemplate', '.*',
215 215 default=None,
216 216 generic=True,
217 217 )
218 218 coreconfigitem('convert', 'bzr.saverev',
219 219 default=True,
220 220 )
221 221 coreconfigitem('convert', 'cvsps.cache',
222 222 default=True,
223 223 )
224 224 coreconfigitem('convert', 'cvsps.fuzz',
225 225 default=60,
226 226 )
227 227 coreconfigitem('convert', 'cvsps.logencoding',
228 228 default=None,
229 229 )
230 230 coreconfigitem('convert', 'cvsps.mergefrom',
231 231 default=None,
232 232 )
233 233 coreconfigitem('convert', 'cvsps.mergeto',
234 234 default=None,
235 235 )
236 236 coreconfigitem('convert', 'git.committeractions',
237 237 default=lambda: ['messagedifferent'],
238 238 )
239 239 coreconfigitem('convert', 'git.extrakeys',
240 240 default=list,
241 241 )
242 242 coreconfigitem('convert', 'git.findcopiesharder',
243 243 default=False,
244 244 )
245 245 coreconfigitem('convert', 'git.remoteprefix',
246 246 default='remote',
247 247 )
248 248 coreconfigitem('convert', 'git.renamelimit',
249 249 default=400,
250 250 )
251 251 coreconfigitem('convert', 'git.saverev',
252 252 default=True,
253 253 )
254 254 coreconfigitem('convert', 'git.similarity',
255 255 default=50,
256 256 )
257 257 coreconfigitem('convert', 'git.skipsubmodules',
258 258 default=False,
259 259 )
260 260 coreconfigitem('convert', 'hg.clonebranches',
261 261 default=False,
262 262 )
263 263 coreconfigitem('convert', 'hg.ignoreerrors',
264 264 default=False,
265 265 )
266 266 coreconfigitem('convert', 'hg.revs',
267 267 default=None,
268 268 )
269 269 coreconfigitem('convert', 'hg.saverev',
270 270 default=False,
271 271 )
272 272 coreconfigitem('convert', 'hg.sourcename',
273 273 default=None,
274 274 )
275 275 coreconfigitem('convert', 'hg.startrev',
276 276 default=None,
277 277 )
278 278 coreconfigitem('convert', 'hg.tagsbranch',
279 279 default='default',
280 280 )
281 281 coreconfigitem('convert', 'hg.usebranchnames',
282 282 default=True,
283 283 )
284 284 coreconfigitem('convert', 'ignoreancestorcheck',
285 285 default=False,
286 286 )
287 287 coreconfigitem('convert', 'localtimezone',
288 288 default=False,
289 289 )
290 290 coreconfigitem('convert', 'p4.encoding',
291 291 default=dynamicdefault,
292 292 )
293 293 coreconfigitem('convert', 'p4.startrev',
294 294 default=0,
295 295 )
296 296 coreconfigitem('convert', 'skiptags',
297 297 default=False,
298 298 )
299 299 coreconfigitem('convert', 'svn.debugsvnlog',
300 300 default=True,
301 301 )
302 302 coreconfigitem('convert', 'svn.trunk',
303 303 default=None,
304 304 )
305 305 coreconfigitem('convert', 'svn.tags',
306 306 default=None,
307 307 )
308 308 coreconfigitem('convert', 'svn.branches',
309 309 default=None,
310 310 )
311 311 coreconfigitem('convert', 'svn.startrev',
312 312 default=0,
313 313 )
314 314 coreconfigitem('debug', 'dirstate.delaywrite',
315 315 default=0,
316 316 )
317 317 coreconfigitem('defaults', '.*',
318 318 default=None,
319 319 generic=True,
320 320 )
321 321 coreconfigitem('devel', 'all-warnings',
322 322 default=False,
323 323 )
324 324 coreconfigitem('devel', 'bundle2.debug',
325 325 default=False,
326 326 )
327 327 coreconfigitem('devel', 'cache-vfs',
328 328 default=None,
329 329 )
330 330 coreconfigitem('devel', 'check-locks',
331 331 default=False,
332 332 )
333 333 coreconfigitem('devel', 'check-relroot',
334 334 default=False,
335 335 )
336 336 coreconfigitem('devel', 'default-date',
337 337 default=None,
338 338 )
339 339 coreconfigitem('devel', 'deprec-warn',
340 340 default=False,
341 341 )
342 342 coreconfigitem('devel', 'disableloaddefaultcerts',
343 343 default=False,
344 344 )
345 345 coreconfigitem('devel', 'warn-empty-changegroup',
346 346 default=False,
347 347 )
348 348 coreconfigitem('devel', 'legacy.exchange',
349 349 default=list,
350 350 )
351 351 coreconfigitem('devel', 'servercafile',
352 352 default='',
353 353 )
354 354 coreconfigitem('devel', 'serverexactprotocol',
355 355 default='',
356 356 )
357 357 coreconfigitem('devel', 'serverrequirecert',
358 358 default=False,
359 359 )
360 360 coreconfigitem('devel', 'strip-obsmarkers',
361 361 default=True,
362 362 )
363 363 coreconfigitem('devel', 'warn-config',
364 364 default=None,
365 365 )
366 366 coreconfigitem('devel', 'warn-config-default',
367 367 default=None,
368 368 )
369 369 coreconfigitem('devel', 'user.obsmarker',
370 370 default=None,
371 371 )
372 372 coreconfigitem('devel', 'warn-config-unknown',
373 373 default=None,
374 374 )
375 375 coreconfigitem('devel', 'debug.extensions',
376 376 default=False,
377 377 )
378 378 coreconfigitem('devel', 'debug.peer-request',
379 379 default=False,
380 380 )
381 381 coreconfigitem('diff', 'nodates',
382 382 default=False,
383 383 )
384 384 coreconfigitem('diff', 'showfunc',
385 385 default=False,
386 386 )
387 387 coreconfigitem('diff', 'unified',
388 388 default=None,
389 389 )
390 390 coreconfigitem('diff', 'git',
391 391 default=False,
392 392 )
393 393 coreconfigitem('diff', 'ignorews',
394 394 default=False,
395 395 )
396 396 coreconfigitem('diff', 'ignorewsamount',
397 397 default=False,
398 398 )
399 399 coreconfigitem('diff', 'ignoreblanklines',
400 400 default=False,
401 401 )
402 402 coreconfigitem('diff', 'ignorewseol',
403 403 default=False,
404 404 )
405 405 coreconfigitem('diff', 'nobinary',
406 406 default=False,
407 407 )
408 408 coreconfigitem('diff', 'noprefix',
409 409 default=False,
410 410 )
411 411 coreconfigitem('diff', 'word-diff',
412 412 default=False,
413 413 )
414 414 coreconfigitem('email', 'bcc',
415 415 default=None,
416 416 )
417 417 coreconfigitem('email', 'cc',
418 418 default=None,
419 419 )
420 420 coreconfigitem('email', 'charsets',
421 421 default=list,
422 422 )
423 423 coreconfigitem('email', 'from',
424 424 default=None,
425 425 )
426 426 coreconfigitem('email', 'method',
427 427 default='smtp',
428 428 )
429 429 coreconfigitem('email', 'reply-to',
430 430 default=None,
431 431 )
432 432 coreconfigitem('email', 'to',
433 433 default=None,
434 434 )
435 435 coreconfigitem('experimental', 'archivemetatemplate',
436 436 default=dynamicdefault,
437 437 )
438 438 coreconfigitem('experimental', 'bundle-phases',
439 439 default=False,
440 440 )
441 441 coreconfigitem('experimental', 'bundle2-advertise',
442 442 default=True,
443 443 )
444 444 coreconfigitem('experimental', 'bundle2-output-capture',
445 445 default=False,
446 446 )
447 447 coreconfigitem('experimental', 'bundle2.pushback',
448 448 default=False,
449 449 )
450 450 coreconfigitem('experimental', 'bundle2.stream',
451 451 default=False,
452 452 )
453 453 coreconfigitem('experimental', 'bundle2lazylocking',
454 454 default=False,
455 455 )
456 456 coreconfigitem('experimental', 'bundlecomplevel',
457 457 default=None,
458 458 )
459 459 coreconfigitem('experimental', 'bundlecomplevel.bzip2',
460 460 default=None,
461 461 )
462 462 coreconfigitem('experimental', 'bundlecomplevel.gzip',
463 463 default=None,
464 464 )
465 465 coreconfigitem('experimental', 'bundlecomplevel.none',
466 466 default=None,
467 467 )
468 468 coreconfigitem('experimental', 'bundlecomplevel.zstd',
469 469 default=None,
470 470 )
471 471 coreconfigitem('experimental', 'changegroup3',
472 472 default=False,
473 473 )
474 474 coreconfigitem('experimental', 'clientcompressionengines',
475 475 default=list,
476 476 )
477 477 coreconfigitem('experimental', 'copytrace',
478 478 default='on',
479 479 )
480 480 coreconfigitem('experimental', 'copytrace.movecandidateslimit',
481 481 default=100,
482 482 )
483 483 coreconfigitem('experimental', 'copytrace.sourcecommitlimit',
484 484 default=100,
485 485 )
486 486 coreconfigitem('experimental', 'crecordtest',
487 487 default=None,
488 488 )
489 489 coreconfigitem('experimental', 'directaccess',
490 490 default=False,
491 491 )
492 492 coreconfigitem('experimental', 'directaccess.revnums',
493 493 default=False,
494 494 )
495 495 coreconfigitem('experimental', 'editortmpinhg',
496 496 default=False,
497 497 )
498 498 coreconfigitem('experimental', 'evolution',
499 499 default=list,
500 500 )
501 501 coreconfigitem('experimental', 'evolution.allowdivergence',
502 502 default=False,
503 503 alias=[('experimental', 'allowdivergence')]
504 504 )
505 505 coreconfigitem('experimental', 'evolution.allowunstable',
506 506 default=None,
507 507 )
508 508 coreconfigitem('experimental', 'evolution.createmarkers',
509 509 default=None,
510 510 )
511 511 coreconfigitem('experimental', 'evolution.effect-flags',
512 512 default=True,
513 513 alias=[('experimental', 'effect-flags')]
514 514 )
515 515 coreconfigitem('experimental', 'evolution.exchange',
516 516 default=None,
517 517 )
518 518 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
519 519 default=False,
520 520 )
521 521 coreconfigitem('experimental', 'evolution.report-instabilities',
522 522 default=True,
523 523 )
524 524 coreconfigitem('experimental', 'evolution.track-operation',
525 525 default=True,
526 526 )
527 527 coreconfigitem('experimental', 'maxdeltachainspan',
528 528 default=-1,
529 529 )
530 530 coreconfigitem('experimental', 'mergetempdirprefix',
531 531 default=None,
532 532 )
533 533 coreconfigitem('experimental', 'mmapindexthreshold',
534 534 default=None,
535 535 )
536 536 coreconfigitem('experimental', 'nonnormalparanoidcheck',
537 537 default=False,
538 538 )
539 539 coreconfigitem('experimental', 'exportableenviron',
540 540 default=list,
541 541 )
542 542 coreconfigitem('experimental', 'extendedheader.index',
543 543 default=None,
544 544 )
545 545 coreconfigitem('experimental', 'extendedheader.similarity',
546 546 default=False,
547 547 )
548 548 coreconfigitem('experimental', 'format.compression',
549 549 default='zlib',
550 550 )
551 551 coreconfigitem('experimental', 'graphshorten',
552 552 default=False,
553 553 )
554 554 coreconfigitem('experimental', 'graphstyle.parent',
555 555 default=dynamicdefault,
556 556 )
557 557 coreconfigitem('experimental', 'graphstyle.missing',
558 558 default=dynamicdefault,
559 559 )
560 560 coreconfigitem('experimental', 'graphstyle.grandparent',
561 561 default=dynamicdefault,
562 562 )
563 563 coreconfigitem('experimental', 'hook-track-tags',
564 564 default=False,
565 565 )
566 566 coreconfigitem('experimental', 'httppeer.advertise-v2',
567 567 default=False,
568 568 )
569 569 coreconfigitem('experimental', 'httppostargs',
570 570 default=False,
571 571 )
572 572 coreconfigitem('experimental', 'mergedriver',
573 573 default=None,
574 574 )
575 575 coreconfigitem('experimental', 'nointerrupt', default=False)
576 576 coreconfigitem('experimental', 'nointerrupt-interactiveonly', default=True)
577 577
578 578 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
579 579 default=False,
580 580 )
581 581 coreconfigitem('experimental', 'remotenames',
582 582 default=False,
583 583 )
584 584 coreconfigitem('experimental', 'removeemptydirs',
585 585 default=True,
586 586 )
587 587 coreconfigitem('experimental', 'revlogv2',
588 588 default=None,
589 589 )
590 590 coreconfigitem('experimental', 'single-head-per-branch',
591 591 default=False,
592 592 )
593 593 coreconfigitem('experimental', 'sshserver.support-v2',
594 594 default=False,
595 595 )
596 596 coreconfigitem('experimental', 'spacemovesdown',
597 597 default=False,
598 598 )
599 599 coreconfigitem('experimental', 'sparse-read',
600 600 default=False,
601 601 )
602 602 coreconfigitem('experimental', 'sparse-read.density-threshold',
603 603 default=0.50,
604 604 )
605 605 coreconfigitem('experimental', 'sparse-read.min-gap-size',
606 606 default='65K',
607 607 )
608 608 coreconfigitem('experimental', 'treemanifest',
609 609 default=False,
610 610 )
611 611 coreconfigitem('experimental', 'update.atomic-file',
612 612 default=False,
613 613 )
614 614 coreconfigitem('experimental', 'sshpeer.advertise-v2',
615 615 default=False,
616 616 )
617 617 coreconfigitem('experimental', 'web.apiserver',
618 618 default=False,
619 619 )
620 620 coreconfigitem('experimental', 'web.api.http-v2',
621 621 default=False,
622 622 )
623 623 coreconfigitem('experimental', 'web.api.debugreflect',
624 624 default=False,
625 625 )
626 626 coreconfigitem('experimental', 'worker.wdir-get-thread-safe',
627 627 default=False,
628 628 )
629 629 coreconfigitem('experimental', 'xdiff',
630 630 default=False,
631 631 )
632 632 coreconfigitem('extensions', '.*',
633 633 default=None,
634 634 generic=True,
635 635 )
636 636 coreconfigitem('extdata', '.*',
637 637 default=None,
638 638 generic=True,
639 639 )
640 640 coreconfigitem('format', 'chunkcachesize',
641 641 default=None,
642 642 )
643 643 coreconfigitem('format', 'dotencode',
644 644 default=True,
645 645 )
646 646 coreconfigitem('format', 'generaldelta',
647 647 default=False,
648 648 )
649 649 coreconfigitem('format', 'manifestcachesize',
650 650 default=None,
651 651 )
652 652 coreconfigitem('format', 'maxchainlen',
653 653 default=None,
654 654 )
655 655 coreconfigitem('format', 'obsstore-version',
656 656 default=None,
657 657 )
658 658 coreconfigitem('format', 'sparse-revlog',
659 659 default=False,
660 660 )
661 661 coreconfigitem('format', 'usefncache',
662 662 default=True,
663 663 )
664 664 coreconfigitem('format', 'usegeneraldelta',
665 665 default=True,
666 666 )
667 667 coreconfigitem('format', 'usestore',
668 668 default=True,
669 669 )
670 670 coreconfigitem('fsmonitor', 'warn_when_unused',
671 671 default=True,
672 672 )
673 673 coreconfigitem('fsmonitor', 'warn_update_file_count',
674 674 default=50000,
675 675 )
676 676 coreconfigitem('hooks', '.*',
677 677 default=dynamicdefault,
678 678 generic=True,
679 679 )
680 680 coreconfigitem('hgweb-paths', '.*',
681 681 default=list,
682 682 generic=True,
683 683 )
684 684 coreconfigitem('hostfingerprints', '.*',
685 685 default=list,
686 686 generic=True,
687 687 )
688 688 coreconfigitem('hostsecurity', 'ciphers',
689 689 default=None,
690 690 )
691 691 coreconfigitem('hostsecurity', 'disabletls10warning',
692 692 default=False,
693 693 )
694 694 coreconfigitem('hostsecurity', 'minimumprotocol',
695 695 default=dynamicdefault,
696 696 )
697 697 coreconfigitem('hostsecurity', '.*:minimumprotocol$',
698 698 default=dynamicdefault,
699 699 generic=True,
700 700 )
701 701 coreconfigitem('hostsecurity', '.*:ciphers$',
702 702 default=dynamicdefault,
703 703 generic=True,
704 704 )
705 705 coreconfigitem('hostsecurity', '.*:fingerprints$',
706 706 default=list,
707 707 generic=True,
708 708 )
709 709 coreconfigitem('hostsecurity', '.*:verifycertsfile$',
710 710 default=None,
711 711 generic=True,
712 712 )
713 713
714 714 coreconfigitem('http_proxy', 'always',
715 715 default=False,
716 716 )
717 717 coreconfigitem('http_proxy', 'host',
718 718 default=None,
719 719 )
720 720 coreconfigitem('http_proxy', 'no',
721 721 default=list,
722 722 )
723 723 coreconfigitem('http_proxy', 'passwd',
724 724 default=None,
725 725 )
726 726 coreconfigitem('http_proxy', 'user',
727 727 default=None,
728 728 )
729 729 coreconfigitem('logtoprocess', 'commandexception',
730 730 default=None,
731 731 )
732 732 coreconfigitem('logtoprocess', 'commandfinish',
733 733 default=None,
734 734 )
735 735 coreconfigitem('logtoprocess', 'command',
736 736 default=None,
737 737 )
738 738 coreconfigitem('logtoprocess', 'develwarn',
739 739 default=None,
740 740 )
741 741 coreconfigitem('logtoprocess', 'uiblocked',
742 742 default=None,
743 743 )
744 744 coreconfigitem('merge', 'checkunknown',
745 745 default='abort',
746 746 )
747 747 coreconfigitem('merge', 'checkignored',
748 748 default='abort',
749 749 )
750 750 coreconfigitem('experimental', 'merge.checkpathconflicts',
751 751 default=False,
752 752 )
753 753 coreconfigitem('merge', 'followcopies',
754 754 default=True,
755 755 )
756 756 coreconfigitem('merge', 'on-failure',
757 757 default='continue',
758 758 )
759 759 coreconfigitem('merge', 'preferancestor',
760 760 default=lambda: ['*'],
761 761 )
762 762 coreconfigitem('merge-tools', '.*',
763 763 default=None,
764 764 generic=True,
765 765 )
766 766 coreconfigitem('merge-tools', br'.*\.args$',
767 767 default="$local $base $other",
768 768 generic=True,
769 769 priority=-1,
770 770 )
771 771 coreconfigitem('merge-tools', br'.*\.binary$',
772 772 default=False,
773 773 generic=True,
774 774 priority=-1,
775 775 )
776 776 coreconfigitem('merge-tools', br'.*\.check$',
777 777 default=list,
778 778 generic=True,
779 779 priority=-1,
780 780 )
781 781 coreconfigitem('merge-tools', br'.*\.checkchanged$',
782 782 default=False,
783 783 generic=True,
784 784 priority=-1,
785 785 )
786 786 coreconfigitem('merge-tools', br'.*\.executable$',
787 787 default=dynamicdefault,
788 788 generic=True,
789 789 priority=-1,
790 790 )
791 791 coreconfigitem('merge-tools', br'.*\.fixeol$',
792 792 default=False,
793 793 generic=True,
794 794 priority=-1,
795 795 )
796 796 coreconfigitem('merge-tools', br'.*\.gui$',
797 797 default=False,
798 798 generic=True,
799 799 priority=-1,
800 800 )
801 801 coreconfigitem('merge-tools', br'.*\.mergemarkers$',
802 802 default='basic',
803 803 generic=True,
804 804 priority=-1,
805 805 )
806 806 coreconfigitem('merge-tools', br'.*\.mergemarkertemplate$',
807 807 default=dynamicdefault, # take from ui.mergemarkertemplate
808 808 generic=True,
809 809 priority=-1,
810 810 )
811 811 coreconfigitem('merge-tools', br'.*\.priority$',
812 812 default=0,
813 813 generic=True,
814 814 priority=-1,
815 815 )
816 816 coreconfigitem('merge-tools', br'.*\.premerge$',
817 817 default=dynamicdefault,
818 818 generic=True,
819 819 priority=-1,
820 820 )
821 821 coreconfigitem('merge-tools', br'.*\.symlink$',
822 822 default=False,
823 823 generic=True,
824 824 priority=-1,
825 825 )
826 826 coreconfigitem('pager', 'attend-.*',
827 827 default=dynamicdefault,
828 828 generic=True,
829 829 )
830 830 coreconfigitem('pager', 'ignore',
831 831 default=list,
832 832 )
833 833 coreconfigitem('pager', 'pager',
834 834 default=dynamicdefault,
835 835 )
836 836 coreconfigitem('patch', 'eol',
837 837 default='strict',
838 838 )
839 839 coreconfigitem('patch', 'fuzz',
840 840 default=2,
841 841 )
842 842 coreconfigitem('paths', 'default',
843 843 default=None,
844 844 )
845 845 coreconfigitem('paths', 'default-push',
846 846 default=None,
847 847 )
848 848 coreconfigitem('paths', '.*',
849 849 default=None,
850 850 generic=True,
851 851 )
852 852 coreconfigitem('phases', 'checksubrepos',
853 853 default='follow',
854 854 )
855 855 coreconfigitem('phases', 'new-commit',
856 856 default='draft',
857 857 )
858 858 coreconfigitem('phases', 'publish',
859 859 default=True,
860 860 )
861 861 coreconfigitem('profiling', 'enabled',
862 862 default=False,
863 863 )
864 864 coreconfigitem('profiling', 'format',
865 865 default='text',
866 866 )
867 867 coreconfigitem('profiling', 'freq',
868 868 default=1000,
869 869 )
870 870 coreconfigitem('profiling', 'limit',
871 871 default=30,
872 872 )
873 873 coreconfigitem('profiling', 'nested',
874 874 default=0,
875 875 )
876 876 coreconfigitem('profiling', 'output',
877 877 default=None,
878 878 )
879 879 coreconfigitem('profiling', 'showmax',
880 880 default=0.999,
881 881 )
882 882 coreconfigitem('profiling', 'showmin',
883 883 default=dynamicdefault,
884 884 )
885 885 coreconfigitem('profiling', 'sort',
886 886 default='inlinetime',
887 887 )
888 888 coreconfigitem('profiling', 'statformat',
889 889 default='hotpath',
890 890 )
891 891 coreconfigitem('profiling', 'time-track',
892 892 default='cpu',
893 893 )
894 894 coreconfigitem('profiling', 'type',
895 895 default='stat',
896 896 )
897 897 coreconfigitem('progress', 'assume-tty',
898 898 default=False,
899 899 )
900 900 coreconfigitem('progress', 'changedelay',
901 901 default=1,
902 902 )
903 903 coreconfigitem('progress', 'clear-complete',
904 904 default=True,
905 905 )
906 906 coreconfigitem('progress', 'debug',
907 907 default=False,
908 908 )
909 909 coreconfigitem('progress', 'delay',
910 910 default=3,
911 911 )
912 912 coreconfigitem('progress', 'disable',
913 913 default=False,
914 914 )
915 915 coreconfigitem('progress', 'estimateinterval',
916 916 default=60.0,
917 917 )
918 918 coreconfigitem('progress', 'format',
919 919 default=lambda: ['topic', 'bar', 'number', 'estimate'],
920 920 )
921 921 coreconfigitem('progress', 'refresh',
922 922 default=0.1,
923 923 )
924 924 coreconfigitem('progress', 'width',
925 925 default=dynamicdefault,
926 926 )
927 927 coreconfigitem('push', 'pushvars.server',
928 928 default=False,
929 929 )
930 coreconfigitem('revlog', 'optimize-delta-parent-choice',
930 coreconfigitem('storage', 'revlog.optimize-delta-parent-choice',
931 931 default=True,
932 932 alias=[('format', 'aggressivemergedeltas')],
933 933 )
934 934 coreconfigitem('server', 'bookmarks-pushkey-compat',
935 935 default=True,
936 936 )
937 937 coreconfigitem('server', 'bundle1',
938 938 default=True,
939 939 )
940 940 coreconfigitem('server', 'bundle1gd',
941 941 default=None,
942 942 )
943 943 coreconfigitem('server', 'bundle1.pull',
944 944 default=None,
945 945 )
946 946 coreconfigitem('server', 'bundle1gd.pull',
947 947 default=None,
948 948 )
949 949 coreconfigitem('server', 'bundle1.push',
950 950 default=None,
951 951 )
952 952 coreconfigitem('server', 'bundle1gd.push',
953 953 default=None,
954 954 )
955 955 coreconfigitem('server', 'compressionengines',
956 956 default=list,
957 957 )
958 958 coreconfigitem('server', 'concurrent-push-mode',
959 959 default='strict',
960 960 )
961 961 coreconfigitem('server', 'disablefullbundle',
962 962 default=False,
963 963 )
964 964 coreconfigitem('server', 'maxhttpheaderlen',
965 965 default=1024,
966 966 )
967 967 coreconfigitem('server', 'pullbundle',
968 968 default=False,
969 969 )
970 970 coreconfigitem('server', 'preferuncompressed',
971 971 default=False,
972 972 )
973 973 coreconfigitem('server', 'streamunbundle',
974 974 default=False,
975 975 )
976 976 coreconfigitem('server', 'uncompressed',
977 977 default=True,
978 978 )
979 979 coreconfigitem('server', 'uncompressedallowsecret',
980 980 default=False,
981 981 )
982 982 coreconfigitem('server', 'validate',
983 983 default=False,
984 984 )
985 985 coreconfigitem('server', 'zliblevel',
986 986 default=-1,
987 987 )
988 988 coreconfigitem('server', 'zstdlevel',
989 989 default=3,
990 990 )
991 991 coreconfigitem('share', 'pool',
992 992 default=None,
993 993 )
994 994 coreconfigitem('share', 'poolnaming',
995 995 default='identity',
996 996 )
997 997 coreconfigitem('smtp', 'host',
998 998 default=None,
999 999 )
1000 1000 coreconfigitem('smtp', 'local_hostname',
1001 1001 default=None,
1002 1002 )
1003 1003 coreconfigitem('smtp', 'password',
1004 1004 default=None,
1005 1005 )
1006 1006 coreconfigitem('smtp', 'port',
1007 1007 default=dynamicdefault,
1008 1008 )
1009 1009 coreconfigitem('smtp', 'tls',
1010 1010 default='none',
1011 1011 )
1012 1012 coreconfigitem('smtp', 'username',
1013 1013 default=None,
1014 1014 )
1015 1015 coreconfigitem('sparse', 'missingwarning',
1016 1016 default=True,
1017 1017 )
1018 1018 coreconfigitem('subrepos', 'allowed',
1019 1019 default=dynamicdefault, # to make backporting simpler
1020 1020 )
1021 1021 coreconfigitem('subrepos', 'hg:allowed',
1022 1022 default=dynamicdefault,
1023 1023 )
1024 1024 coreconfigitem('subrepos', 'git:allowed',
1025 1025 default=dynamicdefault,
1026 1026 )
1027 1027 coreconfigitem('subrepos', 'svn:allowed',
1028 1028 default=dynamicdefault,
1029 1029 )
1030 1030 coreconfigitem('templates', '.*',
1031 1031 default=None,
1032 1032 generic=True,
1033 1033 )
1034 1034 coreconfigitem('trusted', 'groups',
1035 1035 default=list,
1036 1036 )
1037 1037 coreconfigitem('trusted', 'users',
1038 1038 default=list,
1039 1039 )
1040 1040 coreconfigitem('ui', '_usedassubrepo',
1041 1041 default=False,
1042 1042 )
1043 1043 coreconfigitem('ui', 'allowemptycommit',
1044 1044 default=False,
1045 1045 )
1046 1046 coreconfigitem('ui', 'archivemeta',
1047 1047 default=True,
1048 1048 )
1049 1049 coreconfigitem('ui', 'askusername',
1050 1050 default=False,
1051 1051 )
1052 1052 coreconfigitem('ui', 'clonebundlefallback',
1053 1053 default=False,
1054 1054 )
1055 1055 coreconfigitem('ui', 'clonebundleprefers',
1056 1056 default=list,
1057 1057 )
1058 1058 coreconfigitem('ui', 'clonebundles',
1059 1059 default=True,
1060 1060 )
1061 1061 coreconfigitem('ui', 'color',
1062 1062 default='auto',
1063 1063 )
1064 1064 coreconfigitem('ui', 'commitsubrepos',
1065 1065 default=False,
1066 1066 )
1067 1067 coreconfigitem('ui', 'debug',
1068 1068 default=False,
1069 1069 )
1070 1070 coreconfigitem('ui', 'debugger',
1071 1071 default=None,
1072 1072 )
1073 1073 coreconfigitem('ui', 'editor',
1074 1074 default=dynamicdefault,
1075 1075 )
1076 1076 coreconfigitem('ui', 'fallbackencoding',
1077 1077 default=None,
1078 1078 )
1079 1079 coreconfigitem('ui', 'forcecwd',
1080 1080 default=None,
1081 1081 )
1082 1082 coreconfigitem('ui', 'forcemerge',
1083 1083 default=None,
1084 1084 )
1085 1085 coreconfigitem('ui', 'formatdebug',
1086 1086 default=False,
1087 1087 )
1088 1088 coreconfigitem('ui', 'formatjson',
1089 1089 default=False,
1090 1090 )
1091 1091 coreconfigitem('ui', 'formatted',
1092 1092 default=None,
1093 1093 )
1094 1094 coreconfigitem('ui', 'graphnodetemplate',
1095 1095 default=None,
1096 1096 )
1097 1097 coreconfigitem('ui', 'history-editing-backup',
1098 1098 default=True,
1099 1099 )
1100 1100 coreconfigitem('ui', 'interactive',
1101 1101 default=None,
1102 1102 )
1103 1103 coreconfigitem('ui', 'interface',
1104 1104 default=None,
1105 1105 )
1106 1106 coreconfigitem('ui', 'interface.chunkselector',
1107 1107 default=None,
1108 1108 )
1109 1109 coreconfigitem('ui', 'large-file-limit',
1110 1110 default=10000000,
1111 1111 )
1112 1112 coreconfigitem('ui', 'logblockedtimes',
1113 1113 default=False,
1114 1114 )
1115 1115 coreconfigitem('ui', 'logtemplate',
1116 1116 default=None,
1117 1117 )
1118 1118 coreconfigitem('ui', 'merge',
1119 1119 default=None,
1120 1120 )
1121 1121 coreconfigitem('ui', 'mergemarkers',
1122 1122 default='basic',
1123 1123 )
1124 1124 coreconfigitem('ui', 'mergemarkertemplate',
1125 1125 default=('{node|short} '
1126 1126 '{ifeq(tags, "tip", "", '
1127 1127 'ifeq(tags, "", "", "{tags} "))}'
1128 1128 '{if(bookmarks, "{bookmarks} ")}'
1129 1129 '{ifeq(branch, "default", "", "{branch} ")}'
1130 1130 '- {author|user}: {desc|firstline}')
1131 1131 )
1132 1132 coreconfigitem('ui', 'nontty',
1133 1133 default=False,
1134 1134 )
1135 1135 coreconfigitem('ui', 'origbackuppath',
1136 1136 default=None,
1137 1137 )
1138 1138 coreconfigitem('ui', 'paginate',
1139 1139 default=True,
1140 1140 )
1141 1141 coreconfigitem('ui', 'patch',
1142 1142 default=None,
1143 1143 )
1144 1144 coreconfigitem('ui', 'portablefilenames',
1145 1145 default='warn',
1146 1146 )
1147 1147 coreconfigitem('ui', 'promptecho',
1148 1148 default=False,
1149 1149 )
1150 1150 coreconfigitem('ui', 'quiet',
1151 1151 default=False,
1152 1152 )
1153 1153 coreconfigitem('ui', 'quietbookmarkmove',
1154 1154 default=False,
1155 1155 )
1156 1156 coreconfigitem('ui', 'remotecmd',
1157 1157 default='hg',
1158 1158 )
1159 1159 coreconfigitem('ui', 'report_untrusted',
1160 1160 default=True,
1161 1161 )
1162 1162 coreconfigitem('ui', 'rollback',
1163 1163 default=True,
1164 1164 )
1165 1165 coreconfigitem('ui', 'signal-safe-lock',
1166 1166 default=True,
1167 1167 )
1168 1168 coreconfigitem('ui', 'slash',
1169 1169 default=False,
1170 1170 )
1171 1171 coreconfigitem('ui', 'ssh',
1172 1172 default='ssh',
1173 1173 )
1174 1174 coreconfigitem('ui', 'ssherrorhint',
1175 1175 default=None,
1176 1176 )
1177 1177 coreconfigitem('ui', 'statuscopies',
1178 1178 default=False,
1179 1179 )
1180 1180 coreconfigitem('ui', 'strict',
1181 1181 default=False,
1182 1182 )
1183 1183 coreconfigitem('ui', 'style',
1184 1184 default='',
1185 1185 )
1186 1186 coreconfigitem('ui', 'supportcontact',
1187 1187 default=None,
1188 1188 )
1189 1189 coreconfigitem('ui', 'textwidth',
1190 1190 default=78,
1191 1191 )
1192 1192 coreconfigitem('ui', 'timeout',
1193 1193 default='600',
1194 1194 )
1195 1195 coreconfigitem('ui', 'timeout.warn',
1196 1196 default=0,
1197 1197 )
1198 1198 coreconfigitem('ui', 'traceback',
1199 1199 default=False,
1200 1200 )
1201 1201 coreconfigitem('ui', 'tweakdefaults',
1202 1202 default=False,
1203 1203 )
1204 1204 coreconfigitem('ui', 'username',
1205 1205 alias=[('ui', 'user')]
1206 1206 )
1207 1207 coreconfigitem('ui', 'verbose',
1208 1208 default=False,
1209 1209 )
1210 1210 coreconfigitem('verify', 'skipflags',
1211 1211 default=None,
1212 1212 )
1213 1213 coreconfigitem('web', 'allowbz2',
1214 1214 default=False,
1215 1215 )
1216 1216 coreconfigitem('web', 'allowgz',
1217 1217 default=False,
1218 1218 )
1219 1219 coreconfigitem('web', 'allow-pull',
1220 1220 alias=[('web', 'allowpull')],
1221 1221 default=True,
1222 1222 )
1223 1223 coreconfigitem('web', 'allow-push',
1224 1224 alias=[('web', 'allow_push')],
1225 1225 default=list,
1226 1226 )
1227 1227 coreconfigitem('web', 'allowzip',
1228 1228 default=False,
1229 1229 )
1230 1230 coreconfigitem('web', 'archivesubrepos',
1231 1231 default=False,
1232 1232 )
1233 1233 coreconfigitem('web', 'cache',
1234 1234 default=True,
1235 1235 )
1236 1236 coreconfigitem('web', 'contact',
1237 1237 default=None,
1238 1238 )
1239 1239 coreconfigitem('web', 'deny_push',
1240 1240 default=list,
1241 1241 )
1242 1242 coreconfigitem('web', 'guessmime',
1243 1243 default=False,
1244 1244 )
1245 1245 coreconfigitem('web', 'hidden',
1246 1246 default=False,
1247 1247 )
1248 1248 coreconfigitem('web', 'labels',
1249 1249 default=list,
1250 1250 )
1251 1251 coreconfigitem('web', 'logoimg',
1252 1252 default='hglogo.png',
1253 1253 )
1254 1254 coreconfigitem('web', 'logourl',
1255 1255 default='https://mercurial-scm.org/',
1256 1256 )
1257 1257 coreconfigitem('web', 'accesslog',
1258 1258 default='-',
1259 1259 )
1260 1260 coreconfigitem('web', 'address',
1261 1261 default='',
1262 1262 )
1263 1263 coreconfigitem('web', 'allow-archive',
1264 1264 alias=[('web', 'allow_archive')],
1265 1265 default=list,
1266 1266 )
1267 1267 coreconfigitem('web', 'allow_read',
1268 1268 default=list,
1269 1269 )
1270 1270 coreconfigitem('web', 'baseurl',
1271 1271 default=None,
1272 1272 )
1273 1273 coreconfigitem('web', 'cacerts',
1274 1274 default=None,
1275 1275 )
1276 1276 coreconfigitem('web', 'certificate',
1277 1277 default=None,
1278 1278 )
1279 1279 coreconfigitem('web', 'collapse',
1280 1280 default=False,
1281 1281 )
1282 1282 coreconfigitem('web', 'csp',
1283 1283 default=None,
1284 1284 )
1285 1285 coreconfigitem('web', 'deny_read',
1286 1286 default=list,
1287 1287 )
1288 1288 coreconfigitem('web', 'descend',
1289 1289 default=True,
1290 1290 )
1291 1291 coreconfigitem('web', 'description',
1292 1292 default="",
1293 1293 )
1294 1294 coreconfigitem('web', 'encoding',
1295 1295 default=lambda: encoding.encoding,
1296 1296 )
1297 1297 coreconfigitem('web', 'errorlog',
1298 1298 default='-',
1299 1299 )
1300 1300 coreconfigitem('web', 'ipv6',
1301 1301 default=False,
1302 1302 )
1303 1303 coreconfigitem('web', 'maxchanges',
1304 1304 default=10,
1305 1305 )
1306 1306 coreconfigitem('web', 'maxfiles',
1307 1307 default=10,
1308 1308 )
1309 1309 coreconfigitem('web', 'maxshortchanges',
1310 1310 default=60,
1311 1311 )
1312 1312 coreconfigitem('web', 'motd',
1313 1313 default='',
1314 1314 )
1315 1315 coreconfigitem('web', 'name',
1316 1316 default=dynamicdefault,
1317 1317 )
1318 1318 coreconfigitem('web', 'port',
1319 1319 default=8000,
1320 1320 )
1321 1321 coreconfigitem('web', 'prefix',
1322 1322 default='',
1323 1323 )
1324 1324 coreconfigitem('web', 'push_ssl',
1325 1325 default=True,
1326 1326 )
1327 1327 coreconfigitem('web', 'refreshinterval',
1328 1328 default=20,
1329 1329 )
1330 1330 coreconfigitem('web', 'server-header',
1331 1331 default=None,
1332 1332 )
1333 1333 coreconfigitem('web', 'staticurl',
1334 1334 default=None,
1335 1335 )
1336 1336 coreconfigitem('web', 'stripes',
1337 1337 default=1,
1338 1338 )
1339 1339 coreconfigitem('web', 'style',
1340 1340 default='paper',
1341 1341 )
1342 1342 coreconfigitem('web', 'templates',
1343 1343 default=None,
1344 1344 )
1345 1345 coreconfigitem('web', 'view',
1346 1346 default='served',
1347 1347 )
1348 1348 coreconfigitem('worker', 'backgroundclose',
1349 1349 default=dynamicdefault,
1350 1350 )
1351 1351 # Windows defaults to a limit of 512 open files. A buffer of 128
1352 1352 # should give us enough headway.
1353 1353 coreconfigitem('worker', 'backgroundclosemaxqueue',
1354 1354 default=384,
1355 1355 )
1356 1356 coreconfigitem('worker', 'backgroundcloseminfilecount',
1357 1357 default=2048,
1358 1358 )
1359 1359 coreconfigitem('worker', 'backgroundclosethreadcount',
1360 1360 default=4,
1361 1361 )
1362 1362 coreconfigitem('worker', 'enabled',
1363 1363 default=True,
1364 1364 )
1365 1365 coreconfigitem('worker', 'numcpus',
1366 1366 default=None,
1367 1367 )
1368 1368
1369 1369 # Rebase related configuration moved to core because other extension are doing
1370 1370 # strange things. For example, shelve import the extensions to reuse some bit
1371 1371 # without formally loading it.
1372 1372 coreconfigitem('commands', 'rebase.requiredest',
1373 1373 default=False,
1374 1374 )
1375 1375 coreconfigitem('experimental', 'rebaseskipobsolete',
1376 1376 default=True,
1377 1377 )
1378 1378 coreconfigitem('rebase', 'singletransaction',
1379 1379 default=False,
1380 1380 )
1381 1381 coreconfigitem('rebase', 'experimental.inmemory',
1382 1382 default=False,
1383 1383 )
@@ -1,2691 +1,2691 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 ``status.relative``
442 442 Make paths in :hg:`status` output relative to the current directory.
443 443 (default: False)
444 444
445 445 ``status.terse``
446 446 Default value for the --terse flag, which condenes status output.
447 447 (default: empty)
448 448
449 449 ``update.check``
450 450 Determines what level of checking :hg:`update` will perform before moving
451 451 to a destination revision. Valid values are ``abort``, ``none``,
452 452 ``linear``, and ``noconflict``. ``abort`` always fails if the working
453 453 directory has uncommitted changes. ``none`` performs no checking, and may
454 454 result in a merge with uncommitted changes. ``linear`` allows any update
455 455 as long as it follows a straight line in the revision history, and may
456 456 trigger a merge with uncommitted changes. ``noconflict`` will allow any
457 457 update which would not trigger a merge with uncommitted changes, if any
458 458 are present.
459 459 (default: ``linear``)
460 460
461 461 ``update.requiredest``
462 462 Require that the user pass a destination when running :hg:`update`.
463 463 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
464 464 will be disallowed.
465 465 (default: False)
466 466
467 467 ``committemplate``
468 468 ------------------
469 469
470 470 ``changeset``
471 471 String: configuration in this section is used as the template to
472 472 customize the text shown in the editor when committing.
473 473
474 474 In addition to pre-defined template keywords, commit log specific one
475 475 below can be used for customization:
476 476
477 477 ``extramsg``
478 478 String: Extra message (typically 'Leave message empty to abort
479 479 commit.'). This may be changed by some commands or extensions.
480 480
481 481 For example, the template configuration below shows as same text as
482 482 one shown by default::
483 483
484 484 [committemplate]
485 485 changeset = {desc}\n\n
486 486 HG: Enter commit message. Lines beginning with 'HG:' are removed.
487 487 HG: {extramsg}
488 488 HG: --
489 489 HG: user: {author}\n{ifeq(p2rev, "-1", "",
490 490 "HG: branch merge\n")
491 491 }HG: branch '{branch}'\n{if(activebookmark,
492 492 "HG: bookmark '{activebookmark}'\n") }{subrepos %
493 493 "HG: subrepo {subrepo}\n" }{file_adds %
494 494 "HG: added {file}\n" }{file_mods %
495 495 "HG: changed {file}\n" }{file_dels %
496 496 "HG: removed {file}\n" }{if(files, "",
497 497 "HG: no files changed\n")}
498 498
499 499 ``diff()``
500 500 String: show the diff (see :hg:`help templates` for detail)
501 501
502 502 Sometimes it is helpful to show the diff of the changeset in the editor without
503 503 having to prefix 'HG: ' to each line so that highlighting works correctly. For
504 504 this, Mercurial provides a special string which will ignore everything below
505 505 it::
506 506
507 507 HG: ------------------------ >8 ------------------------
508 508
509 509 For example, the template configuration below will show the diff below the
510 510 extra message::
511 511
512 512 [committemplate]
513 513 changeset = {desc}\n\n
514 514 HG: Enter commit message. Lines beginning with 'HG:' are removed.
515 515 HG: {extramsg}
516 516 HG: ------------------------ >8 ------------------------
517 517 HG: Do not touch the line above.
518 518 HG: Everything below will be removed.
519 519 {diff()}
520 520
521 521 .. note::
522 522
523 523 For some problematic encodings (see :hg:`help win32mbcs` for
524 524 detail), this customization should be configured carefully, to
525 525 avoid showing broken characters.
526 526
527 527 For example, if a multibyte character ending with backslash (0x5c) is
528 528 followed by the ASCII character 'n' in the customized template,
529 529 the sequence of backslash and 'n' is treated as line-feed unexpectedly
530 530 (and the multibyte character is broken, too).
531 531
532 532 Customized template is used for commands below (``--edit`` may be
533 533 required):
534 534
535 535 - :hg:`backout`
536 536 - :hg:`commit`
537 537 - :hg:`fetch` (for merge commit only)
538 538 - :hg:`graft`
539 539 - :hg:`histedit`
540 540 - :hg:`import`
541 541 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
542 542 - :hg:`rebase`
543 543 - :hg:`shelve`
544 544 - :hg:`sign`
545 545 - :hg:`tag`
546 546 - :hg:`transplant`
547 547
548 548 Configuring items below instead of ``changeset`` allows showing
549 549 customized message only for specific actions, or showing different
550 550 messages for each action.
551 551
552 552 - ``changeset.backout`` for :hg:`backout`
553 553 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
554 554 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
555 555 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
556 556 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
557 557 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
558 558 - ``changeset.gpg.sign`` for :hg:`sign`
559 559 - ``changeset.graft`` for :hg:`graft`
560 560 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
561 561 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
562 562 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
563 563 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
564 564 - ``changeset.import.bypass`` for :hg:`import --bypass`
565 565 - ``changeset.import.normal.merge`` for :hg:`import` on merges
566 566 - ``changeset.import.normal.normal`` for :hg:`import` on other
567 567 - ``changeset.mq.qnew`` for :hg:`qnew`
568 568 - ``changeset.mq.qfold`` for :hg:`qfold`
569 569 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
570 570 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
571 571 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
572 572 - ``changeset.rebase.normal`` for :hg:`rebase` on other
573 573 - ``changeset.shelve.shelve`` for :hg:`shelve`
574 574 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
575 575 - ``changeset.tag.remove`` for :hg:`tag --remove`
576 576 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
577 577 - ``changeset.transplant.normal`` for :hg:`transplant` on other
578 578
579 579 These dot-separated lists of names are treated as hierarchical ones.
580 580 For example, ``changeset.tag.remove`` customizes the commit message
581 581 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
582 582 commit message for :hg:`tag` regardless of ``--remove`` option.
583 583
584 584 When the external editor is invoked for a commit, the corresponding
585 585 dot-separated list of names without the ``changeset.`` prefix
586 586 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
587 587 variable.
588 588
589 589 In this section, items other than ``changeset`` can be referred from
590 590 others. For example, the configuration to list committed files up
591 591 below can be referred as ``{listupfiles}``::
592 592
593 593 [committemplate]
594 594 listupfiles = {file_adds %
595 595 "HG: added {file}\n" }{file_mods %
596 596 "HG: changed {file}\n" }{file_dels %
597 597 "HG: removed {file}\n" }{if(files, "",
598 598 "HG: no files changed\n")}
599 599
600 600 ``decode/encode``
601 601 -----------------
602 602
603 603 Filters for transforming files on checkout/checkin. This would
604 604 typically be used for newline processing or other
605 605 localization/canonicalization of files.
606 606
607 607 Filters consist of a filter pattern followed by a filter command.
608 608 Filter patterns are globs by default, rooted at the repository root.
609 609 For example, to match any file ending in ``.txt`` in the root
610 610 directory only, use the pattern ``*.txt``. To match any file ending
611 611 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
612 612 For each file only the first matching filter applies.
613 613
614 614 The filter command can start with a specifier, either ``pipe:`` or
615 615 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
616 616
617 617 A ``pipe:`` command must accept data on stdin and return the transformed
618 618 data on stdout.
619 619
620 620 Pipe example::
621 621
622 622 [encode]
623 623 # uncompress gzip files on checkin to improve delta compression
624 624 # note: not necessarily a good idea, just an example
625 625 *.gz = pipe: gunzip
626 626
627 627 [decode]
628 628 # recompress gzip files when writing them to the working dir (we
629 629 # can safely omit "pipe:", because it's the default)
630 630 *.gz = gzip
631 631
632 632 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
633 633 with the name of a temporary file that contains the data to be
634 634 filtered by the command. The string ``OUTFILE`` is replaced with the name
635 635 of an empty temporary file, where the filtered data must be written by
636 636 the command.
637 637
638 638 .. container:: windows
639 639
640 640 .. note::
641 641
642 642 The tempfile mechanism is recommended for Windows systems,
643 643 where the standard shell I/O redirection operators often have
644 644 strange effects and may corrupt the contents of your files.
645 645
646 646 This filter mechanism is used internally by the ``eol`` extension to
647 647 translate line ending characters between Windows (CRLF) and Unix (LF)
648 648 format. We suggest you use the ``eol`` extension for convenience.
649 649
650 650
651 651 ``defaults``
652 652 ------------
653 653
654 654 (defaults are deprecated. Don't use them. Use aliases instead.)
655 655
656 656 Use the ``[defaults]`` section to define command defaults, i.e. the
657 657 default options/arguments to pass to the specified commands.
658 658
659 659 The following example makes :hg:`log` run in verbose mode, and
660 660 :hg:`status` show only the modified files, by default::
661 661
662 662 [defaults]
663 663 log = -v
664 664 status = -m
665 665
666 666 The actual commands, instead of their aliases, must be used when
667 667 defining command defaults. The command defaults will also be applied
668 668 to the aliases of the commands defined.
669 669
670 670
671 671 ``diff``
672 672 --------
673 673
674 674 Settings used when displaying diffs. Everything except for ``unified``
675 675 is a Boolean and defaults to False. See :hg:`help config.annotate`
676 676 for related options for the annotate command.
677 677
678 678 ``git``
679 679 Use git extended diff format.
680 680
681 681 ``nobinary``
682 682 Omit git binary patches.
683 683
684 684 ``nodates``
685 685 Don't include dates in diff headers.
686 686
687 687 ``noprefix``
688 688 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
689 689
690 690 ``showfunc``
691 691 Show which function each change is in.
692 692
693 693 ``ignorews``
694 694 Ignore white space when comparing lines.
695 695
696 696 ``ignorewsamount``
697 697 Ignore changes in the amount of white space.
698 698
699 699 ``ignoreblanklines``
700 700 Ignore changes whose lines are all blank.
701 701
702 702 ``unified``
703 703 Number of lines of context to show.
704 704
705 705 ``word-diff``
706 706 Highlight changed words.
707 707
708 708 ``email``
709 709 ---------
710 710
711 711 Settings for extensions that send email messages.
712 712
713 713 ``from``
714 714 Optional. Email address to use in "From" header and SMTP envelope
715 715 of outgoing messages.
716 716
717 717 ``to``
718 718 Optional. Comma-separated list of recipients' email addresses.
719 719
720 720 ``cc``
721 721 Optional. Comma-separated list of carbon copy recipients'
722 722 email addresses.
723 723
724 724 ``bcc``
725 725 Optional. Comma-separated list of blind carbon copy recipients'
726 726 email addresses.
727 727
728 728 ``method``
729 729 Optional. Method to use to send email messages. If value is ``smtp``
730 730 (default), use SMTP (see the ``[smtp]`` section for configuration).
731 731 Otherwise, use as name of program to run that acts like sendmail
732 732 (takes ``-f`` option for sender, list of recipients on command line,
733 733 message on stdin). Normally, setting this to ``sendmail`` or
734 734 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
735 735
736 736 ``charsets``
737 737 Optional. Comma-separated list of character sets considered
738 738 convenient for recipients. Addresses, headers, and parts not
739 739 containing patches of outgoing messages will be encoded in the
740 740 first character set to which conversion from local encoding
741 741 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
742 742 conversion fails, the text in question is sent as is.
743 743 (default: '')
744 744
745 745 Order of outgoing email character sets:
746 746
747 747 1. ``us-ascii``: always first, regardless of settings
748 748 2. ``email.charsets``: in order given by user
749 749 3. ``ui.fallbackencoding``: if not in email.charsets
750 750 4. ``$HGENCODING``: if not in email.charsets
751 751 5. ``utf-8``: always last, regardless of settings
752 752
753 753 Email example::
754 754
755 755 [email]
756 756 from = Joseph User <joe.user@example.com>
757 757 method = /usr/sbin/sendmail
758 758 # charsets for western Europeans
759 759 # us-ascii, utf-8 omitted, as they are tried first and last
760 760 charsets = iso-8859-1, iso-8859-15, windows-1252
761 761
762 762
763 763 ``extensions``
764 764 --------------
765 765
766 766 Mercurial has an extension mechanism for adding new features. To
767 767 enable an extension, create an entry for it in this section.
768 768
769 769 If you know that the extension is already in Python's search path,
770 770 you can give the name of the module, followed by ``=``, with nothing
771 771 after the ``=``.
772 772
773 773 Otherwise, give a name that you choose, followed by ``=``, followed by
774 774 the path to the ``.py`` file (including the file name extension) that
775 775 defines the extension.
776 776
777 777 To explicitly disable an extension that is enabled in an hgrc of
778 778 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
779 779 or ``foo = !`` when path is not supplied.
780 780
781 781 Example for ``~/.hgrc``::
782 782
783 783 [extensions]
784 784 # (the churn extension will get loaded from Mercurial's path)
785 785 churn =
786 786 # (this extension will get loaded from the file specified)
787 787 myfeature = ~/.hgext/myfeature.py
788 788
789 789
790 790 ``format``
791 791 ----------
792 792
793 793 Configuration that controls the repository format. Newer format options are more
794 794 powerful but incompatible with some older versions of Mercurial. Format options
795 795 are considered at repository initialization only. You need to make a new clone
796 796 for config change to be taken into account.
797 797
798 798 For more details about repository format and version compatibility, see
799 799 https://www.mercurial-scm.org/wiki/MissingRequirement
800 800
801 801 ``usegeneraldelta``
802 802 Enable or disable the "generaldelta" repository format which improves
803 803 repository compression by allowing "revlog" to store delta against arbitrary
804 804 revision instead of the previous stored one. This provides significant
805 805 improvement for repositories with branches.
806 806
807 807 Repositories with this on-disk format require Mercurial version 1.9.
808 808
809 809 Enabled by default.
810 810
811 811 ``dotencode``
812 812 Enable or disable the "dotencode" repository format which enhances
813 813 the "fncache" repository format (which has to be enabled to use
814 814 dotencode) to avoid issues with filenames starting with ._ on
815 815 Mac OS X and spaces on Windows.
816 816
817 817 Repositories with this on-disk format require Mercurial version 1.7.
818 818
819 819 Enabled by default.
820 820
821 821 ``usefncache``
822 822 Enable or disable the "fncache" repository format which enhances
823 823 the "store" repository format (which has to be enabled to use
824 824 fncache) to allow longer filenames and avoids using Windows
825 825 reserved names, e.g. "nul".
826 826
827 827 Repositories with this on-disk format require Mercurial version 1.1.
828 828
829 829 Enabled by default.
830 830
831 831 ``usestore``
832 832 Enable or disable the "store" repository format which improves
833 833 compatibility with systems that fold case or otherwise mangle
834 834 filenames. Disabling this option will allow you to store longer filenames
835 835 in some situations at the expense of compatibility.
836 836
837 837 Repositories with this on-disk format require Mercurial version 0.9.4.
838 838
839 839 Enabled by default.
840 840
841 841 ``graph``
842 842 ---------
843 843
844 844 Web graph view configuration. This section let you change graph
845 845 elements display properties by branches, for instance to make the
846 846 ``default`` branch stand out.
847 847
848 848 Each line has the following format::
849 849
850 850 <branch>.<argument> = <value>
851 851
852 852 where ``<branch>`` is the name of the branch being
853 853 customized. Example::
854 854
855 855 [graph]
856 856 # 2px width
857 857 default.width = 2
858 858 # red color
859 859 default.color = FF0000
860 860
861 861 Supported arguments:
862 862
863 863 ``width``
864 864 Set branch edges width in pixels.
865 865
866 866 ``color``
867 867 Set branch edges color in hexadecimal RGB notation.
868 868
869 869 ``hooks``
870 870 ---------
871 871
872 872 Commands or Python functions that get automatically executed by
873 873 various actions such as starting or finishing a commit. Multiple
874 874 hooks can be run for the same action by appending a suffix to the
875 875 action. Overriding a site-wide hook can be done by changing its
876 876 value or setting it to an empty string. Hooks can be prioritized
877 877 by adding a prefix of ``priority.`` to the hook name on a new line
878 878 and setting the priority. The default priority is 0.
879 879
880 880 Example ``.hg/hgrc``::
881 881
882 882 [hooks]
883 883 # update working directory after adding changesets
884 884 changegroup.update = hg update
885 885 # do not use the site-wide hook
886 886 incoming =
887 887 incoming.email = /my/email/hook
888 888 incoming.autobuild = /my/build/hook
889 889 # force autobuild hook to run before other incoming hooks
890 890 priority.incoming.autobuild = 1
891 891
892 892 Most hooks are run with environment variables set that give useful
893 893 additional information. For each hook below, the environment variables
894 894 it is passed are listed with names in the form ``$HG_foo``. The
895 895 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
896 896 They contain the type of hook which triggered the run and the full name
897 897 of the hook in the config, respectively. In the example above, this will
898 898 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
899 899
900 900 .. container:: windows
901 901
902 902 Some basic Unix syntax can be enabled for portability, including ``$VAR``
903 903 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
904 904 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
905 905 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
906 906 slash or inside of a strong quote. Strong quotes will be replaced by
907 907 double quotes after processing.
908 908
909 909 This feature is enabled by adding a prefix of ``tonative.`` to the hook
910 910 name on a new line, and setting it to ``True``. For example::
911 911
912 912 [hooks]
913 913 incoming.autobuild = /my/build/hook
914 914 # enable translation to cmd.exe syntax for autobuild hook
915 915 tonative.incoming.autobuild = True
916 916
917 917 ``changegroup``
918 918 Run after a changegroup has been added via push, pull or unbundle. The ID of
919 919 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
920 920 The URL from which changes came is in ``$HG_URL``.
921 921
922 922 ``commit``
923 923 Run after a changeset has been created in the local repository. The ID
924 924 of the newly created changeset is in ``$HG_NODE``. Parent changeset
925 925 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
926 926
927 927 ``incoming``
928 928 Run after a changeset has been pulled, pushed, or unbundled into
929 929 the local repository. The ID of the newly arrived changeset is in
930 930 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
931 931
932 932 ``outgoing``
933 933 Run after sending changes from the local repository to another. The ID of
934 934 first changeset sent is in ``$HG_NODE``. The source of operation is in
935 935 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
936 936
937 937 ``post-<command>``
938 938 Run after successful invocations of the associated command. The
939 939 contents of the command line are passed as ``$HG_ARGS`` and the result
940 940 code in ``$HG_RESULT``. Parsed command line arguments are passed as
941 941 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
942 942 the python data internally passed to <command>. ``$HG_OPTS`` is a
943 943 dictionary of options (with unspecified options set to their defaults).
944 944 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
945 945
946 946 ``fail-<command>``
947 947 Run after a failed invocation of an associated command. The contents
948 948 of the command line are passed as ``$HG_ARGS``. Parsed command line
949 949 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
950 950 string representations of the python data internally passed to
951 951 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
952 952 options set to their defaults). ``$HG_PATS`` is a list of arguments.
953 953 Hook failure is ignored.
954 954
955 955 ``pre-<command>``
956 956 Run before executing the associated command. The contents of the
957 957 command line are passed as ``$HG_ARGS``. Parsed command line arguments
958 958 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
959 959 representations of the data internally passed to <command>. ``$HG_OPTS``
960 960 is a dictionary of options (with unspecified options set to their
961 961 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
962 962 failure, the command doesn't execute and Mercurial returns the failure
963 963 code.
964 964
965 965 ``prechangegroup``
966 966 Run before a changegroup is added via push, pull or unbundle. Exit
967 967 status 0 allows the changegroup to proceed. A non-zero status will
968 968 cause the push, pull or unbundle to fail. The URL from which changes
969 969 will come is in ``$HG_URL``.
970 970
971 971 ``precommit``
972 972 Run before starting a local commit. Exit status 0 allows the
973 973 commit to proceed. A non-zero status will cause the commit to fail.
974 974 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
975 975
976 976 ``prelistkeys``
977 977 Run before listing pushkeys (like bookmarks) in the
978 978 repository. A non-zero status will cause failure. The key namespace is
979 979 in ``$HG_NAMESPACE``.
980 980
981 981 ``preoutgoing``
982 982 Run before collecting changes to send from the local repository to
983 983 another. A non-zero status will cause failure. This lets you prevent
984 984 pull over HTTP or SSH. It can also prevent propagating commits (via
985 985 local pull, push (outbound) or bundle commands), but not completely,
986 986 since you can just copy files instead. The source of operation is in
987 987 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
988 988 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
989 989 is happening on behalf of a repository on same system.
990 990
991 991 ``prepushkey``
992 992 Run before a pushkey (like a bookmark) is added to the
993 993 repository. A non-zero status will cause the key to be rejected. The
994 994 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
995 995 the old value (if any) is in ``$HG_OLD``, and the new value is in
996 996 ``$HG_NEW``.
997 997
998 998 ``pretag``
999 999 Run before creating a tag. Exit status 0 allows the tag to be
1000 1000 created. A non-zero status will cause the tag to fail. The ID of the
1001 1001 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1002 1002 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1003 1003
1004 1004 ``pretxnopen``
1005 1005 Run before any new repository transaction is open. The reason for the
1006 1006 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1007 1007 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
1008 1008 transaction from being opened.
1009 1009
1010 1010 ``pretxnclose``
1011 1011 Run right before the transaction is actually finalized. Any repository change
1012 1012 will be visible to the hook program. This lets you validate the transaction
1013 1013 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1014 1014 status will cause the transaction to be rolled back. The reason for the
1015 1015 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1016 1016 the transaction will be in ``HG_TXNID``. The rest of the available data will
1017 1017 vary according the transaction type. New changesets will add ``$HG_NODE``
1018 1018 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
1019 1019 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
1020 1020 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
1021 1021 respectively, etc.
1022 1022
1023 1023 ``pretxnclose-bookmark``
1024 1024 Run right before a bookmark change is actually finalized. Any repository
1025 1025 change will be visible to the hook program. This lets you validate the
1026 1026 transaction content or change it. Exit status 0 allows the commit to
1027 1027 proceed. A non-zero status will cause the transaction to be rolled back.
1028 1028 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1029 1029 bookmark location will be available in ``$HG_NODE`` while the previous
1030 1030 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1031 1031 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1032 1032 will be empty.
1033 1033 In addition, the reason for the transaction opening will be in
1034 1034 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1035 1035 ``HG_TXNID``.
1036 1036
1037 1037 ``pretxnclose-phase``
1038 1038 Run right before a phase change is actually finalized. Any repository change
1039 1039 will be visible to the hook program. This lets you validate the transaction
1040 1040 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1041 1041 status will cause the transaction to be rolled back. The hook is called
1042 1042 multiple times, once for each revision affected by a phase change.
1043 1043 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1044 1044 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1045 1045 will be empty. In addition, the reason for the transaction opening will be in
1046 1046 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1047 1047 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1048 1048 the ``$HG_OLDPHASE`` entry will be empty.
1049 1049
1050 1050 ``txnclose``
1051 1051 Run after any repository transaction has been committed. At this
1052 1052 point, the transaction can no longer be rolled back. The hook will run
1053 1053 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1054 1054 details about available variables.
1055 1055
1056 1056 ``txnclose-bookmark``
1057 1057 Run after any bookmark change has been committed. At this point, the
1058 1058 transaction can no longer be rolled back. The hook will run after the lock
1059 1059 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1060 1060 about available variables.
1061 1061
1062 1062 ``txnclose-phase``
1063 1063 Run after any phase change has been committed. At this point, the
1064 1064 transaction can no longer be rolled back. The hook will run after the lock
1065 1065 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1066 1066 available variables.
1067 1067
1068 1068 ``txnabort``
1069 1069 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1070 1070 for details about available variables.
1071 1071
1072 1072 ``pretxnchangegroup``
1073 1073 Run after a changegroup has been added via push, pull or unbundle, but before
1074 1074 the transaction has been committed. The changegroup is visible to the hook
1075 1075 program. This allows validation of incoming changes before accepting them.
1076 1076 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1077 1077 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1078 1078 status will cause the transaction to be rolled back, and the push, pull or
1079 1079 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1080 1080
1081 1081 ``pretxncommit``
1082 1082 Run after a changeset has been created, but before the transaction is
1083 1083 committed. The changeset is visible to the hook program. This allows
1084 1084 validation of the commit message and changes. Exit status 0 allows the
1085 1085 commit to proceed. A non-zero status will cause the transaction to
1086 1086 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1087 1087 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1088 1088
1089 1089 ``preupdate``
1090 1090 Run before updating the working directory. Exit status 0 allows
1091 1091 the update to proceed. A non-zero status will prevent the update.
1092 1092 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1093 1093 merge, the ID of second new parent is in ``$HG_PARENT2``.
1094 1094
1095 1095 ``listkeys``
1096 1096 Run after listing pushkeys (like bookmarks) in the repository. The
1097 1097 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1098 1098 dictionary containing the keys and values.
1099 1099
1100 1100 ``pushkey``
1101 1101 Run after a pushkey (like a bookmark) is added to the
1102 1102 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1103 1103 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1104 1104 value is in ``$HG_NEW``.
1105 1105
1106 1106 ``tag``
1107 1107 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1108 1108 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1109 1109 the repository if ``$HG_LOCAL=0``.
1110 1110
1111 1111 ``update``
1112 1112 Run after updating the working directory. The changeset ID of first
1113 1113 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1114 1114 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1115 1115 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1116 1116
1117 1117 .. note::
1118 1118
1119 1119 It is generally better to use standard hooks rather than the
1120 1120 generic pre- and post- command hooks, as they are guaranteed to be
1121 1121 called in the appropriate contexts for influencing transactions.
1122 1122 Also, hooks like "commit" will be called in all contexts that
1123 1123 generate a commit (e.g. tag) and not just the commit command.
1124 1124
1125 1125 .. note::
1126 1126
1127 1127 Environment variables with empty values may not be passed to
1128 1128 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1129 1129 will have an empty value under Unix-like platforms for non-merge
1130 1130 changesets, while it will not be available at all under Windows.
1131 1131
1132 1132 The syntax for Python hooks is as follows::
1133 1133
1134 1134 hookname = python:modulename.submodule.callable
1135 1135 hookname = python:/path/to/python/module.py:callable
1136 1136
1137 1137 Python hooks are run within the Mercurial process. Each hook is
1138 1138 called with at least three keyword arguments: a ui object (keyword
1139 1139 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1140 1140 keyword that tells what kind of hook is used. Arguments listed as
1141 1141 environment variables above are passed as keyword arguments, with no
1142 1142 ``HG_`` prefix, and names in lower case.
1143 1143
1144 1144 If a Python hook returns a "true" value or raises an exception, this
1145 1145 is treated as a failure.
1146 1146
1147 1147
1148 1148 ``hostfingerprints``
1149 1149 --------------------
1150 1150
1151 1151 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1152 1152
1153 1153 Fingerprints of the certificates of known HTTPS servers.
1154 1154
1155 1155 A HTTPS connection to a server with a fingerprint configured here will
1156 1156 only succeed if the servers certificate matches the fingerprint.
1157 1157 This is very similar to how ssh known hosts works.
1158 1158
1159 1159 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1160 1160 Multiple values can be specified (separated by spaces or commas). This can
1161 1161 be used to define both old and new fingerprints while a host transitions
1162 1162 to a new certificate.
1163 1163
1164 1164 The CA chain and web.cacerts is not used for servers with a fingerprint.
1165 1165
1166 1166 For example::
1167 1167
1168 1168 [hostfingerprints]
1169 1169 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1170 1170 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1171 1171
1172 1172 ``hostsecurity``
1173 1173 ----------------
1174 1174
1175 1175 Used to specify global and per-host security settings for connecting to
1176 1176 other machines.
1177 1177
1178 1178 The following options control default behavior for all hosts.
1179 1179
1180 1180 ``ciphers``
1181 1181 Defines the cryptographic ciphers to use for connections.
1182 1182
1183 1183 Value must be a valid OpenSSL Cipher List Format as documented at
1184 1184 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1185 1185
1186 1186 This setting is for advanced users only. Setting to incorrect values
1187 1187 can significantly lower connection security or decrease performance.
1188 1188 You have been warned.
1189 1189
1190 1190 This option requires Python 2.7.
1191 1191
1192 1192 ``minimumprotocol``
1193 1193 Defines the minimum channel encryption protocol to use.
1194 1194
1195 1195 By default, the highest version of TLS supported by both client and server
1196 1196 is used.
1197 1197
1198 1198 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1199 1199
1200 1200 When running on an old Python version, only ``tls1.0`` is allowed since
1201 1201 old versions of Python only support up to TLS 1.0.
1202 1202
1203 1203 When running a Python that supports modern TLS versions, the default is
1204 1204 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1205 1205 weakens security and should only be used as a feature of last resort if
1206 1206 a server does not support TLS 1.1+.
1207 1207
1208 1208 Options in the ``[hostsecurity]`` section can have the form
1209 1209 ``hostname``:``setting``. This allows multiple settings to be defined on a
1210 1210 per-host basis.
1211 1211
1212 1212 The following per-host settings can be defined.
1213 1213
1214 1214 ``ciphers``
1215 1215 This behaves like ``ciphers`` as described above except it only applies
1216 1216 to the host on which it is defined.
1217 1217
1218 1218 ``fingerprints``
1219 1219 A list of hashes of the DER encoded peer/remote certificate. Values have
1220 1220 the form ``algorithm``:``fingerprint``. e.g.
1221 1221 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1222 1222 In addition, colons (``:``) can appear in the fingerprint part.
1223 1223
1224 1224 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1225 1225 ``sha512``.
1226 1226
1227 1227 Use of ``sha256`` or ``sha512`` is preferred.
1228 1228
1229 1229 If a fingerprint is specified, the CA chain is not validated for this
1230 1230 host and Mercurial will require the remote certificate to match one
1231 1231 of the fingerprints specified. This means if the server updates its
1232 1232 certificate, Mercurial will abort until a new fingerprint is defined.
1233 1233 This can provide stronger security than traditional CA-based validation
1234 1234 at the expense of convenience.
1235 1235
1236 1236 This option takes precedence over ``verifycertsfile``.
1237 1237
1238 1238 ``minimumprotocol``
1239 1239 This behaves like ``minimumprotocol`` as described above except it
1240 1240 only applies to the host on which it is defined.
1241 1241
1242 1242 ``verifycertsfile``
1243 1243 Path to file a containing a list of PEM encoded certificates used to
1244 1244 verify the server certificate. Environment variables and ``~user``
1245 1245 constructs are expanded in the filename.
1246 1246
1247 1247 The server certificate or the certificate's certificate authority (CA)
1248 1248 must match a certificate from this file or certificate verification
1249 1249 will fail and connections to the server will be refused.
1250 1250
1251 1251 If defined, only certificates provided by this file will be used:
1252 1252 ``web.cacerts`` and any system/default certificates will not be
1253 1253 used.
1254 1254
1255 1255 This option has no effect if the per-host ``fingerprints`` option
1256 1256 is set.
1257 1257
1258 1258 The format of the file is as follows::
1259 1259
1260 1260 -----BEGIN CERTIFICATE-----
1261 1261 ... (certificate in base64 PEM encoding) ...
1262 1262 -----END CERTIFICATE-----
1263 1263 -----BEGIN CERTIFICATE-----
1264 1264 ... (certificate in base64 PEM encoding) ...
1265 1265 -----END CERTIFICATE-----
1266 1266
1267 1267 For example::
1268 1268
1269 1269 [hostsecurity]
1270 1270 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1271 1271 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
1272 1272 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
1273 1273 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1274 1274
1275 1275 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1276 1276 when connecting to ``hg.example.com``::
1277 1277
1278 1278 [hostsecurity]
1279 1279 minimumprotocol = tls1.2
1280 1280 hg.example.com:minimumprotocol = tls1.1
1281 1281
1282 1282 ``http_proxy``
1283 1283 --------------
1284 1284
1285 1285 Used to access web-based Mercurial repositories through a HTTP
1286 1286 proxy.
1287 1287
1288 1288 ``host``
1289 1289 Host name and (optional) port of the proxy server, for example
1290 1290 "myproxy:8000".
1291 1291
1292 1292 ``no``
1293 1293 Optional. Comma-separated list of host names that should bypass
1294 1294 the proxy.
1295 1295
1296 1296 ``passwd``
1297 1297 Optional. Password to authenticate with at the proxy server.
1298 1298
1299 1299 ``user``
1300 1300 Optional. User name to authenticate with at the proxy server.
1301 1301
1302 1302 ``always``
1303 1303 Optional. Always use the proxy, even for localhost and any entries
1304 1304 in ``http_proxy.no``. (default: False)
1305 1305
1306 1306 ``merge``
1307 1307 ---------
1308 1308
1309 1309 This section specifies behavior during merges and updates.
1310 1310
1311 1311 ``checkignored``
1312 1312 Controls behavior when an ignored file on disk has the same name as a tracked
1313 1313 file in the changeset being merged or updated to, and has different
1314 1314 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1315 1315 abort on such files. With ``warn``, warn on such files and back them up as
1316 1316 ``.orig``. With ``ignore``, don't print a warning and back them up as
1317 1317 ``.orig``. (default: ``abort``)
1318 1318
1319 1319 ``checkunknown``
1320 1320 Controls behavior when an unknown file that isn't ignored has the same name
1321 1321 as a tracked file in the changeset being merged or updated to, and has
1322 1322 different contents. Similar to ``merge.checkignored``, except for files that
1323 1323 are not ignored. (default: ``abort``)
1324 1324
1325 1325 ``on-failure``
1326 1326 When set to ``continue`` (the default), the merge process attempts to
1327 1327 merge all unresolved files using the merge chosen tool, regardless of
1328 1328 whether previous file merge attempts during the process succeeded or not.
1329 1329 Setting this to ``prompt`` will prompt after any merge failure continue
1330 1330 or halt the merge process. Setting this to ``halt`` will automatically
1331 1331 halt the merge process on any merge tool failure. The merge process
1332 1332 can be restarted by using the ``resolve`` command. When a merge is
1333 1333 halted, the repository is left in a normal ``unresolved`` merge state.
1334 1334 (default: ``continue``)
1335 1335
1336 1336 ``merge-patterns``
1337 1337 ------------------
1338 1338
1339 1339 This section specifies merge tools to associate with particular file
1340 1340 patterns. Tools matched here will take precedence over the default
1341 1341 merge tool. Patterns are globs by default, rooted at the repository
1342 1342 root.
1343 1343
1344 1344 Example::
1345 1345
1346 1346 [merge-patterns]
1347 1347 **.c = kdiff3
1348 1348 **.jpg = myimgmerge
1349 1349
1350 1350 ``merge-tools``
1351 1351 ---------------
1352 1352
1353 1353 This section configures external merge tools to use for file-level
1354 1354 merges. This section has likely been preconfigured at install time.
1355 1355 Use :hg:`config merge-tools` to check the existing configuration.
1356 1356 Also see :hg:`help merge-tools` for more details.
1357 1357
1358 1358 Example ``~/.hgrc``::
1359 1359
1360 1360 [merge-tools]
1361 1361 # Override stock tool location
1362 1362 kdiff3.executable = ~/bin/kdiff3
1363 1363 # Specify command line
1364 1364 kdiff3.args = $base $local $other -o $output
1365 1365 # Give higher priority
1366 1366 kdiff3.priority = 1
1367 1367
1368 1368 # Changing the priority of preconfigured tool
1369 1369 meld.priority = 0
1370 1370
1371 1371 # Disable a preconfigured tool
1372 1372 vimdiff.disabled = yes
1373 1373
1374 1374 # Define new tool
1375 1375 myHtmlTool.args = -m $local $other $base $output
1376 1376 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1377 1377 myHtmlTool.priority = 1
1378 1378
1379 1379 Supported arguments:
1380 1380
1381 1381 ``priority``
1382 1382 The priority in which to evaluate this tool.
1383 1383 (default: 0)
1384 1384
1385 1385 ``executable``
1386 1386 Either just the name of the executable or its pathname.
1387 1387
1388 1388 .. container:: windows
1389 1389
1390 1390 On Windows, the path can use environment variables with ${ProgramFiles}
1391 1391 syntax.
1392 1392
1393 1393 (default: the tool name)
1394 1394
1395 1395 ``args``
1396 1396 The arguments to pass to the tool executable. You can refer to the
1397 1397 files being merged as well as the output file through these
1398 1398 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1399 1399
1400 1400 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1401 1401 being performed. During an update or merge, ``$local`` represents the original
1402 1402 state of the file, while ``$other`` represents the commit you are updating to or
1403 1403 the commit you are merging with. During a rebase, ``$local`` represents the
1404 1404 destination of the rebase, and ``$other`` represents the commit being rebased.
1405 1405
1406 1406 Some operations define custom labels to assist with identifying the revisions,
1407 1407 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1408 1408 labels are not available, these will be ``local``, ``other``, and ``base``,
1409 1409 respectively.
1410 1410 (default: ``$local $base $other``)
1411 1411
1412 1412 ``premerge``
1413 1413 Attempt to run internal non-interactive 3-way merge tool before
1414 1414 launching external tool. Options are ``true``, ``false``, ``keep`` or
1415 1415 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1416 1416 premerge fails. The ``keep-merge3`` will do the same but include information
1417 1417 about the base of the merge in the marker (see internal :merge3 in
1418 1418 :hg:`help merge-tools`).
1419 1419 (default: True)
1420 1420
1421 1421 ``binary``
1422 1422 This tool can merge binary files. (default: False, unless tool
1423 1423 was selected by file pattern match)
1424 1424
1425 1425 ``symlink``
1426 1426 This tool can merge symlinks. (default: False)
1427 1427
1428 1428 ``check``
1429 1429 A list of merge success-checking options:
1430 1430
1431 1431 ``changed``
1432 1432 Ask whether merge was successful when the merged file shows no changes.
1433 1433 ``conflicts``
1434 1434 Check whether there are conflicts even though the tool reported success.
1435 1435 ``prompt``
1436 1436 Always prompt for merge success, regardless of success reported by tool.
1437 1437
1438 1438 ``fixeol``
1439 1439 Attempt to fix up EOL changes caused by the merge tool.
1440 1440 (default: False)
1441 1441
1442 1442 ``gui``
1443 1443 This tool requires a graphical interface to run. (default: False)
1444 1444
1445 1445 ``mergemarkers``
1446 1446 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1447 1447 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1448 1448 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1449 1449 markers generated during premerge will be ``detailed`` if either this option or
1450 1450 the corresponding option in the ``[ui]`` section is ``detailed``.
1451 1451 (default: ``basic``)
1452 1452
1453 1453 ``mergemarkertemplate``
1454 1454 This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
1455 1455 section on a per-tool basis; this applies to the ``$label``-prefixed variables
1456 1456 and to the conflict markers that are generated if ``premerge`` is ``keep` or
1457 1457 ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
1458 1458 information.
1459 1459
1460 1460 .. container:: windows
1461 1461
1462 1462 ``regkey``
1463 1463 Windows registry key which describes install location of this
1464 1464 tool. Mercurial will search for this key first under
1465 1465 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1466 1466 (default: None)
1467 1467
1468 1468 ``regkeyalt``
1469 1469 An alternate Windows registry key to try if the first key is not
1470 1470 found. The alternate key uses the same ``regname`` and ``regappend``
1471 1471 semantics of the primary key. The most common use for this key
1472 1472 is to search for 32bit applications on 64bit operating systems.
1473 1473 (default: None)
1474 1474
1475 1475 ``regname``
1476 1476 Name of value to read from specified registry key.
1477 1477 (default: the unnamed (default) value)
1478 1478
1479 1479 ``regappend``
1480 1480 String to append to the value read from the registry, typically
1481 1481 the executable name of the tool.
1482 1482 (default: None)
1483 1483
1484 1484 ``pager``
1485 1485 ---------
1486 1486
1487 1487 Setting used to control when to paginate and with what external tool. See
1488 1488 :hg:`help pager` for details.
1489 1489
1490 1490 ``pager``
1491 1491 Define the external tool used as pager.
1492 1492
1493 1493 If no pager is set, Mercurial uses the environment variable $PAGER.
1494 1494 If neither pager.pager, nor $PAGER is set, a default pager will be
1495 1495 used, typically `less` on Unix and `more` on Windows. Example::
1496 1496
1497 1497 [pager]
1498 1498 pager = less -FRX
1499 1499
1500 1500 ``ignore``
1501 1501 List of commands to disable the pager for. Example::
1502 1502
1503 1503 [pager]
1504 1504 ignore = version, help, update
1505 1505
1506 1506 ``patch``
1507 1507 ---------
1508 1508
1509 1509 Settings used when applying patches, for instance through the 'import'
1510 1510 command or with Mercurial Queues extension.
1511 1511
1512 1512 ``eol``
1513 1513 When set to 'strict' patch content and patched files end of lines
1514 1514 are preserved. When set to ``lf`` or ``crlf``, both files end of
1515 1515 lines are ignored when patching and the result line endings are
1516 1516 normalized to either LF (Unix) or CRLF (Windows). When set to
1517 1517 ``auto``, end of lines are again ignored while patching but line
1518 1518 endings in patched files are normalized to their original setting
1519 1519 on a per-file basis. If target file does not exist or has no end
1520 1520 of line, patch line endings are preserved.
1521 1521 (default: strict)
1522 1522
1523 1523 ``fuzz``
1524 1524 The number of lines of 'fuzz' to allow when applying patches. This
1525 1525 controls how much context the patcher is allowed to ignore when
1526 1526 trying to apply a patch.
1527 1527 (default: 2)
1528 1528
1529 1529 ``paths``
1530 1530 ---------
1531 1531
1532 1532 Assigns symbolic names and behavior to repositories.
1533 1533
1534 1534 Options are symbolic names defining the URL or directory that is the
1535 1535 location of the repository. Example::
1536 1536
1537 1537 [paths]
1538 1538 my_server = https://example.com/my_repo
1539 1539 local_path = /home/me/repo
1540 1540
1541 1541 These symbolic names can be used from the command line. To pull
1542 1542 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1543 1543 :hg:`push local_path`.
1544 1544
1545 1545 Options containing colons (``:``) denote sub-options that can influence
1546 1546 behavior for that specific path. Example::
1547 1547
1548 1548 [paths]
1549 1549 my_server = https://example.com/my_path
1550 1550 my_server:pushurl = ssh://example.com/my_path
1551 1551
1552 1552 The following sub-options can be defined:
1553 1553
1554 1554 ``pushurl``
1555 1555 The URL to use for push operations. If not defined, the location
1556 1556 defined by the path's main entry is used.
1557 1557
1558 1558 ``pushrev``
1559 1559 A revset defining which revisions to push by default.
1560 1560
1561 1561 When :hg:`push` is executed without a ``-r`` argument, the revset
1562 1562 defined by this sub-option is evaluated to determine what to push.
1563 1563
1564 1564 For example, a value of ``.`` will push the working directory's
1565 1565 revision by default.
1566 1566
1567 1567 Revsets specifying bookmarks will not result in the bookmark being
1568 1568 pushed.
1569 1569
1570 1570 The following special named paths exist:
1571 1571
1572 1572 ``default``
1573 1573 The URL or directory to use when no source or remote is specified.
1574 1574
1575 1575 :hg:`clone` will automatically define this path to the location the
1576 1576 repository was cloned from.
1577 1577
1578 1578 ``default-push``
1579 1579 (deprecated) The URL or directory for the default :hg:`push` location.
1580 1580 ``default:pushurl`` should be used instead.
1581 1581
1582 1582 ``phases``
1583 1583 ----------
1584 1584
1585 1585 Specifies default handling of phases. See :hg:`help phases` for more
1586 1586 information about working with phases.
1587 1587
1588 1588 ``publish``
1589 1589 Controls draft phase behavior when working as a server. When true,
1590 1590 pushed changesets are set to public in both client and server and
1591 1591 pulled or cloned changesets are set to public in the client.
1592 1592 (default: True)
1593 1593
1594 1594 ``new-commit``
1595 1595 Phase of newly-created commits.
1596 1596 (default: draft)
1597 1597
1598 1598 ``checksubrepos``
1599 1599 Check the phase of the current revision of each subrepository. Allowed
1600 1600 values are "ignore", "follow" and "abort". For settings other than
1601 1601 "ignore", the phase of the current revision of each subrepository is
1602 1602 checked before committing the parent repository. If any of those phases is
1603 1603 greater than the phase of the parent repository (e.g. if a subrepo is in a
1604 1604 "secret" phase while the parent repo is in "draft" phase), the commit is
1605 1605 either aborted (if checksubrepos is set to "abort") or the higher phase is
1606 1606 used for the parent repository commit (if set to "follow").
1607 1607 (default: follow)
1608 1608
1609 1609
1610 1610 ``profiling``
1611 1611 -------------
1612 1612
1613 1613 Specifies profiling type, format, and file output. Two profilers are
1614 1614 supported: an instrumenting profiler (named ``ls``), and a sampling
1615 1615 profiler (named ``stat``).
1616 1616
1617 1617 In this section description, 'profiling data' stands for the raw data
1618 1618 collected during profiling, while 'profiling report' stands for a
1619 1619 statistical text report generated from the profiling data.
1620 1620
1621 1621 ``enabled``
1622 1622 Enable the profiler.
1623 1623 (default: false)
1624 1624
1625 1625 This is equivalent to passing ``--profile`` on the command line.
1626 1626
1627 1627 ``type``
1628 1628 The type of profiler to use.
1629 1629 (default: stat)
1630 1630
1631 1631 ``ls``
1632 1632 Use Python's built-in instrumenting profiler. This profiler
1633 1633 works on all platforms, but each line number it reports is the
1634 1634 first line of a function. This restriction makes it difficult to
1635 1635 identify the expensive parts of a non-trivial function.
1636 1636 ``stat``
1637 1637 Use a statistical profiler, statprof. This profiler is most
1638 1638 useful for profiling commands that run for longer than about 0.1
1639 1639 seconds.
1640 1640
1641 1641 ``format``
1642 1642 Profiling format. Specific to the ``ls`` instrumenting profiler.
1643 1643 (default: text)
1644 1644
1645 1645 ``text``
1646 1646 Generate a profiling report. When saving to a file, it should be
1647 1647 noted that only the report is saved, and the profiling data is
1648 1648 not kept.
1649 1649 ``kcachegrind``
1650 1650 Format profiling data for kcachegrind use: when saving to a
1651 1651 file, the generated file can directly be loaded into
1652 1652 kcachegrind.
1653 1653
1654 1654 ``statformat``
1655 1655 Profiling format for the ``stat`` profiler.
1656 1656 (default: hotpath)
1657 1657
1658 1658 ``hotpath``
1659 1659 Show a tree-based display containing the hot path of execution (where
1660 1660 most time was spent).
1661 1661 ``bymethod``
1662 1662 Show a table of methods ordered by how frequently they are active.
1663 1663 ``byline``
1664 1664 Show a table of lines in files ordered by how frequently they are active.
1665 1665 ``json``
1666 1666 Render profiling data as JSON.
1667 1667
1668 1668 ``frequency``
1669 1669 Sampling frequency. Specific to the ``stat`` sampling profiler.
1670 1670 (default: 1000)
1671 1671
1672 1672 ``output``
1673 1673 File path where profiling data or report should be saved. If the
1674 1674 file exists, it is replaced. (default: None, data is printed on
1675 1675 stderr)
1676 1676
1677 1677 ``sort``
1678 1678 Sort field. Specific to the ``ls`` instrumenting profiler.
1679 1679 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1680 1680 ``inlinetime``.
1681 1681 (default: inlinetime)
1682 1682
1683 1683 ``time-track``
1684 1684 Control if the stat profiler track ``cpu`` or ``real`` time.
1685 1685 (default: ``cpu``)
1686 1686
1687 1687 ``limit``
1688 1688 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1689 1689 (default: 30)
1690 1690
1691 1691 ``nested``
1692 1692 Show at most this number of lines of drill-down info after each main entry.
1693 1693 This can help explain the difference between Total and Inline.
1694 1694 Specific to the ``ls`` instrumenting profiler.
1695 1695 (default: 0)
1696 1696
1697 1697 ``showmin``
1698 1698 Minimum fraction of samples an entry must have for it to be displayed.
1699 1699 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1700 1700 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1701 1701
1702 1702 Only used by the ``stat`` profiler.
1703 1703
1704 1704 For the ``hotpath`` format, default is ``0.05``.
1705 1705 For the ``chrome`` format, default is ``0.005``.
1706 1706
1707 1707 The option is unused on other formats.
1708 1708
1709 1709 ``showmax``
1710 1710 Maximum fraction of samples an entry can have before it is ignored in
1711 1711 display. Values format is the same as ``showmin``.
1712 1712
1713 1713 Only used by the ``stat`` profiler.
1714 1714
1715 1715 For the ``chrome`` format, default is ``0.999``.
1716 1716
1717 1717 The option is unused on other formats.
1718 1718
1719 1719 ``progress``
1720 1720 ------------
1721 1721
1722 1722 Mercurial commands can draw progress bars that are as informative as
1723 1723 possible. Some progress bars only offer indeterminate information, while others
1724 1724 have a definite end point.
1725 1725
1726 1726 ``delay``
1727 1727 Number of seconds (float) before showing the progress bar. (default: 3)
1728 1728
1729 1729 ``changedelay``
1730 1730 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1731 1731 that value will be used instead. (default: 1)
1732 1732
1733 1733 ``estimateinterval``
1734 1734 Maximum sampling interval in seconds for speed and estimated time
1735 1735 calculation. (default: 60)
1736 1736
1737 1737 ``refresh``
1738 1738 Time in seconds between refreshes of the progress bar. (default: 0.1)
1739 1739
1740 1740 ``format``
1741 1741 Format of the progress bar.
1742 1742
1743 1743 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1744 1744 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1745 1745 last 20 characters of the item, but this can be changed by adding either
1746 1746 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1747 1747 first num characters.
1748 1748
1749 1749 (default: topic bar number estimate)
1750 1750
1751 1751 ``width``
1752 1752 If set, the maximum width of the progress information (that is, min(width,
1753 1753 term width) will be used).
1754 1754
1755 1755 ``clear-complete``
1756 1756 Clear the progress bar after it's done. (default: True)
1757 1757
1758 1758 ``disable``
1759 1759 If true, don't show a progress bar.
1760 1760
1761 1761 ``assume-tty``
1762 1762 If true, ALWAYS show a progress bar, unless disable is given.
1763 1763
1764 1764 ``rebase``
1765 1765 ----------
1766 1766
1767 1767 ``evolution.allowdivergence``
1768 1768 Default to False, when True allow creating divergence when performing
1769 1769 rebase of obsolete changesets.
1770 1770
1771 1771 ``revsetalias``
1772 1772 ---------------
1773 1773
1774 1774 Alias definitions for revsets. See :hg:`help revsets` for details.
1775 1775
1776 ``revlog``
1776 ``storage``
1777 1777 ----------
1778 1778
1779 1779 Control the strategy Mercurial uses internally to store history. Options in this
1780 1780 category impact performance and repository size.
1781 1781
1782 ``optimize-delta-parent-choice``
1782 ``revlog.optimize-delta-parent-choice``
1783 1783 When storing a merge revision, both parents will be equally considered as
1784 1784 a possible delta base. This results in better delta selection and improved
1785 1785 revlog compression. This option is enabled by default.
1786 1786
1787 1787 Turning this option off can result in large increase of repository size for
1788 1788 repository with many merges.
1789 1789
1790 1790 ``server``
1791 1791 ----------
1792 1792
1793 1793 Controls generic server settings.
1794 1794
1795 1795 ``bookmarks-pushkey-compat``
1796 1796 Trigger pushkey hook when being pushed bookmark updates. This config exist
1797 1797 for compatibility purpose (default to True)
1798 1798
1799 1799 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1800 1800 movement we recommend you migrate them to ``txnclose-bookmark`` and
1801 1801 ``pretxnclose-bookmark``.
1802 1802
1803 1803 ``compressionengines``
1804 1804 List of compression engines and their relative priority to advertise
1805 1805 to clients.
1806 1806
1807 1807 The order of compression engines determines their priority, the first
1808 1808 having the highest priority. If a compression engine is not listed
1809 1809 here, it won't be advertised to clients.
1810 1810
1811 1811 If not set (the default), built-in defaults are used. Run
1812 1812 :hg:`debuginstall` to list available compression engines and their
1813 1813 default wire protocol priority.
1814 1814
1815 1815 Older Mercurial clients only support zlib compression and this setting
1816 1816 has no effect for legacy clients.
1817 1817
1818 1818 ``uncompressed``
1819 1819 Whether to allow clients to clone a repository using the
1820 1820 uncompressed streaming protocol. This transfers about 40% more
1821 1821 data than a regular clone, but uses less memory and CPU on both
1822 1822 server and client. Over a LAN (100 Mbps or better) or a very fast
1823 1823 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1824 1824 regular clone. Over most WAN connections (anything slower than
1825 1825 about 6 Mbps), uncompressed streaming is slower, because of the
1826 1826 extra data transfer overhead. This mode will also temporarily hold
1827 1827 the write lock while determining what data to transfer.
1828 1828 (default: True)
1829 1829
1830 1830 ``uncompressedallowsecret``
1831 1831 Whether to allow stream clones when the repository contains secret
1832 1832 changesets. (default: False)
1833 1833
1834 1834 ``preferuncompressed``
1835 1835 When set, clients will try to use the uncompressed streaming
1836 1836 protocol. (default: False)
1837 1837
1838 1838 ``disablefullbundle``
1839 1839 When set, servers will refuse attempts to do pull-based clones.
1840 1840 If this option is set, ``preferuncompressed`` and/or clone bundles
1841 1841 are highly recommended. Partial clones will still be allowed.
1842 1842 (default: False)
1843 1843
1844 1844 ``streamunbundle``
1845 1845 When set, servers will apply data sent from the client directly,
1846 1846 otherwise it will be written to a temporary file first. This option
1847 1847 effectively prevents concurrent pushes.
1848 1848
1849 1849 ``pullbundle``
1850 1850 When set, the server will check pullbundle.manifest for bundles
1851 1851 covering the requested heads and common nodes. The first matching
1852 1852 entry will be streamed to the client.
1853 1853
1854 1854 For HTTP transport, the stream will still use zlib compression
1855 1855 for older clients.
1856 1856
1857 1857 ``concurrent-push-mode``
1858 1858 Level of allowed race condition between two pushing clients.
1859 1859
1860 1860 - 'strict': push is abort if another client touched the repository
1861 1861 while the push was preparing. (default)
1862 1862 - 'check-related': push is only aborted if it affects head that got also
1863 1863 affected while the push was preparing.
1864 1864
1865 1865 This requires compatible client (version 4.3 and later). Old client will
1866 1866 use 'strict'.
1867 1867
1868 1868 ``validate``
1869 1869 Whether to validate the completeness of pushed changesets by
1870 1870 checking that all new file revisions specified in manifests are
1871 1871 present. (default: False)
1872 1872
1873 1873 ``maxhttpheaderlen``
1874 1874 Instruct HTTP clients not to send request headers longer than this
1875 1875 many bytes. (default: 1024)
1876 1876
1877 1877 ``bundle1``
1878 1878 Whether to allow clients to push and pull using the legacy bundle1
1879 1879 exchange format. (default: True)
1880 1880
1881 1881 ``bundle1gd``
1882 1882 Like ``bundle1`` but only used if the repository is using the
1883 1883 *generaldelta* storage format. (default: True)
1884 1884
1885 1885 ``bundle1.push``
1886 1886 Whether to allow clients to push using the legacy bundle1 exchange
1887 1887 format. (default: True)
1888 1888
1889 1889 ``bundle1gd.push``
1890 1890 Like ``bundle1.push`` but only used if the repository is using the
1891 1891 *generaldelta* storage format. (default: True)
1892 1892
1893 1893 ``bundle1.pull``
1894 1894 Whether to allow clients to pull using the legacy bundle1 exchange
1895 1895 format. (default: True)
1896 1896
1897 1897 ``bundle1gd.pull``
1898 1898 Like ``bundle1.pull`` but only used if the repository is using the
1899 1899 *generaldelta* storage format. (default: True)
1900 1900
1901 1901 Large repositories using the *generaldelta* storage format should
1902 1902 consider setting this option because converting *generaldelta*
1903 1903 repositories to the exchange format required by the bundle1 data
1904 1904 format can consume a lot of CPU.
1905 1905
1906 1906 ``zliblevel``
1907 1907 Integer between ``-1`` and ``9`` that controls the zlib compression level
1908 1908 for wire protocol commands that send zlib compressed output (notably the
1909 1909 commands that send repository history data).
1910 1910
1911 1911 The default (``-1``) uses the default zlib compression level, which is
1912 1912 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1913 1913 maximum compression.
1914 1914
1915 1915 Setting this option allows server operators to make trade-offs between
1916 1916 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1917 1917 but sends more bytes to clients.
1918 1918
1919 1919 This option only impacts the HTTP server.
1920 1920
1921 1921 ``zstdlevel``
1922 1922 Integer between ``1`` and ``22`` that controls the zstd compression level
1923 1923 for wire protocol commands. ``1`` is the minimal amount of compression and
1924 1924 ``22`` is the highest amount of compression.
1925 1925
1926 1926 The default (``3``) should be significantly faster than zlib while likely
1927 1927 delivering better compression ratios.
1928 1928
1929 1929 This option only impacts the HTTP server.
1930 1930
1931 1931 See also ``server.zliblevel``.
1932 1932
1933 1933 ``smtp``
1934 1934 --------
1935 1935
1936 1936 Configuration for extensions that need to send email messages.
1937 1937
1938 1938 ``host``
1939 1939 Host name of mail server, e.g. "mail.example.com".
1940 1940
1941 1941 ``port``
1942 1942 Optional. Port to connect to on mail server. (default: 465 if
1943 1943 ``tls`` is smtps; 25 otherwise)
1944 1944
1945 1945 ``tls``
1946 1946 Optional. Method to enable TLS when connecting to mail server: starttls,
1947 1947 smtps or none. (default: none)
1948 1948
1949 1949 ``username``
1950 1950 Optional. User name for authenticating with the SMTP server.
1951 1951 (default: None)
1952 1952
1953 1953 ``password``
1954 1954 Optional. Password for authenticating with the SMTP server. If not
1955 1955 specified, interactive sessions will prompt the user for a
1956 1956 password; non-interactive sessions will fail. (default: None)
1957 1957
1958 1958 ``local_hostname``
1959 1959 Optional. The hostname that the sender can use to identify
1960 1960 itself to the MTA.
1961 1961
1962 1962
1963 1963 ``subpaths``
1964 1964 ------------
1965 1965
1966 1966 Subrepository source URLs can go stale if a remote server changes name
1967 1967 or becomes temporarily unavailable. This section lets you define
1968 1968 rewrite rules of the form::
1969 1969
1970 1970 <pattern> = <replacement>
1971 1971
1972 1972 where ``pattern`` is a regular expression matching a subrepository
1973 1973 source URL and ``replacement`` is the replacement string used to
1974 1974 rewrite it. Groups can be matched in ``pattern`` and referenced in
1975 1975 ``replacements``. For instance::
1976 1976
1977 1977 http://server/(.*)-hg/ = http://hg.server/\1/
1978 1978
1979 1979 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1980 1980
1981 1981 Relative subrepository paths are first made absolute, and the
1982 1982 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1983 1983 doesn't match the full path, an attempt is made to apply it on the
1984 1984 relative path alone. The rules are applied in definition order.
1985 1985
1986 1986 ``subrepos``
1987 1987 ------------
1988 1988
1989 1989 This section contains options that control the behavior of the
1990 1990 subrepositories feature. See also :hg:`help subrepos`.
1991 1991
1992 1992 Security note: auditing in Mercurial is known to be insufficient to
1993 1993 prevent clone-time code execution with carefully constructed Git
1994 1994 subrepos. It is unknown if a similar detect is present in Subversion
1995 1995 subrepos. Both Git and Subversion subrepos are disabled by default
1996 1996 out of security concerns. These subrepo types can be enabled using
1997 1997 the respective options below.
1998 1998
1999 1999 ``allowed``
2000 2000 Whether subrepositories are allowed in the working directory.
2001 2001
2002 2002 When false, commands involving subrepositories (like :hg:`update`)
2003 2003 will fail for all subrepository types.
2004 2004 (default: true)
2005 2005
2006 2006 ``hg:allowed``
2007 2007 Whether Mercurial subrepositories are allowed in the working
2008 2008 directory. This option only has an effect if ``subrepos.allowed``
2009 2009 is true.
2010 2010 (default: true)
2011 2011
2012 2012 ``git:allowed``
2013 2013 Whether Git subrepositories are allowed in the working directory.
2014 2014 This option only has an effect if ``subrepos.allowed`` is true.
2015 2015
2016 2016 See the security note above before enabling Git subrepos.
2017 2017 (default: false)
2018 2018
2019 2019 ``svn:allowed``
2020 2020 Whether Subversion subrepositories are allowed in the working
2021 2021 directory. This option only has an effect if ``subrepos.allowed``
2022 2022 is true.
2023 2023
2024 2024 See the security note above before enabling Subversion subrepos.
2025 2025 (default: false)
2026 2026
2027 2027 ``templatealias``
2028 2028 -----------------
2029 2029
2030 2030 Alias definitions for templates. See :hg:`help templates` for details.
2031 2031
2032 2032 ``templates``
2033 2033 -------------
2034 2034
2035 2035 Use the ``[templates]`` section to define template strings.
2036 2036 See :hg:`help templates` for details.
2037 2037
2038 2038 ``trusted``
2039 2039 -----------
2040 2040
2041 2041 Mercurial will not use the settings in the
2042 2042 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2043 2043 user or to a trusted group, as various hgrc features allow arbitrary
2044 2044 commands to be run. This issue is often encountered when configuring
2045 2045 hooks or extensions for shared repositories or servers. However,
2046 2046 the web interface will use some safe settings from the ``[web]``
2047 2047 section.
2048 2048
2049 2049 This section specifies what users and groups are trusted. The
2050 2050 current user is always trusted. To trust everybody, list a user or a
2051 2051 group with name ``*``. These settings must be placed in an
2052 2052 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2053 2053 user or service running Mercurial.
2054 2054
2055 2055 ``users``
2056 2056 Comma-separated list of trusted users.
2057 2057
2058 2058 ``groups``
2059 2059 Comma-separated list of trusted groups.
2060 2060
2061 2061
2062 2062 ``ui``
2063 2063 ------
2064 2064
2065 2065 User interface controls.
2066 2066
2067 2067 ``archivemeta``
2068 2068 Whether to include the .hg_archival.txt file containing meta data
2069 2069 (hashes for the repository base and for tip) in archives created
2070 2070 by the :hg:`archive` command or downloaded via hgweb.
2071 2071 (default: True)
2072 2072
2073 2073 ``askusername``
2074 2074 Whether to prompt for a username when committing. If True, and
2075 2075 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2076 2076 be prompted to enter a username. If no username is entered, the
2077 2077 default ``USER@HOST`` is used instead.
2078 2078 (default: False)
2079 2079
2080 2080 ``clonebundles``
2081 2081 Whether the "clone bundles" feature is enabled.
2082 2082
2083 2083 When enabled, :hg:`clone` may download and apply a server-advertised
2084 2084 bundle file from a URL instead of using the normal exchange mechanism.
2085 2085
2086 2086 This can likely result in faster and more reliable clones.
2087 2087
2088 2088 (default: True)
2089 2089
2090 2090 ``clonebundlefallback``
2091 2091 Whether failure to apply an advertised "clone bundle" from a server
2092 2092 should result in fallback to a regular clone.
2093 2093
2094 2094 This is disabled by default because servers advertising "clone
2095 2095 bundles" often do so to reduce server load. If advertised bundles
2096 2096 start mass failing and clients automatically fall back to a regular
2097 2097 clone, this would add significant and unexpected load to the server
2098 2098 since the server is expecting clone operations to be offloaded to
2099 2099 pre-generated bundles. Failing fast (the default behavior) ensures
2100 2100 clients don't overwhelm the server when "clone bundle" application
2101 2101 fails.
2102 2102
2103 2103 (default: False)
2104 2104
2105 2105 ``clonebundleprefers``
2106 2106 Defines preferences for which "clone bundles" to use.
2107 2107
2108 2108 Servers advertising "clone bundles" may advertise multiple available
2109 2109 bundles. Each bundle may have different attributes, such as the bundle
2110 2110 type and compression format. This option is used to prefer a particular
2111 2111 bundle over another.
2112 2112
2113 2113 The following keys are defined by Mercurial:
2114 2114
2115 2115 BUNDLESPEC
2116 2116 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2117 2117 e.g. ``gzip-v2`` or ``bzip2-v1``.
2118 2118
2119 2119 COMPRESSION
2120 2120 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2121 2121
2122 2122 Server operators may define custom keys.
2123 2123
2124 2124 Example values: ``COMPRESSION=bzip2``,
2125 2125 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2126 2126
2127 2127 By default, the first bundle advertised by the server is used.
2128 2128
2129 2129 ``color``
2130 2130 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2131 2131 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2132 2132 seems possible. See :hg:`help color` for details.
2133 2133
2134 2134 ``commitsubrepos``
2135 2135 Whether to commit modified subrepositories when committing the
2136 2136 parent repository. If False and one subrepository has uncommitted
2137 2137 changes, abort the commit.
2138 2138 (default: False)
2139 2139
2140 2140 ``debug``
2141 2141 Print debugging information. (default: False)
2142 2142
2143 2143 ``editor``
2144 2144 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2145 2145
2146 2146 ``fallbackencoding``
2147 2147 Encoding to try if it's not possible to decode the changelog using
2148 2148 UTF-8. (default: ISO-8859-1)
2149 2149
2150 2150 ``graphnodetemplate``
2151 2151 The template used to print changeset nodes in an ASCII revision graph.
2152 2152 (default: ``{graphnode}``)
2153 2153
2154 2154 ``ignore``
2155 2155 A file to read per-user ignore patterns from. This file should be
2156 2156 in the same format as a repository-wide .hgignore file. Filenames
2157 2157 are relative to the repository root. This option supports hook syntax,
2158 2158 so if you want to specify multiple ignore files, you can do so by
2159 2159 setting something like ``ignore.other = ~/.hgignore2``. For details
2160 2160 of the ignore file format, see the ``hgignore(5)`` man page.
2161 2161
2162 2162 ``interactive``
2163 2163 Allow to prompt the user. (default: True)
2164 2164
2165 2165 ``interface``
2166 2166 Select the default interface for interactive features (default: text).
2167 2167 Possible values are 'text' and 'curses'.
2168 2168
2169 2169 ``interface.chunkselector``
2170 2170 Select the interface for change recording (e.g. :hg:`commit -i`).
2171 2171 Possible values are 'text' and 'curses'.
2172 2172 This config overrides the interface specified by ui.interface.
2173 2173
2174 2174 ``large-file-limit``
2175 2175 Largest file size that gives no memory use warning.
2176 2176 Possible values are integers or 0 to disable the check.
2177 2177 (default: 10000000)
2178 2178
2179 2179 ``logtemplate``
2180 2180 Template string for commands that print changesets.
2181 2181
2182 2182 ``merge``
2183 2183 The conflict resolution program to use during a manual merge.
2184 2184 For more information on merge tools see :hg:`help merge-tools`.
2185 2185 For configuring merge tools see the ``[merge-tools]`` section.
2186 2186
2187 2187 ``mergemarkers``
2188 2188 Sets the merge conflict marker label styling. The ``detailed``
2189 2189 style uses the ``mergemarkertemplate`` setting to style the labels.
2190 2190 The ``basic`` style just uses 'local' and 'other' as the marker label.
2191 2191 One of ``basic`` or ``detailed``.
2192 2192 (default: ``basic``)
2193 2193
2194 2194 ``mergemarkertemplate``
2195 2195 The template used to print the commit description next to each conflict
2196 2196 marker during merge conflicts. See :hg:`help templates` for the template
2197 2197 format.
2198 2198
2199 2199 Defaults to showing the hash, tags, branches, bookmarks, author, and
2200 2200 the first line of the commit description.
2201 2201
2202 2202 If you use non-ASCII characters in names for tags, branches, bookmarks,
2203 2203 authors, and/or commit descriptions, you must pay attention to encodings of
2204 2204 managed files. At template expansion, non-ASCII characters use the encoding
2205 2205 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2206 2206 environment variables that govern your locale. If the encoding of the merge
2207 2207 markers is different from the encoding of the merged files,
2208 2208 serious problems may occur.
2209 2209
2210 2210 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2211 2211
2212 2212 ``origbackuppath``
2213 2213 The path to a directory used to store generated .orig files. If the path is
2214 2214 not a directory, one will be created. If set, files stored in this
2215 2215 directory have the same name as the original file and do not have a .orig
2216 2216 suffix.
2217 2217
2218 2218 ``paginate``
2219 2219 Control the pagination of command output (default: True). See :hg:`help pager`
2220 2220 for details.
2221 2221
2222 2222 ``patch``
2223 2223 An optional external tool that ``hg import`` and some extensions
2224 2224 will use for applying patches. By default Mercurial uses an
2225 2225 internal patch utility. The external tool must work as the common
2226 2226 Unix ``patch`` program. In particular, it must accept a ``-p``
2227 2227 argument to strip patch headers, a ``-d`` argument to specify the
2228 2228 current directory, a file name to patch, and a patch file to take
2229 2229 from stdin.
2230 2230
2231 2231 It is possible to specify a patch tool together with extra
2232 2232 arguments. For example, setting this option to ``patch --merge``
2233 2233 will use the ``patch`` program with its 2-way merge option.
2234 2234
2235 2235 ``portablefilenames``
2236 2236 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2237 2237 (default: ``warn``)
2238 2238
2239 2239 ``warn``
2240 2240 Print a warning message on POSIX platforms, if a file with a non-portable
2241 2241 filename is added (e.g. a file with a name that can't be created on
2242 2242 Windows because it contains reserved parts like ``AUX``, reserved
2243 2243 characters like ``:``, or would cause a case collision with an existing
2244 2244 file).
2245 2245
2246 2246 ``ignore``
2247 2247 Don't print a warning.
2248 2248
2249 2249 ``abort``
2250 2250 The command is aborted.
2251 2251
2252 2252 ``true``
2253 2253 Alias for ``warn``.
2254 2254
2255 2255 ``false``
2256 2256 Alias for ``ignore``.
2257 2257
2258 2258 .. container:: windows
2259 2259
2260 2260 On Windows, this configuration option is ignored and the command aborted.
2261 2261
2262 2262 ``quiet``
2263 2263 Reduce the amount of output printed.
2264 2264 (default: False)
2265 2265
2266 2266 ``remotecmd``
2267 2267 Remote command to use for clone/push/pull operations.
2268 2268 (default: ``hg``)
2269 2269
2270 2270 ``report_untrusted``
2271 2271 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2272 2272 trusted user or group.
2273 2273 (default: True)
2274 2274
2275 2275 ``slash``
2276 2276 (Deprecated. Use ``slashpath`` template filter instead.)
2277 2277
2278 2278 Display paths using a slash (``/``) as the path separator. This
2279 2279 only makes a difference on systems where the default path
2280 2280 separator is not the slash character (e.g. Windows uses the
2281 2281 backslash character (``\``)).
2282 2282 (default: False)
2283 2283
2284 2284 ``statuscopies``
2285 2285 Display copies in the status command.
2286 2286
2287 2287 ``ssh``
2288 2288 Command to use for SSH connections. (default: ``ssh``)
2289 2289
2290 2290 ``ssherrorhint``
2291 2291 A hint shown to the user in the case of SSH error (e.g.
2292 2292 ``Please see http://company/internalwiki/ssh.html``)
2293 2293
2294 2294 ``strict``
2295 2295 Require exact command names, instead of allowing unambiguous
2296 2296 abbreviations. (default: False)
2297 2297
2298 2298 ``style``
2299 2299 Name of style to use for command output.
2300 2300
2301 2301 ``supportcontact``
2302 2302 A URL where users should report a Mercurial traceback. Use this if you are a
2303 2303 large organisation with its own Mercurial deployment process and crash
2304 2304 reports should be addressed to your internal support.
2305 2305
2306 2306 ``textwidth``
2307 2307 Maximum width of help text. A longer line generated by ``hg help`` or
2308 2308 ``hg subcommand --help`` will be broken after white space to get this
2309 2309 width or the terminal width, whichever comes first.
2310 2310 A non-positive value will disable this and the terminal width will be
2311 2311 used. (default: 78)
2312 2312
2313 2313 ``timeout``
2314 2314 The timeout used when a lock is held (in seconds), a negative value
2315 2315 means no timeout. (default: 600)
2316 2316
2317 2317 ``timeout.warn``
2318 2318 Time (in seconds) before a warning is printed about held lock. A negative
2319 2319 value means no warning. (default: 0)
2320 2320
2321 2321 ``traceback``
2322 2322 Mercurial always prints a traceback when an unknown exception
2323 2323 occurs. Setting this to True will make Mercurial print a traceback
2324 2324 on all exceptions, even those recognized by Mercurial (such as
2325 2325 IOError or MemoryError). (default: False)
2326 2326
2327 2327 ``tweakdefaults``
2328 2328
2329 2329 By default Mercurial's behavior changes very little from release
2330 2330 to release, but over time the recommended config settings
2331 2331 shift. Enable this config to opt in to get automatic tweaks to
2332 2332 Mercurial's behavior over time. This config setting will have no
2333 2333 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2334 2334 not include ``tweakdefaults``. (default: False)
2335 2335
2336 2336 ``username``
2337 2337 The committer of a changeset created when running "commit".
2338 2338 Typically a person's name and email address, e.g. ``Fred Widget
2339 2339 <fred@example.com>``. Environment variables in the
2340 2340 username are expanded.
2341 2341
2342 2342 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2343 2343 hgrc is empty, e.g. if the system admin set ``username =`` in the
2344 2344 system hgrc, it has to be specified manually or in a different
2345 2345 hgrc file)
2346 2346
2347 2347 ``verbose``
2348 2348 Increase the amount of output printed. (default: False)
2349 2349
2350 2350
2351 2351 ``web``
2352 2352 -------
2353 2353
2354 2354 Web interface configuration. The settings in this section apply to
2355 2355 both the builtin webserver (started by :hg:`serve`) and the script you
2356 2356 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2357 2357 and WSGI).
2358 2358
2359 2359 The Mercurial webserver does no authentication (it does not prompt for
2360 2360 usernames and passwords to validate *who* users are), but it does do
2361 2361 authorization (it grants or denies access for *authenticated users*
2362 2362 based on settings in this section). You must either configure your
2363 2363 webserver to do authentication for you, or disable the authorization
2364 2364 checks.
2365 2365
2366 2366 For a quick setup in a trusted environment, e.g., a private LAN, where
2367 2367 you want it to accept pushes from anybody, you can use the following
2368 2368 command line::
2369 2369
2370 2370 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2371 2371
2372 2372 Note that this will allow anybody to push anything to the server and
2373 2373 that this should not be used for public servers.
2374 2374
2375 2375 The full set of options is:
2376 2376
2377 2377 ``accesslog``
2378 2378 Where to output the access log. (default: stdout)
2379 2379
2380 2380 ``address``
2381 2381 Interface address to bind to. (default: all)
2382 2382
2383 2383 ``allow-archive``
2384 2384 List of archive format (bz2, gz, zip) allowed for downloading.
2385 2385 (default: empty)
2386 2386
2387 2387 ``allowbz2``
2388 2388 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2389 2389 revisions.
2390 2390 (default: False)
2391 2391
2392 2392 ``allowgz``
2393 2393 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2394 2394 revisions.
2395 2395 (default: False)
2396 2396
2397 2397 ``allow-pull``
2398 2398 Whether to allow pulling from the repository. (default: True)
2399 2399
2400 2400 ``allow-push``
2401 2401 Whether to allow pushing to the repository. If empty or not set,
2402 2402 pushing is not allowed. If the special value ``*``, any remote
2403 2403 user can push, including unauthenticated users. Otherwise, the
2404 2404 remote user must have been authenticated, and the authenticated
2405 2405 user name must be present in this list. The contents of the
2406 2406 allow-push list are examined after the deny_push list.
2407 2407
2408 2408 ``allow_read``
2409 2409 If the user has not already been denied repository access due to
2410 2410 the contents of deny_read, this list determines whether to grant
2411 2411 repository access to the user. If this list is not empty, and the
2412 2412 user is unauthenticated or not present in the list, then access is
2413 2413 denied for the user. If the list is empty or not set, then access
2414 2414 is permitted to all users by default. Setting allow_read to the
2415 2415 special value ``*`` is equivalent to it not being set (i.e. access
2416 2416 is permitted to all users). The contents of the allow_read list are
2417 2417 examined after the deny_read list.
2418 2418
2419 2419 ``allowzip``
2420 2420 (DEPRECATED) Whether to allow .zip downloading of repository
2421 2421 revisions. This feature creates temporary files.
2422 2422 (default: False)
2423 2423
2424 2424 ``archivesubrepos``
2425 2425 Whether to recurse into subrepositories when archiving.
2426 2426 (default: False)
2427 2427
2428 2428 ``baseurl``
2429 2429 Base URL to use when publishing URLs in other locations, so
2430 2430 third-party tools like email notification hooks can construct
2431 2431 URLs. Example: ``http://hgserver/repos/``.
2432 2432
2433 2433 ``cacerts``
2434 2434 Path to file containing a list of PEM encoded certificate
2435 2435 authority certificates. Environment variables and ``~user``
2436 2436 constructs are expanded in the filename. If specified on the
2437 2437 client, then it will verify the identity of remote HTTPS servers
2438 2438 with these certificates.
2439 2439
2440 2440 To disable SSL verification temporarily, specify ``--insecure`` from
2441 2441 command line.
2442 2442
2443 2443 You can use OpenSSL's CA certificate file if your platform has
2444 2444 one. On most Linux systems this will be
2445 2445 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2446 2446 generate this file manually. The form must be as follows::
2447 2447
2448 2448 -----BEGIN CERTIFICATE-----
2449 2449 ... (certificate in base64 PEM encoding) ...
2450 2450 -----END CERTIFICATE-----
2451 2451 -----BEGIN CERTIFICATE-----
2452 2452 ... (certificate in base64 PEM encoding) ...
2453 2453 -----END CERTIFICATE-----
2454 2454
2455 2455 ``cache``
2456 2456 Whether to support caching in hgweb. (default: True)
2457 2457
2458 2458 ``certificate``
2459 2459 Certificate to use when running :hg:`serve`.
2460 2460
2461 2461 ``collapse``
2462 2462 With ``descend`` enabled, repositories in subdirectories are shown at
2463 2463 a single level alongside repositories in the current path. With
2464 2464 ``collapse`` also enabled, repositories residing at a deeper level than
2465 2465 the current path are grouped behind navigable directory entries that
2466 2466 lead to the locations of these repositories. In effect, this setting
2467 2467 collapses each collection of repositories found within a subdirectory
2468 2468 into a single entry for that subdirectory. (default: False)
2469 2469
2470 2470 ``comparisoncontext``
2471 2471 Number of lines of context to show in side-by-side file comparison. If
2472 2472 negative or the value ``full``, whole files are shown. (default: 5)
2473 2473
2474 2474 This setting can be overridden by a ``context`` request parameter to the
2475 2475 ``comparison`` command, taking the same values.
2476 2476
2477 2477 ``contact``
2478 2478 Name or email address of the person in charge of the repository.
2479 2479 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2480 2480
2481 2481 ``csp``
2482 2482 Send a ``Content-Security-Policy`` HTTP header with this value.
2483 2483
2484 2484 The value may contain a special string ``%nonce%``, which will be replaced
2485 2485 by a randomly-generated one-time use value. If the value contains
2486 2486 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2487 2487 one-time property of the nonce. This nonce will also be inserted into
2488 2488 ``<script>`` elements containing inline JavaScript.
2489 2489
2490 2490 Note: lots of HTML content sent by the server is derived from repository
2491 2491 data. Please consider the potential for malicious repository data to
2492 2492 "inject" itself into generated HTML content as part of your security
2493 2493 threat model.
2494 2494
2495 2495 ``deny_push``
2496 2496 Whether to deny pushing to the repository. If empty or not set,
2497 2497 push is not denied. If the special value ``*``, all remote users are
2498 2498 denied push. Otherwise, unauthenticated users are all denied, and
2499 2499 any authenticated user name present in this list is also denied. The
2500 2500 contents of the deny_push list are examined before the allow-push list.
2501 2501
2502 2502 ``deny_read``
2503 2503 Whether to deny reading/viewing of the repository. If this list is
2504 2504 not empty, unauthenticated users are all denied, and any
2505 2505 authenticated user name present in this list is also denied access to
2506 2506 the repository. If set to the special value ``*``, all remote users
2507 2507 are denied access (rarely needed ;). If deny_read is empty or not set,
2508 2508 the determination of repository access depends on the presence and
2509 2509 content of the allow_read list (see description). If both
2510 2510 deny_read and allow_read are empty or not set, then access is
2511 2511 permitted to all users by default. If the repository is being
2512 2512 served via hgwebdir, denied users will not be able to see it in
2513 2513 the list of repositories. The contents of the deny_read list have
2514 2514 priority over (are examined before) the contents of the allow_read
2515 2515 list.
2516 2516
2517 2517 ``descend``
2518 2518 hgwebdir indexes will not descend into subdirectories. Only repositories
2519 2519 directly in the current path will be shown (other repositories are still
2520 2520 available from the index corresponding to their containing path).
2521 2521
2522 2522 ``description``
2523 2523 Textual description of the repository's purpose or contents.
2524 2524 (default: "unknown")
2525 2525
2526 2526 ``encoding``
2527 2527 Character encoding name. (default: the current locale charset)
2528 2528 Example: "UTF-8".
2529 2529
2530 2530 ``errorlog``
2531 2531 Where to output the error log. (default: stderr)
2532 2532
2533 2533 ``guessmime``
2534 2534 Control MIME types for raw download of file content.
2535 2535 Set to True to let hgweb guess the content type from the file
2536 2536 extension. This will serve HTML files as ``text/html`` and might
2537 2537 allow cross-site scripting attacks when serving untrusted
2538 2538 repositories. (default: False)
2539 2539
2540 2540 ``hidden``
2541 2541 Whether to hide the repository in the hgwebdir index.
2542 2542 (default: False)
2543 2543
2544 2544 ``ipv6``
2545 2545 Whether to use IPv6. (default: False)
2546 2546
2547 2547 ``labels``
2548 2548 List of string *labels* associated with the repository.
2549 2549
2550 2550 Labels are exposed as a template keyword and can be used to customize
2551 2551 output. e.g. the ``index`` template can group or filter repositories
2552 2552 by labels and the ``summary`` template can display additional content
2553 2553 if a specific label is present.
2554 2554
2555 2555 ``logoimg``
2556 2556 File name of the logo image that some templates display on each page.
2557 2557 The file name is relative to ``staticurl``. That is, the full path to
2558 2558 the logo image is "staticurl/logoimg".
2559 2559 If unset, ``hglogo.png`` will be used.
2560 2560
2561 2561 ``logourl``
2562 2562 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2563 2563 will be used.
2564 2564
2565 2565 ``maxchanges``
2566 2566 Maximum number of changes to list on the changelog. (default: 10)
2567 2567
2568 2568 ``maxfiles``
2569 2569 Maximum number of files to list per changeset. (default: 10)
2570 2570
2571 2571 ``maxshortchanges``
2572 2572 Maximum number of changes to list on the shortlog, graph or filelog
2573 2573 pages. (default: 60)
2574 2574
2575 2575 ``name``
2576 2576 Repository name to use in the web interface.
2577 2577 (default: current working directory)
2578 2578
2579 2579 ``port``
2580 2580 Port to listen on. (default: 8000)
2581 2581
2582 2582 ``prefix``
2583 2583 Prefix path to serve from. (default: '' (server root))
2584 2584
2585 2585 ``push_ssl``
2586 2586 Whether to require that inbound pushes be transported over SSL to
2587 2587 prevent password sniffing. (default: True)
2588 2588
2589 2589 ``refreshinterval``
2590 2590 How frequently directory listings re-scan the filesystem for new
2591 2591 repositories, in seconds. This is relevant when wildcards are used
2592 2592 to define paths. Depending on how much filesystem traversal is
2593 2593 required, refreshing may negatively impact performance.
2594 2594
2595 2595 Values less than or equal to 0 always refresh.
2596 2596 (default: 20)
2597 2597
2598 2598 ``server-header``
2599 2599 Value for HTTP ``Server`` response header.
2600 2600
2601 2601 ``staticurl``
2602 2602 Base URL to use for static files. If unset, static files (e.g. the
2603 2603 hgicon.png favicon) will be served by the CGI script itself. Use
2604 2604 this setting to serve them directly with the HTTP server.
2605 2605 Example: ``http://hgserver/static/``.
2606 2606
2607 2607 ``stripes``
2608 2608 How many lines a "zebra stripe" should span in multi-line output.
2609 2609 Set to 0 to disable. (default: 1)
2610 2610
2611 2611 ``style``
2612 2612 Which template map style to use. The available options are the names of
2613 2613 subdirectories in the HTML templates path. (default: ``paper``)
2614 2614 Example: ``monoblue``.
2615 2615
2616 2616 ``templates``
2617 2617 Where to find the HTML templates. The default path to the HTML templates
2618 2618 can be obtained from ``hg debuginstall``.
2619 2619
2620 2620 ``websub``
2621 2621 ----------
2622 2622
2623 2623 Web substitution filter definition. You can use this section to
2624 2624 define a set of regular expression substitution patterns which
2625 2625 let you automatically modify the hgweb server output.
2626 2626
2627 2627 The default hgweb templates only apply these substitution patterns
2628 2628 on the revision description fields. You can apply them anywhere
2629 2629 you want when you create your own templates by adding calls to the
2630 2630 "websub" filter (usually after calling the "escape" filter).
2631 2631
2632 2632 This can be used, for example, to convert issue references to links
2633 2633 to your issue tracker, or to convert "markdown-like" syntax into
2634 2634 HTML (see the examples below).
2635 2635
2636 2636 Each entry in this section names a substitution filter.
2637 2637 The value of each entry defines the substitution expression itself.
2638 2638 The websub expressions follow the old interhg extension syntax,
2639 2639 which in turn imitates the Unix sed replacement syntax::
2640 2640
2641 2641 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2642 2642
2643 2643 You can use any separator other than "/". The final "i" is optional
2644 2644 and indicates that the search must be case insensitive.
2645 2645
2646 2646 Examples::
2647 2647
2648 2648 [websub]
2649 2649 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2650 2650 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2651 2651 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2652 2652
2653 2653 ``worker``
2654 2654 ----------
2655 2655
2656 2656 Parallel master/worker configuration. We currently perform working
2657 2657 directory updates in parallel on Unix-like systems, which greatly
2658 2658 helps performance.
2659 2659
2660 2660 ``enabled``
2661 2661 Whether to enable workers code to be used.
2662 2662 (default: true)
2663 2663
2664 2664 ``numcpus``
2665 2665 Number of CPUs to use for parallel operations. A zero or
2666 2666 negative value is treated as ``use the default``.
2667 2667 (default: 4 or the number of CPUs on the system, whichever is larger)
2668 2668
2669 2669 ``backgroundclose``
2670 2670 Whether to enable closing file handles on background threads during certain
2671 2671 operations. Some platforms aren't very efficient at closing file
2672 2672 handles that have been written or appended to. By performing file closing
2673 2673 on background threads, file write rate can increase substantially.
2674 2674 (default: true on Windows, false elsewhere)
2675 2675
2676 2676 ``backgroundcloseminfilecount``
2677 2677 Minimum number of files required to trigger background file closing.
2678 2678 Operations not writing this many files won't start background close
2679 2679 threads.
2680 2680 (default: 2048)
2681 2681
2682 2682 ``backgroundclosemaxqueue``
2683 2683 The maximum number of opened file handles waiting to be closed in the
2684 2684 background. This option only has an effect if ``backgroundclose`` is
2685 2685 enabled.
2686 2686 (default: 384)
2687 2687
2688 2688 ``backgroundclosethreadcount``
2689 2689 Number of threads to process background file closes. Only relevant if
2690 2690 ``backgroundclose`` is enabled.
2691 2691 (default: 4)
@@ -1,2395 +1,2395 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 hex,
21 21 nullid,
22 22 short,
23 23 )
24 24 from . import (
25 25 bookmarks,
26 26 branchmap,
27 27 bundle2,
28 28 changegroup,
29 29 changelog,
30 30 color,
31 31 context,
32 32 dirstate,
33 33 dirstateguard,
34 34 discovery,
35 35 encoding,
36 36 error,
37 37 exchange,
38 38 extensions,
39 39 filelog,
40 40 hook,
41 41 lock as lockmod,
42 42 manifest,
43 43 match as matchmod,
44 44 merge as mergemod,
45 45 mergeutil,
46 46 namespaces,
47 47 narrowspec,
48 48 obsolete,
49 49 pathutil,
50 50 phases,
51 51 pushkey,
52 52 pycompat,
53 53 repository,
54 54 repoview,
55 55 revset,
56 56 revsetlang,
57 57 scmutil,
58 58 sparse,
59 59 store,
60 60 subrepoutil,
61 61 tags as tagsmod,
62 62 transaction,
63 63 txnutil,
64 64 util,
65 65 vfs as vfsmod,
66 66 )
67 67 from .utils import (
68 68 interfaceutil,
69 69 procutil,
70 70 stringutil,
71 71 )
72 72
73 73 release = lockmod.release
74 74 urlerr = util.urlerr
75 75 urlreq = util.urlreq
76 76
77 77 # set of (path, vfs-location) tuples. vfs-location is:
78 78 # - 'plain for vfs relative paths
79 79 # - '' for svfs relative paths
80 80 _cachedfiles = set()
81 81
82 82 class _basefilecache(scmutil.filecache):
83 83 """All filecache usage on repo are done for logic that should be unfiltered
84 84 """
85 85 def __get__(self, repo, type=None):
86 86 if repo is None:
87 87 return self
88 88 return super(_basefilecache, self).__get__(repo.unfiltered(), type)
89 89 def __set__(self, repo, value):
90 90 return super(_basefilecache, self).__set__(repo.unfiltered(), value)
91 91 def __delete__(self, repo):
92 92 return super(_basefilecache, self).__delete__(repo.unfiltered())
93 93
94 94 class repofilecache(_basefilecache):
95 95 """filecache for files in .hg but outside of .hg/store"""
96 96 def __init__(self, *paths):
97 97 super(repofilecache, self).__init__(*paths)
98 98 for path in paths:
99 99 _cachedfiles.add((path, 'plain'))
100 100
101 101 def join(self, obj, fname):
102 102 return obj.vfs.join(fname)
103 103
104 104 class storecache(_basefilecache):
105 105 """filecache for files in the store"""
106 106 def __init__(self, *paths):
107 107 super(storecache, self).__init__(*paths)
108 108 for path in paths:
109 109 _cachedfiles.add((path, ''))
110 110
111 111 def join(self, obj, fname):
112 112 return obj.sjoin(fname)
113 113
114 114 def isfilecached(repo, name):
115 115 """check if a repo has already cached "name" filecache-ed property
116 116
117 117 This returns (cachedobj-or-None, iscached) tuple.
118 118 """
119 119 cacheentry = repo.unfiltered()._filecache.get(name, None)
120 120 if not cacheentry:
121 121 return None, False
122 122 return cacheentry.obj, True
123 123
124 124 class unfilteredpropertycache(util.propertycache):
125 125 """propertycache that apply to unfiltered repo only"""
126 126
127 127 def __get__(self, repo, type=None):
128 128 unfi = repo.unfiltered()
129 129 if unfi is repo:
130 130 return super(unfilteredpropertycache, self).__get__(unfi)
131 131 return getattr(unfi, self.name)
132 132
133 133 class filteredpropertycache(util.propertycache):
134 134 """propertycache that must take filtering in account"""
135 135
136 136 def cachevalue(self, obj, value):
137 137 object.__setattr__(obj, self.name, value)
138 138
139 139
140 140 def hasunfilteredcache(repo, name):
141 141 """check if a repo has an unfilteredpropertycache value for <name>"""
142 142 return name in vars(repo.unfiltered())
143 143
144 144 def unfilteredmethod(orig):
145 145 """decorate method that always need to be run on unfiltered version"""
146 146 def wrapper(repo, *args, **kwargs):
147 147 return orig(repo.unfiltered(), *args, **kwargs)
148 148 return wrapper
149 149
150 150 moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
151 151 'unbundle'}
152 152 legacycaps = moderncaps.union({'changegroupsubset'})
153 153
154 154 @interfaceutil.implementer(repository.ipeercommandexecutor)
155 155 class localcommandexecutor(object):
156 156 def __init__(self, peer):
157 157 self._peer = peer
158 158 self._sent = False
159 159 self._closed = False
160 160
161 161 def __enter__(self):
162 162 return self
163 163
164 164 def __exit__(self, exctype, excvalue, exctb):
165 165 self.close()
166 166
167 167 def callcommand(self, command, args):
168 168 if self._sent:
169 169 raise error.ProgrammingError('callcommand() cannot be used after '
170 170 'sendcommands()')
171 171
172 172 if self._closed:
173 173 raise error.ProgrammingError('callcommand() cannot be used after '
174 174 'close()')
175 175
176 176 # We don't need to support anything fancy. Just call the named
177 177 # method on the peer and return a resolved future.
178 178 fn = getattr(self._peer, pycompat.sysstr(command))
179 179
180 180 f = pycompat.futures.Future()
181 181
182 182 try:
183 183 result = fn(**pycompat.strkwargs(args))
184 184 except Exception:
185 185 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
186 186 else:
187 187 f.set_result(result)
188 188
189 189 return f
190 190
191 191 def sendcommands(self):
192 192 self._sent = True
193 193
194 194 def close(self):
195 195 self._closed = True
196 196
197 197 @interfaceutil.implementer(repository.ipeercommands)
198 198 class localpeer(repository.peer):
199 199 '''peer for a local repo; reflects only the most recent API'''
200 200
201 201 def __init__(self, repo, caps=None):
202 202 super(localpeer, self).__init__()
203 203
204 204 if caps is None:
205 205 caps = moderncaps.copy()
206 206 self._repo = repo.filtered('served')
207 207 self.ui = repo.ui
208 208 self._caps = repo._restrictcapabilities(caps)
209 209
210 210 # Begin of _basepeer interface.
211 211
212 212 def url(self):
213 213 return self._repo.url()
214 214
215 215 def local(self):
216 216 return self._repo
217 217
218 218 def peer(self):
219 219 return self
220 220
221 221 def canpush(self):
222 222 return True
223 223
224 224 def close(self):
225 225 self._repo.close()
226 226
227 227 # End of _basepeer interface.
228 228
229 229 # Begin of _basewirecommands interface.
230 230
231 231 def branchmap(self):
232 232 return self._repo.branchmap()
233 233
234 234 def capabilities(self):
235 235 return self._caps
236 236
237 237 def clonebundles(self):
238 238 return self._repo.tryread('clonebundles.manifest')
239 239
240 240 def debugwireargs(self, one, two, three=None, four=None, five=None):
241 241 """Used to test argument passing over the wire"""
242 242 return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
243 243 pycompat.bytestr(four),
244 244 pycompat.bytestr(five))
245 245
246 246 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
247 247 **kwargs):
248 248 chunks = exchange.getbundlechunks(self._repo, source, heads=heads,
249 249 common=common, bundlecaps=bundlecaps,
250 250 **kwargs)[1]
251 251 cb = util.chunkbuffer(chunks)
252 252
253 253 if exchange.bundle2requested(bundlecaps):
254 254 # When requesting a bundle2, getbundle returns a stream to make the
255 255 # wire level function happier. We need to build a proper object
256 256 # from it in local peer.
257 257 return bundle2.getunbundler(self.ui, cb)
258 258 else:
259 259 return changegroup.getunbundler('01', cb, None)
260 260
261 261 def heads(self):
262 262 return self._repo.heads()
263 263
264 264 def known(self, nodes):
265 265 return self._repo.known(nodes)
266 266
267 267 def listkeys(self, namespace):
268 268 return self._repo.listkeys(namespace)
269 269
270 270 def lookup(self, key):
271 271 return self._repo.lookup(key)
272 272
273 273 def pushkey(self, namespace, key, old, new):
274 274 return self._repo.pushkey(namespace, key, old, new)
275 275
276 276 def stream_out(self):
277 277 raise error.Abort(_('cannot perform stream clone against local '
278 278 'peer'))
279 279
280 280 def unbundle(self, bundle, heads, url):
281 281 """apply a bundle on a repo
282 282
283 283 This function handles the repo locking itself."""
284 284 try:
285 285 try:
286 286 bundle = exchange.readbundle(self.ui, bundle, None)
287 287 ret = exchange.unbundle(self._repo, bundle, heads, 'push', url)
288 288 if util.safehasattr(ret, 'getchunks'):
289 289 # This is a bundle20 object, turn it into an unbundler.
290 290 # This little dance should be dropped eventually when the
291 291 # API is finally improved.
292 292 stream = util.chunkbuffer(ret.getchunks())
293 293 ret = bundle2.getunbundler(self.ui, stream)
294 294 return ret
295 295 except Exception as exc:
296 296 # If the exception contains output salvaged from a bundle2
297 297 # reply, we need to make sure it is printed before continuing
298 298 # to fail. So we build a bundle2 with such output and consume
299 299 # it directly.
300 300 #
301 301 # This is not very elegant but allows a "simple" solution for
302 302 # issue4594
303 303 output = getattr(exc, '_bundle2salvagedoutput', ())
304 304 if output:
305 305 bundler = bundle2.bundle20(self._repo.ui)
306 306 for out in output:
307 307 bundler.addpart(out)
308 308 stream = util.chunkbuffer(bundler.getchunks())
309 309 b = bundle2.getunbundler(self.ui, stream)
310 310 bundle2.processbundle(self._repo, b)
311 311 raise
312 312 except error.PushRaced as exc:
313 313 raise error.ResponseError(_('push failed:'),
314 314 stringutil.forcebytestr(exc))
315 315
316 316 # End of _basewirecommands interface.
317 317
318 318 # Begin of peer interface.
319 319
320 320 def commandexecutor(self):
321 321 return localcommandexecutor(self)
322 322
323 323 # End of peer interface.
324 324
325 325 @interfaceutil.implementer(repository.ipeerlegacycommands)
326 326 class locallegacypeer(localpeer):
327 327 '''peer extension which implements legacy methods too; used for tests with
328 328 restricted capabilities'''
329 329
330 330 def __init__(self, repo):
331 331 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
332 332
333 333 # Begin of baselegacywirecommands interface.
334 334
335 335 def between(self, pairs):
336 336 return self._repo.between(pairs)
337 337
338 338 def branches(self, nodes):
339 339 return self._repo.branches(nodes)
340 340
341 341 def changegroup(self, nodes, source):
342 342 outgoing = discovery.outgoing(self._repo, missingroots=nodes,
343 343 missingheads=self._repo.heads())
344 344 return changegroup.makechangegroup(self._repo, outgoing, '01', source)
345 345
346 346 def changegroupsubset(self, bases, heads, source):
347 347 outgoing = discovery.outgoing(self._repo, missingroots=bases,
348 348 missingheads=heads)
349 349 return changegroup.makechangegroup(self._repo, outgoing, '01', source)
350 350
351 351 # End of baselegacywirecommands interface.
352 352
353 353 # Increment the sub-version when the revlog v2 format changes to lock out old
354 354 # clients.
355 355 REVLOGV2_REQUIREMENT = 'exp-revlogv2.0'
356 356
357 357 # A repository with the sparserevlog feature will have delta chains that
358 358 # can spread over a larger span. Sparse reading cuts these large spans into
359 359 # pieces, so that each piece isn't too big.
360 360 # Without the sparserevlog capability, reading from the repository could use
361 361 # huge amounts of memory, because the whole span would be read at once,
362 362 # including all the intermediate revisions that aren't pertinent for the chain.
363 363 # This is why once a repository has enabled sparse-read, it becomes required.
364 364 SPARSEREVLOG_REQUIREMENT = 'sparserevlog'
365 365
366 366 # Functions receiving (ui, features) that extensions can register to impact
367 367 # the ability to load repositories with custom requirements. Only
368 368 # functions defined in loaded extensions are called.
369 369 #
370 370 # The function receives a set of requirement strings that the repository
371 371 # is capable of opening. Functions will typically add elements to the
372 372 # set to reflect that the extension knows how to handle that requirements.
373 373 featuresetupfuncs = set()
374 374
375 375 @interfaceutil.implementer(repository.completelocalrepository)
376 376 class localrepository(object):
377 377
378 378 # obsolete experimental requirements:
379 379 # - manifestv2: An experimental new manifest format that allowed
380 380 # for stem compression of long paths. Experiment ended up not
381 381 # being successful (repository sizes went up due to worse delta
382 382 # chains), and the code was deleted in 4.6.
383 383 supportedformats = {
384 384 'revlogv1',
385 385 'generaldelta',
386 386 'treemanifest',
387 387 REVLOGV2_REQUIREMENT,
388 388 SPARSEREVLOG_REQUIREMENT,
389 389 }
390 390 _basesupported = supportedformats | {
391 391 'store',
392 392 'fncache',
393 393 'shared',
394 394 'relshared',
395 395 'dotencode',
396 396 'exp-sparse',
397 397 }
398 398 openerreqs = {
399 399 'revlogv1',
400 400 'generaldelta',
401 401 'treemanifest',
402 402 }
403 403
404 404 # list of prefix for file which can be written without 'wlock'
405 405 # Extensions should extend this list when needed
406 406 _wlockfreeprefix = {
407 407 # We migh consider requiring 'wlock' for the next
408 408 # two, but pretty much all the existing code assume
409 409 # wlock is not needed so we keep them excluded for
410 410 # now.
411 411 'hgrc',
412 412 'requires',
413 413 # XXX cache is a complicatged business someone
414 414 # should investigate this in depth at some point
415 415 'cache/',
416 416 # XXX shouldn't be dirstate covered by the wlock?
417 417 'dirstate',
418 418 # XXX bisect was still a bit too messy at the time
419 419 # this changeset was introduced. Someone should fix
420 420 # the remainig bit and drop this line
421 421 'bisect.state',
422 422 }
423 423
424 424 def __init__(self, baseui, path, create=False, intents=None):
425 425 self.requirements = set()
426 426 self.filtername = None
427 427 # wvfs: rooted at the repository root, used to access the working copy
428 428 self.wvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
429 429 # vfs: rooted at .hg, used to access repo files outside of .hg/store
430 430 self.vfs = None
431 431 # svfs: usually rooted at .hg/store, used to access repository history
432 432 # If this is a shared repository, this vfs may point to another
433 433 # repository's .hg/store directory.
434 434 self.svfs = None
435 435 self.root = self.wvfs.base
436 436 self.path = self.wvfs.join(".hg")
437 437 self.origroot = path
438 438 # This is only used by context.workingctx.match in order to
439 439 # detect files in subrepos.
440 440 self.auditor = pathutil.pathauditor(
441 441 self.root, callback=self._checknested)
442 442 # This is only used by context.basectx.match in order to detect
443 443 # files in subrepos.
444 444 self.nofsauditor = pathutil.pathauditor(
445 445 self.root, callback=self._checknested, realfs=False, cached=True)
446 446 self.baseui = baseui
447 447 self.ui = baseui.copy()
448 448 self.ui.copy = baseui.copy # prevent copying repo configuration
449 449 self.vfs = vfsmod.vfs(self.path, cacheaudited=True)
450 450 if (self.ui.configbool('devel', 'all-warnings') or
451 451 self.ui.configbool('devel', 'check-locks')):
452 452 self.vfs.audit = self._getvfsward(self.vfs.audit)
453 453 # A list of callback to shape the phase if no data were found.
454 454 # Callback are in the form: func(repo, roots) --> processed root.
455 455 # This list it to be filled by extension during repo setup
456 456 self._phasedefaults = []
457 457 try:
458 458 self.ui.readconfig(self.vfs.join("hgrc"), self.root)
459 459 self._loadextensions()
460 460 except IOError:
461 461 pass
462 462
463 463 if featuresetupfuncs:
464 464 self.supported = set(self._basesupported) # use private copy
465 465 extmods = set(m.__name__ for n, m
466 466 in extensions.extensions(self.ui))
467 467 for setupfunc in featuresetupfuncs:
468 468 if setupfunc.__module__ in extmods:
469 469 setupfunc(self.ui, self.supported)
470 470 else:
471 471 self.supported = self._basesupported
472 472 color.setup(self.ui)
473 473
474 474 # Add compression engines.
475 475 for name in util.compengines:
476 476 engine = util.compengines[name]
477 477 if engine.revlogheader():
478 478 self.supported.add('exp-compression-%s' % name)
479 479
480 480 if not self.vfs.isdir():
481 481 if create:
482 482 self.requirements = newreporequirements(self)
483 483
484 484 if not self.wvfs.exists():
485 485 self.wvfs.makedirs()
486 486 self.vfs.makedir(notindexed=True)
487 487
488 488 if 'store' in self.requirements:
489 489 self.vfs.mkdir("store")
490 490
491 491 # create an invalid changelog
492 492 self.vfs.append(
493 493 "00changelog.i",
494 494 '\0\0\0\2' # represents revlogv2
495 495 ' dummy changelog to prevent using the old repo layout'
496 496 )
497 497 else:
498 498 raise error.RepoError(_("repository %s not found") % path)
499 499 elif create:
500 500 raise error.RepoError(_("repository %s already exists") % path)
501 501 else:
502 502 try:
503 503 self.requirements = scmutil.readrequires(
504 504 self.vfs, self.supported)
505 505 except IOError as inst:
506 506 if inst.errno != errno.ENOENT:
507 507 raise
508 508
509 509 cachepath = self.vfs.join('cache')
510 510 self.sharedpath = self.path
511 511 try:
512 512 sharedpath = self.vfs.read("sharedpath").rstrip('\n')
513 513 if 'relshared' in self.requirements:
514 514 sharedpath = self.vfs.join(sharedpath)
515 515 vfs = vfsmod.vfs(sharedpath, realpath=True)
516 516 cachepath = vfs.join('cache')
517 517 s = vfs.base
518 518 if not vfs.exists():
519 519 raise error.RepoError(
520 520 _('.hg/sharedpath points to nonexistent directory %s') % s)
521 521 self.sharedpath = s
522 522 except IOError as inst:
523 523 if inst.errno != errno.ENOENT:
524 524 raise
525 525
526 526 if 'exp-sparse' in self.requirements and not sparse.enabled:
527 527 raise error.RepoError(_('repository is using sparse feature but '
528 528 'sparse is not enabled; enable the '
529 529 '"sparse" extensions to access'))
530 530
531 531 self.store = store.store(
532 532 self.requirements, self.sharedpath,
533 533 lambda base: vfsmod.vfs(base, cacheaudited=True))
534 534 self.spath = self.store.path
535 535 self.svfs = self.store.vfs
536 536 self.sjoin = self.store.join
537 537 self.vfs.createmode = self.store.createmode
538 538 self.cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
539 539 self.cachevfs.createmode = self.store.createmode
540 540 if (self.ui.configbool('devel', 'all-warnings') or
541 541 self.ui.configbool('devel', 'check-locks')):
542 542 if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs
543 543 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
544 544 else: # standard vfs
545 545 self.svfs.audit = self._getsvfsward(self.svfs.audit)
546 546 self._applyopenerreqs()
547 547 if create:
548 548 self._writerequirements()
549 549
550 550 self._dirstatevalidatewarned = False
551 551
552 552 self._branchcaches = {}
553 553 self._revbranchcache = None
554 554 self._filterpats = {}
555 555 self._datafilters = {}
556 556 self._transref = self._lockref = self._wlockref = None
557 557
558 558 # A cache for various files under .hg/ that tracks file changes,
559 559 # (used by the filecache decorator)
560 560 #
561 561 # Maps a property name to its util.filecacheentry
562 562 self._filecache = {}
563 563
564 564 # hold sets of revision to be filtered
565 565 # should be cleared when something might have changed the filter value:
566 566 # - new changesets,
567 567 # - phase change,
568 568 # - new obsolescence marker,
569 569 # - working directory parent change,
570 570 # - bookmark changes
571 571 self.filteredrevcache = {}
572 572
573 573 # post-dirstate-status hooks
574 574 self._postdsstatus = []
575 575
576 576 # generic mapping between names and nodes
577 577 self.names = namespaces.namespaces()
578 578
579 579 # Key to signature value.
580 580 self._sparsesignaturecache = {}
581 581 # Signature to cached matcher instance.
582 582 self._sparsematchercache = {}
583 583
584 584 def _getvfsward(self, origfunc):
585 585 """build a ward for self.vfs"""
586 586 rref = weakref.ref(self)
587 587 def checkvfs(path, mode=None):
588 588 ret = origfunc(path, mode=mode)
589 589 repo = rref()
590 590 if (repo is None
591 591 or not util.safehasattr(repo, '_wlockref')
592 592 or not util.safehasattr(repo, '_lockref')):
593 593 return
594 594 if mode in (None, 'r', 'rb'):
595 595 return
596 596 if path.startswith(repo.path):
597 597 # truncate name relative to the repository (.hg)
598 598 path = path[len(repo.path) + 1:]
599 599 if path.startswith('cache/'):
600 600 msg = 'accessing cache with vfs instead of cachevfs: "%s"'
601 601 repo.ui.develwarn(msg % path, stacklevel=2, config="cache-vfs")
602 602 if path.startswith('journal.'):
603 603 # journal is covered by 'lock'
604 604 if repo._currentlock(repo._lockref) is None:
605 605 repo.ui.develwarn('write with no lock: "%s"' % path,
606 606 stacklevel=2, config='check-locks')
607 607 elif repo._currentlock(repo._wlockref) is None:
608 608 # rest of vfs files are covered by 'wlock'
609 609 #
610 610 # exclude special files
611 611 for prefix in self._wlockfreeprefix:
612 612 if path.startswith(prefix):
613 613 return
614 614 repo.ui.develwarn('write with no wlock: "%s"' % path,
615 615 stacklevel=2, config='check-locks')
616 616 return ret
617 617 return checkvfs
618 618
619 619 def _getsvfsward(self, origfunc):
620 620 """build a ward for self.svfs"""
621 621 rref = weakref.ref(self)
622 622 def checksvfs(path, mode=None):
623 623 ret = origfunc(path, mode=mode)
624 624 repo = rref()
625 625 if repo is None or not util.safehasattr(repo, '_lockref'):
626 626 return
627 627 if mode in (None, 'r', 'rb'):
628 628 return
629 629 if path.startswith(repo.sharedpath):
630 630 # truncate name relative to the repository (.hg)
631 631 path = path[len(repo.sharedpath) + 1:]
632 632 if repo._currentlock(repo._lockref) is None:
633 633 repo.ui.develwarn('write with no lock: "%s"' % path,
634 634 stacklevel=3)
635 635 return ret
636 636 return checksvfs
637 637
638 638 def close(self):
639 639 self._writecaches()
640 640
641 641 def _loadextensions(self):
642 642 extensions.loadall(self.ui)
643 643
644 644 def _writecaches(self):
645 645 if self._revbranchcache:
646 646 self._revbranchcache.write()
647 647
648 648 def _restrictcapabilities(self, caps):
649 649 if self.ui.configbool('experimental', 'bundle2-advertise'):
650 650 caps = set(caps)
651 651 capsblob = bundle2.encodecaps(bundle2.getrepocaps(self,
652 652 role='client'))
653 653 caps.add('bundle2=' + urlreq.quote(capsblob))
654 654 return caps
655 655
656 656 def _applyopenerreqs(self):
657 657 self.svfs.options = dict((r, 1) for r in self.requirements
658 658 if r in self.openerreqs)
659 659 # experimental config: format.chunkcachesize
660 660 chunkcachesize = self.ui.configint('format', 'chunkcachesize')
661 661 if chunkcachesize is not None:
662 662 self.svfs.options['chunkcachesize'] = chunkcachesize
663 663 # experimental config: format.maxchainlen
664 664 maxchainlen = self.ui.configint('format', 'maxchainlen')
665 665 if maxchainlen is not None:
666 666 self.svfs.options['maxchainlen'] = maxchainlen
667 667 # experimental config: format.manifestcachesize
668 668 manifestcachesize = self.ui.configint('format', 'manifestcachesize')
669 669 if manifestcachesize is not None:
670 670 self.svfs.options['manifestcachesize'] = manifestcachesize
671 deltabothparents = self.ui.configbool('revlog',
672 'optimize-delta-parent-choice')
671 deltabothparents = self.ui.configbool('storage',
672 'revlog.optimize-delta-parent-choice')
673 673 self.svfs.options['deltabothparents'] = deltabothparents
674 674 self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui)
675 675 chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan')
676 676 if 0 <= chainspan:
677 677 self.svfs.options['maxdeltachainspan'] = chainspan
678 678 mmapindexthreshold = self.ui.configbytes('experimental',
679 679 'mmapindexthreshold')
680 680 if mmapindexthreshold is not None:
681 681 self.svfs.options['mmapindexthreshold'] = mmapindexthreshold
682 682 withsparseread = self.ui.configbool('experimental', 'sparse-read')
683 683 srdensitythres = float(self.ui.config('experimental',
684 684 'sparse-read.density-threshold'))
685 685 srmingapsize = self.ui.configbytes('experimental',
686 686 'sparse-read.min-gap-size')
687 687 self.svfs.options['with-sparse-read'] = withsparseread
688 688 self.svfs.options['sparse-read-density-threshold'] = srdensitythres
689 689 self.svfs.options['sparse-read-min-gap-size'] = srmingapsize
690 690 sparserevlog = SPARSEREVLOG_REQUIREMENT in self.requirements
691 691 self.svfs.options['sparse-revlog'] = sparserevlog
692 692
693 693 for r in self.requirements:
694 694 if r.startswith('exp-compression-'):
695 695 self.svfs.options['compengine'] = r[len('exp-compression-'):]
696 696
697 697 # TODO move "revlogv2" to openerreqs once finalized.
698 698 if REVLOGV2_REQUIREMENT in self.requirements:
699 699 self.svfs.options['revlogv2'] = True
700 700
701 701 def _writerequirements(self):
702 702 scmutil.writerequires(self.vfs, self.requirements)
703 703
704 704 def _checknested(self, path):
705 705 """Determine if path is a legal nested repository."""
706 706 if not path.startswith(self.root):
707 707 return False
708 708 subpath = path[len(self.root) + 1:]
709 709 normsubpath = util.pconvert(subpath)
710 710
711 711 # XXX: Checking against the current working copy is wrong in
712 712 # the sense that it can reject things like
713 713 #
714 714 # $ hg cat -r 10 sub/x.txt
715 715 #
716 716 # if sub/ is no longer a subrepository in the working copy
717 717 # parent revision.
718 718 #
719 719 # However, it can of course also allow things that would have
720 720 # been rejected before, such as the above cat command if sub/
721 721 # is a subrepository now, but was a normal directory before.
722 722 # The old path auditor would have rejected by mistake since it
723 723 # panics when it sees sub/.hg/.
724 724 #
725 725 # All in all, checking against the working copy seems sensible
726 726 # since we want to prevent access to nested repositories on
727 727 # the filesystem *now*.
728 728 ctx = self[None]
729 729 parts = util.splitpath(subpath)
730 730 while parts:
731 731 prefix = '/'.join(parts)
732 732 if prefix in ctx.substate:
733 733 if prefix == normsubpath:
734 734 return True
735 735 else:
736 736 sub = ctx.sub(prefix)
737 737 return sub.checknested(subpath[len(prefix) + 1:])
738 738 else:
739 739 parts.pop()
740 740 return False
741 741
742 742 def peer(self):
743 743 return localpeer(self) # not cached to avoid reference cycle
744 744
745 745 def unfiltered(self):
746 746 """Return unfiltered version of the repository
747 747
748 748 Intended to be overwritten by filtered repo."""
749 749 return self
750 750
751 751 def filtered(self, name, visibilityexceptions=None):
752 752 """Return a filtered version of a repository"""
753 753 cls = repoview.newtype(self.unfiltered().__class__)
754 754 return cls(self, name, visibilityexceptions)
755 755
756 756 @repofilecache('bookmarks', 'bookmarks.current')
757 757 def _bookmarks(self):
758 758 return bookmarks.bmstore(self)
759 759
760 760 @property
761 761 def _activebookmark(self):
762 762 return self._bookmarks.active
763 763
764 764 # _phasesets depend on changelog. what we need is to call
765 765 # _phasecache.invalidate() if '00changelog.i' was changed, but it
766 766 # can't be easily expressed in filecache mechanism.
767 767 @storecache('phaseroots', '00changelog.i')
768 768 def _phasecache(self):
769 769 return phases.phasecache(self, self._phasedefaults)
770 770
771 771 @storecache('obsstore')
772 772 def obsstore(self):
773 773 return obsolete.makestore(self.ui, self)
774 774
775 775 @storecache('00changelog.i')
776 776 def changelog(self):
777 777 return changelog.changelog(self.svfs,
778 778 trypending=txnutil.mayhavepending(self.root))
779 779
780 780 def _constructmanifest(self):
781 781 # This is a temporary function while we migrate from manifest to
782 782 # manifestlog. It allows bundlerepo and unionrepo to intercept the
783 783 # manifest creation.
784 784 return manifest.manifestrevlog(self.svfs)
785 785
786 786 @storecache('00manifest.i')
787 787 def manifestlog(self):
788 788 return manifest.manifestlog(self.svfs, self)
789 789
790 790 @repofilecache('dirstate')
791 791 def dirstate(self):
792 792 return self._makedirstate()
793 793
794 794 def _makedirstate(self):
795 795 """Extension point for wrapping the dirstate per-repo."""
796 796 sparsematchfn = lambda: sparse.matcher(self)
797 797
798 798 return dirstate.dirstate(self.vfs, self.ui, self.root,
799 799 self._dirstatevalidate, sparsematchfn)
800 800
801 801 def _dirstatevalidate(self, node):
802 802 try:
803 803 self.changelog.rev(node)
804 804 return node
805 805 except error.LookupError:
806 806 if not self._dirstatevalidatewarned:
807 807 self._dirstatevalidatewarned = True
808 808 self.ui.warn(_("warning: ignoring unknown"
809 809 " working parent %s!\n") % short(node))
810 810 return nullid
811 811
812 812 @repofilecache(narrowspec.FILENAME)
813 813 def narrowpats(self):
814 814 """matcher patterns for this repository's narrowspec
815 815
816 816 A tuple of (includes, excludes).
817 817 """
818 818 source = self
819 819 if self.shared():
820 820 from . import hg
821 821 source = hg.sharedreposource(self)
822 822 return narrowspec.load(source)
823 823
824 824 @repofilecache(narrowspec.FILENAME)
825 825 def _narrowmatch(self):
826 826 if changegroup.NARROW_REQUIREMENT not in self.requirements:
827 827 return matchmod.always(self.root, '')
828 828 include, exclude = self.narrowpats
829 829 return narrowspec.match(self.root, include=include, exclude=exclude)
830 830
831 831 # TODO(martinvonz): make this property-like instead?
832 832 def narrowmatch(self):
833 833 return self._narrowmatch
834 834
835 835 def setnarrowpats(self, newincludes, newexcludes):
836 836 target = self
837 837 if self.shared():
838 838 from . import hg
839 839 target = hg.sharedreposource(self)
840 840 narrowspec.save(target, newincludes, newexcludes)
841 841 self.invalidate(clearfilecache=True)
842 842
843 843 def __getitem__(self, changeid):
844 844 if changeid is None:
845 845 return context.workingctx(self)
846 846 if isinstance(changeid, context.basectx):
847 847 return changeid
848 848 if isinstance(changeid, slice):
849 849 # wdirrev isn't contiguous so the slice shouldn't include it
850 850 return [context.changectx(self, i)
851 851 for i in xrange(*changeid.indices(len(self)))
852 852 if i not in self.changelog.filteredrevs]
853 853 try:
854 854 return context.changectx(self, changeid)
855 855 except error.WdirUnsupported:
856 856 return context.workingctx(self)
857 857
858 858 def __contains__(self, changeid):
859 859 """True if the given changeid exists
860 860
861 861 error.LookupError is raised if an ambiguous node specified.
862 862 """
863 863 try:
864 864 self[changeid]
865 865 return True
866 866 except error.RepoLookupError:
867 867 return False
868 868
869 869 def __nonzero__(self):
870 870 return True
871 871
872 872 __bool__ = __nonzero__
873 873
874 874 def __len__(self):
875 875 # no need to pay the cost of repoview.changelog
876 876 unfi = self.unfiltered()
877 877 return len(unfi.changelog)
878 878
879 879 def __iter__(self):
880 880 return iter(self.changelog)
881 881
882 882 def revs(self, expr, *args):
883 883 '''Find revisions matching a revset.
884 884
885 885 The revset is specified as a string ``expr`` that may contain
886 886 %-formatting to escape certain types. See ``revsetlang.formatspec``.
887 887
888 888 Revset aliases from the configuration are not expanded. To expand
889 889 user aliases, consider calling ``scmutil.revrange()`` or
890 890 ``repo.anyrevs([expr], user=True)``.
891 891
892 892 Returns a revset.abstractsmartset, which is a list-like interface
893 893 that contains integer revisions.
894 894 '''
895 895 expr = revsetlang.formatspec(expr, *args)
896 896 m = revset.match(None, expr)
897 897 return m(self)
898 898
899 899 def set(self, expr, *args):
900 900 '''Find revisions matching a revset and emit changectx instances.
901 901
902 902 This is a convenience wrapper around ``revs()`` that iterates the
903 903 result and is a generator of changectx instances.
904 904
905 905 Revset aliases from the configuration are not expanded. To expand
906 906 user aliases, consider calling ``scmutil.revrange()``.
907 907 '''
908 908 for r in self.revs(expr, *args):
909 909 yield self[r]
910 910
911 911 def anyrevs(self, specs, user=False, localalias=None):
912 912 '''Find revisions matching one of the given revsets.
913 913
914 914 Revset aliases from the configuration are not expanded by default. To
915 915 expand user aliases, specify ``user=True``. To provide some local
916 916 definitions overriding user aliases, set ``localalias`` to
917 917 ``{name: definitionstring}``.
918 918 '''
919 919 if user:
920 920 m = revset.matchany(self.ui, specs,
921 921 lookup=revset.lookupfn(self),
922 922 localalias=localalias)
923 923 else:
924 924 m = revset.matchany(None, specs, localalias=localalias)
925 925 return m(self)
926 926
927 927 def url(self):
928 928 return 'file:' + self.root
929 929
930 930 def hook(self, name, throw=False, **args):
931 931 """Call a hook, passing this repo instance.
932 932
933 933 This a convenience method to aid invoking hooks. Extensions likely
934 934 won't call this unless they have registered a custom hook or are
935 935 replacing code that is expected to call a hook.
936 936 """
937 937 return hook.hook(self.ui, self, name, throw, **args)
938 938
939 939 @filteredpropertycache
940 940 def _tagscache(self):
941 941 '''Returns a tagscache object that contains various tags related
942 942 caches.'''
943 943
944 944 # This simplifies its cache management by having one decorated
945 945 # function (this one) and the rest simply fetch things from it.
946 946 class tagscache(object):
947 947 def __init__(self):
948 948 # These two define the set of tags for this repository. tags
949 949 # maps tag name to node; tagtypes maps tag name to 'global' or
950 950 # 'local'. (Global tags are defined by .hgtags across all
951 951 # heads, and local tags are defined in .hg/localtags.)
952 952 # They constitute the in-memory cache of tags.
953 953 self.tags = self.tagtypes = None
954 954
955 955 self.nodetagscache = self.tagslist = None
956 956
957 957 cache = tagscache()
958 958 cache.tags, cache.tagtypes = self._findtags()
959 959
960 960 return cache
961 961
962 962 def tags(self):
963 963 '''return a mapping of tag to node'''
964 964 t = {}
965 965 if self.changelog.filteredrevs:
966 966 tags, tt = self._findtags()
967 967 else:
968 968 tags = self._tagscache.tags
969 969 for k, v in tags.iteritems():
970 970 try:
971 971 # ignore tags to unknown nodes
972 972 self.changelog.rev(v)
973 973 t[k] = v
974 974 except (error.LookupError, ValueError):
975 975 pass
976 976 return t
977 977
978 978 def _findtags(self):
979 979 '''Do the hard work of finding tags. Return a pair of dicts
980 980 (tags, tagtypes) where tags maps tag name to node, and tagtypes
981 981 maps tag name to a string like \'global\' or \'local\'.
982 982 Subclasses or extensions are free to add their own tags, but
983 983 should be aware that the returned dicts will be retained for the
984 984 duration of the localrepo object.'''
985 985
986 986 # XXX what tagtype should subclasses/extensions use? Currently
987 987 # mq and bookmarks add tags, but do not set the tagtype at all.
988 988 # Should each extension invent its own tag type? Should there
989 989 # be one tagtype for all such "virtual" tags? Or is the status
990 990 # quo fine?
991 991
992 992
993 993 # map tag name to (node, hist)
994 994 alltags = tagsmod.findglobaltags(self.ui, self)
995 995 # map tag name to tag type
996 996 tagtypes = dict((tag, 'global') for tag in alltags)
997 997
998 998 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
999 999
1000 1000 # Build the return dicts. Have to re-encode tag names because
1001 1001 # the tags module always uses UTF-8 (in order not to lose info
1002 1002 # writing to the cache), but the rest of Mercurial wants them in
1003 1003 # local encoding.
1004 1004 tags = {}
1005 1005 for (name, (node, hist)) in alltags.iteritems():
1006 1006 if node != nullid:
1007 1007 tags[encoding.tolocal(name)] = node
1008 1008 tags['tip'] = self.changelog.tip()
1009 1009 tagtypes = dict([(encoding.tolocal(name), value)
1010 1010 for (name, value) in tagtypes.iteritems()])
1011 1011 return (tags, tagtypes)
1012 1012
1013 1013 def tagtype(self, tagname):
1014 1014 '''
1015 1015 return the type of the given tag. result can be:
1016 1016
1017 1017 'local' : a local tag
1018 1018 'global' : a global tag
1019 1019 None : tag does not exist
1020 1020 '''
1021 1021
1022 1022 return self._tagscache.tagtypes.get(tagname)
1023 1023
1024 1024 def tagslist(self):
1025 1025 '''return a list of tags ordered by revision'''
1026 1026 if not self._tagscache.tagslist:
1027 1027 l = []
1028 1028 for t, n in self.tags().iteritems():
1029 1029 l.append((self.changelog.rev(n), t, n))
1030 1030 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
1031 1031
1032 1032 return self._tagscache.tagslist
1033 1033
1034 1034 def nodetags(self, node):
1035 1035 '''return the tags associated with a node'''
1036 1036 if not self._tagscache.nodetagscache:
1037 1037 nodetagscache = {}
1038 1038 for t, n in self._tagscache.tags.iteritems():
1039 1039 nodetagscache.setdefault(n, []).append(t)
1040 1040 for tags in nodetagscache.itervalues():
1041 1041 tags.sort()
1042 1042 self._tagscache.nodetagscache = nodetagscache
1043 1043 return self._tagscache.nodetagscache.get(node, [])
1044 1044
1045 1045 def nodebookmarks(self, node):
1046 1046 """return the list of bookmarks pointing to the specified node"""
1047 1047 return self._bookmarks.names(node)
1048 1048
1049 1049 def branchmap(self):
1050 1050 '''returns a dictionary {branch: [branchheads]} with branchheads
1051 1051 ordered by increasing revision number'''
1052 1052 branchmap.updatecache(self)
1053 1053 return self._branchcaches[self.filtername]
1054 1054
1055 1055 @unfilteredmethod
1056 1056 def revbranchcache(self):
1057 1057 if not self._revbranchcache:
1058 1058 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
1059 1059 return self._revbranchcache
1060 1060
1061 1061 def branchtip(self, branch, ignoremissing=False):
1062 1062 '''return the tip node for a given branch
1063 1063
1064 1064 If ignoremissing is True, then this method will not raise an error.
1065 1065 This is helpful for callers that only expect None for a missing branch
1066 1066 (e.g. namespace).
1067 1067
1068 1068 '''
1069 1069 try:
1070 1070 return self.branchmap().branchtip(branch)
1071 1071 except KeyError:
1072 1072 if not ignoremissing:
1073 1073 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
1074 1074 else:
1075 1075 pass
1076 1076
1077 1077 def lookup(self, key):
1078 1078 return scmutil.revsymbol(self, key).node()
1079 1079
1080 1080 def lookupbranch(self, key):
1081 1081 if key in self.branchmap():
1082 1082 return key
1083 1083
1084 1084 return scmutil.revsymbol(self, key).branch()
1085 1085
1086 1086 def known(self, nodes):
1087 1087 cl = self.changelog
1088 1088 nm = cl.nodemap
1089 1089 filtered = cl.filteredrevs
1090 1090 result = []
1091 1091 for n in nodes:
1092 1092 r = nm.get(n)
1093 1093 resp = not (r is None or r in filtered)
1094 1094 result.append(resp)
1095 1095 return result
1096 1096
1097 1097 def local(self):
1098 1098 return self
1099 1099
1100 1100 def publishing(self):
1101 1101 # it's safe (and desirable) to trust the publish flag unconditionally
1102 1102 # so that we don't finalize changes shared between users via ssh or nfs
1103 1103 return self.ui.configbool('phases', 'publish', untrusted=True)
1104 1104
1105 1105 def cancopy(self):
1106 1106 # so statichttprepo's override of local() works
1107 1107 if not self.local():
1108 1108 return False
1109 1109 if not self.publishing():
1110 1110 return True
1111 1111 # if publishing we can't copy if there is filtered content
1112 1112 return not self.filtered('visible').changelog.filteredrevs
1113 1113
1114 1114 def shared(self):
1115 1115 '''the type of shared repository (None if not shared)'''
1116 1116 if self.sharedpath != self.path:
1117 1117 return 'store'
1118 1118 return None
1119 1119
1120 1120 def wjoin(self, f, *insidef):
1121 1121 return self.vfs.reljoin(self.root, f, *insidef)
1122 1122
1123 1123 def file(self, f):
1124 1124 if f[0] == '/':
1125 1125 f = f[1:]
1126 1126 return filelog.filelog(self.svfs, f)
1127 1127
1128 1128 def setparents(self, p1, p2=nullid):
1129 1129 with self.dirstate.parentchange():
1130 1130 copies = self.dirstate.setparents(p1, p2)
1131 1131 pctx = self[p1]
1132 1132 if copies:
1133 1133 # Adjust copy records, the dirstate cannot do it, it
1134 1134 # requires access to parents manifests. Preserve them
1135 1135 # only for entries added to first parent.
1136 1136 for f in copies:
1137 1137 if f not in pctx and copies[f] in pctx:
1138 1138 self.dirstate.copy(copies[f], f)
1139 1139 if p2 == nullid:
1140 1140 for f, s in sorted(self.dirstate.copies().items()):
1141 1141 if f not in pctx and s not in pctx:
1142 1142 self.dirstate.copy(None, f)
1143 1143
1144 1144 def filectx(self, path, changeid=None, fileid=None, changectx=None):
1145 1145 """changeid can be a changeset revision, node, or tag.
1146 1146 fileid can be a file revision or node."""
1147 1147 return context.filectx(self, path, changeid, fileid,
1148 1148 changectx=changectx)
1149 1149
1150 1150 def getcwd(self):
1151 1151 return self.dirstate.getcwd()
1152 1152
1153 1153 def pathto(self, f, cwd=None):
1154 1154 return self.dirstate.pathto(f, cwd)
1155 1155
1156 1156 def _loadfilter(self, filter):
1157 1157 if filter not in self._filterpats:
1158 1158 l = []
1159 1159 for pat, cmd in self.ui.configitems(filter):
1160 1160 if cmd == '!':
1161 1161 continue
1162 1162 mf = matchmod.match(self.root, '', [pat])
1163 1163 fn = None
1164 1164 params = cmd
1165 1165 for name, filterfn in self._datafilters.iteritems():
1166 1166 if cmd.startswith(name):
1167 1167 fn = filterfn
1168 1168 params = cmd[len(name):].lstrip()
1169 1169 break
1170 1170 if not fn:
1171 1171 fn = lambda s, c, **kwargs: procutil.filter(s, c)
1172 1172 # Wrap old filters not supporting keyword arguments
1173 1173 if not pycompat.getargspec(fn)[2]:
1174 1174 oldfn = fn
1175 1175 fn = lambda s, c, **kwargs: oldfn(s, c)
1176 1176 l.append((mf, fn, params))
1177 1177 self._filterpats[filter] = l
1178 1178 return self._filterpats[filter]
1179 1179
1180 1180 def _filter(self, filterpats, filename, data):
1181 1181 for mf, fn, cmd in filterpats:
1182 1182 if mf(filename):
1183 1183 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
1184 1184 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
1185 1185 break
1186 1186
1187 1187 return data
1188 1188
1189 1189 @unfilteredpropertycache
1190 1190 def _encodefilterpats(self):
1191 1191 return self._loadfilter('encode')
1192 1192
1193 1193 @unfilteredpropertycache
1194 1194 def _decodefilterpats(self):
1195 1195 return self._loadfilter('decode')
1196 1196
1197 1197 def adddatafilter(self, name, filter):
1198 1198 self._datafilters[name] = filter
1199 1199
1200 1200 def wread(self, filename):
1201 1201 if self.wvfs.islink(filename):
1202 1202 data = self.wvfs.readlink(filename)
1203 1203 else:
1204 1204 data = self.wvfs.read(filename)
1205 1205 return self._filter(self._encodefilterpats, filename, data)
1206 1206
1207 1207 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
1208 1208 """write ``data`` into ``filename`` in the working directory
1209 1209
1210 1210 This returns length of written (maybe decoded) data.
1211 1211 """
1212 1212 data = self._filter(self._decodefilterpats, filename, data)
1213 1213 if 'l' in flags:
1214 1214 self.wvfs.symlink(data, filename)
1215 1215 else:
1216 1216 self.wvfs.write(filename, data, backgroundclose=backgroundclose,
1217 1217 **kwargs)
1218 1218 if 'x' in flags:
1219 1219 self.wvfs.setflags(filename, False, True)
1220 1220 else:
1221 1221 self.wvfs.setflags(filename, False, False)
1222 1222 return len(data)
1223 1223
1224 1224 def wwritedata(self, filename, data):
1225 1225 return self._filter(self._decodefilterpats, filename, data)
1226 1226
1227 1227 def currenttransaction(self):
1228 1228 """return the current transaction or None if non exists"""
1229 1229 if self._transref:
1230 1230 tr = self._transref()
1231 1231 else:
1232 1232 tr = None
1233 1233
1234 1234 if tr and tr.running():
1235 1235 return tr
1236 1236 return None
1237 1237
1238 1238 def transaction(self, desc, report=None):
1239 1239 if (self.ui.configbool('devel', 'all-warnings')
1240 1240 or self.ui.configbool('devel', 'check-locks')):
1241 1241 if self._currentlock(self._lockref) is None:
1242 1242 raise error.ProgrammingError('transaction requires locking')
1243 1243 tr = self.currenttransaction()
1244 1244 if tr is not None:
1245 1245 return tr.nest(name=desc)
1246 1246
1247 1247 # abort here if the journal already exists
1248 1248 if self.svfs.exists("journal"):
1249 1249 raise error.RepoError(
1250 1250 _("abandoned transaction found"),
1251 1251 hint=_("run 'hg recover' to clean up transaction"))
1252 1252
1253 1253 idbase = "%.40f#%f" % (random.random(), time.time())
1254 1254 ha = hex(hashlib.sha1(idbase).digest())
1255 1255 txnid = 'TXN:' + ha
1256 1256 self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
1257 1257
1258 1258 self._writejournal(desc)
1259 1259 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
1260 1260 if report:
1261 1261 rp = report
1262 1262 else:
1263 1263 rp = self.ui.warn
1264 1264 vfsmap = {'plain': self.vfs} # root of .hg/
1265 1265 # we must avoid cyclic reference between repo and transaction.
1266 1266 reporef = weakref.ref(self)
1267 1267 # Code to track tag movement
1268 1268 #
1269 1269 # Since tags are all handled as file content, it is actually quite hard
1270 1270 # to track these movement from a code perspective. So we fallback to a
1271 1271 # tracking at the repository level. One could envision to track changes
1272 1272 # to the '.hgtags' file through changegroup apply but that fails to
1273 1273 # cope with case where transaction expose new heads without changegroup
1274 1274 # being involved (eg: phase movement).
1275 1275 #
1276 1276 # For now, We gate the feature behind a flag since this likely comes
1277 1277 # with performance impacts. The current code run more often than needed
1278 1278 # and do not use caches as much as it could. The current focus is on
1279 1279 # the behavior of the feature so we disable it by default. The flag
1280 1280 # will be removed when we are happy with the performance impact.
1281 1281 #
1282 1282 # Once this feature is no longer experimental move the following
1283 1283 # documentation to the appropriate help section:
1284 1284 #
1285 1285 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
1286 1286 # tags (new or changed or deleted tags). In addition the details of
1287 1287 # these changes are made available in a file at:
1288 1288 # ``REPOROOT/.hg/changes/tags.changes``.
1289 1289 # Make sure you check for HG_TAG_MOVED before reading that file as it
1290 1290 # might exist from a previous transaction even if no tag were touched
1291 1291 # in this one. Changes are recorded in a line base format::
1292 1292 #
1293 1293 # <action> <hex-node> <tag-name>\n
1294 1294 #
1295 1295 # Actions are defined as follow:
1296 1296 # "-R": tag is removed,
1297 1297 # "+A": tag is added,
1298 1298 # "-M": tag is moved (old value),
1299 1299 # "+M": tag is moved (new value),
1300 1300 tracktags = lambda x: None
1301 1301 # experimental config: experimental.hook-track-tags
1302 1302 shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags')
1303 1303 if desc != 'strip' and shouldtracktags:
1304 1304 oldheads = self.changelog.headrevs()
1305 1305 def tracktags(tr2):
1306 1306 repo = reporef()
1307 1307 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
1308 1308 newheads = repo.changelog.headrevs()
1309 1309 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
1310 1310 # notes: we compare lists here.
1311 1311 # As we do it only once buiding set would not be cheaper
1312 1312 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
1313 1313 if changes:
1314 1314 tr2.hookargs['tag_moved'] = '1'
1315 1315 with repo.vfs('changes/tags.changes', 'w',
1316 1316 atomictemp=True) as changesfile:
1317 1317 # note: we do not register the file to the transaction
1318 1318 # because we needs it to still exist on the transaction
1319 1319 # is close (for txnclose hooks)
1320 1320 tagsmod.writediff(changesfile, changes)
1321 1321 def validate(tr2):
1322 1322 """will run pre-closing hooks"""
1323 1323 # XXX the transaction API is a bit lacking here so we take a hacky
1324 1324 # path for now
1325 1325 #
1326 1326 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
1327 1327 # dict is copied before these run. In addition we needs the data
1328 1328 # available to in memory hooks too.
1329 1329 #
1330 1330 # Moreover, we also need to make sure this runs before txnclose
1331 1331 # hooks and there is no "pending" mechanism that would execute
1332 1332 # logic only if hooks are about to run.
1333 1333 #
1334 1334 # Fixing this limitation of the transaction is also needed to track
1335 1335 # other families of changes (bookmarks, phases, obsolescence).
1336 1336 #
1337 1337 # This will have to be fixed before we remove the experimental
1338 1338 # gating.
1339 1339 tracktags(tr2)
1340 1340 repo = reporef()
1341 1341 if repo.ui.configbool('experimental', 'single-head-per-branch'):
1342 1342 scmutil.enforcesinglehead(repo, tr2, desc)
1343 1343 if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
1344 1344 for name, (old, new) in sorted(tr.changes['bookmarks'].items()):
1345 1345 args = tr.hookargs.copy()
1346 1346 args.update(bookmarks.preparehookargs(name, old, new))
1347 1347 repo.hook('pretxnclose-bookmark', throw=True,
1348 1348 txnname=desc,
1349 1349 **pycompat.strkwargs(args))
1350 1350 if hook.hashook(repo.ui, 'pretxnclose-phase'):
1351 1351 cl = repo.unfiltered().changelog
1352 1352 for rev, (old, new) in tr.changes['phases'].items():
1353 1353 args = tr.hookargs.copy()
1354 1354 node = hex(cl.node(rev))
1355 1355 args.update(phases.preparehookargs(node, old, new))
1356 1356 repo.hook('pretxnclose-phase', throw=True, txnname=desc,
1357 1357 **pycompat.strkwargs(args))
1358 1358
1359 1359 repo.hook('pretxnclose', throw=True,
1360 1360 txnname=desc, **pycompat.strkwargs(tr.hookargs))
1361 1361 def releasefn(tr, success):
1362 1362 repo = reporef()
1363 1363 if success:
1364 1364 # this should be explicitly invoked here, because
1365 1365 # in-memory changes aren't written out at closing
1366 1366 # transaction, if tr.addfilegenerator (via
1367 1367 # dirstate.write or so) isn't invoked while
1368 1368 # transaction running
1369 1369 repo.dirstate.write(None)
1370 1370 else:
1371 1371 # discard all changes (including ones already written
1372 1372 # out) in this transaction
1373 1373 repo.dirstate.restorebackup(None, 'journal.dirstate')
1374 1374
1375 1375 repo.invalidate(clearfilecache=True)
1376 1376
1377 1377 tr = transaction.transaction(rp, self.svfs, vfsmap,
1378 1378 "journal",
1379 1379 "undo",
1380 1380 aftertrans(renames),
1381 1381 self.store.createmode,
1382 1382 validator=validate,
1383 1383 releasefn=releasefn,
1384 1384 checkambigfiles=_cachedfiles,
1385 1385 name=desc)
1386 1386 tr.changes['revs'] = xrange(0, 0)
1387 1387 tr.changes['obsmarkers'] = set()
1388 1388 tr.changes['phases'] = {}
1389 1389 tr.changes['bookmarks'] = {}
1390 1390
1391 1391 tr.hookargs['txnid'] = txnid
1392 1392 # note: writing the fncache only during finalize mean that the file is
1393 1393 # outdated when running hooks. As fncache is used for streaming clone,
1394 1394 # this is not expected to break anything that happen during the hooks.
1395 1395 tr.addfinalize('flush-fncache', self.store.write)
1396 1396 def txnclosehook(tr2):
1397 1397 """To be run if transaction is successful, will schedule a hook run
1398 1398 """
1399 1399 # Don't reference tr2 in hook() so we don't hold a reference.
1400 1400 # This reduces memory consumption when there are multiple
1401 1401 # transactions per lock. This can likely go away if issue5045
1402 1402 # fixes the function accumulation.
1403 1403 hookargs = tr2.hookargs
1404 1404
1405 1405 def hookfunc():
1406 1406 repo = reporef()
1407 1407 if hook.hashook(repo.ui, 'txnclose-bookmark'):
1408 1408 bmchanges = sorted(tr.changes['bookmarks'].items())
1409 1409 for name, (old, new) in bmchanges:
1410 1410 args = tr.hookargs.copy()
1411 1411 args.update(bookmarks.preparehookargs(name, old, new))
1412 1412 repo.hook('txnclose-bookmark', throw=False,
1413 1413 txnname=desc, **pycompat.strkwargs(args))
1414 1414
1415 1415 if hook.hashook(repo.ui, 'txnclose-phase'):
1416 1416 cl = repo.unfiltered().changelog
1417 1417 phasemv = sorted(tr.changes['phases'].items())
1418 1418 for rev, (old, new) in phasemv:
1419 1419 args = tr.hookargs.copy()
1420 1420 node = hex(cl.node(rev))
1421 1421 args.update(phases.preparehookargs(node, old, new))
1422 1422 repo.hook('txnclose-phase', throw=False, txnname=desc,
1423 1423 **pycompat.strkwargs(args))
1424 1424
1425 1425 repo.hook('txnclose', throw=False, txnname=desc,
1426 1426 **pycompat.strkwargs(hookargs))
1427 1427 reporef()._afterlock(hookfunc)
1428 1428 tr.addfinalize('txnclose-hook', txnclosehook)
1429 1429 # Include a leading "-" to make it happen before the transaction summary
1430 1430 # reports registered via scmutil.registersummarycallback() whose names
1431 1431 # are 00-txnreport etc. That way, the caches will be warm when the
1432 1432 # callbacks run.
1433 1433 tr.addpostclose('-warm-cache', self._buildcacheupdater(tr))
1434 1434 def txnaborthook(tr2):
1435 1435 """To be run if transaction is aborted
1436 1436 """
1437 1437 reporef().hook('txnabort', throw=False, txnname=desc,
1438 1438 **pycompat.strkwargs(tr2.hookargs))
1439 1439 tr.addabort('txnabort-hook', txnaborthook)
1440 1440 # avoid eager cache invalidation. in-memory data should be identical
1441 1441 # to stored data if transaction has no error.
1442 1442 tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats)
1443 1443 self._transref = weakref.ref(tr)
1444 1444 scmutil.registersummarycallback(self, tr, desc)
1445 1445 return tr
1446 1446
1447 1447 def _journalfiles(self):
1448 1448 return ((self.svfs, 'journal'),
1449 1449 (self.vfs, 'journal.dirstate'),
1450 1450 (self.vfs, 'journal.branch'),
1451 1451 (self.vfs, 'journal.desc'),
1452 1452 (self.vfs, 'journal.bookmarks'),
1453 1453 (self.svfs, 'journal.phaseroots'))
1454 1454
1455 1455 def undofiles(self):
1456 1456 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
1457 1457
1458 1458 @unfilteredmethod
1459 1459 def _writejournal(self, desc):
1460 1460 self.dirstate.savebackup(None, 'journal.dirstate')
1461 1461 self.vfs.write("journal.branch",
1462 1462 encoding.fromlocal(self.dirstate.branch()))
1463 1463 self.vfs.write("journal.desc",
1464 1464 "%d\n%s\n" % (len(self), desc))
1465 1465 self.vfs.write("journal.bookmarks",
1466 1466 self.vfs.tryread("bookmarks"))
1467 1467 self.svfs.write("journal.phaseroots",
1468 1468 self.svfs.tryread("phaseroots"))
1469 1469
1470 1470 def recover(self):
1471 1471 with self.lock():
1472 1472 if self.svfs.exists("journal"):
1473 1473 self.ui.status(_("rolling back interrupted transaction\n"))
1474 1474 vfsmap = {'': self.svfs,
1475 1475 'plain': self.vfs,}
1476 1476 transaction.rollback(self.svfs, vfsmap, "journal",
1477 1477 self.ui.warn,
1478 1478 checkambigfiles=_cachedfiles)
1479 1479 self.invalidate()
1480 1480 return True
1481 1481 else:
1482 1482 self.ui.warn(_("no interrupted transaction available\n"))
1483 1483 return False
1484 1484
1485 1485 def rollback(self, dryrun=False, force=False):
1486 1486 wlock = lock = dsguard = None
1487 1487 try:
1488 1488 wlock = self.wlock()
1489 1489 lock = self.lock()
1490 1490 if self.svfs.exists("undo"):
1491 1491 dsguard = dirstateguard.dirstateguard(self, 'rollback')
1492 1492
1493 1493 return self._rollback(dryrun, force, dsguard)
1494 1494 else:
1495 1495 self.ui.warn(_("no rollback information available\n"))
1496 1496 return 1
1497 1497 finally:
1498 1498 release(dsguard, lock, wlock)
1499 1499
1500 1500 @unfilteredmethod # Until we get smarter cache management
1501 1501 def _rollback(self, dryrun, force, dsguard):
1502 1502 ui = self.ui
1503 1503 try:
1504 1504 args = self.vfs.read('undo.desc').splitlines()
1505 1505 (oldlen, desc, detail) = (int(args[0]), args[1], None)
1506 1506 if len(args) >= 3:
1507 1507 detail = args[2]
1508 1508 oldtip = oldlen - 1
1509 1509
1510 1510 if detail and ui.verbose:
1511 1511 msg = (_('repository tip rolled back to revision %d'
1512 1512 ' (undo %s: %s)\n')
1513 1513 % (oldtip, desc, detail))
1514 1514 else:
1515 1515 msg = (_('repository tip rolled back to revision %d'
1516 1516 ' (undo %s)\n')
1517 1517 % (oldtip, desc))
1518 1518 except IOError:
1519 1519 msg = _('rolling back unknown transaction\n')
1520 1520 desc = None
1521 1521
1522 1522 if not force and self['.'] != self['tip'] and desc == 'commit':
1523 1523 raise error.Abort(
1524 1524 _('rollback of last commit while not checked out '
1525 1525 'may lose data'), hint=_('use -f to force'))
1526 1526
1527 1527 ui.status(msg)
1528 1528 if dryrun:
1529 1529 return 0
1530 1530
1531 1531 parents = self.dirstate.parents()
1532 1532 self.destroying()
1533 1533 vfsmap = {'plain': self.vfs, '': self.svfs}
1534 1534 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn,
1535 1535 checkambigfiles=_cachedfiles)
1536 1536 if self.vfs.exists('undo.bookmarks'):
1537 1537 self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True)
1538 1538 if self.svfs.exists('undo.phaseroots'):
1539 1539 self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True)
1540 1540 self.invalidate()
1541 1541
1542 1542 parentgone = (parents[0] not in self.changelog.nodemap or
1543 1543 parents[1] not in self.changelog.nodemap)
1544 1544 if parentgone:
1545 1545 # prevent dirstateguard from overwriting already restored one
1546 1546 dsguard.close()
1547 1547
1548 1548 self.dirstate.restorebackup(None, 'undo.dirstate')
1549 1549 try:
1550 1550 branch = self.vfs.read('undo.branch')
1551 1551 self.dirstate.setbranch(encoding.tolocal(branch))
1552 1552 except IOError:
1553 1553 ui.warn(_('named branch could not be reset: '
1554 1554 'current branch is still \'%s\'\n')
1555 1555 % self.dirstate.branch())
1556 1556
1557 1557 parents = tuple([p.rev() for p in self[None].parents()])
1558 1558 if len(parents) > 1:
1559 1559 ui.status(_('working directory now based on '
1560 1560 'revisions %d and %d\n') % parents)
1561 1561 else:
1562 1562 ui.status(_('working directory now based on '
1563 1563 'revision %d\n') % parents)
1564 1564 mergemod.mergestate.clean(self, self['.'].node())
1565 1565
1566 1566 # TODO: if we know which new heads may result from this rollback, pass
1567 1567 # them to destroy(), which will prevent the branchhead cache from being
1568 1568 # invalidated.
1569 1569 self.destroyed()
1570 1570 return 0
1571 1571
1572 1572 def _buildcacheupdater(self, newtransaction):
1573 1573 """called during transaction to build the callback updating cache
1574 1574
1575 1575 Lives on the repository to help extension who might want to augment
1576 1576 this logic. For this purpose, the created transaction is passed to the
1577 1577 method.
1578 1578 """
1579 1579 # we must avoid cyclic reference between repo and transaction.
1580 1580 reporef = weakref.ref(self)
1581 1581 def updater(tr):
1582 1582 repo = reporef()
1583 1583 repo.updatecaches(tr)
1584 1584 return updater
1585 1585
1586 1586 @unfilteredmethod
1587 1587 def updatecaches(self, tr=None, full=False):
1588 1588 """warm appropriate caches
1589 1589
1590 1590 If this function is called after a transaction closed. The transaction
1591 1591 will be available in the 'tr' argument. This can be used to selectively
1592 1592 update caches relevant to the changes in that transaction.
1593 1593
1594 1594 If 'full' is set, make sure all caches the function knows about have
1595 1595 up-to-date data. Even the ones usually loaded more lazily.
1596 1596 """
1597 1597 if tr is not None and tr.hookargs.get('source') == 'strip':
1598 1598 # During strip, many caches are invalid but
1599 1599 # later call to `destroyed` will refresh them.
1600 1600 return
1601 1601
1602 1602 if tr is None or tr.changes['revs']:
1603 1603 # updating the unfiltered branchmap should refresh all the others,
1604 1604 self.ui.debug('updating the branch cache\n')
1605 1605 branchmap.updatecache(self.filtered('served'))
1606 1606
1607 1607 if full:
1608 1608 rbc = self.revbranchcache()
1609 1609 for r in self.changelog:
1610 1610 rbc.branchinfo(r)
1611 1611 rbc.write()
1612 1612
1613 1613 def invalidatecaches(self):
1614 1614
1615 1615 if '_tagscache' in vars(self):
1616 1616 # can't use delattr on proxy
1617 1617 del self.__dict__['_tagscache']
1618 1618
1619 1619 self.unfiltered()._branchcaches.clear()
1620 1620 self.invalidatevolatilesets()
1621 1621 self._sparsesignaturecache.clear()
1622 1622
1623 1623 def invalidatevolatilesets(self):
1624 1624 self.filteredrevcache.clear()
1625 1625 obsolete.clearobscaches(self)
1626 1626
1627 1627 def invalidatedirstate(self):
1628 1628 '''Invalidates the dirstate, causing the next call to dirstate
1629 1629 to check if it was modified since the last time it was read,
1630 1630 rereading it if it has.
1631 1631
1632 1632 This is different to dirstate.invalidate() that it doesn't always
1633 1633 rereads the dirstate. Use dirstate.invalidate() if you want to
1634 1634 explicitly read the dirstate again (i.e. restoring it to a previous
1635 1635 known good state).'''
1636 1636 if hasunfilteredcache(self, 'dirstate'):
1637 1637 for k in self.dirstate._filecache:
1638 1638 try:
1639 1639 delattr(self.dirstate, k)
1640 1640 except AttributeError:
1641 1641 pass
1642 1642 delattr(self.unfiltered(), 'dirstate')
1643 1643
1644 1644 def invalidate(self, clearfilecache=False):
1645 1645 '''Invalidates both store and non-store parts other than dirstate
1646 1646
1647 1647 If a transaction is running, invalidation of store is omitted,
1648 1648 because discarding in-memory changes might cause inconsistency
1649 1649 (e.g. incomplete fncache causes unintentional failure, but
1650 1650 redundant one doesn't).
1651 1651 '''
1652 1652 unfiltered = self.unfiltered() # all file caches are stored unfiltered
1653 1653 for k in list(self._filecache.keys()):
1654 1654 # dirstate is invalidated separately in invalidatedirstate()
1655 1655 if k == 'dirstate':
1656 1656 continue
1657 1657 if (k == 'changelog' and
1658 1658 self.currenttransaction() and
1659 1659 self.changelog._delayed):
1660 1660 # The changelog object may store unwritten revisions. We don't
1661 1661 # want to lose them.
1662 1662 # TODO: Solve the problem instead of working around it.
1663 1663 continue
1664 1664
1665 1665 if clearfilecache:
1666 1666 del self._filecache[k]
1667 1667 try:
1668 1668 delattr(unfiltered, k)
1669 1669 except AttributeError:
1670 1670 pass
1671 1671 self.invalidatecaches()
1672 1672 if not self.currenttransaction():
1673 1673 # TODO: Changing contents of store outside transaction
1674 1674 # causes inconsistency. We should make in-memory store
1675 1675 # changes detectable, and abort if changed.
1676 1676 self.store.invalidatecaches()
1677 1677
1678 1678 def invalidateall(self):
1679 1679 '''Fully invalidates both store and non-store parts, causing the
1680 1680 subsequent operation to reread any outside changes.'''
1681 1681 # extension should hook this to invalidate its caches
1682 1682 self.invalidate()
1683 1683 self.invalidatedirstate()
1684 1684
1685 1685 @unfilteredmethod
1686 1686 def _refreshfilecachestats(self, tr):
1687 1687 """Reload stats of cached files so that they are flagged as valid"""
1688 1688 for k, ce in self._filecache.items():
1689 1689 k = pycompat.sysstr(k)
1690 1690 if k == r'dirstate' or k not in self.__dict__:
1691 1691 continue
1692 1692 ce.refresh()
1693 1693
1694 1694 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc,
1695 1695 inheritchecker=None, parentenvvar=None):
1696 1696 parentlock = None
1697 1697 # the contents of parentenvvar are used by the underlying lock to
1698 1698 # determine whether it can be inherited
1699 1699 if parentenvvar is not None:
1700 1700 parentlock = encoding.environ.get(parentenvvar)
1701 1701
1702 1702 timeout = 0
1703 1703 warntimeout = 0
1704 1704 if wait:
1705 1705 timeout = self.ui.configint("ui", "timeout")
1706 1706 warntimeout = self.ui.configint("ui", "timeout.warn")
1707 1707 # internal config: ui.signal-safe-lock
1708 1708 signalsafe = self.ui.configbool('ui', 'signal-safe-lock')
1709 1709
1710 1710 l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout,
1711 1711 releasefn=releasefn,
1712 1712 acquirefn=acquirefn, desc=desc,
1713 1713 inheritchecker=inheritchecker,
1714 1714 parentlock=parentlock,
1715 1715 signalsafe=signalsafe)
1716 1716 return l
1717 1717
1718 1718 def _afterlock(self, callback):
1719 1719 """add a callback to be run when the repository is fully unlocked
1720 1720
1721 1721 The callback will be executed when the outermost lock is released
1722 1722 (with wlock being higher level than 'lock')."""
1723 1723 for ref in (self._wlockref, self._lockref):
1724 1724 l = ref and ref()
1725 1725 if l and l.held:
1726 1726 l.postrelease.append(callback)
1727 1727 break
1728 1728 else: # no lock have been found.
1729 1729 callback()
1730 1730
1731 1731 def lock(self, wait=True):
1732 1732 '''Lock the repository store (.hg/store) and return a weak reference
1733 1733 to the lock. Use this before modifying the store (e.g. committing or
1734 1734 stripping). If you are opening a transaction, get a lock as well.)
1735 1735
1736 1736 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1737 1737 'wlock' first to avoid a dead-lock hazard.'''
1738 1738 l = self._currentlock(self._lockref)
1739 1739 if l is not None:
1740 1740 l.lock()
1741 1741 return l
1742 1742
1743 1743 l = self._lock(self.svfs, "lock", wait, None,
1744 1744 self.invalidate, _('repository %s') % self.origroot)
1745 1745 self._lockref = weakref.ref(l)
1746 1746 return l
1747 1747
1748 1748 def _wlockchecktransaction(self):
1749 1749 if self.currenttransaction() is not None:
1750 1750 raise error.LockInheritanceContractViolation(
1751 1751 'wlock cannot be inherited in the middle of a transaction')
1752 1752
1753 1753 def wlock(self, wait=True):
1754 1754 '''Lock the non-store parts of the repository (everything under
1755 1755 .hg except .hg/store) and return a weak reference to the lock.
1756 1756
1757 1757 Use this before modifying files in .hg.
1758 1758
1759 1759 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1760 1760 'wlock' first to avoid a dead-lock hazard.'''
1761 1761 l = self._wlockref and self._wlockref()
1762 1762 if l is not None and l.held:
1763 1763 l.lock()
1764 1764 return l
1765 1765
1766 1766 # We do not need to check for non-waiting lock acquisition. Such
1767 1767 # acquisition would not cause dead-lock as they would just fail.
1768 1768 if wait and (self.ui.configbool('devel', 'all-warnings')
1769 1769 or self.ui.configbool('devel', 'check-locks')):
1770 1770 if self._currentlock(self._lockref) is not None:
1771 1771 self.ui.develwarn('"wlock" acquired after "lock"')
1772 1772
1773 1773 def unlock():
1774 1774 if self.dirstate.pendingparentchange():
1775 1775 self.dirstate.invalidate()
1776 1776 else:
1777 1777 self.dirstate.write(None)
1778 1778
1779 1779 self._filecache['dirstate'].refresh()
1780 1780
1781 1781 l = self._lock(self.vfs, "wlock", wait, unlock,
1782 1782 self.invalidatedirstate, _('working directory of %s') %
1783 1783 self.origroot,
1784 1784 inheritchecker=self._wlockchecktransaction,
1785 1785 parentenvvar='HG_WLOCK_LOCKER')
1786 1786 self._wlockref = weakref.ref(l)
1787 1787 return l
1788 1788
1789 1789 def _currentlock(self, lockref):
1790 1790 """Returns the lock if it's held, or None if it's not."""
1791 1791 if lockref is None:
1792 1792 return None
1793 1793 l = lockref()
1794 1794 if l is None or not l.held:
1795 1795 return None
1796 1796 return l
1797 1797
1798 1798 def currentwlock(self):
1799 1799 """Returns the wlock if it's held, or None if it's not."""
1800 1800 return self._currentlock(self._wlockref)
1801 1801
1802 1802 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
1803 1803 """
1804 1804 commit an individual file as part of a larger transaction
1805 1805 """
1806 1806
1807 1807 fname = fctx.path()
1808 1808 fparent1 = manifest1.get(fname, nullid)
1809 1809 fparent2 = manifest2.get(fname, nullid)
1810 1810 if isinstance(fctx, context.filectx):
1811 1811 node = fctx.filenode()
1812 1812 if node in [fparent1, fparent2]:
1813 1813 self.ui.debug('reusing %s filelog entry\n' % fname)
1814 1814 if manifest1.flags(fname) != fctx.flags():
1815 1815 changelist.append(fname)
1816 1816 return node
1817 1817
1818 1818 flog = self.file(fname)
1819 1819 meta = {}
1820 1820 copy = fctx.renamed()
1821 1821 if copy and copy[0] != fname:
1822 1822 # Mark the new revision of this file as a copy of another
1823 1823 # file. This copy data will effectively act as a parent
1824 1824 # of this new revision. If this is a merge, the first
1825 1825 # parent will be the nullid (meaning "look up the copy data")
1826 1826 # and the second one will be the other parent. For example:
1827 1827 #
1828 1828 # 0 --- 1 --- 3 rev1 changes file foo
1829 1829 # \ / rev2 renames foo to bar and changes it
1830 1830 # \- 2 -/ rev3 should have bar with all changes and
1831 1831 # should record that bar descends from
1832 1832 # bar in rev2 and foo in rev1
1833 1833 #
1834 1834 # this allows this merge to succeed:
1835 1835 #
1836 1836 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
1837 1837 # \ / merging rev3 and rev4 should use bar@rev2
1838 1838 # \- 2 --- 4 as the merge base
1839 1839 #
1840 1840
1841 1841 cfname = copy[0]
1842 1842 crev = manifest1.get(cfname)
1843 1843 newfparent = fparent2
1844 1844
1845 1845 if manifest2: # branch merge
1846 1846 if fparent2 == nullid or crev is None: # copied on remote side
1847 1847 if cfname in manifest2:
1848 1848 crev = manifest2[cfname]
1849 1849 newfparent = fparent1
1850 1850
1851 1851 # Here, we used to search backwards through history to try to find
1852 1852 # where the file copy came from if the source of a copy was not in
1853 1853 # the parent directory. However, this doesn't actually make sense to
1854 1854 # do (what does a copy from something not in your working copy even
1855 1855 # mean?) and it causes bugs (eg, issue4476). Instead, we will warn
1856 1856 # the user that copy information was dropped, so if they didn't
1857 1857 # expect this outcome it can be fixed, but this is the correct
1858 1858 # behavior in this circumstance.
1859 1859
1860 1860 if crev:
1861 1861 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1862 1862 meta["copy"] = cfname
1863 1863 meta["copyrev"] = hex(crev)
1864 1864 fparent1, fparent2 = nullid, newfparent
1865 1865 else:
1866 1866 self.ui.warn(_("warning: can't find ancestor for '%s' "
1867 1867 "copied from '%s'!\n") % (fname, cfname))
1868 1868
1869 1869 elif fparent1 == nullid:
1870 1870 fparent1, fparent2 = fparent2, nullid
1871 1871 elif fparent2 != nullid:
1872 1872 # is one parent an ancestor of the other?
1873 1873 fparentancestors = flog.commonancestorsheads(fparent1, fparent2)
1874 1874 if fparent1 in fparentancestors:
1875 1875 fparent1, fparent2 = fparent2, nullid
1876 1876 elif fparent2 in fparentancestors:
1877 1877 fparent2 = nullid
1878 1878
1879 1879 # is the file changed?
1880 1880 text = fctx.data()
1881 1881 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
1882 1882 changelist.append(fname)
1883 1883 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
1884 1884 # are just the flags changed during merge?
1885 1885 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags():
1886 1886 changelist.append(fname)
1887 1887
1888 1888 return fparent1
1889 1889
1890 1890 def checkcommitpatterns(self, wctx, vdirs, match, status, fail):
1891 1891 """check for commit arguments that aren't committable"""
1892 1892 if match.isexact() or match.prefix():
1893 1893 matched = set(status.modified + status.added + status.removed)
1894 1894
1895 1895 for f in match.files():
1896 1896 f = self.dirstate.normalize(f)
1897 1897 if f == '.' or f in matched or f in wctx.substate:
1898 1898 continue
1899 1899 if f in status.deleted:
1900 1900 fail(f, _('file not found!'))
1901 1901 if f in vdirs: # visited directory
1902 1902 d = f + '/'
1903 1903 for mf in matched:
1904 1904 if mf.startswith(d):
1905 1905 break
1906 1906 else:
1907 1907 fail(f, _("no match under directory!"))
1908 1908 elif f not in self.dirstate:
1909 1909 fail(f, _("file not tracked!"))
1910 1910
1911 1911 @unfilteredmethod
1912 1912 def commit(self, text="", user=None, date=None, match=None, force=False,
1913 1913 editor=False, extra=None):
1914 1914 """Add a new revision to current repository.
1915 1915
1916 1916 Revision information is gathered from the working directory,
1917 1917 match can be used to filter the committed files. If editor is
1918 1918 supplied, it is called to get a commit message.
1919 1919 """
1920 1920 if extra is None:
1921 1921 extra = {}
1922 1922
1923 1923 def fail(f, msg):
1924 1924 raise error.Abort('%s: %s' % (f, msg))
1925 1925
1926 1926 if not match:
1927 1927 match = matchmod.always(self.root, '')
1928 1928
1929 1929 if not force:
1930 1930 vdirs = []
1931 1931 match.explicitdir = vdirs.append
1932 1932 match.bad = fail
1933 1933
1934 1934 wlock = lock = tr = None
1935 1935 try:
1936 1936 wlock = self.wlock()
1937 1937 lock = self.lock() # for recent changelog (see issue4368)
1938 1938
1939 1939 wctx = self[None]
1940 1940 merge = len(wctx.parents()) > 1
1941 1941
1942 1942 if not force and merge and not match.always():
1943 1943 raise error.Abort(_('cannot partially commit a merge '
1944 1944 '(do not specify files or patterns)'))
1945 1945
1946 1946 status = self.status(match=match, clean=force)
1947 1947 if force:
1948 1948 status.modified.extend(status.clean) # mq may commit clean files
1949 1949
1950 1950 # check subrepos
1951 1951 subs, commitsubs, newstate = subrepoutil.precommit(
1952 1952 self.ui, wctx, status, match, force=force)
1953 1953
1954 1954 # make sure all explicit patterns are matched
1955 1955 if not force:
1956 1956 self.checkcommitpatterns(wctx, vdirs, match, status, fail)
1957 1957
1958 1958 cctx = context.workingcommitctx(self, status,
1959 1959 text, user, date, extra)
1960 1960
1961 1961 # internal config: ui.allowemptycommit
1962 1962 allowemptycommit = (wctx.branch() != wctx.p1().branch()
1963 1963 or extra.get('close') or merge or cctx.files()
1964 1964 or self.ui.configbool('ui', 'allowemptycommit'))
1965 1965 if not allowemptycommit:
1966 1966 return None
1967 1967
1968 1968 if merge and cctx.deleted():
1969 1969 raise error.Abort(_("cannot commit merge with missing files"))
1970 1970
1971 1971 ms = mergemod.mergestate.read(self)
1972 1972 mergeutil.checkunresolved(ms)
1973 1973
1974 1974 if editor:
1975 1975 cctx._text = editor(self, cctx, subs)
1976 1976 edited = (text != cctx._text)
1977 1977
1978 1978 # Save commit message in case this transaction gets rolled back
1979 1979 # (e.g. by a pretxncommit hook). Leave the content alone on
1980 1980 # the assumption that the user will use the same editor again.
1981 1981 msgfn = self.savecommitmessage(cctx._text)
1982 1982
1983 1983 # commit subs and write new state
1984 1984 if subs:
1985 1985 for s in sorted(commitsubs):
1986 1986 sub = wctx.sub(s)
1987 1987 self.ui.status(_('committing subrepository %s\n') %
1988 1988 subrepoutil.subrelpath(sub))
1989 1989 sr = sub.commit(cctx._text, user, date)
1990 1990 newstate[s] = (newstate[s][0], sr)
1991 1991 subrepoutil.writestate(self, newstate)
1992 1992
1993 1993 p1, p2 = self.dirstate.parents()
1994 1994 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1995 1995 try:
1996 1996 self.hook("precommit", throw=True, parent1=hookp1,
1997 1997 parent2=hookp2)
1998 1998 tr = self.transaction('commit')
1999 1999 ret = self.commitctx(cctx, True)
2000 2000 except: # re-raises
2001 2001 if edited:
2002 2002 self.ui.write(
2003 2003 _('note: commit message saved in %s\n') % msgfn)
2004 2004 raise
2005 2005 # update bookmarks, dirstate and mergestate
2006 2006 bookmarks.update(self, [p1, p2], ret)
2007 2007 cctx.markcommitted(ret)
2008 2008 ms.reset()
2009 2009 tr.close()
2010 2010
2011 2011 finally:
2012 2012 lockmod.release(tr, lock, wlock)
2013 2013
2014 2014 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
2015 2015 # hack for command that use a temporary commit (eg: histedit)
2016 2016 # temporary commit got stripped before hook release
2017 2017 if self.changelog.hasnode(ret):
2018 2018 self.hook("commit", node=node, parent1=parent1,
2019 2019 parent2=parent2)
2020 2020 self._afterlock(commithook)
2021 2021 return ret
2022 2022
2023 2023 @unfilteredmethod
2024 2024 def commitctx(self, ctx, error=False):
2025 2025 """Add a new revision to current repository.
2026 2026 Revision information is passed via the context argument.
2027 2027 """
2028 2028
2029 2029 tr = None
2030 2030 p1, p2 = ctx.p1(), ctx.p2()
2031 2031 user = ctx.user()
2032 2032
2033 2033 lock = self.lock()
2034 2034 try:
2035 2035 tr = self.transaction("commit")
2036 2036 trp = weakref.proxy(tr)
2037 2037
2038 2038 if ctx.manifestnode():
2039 2039 # reuse an existing manifest revision
2040 2040 mn = ctx.manifestnode()
2041 2041 files = ctx.files()
2042 2042 elif ctx.files():
2043 2043 m1ctx = p1.manifestctx()
2044 2044 m2ctx = p2.manifestctx()
2045 2045 mctx = m1ctx.copy()
2046 2046
2047 2047 m = mctx.read()
2048 2048 m1 = m1ctx.read()
2049 2049 m2 = m2ctx.read()
2050 2050
2051 2051 # check in files
2052 2052 added = []
2053 2053 changed = []
2054 2054 removed = list(ctx.removed())
2055 2055 linkrev = len(self)
2056 2056 self.ui.note(_("committing files:\n"))
2057 2057 for f in sorted(ctx.modified() + ctx.added()):
2058 2058 self.ui.note(f + "\n")
2059 2059 try:
2060 2060 fctx = ctx[f]
2061 2061 if fctx is None:
2062 2062 removed.append(f)
2063 2063 else:
2064 2064 added.append(f)
2065 2065 m[f] = self._filecommit(fctx, m1, m2, linkrev,
2066 2066 trp, changed)
2067 2067 m.setflag(f, fctx.flags())
2068 2068 except OSError as inst:
2069 2069 self.ui.warn(_("trouble committing %s!\n") % f)
2070 2070 raise
2071 2071 except IOError as inst:
2072 2072 errcode = getattr(inst, 'errno', errno.ENOENT)
2073 2073 if error or errcode and errcode != errno.ENOENT:
2074 2074 self.ui.warn(_("trouble committing %s!\n") % f)
2075 2075 raise
2076 2076
2077 2077 # update manifest
2078 2078 self.ui.note(_("committing manifest\n"))
2079 2079 removed = [f for f in sorted(removed) if f in m1 or f in m2]
2080 2080 drop = [f for f in removed if f in m]
2081 2081 for f in drop:
2082 2082 del m[f]
2083 2083 mn = mctx.write(trp, linkrev,
2084 2084 p1.manifestnode(), p2.manifestnode(),
2085 2085 added, drop)
2086 2086 files = changed + removed
2087 2087 else:
2088 2088 mn = p1.manifestnode()
2089 2089 files = []
2090 2090
2091 2091 # update changelog
2092 2092 self.ui.note(_("committing changelog\n"))
2093 2093 self.changelog.delayupdate(tr)
2094 2094 n = self.changelog.add(mn, files, ctx.description(),
2095 2095 trp, p1.node(), p2.node(),
2096 2096 user, ctx.date(), ctx.extra().copy())
2097 2097 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
2098 2098 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
2099 2099 parent2=xp2)
2100 2100 # set the new commit is proper phase
2101 2101 targetphase = subrepoutil.newcommitphase(self.ui, ctx)
2102 2102 if targetphase:
2103 2103 # retract boundary do not alter parent changeset.
2104 2104 # if a parent have higher the resulting phase will
2105 2105 # be compliant anyway
2106 2106 #
2107 2107 # if minimal phase was 0 we don't need to retract anything
2108 2108 phases.registernew(self, tr, targetphase, [n])
2109 2109 tr.close()
2110 2110 return n
2111 2111 finally:
2112 2112 if tr:
2113 2113 tr.release()
2114 2114 lock.release()
2115 2115
2116 2116 @unfilteredmethod
2117 2117 def destroying(self):
2118 2118 '''Inform the repository that nodes are about to be destroyed.
2119 2119 Intended for use by strip and rollback, so there's a common
2120 2120 place for anything that has to be done before destroying history.
2121 2121
2122 2122 This is mostly useful for saving state that is in memory and waiting
2123 2123 to be flushed when the current lock is released. Because a call to
2124 2124 destroyed is imminent, the repo will be invalidated causing those
2125 2125 changes to stay in memory (waiting for the next unlock), or vanish
2126 2126 completely.
2127 2127 '''
2128 2128 # When using the same lock to commit and strip, the phasecache is left
2129 2129 # dirty after committing. Then when we strip, the repo is invalidated,
2130 2130 # causing those changes to disappear.
2131 2131 if '_phasecache' in vars(self):
2132 2132 self._phasecache.write()
2133 2133
2134 2134 @unfilteredmethod
2135 2135 def destroyed(self):
2136 2136 '''Inform the repository that nodes have been destroyed.
2137 2137 Intended for use by strip and rollback, so there's a common
2138 2138 place for anything that has to be done after destroying history.
2139 2139 '''
2140 2140 # When one tries to:
2141 2141 # 1) destroy nodes thus calling this method (e.g. strip)
2142 2142 # 2) use phasecache somewhere (e.g. commit)
2143 2143 #
2144 2144 # then 2) will fail because the phasecache contains nodes that were
2145 2145 # removed. We can either remove phasecache from the filecache,
2146 2146 # causing it to reload next time it is accessed, or simply filter
2147 2147 # the removed nodes now and write the updated cache.
2148 2148 self._phasecache.filterunknown(self)
2149 2149 self._phasecache.write()
2150 2150
2151 2151 # refresh all repository caches
2152 2152 self.updatecaches()
2153 2153
2154 2154 # Ensure the persistent tag cache is updated. Doing it now
2155 2155 # means that the tag cache only has to worry about destroyed
2156 2156 # heads immediately after a strip/rollback. That in turn
2157 2157 # guarantees that "cachetip == currenttip" (comparing both rev
2158 2158 # and node) always means no nodes have been added or destroyed.
2159 2159
2160 2160 # XXX this is suboptimal when qrefresh'ing: we strip the current
2161 2161 # head, refresh the tag cache, then immediately add a new head.
2162 2162 # But I think doing it this way is necessary for the "instant
2163 2163 # tag cache retrieval" case to work.
2164 2164 self.invalidate()
2165 2165
2166 2166 def status(self, node1='.', node2=None, match=None,
2167 2167 ignored=False, clean=False, unknown=False,
2168 2168 listsubrepos=False):
2169 2169 '''a convenience method that calls node1.status(node2)'''
2170 2170 return self[node1].status(node2, match, ignored, clean, unknown,
2171 2171 listsubrepos)
2172 2172
2173 2173 def addpostdsstatus(self, ps):
2174 2174 """Add a callback to run within the wlock, at the point at which status
2175 2175 fixups happen.
2176 2176
2177 2177 On status completion, callback(wctx, status) will be called with the
2178 2178 wlock held, unless the dirstate has changed from underneath or the wlock
2179 2179 couldn't be grabbed.
2180 2180
2181 2181 Callbacks should not capture and use a cached copy of the dirstate --
2182 2182 it might change in the meanwhile. Instead, they should access the
2183 2183 dirstate via wctx.repo().dirstate.
2184 2184
2185 2185 This list is emptied out after each status run -- extensions should
2186 2186 make sure it adds to this list each time dirstate.status is called.
2187 2187 Extensions should also make sure they don't call this for statuses
2188 2188 that don't involve the dirstate.
2189 2189 """
2190 2190
2191 2191 # The list is located here for uniqueness reasons -- it is actually
2192 2192 # managed by the workingctx, but that isn't unique per-repo.
2193 2193 self._postdsstatus.append(ps)
2194 2194
2195 2195 def postdsstatus(self):
2196 2196 """Used by workingctx to get the list of post-dirstate-status hooks."""
2197 2197 return self._postdsstatus
2198 2198
2199 2199 def clearpostdsstatus(self):
2200 2200 """Used by workingctx to clear post-dirstate-status hooks."""
2201 2201 del self._postdsstatus[:]
2202 2202
2203 2203 def heads(self, start=None):
2204 2204 if start is None:
2205 2205 cl = self.changelog
2206 2206 headrevs = reversed(cl.headrevs())
2207 2207 return [cl.node(rev) for rev in headrevs]
2208 2208
2209 2209 heads = self.changelog.heads(start)
2210 2210 # sort the output in rev descending order
2211 2211 return sorted(heads, key=self.changelog.rev, reverse=True)
2212 2212
2213 2213 def branchheads(self, branch=None, start=None, closed=False):
2214 2214 '''return a (possibly filtered) list of heads for the given branch
2215 2215
2216 2216 Heads are returned in topological order, from newest to oldest.
2217 2217 If branch is None, use the dirstate branch.
2218 2218 If start is not None, return only heads reachable from start.
2219 2219 If closed is True, return heads that are marked as closed as well.
2220 2220 '''
2221 2221 if branch is None:
2222 2222 branch = self[None].branch()
2223 2223 branches = self.branchmap()
2224 2224 if branch not in branches:
2225 2225 return []
2226 2226 # the cache returns heads ordered lowest to highest
2227 2227 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
2228 2228 if start is not None:
2229 2229 # filter out the heads that cannot be reached from startrev
2230 2230 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
2231 2231 bheads = [h for h in bheads if h in fbheads]
2232 2232 return bheads
2233 2233
2234 2234 def branches(self, nodes):
2235 2235 if not nodes:
2236 2236 nodes = [self.changelog.tip()]
2237 2237 b = []
2238 2238 for n in nodes:
2239 2239 t = n
2240 2240 while True:
2241 2241 p = self.changelog.parents(n)
2242 2242 if p[1] != nullid or p[0] == nullid:
2243 2243 b.append((t, n, p[0], p[1]))
2244 2244 break
2245 2245 n = p[0]
2246 2246 return b
2247 2247
2248 2248 def between(self, pairs):
2249 2249 r = []
2250 2250
2251 2251 for top, bottom in pairs:
2252 2252 n, l, i = top, [], 0
2253 2253 f = 1
2254 2254
2255 2255 while n != bottom and n != nullid:
2256 2256 p = self.changelog.parents(n)[0]
2257 2257 if i == f:
2258 2258 l.append(n)
2259 2259 f = f * 2
2260 2260 n = p
2261 2261 i += 1
2262 2262
2263 2263 r.append(l)
2264 2264
2265 2265 return r
2266 2266
2267 2267 def checkpush(self, pushop):
2268 2268 """Extensions can override this function if additional checks have
2269 2269 to be performed before pushing, or call it if they override push
2270 2270 command.
2271 2271 """
2272 2272
2273 2273 @unfilteredpropertycache
2274 2274 def prepushoutgoinghooks(self):
2275 2275 """Return util.hooks consists of a pushop with repo, remote, outgoing
2276 2276 methods, which are called before pushing changesets.
2277 2277 """
2278 2278 return util.hooks()
2279 2279
2280 2280 def pushkey(self, namespace, key, old, new):
2281 2281 try:
2282 2282 tr = self.currenttransaction()
2283 2283 hookargs = {}
2284 2284 if tr is not None:
2285 2285 hookargs.update(tr.hookargs)
2286 2286 hookargs = pycompat.strkwargs(hookargs)
2287 2287 hookargs[r'namespace'] = namespace
2288 2288 hookargs[r'key'] = key
2289 2289 hookargs[r'old'] = old
2290 2290 hookargs[r'new'] = new
2291 2291 self.hook('prepushkey', throw=True, **hookargs)
2292 2292 except error.HookAbort as exc:
2293 2293 self.ui.write_err(_("pushkey-abort: %s\n") % exc)
2294 2294 if exc.hint:
2295 2295 self.ui.write_err(_("(%s)\n") % exc.hint)
2296 2296 return False
2297 2297 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
2298 2298 ret = pushkey.push(self, namespace, key, old, new)
2299 2299 def runhook():
2300 2300 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
2301 2301 ret=ret)
2302 2302 self._afterlock(runhook)
2303 2303 return ret
2304 2304
2305 2305 def listkeys(self, namespace):
2306 2306 self.hook('prelistkeys', throw=True, namespace=namespace)
2307 2307 self.ui.debug('listing keys for "%s"\n' % namespace)
2308 2308 values = pushkey.list(self, namespace)
2309 2309 self.hook('listkeys', namespace=namespace, values=values)
2310 2310 return values
2311 2311
2312 2312 def debugwireargs(self, one, two, three=None, four=None, five=None):
2313 2313 '''used to test argument passing over the wire'''
2314 2314 return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
2315 2315 pycompat.bytestr(four),
2316 2316 pycompat.bytestr(five))
2317 2317
2318 2318 def savecommitmessage(self, text):
2319 2319 fp = self.vfs('last-message.txt', 'wb')
2320 2320 try:
2321 2321 fp.write(text)
2322 2322 finally:
2323 2323 fp.close()
2324 2324 return self.pathto(fp.name[len(self.root) + 1:])
2325 2325
2326 2326 # used to avoid circular references so destructors work
2327 2327 def aftertrans(files):
2328 2328 renamefiles = [tuple(t) for t in files]
2329 2329 def a():
2330 2330 for vfs, src, dest in renamefiles:
2331 2331 # if src and dest refer to a same file, vfs.rename is a no-op,
2332 2332 # leaving both src and dest on disk. delete dest to make sure
2333 2333 # the rename couldn't be such a no-op.
2334 2334 vfs.tryunlink(dest)
2335 2335 try:
2336 2336 vfs.rename(src, dest)
2337 2337 except OSError: # journal file does not yet exist
2338 2338 pass
2339 2339 return a
2340 2340
2341 2341 def undoname(fn):
2342 2342 base, name = os.path.split(fn)
2343 2343 assert name.startswith('journal')
2344 2344 return os.path.join(base, name.replace('journal', 'undo', 1))
2345 2345
2346 2346 def instance(ui, path, create, intents=None):
2347 2347 return localrepository(ui, util.urllocalpath(path), create,
2348 2348 intents=intents)
2349 2349
2350 2350 def islocal(path):
2351 2351 return True
2352 2352
2353 2353 def newreporequirements(repo):
2354 2354 """Determine the set of requirements for a new local repository.
2355 2355
2356 2356 Extensions can wrap this function to specify custom requirements for
2357 2357 new repositories.
2358 2358 """
2359 2359 ui = repo.ui
2360 2360 requirements = {'revlogv1'}
2361 2361 if ui.configbool('format', 'usestore'):
2362 2362 requirements.add('store')
2363 2363 if ui.configbool('format', 'usefncache'):
2364 2364 requirements.add('fncache')
2365 2365 if ui.configbool('format', 'dotencode'):
2366 2366 requirements.add('dotencode')
2367 2367
2368 2368 compengine = ui.config('experimental', 'format.compression')
2369 2369 if compengine not in util.compengines:
2370 2370 raise error.Abort(_('compression engine %s defined by '
2371 2371 'experimental.format.compression not available') %
2372 2372 compengine,
2373 2373 hint=_('run "hg debuginstall" to list available '
2374 2374 'compression engines'))
2375 2375
2376 2376 # zlib is the historical default and doesn't need an explicit requirement.
2377 2377 if compengine != 'zlib':
2378 2378 requirements.add('exp-compression-%s' % compengine)
2379 2379
2380 2380 if scmutil.gdinitconfig(ui):
2381 2381 requirements.add('generaldelta')
2382 2382 if ui.configbool('experimental', 'treemanifest'):
2383 2383 requirements.add('treemanifest')
2384 2384 # experimental config: format.sparse-revlog
2385 2385 if ui.configbool('format', 'sparse-revlog'):
2386 2386 requirements.add(SPARSEREVLOG_REQUIREMENT)
2387 2387
2388 2388 revlogv2 = ui.config('experimental', 'revlogv2')
2389 2389 if revlogv2 == 'enable-unstable-format-and-corrupt-my-data':
2390 2390 requirements.remove('revlogv1')
2391 2391 # generaldelta is implied by revlogv2.
2392 2392 requirements.discard('generaldelta')
2393 2393 requirements.add(REVLOGV2_REQUIREMENT)
2394 2394
2395 2395 return requirements
@@ -1,402 +1,402 b''
1 1 #require no-reposimplestore
2 2
3 3 Check whether size of generaldelta revlog is not bigger than its
4 4 regular equivalent. Test would fail if generaldelta was naive
5 5 implementation of parentdelta: third manifest revision would be fully
6 6 inserted due to big distance from its paren revision (zero).
7 7
8 8 $ hg init repo --config format.generaldelta=no --config format.usegeneraldelta=no
9 9 $ cd repo
10 10 $ echo foo > foo
11 11 $ echo bar > bar
12 12 $ echo baz > baz
13 13 $ hg commit -q -Am boo
14 14 $ hg clone --pull . ../gdrepo -q --config format.generaldelta=yes
15 15 $ for r in 1 2 3; do
16 16 > echo $r > foo
17 17 > hg commit -q -m $r
18 18 > hg up -q -r 0
19 19 > hg pull . -q -r $r -R ../gdrepo
20 20 > done
21 21
22 22 $ cd ..
23 23 >>> from __future__ import print_function
24 24 >>> import os
25 25 >>> regsize = os.stat("repo/.hg/store/00manifest.i").st_size
26 26 >>> gdsize = os.stat("gdrepo/.hg/store/00manifest.i").st_size
27 27 >>> if regsize < gdsize:
28 28 ... print('generaldata increased size of manifest')
29 29
30 30 Verify rev reordering doesnt create invalid bundles (issue4462)
31 31 This requires a commit tree that when pulled will reorder manifest revs such
32 32 that the second manifest to create a file rev will be ordered before the first
33 33 manifest to create that file rev. We also need to do a partial pull to ensure
34 34 reordering happens. At the end we verify the linkrev points at the earliest
35 35 commit.
36 36
37 37 $ hg init server --config format.generaldelta=True
38 38 $ cd server
39 39 $ touch a
40 40 $ hg commit -Aqm a
41 41 $ echo x > x
42 42 $ echo y > y
43 43 $ hg commit -Aqm xy
44 44 $ hg up -q '.^'
45 45 $ echo x > x
46 46 $ echo z > z
47 47 $ hg commit -Aqm xz
48 48 $ hg up -q 1
49 49 $ echo b > b
50 50 $ hg commit -Aqm b
51 51 $ hg merge -q 2
52 52 $ hg commit -Aqm merge
53 53 $ echo c > c
54 54 $ hg commit -Aqm c
55 55 $ hg log -G -T '{rev} {shortest(node)} {desc}'
56 56 @ 5 ebb8 c
57 57 |
58 58 o 4 baf7 merge
59 59 |\
60 60 | o 3 a129 b
61 61 | |
62 62 o | 2 958c xz
63 63 | |
64 64 | o 1 f00c xy
65 65 |/
66 66 o 0 3903 a
67 67
68 68 $ cd ..
69 69 $ hg init client --config format.generaldelta=false --config format.usegeneraldelta=false
70 70 $ cd client
71 71 $ hg pull -q ../server -r 4
72 72 $ hg debugdeltachain x
73 73 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
74 74 0 1 1 -1 base 3 2 3 1.50000 3 0 0.00000
75 75
76 76 $ cd ..
77 77
78 78 Test "usegeneraldelta" config
79 79 (repo are general delta, but incoming bundle are not re-deltafied)
80 80
81 81 delta coming from the server base delta server are not recompressed.
82 82 (also include the aggressive version for comparison)
83 83
84 84 $ hg clone repo --pull --config format.usegeneraldelta=1 usegd
85 85 requesting all changes
86 86 adding changesets
87 87 adding manifests
88 88 adding file changes
89 89 added 4 changesets with 6 changes to 3 files (+2 heads)
90 90 new changesets 0ea3fcf9d01d:bba78d330d9c
91 91 updating to branch default
92 92 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
93 93 $ hg clone repo --pull --config format.generaldelta=1 full
94 94 requesting all changes
95 95 adding changesets
96 96 adding manifests
97 97 adding file changes
98 98 added 4 changesets with 6 changes to 3 files (+2 heads)
99 99 new changesets 0ea3fcf9d01d:bba78d330d9c
100 100 updating to branch default
101 101 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 102 $ hg -R repo debugdeltachain -m
103 103 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
104 104 0 1 1 -1 base 104 135 104 0.77037 104 0 0.00000
105 105 1 1 2 0 prev 57 135 161 1.19259 161 0 0.00000
106 106 2 1 3 1 prev 57 135 218 1.61481 218 0 0.00000
107 107 3 2 1 -1 base 104 135 104 0.77037 104 0 0.00000
108 108 $ hg -R usegd debugdeltachain -m
109 109 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
110 110 0 1 1 -1 base 104 135 104 0.77037 104 0 0.00000
111 111 1 1 2 0 p1 57 135 161 1.19259 161 0 0.00000
112 112 2 1 3 1 prev 57 135 218 1.61481 218 0 0.00000
113 113 3 1 2 0 p1 57 135 161 1.19259 275 114 0.70807
114 114 $ hg -R full debugdeltachain -m
115 115 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
116 116 0 1 1 -1 base 104 135 104 0.77037 104 0 0.00000
117 117 1 1 2 0 p1 57 135 161 1.19259 161 0 0.00000
118 118 2 1 2 0 p1 57 135 161 1.19259 218 57 0.35404
119 119 3 1 2 0 p1 57 135 161 1.19259 275 114 0.70807
120 120
121 121 Test revlog.optimize-delta-parent-choice
122 122
123 123 $ hg init --config format.generaldelta=1 aggressive
124 124 $ cd aggressive
125 125 $ cat << EOF >> .hg/hgrc
126 126 > [format]
127 127 > generaldelta = 1
128 128 > EOF
129 129 $ touch a b c d e
130 130 $ hg commit -Aqm side1
131 131 $ hg up -q null
132 132 $ touch x y
133 133 $ hg commit -Aqm side2
134 134
135 135 - Verify non-aggressive merge uses p1 (commit 1) as delta parent
136 136 $ hg merge -q 0
137 137 $ hg commit -q -m merge
138 138 $ hg debugdeltachain -m
139 139 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
140 140 0 1 1 -1 base 59 215 59 0.27442 59 0 0.00000
141 141 1 1 2 0 prev 61 86 120 1.39535 120 0 0.00000
142 142 2 1 2 0 p2 62 301 121 0.40199 182 61 0.50413
143 143
144 144 $ hg strip -q -r . --config extensions.strip=
145 145
146 146 - Verify aggressive merge uses p2 (commit 0) as delta parent
147 147 $ hg up -q -C 1
148 148 $ hg merge -q 0
149 $ hg commit -q -m merge --config revlog.optimize-delta-parent-choice=yes
149 $ hg commit -q -m merge --config storage.revlog.optimize-delta-parent-choice=yes
150 150 $ hg debugdeltachain -m
151 151 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
152 152 0 1 1 -1 base 59 215 59 0.27442 59 0 0.00000
153 153 1 1 2 0 prev 61 86 120 1.39535 120 0 0.00000
154 154 2 1 2 0 p2 62 301 121 0.40199 182 61 0.50413
155 155
156 156 Test that strip bundle use bundle2
157 157 $ hg --config extensions.strip= strip .
158 158 0 files updated, 0 files merged, 5 files removed, 0 files unresolved
159 159 saved backup bundle to $TESTTMP/aggressive/.hg/strip-backup/1c5d4dc9a8b8-6c68e60c-backup.hg
160 160 $ hg debugbundle .hg/strip-backup/*
161 161 Stream params: {Compression: BZ}
162 162 changegroup -- {nbchanges: 1, version: 02} (mandatory: True)
163 163 1c5d4dc9a8b8d6e1750966d343e94db665e7a1e9
164 164 cache:rev-branch-cache -- {} (mandatory: False)
165 165 phase-heads -- {} (mandatory: True)
166 166 1c5d4dc9a8b8d6e1750966d343e94db665e7a1e9 draft
167 167
168 168 $ cd ..
169 169
170 170 test maxdeltachainspan
171 171
172 172 $ hg init source-repo
173 173 $ cd source-repo
174 174 $ hg debugbuilddag --new-file '.+5:brancha$.+11:branchb$.+30:branchc<brancha+2<branchb+2'
175 175 # add an empty revision somewhere
176 176 $ hg up tip
177 177 14 files updated, 0 files merged, 0 files removed, 0 files unresolved
178 178 $ hg rm .
179 179 removing nf10
180 180 removing nf11
181 181 removing nf12
182 182 removing nf13
183 183 removing nf14
184 184 removing nf15
185 185 removing nf16
186 186 removing nf17
187 187 removing nf51
188 188 removing nf52
189 189 removing nf6
190 190 removing nf7
191 191 removing nf8
192 192 removing nf9
193 193 $ hg commit -m 'empty all'
194 194 $ hg revert --all --rev 'p1(.)'
195 195 adding nf10
196 196 adding nf11
197 197 adding nf12
198 198 adding nf13
199 199 adding nf14
200 200 adding nf15
201 201 adding nf16
202 202 adding nf17
203 203 adding nf51
204 204 adding nf52
205 205 adding nf6
206 206 adding nf7
207 207 adding nf8
208 208 adding nf9
209 209 $ hg commit -m 'restore all'
210 210 $ hg up null
211 211 0 files updated, 0 files merged, 14 files removed, 0 files unresolved
212 212 $
213 213 $ cd ..
214 214 $ hg -R source-repo debugdeltachain -m
215 215 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
216 216 0 1 1 -1 base 46 45 46 1.02222 46 0 0.00000
217 217 1 1 2 0 p1 57 90 103 1.14444 103 0 0.00000
218 218 2 1 3 1 p1 57 135 160 1.18519 160 0 0.00000
219 219 3 1 4 2 p1 57 180 217 1.20556 217 0 0.00000
220 220 4 1 5 3 p1 57 225 274 1.21778 274 0 0.00000
221 221 5 1 6 4 p1 57 270 331 1.22593 331 0 0.00000
222 222 6 2 1 -1 base 46 45 46 1.02222 46 0 0.00000
223 223 7 2 2 6 p1 57 90 103 1.14444 103 0 0.00000
224 224 8 2 3 7 p1 57 135 160 1.18519 160 0 0.00000
225 225 9 2 4 8 p1 57 180 217 1.20556 217 0 0.00000
226 226 10 2 5 9 p1 58 226 275 1.21681 275 0 0.00000
227 227 11 2 6 10 p1 58 272 333 1.22426 333 0 0.00000
228 228 12 2 7 11 p1 58 318 391 1.22956 391 0 0.00000
229 229 13 2 8 12 p1 58 364 449 1.23352 449 0 0.00000
230 230 14 2 9 13 p1 58 410 507 1.23659 507 0 0.00000
231 231 15 2 10 14 p1 58 456 565 1.23904 565 0 0.00000
232 232 16 2 11 15 p1 58 502 623 1.24104 623 0 0.00000
233 233 17 2 12 16 p1 58 548 681 1.24270 681 0 0.00000
234 234 18 3 1 -1 base 47 46 47 1.02174 47 0 0.00000
235 235 19 3 2 18 p1 58 92 105 1.14130 105 0 0.00000
236 236 20 3 3 19 p1 58 138 163 1.18116 163 0 0.00000
237 237 21 3 4 20 p1 58 184 221 1.20109 221 0 0.00000
238 238 22 3 5 21 p1 58 230 279 1.21304 279 0 0.00000
239 239 23 3 6 22 p1 58 276 337 1.22101 337 0 0.00000
240 240 24 3 7 23 p1 58 322 395 1.22671 395 0 0.00000
241 241 25 3 8 24 p1 58 368 453 1.23098 453 0 0.00000
242 242 26 3 9 25 p1 58 414 511 1.23430 511 0 0.00000
243 243 27 3 10 26 p1 58 460 569 1.23696 569 0 0.00000
244 244 28 3 11 27 p1 58 506 627 1.23913 627 0 0.00000
245 245 29 3 12 28 p1 58 552 685 1.24094 685 0 0.00000
246 246 30 3 13 29 p1 58 598 743 1.24247 743 0 0.00000
247 247 31 3 14 30 p1 58 644 801 1.24379 801 0 0.00000
248 248 32 3 15 31 p1 58 690 859 1.24493 859 0 0.00000
249 249 33 3 16 32 p1 58 736 917 1.24592 917 0 0.00000
250 250 34 3 17 33 p1 58 782 975 1.24680 975 0 0.00000
251 251 35 3 18 34 p1 58 828 1033 1.24758 1033 0 0.00000
252 252 36 3 19 35 p1 58 874 1091 1.24828 1091 0 0.00000
253 253 37 3 20 36 p1 58 920 1149 1.24891 1149 0 0.00000
254 254 38 3 21 37 p1 58 966 1207 1.24948 1207 0 0.00000
255 255 39 3 22 38 p1 58 1012 1265 1.25000 1265 0 0.00000
256 256 40 3 23 39 p1 58 1058 1323 1.25047 1323 0 0.00000
257 257 41 3 24 40 p1 58 1104 1381 1.25091 1381 0 0.00000
258 258 42 3 25 41 p1 58 1150 1439 1.25130 1439 0 0.00000
259 259 43 3 26 42 p1 58 1196 1497 1.25167 1497 0 0.00000
260 260 44 3 27 43 p1 58 1242 1555 1.25201 1555 0 0.00000
261 261 45 3 28 44 p1 58 1288 1613 1.25233 1613 0 0.00000
262 262 46 3 29 45 p1 58 1334 1671 1.25262 1671 0 0.00000
263 263 47 3 30 46 p1 58 1380 1729 1.25290 1729 0 0.00000
264 264 48 3 31 47 p1 58 1426 1787 1.25316 1787 0 0.00000
265 265 49 4 1 -1 base 197 316 197 0.62342 197 0 0.00000
266 266 50 4 2 49 p1 58 362 255 0.70442 255 0 0.00000
267 267 51 4 3 50 prev 356 594 611 1.02862 611 0 0.00000
268 268 52 4 4 51 p1 58 640 669 1.04531 669 0 0.00000
269 269 53 5 1 -1 base 0 0 0 0.00000 0 0 0.00000
270 270 54 5 2 53 p1 376 640 376 0.58750 376 0 0.00000
271 271 $ hg clone --pull source-repo --config experimental.maxdeltachainspan=2800 relax-chain --config format.generaldelta=yes
272 272 requesting all changes
273 273 adding changesets
274 274 adding manifests
275 275 adding file changes
276 276 added 55 changesets with 53 changes to 53 files (+2 heads)
277 277 new changesets 61246295ee1e:c930ac4a5b32
278 278 updating to branch default
279 279 14 files updated, 0 files merged, 0 files removed, 0 files unresolved
280 280 $ hg -R relax-chain debugdeltachain -m
281 281 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
282 282 0 1 1 -1 base 46 45 46 1.02222 46 0 0.00000
283 283 1 1 2 0 p1 57 90 103 1.14444 103 0 0.00000
284 284 2 1 3 1 p1 57 135 160 1.18519 160 0 0.00000
285 285 3 1 4 2 p1 57 180 217 1.20556 217 0 0.00000
286 286 4 1 5 3 p1 57 225 274 1.21778 274 0 0.00000
287 287 5 1 6 4 p1 57 270 331 1.22593 331 0 0.00000
288 288 6 2 1 -1 base 46 45 46 1.02222 46 0 0.00000
289 289 7 2 2 6 p1 57 90 103 1.14444 103 0 0.00000
290 290 8 2 3 7 p1 57 135 160 1.18519 160 0 0.00000
291 291 9 2 4 8 p1 57 180 217 1.20556 217 0 0.00000
292 292 10 2 5 9 p1 58 226 275 1.21681 275 0 0.00000
293 293 11 2 6 10 p1 58 272 333 1.22426 333 0 0.00000
294 294 12 2 7 11 p1 58 318 391 1.22956 391 0 0.00000
295 295 13 2 8 12 p1 58 364 449 1.23352 449 0 0.00000
296 296 14 2 9 13 p1 58 410 507 1.23659 507 0 0.00000
297 297 15 2 10 14 p1 58 456 565 1.23904 565 0 0.00000
298 298 16 2 11 15 p1 58 502 623 1.24104 623 0 0.00000
299 299 17 2 12 16 p1 58 548 681 1.24270 681 0 0.00000
300 300 18 3 1 -1 base 47 46 47 1.02174 47 0 0.00000
301 301 19 3 2 18 p1 58 92 105 1.14130 105 0 0.00000
302 302 20 3 3 19 p1 58 138 163 1.18116 163 0 0.00000
303 303 21 3 4 20 p1 58 184 221 1.20109 221 0 0.00000
304 304 22 3 5 21 p1 58 230 279 1.21304 279 0 0.00000
305 305 23 3 6 22 p1 58 276 337 1.22101 337 0 0.00000
306 306 24 3 7 23 p1 58 322 395 1.22671 395 0 0.00000
307 307 25 3 8 24 p1 58 368 453 1.23098 453 0 0.00000
308 308 26 3 9 25 p1 58 414 511 1.23430 511 0 0.00000
309 309 27 3 10 26 p1 58 460 569 1.23696 569 0 0.00000
310 310 28 3 11 27 p1 58 506 627 1.23913 627 0 0.00000
311 311 29 3 12 28 p1 58 552 685 1.24094 685 0 0.00000
312 312 30 3 13 29 p1 58 598 743 1.24247 743 0 0.00000
313 313 31 3 14 30 p1 58 644 801 1.24379 801 0 0.00000
314 314 32 3 15 31 p1 58 690 859 1.24493 859 0 0.00000
315 315 33 3 16 32 p1 58 736 917 1.24592 917 0 0.00000
316 316 34 3 17 33 p1 58 782 975 1.24680 975 0 0.00000
317 317 35 3 18 34 p1 58 828 1033 1.24758 1033 0 0.00000
318 318 36 3 19 35 p1 58 874 1091 1.24828 1091 0 0.00000
319 319 37 3 20 36 p1 58 920 1149 1.24891 1149 0 0.00000
320 320 38 3 21 37 p1 58 966 1207 1.24948 1207 0 0.00000
321 321 39 3 22 38 p1 58 1012 1265 1.25000 1265 0 0.00000
322 322 40 3 23 39 p1 58 1058 1323 1.25047 1323 0 0.00000
323 323 41 3 24 40 p1 58 1104 1381 1.25091 1381 0 0.00000
324 324 42 3 25 41 p1 58 1150 1439 1.25130 1439 0 0.00000
325 325 43 3 26 42 p1 58 1196 1497 1.25167 1497 0 0.00000
326 326 44 3 27 43 p1 58 1242 1555 1.25201 1555 0 0.00000
327 327 45 3 28 44 p1 58 1288 1613 1.25233 1613 0 0.00000
328 328 46 3 29 45 p1 58 1334 1671 1.25262 1671 0 0.00000
329 329 47 3 30 46 p1 58 1380 1729 1.25290 1729 0 0.00000
330 330 48 3 31 47 p1 58 1426 1787 1.25316 1787 0 0.00000
331 331 49 4 1 -1 base 197 316 197 0.62342 197 0 0.00000
332 332 50 4 2 49 p1 58 362 255 0.70442 255 0 0.00000
333 333 51 2 13 17 p1 58 594 739 1.24411 2781 2042 2.76319
334 334 52 5 1 -1 base 369 640 369 0.57656 369 0 0.00000
335 335 53 6 1 -1 base 0 0 0 0.00000 0 0 0.00000
336 336 54 6 2 53 p1 376 640 376 0.58750 376 0 0.00000
337 337 $ hg clone --pull source-repo --config experimental.maxdeltachainspan=0 noconst-chain --config format.generaldelta=yes
338 338 requesting all changes
339 339 adding changesets
340 340 adding manifests
341 341 adding file changes
342 342 added 55 changesets with 53 changes to 53 files (+2 heads)
343 343 new changesets 61246295ee1e:c930ac4a5b32
344 344 updating to branch default
345 345 14 files updated, 0 files merged, 0 files removed, 0 files unresolved
346 346 $ hg -R noconst-chain debugdeltachain -m
347 347 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
348 348 0 1 1 -1 base 46 45 46 1.02222 46 0 0.00000
349 349 1 1 2 0 p1 57 90 103 1.14444 103 0 0.00000
350 350 2 1 3 1 p1 57 135 160 1.18519 160 0 0.00000
351 351 3 1 4 2 p1 57 180 217 1.20556 217 0 0.00000
352 352 4 1 5 3 p1 57 225 274 1.21778 274 0 0.00000
353 353 5 1 6 4 p1 57 270 331 1.22593 331 0 0.00000
354 354 6 2 1 -1 base 46 45 46 1.02222 46 0 0.00000
355 355 7 2 2 6 p1 57 90 103 1.14444 103 0 0.00000
356 356 8 2 3 7 p1 57 135 160 1.18519 160 0 0.00000
357 357 9 2 4 8 p1 57 180 217 1.20556 217 0 0.00000
358 358 10 2 5 9 p1 58 226 275 1.21681 275 0 0.00000
359 359 11 2 6 10 p1 58 272 333 1.22426 333 0 0.00000
360 360 12 2 7 11 p1 58 318 391 1.22956 391 0 0.00000
361 361 13 2 8 12 p1 58 364 449 1.23352 449 0 0.00000
362 362 14 2 9 13 p1 58 410 507 1.23659 507 0 0.00000
363 363 15 2 10 14 p1 58 456 565 1.23904 565 0 0.00000
364 364 16 2 11 15 p1 58 502 623 1.24104 623 0 0.00000
365 365 17 2 12 16 p1 58 548 681 1.24270 681 0 0.00000
366 366 18 3 1 -1 base 47 46 47 1.02174 47 0 0.00000
367 367 19 3 2 18 p1 58 92 105 1.14130 105 0 0.00000
368 368 20 3 3 19 p1 58 138 163 1.18116 163 0 0.00000
369 369 21 3 4 20 p1 58 184 221 1.20109 221 0 0.00000
370 370 22 3 5 21 p1 58 230 279 1.21304 279 0 0.00000
371 371 23 3 6 22 p1 58 276 337 1.22101 337 0 0.00000
372 372 24 3 7 23 p1 58 322 395 1.22671 395 0 0.00000
373 373 25 3 8 24 p1 58 368 453 1.23098 453 0 0.00000
374 374 26 3 9 25 p1 58 414 511 1.23430 511 0 0.00000
375 375 27 3 10 26 p1 58 460 569 1.23696 569 0 0.00000
376 376 28 3 11 27 p1 58 506 627 1.23913 627 0 0.00000
377 377 29 3 12 28 p1 58 552 685 1.24094 685 0 0.00000
378 378 30 3 13 29 p1 58 598 743 1.24247 743 0 0.00000
379 379 31 3 14 30 p1 58 644 801 1.24379 801 0 0.00000
380 380 32 3 15 31 p1 58 690 859 1.24493 859 0 0.00000
381 381 33 3 16 32 p1 58 736 917 1.24592 917 0 0.00000
382 382 34 3 17 33 p1 58 782 975 1.24680 975 0 0.00000
383 383 35 3 18 34 p1 58 828 1033 1.24758 1033 0 0.00000
384 384 36 3 19 35 p1 58 874 1091 1.24828 1091 0 0.00000
385 385 37 3 20 36 p1 58 920 1149 1.24891 1149 0 0.00000
386 386 38 3 21 37 p1 58 966 1207 1.24948 1207 0 0.00000
387 387 39 3 22 38 p1 58 1012 1265 1.25000 1265 0 0.00000
388 388 40 3 23 39 p1 58 1058 1323 1.25047 1323 0 0.00000
389 389 41 3 24 40 p1 58 1104 1381 1.25091 1381 0 0.00000
390 390 42 3 25 41 p1 58 1150 1439 1.25130 1439 0 0.00000
391 391 43 3 26 42 p1 58 1196 1497 1.25167 1497 0 0.00000
392 392 44 3 27 43 p1 58 1242 1555 1.25201 1555 0 0.00000
393 393 45 3 28 44 p1 58 1288 1613 1.25233 1613 0 0.00000
394 394 46 3 29 45 p1 58 1334 1671 1.25262 1671 0 0.00000
395 395 47 3 30 46 p1 58 1380 1729 1.25290 1729 0 0.00000
396 396 48 3 31 47 p1 58 1426 1787 1.25316 1787 0 0.00000
397 397 49 1 7 5 p1 58 316 389 1.23101 2857 2468 6.34447
398 398 50 1 8 49 p1 58 362 447 1.23481 2915 2468 5.52125
399 399 51 2 13 17 p1 58 594 739 1.24411 2642 1903 2.57510
400 400 52 2 14 51 p1 58 640 797 1.24531 2700 1903 2.38770
401 401 53 4 1 -1 base 0 0 0 0.00000 0 0 0.00000
402 402 54 4 2 53 p1 376 640 376 0.58750 376 0 0.00000
General Comments 0
You need to be logged in to leave comments. Login now