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