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