##// END OF EJS Templates
aggressivemergedelta: document rename and move to `revlog` section...
Boris Feld -
r38760:913ca175 @87 default
parent child Browse files
Show More
@@ -1,1382 +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 coreconfigitem('format', 'aggressivemergedeltas',
641 default=True,
642 )
643 640 coreconfigitem('format', 'chunkcachesize',
644 641 default=None,
645 642 )
646 643 coreconfigitem('format', 'dotencode',
647 644 default=True,
648 645 )
649 646 coreconfigitem('format', 'generaldelta',
650 647 default=False,
651 648 )
652 649 coreconfigitem('format', 'manifestcachesize',
653 650 default=None,
654 651 )
655 652 coreconfigitem('format', 'maxchainlen',
656 653 default=None,
657 654 )
658 655 coreconfigitem('format', 'obsstore-version',
659 656 default=None,
660 657 )
661 658 coreconfigitem('format', 'sparse-revlog',
662 659 default=False,
663 660 )
664 661 coreconfigitem('format', 'usefncache',
665 662 default=True,
666 663 )
667 664 coreconfigitem('format', 'usegeneraldelta',
668 665 default=True,
669 666 )
670 667 coreconfigitem('format', 'usestore',
671 668 default=True,
672 669 )
673 670 coreconfigitem('fsmonitor', 'warn_when_unused',
674 671 default=True,
675 672 )
676 673 coreconfigitem('fsmonitor', 'warn_update_file_count',
677 674 default=50000,
678 675 )
679 676 coreconfigitem('hooks', '.*',
680 677 default=dynamicdefault,
681 678 generic=True,
682 679 )
683 680 coreconfigitem('hgweb-paths', '.*',
684 681 default=list,
685 682 generic=True,
686 683 )
687 684 coreconfigitem('hostfingerprints', '.*',
688 685 default=list,
689 686 generic=True,
690 687 )
691 688 coreconfigitem('hostsecurity', 'ciphers',
692 689 default=None,
693 690 )
694 691 coreconfigitem('hostsecurity', 'disabletls10warning',
695 692 default=False,
696 693 )
697 694 coreconfigitem('hostsecurity', 'minimumprotocol',
698 695 default=dynamicdefault,
699 696 )
700 697 coreconfigitem('hostsecurity', '.*:minimumprotocol$',
701 698 default=dynamicdefault,
702 699 generic=True,
703 700 )
704 701 coreconfigitem('hostsecurity', '.*:ciphers$',
705 702 default=dynamicdefault,
706 703 generic=True,
707 704 )
708 705 coreconfigitem('hostsecurity', '.*:fingerprints$',
709 706 default=list,
710 707 generic=True,
711 708 )
712 709 coreconfigitem('hostsecurity', '.*:verifycertsfile$',
713 710 default=None,
714 711 generic=True,
715 712 )
716 713
717 714 coreconfigitem('http_proxy', 'always',
718 715 default=False,
719 716 )
720 717 coreconfigitem('http_proxy', 'host',
721 718 default=None,
722 719 )
723 720 coreconfigitem('http_proxy', 'no',
724 721 default=list,
725 722 )
726 723 coreconfigitem('http_proxy', 'passwd',
727 724 default=None,
728 725 )
729 726 coreconfigitem('http_proxy', 'user',
730 727 default=None,
731 728 )
732 729 coreconfigitem('logtoprocess', 'commandexception',
733 730 default=None,
734 731 )
735 732 coreconfigitem('logtoprocess', 'commandfinish',
736 733 default=None,
737 734 )
738 735 coreconfigitem('logtoprocess', 'command',
739 736 default=None,
740 737 )
741 738 coreconfigitem('logtoprocess', 'develwarn',
742 739 default=None,
743 740 )
744 741 coreconfigitem('logtoprocess', 'uiblocked',
745 742 default=None,
746 743 )
747 744 coreconfigitem('merge', 'checkunknown',
748 745 default='abort',
749 746 )
750 747 coreconfigitem('merge', 'checkignored',
751 748 default='abort',
752 749 )
753 750 coreconfigitem('experimental', 'merge.checkpathconflicts',
754 751 default=False,
755 752 )
756 753 coreconfigitem('merge', 'followcopies',
757 754 default=True,
758 755 )
759 756 coreconfigitem('merge', 'on-failure',
760 757 default='continue',
761 758 )
762 759 coreconfigitem('merge', 'preferancestor',
763 760 default=lambda: ['*'],
764 761 )
765 762 coreconfigitem('merge-tools', '.*',
766 763 default=None,
767 764 generic=True,
768 765 )
769 766 coreconfigitem('merge-tools', br'.*\.args$',
770 767 default="$local $base $other",
771 768 generic=True,
772 769 priority=-1,
773 770 )
774 771 coreconfigitem('merge-tools', br'.*\.binary$',
775 772 default=False,
776 773 generic=True,
777 774 priority=-1,
778 775 )
779 776 coreconfigitem('merge-tools', br'.*\.check$',
780 777 default=list,
781 778 generic=True,
782 779 priority=-1,
783 780 )
784 781 coreconfigitem('merge-tools', br'.*\.checkchanged$',
785 782 default=False,
786 783 generic=True,
787 784 priority=-1,
788 785 )
789 786 coreconfigitem('merge-tools', br'.*\.executable$',
790 787 default=dynamicdefault,
791 788 generic=True,
792 789 priority=-1,
793 790 )
794 791 coreconfigitem('merge-tools', br'.*\.fixeol$',
795 792 default=False,
796 793 generic=True,
797 794 priority=-1,
798 795 )
799 796 coreconfigitem('merge-tools', br'.*\.gui$',
800 797 default=False,
801 798 generic=True,
802 799 priority=-1,
803 800 )
804 801 coreconfigitem('merge-tools', br'.*\.mergemarkers$',
805 802 default='basic',
806 803 generic=True,
807 804 priority=-1,
808 805 )
809 806 coreconfigitem('merge-tools', br'.*\.mergemarkertemplate$',
810 807 default=dynamicdefault, # take from ui.mergemarkertemplate
811 808 generic=True,
812 809 priority=-1,
813 810 )
814 811 coreconfigitem('merge-tools', br'.*\.priority$',
815 812 default=0,
816 813 generic=True,
817 814 priority=-1,
818 815 )
819 816 coreconfigitem('merge-tools', br'.*\.premerge$',
820 817 default=dynamicdefault,
821 818 generic=True,
822 819 priority=-1,
823 820 )
824 821 coreconfigitem('merge-tools', br'.*\.symlink$',
825 822 default=False,
826 823 generic=True,
827 824 priority=-1,
828 825 )
829 826 coreconfigitem('pager', 'attend-.*',
830 827 default=dynamicdefault,
831 828 generic=True,
832 829 )
833 830 coreconfigitem('pager', 'ignore',
834 831 default=list,
835 832 )
836 833 coreconfigitem('pager', 'pager',
837 834 default=dynamicdefault,
838 835 )
839 836 coreconfigitem('patch', 'eol',
840 837 default='strict',
841 838 )
842 839 coreconfigitem('patch', 'fuzz',
843 840 default=2,
844 841 )
845 842 coreconfigitem('paths', 'default',
846 843 default=None,
847 844 )
848 845 coreconfigitem('paths', 'default-push',
849 846 default=None,
850 847 )
851 848 coreconfigitem('paths', '.*',
852 849 default=None,
853 850 generic=True,
854 851 )
855 852 coreconfigitem('phases', 'checksubrepos',
856 853 default='follow',
857 854 )
858 855 coreconfigitem('phases', 'new-commit',
859 856 default='draft',
860 857 )
861 858 coreconfigitem('phases', 'publish',
862 859 default=True,
863 860 )
864 861 coreconfigitem('profiling', 'enabled',
865 862 default=False,
866 863 )
867 864 coreconfigitem('profiling', 'format',
868 865 default='text',
869 866 )
870 867 coreconfigitem('profiling', 'freq',
871 868 default=1000,
872 869 )
873 870 coreconfigitem('profiling', 'limit',
874 871 default=30,
875 872 )
876 873 coreconfigitem('profiling', 'nested',
877 874 default=0,
878 875 )
879 876 coreconfigitem('profiling', 'output',
880 877 default=None,
881 878 )
882 879 coreconfigitem('profiling', 'showmax',
883 880 default=0.999,
884 881 )
885 882 coreconfigitem('profiling', 'showmin',
886 883 default=dynamicdefault,
887 884 )
888 885 coreconfigitem('profiling', 'sort',
889 886 default='inlinetime',
890 887 )
891 888 coreconfigitem('profiling', 'statformat',
892 889 default='hotpath',
893 890 )
894 891 coreconfigitem('profiling', 'time-track',
895 892 default='cpu',
896 893 )
897 894 coreconfigitem('profiling', 'type',
898 895 default='stat',
899 896 )
900 897 coreconfigitem('progress', 'assume-tty',
901 898 default=False,
902 899 )
903 900 coreconfigitem('progress', 'changedelay',
904 901 default=1,
905 902 )
906 903 coreconfigitem('progress', 'clear-complete',
907 904 default=True,
908 905 )
909 906 coreconfigitem('progress', 'debug',
910 907 default=False,
911 908 )
912 909 coreconfigitem('progress', 'delay',
913 910 default=3,
914 911 )
915 912 coreconfigitem('progress', 'disable',
916 913 default=False,
917 914 )
918 915 coreconfigitem('progress', 'estimateinterval',
919 916 default=60.0,
920 917 )
921 918 coreconfigitem('progress', 'format',
922 919 default=lambda: ['topic', 'bar', 'number', 'estimate'],
923 920 )
924 921 coreconfigitem('progress', 'refresh',
925 922 default=0.1,
926 923 )
927 924 coreconfigitem('progress', 'width',
928 925 default=dynamicdefault,
929 926 )
930 927 coreconfigitem('push', 'pushvars.server',
931 928 default=False,
932 929 )
930 coreconfigitem('revlog', 'optimize-delta-parent-choice',
931 default=True,
932 # formely an experimental option: format.aggressivemergedeltas
933 )
933 934 coreconfigitem('server', 'bookmarks-pushkey-compat',
934 935 default=True,
935 936 )
936 937 coreconfigitem('server', 'bundle1',
937 938 default=True,
938 939 )
939 940 coreconfigitem('server', 'bundle1gd',
940 941 default=None,
941 942 )
942 943 coreconfigitem('server', 'bundle1.pull',
943 944 default=None,
944 945 )
945 946 coreconfigitem('server', 'bundle1gd.pull',
946 947 default=None,
947 948 )
948 949 coreconfigitem('server', 'bundle1.push',
949 950 default=None,
950 951 )
951 952 coreconfigitem('server', 'bundle1gd.push',
952 953 default=None,
953 954 )
954 955 coreconfigitem('server', 'compressionengines',
955 956 default=list,
956 957 )
957 958 coreconfigitem('server', 'concurrent-push-mode',
958 959 default='strict',
959 960 )
960 961 coreconfigitem('server', 'disablefullbundle',
961 962 default=False,
962 963 )
963 964 coreconfigitem('server', 'maxhttpheaderlen',
964 965 default=1024,
965 966 )
966 967 coreconfigitem('server', 'pullbundle',
967 968 default=False,
968 969 )
969 970 coreconfigitem('server', 'preferuncompressed',
970 971 default=False,
971 972 )
972 973 coreconfigitem('server', 'streamunbundle',
973 974 default=False,
974 975 )
975 976 coreconfigitem('server', 'uncompressed',
976 977 default=True,
977 978 )
978 979 coreconfigitem('server', 'uncompressedallowsecret',
979 980 default=False,
980 981 )
981 982 coreconfigitem('server', 'validate',
982 983 default=False,
983 984 )
984 985 coreconfigitem('server', 'zliblevel',
985 986 default=-1,
986 987 )
987 988 coreconfigitem('server', 'zstdlevel',
988 989 default=3,
989 990 )
990 991 coreconfigitem('share', 'pool',
991 992 default=None,
992 993 )
993 994 coreconfigitem('share', 'poolnaming',
994 995 default='identity',
995 996 )
996 997 coreconfigitem('smtp', 'host',
997 998 default=None,
998 999 )
999 1000 coreconfigitem('smtp', 'local_hostname',
1000 1001 default=None,
1001 1002 )
1002 1003 coreconfigitem('smtp', 'password',
1003 1004 default=None,
1004 1005 )
1005 1006 coreconfigitem('smtp', 'port',
1006 1007 default=dynamicdefault,
1007 1008 )
1008 1009 coreconfigitem('smtp', 'tls',
1009 1010 default='none',
1010 1011 )
1011 1012 coreconfigitem('smtp', 'username',
1012 1013 default=None,
1013 1014 )
1014 1015 coreconfigitem('sparse', 'missingwarning',
1015 1016 default=True,
1016 1017 )
1017 1018 coreconfigitem('subrepos', 'allowed',
1018 1019 default=dynamicdefault, # to make backporting simpler
1019 1020 )
1020 1021 coreconfigitem('subrepos', 'hg:allowed',
1021 1022 default=dynamicdefault,
1022 1023 )
1023 1024 coreconfigitem('subrepos', 'git:allowed',
1024 1025 default=dynamicdefault,
1025 1026 )
1026 1027 coreconfigitem('subrepos', 'svn:allowed',
1027 1028 default=dynamicdefault,
1028 1029 )
1029 1030 coreconfigitem('templates', '.*',
1030 1031 default=None,
1031 1032 generic=True,
1032 1033 )
1033 1034 coreconfigitem('trusted', 'groups',
1034 1035 default=list,
1035 1036 )
1036 1037 coreconfigitem('trusted', 'users',
1037 1038 default=list,
1038 1039 )
1039 1040 coreconfigitem('ui', '_usedassubrepo',
1040 1041 default=False,
1041 1042 )
1042 1043 coreconfigitem('ui', 'allowemptycommit',
1043 1044 default=False,
1044 1045 )
1045 1046 coreconfigitem('ui', 'archivemeta',
1046 1047 default=True,
1047 1048 )
1048 1049 coreconfigitem('ui', 'askusername',
1049 1050 default=False,
1050 1051 )
1051 1052 coreconfigitem('ui', 'clonebundlefallback',
1052 1053 default=False,
1053 1054 )
1054 1055 coreconfigitem('ui', 'clonebundleprefers',
1055 1056 default=list,
1056 1057 )
1057 1058 coreconfigitem('ui', 'clonebundles',
1058 1059 default=True,
1059 1060 )
1060 1061 coreconfigitem('ui', 'color',
1061 1062 default='auto',
1062 1063 )
1063 1064 coreconfigitem('ui', 'commitsubrepos',
1064 1065 default=False,
1065 1066 )
1066 1067 coreconfigitem('ui', 'debug',
1067 1068 default=False,
1068 1069 )
1069 1070 coreconfigitem('ui', 'debugger',
1070 1071 default=None,
1071 1072 )
1072 1073 coreconfigitem('ui', 'editor',
1073 1074 default=dynamicdefault,
1074 1075 )
1075 1076 coreconfigitem('ui', 'fallbackencoding',
1076 1077 default=None,
1077 1078 )
1078 1079 coreconfigitem('ui', 'forcecwd',
1079 1080 default=None,
1080 1081 )
1081 1082 coreconfigitem('ui', 'forcemerge',
1082 1083 default=None,
1083 1084 )
1084 1085 coreconfigitem('ui', 'formatdebug',
1085 1086 default=False,
1086 1087 )
1087 1088 coreconfigitem('ui', 'formatjson',
1088 1089 default=False,
1089 1090 )
1090 1091 coreconfigitem('ui', 'formatted',
1091 1092 default=None,
1092 1093 )
1093 1094 coreconfigitem('ui', 'graphnodetemplate',
1094 1095 default=None,
1095 1096 )
1096 1097 coreconfigitem('ui', 'history-editing-backup',
1097 1098 default=True,
1098 1099 )
1099 1100 coreconfigitem('ui', 'interactive',
1100 1101 default=None,
1101 1102 )
1102 1103 coreconfigitem('ui', 'interface',
1103 1104 default=None,
1104 1105 )
1105 1106 coreconfigitem('ui', 'interface.chunkselector',
1106 1107 default=None,
1107 1108 )
1108 1109 coreconfigitem('ui', 'large-file-limit',
1109 1110 default=10000000,
1110 1111 )
1111 1112 coreconfigitem('ui', 'logblockedtimes',
1112 1113 default=False,
1113 1114 )
1114 1115 coreconfigitem('ui', 'logtemplate',
1115 1116 default=None,
1116 1117 )
1117 1118 coreconfigitem('ui', 'merge',
1118 1119 default=None,
1119 1120 )
1120 1121 coreconfigitem('ui', 'mergemarkers',
1121 1122 default='basic',
1122 1123 )
1123 1124 coreconfigitem('ui', 'mergemarkertemplate',
1124 1125 default=('{node|short} '
1125 1126 '{ifeq(tags, "tip", "", '
1126 1127 'ifeq(tags, "", "", "{tags} "))}'
1127 1128 '{if(bookmarks, "{bookmarks} ")}'
1128 1129 '{ifeq(branch, "default", "", "{branch} ")}'
1129 1130 '- {author|user}: {desc|firstline}')
1130 1131 )
1131 1132 coreconfigitem('ui', 'nontty',
1132 1133 default=False,
1133 1134 )
1134 1135 coreconfigitem('ui', 'origbackuppath',
1135 1136 default=None,
1136 1137 )
1137 1138 coreconfigitem('ui', 'paginate',
1138 1139 default=True,
1139 1140 )
1140 1141 coreconfigitem('ui', 'patch',
1141 1142 default=None,
1142 1143 )
1143 1144 coreconfigitem('ui', 'portablefilenames',
1144 1145 default='warn',
1145 1146 )
1146 1147 coreconfigitem('ui', 'promptecho',
1147 1148 default=False,
1148 1149 )
1149 1150 coreconfigitem('ui', 'quiet',
1150 1151 default=False,
1151 1152 )
1152 1153 coreconfigitem('ui', 'quietbookmarkmove',
1153 1154 default=False,
1154 1155 )
1155 1156 coreconfigitem('ui', 'remotecmd',
1156 1157 default='hg',
1157 1158 )
1158 1159 coreconfigitem('ui', 'report_untrusted',
1159 1160 default=True,
1160 1161 )
1161 1162 coreconfigitem('ui', 'rollback',
1162 1163 default=True,
1163 1164 )
1164 1165 coreconfigitem('ui', 'signal-safe-lock',
1165 1166 default=True,
1166 1167 )
1167 1168 coreconfigitem('ui', 'slash',
1168 1169 default=False,
1169 1170 )
1170 1171 coreconfigitem('ui', 'ssh',
1171 1172 default='ssh',
1172 1173 )
1173 1174 coreconfigitem('ui', 'ssherrorhint',
1174 1175 default=None,
1175 1176 )
1176 1177 coreconfigitem('ui', 'statuscopies',
1177 1178 default=False,
1178 1179 )
1179 1180 coreconfigitem('ui', 'strict',
1180 1181 default=False,
1181 1182 )
1182 1183 coreconfigitem('ui', 'style',
1183 1184 default='',
1184 1185 )
1185 1186 coreconfigitem('ui', 'supportcontact',
1186 1187 default=None,
1187 1188 )
1188 1189 coreconfigitem('ui', 'textwidth',
1189 1190 default=78,
1190 1191 )
1191 1192 coreconfigitem('ui', 'timeout',
1192 1193 default='600',
1193 1194 )
1194 1195 coreconfigitem('ui', 'timeout.warn',
1195 1196 default=0,
1196 1197 )
1197 1198 coreconfigitem('ui', 'traceback',
1198 1199 default=False,
1199 1200 )
1200 1201 coreconfigitem('ui', 'tweakdefaults',
1201 1202 default=False,
1202 1203 )
1203 1204 coreconfigitem('ui', 'username',
1204 1205 alias=[('ui', 'user')]
1205 1206 )
1206 1207 coreconfigitem('ui', 'verbose',
1207 1208 default=False,
1208 1209 )
1209 1210 coreconfigitem('verify', 'skipflags',
1210 1211 default=None,
1211 1212 )
1212 1213 coreconfigitem('web', 'allowbz2',
1213 1214 default=False,
1214 1215 )
1215 1216 coreconfigitem('web', 'allowgz',
1216 1217 default=False,
1217 1218 )
1218 1219 coreconfigitem('web', 'allow-pull',
1219 1220 alias=[('web', 'allowpull')],
1220 1221 default=True,
1221 1222 )
1222 1223 coreconfigitem('web', 'allow-push',
1223 1224 alias=[('web', 'allow_push')],
1224 1225 default=list,
1225 1226 )
1226 1227 coreconfigitem('web', 'allowzip',
1227 1228 default=False,
1228 1229 )
1229 1230 coreconfigitem('web', 'archivesubrepos',
1230 1231 default=False,
1231 1232 )
1232 1233 coreconfigitem('web', 'cache',
1233 1234 default=True,
1234 1235 )
1235 1236 coreconfigitem('web', 'contact',
1236 1237 default=None,
1237 1238 )
1238 1239 coreconfigitem('web', 'deny_push',
1239 1240 default=list,
1240 1241 )
1241 1242 coreconfigitem('web', 'guessmime',
1242 1243 default=False,
1243 1244 )
1244 1245 coreconfigitem('web', 'hidden',
1245 1246 default=False,
1246 1247 )
1247 1248 coreconfigitem('web', 'labels',
1248 1249 default=list,
1249 1250 )
1250 1251 coreconfigitem('web', 'logoimg',
1251 1252 default='hglogo.png',
1252 1253 )
1253 1254 coreconfigitem('web', 'logourl',
1254 1255 default='https://mercurial-scm.org/',
1255 1256 )
1256 1257 coreconfigitem('web', 'accesslog',
1257 1258 default='-',
1258 1259 )
1259 1260 coreconfigitem('web', 'address',
1260 1261 default='',
1261 1262 )
1262 1263 coreconfigitem('web', 'allow-archive',
1263 1264 alias=[('web', 'allow_archive')],
1264 1265 default=list,
1265 1266 )
1266 1267 coreconfigitem('web', 'allow_read',
1267 1268 default=list,
1268 1269 )
1269 1270 coreconfigitem('web', 'baseurl',
1270 1271 default=None,
1271 1272 )
1272 1273 coreconfigitem('web', 'cacerts',
1273 1274 default=None,
1274 1275 )
1275 1276 coreconfigitem('web', 'certificate',
1276 1277 default=None,
1277 1278 )
1278 1279 coreconfigitem('web', 'collapse',
1279 1280 default=False,
1280 1281 )
1281 1282 coreconfigitem('web', 'csp',
1282 1283 default=None,
1283 1284 )
1284 1285 coreconfigitem('web', 'deny_read',
1285 1286 default=list,
1286 1287 )
1287 1288 coreconfigitem('web', 'descend',
1288 1289 default=True,
1289 1290 )
1290 1291 coreconfigitem('web', 'description',
1291 1292 default="",
1292 1293 )
1293 1294 coreconfigitem('web', 'encoding',
1294 1295 default=lambda: encoding.encoding,
1295 1296 )
1296 1297 coreconfigitem('web', 'errorlog',
1297 1298 default='-',
1298 1299 )
1299 1300 coreconfigitem('web', 'ipv6',
1300 1301 default=False,
1301 1302 )
1302 1303 coreconfigitem('web', 'maxchanges',
1303 1304 default=10,
1304 1305 )
1305 1306 coreconfigitem('web', 'maxfiles',
1306 1307 default=10,
1307 1308 )
1308 1309 coreconfigitem('web', 'maxshortchanges',
1309 1310 default=60,
1310 1311 )
1311 1312 coreconfigitem('web', 'motd',
1312 1313 default='',
1313 1314 )
1314 1315 coreconfigitem('web', 'name',
1315 1316 default=dynamicdefault,
1316 1317 )
1317 1318 coreconfigitem('web', 'port',
1318 1319 default=8000,
1319 1320 )
1320 1321 coreconfigitem('web', 'prefix',
1321 1322 default='',
1322 1323 )
1323 1324 coreconfigitem('web', 'push_ssl',
1324 1325 default=True,
1325 1326 )
1326 1327 coreconfigitem('web', 'refreshinterval',
1327 1328 default=20,
1328 1329 )
1329 1330 coreconfigitem('web', 'server-header',
1330 1331 default=None,
1331 1332 )
1332 1333 coreconfigitem('web', 'staticurl',
1333 1334 default=None,
1334 1335 )
1335 1336 coreconfigitem('web', 'stripes',
1336 1337 default=1,
1337 1338 )
1338 1339 coreconfigitem('web', 'style',
1339 1340 default='paper',
1340 1341 )
1341 1342 coreconfigitem('web', 'templates',
1342 1343 default=None,
1343 1344 )
1344 1345 coreconfigitem('web', 'view',
1345 1346 default='served',
1346 1347 )
1347 1348 coreconfigitem('worker', 'backgroundclose',
1348 1349 default=dynamicdefault,
1349 1350 )
1350 1351 # Windows defaults to a limit of 512 open files. A buffer of 128
1351 1352 # should give us enough headway.
1352 1353 coreconfigitem('worker', 'backgroundclosemaxqueue',
1353 1354 default=384,
1354 1355 )
1355 1356 coreconfigitem('worker', 'backgroundcloseminfilecount',
1356 1357 default=2048,
1357 1358 )
1358 1359 coreconfigitem('worker', 'backgroundclosethreadcount',
1359 1360 default=4,
1360 1361 )
1361 1362 coreconfigitem('worker', 'enabled',
1362 1363 default=True,
1363 1364 )
1364 1365 coreconfigitem('worker', 'numcpus',
1365 1366 default=None,
1366 1367 )
1367 1368
1368 1369 # Rebase related configuration moved to core because other extension are doing
1369 1370 # strange things. For example, shelve import the extensions to reuse some bit
1370 1371 # without formally loading it.
1371 1372 coreconfigitem('commands', 'rebase.requiredest',
1372 1373 default=False,
1373 1374 )
1374 1375 coreconfigitem('experimental', 'rebaseskipobsolete',
1375 1376 default=True,
1376 1377 )
1377 1378 coreconfigitem('rebase', 'singletransaction',
1378 1379 default=False,
1379 1380 )
1380 1381 coreconfigitem('rebase', 'experimental.inmemory',
1381 1382 default=False,
1382 1383 )
@@ -1,2677 +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``
1777 ----------
1778
1779 Control the strategy Mercurial uses internally to store history. Options in this
1780 category impact performance and repository size.
1781
1782 ``optimize-delta-parent-choice``
1783 When storing a merge revision, both parents will be equally considered as
1784 a possible delta base. This results in better delta selection and improved
1785 revlog compression. This option is enabled by default.
1786
1787 Turning this option off can result in large increase of repository size for
1788 repository with many merges.
1789
1776 1790 ``server``
1777 1791 ----------
1778 1792
1779 1793 Controls generic server settings.
1780 1794
1781 1795 ``bookmarks-pushkey-compat``
1782 1796 Trigger pushkey hook when being pushed bookmark updates. This config exist
1783 1797 for compatibility purpose (default to True)
1784 1798
1785 1799 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
1786 1800 movement we recommend you migrate them to ``txnclose-bookmark`` and
1787 1801 ``pretxnclose-bookmark``.
1788 1802
1789 1803 ``compressionengines``
1790 1804 List of compression engines and their relative priority to advertise
1791 1805 to clients.
1792 1806
1793 1807 The order of compression engines determines their priority, the first
1794 1808 having the highest priority. If a compression engine is not listed
1795 1809 here, it won't be advertised to clients.
1796 1810
1797 1811 If not set (the default), built-in defaults are used. Run
1798 1812 :hg:`debuginstall` to list available compression engines and their
1799 1813 default wire protocol priority.
1800 1814
1801 1815 Older Mercurial clients only support zlib compression and this setting
1802 1816 has no effect for legacy clients.
1803 1817
1804 1818 ``uncompressed``
1805 1819 Whether to allow clients to clone a repository using the
1806 1820 uncompressed streaming protocol. This transfers about 40% more
1807 1821 data than a regular clone, but uses less memory and CPU on both
1808 1822 server and client. Over a LAN (100 Mbps or better) or a very fast
1809 1823 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1810 1824 regular clone. Over most WAN connections (anything slower than
1811 1825 about 6 Mbps), uncompressed streaming is slower, because of the
1812 1826 extra data transfer overhead. This mode will also temporarily hold
1813 1827 the write lock while determining what data to transfer.
1814 1828 (default: True)
1815 1829
1816 1830 ``uncompressedallowsecret``
1817 1831 Whether to allow stream clones when the repository contains secret
1818 1832 changesets. (default: False)
1819 1833
1820 1834 ``preferuncompressed``
1821 1835 When set, clients will try to use the uncompressed streaming
1822 1836 protocol. (default: False)
1823 1837
1824 1838 ``disablefullbundle``
1825 1839 When set, servers will refuse attempts to do pull-based clones.
1826 1840 If this option is set, ``preferuncompressed`` and/or clone bundles
1827 1841 are highly recommended. Partial clones will still be allowed.
1828 1842 (default: False)
1829 1843
1830 1844 ``streamunbundle``
1831 1845 When set, servers will apply data sent from the client directly,
1832 1846 otherwise it will be written to a temporary file first. This option
1833 1847 effectively prevents concurrent pushes.
1834 1848
1835 1849 ``pullbundle``
1836 1850 When set, the server will check pullbundle.manifest for bundles
1837 1851 covering the requested heads and common nodes. The first matching
1838 1852 entry will be streamed to the client.
1839 1853
1840 1854 For HTTP transport, the stream will still use zlib compression
1841 1855 for older clients.
1842 1856
1843 1857 ``concurrent-push-mode``
1844 1858 Level of allowed race condition between two pushing clients.
1845 1859
1846 1860 - 'strict': push is abort if another client touched the repository
1847 1861 while the push was preparing. (default)
1848 1862 - 'check-related': push is only aborted if it affects head that got also
1849 1863 affected while the push was preparing.
1850 1864
1851 1865 This requires compatible client (version 4.3 and later). Old client will
1852 1866 use 'strict'.
1853 1867
1854 1868 ``validate``
1855 1869 Whether to validate the completeness of pushed changesets by
1856 1870 checking that all new file revisions specified in manifests are
1857 1871 present. (default: False)
1858 1872
1859 1873 ``maxhttpheaderlen``
1860 1874 Instruct HTTP clients not to send request headers longer than this
1861 1875 many bytes. (default: 1024)
1862 1876
1863 1877 ``bundle1``
1864 1878 Whether to allow clients to push and pull using the legacy bundle1
1865 1879 exchange format. (default: True)
1866 1880
1867 1881 ``bundle1gd``
1868 1882 Like ``bundle1`` but only used if the repository is using the
1869 1883 *generaldelta* storage format. (default: True)
1870 1884
1871 1885 ``bundle1.push``
1872 1886 Whether to allow clients to push using the legacy bundle1 exchange
1873 1887 format. (default: True)
1874 1888
1875 1889 ``bundle1gd.push``
1876 1890 Like ``bundle1.push`` but only used if the repository is using the
1877 1891 *generaldelta* storage format. (default: True)
1878 1892
1879 1893 ``bundle1.pull``
1880 1894 Whether to allow clients to pull using the legacy bundle1 exchange
1881 1895 format. (default: True)
1882 1896
1883 1897 ``bundle1gd.pull``
1884 1898 Like ``bundle1.pull`` but only used if the repository is using the
1885 1899 *generaldelta* storage format. (default: True)
1886 1900
1887 1901 Large repositories using the *generaldelta* storage format should
1888 1902 consider setting this option because converting *generaldelta*
1889 1903 repositories to the exchange format required by the bundle1 data
1890 1904 format can consume a lot of CPU.
1891 1905
1892 1906 ``zliblevel``
1893 1907 Integer between ``-1`` and ``9`` that controls the zlib compression level
1894 1908 for wire protocol commands that send zlib compressed output (notably the
1895 1909 commands that send repository history data).
1896 1910
1897 1911 The default (``-1``) uses the default zlib compression level, which is
1898 1912 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1899 1913 maximum compression.
1900 1914
1901 1915 Setting this option allows server operators to make trade-offs between
1902 1916 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1903 1917 but sends more bytes to clients.
1904 1918
1905 1919 This option only impacts the HTTP server.
1906 1920
1907 1921 ``zstdlevel``
1908 1922 Integer between ``1`` and ``22`` that controls the zstd compression level
1909 1923 for wire protocol commands. ``1`` is the minimal amount of compression and
1910 1924 ``22`` is the highest amount of compression.
1911 1925
1912 1926 The default (``3``) should be significantly faster than zlib while likely
1913 1927 delivering better compression ratios.
1914 1928
1915 1929 This option only impacts the HTTP server.
1916 1930
1917 1931 See also ``server.zliblevel``.
1918 1932
1919 1933 ``smtp``
1920 1934 --------
1921 1935
1922 1936 Configuration for extensions that need to send email messages.
1923 1937
1924 1938 ``host``
1925 1939 Host name of mail server, e.g. "mail.example.com".
1926 1940
1927 1941 ``port``
1928 1942 Optional. Port to connect to on mail server. (default: 465 if
1929 1943 ``tls`` is smtps; 25 otherwise)
1930 1944
1931 1945 ``tls``
1932 1946 Optional. Method to enable TLS when connecting to mail server: starttls,
1933 1947 smtps or none. (default: none)
1934 1948
1935 1949 ``username``
1936 1950 Optional. User name for authenticating with the SMTP server.
1937 1951 (default: None)
1938 1952
1939 1953 ``password``
1940 1954 Optional. Password for authenticating with the SMTP server. If not
1941 1955 specified, interactive sessions will prompt the user for a
1942 1956 password; non-interactive sessions will fail. (default: None)
1943 1957
1944 1958 ``local_hostname``
1945 1959 Optional. The hostname that the sender can use to identify
1946 1960 itself to the MTA.
1947 1961
1948 1962
1949 1963 ``subpaths``
1950 1964 ------------
1951 1965
1952 1966 Subrepository source URLs can go stale if a remote server changes name
1953 1967 or becomes temporarily unavailable. This section lets you define
1954 1968 rewrite rules of the form::
1955 1969
1956 1970 <pattern> = <replacement>
1957 1971
1958 1972 where ``pattern`` is a regular expression matching a subrepository
1959 1973 source URL and ``replacement`` is the replacement string used to
1960 1974 rewrite it. Groups can be matched in ``pattern`` and referenced in
1961 1975 ``replacements``. For instance::
1962 1976
1963 1977 http://server/(.*)-hg/ = http://hg.server/\1/
1964 1978
1965 1979 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1966 1980
1967 1981 Relative subrepository paths are first made absolute, and the
1968 1982 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1969 1983 doesn't match the full path, an attempt is made to apply it on the
1970 1984 relative path alone. The rules are applied in definition order.
1971 1985
1972 1986 ``subrepos``
1973 1987 ------------
1974 1988
1975 1989 This section contains options that control the behavior of the
1976 1990 subrepositories feature. See also :hg:`help subrepos`.
1977 1991
1978 1992 Security note: auditing in Mercurial is known to be insufficient to
1979 1993 prevent clone-time code execution with carefully constructed Git
1980 1994 subrepos. It is unknown if a similar detect is present in Subversion
1981 1995 subrepos. Both Git and Subversion subrepos are disabled by default
1982 1996 out of security concerns. These subrepo types can be enabled using
1983 1997 the respective options below.
1984 1998
1985 1999 ``allowed``
1986 2000 Whether subrepositories are allowed in the working directory.
1987 2001
1988 2002 When false, commands involving subrepositories (like :hg:`update`)
1989 2003 will fail for all subrepository types.
1990 2004 (default: true)
1991 2005
1992 2006 ``hg:allowed``
1993 2007 Whether Mercurial subrepositories are allowed in the working
1994 2008 directory. This option only has an effect if ``subrepos.allowed``
1995 2009 is true.
1996 2010 (default: true)
1997 2011
1998 2012 ``git:allowed``
1999 2013 Whether Git subrepositories are allowed in the working directory.
2000 2014 This option only has an effect if ``subrepos.allowed`` is true.
2001 2015
2002 2016 See the security note above before enabling Git subrepos.
2003 2017 (default: false)
2004 2018
2005 2019 ``svn:allowed``
2006 2020 Whether Subversion subrepositories are allowed in the working
2007 2021 directory. This option only has an effect if ``subrepos.allowed``
2008 2022 is true.
2009 2023
2010 2024 See the security note above before enabling Subversion subrepos.
2011 2025 (default: false)
2012 2026
2013 2027 ``templatealias``
2014 2028 -----------------
2015 2029
2016 2030 Alias definitions for templates. See :hg:`help templates` for details.
2017 2031
2018 2032 ``templates``
2019 2033 -------------
2020 2034
2021 2035 Use the ``[templates]`` section to define template strings.
2022 2036 See :hg:`help templates` for details.
2023 2037
2024 2038 ``trusted``
2025 2039 -----------
2026 2040
2027 2041 Mercurial will not use the settings in the
2028 2042 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2029 2043 user or to a trusted group, as various hgrc features allow arbitrary
2030 2044 commands to be run. This issue is often encountered when configuring
2031 2045 hooks or extensions for shared repositories or servers. However,
2032 2046 the web interface will use some safe settings from the ``[web]``
2033 2047 section.
2034 2048
2035 2049 This section specifies what users and groups are trusted. The
2036 2050 current user is always trusted. To trust everybody, list a user or a
2037 2051 group with name ``*``. These settings must be placed in an
2038 2052 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2039 2053 user or service running Mercurial.
2040 2054
2041 2055 ``users``
2042 2056 Comma-separated list of trusted users.
2043 2057
2044 2058 ``groups``
2045 2059 Comma-separated list of trusted groups.
2046 2060
2047 2061
2048 2062 ``ui``
2049 2063 ------
2050 2064
2051 2065 User interface controls.
2052 2066
2053 2067 ``archivemeta``
2054 2068 Whether to include the .hg_archival.txt file containing meta data
2055 2069 (hashes for the repository base and for tip) in archives created
2056 2070 by the :hg:`archive` command or downloaded via hgweb.
2057 2071 (default: True)
2058 2072
2059 2073 ``askusername``
2060 2074 Whether to prompt for a username when committing. If True, and
2061 2075 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2062 2076 be prompted to enter a username. If no username is entered, the
2063 2077 default ``USER@HOST`` is used instead.
2064 2078 (default: False)
2065 2079
2066 2080 ``clonebundles``
2067 2081 Whether the "clone bundles" feature is enabled.
2068 2082
2069 2083 When enabled, :hg:`clone` may download and apply a server-advertised
2070 2084 bundle file from a URL instead of using the normal exchange mechanism.
2071 2085
2072 2086 This can likely result in faster and more reliable clones.
2073 2087
2074 2088 (default: True)
2075 2089
2076 2090 ``clonebundlefallback``
2077 2091 Whether failure to apply an advertised "clone bundle" from a server
2078 2092 should result in fallback to a regular clone.
2079 2093
2080 2094 This is disabled by default because servers advertising "clone
2081 2095 bundles" often do so to reduce server load. If advertised bundles
2082 2096 start mass failing and clients automatically fall back to a regular
2083 2097 clone, this would add significant and unexpected load to the server
2084 2098 since the server is expecting clone operations to be offloaded to
2085 2099 pre-generated bundles. Failing fast (the default behavior) ensures
2086 2100 clients don't overwhelm the server when "clone bundle" application
2087 2101 fails.
2088 2102
2089 2103 (default: False)
2090 2104
2091 2105 ``clonebundleprefers``
2092 2106 Defines preferences for which "clone bundles" to use.
2093 2107
2094 2108 Servers advertising "clone bundles" may advertise multiple available
2095 2109 bundles. Each bundle may have different attributes, such as the bundle
2096 2110 type and compression format. This option is used to prefer a particular
2097 2111 bundle over another.
2098 2112
2099 2113 The following keys are defined by Mercurial:
2100 2114
2101 2115 BUNDLESPEC
2102 2116 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2103 2117 e.g. ``gzip-v2`` or ``bzip2-v1``.
2104 2118
2105 2119 COMPRESSION
2106 2120 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2107 2121
2108 2122 Server operators may define custom keys.
2109 2123
2110 2124 Example values: ``COMPRESSION=bzip2``,
2111 2125 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2112 2126
2113 2127 By default, the first bundle advertised by the server is used.
2114 2128
2115 2129 ``color``
2116 2130 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2117 2131 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2118 2132 seems possible. See :hg:`help color` for details.
2119 2133
2120 2134 ``commitsubrepos``
2121 2135 Whether to commit modified subrepositories when committing the
2122 2136 parent repository. If False and one subrepository has uncommitted
2123 2137 changes, abort the commit.
2124 2138 (default: False)
2125 2139
2126 2140 ``debug``
2127 2141 Print debugging information. (default: False)
2128 2142
2129 2143 ``editor``
2130 2144 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2131 2145
2132 2146 ``fallbackencoding``
2133 2147 Encoding to try if it's not possible to decode the changelog using
2134 2148 UTF-8. (default: ISO-8859-1)
2135 2149
2136 2150 ``graphnodetemplate``
2137 2151 The template used to print changeset nodes in an ASCII revision graph.
2138 2152 (default: ``{graphnode}``)
2139 2153
2140 2154 ``ignore``
2141 2155 A file to read per-user ignore patterns from. This file should be
2142 2156 in the same format as a repository-wide .hgignore file. Filenames
2143 2157 are relative to the repository root. This option supports hook syntax,
2144 2158 so if you want to specify multiple ignore files, you can do so by
2145 2159 setting something like ``ignore.other = ~/.hgignore2``. For details
2146 2160 of the ignore file format, see the ``hgignore(5)`` man page.
2147 2161
2148 2162 ``interactive``
2149 2163 Allow to prompt the user. (default: True)
2150 2164
2151 2165 ``interface``
2152 2166 Select the default interface for interactive features (default: text).
2153 2167 Possible values are 'text' and 'curses'.
2154 2168
2155 2169 ``interface.chunkselector``
2156 2170 Select the interface for change recording (e.g. :hg:`commit -i`).
2157 2171 Possible values are 'text' and 'curses'.
2158 2172 This config overrides the interface specified by ui.interface.
2159 2173
2160 2174 ``large-file-limit``
2161 2175 Largest file size that gives no memory use warning.
2162 2176 Possible values are integers or 0 to disable the check.
2163 2177 (default: 10000000)
2164 2178
2165 2179 ``logtemplate``
2166 2180 Template string for commands that print changesets.
2167 2181
2168 2182 ``merge``
2169 2183 The conflict resolution program to use during a manual merge.
2170 2184 For more information on merge tools see :hg:`help merge-tools`.
2171 2185 For configuring merge tools see the ``[merge-tools]`` section.
2172 2186
2173 2187 ``mergemarkers``
2174 2188 Sets the merge conflict marker label styling. The ``detailed``
2175 2189 style uses the ``mergemarkertemplate`` setting to style the labels.
2176 2190 The ``basic`` style just uses 'local' and 'other' as the marker label.
2177 2191 One of ``basic`` or ``detailed``.
2178 2192 (default: ``basic``)
2179 2193
2180 2194 ``mergemarkertemplate``
2181 2195 The template used to print the commit description next to each conflict
2182 2196 marker during merge conflicts. See :hg:`help templates` for the template
2183 2197 format.
2184 2198
2185 2199 Defaults to showing the hash, tags, branches, bookmarks, author, and
2186 2200 the first line of the commit description.
2187 2201
2188 2202 If you use non-ASCII characters in names for tags, branches, bookmarks,
2189 2203 authors, and/or commit descriptions, you must pay attention to encodings of
2190 2204 managed files. At template expansion, non-ASCII characters use the encoding
2191 2205 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2192 2206 environment variables that govern your locale. If the encoding of the merge
2193 2207 markers is different from the encoding of the merged files,
2194 2208 serious problems may occur.
2195 2209
2196 2210 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2197 2211
2198 2212 ``origbackuppath``
2199 2213 The path to a directory used to store generated .orig files. If the path is
2200 2214 not a directory, one will be created. If set, files stored in this
2201 2215 directory have the same name as the original file and do not have a .orig
2202 2216 suffix.
2203 2217
2204 2218 ``paginate``
2205 2219 Control the pagination of command output (default: True). See :hg:`help pager`
2206 2220 for details.
2207 2221
2208 2222 ``patch``
2209 2223 An optional external tool that ``hg import`` and some extensions
2210 2224 will use for applying patches. By default Mercurial uses an
2211 2225 internal patch utility. The external tool must work as the common
2212 2226 Unix ``patch`` program. In particular, it must accept a ``-p``
2213 2227 argument to strip patch headers, a ``-d`` argument to specify the
2214 2228 current directory, a file name to patch, and a patch file to take
2215 2229 from stdin.
2216 2230
2217 2231 It is possible to specify a patch tool together with extra
2218 2232 arguments. For example, setting this option to ``patch --merge``
2219 2233 will use the ``patch`` program with its 2-way merge option.
2220 2234
2221 2235 ``portablefilenames``
2222 2236 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2223 2237 (default: ``warn``)
2224 2238
2225 2239 ``warn``
2226 2240 Print a warning message on POSIX platforms, if a file with a non-portable
2227 2241 filename is added (e.g. a file with a name that can't be created on
2228 2242 Windows because it contains reserved parts like ``AUX``, reserved
2229 2243 characters like ``:``, or would cause a case collision with an existing
2230 2244 file).
2231 2245
2232 2246 ``ignore``
2233 2247 Don't print a warning.
2234 2248
2235 2249 ``abort``
2236 2250 The command is aborted.
2237 2251
2238 2252 ``true``
2239 2253 Alias for ``warn``.
2240 2254
2241 2255 ``false``
2242 2256 Alias for ``ignore``.
2243 2257
2244 2258 .. container:: windows
2245 2259
2246 2260 On Windows, this configuration option is ignored and the command aborted.
2247 2261
2248 2262 ``quiet``
2249 2263 Reduce the amount of output printed.
2250 2264 (default: False)
2251 2265
2252 2266 ``remotecmd``
2253 2267 Remote command to use for clone/push/pull operations.
2254 2268 (default: ``hg``)
2255 2269
2256 2270 ``report_untrusted``
2257 2271 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2258 2272 trusted user or group.
2259 2273 (default: True)
2260 2274
2261 2275 ``slash``
2262 2276 (Deprecated. Use ``slashpath`` template filter instead.)
2263 2277
2264 2278 Display paths using a slash (``/``) as the path separator. This
2265 2279 only makes a difference on systems where the default path
2266 2280 separator is not the slash character (e.g. Windows uses the
2267 2281 backslash character (``\``)).
2268 2282 (default: False)
2269 2283
2270 2284 ``statuscopies``
2271 2285 Display copies in the status command.
2272 2286
2273 2287 ``ssh``
2274 2288 Command to use for SSH connections. (default: ``ssh``)
2275 2289
2276 2290 ``ssherrorhint``
2277 2291 A hint shown to the user in the case of SSH error (e.g.
2278 2292 ``Please see http://company/internalwiki/ssh.html``)
2279 2293
2280 2294 ``strict``
2281 2295 Require exact command names, instead of allowing unambiguous
2282 2296 abbreviations. (default: False)
2283 2297
2284 2298 ``style``
2285 2299 Name of style to use for command output.
2286 2300
2287 2301 ``supportcontact``
2288 2302 A URL where users should report a Mercurial traceback. Use this if you are a
2289 2303 large organisation with its own Mercurial deployment process and crash
2290 2304 reports should be addressed to your internal support.
2291 2305
2292 2306 ``textwidth``
2293 2307 Maximum width of help text. A longer line generated by ``hg help`` or
2294 2308 ``hg subcommand --help`` will be broken after white space to get this
2295 2309 width or the terminal width, whichever comes first.
2296 2310 A non-positive value will disable this and the terminal width will be
2297 2311 used. (default: 78)
2298 2312
2299 2313 ``timeout``
2300 2314 The timeout used when a lock is held (in seconds), a negative value
2301 2315 means no timeout. (default: 600)
2302 2316
2303 2317 ``timeout.warn``
2304 2318 Time (in seconds) before a warning is printed about held lock. A negative
2305 2319 value means no warning. (default: 0)
2306 2320
2307 2321 ``traceback``
2308 2322 Mercurial always prints a traceback when an unknown exception
2309 2323 occurs. Setting this to True will make Mercurial print a traceback
2310 2324 on all exceptions, even those recognized by Mercurial (such as
2311 2325 IOError or MemoryError). (default: False)
2312 2326
2313 2327 ``tweakdefaults``
2314 2328
2315 2329 By default Mercurial's behavior changes very little from release
2316 2330 to release, but over time the recommended config settings
2317 2331 shift. Enable this config to opt in to get automatic tweaks to
2318 2332 Mercurial's behavior over time. This config setting will have no
2319 2333 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2320 2334 not include ``tweakdefaults``. (default: False)
2321 2335
2322 2336 ``username``
2323 2337 The committer of a changeset created when running "commit".
2324 2338 Typically a person's name and email address, e.g. ``Fred Widget
2325 2339 <fred@example.com>``. Environment variables in the
2326 2340 username are expanded.
2327 2341
2328 2342 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2329 2343 hgrc is empty, e.g. if the system admin set ``username =`` in the
2330 2344 system hgrc, it has to be specified manually or in a different
2331 2345 hgrc file)
2332 2346
2333 2347 ``verbose``
2334 2348 Increase the amount of output printed. (default: False)
2335 2349
2336 2350
2337 2351 ``web``
2338 2352 -------
2339 2353
2340 2354 Web interface configuration. The settings in this section apply to
2341 2355 both the builtin webserver (started by :hg:`serve`) and the script you
2342 2356 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2343 2357 and WSGI).
2344 2358
2345 2359 The Mercurial webserver does no authentication (it does not prompt for
2346 2360 usernames and passwords to validate *who* users are), but it does do
2347 2361 authorization (it grants or denies access for *authenticated users*
2348 2362 based on settings in this section). You must either configure your
2349 2363 webserver to do authentication for you, or disable the authorization
2350 2364 checks.
2351 2365
2352 2366 For a quick setup in a trusted environment, e.g., a private LAN, where
2353 2367 you want it to accept pushes from anybody, you can use the following
2354 2368 command line::
2355 2369
2356 2370 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2357 2371
2358 2372 Note that this will allow anybody to push anything to the server and
2359 2373 that this should not be used for public servers.
2360 2374
2361 2375 The full set of options is:
2362 2376
2363 2377 ``accesslog``
2364 2378 Where to output the access log. (default: stdout)
2365 2379
2366 2380 ``address``
2367 2381 Interface address to bind to. (default: all)
2368 2382
2369 2383 ``allow-archive``
2370 2384 List of archive format (bz2, gz, zip) allowed for downloading.
2371 2385 (default: empty)
2372 2386
2373 2387 ``allowbz2``
2374 2388 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2375 2389 revisions.
2376 2390 (default: False)
2377 2391
2378 2392 ``allowgz``
2379 2393 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2380 2394 revisions.
2381 2395 (default: False)
2382 2396
2383 2397 ``allow-pull``
2384 2398 Whether to allow pulling from the repository. (default: True)
2385 2399
2386 2400 ``allow-push``
2387 2401 Whether to allow pushing to the repository. If empty or not set,
2388 2402 pushing is not allowed. If the special value ``*``, any remote
2389 2403 user can push, including unauthenticated users. Otherwise, the
2390 2404 remote user must have been authenticated, and the authenticated
2391 2405 user name must be present in this list. The contents of the
2392 2406 allow-push list are examined after the deny_push list.
2393 2407
2394 2408 ``allow_read``
2395 2409 If the user has not already been denied repository access due to
2396 2410 the contents of deny_read, this list determines whether to grant
2397 2411 repository access to the user. If this list is not empty, and the
2398 2412 user is unauthenticated or not present in the list, then access is
2399 2413 denied for the user. If the list is empty or not set, then access
2400 2414 is permitted to all users by default. Setting allow_read to the
2401 2415 special value ``*`` is equivalent to it not being set (i.e. access
2402 2416 is permitted to all users). The contents of the allow_read list are
2403 2417 examined after the deny_read list.
2404 2418
2405 2419 ``allowzip``
2406 2420 (DEPRECATED) Whether to allow .zip downloading of repository
2407 2421 revisions. This feature creates temporary files.
2408 2422 (default: False)
2409 2423
2410 2424 ``archivesubrepos``
2411 2425 Whether to recurse into subrepositories when archiving.
2412 2426 (default: False)
2413 2427
2414 2428 ``baseurl``
2415 2429 Base URL to use when publishing URLs in other locations, so
2416 2430 third-party tools like email notification hooks can construct
2417 2431 URLs. Example: ``http://hgserver/repos/``.
2418 2432
2419 2433 ``cacerts``
2420 2434 Path to file containing a list of PEM encoded certificate
2421 2435 authority certificates. Environment variables and ``~user``
2422 2436 constructs are expanded in the filename. If specified on the
2423 2437 client, then it will verify the identity of remote HTTPS servers
2424 2438 with these certificates.
2425 2439
2426 2440 To disable SSL verification temporarily, specify ``--insecure`` from
2427 2441 command line.
2428 2442
2429 2443 You can use OpenSSL's CA certificate file if your platform has
2430 2444 one. On most Linux systems this will be
2431 2445 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2432 2446 generate this file manually. The form must be as follows::
2433 2447
2434 2448 -----BEGIN CERTIFICATE-----
2435 2449 ... (certificate in base64 PEM encoding) ...
2436 2450 -----END CERTIFICATE-----
2437 2451 -----BEGIN CERTIFICATE-----
2438 2452 ... (certificate in base64 PEM encoding) ...
2439 2453 -----END CERTIFICATE-----
2440 2454
2441 2455 ``cache``
2442 2456 Whether to support caching in hgweb. (default: True)
2443 2457
2444 2458 ``certificate``
2445 2459 Certificate to use when running :hg:`serve`.
2446 2460
2447 2461 ``collapse``
2448 2462 With ``descend`` enabled, repositories in subdirectories are shown at
2449 2463 a single level alongside repositories in the current path. With
2450 2464 ``collapse`` also enabled, repositories residing at a deeper level than
2451 2465 the current path are grouped behind navigable directory entries that
2452 2466 lead to the locations of these repositories. In effect, this setting
2453 2467 collapses each collection of repositories found within a subdirectory
2454 2468 into a single entry for that subdirectory. (default: False)
2455 2469
2456 2470 ``comparisoncontext``
2457 2471 Number of lines of context to show in side-by-side file comparison. If
2458 2472 negative or the value ``full``, whole files are shown. (default: 5)
2459 2473
2460 2474 This setting can be overridden by a ``context`` request parameter to the
2461 2475 ``comparison`` command, taking the same values.
2462 2476
2463 2477 ``contact``
2464 2478 Name or email address of the person in charge of the repository.
2465 2479 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2466 2480
2467 2481 ``csp``
2468 2482 Send a ``Content-Security-Policy`` HTTP header with this value.
2469 2483
2470 2484 The value may contain a special string ``%nonce%``, which will be replaced
2471 2485 by a randomly-generated one-time use value. If the value contains
2472 2486 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2473 2487 one-time property of the nonce. This nonce will also be inserted into
2474 2488 ``<script>`` elements containing inline JavaScript.
2475 2489
2476 2490 Note: lots of HTML content sent by the server is derived from repository
2477 2491 data. Please consider the potential for malicious repository data to
2478 2492 "inject" itself into generated HTML content as part of your security
2479 2493 threat model.
2480 2494
2481 2495 ``deny_push``
2482 2496 Whether to deny pushing to the repository. If empty or not set,
2483 2497 push is not denied. If the special value ``*``, all remote users are
2484 2498 denied push. Otherwise, unauthenticated users are all denied, and
2485 2499 any authenticated user name present in this list is also denied. The
2486 2500 contents of the deny_push list are examined before the allow-push list.
2487 2501
2488 2502 ``deny_read``
2489 2503 Whether to deny reading/viewing of the repository. If this list is
2490 2504 not empty, unauthenticated users are all denied, and any
2491 2505 authenticated user name present in this list is also denied access to
2492 2506 the repository. If set to the special value ``*``, all remote users
2493 2507 are denied access (rarely needed ;). If deny_read is empty or not set,
2494 2508 the determination of repository access depends on the presence and
2495 2509 content of the allow_read list (see description). If both
2496 2510 deny_read and allow_read are empty or not set, then access is
2497 2511 permitted to all users by default. If the repository is being
2498 2512 served via hgwebdir, denied users will not be able to see it in
2499 2513 the list of repositories. The contents of the deny_read list have
2500 2514 priority over (are examined before) the contents of the allow_read
2501 2515 list.
2502 2516
2503 2517 ``descend``
2504 2518 hgwebdir indexes will not descend into subdirectories. Only repositories
2505 2519 directly in the current path will be shown (other repositories are still
2506 2520 available from the index corresponding to their containing path).
2507 2521
2508 2522 ``description``
2509 2523 Textual description of the repository's purpose or contents.
2510 2524 (default: "unknown")
2511 2525
2512 2526 ``encoding``
2513 2527 Character encoding name. (default: the current locale charset)
2514 2528 Example: "UTF-8".
2515 2529
2516 2530 ``errorlog``
2517 2531 Where to output the error log. (default: stderr)
2518 2532
2519 2533 ``guessmime``
2520 2534 Control MIME types for raw download of file content.
2521 2535 Set to True to let hgweb guess the content type from the file
2522 2536 extension. This will serve HTML files as ``text/html`` and might
2523 2537 allow cross-site scripting attacks when serving untrusted
2524 2538 repositories. (default: False)
2525 2539
2526 2540 ``hidden``
2527 2541 Whether to hide the repository in the hgwebdir index.
2528 2542 (default: False)
2529 2543
2530 2544 ``ipv6``
2531 2545 Whether to use IPv6. (default: False)
2532 2546
2533 2547 ``labels``
2534 2548 List of string *labels* associated with the repository.
2535 2549
2536 2550 Labels are exposed as a template keyword and can be used to customize
2537 2551 output. e.g. the ``index`` template can group or filter repositories
2538 2552 by labels and the ``summary`` template can display additional content
2539 2553 if a specific label is present.
2540 2554
2541 2555 ``logoimg``
2542 2556 File name of the logo image that some templates display on each page.
2543 2557 The file name is relative to ``staticurl``. That is, the full path to
2544 2558 the logo image is "staticurl/logoimg".
2545 2559 If unset, ``hglogo.png`` will be used.
2546 2560
2547 2561 ``logourl``
2548 2562 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2549 2563 will be used.
2550 2564
2551 2565 ``maxchanges``
2552 2566 Maximum number of changes to list on the changelog. (default: 10)
2553 2567
2554 2568 ``maxfiles``
2555 2569 Maximum number of files to list per changeset. (default: 10)
2556 2570
2557 2571 ``maxshortchanges``
2558 2572 Maximum number of changes to list on the shortlog, graph or filelog
2559 2573 pages. (default: 60)
2560 2574
2561 2575 ``name``
2562 2576 Repository name to use in the web interface.
2563 2577 (default: current working directory)
2564 2578
2565 2579 ``port``
2566 2580 Port to listen on. (default: 8000)
2567 2581
2568 2582 ``prefix``
2569 2583 Prefix path to serve from. (default: '' (server root))
2570 2584
2571 2585 ``push_ssl``
2572 2586 Whether to require that inbound pushes be transported over SSL to
2573 2587 prevent password sniffing. (default: True)
2574 2588
2575 2589 ``refreshinterval``
2576 2590 How frequently directory listings re-scan the filesystem for new
2577 2591 repositories, in seconds. This is relevant when wildcards are used
2578 2592 to define paths. Depending on how much filesystem traversal is
2579 2593 required, refreshing may negatively impact performance.
2580 2594
2581 2595 Values less than or equal to 0 always refresh.
2582 2596 (default: 20)
2583 2597
2584 2598 ``server-header``
2585 2599 Value for HTTP ``Server`` response header.
2586 2600
2587 2601 ``staticurl``
2588 2602 Base URL to use for static files. If unset, static files (e.g. the
2589 2603 hgicon.png favicon) will be served by the CGI script itself. Use
2590 2604 this setting to serve them directly with the HTTP server.
2591 2605 Example: ``http://hgserver/static/``.
2592 2606
2593 2607 ``stripes``
2594 2608 How many lines a "zebra stripe" should span in multi-line output.
2595 2609 Set to 0 to disable. (default: 1)
2596 2610
2597 2611 ``style``
2598 2612 Which template map style to use. The available options are the names of
2599 2613 subdirectories in the HTML templates path. (default: ``paper``)
2600 2614 Example: ``monoblue``.
2601 2615
2602 2616 ``templates``
2603 2617 Where to find the HTML templates. The default path to the HTML templates
2604 2618 can be obtained from ``hg debuginstall``.
2605 2619
2606 2620 ``websub``
2607 2621 ----------
2608 2622
2609 2623 Web substitution filter definition. You can use this section to
2610 2624 define a set of regular expression substitution patterns which
2611 2625 let you automatically modify the hgweb server output.
2612 2626
2613 2627 The default hgweb templates only apply these substitution patterns
2614 2628 on the revision description fields. You can apply them anywhere
2615 2629 you want when you create your own templates by adding calls to the
2616 2630 "websub" filter (usually after calling the "escape" filter).
2617 2631
2618 2632 This can be used, for example, to convert issue references to links
2619 2633 to your issue tracker, or to convert "markdown-like" syntax into
2620 2634 HTML (see the examples below).
2621 2635
2622 2636 Each entry in this section names a substitution filter.
2623 2637 The value of each entry defines the substitution expression itself.
2624 2638 The websub expressions follow the old interhg extension syntax,
2625 2639 which in turn imitates the Unix sed replacement syntax::
2626 2640
2627 2641 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2628 2642
2629 2643 You can use any separator other than "/". The final "i" is optional
2630 2644 and indicates that the search must be case insensitive.
2631 2645
2632 2646 Examples::
2633 2647
2634 2648 [websub]
2635 2649 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2636 2650 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2637 2651 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2638 2652
2639 2653 ``worker``
2640 2654 ----------
2641 2655
2642 2656 Parallel master/worker configuration. We currently perform working
2643 2657 directory updates in parallel on Unix-like systems, which greatly
2644 2658 helps performance.
2645 2659
2646 2660 ``enabled``
2647 2661 Whether to enable workers code to be used.
2648 2662 (default: true)
2649 2663
2650 2664 ``numcpus``
2651 2665 Number of CPUs to use for parallel operations. A zero or
2652 2666 negative value is treated as ``use the default``.
2653 2667 (default: 4 or the number of CPUs on the system, whichever is larger)
2654 2668
2655 2669 ``backgroundclose``
2656 2670 Whether to enable closing file handles on background threads during certain
2657 2671 operations. Some platforms aren't very efficient at closing file
2658 2672 handles that have been written or appended to. By performing file closing
2659 2673 on background threads, file write rate can increase substantially.
2660 2674 (default: true on Windows, false elsewhere)
2661 2675
2662 2676 ``backgroundcloseminfilecount``
2663 2677 Minimum number of files required to trigger background file closing.
2664 2678 Operations not writing this many files won't start background close
2665 2679 threads.
2666 2680 (default: 2048)
2667 2681
2668 2682 ``backgroundclosemaxqueue``
2669 2683 The maximum number of opened file handles waiting to be closed in the
2670 2684 background. This option only has an effect if ``backgroundclose`` is
2671 2685 enabled.
2672 2686 (default: 384)
2673 2687
2674 2688 ``backgroundclosethreadcount``
2675 2689 Number of threads to process background file closes. Only relevant if
2676 2690 ``backgroundclose`` is enabled.
2677 2691 (default: 4)
@@ -1,2396 +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 # experimental config: format.aggressivemergedeltas
672 deltabothparents = self.ui.configbool('format',
673 'aggressivemergedeltas')
671 deltabothparents = self.ui.configbool('revlog',
672 'optimize-delta-parent-choice')
674 673 self.svfs.options['deltabothparents'] = deltabothparents
675 674 self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui)
676 675 chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan')
677 676 if 0 <= chainspan:
678 677 self.svfs.options['maxdeltachainspan'] = chainspan
679 678 mmapindexthreshold = self.ui.configbytes('experimental',
680 679 'mmapindexthreshold')
681 680 if mmapindexthreshold is not None:
682 681 self.svfs.options['mmapindexthreshold'] = mmapindexthreshold
683 682 withsparseread = self.ui.configbool('experimental', 'sparse-read')
684 683 srdensitythres = float(self.ui.config('experimental',
685 684 'sparse-read.density-threshold'))
686 685 srmingapsize = self.ui.configbytes('experimental',
687 686 'sparse-read.min-gap-size')
688 687 self.svfs.options['with-sparse-read'] = withsparseread
689 688 self.svfs.options['sparse-read-density-threshold'] = srdensitythres
690 689 self.svfs.options['sparse-read-min-gap-size'] = srmingapsize
691 690 sparserevlog = SPARSEREVLOG_REQUIREMENT in self.requirements
692 691 self.svfs.options['sparse-revlog'] = sparserevlog
693 692
694 693 for r in self.requirements:
695 694 if r.startswith('exp-compression-'):
696 695 self.svfs.options['compengine'] = r[len('exp-compression-'):]
697 696
698 697 # TODO move "revlogv2" to openerreqs once finalized.
699 698 if REVLOGV2_REQUIREMENT in self.requirements:
700 699 self.svfs.options['revlogv2'] = True
701 700
702 701 def _writerequirements(self):
703 702 scmutil.writerequires(self.vfs, self.requirements)
704 703
705 704 def _checknested(self, path):
706 705 """Determine if path is a legal nested repository."""
707 706 if not path.startswith(self.root):
708 707 return False
709 708 subpath = path[len(self.root) + 1:]
710 709 normsubpath = util.pconvert(subpath)
711 710
712 711 # XXX: Checking against the current working copy is wrong in
713 712 # the sense that it can reject things like
714 713 #
715 714 # $ hg cat -r 10 sub/x.txt
716 715 #
717 716 # if sub/ is no longer a subrepository in the working copy
718 717 # parent revision.
719 718 #
720 719 # However, it can of course also allow things that would have
721 720 # been rejected before, such as the above cat command if sub/
722 721 # is a subrepository now, but was a normal directory before.
723 722 # The old path auditor would have rejected by mistake since it
724 723 # panics when it sees sub/.hg/.
725 724 #
726 725 # All in all, checking against the working copy seems sensible
727 726 # since we want to prevent access to nested repositories on
728 727 # the filesystem *now*.
729 728 ctx = self[None]
730 729 parts = util.splitpath(subpath)
731 730 while parts:
732 731 prefix = '/'.join(parts)
733 732 if prefix in ctx.substate:
734 733 if prefix == normsubpath:
735 734 return True
736 735 else:
737 736 sub = ctx.sub(prefix)
738 737 return sub.checknested(subpath[len(prefix) + 1:])
739 738 else:
740 739 parts.pop()
741 740 return False
742 741
743 742 def peer(self):
744 743 return localpeer(self) # not cached to avoid reference cycle
745 744
746 745 def unfiltered(self):
747 746 """Return unfiltered version of the repository
748 747
749 748 Intended to be overwritten by filtered repo."""
750 749 return self
751 750
752 751 def filtered(self, name, visibilityexceptions=None):
753 752 """Return a filtered version of a repository"""
754 753 cls = repoview.newtype(self.unfiltered().__class__)
755 754 return cls(self, name, visibilityexceptions)
756 755
757 756 @repofilecache('bookmarks', 'bookmarks.current')
758 757 def _bookmarks(self):
759 758 return bookmarks.bmstore(self)
760 759
761 760 @property
762 761 def _activebookmark(self):
763 762 return self._bookmarks.active
764 763
765 764 # _phasesets depend on changelog. what we need is to call
766 765 # _phasecache.invalidate() if '00changelog.i' was changed, but it
767 766 # can't be easily expressed in filecache mechanism.
768 767 @storecache('phaseroots', '00changelog.i')
769 768 def _phasecache(self):
770 769 return phases.phasecache(self, self._phasedefaults)
771 770
772 771 @storecache('obsstore')
773 772 def obsstore(self):
774 773 return obsolete.makestore(self.ui, self)
775 774
776 775 @storecache('00changelog.i')
777 776 def changelog(self):
778 777 return changelog.changelog(self.svfs,
779 778 trypending=txnutil.mayhavepending(self.root))
780 779
781 780 def _constructmanifest(self):
782 781 # This is a temporary function while we migrate from manifest to
783 782 # manifestlog. It allows bundlerepo and unionrepo to intercept the
784 783 # manifest creation.
785 784 return manifest.manifestrevlog(self.svfs)
786 785
787 786 @storecache('00manifest.i')
788 787 def manifestlog(self):
789 788 return manifest.manifestlog(self.svfs, self)
790 789
791 790 @repofilecache('dirstate')
792 791 def dirstate(self):
793 792 return self._makedirstate()
794 793
795 794 def _makedirstate(self):
796 795 """Extension point for wrapping the dirstate per-repo."""
797 796 sparsematchfn = lambda: sparse.matcher(self)
798 797
799 798 return dirstate.dirstate(self.vfs, self.ui, self.root,
800 799 self._dirstatevalidate, sparsematchfn)
801 800
802 801 def _dirstatevalidate(self, node):
803 802 try:
804 803 self.changelog.rev(node)
805 804 return node
806 805 except error.LookupError:
807 806 if not self._dirstatevalidatewarned:
808 807 self._dirstatevalidatewarned = True
809 808 self.ui.warn(_("warning: ignoring unknown"
810 809 " working parent %s!\n") % short(node))
811 810 return nullid
812 811
813 812 @repofilecache(narrowspec.FILENAME)
814 813 def narrowpats(self):
815 814 """matcher patterns for this repository's narrowspec
816 815
817 816 A tuple of (includes, excludes).
818 817 """
819 818 source = self
820 819 if self.shared():
821 820 from . import hg
822 821 source = hg.sharedreposource(self)
823 822 return narrowspec.load(source)
824 823
825 824 @repofilecache(narrowspec.FILENAME)
826 825 def _narrowmatch(self):
827 826 if changegroup.NARROW_REQUIREMENT not in self.requirements:
828 827 return matchmod.always(self.root, '')
829 828 include, exclude = self.narrowpats
830 829 return narrowspec.match(self.root, include=include, exclude=exclude)
831 830
832 831 # TODO(martinvonz): make this property-like instead?
833 832 def narrowmatch(self):
834 833 return self._narrowmatch
835 834
836 835 def setnarrowpats(self, newincludes, newexcludes):
837 836 target = self
838 837 if self.shared():
839 838 from . import hg
840 839 target = hg.sharedreposource(self)
841 840 narrowspec.save(target, newincludes, newexcludes)
842 841 self.invalidate(clearfilecache=True)
843 842
844 843 def __getitem__(self, changeid):
845 844 if changeid is None:
846 845 return context.workingctx(self)
847 846 if isinstance(changeid, context.basectx):
848 847 return changeid
849 848 if isinstance(changeid, slice):
850 849 # wdirrev isn't contiguous so the slice shouldn't include it
851 850 return [context.changectx(self, i)
852 851 for i in xrange(*changeid.indices(len(self)))
853 852 if i not in self.changelog.filteredrevs]
854 853 try:
855 854 return context.changectx(self, changeid)
856 855 except error.WdirUnsupported:
857 856 return context.workingctx(self)
858 857
859 858 def __contains__(self, changeid):
860 859 """True if the given changeid exists
861 860
862 861 error.LookupError is raised if an ambiguous node specified.
863 862 """
864 863 try:
865 864 self[changeid]
866 865 return True
867 866 except error.RepoLookupError:
868 867 return False
869 868
870 869 def __nonzero__(self):
871 870 return True
872 871
873 872 __bool__ = __nonzero__
874 873
875 874 def __len__(self):
876 875 # no need to pay the cost of repoview.changelog
877 876 unfi = self.unfiltered()
878 877 return len(unfi.changelog)
879 878
880 879 def __iter__(self):
881 880 return iter(self.changelog)
882 881
883 882 def revs(self, expr, *args):
884 883 '''Find revisions matching a revset.
885 884
886 885 The revset is specified as a string ``expr`` that may contain
887 886 %-formatting to escape certain types. See ``revsetlang.formatspec``.
888 887
889 888 Revset aliases from the configuration are not expanded. To expand
890 889 user aliases, consider calling ``scmutil.revrange()`` or
891 890 ``repo.anyrevs([expr], user=True)``.
892 891
893 892 Returns a revset.abstractsmartset, which is a list-like interface
894 893 that contains integer revisions.
895 894 '''
896 895 expr = revsetlang.formatspec(expr, *args)
897 896 m = revset.match(None, expr)
898 897 return m(self)
899 898
900 899 def set(self, expr, *args):
901 900 '''Find revisions matching a revset and emit changectx instances.
902 901
903 902 This is a convenience wrapper around ``revs()`` that iterates the
904 903 result and is a generator of changectx instances.
905 904
906 905 Revset aliases from the configuration are not expanded. To expand
907 906 user aliases, consider calling ``scmutil.revrange()``.
908 907 '''
909 908 for r in self.revs(expr, *args):
910 909 yield self[r]
911 910
912 911 def anyrevs(self, specs, user=False, localalias=None):
913 912 '''Find revisions matching one of the given revsets.
914 913
915 914 Revset aliases from the configuration are not expanded by default. To
916 915 expand user aliases, specify ``user=True``. To provide some local
917 916 definitions overriding user aliases, set ``localalias`` to
918 917 ``{name: definitionstring}``.
919 918 '''
920 919 if user:
921 920 m = revset.matchany(self.ui, specs,
922 921 lookup=revset.lookupfn(self),
923 922 localalias=localalias)
924 923 else:
925 924 m = revset.matchany(None, specs, localalias=localalias)
926 925 return m(self)
927 926
928 927 def url(self):
929 928 return 'file:' + self.root
930 929
931 930 def hook(self, name, throw=False, **args):
932 931 """Call a hook, passing this repo instance.
933 932
934 933 This a convenience method to aid invoking hooks. Extensions likely
935 934 won't call this unless they have registered a custom hook or are
936 935 replacing code that is expected to call a hook.
937 936 """
938 937 return hook.hook(self.ui, self, name, throw, **args)
939 938
940 939 @filteredpropertycache
941 940 def _tagscache(self):
942 941 '''Returns a tagscache object that contains various tags related
943 942 caches.'''
944 943
945 944 # This simplifies its cache management by having one decorated
946 945 # function (this one) and the rest simply fetch things from it.
947 946 class tagscache(object):
948 947 def __init__(self):
949 948 # These two define the set of tags for this repository. tags
950 949 # maps tag name to node; tagtypes maps tag name to 'global' or
951 950 # 'local'. (Global tags are defined by .hgtags across all
952 951 # heads, and local tags are defined in .hg/localtags.)
953 952 # They constitute the in-memory cache of tags.
954 953 self.tags = self.tagtypes = None
955 954
956 955 self.nodetagscache = self.tagslist = None
957 956
958 957 cache = tagscache()
959 958 cache.tags, cache.tagtypes = self._findtags()
960 959
961 960 return cache
962 961
963 962 def tags(self):
964 963 '''return a mapping of tag to node'''
965 964 t = {}
966 965 if self.changelog.filteredrevs:
967 966 tags, tt = self._findtags()
968 967 else:
969 968 tags = self._tagscache.tags
970 969 for k, v in tags.iteritems():
971 970 try:
972 971 # ignore tags to unknown nodes
973 972 self.changelog.rev(v)
974 973 t[k] = v
975 974 except (error.LookupError, ValueError):
976 975 pass
977 976 return t
978 977
979 978 def _findtags(self):
980 979 '''Do the hard work of finding tags. Return a pair of dicts
981 980 (tags, tagtypes) where tags maps tag name to node, and tagtypes
982 981 maps tag name to a string like \'global\' or \'local\'.
983 982 Subclasses or extensions are free to add their own tags, but
984 983 should be aware that the returned dicts will be retained for the
985 984 duration of the localrepo object.'''
986 985
987 986 # XXX what tagtype should subclasses/extensions use? Currently
988 987 # mq and bookmarks add tags, but do not set the tagtype at all.
989 988 # Should each extension invent its own tag type? Should there
990 989 # be one tagtype for all such "virtual" tags? Or is the status
991 990 # quo fine?
992 991
993 992
994 993 # map tag name to (node, hist)
995 994 alltags = tagsmod.findglobaltags(self.ui, self)
996 995 # map tag name to tag type
997 996 tagtypes = dict((tag, 'global') for tag in alltags)
998 997
999 998 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
1000 999
1001 1000 # Build the return dicts. Have to re-encode tag names because
1002 1001 # the tags module always uses UTF-8 (in order not to lose info
1003 1002 # writing to the cache), but the rest of Mercurial wants them in
1004 1003 # local encoding.
1005 1004 tags = {}
1006 1005 for (name, (node, hist)) in alltags.iteritems():
1007 1006 if node != nullid:
1008 1007 tags[encoding.tolocal(name)] = node
1009 1008 tags['tip'] = self.changelog.tip()
1010 1009 tagtypes = dict([(encoding.tolocal(name), value)
1011 1010 for (name, value) in tagtypes.iteritems()])
1012 1011 return (tags, tagtypes)
1013 1012
1014 1013 def tagtype(self, tagname):
1015 1014 '''
1016 1015 return the type of the given tag. result can be:
1017 1016
1018 1017 'local' : a local tag
1019 1018 'global' : a global tag
1020 1019 None : tag does not exist
1021 1020 '''
1022 1021
1023 1022 return self._tagscache.tagtypes.get(tagname)
1024 1023
1025 1024 def tagslist(self):
1026 1025 '''return a list of tags ordered by revision'''
1027 1026 if not self._tagscache.tagslist:
1028 1027 l = []
1029 1028 for t, n in self.tags().iteritems():
1030 1029 l.append((self.changelog.rev(n), t, n))
1031 1030 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
1032 1031
1033 1032 return self._tagscache.tagslist
1034 1033
1035 1034 def nodetags(self, node):
1036 1035 '''return the tags associated with a node'''
1037 1036 if not self._tagscache.nodetagscache:
1038 1037 nodetagscache = {}
1039 1038 for t, n in self._tagscache.tags.iteritems():
1040 1039 nodetagscache.setdefault(n, []).append(t)
1041 1040 for tags in nodetagscache.itervalues():
1042 1041 tags.sort()
1043 1042 self._tagscache.nodetagscache = nodetagscache
1044 1043 return self._tagscache.nodetagscache.get(node, [])
1045 1044
1046 1045 def nodebookmarks(self, node):
1047 1046 """return the list of bookmarks pointing to the specified node"""
1048 1047 return self._bookmarks.names(node)
1049 1048
1050 1049 def branchmap(self):
1051 1050 '''returns a dictionary {branch: [branchheads]} with branchheads
1052 1051 ordered by increasing revision number'''
1053 1052 branchmap.updatecache(self)
1054 1053 return self._branchcaches[self.filtername]
1055 1054
1056 1055 @unfilteredmethod
1057 1056 def revbranchcache(self):
1058 1057 if not self._revbranchcache:
1059 1058 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
1060 1059 return self._revbranchcache
1061 1060
1062 1061 def branchtip(self, branch, ignoremissing=False):
1063 1062 '''return the tip node for a given branch
1064 1063
1065 1064 If ignoremissing is True, then this method will not raise an error.
1066 1065 This is helpful for callers that only expect None for a missing branch
1067 1066 (e.g. namespace).
1068 1067
1069 1068 '''
1070 1069 try:
1071 1070 return self.branchmap().branchtip(branch)
1072 1071 except KeyError:
1073 1072 if not ignoremissing:
1074 1073 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
1075 1074 else:
1076 1075 pass
1077 1076
1078 1077 def lookup(self, key):
1079 1078 return scmutil.revsymbol(self, key).node()
1080 1079
1081 1080 def lookupbranch(self, key):
1082 1081 if key in self.branchmap():
1083 1082 return key
1084 1083
1085 1084 return scmutil.revsymbol(self, key).branch()
1086 1085
1087 1086 def known(self, nodes):
1088 1087 cl = self.changelog
1089 1088 nm = cl.nodemap
1090 1089 filtered = cl.filteredrevs
1091 1090 result = []
1092 1091 for n in nodes:
1093 1092 r = nm.get(n)
1094 1093 resp = not (r is None or r in filtered)
1095 1094 result.append(resp)
1096 1095 return result
1097 1096
1098 1097 def local(self):
1099 1098 return self
1100 1099
1101 1100 def publishing(self):
1102 1101 # it's safe (and desirable) to trust the publish flag unconditionally
1103 1102 # so that we don't finalize changes shared between users via ssh or nfs
1104 1103 return self.ui.configbool('phases', 'publish', untrusted=True)
1105 1104
1106 1105 def cancopy(self):
1107 1106 # so statichttprepo's override of local() works
1108 1107 if not self.local():
1109 1108 return False
1110 1109 if not self.publishing():
1111 1110 return True
1112 1111 # if publishing we can't copy if there is filtered content
1113 1112 return not self.filtered('visible').changelog.filteredrevs
1114 1113
1115 1114 def shared(self):
1116 1115 '''the type of shared repository (None if not shared)'''
1117 1116 if self.sharedpath != self.path:
1118 1117 return 'store'
1119 1118 return None
1120 1119
1121 1120 def wjoin(self, f, *insidef):
1122 1121 return self.vfs.reljoin(self.root, f, *insidef)
1123 1122
1124 1123 def file(self, f):
1125 1124 if f[0] == '/':
1126 1125 f = f[1:]
1127 1126 return filelog.filelog(self.svfs, f)
1128 1127
1129 1128 def setparents(self, p1, p2=nullid):
1130 1129 with self.dirstate.parentchange():
1131 1130 copies = self.dirstate.setparents(p1, p2)
1132 1131 pctx = self[p1]
1133 1132 if copies:
1134 1133 # Adjust copy records, the dirstate cannot do it, it
1135 1134 # requires access to parents manifests. Preserve them
1136 1135 # only for entries added to first parent.
1137 1136 for f in copies:
1138 1137 if f not in pctx and copies[f] in pctx:
1139 1138 self.dirstate.copy(copies[f], f)
1140 1139 if p2 == nullid:
1141 1140 for f, s in sorted(self.dirstate.copies().items()):
1142 1141 if f not in pctx and s not in pctx:
1143 1142 self.dirstate.copy(None, f)
1144 1143
1145 1144 def filectx(self, path, changeid=None, fileid=None, changectx=None):
1146 1145 """changeid can be a changeset revision, node, or tag.
1147 1146 fileid can be a file revision or node."""
1148 1147 return context.filectx(self, path, changeid, fileid,
1149 1148 changectx=changectx)
1150 1149
1151 1150 def getcwd(self):
1152 1151 return self.dirstate.getcwd()
1153 1152
1154 1153 def pathto(self, f, cwd=None):
1155 1154 return self.dirstate.pathto(f, cwd)
1156 1155
1157 1156 def _loadfilter(self, filter):
1158 1157 if filter not in self._filterpats:
1159 1158 l = []
1160 1159 for pat, cmd in self.ui.configitems(filter):
1161 1160 if cmd == '!':
1162 1161 continue
1163 1162 mf = matchmod.match(self.root, '', [pat])
1164 1163 fn = None
1165 1164 params = cmd
1166 1165 for name, filterfn in self._datafilters.iteritems():
1167 1166 if cmd.startswith(name):
1168 1167 fn = filterfn
1169 1168 params = cmd[len(name):].lstrip()
1170 1169 break
1171 1170 if not fn:
1172 1171 fn = lambda s, c, **kwargs: procutil.filter(s, c)
1173 1172 # Wrap old filters not supporting keyword arguments
1174 1173 if not pycompat.getargspec(fn)[2]:
1175 1174 oldfn = fn
1176 1175 fn = lambda s, c, **kwargs: oldfn(s, c)
1177 1176 l.append((mf, fn, params))
1178 1177 self._filterpats[filter] = l
1179 1178 return self._filterpats[filter]
1180 1179
1181 1180 def _filter(self, filterpats, filename, data):
1182 1181 for mf, fn, cmd in filterpats:
1183 1182 if mf(filename):
1184 1183 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
1185 1184 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
1186 1185 break
1187 1186
1188 1187 return data
1189 1188
1190 1189 @unfilteredpropertycache
1191 1190 def _encodefilterpats(self):
1192 1191 return self._loadfilter('encode')
1193 1192
1194 1193 @unfilteredpropertycache
1195 1194 def _decodefilterpats(self):
1196 1195 return self._loadfilter('decode')
1197 1196
1198 1197 def adddatafilter(self, name, filter):
1199 1198 self._datafilters[name] = filter
1200 1199
1201 1200 def wread(self, filename):
1202 1201 if self.wvfs.islink(filename):
1203 1202 data = self.wvfs.readlink(filename)
1204 1203 else:
1205 1204 data = self.wvfs.read(filename)
1206 1205 return self._filter(self._encodefilterpats, filename, data)
1207 1206
1208 1207 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
1209 1208 """write ``data`` into ``filename`` in the working directory
1210 1209
1211 1210 This returns length of written (maybe decoded) data.
1212 1211 """
1213 1212 data = self._filter(self._decodefilterpats, filename, data)
1214 1213 if 'l' in flags:
1215 1214 self.wvfs.symlink(data, filename)
1216 1215 else:
1217 1216 self.wvfs.write(filename, data, backgroundclose=backgroundclose,
1218 1217 **kwargs)
1219 1218 if 'x' in flags:
1220 1219 self.wvfs.setflags(filename, False, True)
1221 1220 else:
1222 1221 self.wvfs.setflags(filename, False, False)
1223 1222 return len(data)
1224 1223
1225 1224 def wwritedata(self, filename, data):
1226 1225 return self._filter(self._decodefilterpats, filename, data)
1227 1226
1228 1227 def currenttransaction(self):
1229 1228 """return the current transaction or None if non exists"""
1230 1229 if self._transref:
1231 1230 tr = self._transref()
1232 1231 else:
1233 1232 tr = None
1234 1233
1235 1234 if tr and tr.running():
1236 1235 return tr
1237 1236 return None
1238 1237
1239 1238 def transaction(self, desc, report=None):
1240 1239 if (self.ui.configbool('devel', 'all-warnings')
1241 1240 or self.ui.configbool('devel', 'check-locks')):
1242 1241 if self._currentlock(self._lockref) is None:
1243 1242 raise error.ProgrammingError('transaction requires locking')
1244 1243 tr = self.currenttransaction()
1245 1244 if tr is not None:
1246 1245 return tr.nest(name=desc)
1247 1246
1248 1247 # abort here if the journal already exists
1249 1248 if self.svfs.exists("journal"):
1250 1249 raise error.RepoError(
1251 1250 _("abandoned transaction found"),
1252 1251 hint=_("run 'hg recover' to clean up transaction"))
1253 1252
1254 1253 idbase = "%.40f#%f" % (random.random(), time.time())
1255 1254 ha = hex(hashlib.sha1(idbase).digest())
1256 1255 txnid = 'TXN:' + ha
1257 1256 self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
1258 1257
1259 1258 self._writejournal(desc)
1260 1259 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
1261 1260 if report:
1262 1261 rp = report
1263 1262 else:
1264 1263 rp = self.ui.warn
1265 1264 vfsmap = {'plain': self.vfs} # root of .hg/
1266 1265 # we must avoid cyclic reference between repo and transaction.
1267 1266 reporef = weakref.ref(self)
1268 1267 # Code to track tag movement
1269 1268 #
1270 1269 # Since tags are all handled as file content, it is actually quite hard
1271 1270 # to track these movement from a code perspective. So we fallback to a
1272 1271 # tracking at the repository level. One could envision to track changes
1273 1272 # to the '.hgtags' file through changegroup apply but that fails to
1274 1273 # cope with case where transaction expose new heads without changegroup
1275 1274 # being involved (eg: phase movement).
1276 1275 #
1277 1276 # For now, We gate the feature behind a flag since this likely comes
1278 1277 # with performance impacts. The current code run more often than needed
1279 1278 # and do not use caches as much as it could. The current focus is on
1280 1279 # the behavior of the feature so we disable it by default. The flag
1281 1280 # will be removed when we are happy with the performance impact.
1282 1281 #
1283 1282 # Once this feature is no longer experimental move the following
1284 1283 # documentation to the appropriate help section:
1285 1284 #
1286 1285 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
1287 1286 # tags (new or changed or deleted tags). In addition the details of
1288 1287 # these changes are made available in a file at:
1289 1288 # ``REPOROOT/.hg/changes/tags.changes``.
1290 1289 # Make sure you check for HG_TAG_MOVED before reading that file as it
1291 1290 # might exist from a previous transaction even if no tag were touched
1292 1291 # in this one. Changes are recorded in a line base format::
1293 1292 #
1294 1293 # <action> <hex-node> <tag-name>\n
1295 1294 #
1296 1295 # Actions are defined as follow:
1297 1296 # "-R": tag is removed,
1298 1297 # "+A": tag is added,
1299 1298 # "-M": tag is moved (old value),
1300 1299 # "+M": tag is moved (new value),
1301 1300 tracktags = lambda x: None
1302 1301 # experimental config: experimental.hook-track-tags
1303 1302 shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags')
1304 1303 if desc != 'strip' and shouldtracktags:
1305 1304 oldheads = self.changelog.headrevs()
1306 1305 def tracktags(tr2):
1307 1306 repo = reporef()
1308 1307 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
1309 1308 newheads = repo.changelog.headrevs()
1310 1309 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
1311 1310 # notes: we compare lists here.
1312 1311 # As we do it only once buiding set would not be cheaper
1313 1312 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
1314 1313 if changes:
1315 1314 tr2.hookargs['tag_moved'] = '1'
1316 1315 with repo.vfs('changes/tags.changes', 'w',
1317 1316 atomictemp=True) as changesfile:
1318 1317 # note: we do not register the file to the transaction
1319 1318 # because we needs it to still exist on the transaction
1320 1319 # is close (for txnclose hooks)
1321 1320 tagsmod.writediff(changesfile, changes)
1322 1321 def validate(tr2):
1323 1322 """will run pre-closing hooks"""
1324 1323 # XXX the transaction API is a bit lacking here so we take a hacky
1325 1324 # path for now
1326 1325 #
1327 1326 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
1328 1327 # dict is copied before these run. In addition we needs the data
1329 1328 # available to in memory hooks too.
1330 1329 #
1331 1330 # Moreover, we also need to make sure this runs before txnclose
1332 1331 # hooks and there is no "pending" mechanism that would execute
1333 1332 # logic only if hooks are about to run.
1334 1333 #
1335 1334 # Fixing this limitation of the transaction is also needed to track
1336 1335 # other families of changes (bookmarks, phases, obsolescence).
1337 1336 #
1338 1337 # This will have to be fixed before we remove the experimental
1339 1338 # gating.
1340 1339 tracktags(tr2)
1341 1340 repo = reporef()
1342 1341 if repo.ui.configbool('experimental', 'single-head-per-branch'):
1343 1342 scmutil.enforcesinglehead(repo, tr2, desc)
1344 1343 if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
1345 1344 for name, (old, new) in sorted(tr.changes['bookmarks'].items()):
1346 1345 args = tr.hookargs.copy()
1347 1346 args.update(bookmarks.preparehookargs(name, old, new))
1348 1347 repo.hook('pretxnclose-bookmark', throw=True,
1349 1348 txnname=desc,
1350 1349 **pycompat.strkwargs(args))
1351 1350 if hook.hashook(repo.ui, 'pretxnclose-phase'):
1352 1351 cl = repo.unfiltered().changelog
1353 1352 for rev, (old, new) in tr.changes['phases'].items():
1354 1353 args = tr.hookargs.copy()
1355 1354 node = hex(cl.node(rev))
1356 1355 args.update(phases.preparehookargs(node, old, new))
1357 1356 repo.hook('pretxnclose-phase', throw=True, txnname=desc,
1358 1357 **pycompat.strkwargs(args))
1359 1358
1360 1359 repo.hook('pretxnclose', throw=True,
1361 1360 txnname=desc, **pycompat.strkwargs(tr.hookargs))
1362 1361 def releasefn(tr, success):
1363 1362 repo = reporef()
1364 1363 if success:
1365 1364 # this should be explicitly invoked here, because
1366 1365 # in-memory changes aren't written out at closing
1367 1366 # transaction, if tr.addfilegenerator (via
1368 1367 # dirstate.write or so) isn't invoked while
1369 1368 # transaction running
1370 1369 repo.dirstate.write(None)
1371 1370 else:
1372 1371 # discard all changes (including ones already written
1373 1372 # out) in this transaction
1374 1373 repo.dirstate.restorebackup(None, 'journal.dirstate')
1375 1374
1376 1375 repo.invalidate(clearfilecache=True)
1377 1376
1378 1377 tr = transaction.transaction(rp, self.svfs, vfsmap,
1379 1378 "journal",
1380 1379 "undo",
1381 1380 aftertrans(renames),
1382 1381 self.store.createmode,
1383 1382 validator=validate,
1384 1383 releasefn=releasefn,
1385 1384 checkambigfiles=_cachedfiles,
1386 1385 name=desc)
1387 1386 tr.changes['revs'] = xrange(0, 0)
1388 1387 tr.changes['obsmarkers'] = set()
1389 1388 tr.changes['phases'] = {}
1390 1389 tr.changes['bookmarks'] = {}
1391 1390
1392 1391 tr.hookargs['txnid'] = txnid
1393 1392 # note: writing the fncache only during finalize mean that the file is
1394 1393 # outdated when running hooks. As fncache is used for streaming clone,
1395 1394 # this is not expected to break anything that happen during the hooks.
1396 1395 tr.addfinalize('flush-fncache', self.store.write)
1397 1396 def txnclosehook(tr2):
1398 1397 """To be run if transaction is successful, will schedule a hook run
1399 1398 """
1400 1399 # Don't reference tr2 in hook() so we don't hold a reference.
1401 1400 # This reduces memory consumption when there are multiple
1402 1401 # transactions per lock. This can likely go away if issue5045
1403 1402 # fixes the function accumulation.
1404 1403 hookargs = tr2.hookargs
1405 1404
1406 1405 def hookfunc():
1407 1406 repo = reporef()
1408 1407 if hook.hashook(repo.ui, 'txnclose-bookmark'):
1409 1408 bmchanges = sorted(tr.changes['bookmarks'].items())
1410 1409 for name, (old, new) in bmchanges:
1411 1410 args = tr.hookargs.copy()
1412 1411 args.update(bookmarks.preparehookargs(name, old, new))
1413 1412 repo.hook('txnclose-bookmark', throw=False,
1414 1413 txnname=desc, **pycompat.strkwargs(args))
1415 1414
1416 1415 if hook.hashook(repo.ui, 'txnclose-phase'):
1417 1416 cl = repo.unfiltered().changelog
1418 1417 phasemv = sorted(tr.changes['phases'].items())
1419 1418 for rev, (old, new) in phasemv:
1420 1419 args = tr.hookargs.copy()
1421 1420 node = hex(cl.node(rev))
1422 1421 args.update(phases.preparehookargs(node, old, new))
1423 1422 repo.hook('txnclose-phase', throw=False, txnname=desc,
1424 1423 **pycompat.strkwargs(args))
1425 1424
1426 1425 repo.hook('txnclose', throw=False, txnname=desc,
1427 1426 **pycompat.strkwargs(hookargs))
1428 1427 reporef()._afterlock(hookfunc)
1429 1428 tr.addfinalize('txnclose-hook', txnclosehook)
1430 1429 # Include a leading "-" to make it happen before the transaction summary
1431 1430 # reports registered via scmutil.registersummarycallback() whose names
1432 1431 # are 00-txnreport etc. That way, the caches will be warm when the
1433 1432 # callbacks run.
1434 1433 tr.addpostclose('-warm-cache', self._buildcacheupdater(tr))
1435 1434 def txnaborthook(tr2):
1436 1435 """To be run if transaction is aborted
1437 1436 """
1438 1437 reporef().hook('txnabort', throw=False, txnname=desc,
1439 1438 **pycompat.strkwargs(tr2.hookargs))
1440 1439 tr.addabort('txnabort-hook', txnaborthook)
1441 1440 # avoid eager cache invalidation. in-memory data should be identical
1442 1441 # to stored data if transaction has no error.
1443 1442 tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats)
1444 1443 self._transref = weakref.ref(tr)
1445 1444 scmutil.registersummarycallback(self, tr, desc)
1446 1445 return tr
1447 1446
1448 1447 def _journalfiles(self):
1449 1448 return ((self.svfs, 'journal'),
1450 1449 (self.vfs, 'journal.dirstate'),
1451 1450 (self.vfs, 'journal.branch'),
1452 1451 (self.vfs, 'journal.desc'),
1453 1452 (self.vfs, 'journal.bookmarks'),
1454 1453 (self.svfs, 'journal.phaseroots'))
1455 1454
1456 1455 def undofiles(self):
1457 1456 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
1458 1457
1459 1458 @unfilteredmethod
1460 1459 def _writejournal(self, desc):
1461 1460 self.dirstate.savebackup(None, 'journal.dirstate')
1462 1461 self.vfs.write("journal.branch",
1463 1462 encoding.fromlocal(self.dirstate.branch()))
1464 1463 self.vfs.write("journal.desc",
1465 1464 "%d\n%s\n" % (len(self), desc))
1466 1465 self.vfs.write("journal.bookmarks",
1467 1466 self.vfs.tryread("bookmarks"))
1468 1467 self.svfs.write("journal.phaseroots",
1469 1468 self.svfs.tryread("phaseroots"))
1470 1469
1471 1470 def recover(self):
1472 1471 with self.lock():
1473 1472 if self.svfs.exists("journal"):
1474 1473 self.ui.status(_("rolling back interrupted transaction\n"))
1475 1474 vfsmap = {'': self.svfs,
1476 1475 'plain': self.vfs,}
1477 1476 transaction.rollback(self.svfs, vfsmap, "journal",
1478 1477 self.ui.warn,
1479 1478 checkambigfiles=_cachedfiles)
1480 1479 self.invalidate()
1481 1480 return True
1482 1481 else:
1483 1482 self.ui.warn(_("no interrupted transaction available\n"))
1484 1483 return False
1485 1484
1486 1485 def rollback(self, dryrun=False, force=False):
1487 1486 wlock = lock = dsguard = None
1488 1487 try:
1489 1488 wlock = self.wlock()
1490 1489 lock = self.lock()
1491 1490 if self.svfs.exists("undo"):
1492 1491 dsguard = dirstateguard.dirstateguard(self, 'rollback')
1493 1492
1494 1493 return self._rollback(dryrun, force, dsguard)
1495 1494 else:
1496 1495 self.ui.warn(_("no rollback information available\n"))
1497 1496 return 1
1498 1497 finally:
1499 1498 release(dsguard, lock, wlock)
1500 1499
1501 1500 @unfilteredmethod # Until we get smarter cache management
1502 1501 def _rollback(self, dryrun, force, dsguard):
1503 1502 ui = self.ui
1504 1503 try:
1505 1504 args = self.vfs.read('undo.desc').splitlines()
1506 1505 (oldlen, desc, detail) = (int(args[0]), args[1], None)
1507 1506 if len(args) >= 3:
1508 1507 detail = args[2]
1509 1508 oldtip = oldlen - 1
1510 1509
1511 1510 if detail and ui.verbose:
1512 1511 msg = (_('repository tip rolled back to revision %d'
1513 1512 ' (undo %s: %s)\n')
1514 1513 % (oldtip, desc, detail))
1515 1514 else:
1516 1515 msg = (_('repository tip rolled back to revision %d'
1517 1516 ' (undo %s)\n')
1518 1517 % (oldtip, desc))
1519 1518 except IOError:
1520 1519 msg = _('rolling back unknown transaction\n')
1521 1520 desc = None
1522 1521
1523 1522 if not force and self['.'] != self['tip'] and desc == 'commit':
1524 1523 raise error.Abort(
1525 1524 _('rollback of last commit while not checked out '
1526 1525 'may lose data'), hint=_('use -f to force'))
1527 1526
1528 1527 ui.status(msg)
1529 1528 if dryrun:
1530 1529 return 0
1531 1530
1532 1531 parents = self.dirstate.parents()
1533 1532 self.destroying()
1534 1533 vfsmap = {'plain': self.vfs, '': self.svfs}
1535 1534 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn,
1536 1535 checkambigfiles=_cachedfiles)
1537 1536 if self.vfs.exists('undo.bookmarks'):
1538 1537 self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True)
1539 1538 if self.svfs.exists('undo.phaseroots'):
1540 1539 self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True)
1541 1540 self.invalidate()
1542 1541
1543 1542 parentgone = (parents[0] not in self.changelog.nodemap or
1544 1543 parents[1] not in self.changelog.nodemap)
1545 1544 if parentgone:
1546 1545 # prevent dirstateguard from overwriting already restored one
1547 1546 dsguard.close()
1548 1547
1549 1548 self.dirstate.restorebackup(None, 'undo.dirstate')
1550 1549 try:
1551 1550 branch = self.vfs.read('undo.branch')
1552 1551 self.dirstate.setbranch(encoding.tolocal(branch))
1553 1552 except IOError:
1554 1553 ui.warn(_('named branch could not be reset: '
1555 1554 'current branch is still \'%s\'\n')
1556 1555 % self.dirstate.branch())
1557 1556
1558 1557 parents = tuple([p.rev() for p in self[None].parents()])
1559 1558 if len(parents) > 1:
1560 1559 ui.status(_('working directory now based on '
1561 1560 'revisions %d and %d\n') % parents)
1562 1561 else:
1563 1562 ui.status(_('working directory now based on '
1564 1563 'revision %d\n') % parents)
1565 1564 mergemod.mergestate.clean(self, self['.'].node())
1566 1565
1567 1566 # TODO: if we know which new heads may result from this rollback, pass
1568 1567 # them to destroy(), which will prevent the branchhead cache from being
1569 1568 # invalidated.
1570 1569 self.destroyed()
1571 1570 return 0
1572 1571
1573 1572 def _buildcacheupdater(self, newtransaction):
1574 1573 """called during transaction to build the callback updating cache
1575 1574
1576 1575 Lives on the repository to help extension who might want to augment
1577 1576 this logic. For this purpose, the created transaction is passed to the
1578 1577 method.
1579 1578 """
1580 1579 # we must avoid cyclic reference between repo and transaction.
1581 1580 reporef = weakref.ref(self)
1582 1581 def updater(tr):
1583 1582 repo = reporef()
1584 1583 repo.updatecaches(tr)
1585 1584 return updater
1586 1585
1587 1586 @unfilteredmethod
1588 1587 def updatecaches(self, tr=None, full=False):
1589 1588 """warm appropriate caches
1590 1589
1591 1590 If this function is called after a transaction closed. The transaction
1592 1591 will be available in the 'tr' argument. This can be used to selectively
1593 1592 update caches relevant to the changes in that transaction.
1594 1593
1595 1594 If 'full' is set, make sure all caches the function knows about have
1596 1595 up-to-date data. Even the ones usually loaded more lazily.
1597 1596 """
1598 1597 if tr is not None and tr.hookargs.get('source') == 'strip':
1599 1598 # During strip, many caches are invalid but
1600 1599 # later call to `destroyed` will refresh them.
1601 1600 return
1602 1601
1603 1602 if tr is None or tr.changes['revs']:
1604 1603 # updating the unfiltered branchmap should refresh all the others,
1605 1604 self.ui.debug('updating the branch cache\n')
1606 1605 branchmap.updatecache(self.filtered('served'))
1607 1606
1608 1607 if full:
1609 1608 rbc = self.revbranchcache()
1610 1609 for r in self.changelog:
1611 1610 rbc.branchinfo(r)
1612 1611 rbc.write()
1613 1612
1614 1613 def invalidatecaches(self):
1615 1614
1616 1615 if '_tagscache' in vars(self):
1617 1616 # can't use delattr on proxy
1618 1617 del self.__dict__['_tagscache']
1619 1618
1620 1619 self.unfiltered()._branchcaches.clear()
1621 1620 self.invalidatevolatilesets()
1622 1621 self._sparsesignaturecache.clear()
1623 1622
1624 1623 def invalidatevolatilesets(self):
1625 1624 self.filteredrevcache.clear()
1626 1625 obsolete.clearobscaches(self)
1627 1626
1628 1627 def invalidatedirstate(self):
1629 1628 '''Invalidates the dirstate, causing the next call to dirstate
1630 1629 to check if it was modified since the last time it was read,
1631 1630 rereading it if it has.
1632 1631
1633 1632 This is different to dirstate.invalidate() that it doesn't always
1634 1633 rereads the dirstate. Use dirstate.invalidate() if you want to
1635 1634 explicitly read the dirstate again (i.e. restoring it to a previous
1636 1635 known good state).'''
1637 1636 if hasunfilteredcache(self, 'dirstate'):
1638 1637 for k in self.dirstate._filecache:
1639 1638 try:
1640 1639 delattr(self.dirstate, k)
1641 1640 except AttributeError:
1642 1641 pass
1643 1642 delattr(self.unfiltered(), 'dirstate')
1644 1643
1645 1644 def invalidate(self, clearfilecache=False):
1646 1645 '''Invalidates both store and non-store parts other than dirstate
1647 1646
1648 1647 If a transaction is running, invalidation of store is omitted,
1649 1648 because discarding in-memory changes might cause inconsistency
1650 1649 (e.g. incomplete fncache causes unintentional failure, but
1651 1650 redundant one doesn't).
1652 1651 '''
1653 1652 unfiltered = self.unfiltered() # all file caches are stored unfiltered
1654 1653 for k in list(self._filecache.keys()):
1655 1654 # dirstate is invalidated separately in invalidatedirstate()
1656 1655 if k == 'dirstate':
1657 1656 continue
1658 1657 if (k == 'changelog' and
1659 1658 self.currenttransaction() and
1660 1659 self.changelog._delayed):
1661 1660 # The changelog object may store unwritten revisions. We don't
1662 1661 # want to lose them.
1663 1662 # TODO: Solve the problem instead of working around it.
1664 1663 continue
1665 1664
1666 1665 if clearfilecache:
1667 1666 del self._filecache[k]
1668 1667 try:
1669 1668 delattr(unfiltered, k)
1670 1669 except AttributeError:
1671 1670 pass
1672 1671 self.invalidatecaches()
1673 1672 if not self.currenttransaction():
1674 1673 # TODO: Changing contents of store outside transaction
1675 1674 # causes inconsistency. We should make in-memory store
1676 1675 # changes detectable, and abort if changed.
1677 1676 self.store.invalidatecaches()
1678 1677
1679 1678 def invalidateall(self):
1680 1679 '''Fully invalidates both store and non-store parts, causing the
1681 1680 subsequent operation to reread any outside changes.'''
1682 1681 # extension should hook this to invalidate its caches
1683 1682 self.invalidate()
1684 1683 self.invalidatedirstate()
1685 1684
1686 1685 @unfilteredmethod
1687 1686 def _refreshfilecachestats(self, tr):
1688 1687 """Reload stats of cached files so that they are flagged as valid"""
1689 1688 for k, ce in self._filecache.items():
1690 1689 k = pycompat.sysstr(k)
1691 1690 if k == r'dirstate' or k not in self.__dict__:
1692 1691 continue
1693 1692 ce.refresh()
1694 1693
1695 1694 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc,
1696 1695 inheritchecker=None, parentenvvar=None):
1697 1696 parentlock = None
1698 1697 # the contents of parentenvvar are used by the underlying lock to
1699 1698 # determine whether it can be inherited
1700 1699 if parentenvvar is not None:
1701 1700 parentlock = encoding.environ.get(parentenvvar)
1702 1701
1703 1702 timeout = 0
1704 1703 warntimeout = 0
1705 1704 if wait:
1706 1705 timeout = self.ui.configint("ui", "timeout")
1707 1706 warntimeout = self.ui.configint("ui", "timeout.warn")
1708 1707 # internal config: ui.signal-safe-lock
1709 1708 signalsafe = self.ui.configbool('ui', 'signal-safe-lock')
1710 1709
1711 1710 l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout,
1712 1711 releasefn=releasefn,
1713 1712 acquirefn=acquirefn, desc=desc,
1714 1713 inheritchecker=inheritchecker,
1715 1714 parentlock=parentlock,
1716 1715 signalsafe=signalsafe)
1717 1716 return l
1718 1717
1719 1718 def _afterlock(self, callback):
1720 1719 """add a callback to be run when the repository is fully unlocked
1721 1720
1722 1721 The callback will be executed when the outermost lock is released
1723 1722 (with wlock being higher level than 'lock')."""
1724 1723 for ref in (self._wlockref, self._lockref):
1725 1724 l = ref and ref()
1726 1725 if l and l.held:
1727 1726 l.postrelease.append(callback)
1728 1727 break
1729 1728 else: # no lock have been found.
1730 1729 callback()
1731 1730
1732 1731 def lock(self, wait=True):
1733 1732 '''Lock the repository store (.hg/store) and return a weak reference
1734 1733 to the lock. Use this before modifying the store (e.g. committing or
1735 1734 stripping). If you are opening a transaction, get a lock as well.)
1736 1735
1737 1736 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1738 1737 'wlock' first to avoid a dead-lock hazard.'''
1739 1738 l = self._currentlock(self._lockref)
1740 1739 if l is not None:
1741 1740 l.lock()
1742 1741 return l
1743 1742
1744 1743 l = self._lock(self.svfs, "lock", wait, None,
1745 1744 self.invalidate, _('repository %s') % self.origroot)
1746 1745 self._lockref = weakref.ref(l)
1747 1746 return l
1748 1747
1749 1748 def _wlockchecktransaction(self):
1750 1749 if self.currenttransaction() is not None:
1751 1750 raise error.LockInheritanceContractViolation(
1752 1751 'wlock cannot be inherited in the middle of a transaction')
1753 1752
1754 1753 def wlock(self, wait=True):
1755 1754 '''Lock the non-store parts of the repository (everything under
1756 1755 .hg except .hg/store) and return a weak reference to the lock.
1757 1756
1758 1757 Use this before modifying files in .hg.
1759 1758
1760 1759 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1761 1760 'wlock' first to avoid a dead-lock hazard.'''
1762 1761 l = self._wlockref and self._wlockref()
1763 1762 if l is not None and l.held:
1764 1763 l.lock()
1765 1764 return l
1766 1765
1767 1766 # We do not need to check for non-waiting lock acquisition. Such
1768 1767 # acquisition would not cause dead-lock as they would just fail.
1769 1768 if wait and (self.ui.configbool('devel', 'all-warnings')
1770 1769 or self.ui.configbool('devel', 'check-locks')):
1771 1770 if self._currentlock(self._lockref) is not None:
1772 1771 self.ui.develwarn('"wlock" acquired after "lock"')
1773 1772
1774 1773 def unlock():
1775 1774 if self.dirstate.pendingparentchange():
1776 1775 self.dirstate.invalidate()
1777 1776 else:
1778 1777 self.dirstate.write(None)
1779 1778
1780 1779 self._filecache['dirstate'].refresh()
1781 1780
1782 1781 l = self._lock(self.vfs, "wlock", wait, unlock,
1783 1782 self.invalidatedirstate, _('working directory of %s') %
1784 1783 self.origroot,
1785 1784 inheritchecker=self._wlockchecktransaction,
1786 1785 parentenvvar='HG_WLOCK_LOCKER')
1787 1786 self._wlockref = weakref.ref(l)
1788 1787 return l
1789 1788
1790 1789 def _currentlock(self, lockref):
1791 1790 """Returns the lock if it's held, or None if it's not."""
1792 1791 if lockref is None:
1793 1792 return None
1794 1793 l = lockref()
1795 1794 if l is None or not l.held:
1796 1795 return None
1797 1796 return l
1798 1797
1799 1798 def currentwlock(self):
1800 1799 """Returns the wlock if it's held, or None if it's not."""
1801 1800 return self._currentlock(self._wlockref)
1802 1801
1803 1802 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
1804 1803 """
1805 1804 commit an individual file as part of a larger transaction
1806 1805 """
1807 1806
1808 1807 fname = fctx.path()
1809 1808 fparent1 = manifest1.get(fname, nullid)
1810 1809 fparent2 = manifest2.get(fname, nullid)
1811 1810 if isinstance(fctx, context.filectx):
1812 1811 node = fctx.filenode()
1813 1812 if node in [fparent1, fparent2]:
1814 1813 self.ui.debug('reusing %s filelog entry\n' % fname)
1815 1814 if manifest1.flags(fname) != fctx.flags():
1816 1815 changelist.append(fname)
1817 1816 return node
1818 1817
1819 1818 flog = self.file(fname)
1820 1819 meta = {}
1821 1820 copy = fctx.renamed()
1822 1821 if copy and copy[0] != fname:
1823 1822 # Mark the new revision of this file as a copy of another
1824 1823 # file. This copy data will effectively act as a parent
1825 1824 # of this new revision. If this is a merge, the first
1826 1825 # parent will be the nullid (meaning "look up the copy data")
1827 1826 # and the second one will be the other parent. For example:
1828 1827 #
1829 1828 # 0 --- 1 --- 3 rev1 changes file foo
1830 1829 # \ / rev2 renames foo to bar and changes it
1831 1830 # \- 2 -/ rev3 should have bar with all changes and
1832 1831 # should record that bar descends from
1833 1832 # bar in rev2 and foo in rev1
1834 1833 #
1835 1834 # this allows this merge to succeed:
1836 1835 #
1837 1836 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
1838 1837 # \ / merging rev3 and rev4 should use bar@rev2
1839 1838 # \- 2 --- 4 as the merge base
1840 1839 #
1841 1840
1842 1841 cfname = copy[0]
1843 1842 crev = manifest1.get(cfname)
1844 1843 newfparent = fparent2
1845 1844
1846 1845 if manifest2: # branch merge
1847 1846 if fparent2 == nullid or crev is None: # copied on remote side
1848 1847 if cfname in manifest2:
1849 1848 crev = manifest2[cfname]
1850 1849 newfparent = fparent1
1851 1850
1852 1851 # Here, we used to search backwards through history to try to find
1853 1852 # where the file copy came from if the source of a copy was not in
1854 1853 # the parent directory. However, this doesn't actually make sense to
1855 1854 # do (what does a copy from something not in your working copy even
1856 1855 # mean?) and it causes bugs (eg, issue4476). Instead, we will warn
1857 1856 # the user that copy information was dropped, so if they didn't
1858 1857 # expect this outcome it can be fixed, but this is the correct
1859 1858 # behavior in this circumstance.
1860 1859
1861 1860 if crev:
1862 1861 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1863 1862 meta["copy"] = cfname
1864 1863 meta["copyrev"] = hex(crev)
1865 1864 fparent1, fparent2 = nullid, newfparent
1866 1865 else:
1867 1866 self.ui.warn(_("warning: can't find ancestor for '%s' "
1868 1867 "copied from '%s'!\n") % (fname, cfname))
1869 1868
1870 1869 elif fparent1 == nullid:
1871 1870 fparent1, fparent2 = fparent2, nullid
1872 1871 elif fparent2 != nullid:
1873 1872 # is one parent an ancestor of the other?
1874 1873 fparentancestors = flog.commonancestorsheads(fparent1, fparent2)
1875 1874 if fparent1 in fparentancestors:
1876 1875 fparent1, fparent2 = fparent2, nullid
1877 1876 elif fparent2 in fparentancestors:
1878 1877 fparent2 = nullid
1879 1878
1880 1879 # is the file changed?
1881 1880 text = fctx.data()
1882 1881 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
1883 1882 changelist.append(fname)
1884 1883 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
1885 1884 # are just the flags changed during merge?
1886 1885 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags():
1887 1886 changelist.append(fname)
1888 1887
1889 1888 return fparent1
1890 1889
1891 1890 def checkcommitpatterns(self, wctx, vdirs, match, status, fail):
1892 1891 """check for commit arguments that aren't committable"""
1893 1892 if match.isexact() or match.prefix():
1894 1893 matched = set(status.modified + status.added + status.removed)
1895 1894
1896 1895 for f in match.files():
1897 1896 f = self.dirstate.normalize(f)
1898 1897 if f == '.' or f in matched or f in wctx.substate:
1899 1898 continue
1900 1899 if f in status.deleted:
1901 1900 fail(f, _('file not found!'))
1902 1901 if f in vdirs: # visited directory
1903 1902 d = f + '/'
1904 1903 for mf in matched:
1905 1904 if mf.startswith(d):
1906 1905 break
1907 1906 else:
1908 1907 fail(f, _("no match under directory!"))
1909 1908 elif f not in self.dirstate:
1910 1909 fail(f, _("file not tracked!"))
1911 1910
1912 1911 @unfilteredmethod
1913 1912 def commit(self, text="", user=None, date=None, match=None, force=False,
1914 1913 editor=False, extra=None):
1915 1914 """Add a new revision to current repository.
1916 1915
1917 1916 Revision information is gathered from the working directory,
1918 1917 match can be used to filter the committed files. If editor is
1919 1918 supplied, it is called to get a commit message.
1920 1919 """
1921 1920 if extra is None:
1922 1921 extra = {}
1923 1922
1924 1923 def fail(f, msg):
1925 1924 raise error.Abort('%s: %s' % (f, msg))
1926 1925
1927 1926 if not match:
1928 1927 match = matchmod.always(self.root, '')
1929 1928
1930 1929 if not force:
1931 1930 vdirs = []
1932 1931 match.explicitdir = vdirs.append
1933 1932 match.bad = fail
1934 1933
1935 1934 wlock = lock = tr = None
1936 1935 try:
1937 1936 wlock = self.wlock()
1938 1937 lock = self.lock() # for recent changelog (see issue4368)
1939 1938
1940 1939 wctx = self[None]
1941 1940 merge = len(wctx.parents()) > 1
1942 1941
1943 1942 if not force and merge and not match.always():
1944 1943 raise error.Abort(_('cannot partially commit a merge '
1945 1944 '(do not specify files or patterns)'))
1946 1945
1947 1946 status = self.status(match=match, clean=force)
1948 1947 if force:
1949 1948 status.modified.extend(status.clean) # mq may commit clean files
1950 1949
1951 1950 # check subrepos
1952 1951 subs, commitsubs, newstate = subrepoutil.precommit(
1953 1952 self.ui, wctx, status, match, force=force)
1954 1953
1955 1954 # make sure all explicit patterns are matched
1956 1955 if not force:
1957 1956 self.checkcommitpatterns(wctx, vdirs, match, status, fail)
1958 1957
1959 1958 cctx = context.workingcommitctx(self, status,
1960 1959 text, user, date, extra)
1961 1960
1962 1961 # internal config: ui.allowemptycommit
1963 1962 allowemptycommit = (wctx.branch() != wctx.p1().branch()
1964 1963 or extra.get('close') or merge or cctx.files()
1965 1964 or self.ui.configbool('ui', 'allowemptycommit'))
1966 1965 if not allowemptycommit:
1967 1966 return None
1968 1967
1969 1968 if merge and cctx.deleted():
1970 1969 raise error.Abort(_("cannot commit merge with missing files"))
1971 1970
1972 1971 ms = mergemod.mergestate.read(self)
1973 1972 mergeutil.checkunresolved(ms)
1974 1973
1975 1974 if editor:
1976 1975 cctx._text = editor(self, cctx, subs)
1977 1976 edited = (text != cctx._text)
1978 1977
1979 1978 # Save commit message in case this transaction gets rolled back
1980 1979 # (e.g. by a pretxncommit hook). Leave the content alone on
1981 1980 # the assumption that the user will use the same editor again.
1982 1981 msgfn = self.savecommitmessage(cctx._text)
1983 1982
1984 1983 # commit subs and write new state
1985 1984 if subs:
1986 1985 for s in sorted(commitsubs):
1987 1986 sub = wctx.sub(s)
1988 1987 self.ui.status(_('committing subrepository %s\n') %
1989 1988 subrepoutil.subrelpath(sub))
1990 1989 sr = sub.commit(cctx._text, user, date)
1991 1990 newstate[s] = (newstate[s][0], sr)
1992 1991 subrepoutil.writestate(self, newstate)
1993 1992
1994 1993 p1, p2 = self.dirstate.parents()
1995 1994 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1996 1995 try:
1997 1996 self.hook("precommit", throw=True, parent1=hookp1,
1998 1997 parent2=hookp2)
1999 1998 tr = self.transaction('commit')
2000 1999 ret = self.commitctx(cctx, True)
2001 2000 except: # re-raises
2002 2001 if edited:
2003 2002 self.ui.write(
2004 2003 _('note: commit message saved in %s\n') % msgfn)
2005 2004 raise
2006 2005 # update bookmarks, dirstate and mergestate
2007 2006 bookmarks.update(self, [p1, p2], ret)
2008 2007 cctx.markcommitted(ret)
2009 2008 ms.reset()
2010 2009 tr.close()
2011 2010
2012 2011 finally:
2013 2012 lockmod.release(tr, lock, wlock)
2014 2013
2015 2014 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
2016 2015 # hack for command that use a temporary commit (eg: histedit)
2017 2016 # temporary commit got stripped before hook release
2018 2017 if self.changelog.hasnode(ret):
2019 2018 self.hook("commit", node=node, parent1=parent1,
2020 2019 parent2=parent2)
2021 2020 self._afterlock(commithook)
2022 2021 return ret
2023 2022
2024 2023 @unfilteredmethod
2025 2024 def commitctx(self, ctx, error=False):
2026 2025 """Add a new revision to current repository.
2027 2026 Revision information is passed via the context argument.
2028 2027 """
2029 2028
2030 2029 tr = None
2031 2030 p1, p2 = ctx.p1(), ctx.p2()
2032 2031 user = ctx.user()
2033 2032
2034 2033 lock = self.lock()
2035 2034 try:
2036 2035 tr = self.transaction("commit")
2037 2036 trp = weakref.proxy(tr)
2038 2037
2039 2038 if ctx.manifestnode():
2040 2039 # reuse an existing manifest revision
2041 2040 mn = ctx.manifestnode()
2042 2041 files = ctx.files()
2043 2042 elif ctx.files():
2044 2043 m1ctx = p1.manifestctx()
2045 2044 m2ctx = p2.manifestctx()
2046 2045 mctx = m1ctx.copy()
2047 2046
2048 2047 m = mctx.read()
2049 2048 m1 = m1ctx.read()
2050 2049 m2 = m2ctx.read()
2051 2050
2052 2051 # check in files
2053 2052 added = []
2054 2053 changed = []
2055 2054 removed = list(ctx.removed())
2056 2055 linkrev = len(self)
2057 2056 self.ui.note(_("committing files:\n"))
2058 2057 for f in sorted(ctx.modified() + ctx.added()):
2059 2058 self.ui.note(f + "\n")
2060 2059 try:
2061 2060 fctx = ctx[f]
2062 2061 if fctx is None:
2063 2062 removed.append(f)
2064 2063 else:
2065 2064 added.append(f)
2066 2065 m[f] = self._filecommit(fctx, m1, m2, linkrev,
2067 2066 trp, changed)
2068 2067 m.setflag(f, fctx.flags())
2069 2068 except OSError as inst:
2070 2069 self.ui.warn(_("trouble committing %s!\n") % f)
2071 2070 raise
2072 2071 except IOError as inst:
2073 2072 errcode = getattr(inst, 'errno', errno.ENOENT)
2074 2073 if error or errcode and errcode != errno.ENOENT:
2075 2074 self.ui.warn(_("trouble committing %s!\n") % f)
2076 2075 raise
2077 2076
2078 2077 # update manifest
2079 2078 self.ui.note(_("committing manifest\n"))
2080 2079 removed = [f for f in sorted(removed) if f in m1 or f in m2]
2081 2080 drop = [f for f in removed if f in m]
2082 2081 for f in drop:
2083 2082 del m[f]
2084 2083 mn = mctx.write(trp, linkrev,
2085 2084 p1.manifestnode(), p2.manifestnode(),
2086 2085 added, drop)
2087 2086 files = changed + removed
2088 2087 else:
2089 2088 mn = p1.manifestnode()
2090 2089 files = []
2091 2090
2092 2091 # update changelog
2093 2092 self.ui.note(_("committing changelog\n"))
2094 2093 self.changelog.delayupdate(tr)
2095 2094 n = self.changelog.add(mn, files, ctx.description(),
2096 2095 trp, p1.node(), p2.node(),
2097 2096 user, ctx.date(), ctx.extra().copy())
2098 2097 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
2099 2098 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
2100 2099 parent2=xp2)
2101 2100 # set the new commit is proper phase
2102 2101 targetphase = subrepoutil.newcommitphase(self.ui, ctx)
2103 2102 if targetphase:
2104 2103 # retract boundary do not alter parent changeset.
2105 2104 # if a parent have higher the resulting phase will
2106 2105 # be compliant anyway
2107 2106 #
2108 2107 # if minimal phase was 0 we don't need to retract anything
2109 2108 phases.registernew(self, tr, targetphase, [n])
2110 2109 tr.close()
2111 2110 return n
2112 2111 finally:
2113 2112 if tr:
2114 2113 tr.release()
2115 2114 lock.release()
2116 2115
2117 2116 @unfilteredmethod
2118 2117 def destroying(self):
2119 2118 '''Inform the repository that nodes are about to be destroyed.
2120 2119 Intended for use by strip and rollback, so there's a common
2121 2120 place for anything that has to be done before destroying history.
2122 2121
2123 2122 This is mostly useful for saving state that is in memory and waiting
2124 2123 to be flushed when the current lock is released. Because a call to
2125 2124 destroyed is imminent, the repo will be invalidated causing those
2126 2125 changes to stay in memory (waiting for the next unlock), or vanish
2127 2126 completely.
2128 2127 '''
2129 2128 # When using the same lock to commit and strip, the phasecache is left
2130 2129 # dirty after committing. Then when we strip, the repo is invalidated,
2131 2130 # causing those changes to disappear.
2132 2131 if '_phasecache' in vars(self):
2133 2132 self._phasecache.write()
2134 2133
2135 2134 @unfilteredmethod
2136 2135 def destroyed(self):
2137 2136 '''Inform the repository that nodes have been destroyed.
2138 2137 Intended for use by strip and rollback, so there's a common
2139 2138 place for anything that has to be done after destroying history.
2140 2139 '''
2141 2140 # When one tries to:
2142 2141 # 1) destroy nodes thus calling this method (e.g. strip)
2143 2142 # 2) use phasecache somewhere (e.g. commit)
2144 2143 #
2145 2144 # then 2) will fail because the phasecache contains nodes that were
2146 2145 # removed. We can either remove phasecache from the filecache,
2147 2146 # causing it to reload next time it is accessed, or simply filter
2148 2147 # the removed nodes now and write the updated cache.
2149 2148 self._phasecache.filterunknown(self)
2150 2149 self._phasecache.write()
2151 2150
2152 2151 # refresh all repository caches
2153 2152 self.updatecaches()
2154 2153
2155 2154 # Ensure the persistent tag cache is updated. Doing it now
2156 2155 # means that the tag cache only has to worry about destroyed
2157 2156 # heads immediately after a strip/rollback. That in turn
2158 2157 # guarantees that "cachetip == currenttip" (comparing both rev
2159 2158 # and node) always means no nodes have been added or destroyed.
2160 2159
2161 2160 # XXX this is suboptimal when qrefresh'ing: we strip the current
2162 2161 # head, refresh the tag cache, then immediately add a new head.
2163 2162 # But I think doing it this way is necessary for the "instant
2164 2163 # tag cache retrieval" case to work.
2165 2164 self.invalidate()
2166 2165
2167 2166 def status(self, node1='.', node2=None, match=None,
2168 2167 ignored=False, clean=False, unknown=False,
2169 2168 listsubrepos=False):
2170 2169 '''a convenience method that calls node1.status(node2)'''
2171 2170 return self[node1].status(node2, match, ignored, clean, unknown,
2172 2171 listsubrepos)
2173 2172
2174 2173 def addpostdsstatus(self, ps):
2175 2174 """Add a callback to run within the wlock, at the point at which status
2176 2175 fixups happen.
2177 2176
2178 2177 On status completion, callback(wctx, status) will be called with the
2179 2178 wlock held, unless the dirstate has changed from underneath or the wlock
2180 2179 couldn't be grabbed.
2181 2180
2182 2181 Callbacks should not capture and use a cached copy of the dirstate --
2183 2182 it might change in the meanwhile. Instead, they should access the
2184 2183 dirstate via wctx.repo().dirstate.
2185 2184
2186 2185 This list is emptied out after each status run -- extensions should
2187 2186 make sure it adds to this list each time dirstate.status is called.
2188 2187 Extensions should also make sure they don't call this for statuses
2189 2188 that don't involve the dirstate.
2190 2189 """
2191 2190
2192 2191 # The list is located here for uniqueness reasons -- it is actually
2193 2192 # managed by the workingctx, but that isn't unique per-repo.
2194 2193 self._postdsstatus.append(ps)
2195 2194
2196 2195 def postdsstatus(self):
2197 2196 """Used by workingctx to get the list of post-dirstate-status hooks."""
2198 2197 return self._postdsstatus
2199 2198
2200 2199 def clearpostdsstatus(self):
2201 2200 """Used by workingctx to clear post-dirstate-status hooks."""
2202 2201 del self._postdsstatus[:]
2203 2202
2204 2203 def heads(self, start=None):
2205 2204 if start is None:
2206 2205 cl = self.changelog
2207 2206 headrevs = reversed(cl.headrevs())
2208 2207 return [cl.node(rev) for rev in headrevs]
2209 2208
2210 2209 heads = self.changelog.heads(start)
2211 2210 # sort the output in rev descending order
2212 2211 return sorted(heads, key=self.changelog.rev, reverse=True)
2213 2212
2214 2213 def branchheads(self, branch=None, start=None, closed=False):
2215 2214 '''return a (possibly filtered) list of heads for the given branch
2216 2215
2217 2216 Heads are returned in topological order, from newest to oldest.
2218 2217 If branch is None, use the dirstate branch.
2219 2218 If start is not None, return only heads reachable from start.
2220 2219 If closed is True, return heads that are marked as closed as well.
2221 2220 '''
2222 2221 if branch is None:
2223 2222 branch = self[None].branch()
2224 2223 branches = self.branchmap()
2225 2224 if branch not in branches:
2226 2225 return []
2227 2226 # the cache returns heads ordered lowest to highest
2228 2227 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
2229 2228 if start is not None:
2230 2229 # filter out the heads that cannot be reached from startrev
2231 2230 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
2232 2231 bheads = [h for h in bheads if h in fbheads]
2233 2232 return bheads
2234 2233
2235 2234 def branches(self, nodes):
2236 2235 if not nodes:
2237 2236 nodes = [self.changelog.tip()]
2238 2237 b = []
2239 2238 for n in nodes:
2240 2239 t = n
2241 2240 while True:
2242 2241 p = self.changelog.parents(n)
2243 2242 if p[1] != nullid or p[0] == nullid:
2244 2243 b.append((t, n, p[0], p[1]))
2245 2244 break
2246 2245 n = p[0]
2247 2246 return b
2248 2247
2249 2248 def between(self, pairs):
2250 2249 r = []
2251 2250
2252 2251 for top, bottom in pairs:
2253 2252 n, l, i = top, [], 0
2254 2253 f = 1
2255 2254
2256 2255 while n != bottom and n != nullid:
2257 2256 p = self.changelog.parents(n)[0]
2258 2257 if i == f:
2259 2258 l.append(n)
2260 2259 f = f * 2
2261 2260 n = p
2262 2261 i += 1
2263 2262
2264 2263 r.append(l)
2265 2264
2266 2265 return r
2267 2266
2268 2267 def checkpush(self, pushop):
2269 2268 """Extensions can override this function if additional checks have
2270 2269 to be performed before pushing, or call it if they override push
2271 2270 command.
2272 2271 """
2273 2272
2274 2273 @unfilteredpropertycache
2275 2274 def prepushoutgoinghooks(self):
2276 2275 """Return util.hooks consists of a pushop with repo, remote, outgoing
2277 2276 methods, which are called before pushing changesets.
2278 2277 """
2279 2278 return util.hooks()
2280 2279
2281 2280 def pushkey(self, namespace, key, old, new):
2282 2281 try:
2283 2282 tr = self.currenttransaction()
2284 2283 hookargs = {}
2285 2284 if tr is not None:
2286 2285 hookargs.update(tr.hookargs)
2287 2286 hookargs = pycompat.strkwargs(hookargs)
2288 2287 hookargs[r'namespace'] = namespace
2289 2288 hookargs[r'key'] = key
2290 2289 hookargs[r'old'] = old
2291 2290 hookargs[r'new'] = new
2292 2291 self.hook('prepushkey', throw=True, **hookargs)
2293 2292 except error.HookAbort as exc:
2294 2293 self.ui.write_err(_("pushkey-abort: %s\n") % exc)
2295 2294 if exc.hint:
2296 2295 self.ui.write_err(_("(%s)\n") % exc.hint)
2297 2296 return False
2298 2297 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
2299 2298 ret = pushkey.push(self, namespace, key, old, new)
2300 2299 def runhook():
2301 2300 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
2302 2301 ret=ret)
2303 2302 self._afterlock(runhook)
2304 2303 return ret
2305 2304
2306 2305 def listkeys(self, namespace):
2307 2306 self.hook('prelistkeys', throw=True, namespace=namespace)
2308 2307 self.ui.debug('listing keys for "%s"\n' % namespace)
2309 2308 values = pushkey.list(self, namespace)
2310 2309 self.hook('listkeys', namespace=namespace, values=values)
2311 2310 return values
2312 2311
2313 2312 def debugwireargs(self, one, two, three=None, four=None, five=None):
2314 2313 '''used to test argument passing over the wire'''
2315 2314 return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three),
2316 2315 pycompat.bytestr(four),
2317 2316 pycompat.bytestr(five))
2318 2317
2319 2318 def savecommitmessage(self, text):
2320 2319 fp = self.vfs('last-message.txt', 'wb')
2321 2320 try:
2322 2321 fp.write(text)
2323 2322 finally:
2324 2323 fp.close()
2325 2324 return self.pathto(fp.name[len(self.root) + 1:])
2326 2325
2327 2326 # used to avoid circular references so destructors work
2328 2327 def aftertrans(files):
2329 2328 renamefiles = [tuple(t) for t in files]
2330 2329 def a():
2331 2330 for vfs, src, dest in renamefiles:
2332 2331 # if src and dest refer to a same file, vfs.rename is a no-op,
2333 2332 # leaving both src and dest on disk. delete dest to make sure
2334 2333 # the rename couldn't be such a no-op.
2335 2334 vfs.tryunlink(dest)
2336 2335 try:
2337 2336 vfs.rename(src, dest)
2338 2337 except OSError: # journal file does not yet exist
2339 2338 pass
2340 2339 return a
2341 2340
2342 2341 def undoname(fn):
2343 2342 base, name = os.path.split(fn)
2344 2343 assert name.startswith('journal')
2345 2344 return os.path.join(base, name.replace('journal', 'undo', 1))
2346 2345
2347 2346 def instance(ui, path, create, intents=None):
2348 2347 return localrepository(ui, util.urllocalpath(path), create,
2349 2348 intents=intents)
2350 2349
2351 2350 def islocal(path):
2352 2351 return True
2353 2352
2354 2353 def newreporequirements(repo):
2355 2354 """Determine the set of requirements for a new local repository.
2356 2355
2357 2356 Extensions can wrap this function to specify custom requirements for
2358 2357 new repositories.
2359 2358 """
2360 2359 ui = repo.ui
2361 2360 requirements = {'revlogv1'}
2362 2361 if ui.configbool('format', 'usestore'):
2363 2362 requirements.add('store')
2364 2363 if ui.configbool('format', 'usefncache'):
2365 2364 requirements.add('fncache')
2366 2365 if ui.configbool('format', 'dotencode'):
2367 2366 requirements.add('dotencode')
2368 2367
2369 2368 compengine = ui.config('experimental', 'format.compression')
2370 2369 if compengine not in util.compengines:
2371 2370 raise error.Abort(_('compression engine %s defined by '
2372 2371 'experimental.format.compression not available') %
2373 2372 compengine,
2374 2373 hint=_('run "hg debuginstall" to list available '
2375 2374 'compression engines'))
2376 2375
2377 2376 # zlib is the historical default and doesn't need an explicit requirement.
2378 2377 if compengine != 'zlib':
2379 2378 requirements.add('exp-compression-%s' % compengine)
2380 2379
2381 2380 if scmutil.gdinitconfig(ui):
2382 2381 requirements.add('generaldelta')
2383 2382 if ui.configbool('experimental', 'treemanifest'):
2384 2383 requirements.add('treemanifest')
2385 2384 # experimental config: format.sparse-revlog
2386 2385 if ui.configbool('format', 'sparse-revlog'):
2387 2386 requirements.add(SPARSEREVLOG_REQUIREMENT)
2388 2387
2389 2388 revlogv2 = ui.config('experimental', 'revlogv2')
2390 2389 if revlogv2 == 'enable-unstable-format-and-corrupt-my-data':
2391 2390 requirements.remove('revlogv1')
2392 2391 # generaldelta is implied by revlogv2.
2393 2392 requirements.discard('generaldelta')
2394 2393 requirements.add(REVLOGV2_REQUIREMENT)
2395 2394
2396 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 Test format.aggressivemergedeltas
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 format.aggressivemergedeltas=True
149 $ hg commit -q -m merge --config 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