##// END OF EJS Templates
issue6528: add a config option to control the fixing on the fly...
marmoute -
r48630:2813d406 5.9rc1 stable
parent child Browse files
Show More
@@ -1,2719 +1,2724 b''
1 # configitems.py - centralized declaration of configuration option
1 # configitems.py - centralized declaration of configuration option
2 #
2 #
3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import functools
10 import functools
11 import re
11 import re
12
12
13 from . import (
13 from . import (
14 encoding,
14 encoding,
15 error,
15 error,
16 )
16 )
17
17
18
18
19 def loadconfigtable(ui, extname, configtable):
19 def loadconfigtable(ui, extname, configtable):
20 """update config item known to the ui with the extension ones"""
20 """update config item known to the ui with the extension ones"""
21 for section, items in sorted(configtable.items()):
21 for section, items in sorted(configtable.items()):
22 knownitems = ui._knownconfig.setdefault(section, itemregister())
22 knownitems = ui._knownconfig.setdefault(section, itemregister())
23 knownkeys = set(knownitems)
23 knownkeys = set(knownitems)
24 newkeys = set(items)
24 newkeys = set(items)
25 for key in sorted(knownkeys & newkeys):
25 for key in sorted(knownkeys & newkeys):
26 msg = b"extension '%s' overwrite config item '%s.%s'"
26 msg = b"extension '%s' overwrite config item '%s.%s'"
27 msg %= (extname, section, key)
27 msg %= (extname, section, key)
28 ui.develwarn(msg, config=b'warn-config')
28 ui.develwarn(msg, config=b'warn-config')
29
29
30 knownitems.update(items)
30 knownitems.update(items)
31
31
32
32
33 class configitem(object):
33 class configitem(object):
34 """represent a known config item
34 """represent a known config item
35
35
36 :section: the official config section where to find this item,
36 :section: the official config section where to find this item,
37 :name: the official name within the section,
37 :name: the official name within the section,
38 :default: default value for this item,
38 :default: default value for this item,
39 :alias: optional list of tuples as alternatives,
39 :alias: optional list of tuples as alternatives,
40 :generic: this is a generic definition, match name using regular expression.
40 :generic: this is a generic definition, match name using regular expression.
41 """
41 """
42
42
43 def __init__(
43 def __init__(
44 self,
44 self,
45 section,
45 section,
46 name,
46 name,
47 default=None,
47 default=None,
48 alias=(),
48 alias=(),
49 generic=False,
49 generic=False,
50 priority=0,
50 priority=0,
51 experimental=False,
51 experimental=False,
52 ):
52 ):
53 self.section = section
53 self.section = section
54 self.name = name
54 self.name = name
55 self.default = default
55 self.default = default
56 self.alias = list(alias)
56 self.alias = list(alias)
57 self.generic = generic
57 self.generic = generic
58 self.priority = priority
58 self.priority = priority
59 self.experimental = experimental
59 self.experimental = experimental
60 self._re = None
60 self._re = None
61 if generic:
61 if generic:
62 self._re = re.compile(self.name)
62 self._re = re.compile(self.name)
63
63
64
64
65 class itemregister(dict):
65 class itemregister(dict):
66 """A specialized dictionary that can handle wild-card selection"""
66 """A specialized dictionary that can handle wild-card selection"""
67
67
68 def __init__(self):
68 def __init__(self):
69 super(itemregister, self).__init__()
69 super(itemregister, self).__init__()
70 self._generics = set()
70 self._generics = set()
71
71
72 def update(self, other):
72 def update(self, other):
73 super(itemregister, self).update(other)
73 super(itemregister, self).update(other)
74 self._generics.update(other._generics)
74 self._generics.update(other._generics)
75
75
76 def __setitem__(self, key, item):
76 def __setitem__(self, key, item):
77 super(itemregister, self).__setitem__(key, item)
77 super(itemregister, self).__setitem__(key, item)
78 if item.generic:
78 if item.generic:
79 self._generics.add(item)
79 self._generics.add(item)
80
80
81 def get(self, key):
81 def get(self, key):
82 baseitem = super(itemregister, self).get(key)
82 baseitem = super(itemregister, self).get(key)
83 if baseitem is not None and not baseitem.generic:
83 if baseitem is not None and not baseitem.generic:
84 return baseitem
84 return baseitem
85
85
86 # search for a matching generic item
86 # search for a matching generic item
87 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
87 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
88 for item in generics:
88 for item in generics:
89 # we use 'match' instead of 'search' to make the matching simpler
89 # we use 'match' instead of 'search' to make the matching simpler
90 # for people unfamiliar with regular expression. Having the match
90 # for people unfamiliar with regular expression. Having the match
91 # rooted to the start of the string will produce less surprising
91 # rooted to the start of the string will produce less surprising
92 # result for user writing simple regex for sub-attribute.
92 # result for user writing simple regex for sub-attribute.
93 #
93 #
94 # For example using "color\..*" match produces an unsurprising
94 # For example using "color\..*" match produces an unsurprising
95 # result, while using search could suddenly match apparently
95 # result, while using search could suddenly match apparently
96 # unrelated configuration that happens to contains "color."
96 # unrelated configuration that happens to contains "color."
97 # anywhere. This is a tradeoff where we favor requiring ".*" on
97 # anywhere. This is a tradeoff where we favor requiring ".*" on
98 # some match to avoid the need to prefix most pattern with "^".
98 # some match to avoid the need to prefix most pattern with "^".
99 # The "^" seems more error prone.
99 # The "^" seems more error prone.
100 if item._re.match(key):
100 if item._re.match(key):
101 return item
101 return item
102
102
103 return None
103 return None
104
104
105
105
106 coreitems = {}
106 coreitems = {}
107
107
108
108
109 def _register(configtable, *args, **kwargs):
109 def _register(configtable, *args, **kwargs):
110 item = configitem(*args, **kwargs)
110 item = configitem(*args, **kwargs)
111 section = configtable.setdefault(item.section, itemregister())
111 section = configtable.setdefault(item.section, itemregister())
112 if item.name in section:
112 if item.name in section:
113 msg = b"duplicated config item registration for '%s.%s'"
113 msg = b"duplicated config item registration for '%s.%s'"
114 raise error.ProgrammingError(msg % (item.section, item.name))
114 raise error.ProgrammingError(msg % (item.section, item.name))
115 section[item.name] = item
115 section[item.name] = item
116
116
117
117
118 # special value for case where the default is derived from other values
118 # special value for case where the default is derived from other values
119 dynamicdefault = object()
119 dynamicdefault = object()
120
120
121 # Registering actual config items
121 # Registering actual config items
122
122
123
123
124 def getitemregister(configtable):
124 def getitemregister(configtable):
125 f = functools.partial(_register, configtable)
125 f = functools.partial(_register, configtable)
126 # export pseudo enum as configitem.*
126 # export pseudo enum as configitem.*
127 f.dynamicdefault = dynamicdefault
127 f.dynamicdefault = dynamicdefault
128 return f
128 return f
129
129
130
130
131 coreconfigitem = getitemregister(coreitems)
131 coreconfigitem = getitemregister(coreitems)
132
132
133
133
134 def _registerdiffopts(section, configprefix=b''):
134 def _registerdiffopts(section, configprefix=b''):
135 coreconfigitem(
135 coreconfigitem(
136 section,
136 section,
137 configprefix + b'nodates',
137 configprefix + b'nodates',
138 default=False,
138 default=False,
139 )
139 )
140 coreconfigitem(
140 coreconfigitem(
141 section,
141 section,
142 configprefix + b'showfunc',
142 configprefix + b'showfunc',
143 default=False,
143 default=False,
144 )
144 )
145 coreconfigitem(
145 coreconfigitem(
146 section,
146 section,
147 configprefix + b'unified',
147 configprefix + b'unified',
148 default=None,
148 default=None,
149 )
149 )
150 coreconfigitem(
150 coreconfigitem(
151 section,
151 section,
152 configprefix + b'git',
152 configprefix + b'git',
153 default=False,
153 default=False,
154 )
154 )
155 coreconfigitem(
155 coreconfigitem(
156 section,
156 section,
157 configprefix + b'ignorews',
157 configprefix + b'ignorews',
158 default=False,
158 default=False,
159 )
159 )
160 coreconfigitem(
160 coreconfigitem(
161 section,
161 section,
162 configprefix + b'ignorewsamount',
162 configprefix + b'ignorewsamount',
163 default=False,
163 default=False,
164 )
164 )
165 coreconfigitem(
165 coreconfigitem(
166 section,
166 section,
167 configprefix + b'ignoreblanklines',
167 configprefix + b'ignoreblanklines',
168 default=False,
168 default=False,
169 )
169 )
170 coreconfigitem(
170 coreconfigitem(
171 section,
171 section,
172 configprefix + b'ignorewseol',
172 configprefix + b'ignorewseol',
173 default=False,
173 default=False,
174 )
174 )
175 coreconfigitem(
175 coreconfigitem(
176 section,
176 section,
177 configprefix + b'nobinary',
177 configprefix + b'nobinary',
178 default=False,
178 default=False,
179 )
179 )
180 coreconfigitem(
180 coreconfigitem(
181 section,
181 section,
182 configprefix + b'noprefix',
182 configprefix + b'noprefix',
183 default=False,
183 default=False,
184 )
184 )
185 coreconfigitem(
185 coreconfigitem(
186 section,
186 section,
187 configprefix + b'word-diff',
187 configprefix + b'word-diff',
188 default=False,
188 default=False,
189 )
189 )
190
190
191
191
192 coreconfigitem(
192 coreconfigitem(
193 b'alias',
193 b'alias',
194 b'.*',
194 b'.*',
195 default=dynamicdefault,
195 default=dynamicdefault,
196 generic=True,
196 generic=True,
197 )
197 )
198 coreconfigitem(
198 coreconfigitem(
199 b'auth',
199 b'auth',
200 b'cookiefile',
200 b'cookiefile',
201 default=None,
201 default=None,
202 )
202 )
203 _registerdiffopts(section=b'annotate')
203 _registerdiffopts(section=b'annotate')
204 # bookmarks.pushing: internal hack for discovery
204 # bookmarks.pushing: internal hack for discovery
205 coreconfigitem(
205 coreconfigitem(
206 b'bookmarks',
206 b'bookmarks',
207 b'pushing',
207 b'pushing',
208 default=list,
208 default=list,
209 )
209 )
210 # bundle.mainreporoot: internal hack for bundlerepo
210 # bundle.mainreporoot: internal hack for bundlerepo
211 coreconfigitem(
211 coreconfigitem(
212 b'bundle',
212 b'bundle',
213 b'mainreporoot',
213 b'mainreporoot',
214 default=b'',
214 default=b'',
215 )
215 )
216 coreconfigitem(
216 coreconfigitem(
217 b'censor',
217 b'censor',
218 b'policy',
218 b'policy',
219 default=b'abort',
219 default=b'abort',
220 experimental=True,
220 experimental=True,
221 )
221 )
222 coreconfigitem(
222 coreconfigitem(
223 b'chgserver',
223 b'chgserver',
224 b'idletimeout',
224 b'idletimeout',
225 default=3600,
225 default=3600,
226 )
226 )
227 coreconfigitem(
227 coreconfigitem(
228 b'chgserver',
228 b'chgserver',
229 b'skiphash',
229 b'skiphash',
230 default=False,
230 default=False,
231 )
231 )
232 coreconfigitem(
232 coreconfigitem(
233 b'cmdserver',
233 b'cmdserver',
234 b'log',
234 b'log',
235 default=None,
235 default=None,
236 )
236 )
237 coreconfigitem(
237 coreconfigitem(
238 b'cmdserver',
238 b'cmdserver',
239 b'max-log-files',
239 b'max-log-files',
240 default=7,
240 default=7,
241 )
241 )
242 coreconfigitem(
242 coreconfigitem(
243 b'cmdserver',
243 b'cmdserver',
244 b'max-log-size',
244 b'max-log-size',
245 default=b'1 MB',
245 default=b'1 MB',
246 )
246 )
247 coreconfigitem(
247 coreconfigitem(
248 b'cmdserver',
248 b'cmdserver',
249 b'max-repo-cache',
249 b'max-repo-cache',
250 default=0,
250 default=0,
251 experimental=True,
251 experimental=True,
252 )
252 )
253 coreconfigitem(
253 coreconfigitem(
254 b'cmdserver',
254 b'cmdserver',
255 b'message-encodings',
255 b'message-encodings',
256 default=list,
256 default=list,
257 )
257 )
258 coreconfigitem(
258 coreconfigitem(
259 b'cmdserver',
259 b'cmdserver',
260 b'track-log',
260 b'track-log',
261 default=lambda: [b'chgserver', b'cmdserver', b'repocache'],
261 default=lambda: [b'chgserver', b'cmdserver', b'repocache'],
262 )
262 )
263 coreconfigitem(
263 coreconfigitem(
264 b'cmdserver',
264 b'cmdserver',
265 b'shutdown-on-interrupt',
265 b'shutdown-on-interrupt',
266 default=True,
266 default=True,
267 )
267 )
268 coreconfigitem(
268 coreconfigitem(
269 b'color',
269 b'color',
270 b'.*',
270 b'.*',
271 default=None,
271 default=None,
272 generic=True,
272 generic=True,
273 )
273 )
274 coreconfigitem(
274 coreconfigitem(
275 b'color',
275 b'color',
276 b'mode',
276 b'mode',
277 default=b'auto',
277 default=b'auto',
278 )
278 )
279 coreconfigitem(
279 coreconfigitem(
280 b'color',
280 b'color',
281 b'pagermode',
281 b'pagermode',
282 default=dynamicdefault,
282 default=dynamicdefault,
283 )
283 )
284 coreconfigitem(
284 coreconfigitem(
285 b'command-templates',
285 b'command-templates',
286 b'graphnode',
286 b'graphnode',
287 default=None,
287 default=None,
288 alias=[(b'ui', b'graphnodetemplate')],
288 alias=[(b'ui', b'graphnodetemplate')],
289 )
289 )
290 coreconfigitem(
290 coreconfigitem(
291 b'command-templates',
291 b'command-templates',
292 b'log',
292 b'log',
293 default=None,
293 default=None,
294 alias=[(b'ui', b'logtemplate')],
294 alias=[(b'ui', b'logtemplate')],
295 )
295 )
296 coreconfigitem(
296 coreconfigitem(
297 b'command-templates',
297 b'command-templates',
298 b'mergemarker',
298 b'mergemarker',
299 default=(
299 default=(
300 b'{node|short} '
300 b'{node|short} '
301 b'{ifeq(tags, "tip", "", '
301 b'{ifeq(tags, "tip", "", '
302 b'ifeq(tags, "", "", "{tags} "))}'
302 b'ifeq(tags, "", "", "{tags} "))}'
303 b'{if(bookmarks, "{bookmarks} ")}'
303 b'{if(bookmarks, "{bookmarks} ")}'
304 b'{ifeq(branch, "default", "", "{branch} ")}'
304 b'{ifeq(branch, "default", "", "{branch} ")}'
305 b'- {author|user}: {desc|firstline}'
305 b'- {author|user}: {desc|firstline}'
306 ),
306 ),
307 alias=[(b'ui', b'mergemarkertemplate')],
307 alias=[(b'ui', b'mergemarkertemplate')],
308 )
308 )
309 coreconfigitem(
309 coreconfigitem(
310 b'command-templates',
310 b'command-templates',
311 b'pre-merge-tool-output',
311 b'pre-merge-tool-output',
312 default=None,
312 default=None,
313 alias=[(b'ui', b'pre-merge-tool-output-template')],
313 alias=[(b'ui', b'pre-merge-tool-output-template')],
314 )
314 )
315 coreconfigitem(
315 coreconfigitem(
316 b'command-templates',
316 b'command-templates',
317 b'oneline-summary',
317 b'oneline-summary',
318 default=None,
318 default=None,
319 )
319 )
320 coreconfigitem(
320 coreconfigitem(
321 b'command-templates',
321 b'command-templates',
322 b'oneline-summary.*',
322 b'oneline-summary.*',
323 default=dynamicdefault,
323 default=dynamicdefault,
324 generic=True,
324 generic=True,
325 )
325 )
326 _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.')
326 _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.')
327 coreconfigitem(
327 coreconfigitem(
328 b'commands',
328 b'commands',
329 b'commit.post-status',
329 b'commit.post-status',
330 default=False,
330 default=False,
331 )
331 )
332 coreconfigitem(
332 coreconfigitem(
333 b'commands',
333 b'commands',
334 b'grep.all-files',
334 b'grep.all-files',
335 default=False,
335 default=False,
336 experimental=True,
336 experimental=True,
337 )
337 )
338 coreconfigitem(
338 coreconfigitem(
339 b'commands',
339 b'commands',
340 b'merge.require-rev',
340 b'merge.require-rev',
341 default=False,
341 default=False,
342 )
342 )
343 coreconfigitem(
343 coreconfigitem(
344 b'commands',
344 b'commands',
345 b'push.require-revs',
345 b'push.require-revs',
346 default=False,
346 default=False,
347 )
347 )
348 coreconfigitem(
348 coreconfigitem(
349 b'commands',
349 b'commands',
350 b'resolve.confirm',
350 b'resolve.confirm',
351 default=False,
351 default=False,
352 )
352 )
353 coreconfigitem(
353 coreconfigitem(
354 b'commands',
354 b'commands',
355 b'resolve.explicit-re-merge',
355 b'resolve.explicit-re-merge',
356 default=False,
356 default=False,
357 )
357 )
358 coreconfigitem(
358 coreconfigitem(
359 b'commands',
359 b'commands',
360 b'resolve.mark-check',
360 b'resolve.mark-check',
361 default=b'none',
361 default=b'none',
362 )
362 )
363 _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.')
363 _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.')
364 coreconfigitem(
364 coreconfigitem(
365 b'commands',
365 b'commands',
366 b'show.aliasprefix',
366 b'show.aliasprefix',
367 default=list,
367 default=list,
368 )
368 )
369 coreconfigitem(
369 coreconfigitem(
370 b'commands',
370 b'commands',
371 b'status.relative',
371 b'status.relative',
372 default=False,
372 default=False,
373 )
373 )
374 coreconfigitem(
374 coreconfigitem(
375 b'commands',
375 b'commands',
376 b'status.skipstates',
376 b'status.skipstates',
377 default=[],
377 default=[],
378 experimental=True,
378 experimental=True,
379 )
379 )
380 coreconfigitem(
380 coreconfigitem(
381 b'commands',
381 b'commands',
382 b'status.terse',
382 b'status.terse',
383 default=b'',
383 default=b'',
384 )
384 )
385 coreconfigitem(
385 coreconfigitem(
386 b'commands',
386 b'commands',
387 b'status.verbose',
387 b'status.verbose',
388 default=False,
388 default=False,
389 )
389 )
390 coreconfigitem(
390 coreconfigitem(
391 b'commands',
391 b'commands',
392 b'update.check',
392 b'update.check',
393 default=None,
393 default=None,
394 )
394 )
395 coreconfigitem(
395 coreconfigitem(
396 b'commands',
396 b'commands',
397 b'update.requiredest',
397 b'update.requiredest',
398 default=False,
398 default=False,
399 )
399 )
400 coreconfigitem(
400 coreconfigitem(
401 b'committemplate',
401 b'committemplate',
402 b'.*',
402 b'.*',
403 default=None,
403 default=None,
404 generic=True,
404 generic=True,
405 )
405 )
406 coreconfigitem(
406 coreconfigitem(
407 b'convert',
407 b'convert',
408 b'bzr.saverev',
408 b'bzr.saverev',
409 default=True,
409 default=True,
410 )
410 )
411 coreconfigitem(
411 coreconfigitem(
412 b'convert',
412 b'convert',
413 b'cvsps.cache',
413 b'cvsps.cache',
414 default=True,
414 default=True,
415 )
415 )
416 coreconfigitem(
416 coreconfigitem(
417 b'convert',
417 b'convert',
418 b'cvsps.fuzz',
418 b'cvsps.fuzz',
419 default=60,
419 default=60,
420 )
420 )
421 coreconfigitem(
421 coreconfigitem(
422 b'convert',
422 b'convert',
423 b'cvsps.logencoding',
423 b'cvsps.logencoding',
424 default=None,
424 default=None,
425 )
425 )
426 coreconfigitem(
426 coreconfigitem(
427 b'convert',
427 b'convert',
428 b'cvsps.mergefrom',
428 b'cvsps.mergefrom',
429 default=None,
429 default=None,
430 )
430 )
431 coreconfigitem(
431 coreconfigitem(
432 b'convert',
432 b'convert',
433 b'cvsps.mergeto',
433 b'cvsps.mergeto',
434 default=None,
434 default=None,
435 )
435 )
436 coreconfigitem(
436 coreconfigitem(
437 b'convert',
437 b'convert',
438 b'git.committeractions',
438 b'git.committeractions',
439 default=lambda: [b'messagedifferent'],
439 default=lambda: [b'messagedifferent'],
440 )
440 )
441 coreconfigitem(
441 coreconfigitem(
442 b'convert',
442 b'convert',
443 b'git.extrakeys',
443 b'git.extrakeys',
444 default=list,
444 default=list,
445 )
445 )
446 coreconfigitem(
446 coreconfigitem(
447 b'convert',
447 b'convert',
448 b'git.findcopiesharder',
448 b'git.findcopiesharder',
449 default=False,
449 default=False,
450 )
450 )
451 coreconfigitem(
451 coreconfigitem(
452 b'convert',
452 b'convert',
453 b'git.remoteprefix',
453 b'git.remoteprefix',
454 default=b'remote',
454 default=b'remote',
455 )
455 )
456 coreconfigitem(
456 coreconfigitem(
457 b'convert',
457 b'convert',
458 b'git.renamelimit',
458 b'git.renamelimit',
459 default=400,
459 default=400,
460 )
460 )
461 coreconfigitem(
461 coreconfigitem(
462 b'convert',
462 b'convert',
463 b'git.saverev',
463 b'git.saverev',
464 default=True,
464 default=True,
465 )
465 )
466 coreconfigitem(
466 coreconfigitem(
467 b'convert',
467 b'convert',
468 b'git.similarity',
468 b'git.similarity',
469 default=50,
469 default=50,
470 )
470 )
471 coreconfigitem(
471 coreconfigitem(
472 b'convert',
472 b'convert',
473 b'git.skipsubmodules',
473 b'git.skipsubmodules',
474 default=False,
474 default=False,
475 )
475 )
476 coreconfigitem(
476 coreconfigitem(
477 b'convert',
477 b'convert',
478 b'hg.clonebranches',
478 b'hg.clonebranches',
479 default=False,
479 default=False,
480 )
480 )
481 coreconfigitem(
481 coreconfigitem(
482 b'convert',
482 b'convert',
483 b'hg.ignoreerrors',
483 b'hg.ignoreerrors',
484 default=False,
484 default=False,
485 )
485 )
486 coreconfigitem(
486 coreconfigitem(
487 b'convert',
487 b'convert',
488 b'hg.preserve-hash',
488 b'hg.preserve-hash',
489 default=False,
489 default=False,
490 )
490 )
491 coreconfigitem(
491 coreconfigitem(
492 b'convert',
492 b'convert',
493 b'hg.revs',
493 b'hg.revs',
494 default=None,
494 default=None,
495 )
495 )
496 coreconfigitem(
496 coreconfigitem(
497 b'convert',
497 b'convert',
498 b'hg.saverev',
498 b'hg.saverev',
499 default=False,
499 default=False,
500 )
500 )
501 coreconfigitem(
501 coreconfigitem(
502 b'convert',
502 b'convert',
503 b'hg.sourcename',
503 b'hg.sourcename',
504 default=None,
504 default=None,
505 )
505 )
506 coreconfigitem(
506 coreconfigitem(
507 b'convert',
507 b'convert',
508 b'hg.startrev',
508 b'hg.startrev',
509 default=None,
509 default=None,
510 )
510 )
511 coreconfigitem(
511 coreconfigitem(
512 b'convert',
512 b'convert',
513 b'hg.tagsbranch',
513 b'hg.tagsbranch',
514 default=b'default',
514 default=b'default',
515 )
515 )
516 coreconfigitem(
516 coreconfigitem(
517 b'convert',
517 b'convert',
518 b'hg.usebranchnames',
518 b'hg.usebranchnames',
519 default=True,
519 default=True,
520 )
520 )
521 coreconfigitem(
521 coreconfigitem(
522 b'convert',
522 b'convert',
523 b'ignoreancestorcheck',
523 b'ignoreancestorcheck',
524 default=False,
524 default=False,
525 experimental=True,
525 experimental=True,
526 )
526 )
527 coreconfigitem(
527 coreconfigitem(
528 b'convert',
528 b'convert',
529 b'localtimezone',
529 b'localtimezone',
530 default=False,
530 default=False,
531 )
531 )
532 coreconfigitem(
532 coreconfigitem(
533 b'convert',
533 b'convert',
534 b'p4.encoding',
534 b'p4.encoding',
535 default=dynamicdefault,
535 default=dynamicdefault,
536 )
536 )
537 coreconfigitem(
537 coreconfigitem(
538 b'convert',
538 b'convert',
539 b'p4.startrev',
539 b'p4.startrev',
540 default=0,
540 default=0,
541 )
541 )
542 coreconfigitem(
542 coreconfigitem(
543 b'convert',
543 b'convert',
544 b'skiptags',
544 b'skiptags',
545 default=False,
545 default=False,
546 )
546 )
547 coreconfigitem(
547 coreconfigitem(
548 b'convert',
548 b'convert',
549 b'svn.debugsvnlog',
549 b'svn.debugsvnlog',
550 default=True,
550 default=True,
551 )
551 )
552 coreconfigitem(
552 coreconfigitem(
553 b'convert',
553 b'convert',
554 b'svn.trunk',
554 b'svn.trunk',
555 default=None,
555 default=None,
556 )
556 )
557 coreconfigitem(
557 coreconfigitem(
558 b'convert',
558 b'convert',
559 b'svn.tags',
559 b'svn.tags',
560 default=None,
560 default=None,
561 )
561 )
562 coreconfigitem(
562 coreconfigitem(
563 b'convert',
563 b'convert',
564 b'svn.branches',
564 b'svn.branches',
565 default=None,
565 default=None,
566 )
566 )
567 coreconfigitem(
567 coreconfigitem(
568 b'convert',
568 b'convert',
569 b'svn.startrev',
569 b'svn.startrev',
570 default=0,
570 default=0,
571 )
571 )
572 coreconfigitem(
572 coreconfigitem(
573 b'convert',
573 b'convert',
574 b'svn.dangerous-set-commit-dates',
574 b'svn.dangerous-set-commit-dates',
575 default=False,
575 default=False,
576 )
576 )
577 coreconfigitem(
577 coreconfigitem(
578 b'debug',
578 b'debug',
579 b'dirstate.delaywrite',
579 b'dirstate.delaywrite',
580 default=0,
580 default=0,
581 )
581 )
582 coreconfigitem(
582 coreconfigitem(
583 b'debug',
583 b'debug',
584 b'revlog.verifyposition.changelog',
584 b'revlog.verifyposition.changelog',
585 default=b'',
585 default=b'',
586 )
586 )
587 coreconfigitem(
587 coreconfigitem(
588 b'defaults',
588 b'defaults',
589 b'.*',
589 b'.*',
590 default=None,
590 default=None,
591 generic=True,
591 generic=True,
592 )
592 )
593 coreconfigitem(
593 coreconfigitem(
594 b'devel',
594 b'devel',
595 b'all-warnings',
595 b'all-warnings',
596 default=False,
596 default=False,
597 )
597 )
598 coreconfigitem(
598 coreconfigitem(
599 b'devel',
599 b'devel',
600 b'bundle2.debug',
600 b'bundle2.debug',
601 default=False,
601 default=False,
602 )
602 )
603 coreconfigitem(
603 coreconfigitem(
604 b'devel',
604 b'devel',
605 b'bundle.delta',
605 b'bundle.delta',
606 default=b'',
606 default=b'',
607 )
607 )
608 coreconfigitem(
608 coreconfigitem(
609 b'devel',
609 b'devel',
610 b'cache-vfs',
610 b'cache-vfs',
611 default=None,
611 default=None,
612 )
612 )
613 coreconfigitem(
613 coreconfigitem(
614 b'devel',
614 b'devel',
615 b'check-locks',
615 b'check-locks',
616 default=False,
616 default=False,
617 )
617 )
618 coreconfigitem(
618 coreconfigitem(
619 b'devel',
619 b'devel',
620 b'check-relroot',
620 b'check-relroot',
621 default=False,
621 default=False,
622 )
622 )
623 # Track copy information for all file, not just "added" one (very slow)
623 # Track copy information for all file, not just "added" one (very slow)
624 coreconfigitem(
624 coreconfigitem(
625 b'devel',
625 b'devel',
626 b'copy-tracing.trace-all-files',
626 b'copy-tracing.trace-all-files',
627 default=False,
627 default=False,
628 )
628 )
629 coreconfigitem(
629 coreconfigitem(
630 b'devel',
630 b'devel',
631 b'default-date',
631 b'default-date',
632 default=None,
632 default=None,
633 )
633 )
634 coreconfigitem(
634 coreconfigitem(
635 b'devel',
635 b'devel',
636 b'deprec-warn',
636 b'deprec-warn',
637 default=False,
637 default=False,
638 )
638 )
639 coreconfigitem(
639 coreconfigitem(
640 b'devel',
640 b'devel',
641 b'disableloaddefaultcerts',
641 b'disableloaddefaultcerts',
642 default=False,
642 default=False,
643 )
643 )
644 coreconfigitem(
644 coreconfigitem(
645 b'devel',
645 b'devel',
646 b'warn-empty-changegroup',
646 b'warn-empty-changegroup',
647 default=False,
647 default=False,
648 )
648 )
649 coreconfigitem(
649 coreconfigitem(
650 b'devel',
650 b'devel',
651 b'legacy.exchange',
651 b'legacy.exchange',
652 default=list,
652 default=list,
653 )
653 )
654 # When True, revlogs use a special reference version of the nodemap, that is not
654 # When True, revlogs use a special reference version of the nodemap, that is not
655 # performant but is "known" to behave properly.
655 # performant but is "known" to behave properly.
656 coreconfigitem(
656 coreconfigitem(
657 b'devel',
657 b'devel',
658 b'persistent-nodemap',
658 b'persistent-nodemap',
659 default=False,
659 default=False,
660 )
660 )
661 coreconfigitem(
661 coreconfigitem(
662 b'devel',
662 b'devel',
663 b'servercafile',
663 b'servercafile',
664 default=b'',
664 default=b'',
665 )
665 )
666 coreconfigitem(
666 coreconfigitem(
667 b'devel',
667 b'devel',
668 b'serverexactprotocol',
668 b'serverexactprotocol',
669 default=b'',
669 default=b'',
670 )
670 )
671 coreconfigitem(
671 coreconfigitem(
672 b'devel',
672 b'devel',
673 b'serverrequirecert',
673 b'serverrequirecert',
674 default=False,
674 default=False,
675 )
675 )
676 coreconfigitem(
676 coreconfigitem(
677 b'devel',
677 b'devel',
678 b'strip-obsmarkers',
678 b'strip-obsmarkers',
679 default=True,
679 default=True,
680 )
680 )
681 coreconfigitem(
681 coreconfigitem(
682 b'devel',
682 b'devel',
683 b'warn-config',
683 b'warn-config',
684 default=None,
684 default=None,
685 )
685 )
686 coreconfigitem(
686 coreconfigitem(
687 b'devel',
687 b'devel',
688 b'warn-config-default',
688 b'warn-config-default',
689 default=None,
689 default=None,
690 )
690 )
691 coreconfigitem(
691 coreconfigitem(
692 b'devel',
692 b'devel',
693 b'user.obsmarker',
693 b'user.obsmarker',
694 default=None,
694 default=None,
695 )
695 )
696 coreconfigitem(
696 coreconfigitem(
697 b'devel',
697 b'devel',
698 b'warn-config-unknown',
698 b'warn-config-unknown',
699 default=None,
699 default=None,
700 )
700 )
701 coreconfigitem(
701 coreconfigitem(
702 b'devel',
702 b'devel',
703 b'debug.copies',
703 b'debug.copies',
704 default=False,
704 default=False,
705 )
705 )
706 coreconfigitem(
706 coreconfigitem(
707 b'devel',
707 b'devel',
708 b'copy-tracing.multi-thread',
708 b'copy-tracing.multi-thread',
709 default=True,
709 default=True,
710 )
710 )
711 coreconfigitem(
711 coreconfigitem(
712 b'devel',
712 b'devel',
713 b'debug.extensions',
713 b'debug.extensions',
714 default=False,
714 default=False,
715 )
715 )
716 coreconfigitem(
716 coreconfigitem(
717 b'devel',
717 b'devel',
718 b'debug.repo-filters',
718 b'debug.repo-filters',
719 default=False,
719 default=False,
720 )
720 )
721 coreconfigitem(
721 coreconfigitem(
722 b'devel',
722 b'devel',
723 b'debug.peer-request',
723 b'debug.peer-request',
724 default=False,
724 default=False,
725 )
725 )
726 # If discovery.exchange-heads is False, the discovery will not start with
726 # If discovery.exchange-heads is False, the discovery will not start with
727 # remote head fetching and local head querying.
727 # remote head fetching and local head querying.
728 coreconfigitem(
728 coreconfigitem(
729 b'devel',
729 b'devel',
730 b'discovery.exchange-heads',
730 b'discovery.exchange-heads',
731 default=True,
731 default=True,
732 )
732 )
733 # If discovery.grow-sample is False, the sample size used in set discovery will
733 # If discovery.grow-sample is False, the sample size used in set discovery will
734 # not be increased through the process
734 # not be increased through the process
735 coreconfigitem(
735 coreconfigitem(
736 b'devel',
736 b'devel',
737 b'discovery.grow-sample',
737 b'discovery.grow-sample',
738 default=True,
738 default=True,
739 )
739 )
740 # When discovery.grow-sample.dynamic is True, the default, the sample size is
740 # When discovery.grow-sample.dynamic is True, the default, the sample size is
741 # adapted to the shape of the undecided set (it is set to the max of:
741 # adapted to the shape of the undecided set (it is set to the max of:
742 # <target-size>, len(roots(undecided)), len(heads(undecided)
742 # <target-size>, len(roots(undecided)), len(heads(undecided)
743 coreconfigitem(
743 coreconfigitem(
744 b'devel',
744 b'devel',
745 b'discovery.grow-sample.dynamic',
745 b'discovery.grow-sample.dynamic',
746 default=True,
746 default=True,
747 )
747 )
748 # discovery.grow-sample.rate control the rate at which the sample grow
748 # discovery.grow-sample.rate control the rate at which the sample grow
749 coreconfigitem(
749 coreconfigitem(
750 b'devel',
750 b'devel',
751 b'discovery.grow-sample.rate',
751 b'discovery.grow-sample.rate',
752 default=1.05,
752 default=1.05,
753 )
753 )
754 # If discovery.randomize is False, random sampling during discovery are
754 # If discovery.randomize is False, random sampling during discovery are
755 # deterministic. It is meant for integration tests.
755 # deterministic. It is meant for integration tests.
756 coreconfigitem(
756 coreconfigitem(
757 b'devel',
757 b'devel',
758 b'discovery.randomize',
758 b'discovery.randomize',
759 default=True,
759 default=True,
760 )
760 )
761 # Control the initial size of the discovery sample
761 # Control the initial size of the discovery sample
762 coreconfigitem(
762 coreconfigitem(
763 b'devel',
763 b'devel',
764 b'discovery.sample-size',
764 b'discovery.sample-size',
765 default=200,
765 default=200,
766 )
766 )
767 # Control the initial size of the discovery for initial change
767 # Control the initial size of the discovery for initial change
768 coreconfigitem(
768 coreconfigitem(
769 b'devel',
769 b'devel',
770 b'discovery.sample-size.initial',
770 b'discovery.sample-size.initial',
771 default=100,
771 default=100,
772 )
772 )
773 _registerdiffopts(section=b'diff')
773 _registerdiffopts(section=b'diff')
774 coreconfigitem(
774 coreconfigitem(
775 b'diff',
775 b'diff',
776 b'merge',
776 b'merge',
777 default=False,
777 default=False,
778 experimental=True,
778 experimental=True,
779 )
779 )
780 coreconfigitem(
780 coreconfigitem(
781 b'email',
781 b'email',
782 b'bcc',
782 b'bcc',
783 default=None,
783 default=None,
784 )
784 )
785 coreconfigitem(
785 coreconfigitem(
786 b'email',
786 b'email',
787 b'cc',
787 b'cc',
788 default=None,
788 default=None,
789 )
789 )
790 coreconfigitem(
790 coreconfigitem(
791 b'email',
791 b'email',
792 b'charsets',
792 b'charsets',
793 default=list,
793 default=list,
794 )
794 )
795 coreconfigitem(
795 coreconfigitem(
796 b'email',
796 b'email',
797 b'from',
797 b'from',
798 default=None,
798 default=None,
799 )
799 )
800 coreconfigitem(
800 coreconfigitem(
801 b'email',
801 b'email',
802 b'method',
802 b'method',
803 default=b'smtp',
803 default=b'smtp',
804 )
804 )
805 coreconfigitem(
805 coreconfigitem(
806 b'email',
806 b'email',
807 b'reply-to',
807 b'reply-to',
808 default=None,
808 default=None,
809 )
809 )
810 coreconfigitem(
810 coreconfigitem(
811 b'email',
811 b'email',
812 b'to',
812 b'to',
813 default=None,
813 default=None,
814 )
814 )
815 coreconfigitem(
815 coreconfigitem(
816 b'experimental',
816 b'experimental',
817 b'archivemetatemplate',
817 b'archivemetatemplate',
818 default=dynamicdefault,
818 default=dynamicdefault,
819 )
819 )
820 coreconfigitem(
820 coreconfigitem(
821 b'experimental',
821 b'experimental',
822 b'auto-publish',
822 b'auto-publish',
823 default=b'publish',
823 default=b'publish',
824 )
824 )
825 coreconfigitem(
825 coreconfigitem(
826 b'experimental',
826 b'experimental',
827 b'bundle-phases',
827 b'bundle-phases',
828 default=False,
828 default=False,
829 )
829 )
830 coreconfigitem(
830 coreconfigitem(
831 b'experimental',
831 b'experimental',
832 b'bundle2-advertise',
832 b'bundle2-advertise',
833 default=True,
833 default=True,
834 )
834 )
835 coreconfigitem(
835 coreconfigitem(
836 b'experimental',
836 b'experimental',
837 b'bundle2-output-capture',
837 b'bundle2-output-capture',
838 default=False,
838 default=False,
839 )
839 )
840 coreconfigitem(
840 coreconfigitem(
841 b'experimental',
841 b'experimental',
842 b'bundle2.pushback',
842 b'bundle2.pushback',
843 default=False,
843 default=False,
844 )
844 )
845 coreconfigitem(
845 coreconfigitem(
846 b'experimental',
846 b'experimental',
847 b'bundle2lazylocking',
847 b'bundle2lazylocking',
848 default=False,
848 default=False,
849 )
849 )
850 coreconfigitem(
850 coreconfigitem(
851 b'experimental',
851 b'experimental',
852 b'bundlecomplevel',
852 b'bundlecomplevel',
853 default=None,
853 default=None,
854 )
854 )
855 coreconfigitem(
855 coreconfigitem(
856 b'experimental',
856 b'experimental',
857 b'bundlecomplevel.bzip2',
857 b'bundlecomplevel.bzip2',
858 default=None,
858 default=None,
859 )
859 )
860 coreconfigitem(
860 coreconfigitem(
861 b'experimental',
861 b'experimental',
862 b'bundlecomplevel.gzip',
862 b'bundlecomplevel.gzip',
863 default=None,
863 default=None,
864 )
864 )
865 coreconfigitem(
865 coreconfigitem(
866 b'experimental',
866 b'experimental',
867 b'bundlecomplevel.none',
867 b'bundlecomplevel.none',
868 default=None,
868 default=None,
869 )
869 )
870 coreconfigitem(
870 coreconfigitem(
871 b'experimental',
871 b'experimental',
872 b'bundlecomplevel.zstd',
872 b'bundlecomplevel.zstd',
873 default=None,
873 default=None,
874 )
874 )
875 coreconfigitem(
875 coreconfigitem(
876 b'experimental',
876 b'experimental',
877 b'bundlecompthreads',
877 b'bundlecompthreads',
878 default=None,
878 default=None,
879 )
879 )
880 coreconfigitem(
880 coreconfigitem(
881 b'experimental',
881 b'experimental',
882 b'bundlecompthreads.bzip2',
882 b'bundlecompthreads.bzip2',
883 default=None,
883 default=None,
884 )
884 )
885 coreconfigitem(
885 coreconfigitem(
886 b'experimental',
886 b'experimental',
887 b'bundlecompthreads.gzip',
887 b'bundlecompthreads.gzip',
888 default=None,
888 default=None,
889 )
889 )
890 coreconfigitem(
890 coreconfigitem(
891 b'experimental',
891 b'experimental',
892 b'bundlecompthreads.none',
892 b'bundlecompthreads.none',
893 default=None,
893 default=None,
894 )
894 )
895 coreconfigitem(
895 coreconfigitem(
896 b'experimental',
896 b'experimental',
897 b'bundlecompthreads.zstd',
897 b'bundlecompthreads.zstd',
898 default=None,
898 default=None,
899 )
899 )
900 coreconfigitem(
900 coreconfigitem(
901 b'experimental',
901 b'experimental',
902 b'changegroup3',
902 b'changegroup3',
903 default=False,
903 default=False,
904 )
904 )
905 coreconfigitem(
905 coreconfigitem(
906 b'experimental',
906 b'experimental',
907 b'changegroup4',
907 b'changegroup4',
908 default=False,
908 default=False,
909 )
909 )
910 coreconfigitem(
910 coreconfigitem(
911 b'experimental',
911 b'experimental',
912 b'cleanup-as-archived',
912 b'cleanup-as-archived',
913 default=False,
913 default=False,
914 )
914 )
915 coreconfigitem(
915 coreconfigitem(
916 b'experimental',
916 b'experimental',
917 b'clientcompressionengines',
917 b'clientcompressionengines',
918 default=list,
918 default=list,
919 )
919 )
920 coreconfigitem(
920 coreconfigitem(
921 b'experimental',
921 b'experimental',
922 b'copytrace',
922 b'copytrace',
923 default=b'on',
923 default=b'on',
924 )
924 )
925 coreconfigitem(
925 coreconfigitem(
926 b'experimental',
926 b'experimental',
927 b'copytrace.movecandidateslimit',
927 b'copytrace.movecandidateslimit',
928 default=100,
928 default=100,
929 )
929 )
930 coreconfigitem(
930 coreconfigitem(
931 b'experimental',
931 b'experimental',
932 b'copytrace.sourcecommitlimit',
932 b'copytrace.sourcecommitlimit',
933 default=100,
933 default=100,
934 )
934 )
935 coreconfigitem(
935 coreconfigitem(
936 b'experimental',
936 b'experimental',
937 b'copies.read-from',
937 b'copies.read-from',
938 default=b"filelog-only",
938 default=b"filelog-only",
939 )
939 )
940 coreconfigitem(
940 coreconfigitem(
941 b'experimental',
941 b'experimental',
942 b'copies.write-to',
942 b'copies.write-to',
943 default=b'filelog-only',
943 default=b'filelog-only',
944 )
944 )
945 coreconfigitem(
945 coreconfigitem(
946 b'experimental',
946 b'experimental',
947 b'crecordtest',
947 b'crecordtest',
948 default=None,
948 default=None,
949 )
949 )
950 coreconfigitem(
950 coreconfigitem(
951 b'experimental',
951 b'experimental',
952 b'directaccess',
952 b'directaccess',
953 default=False,
953 default=False,
954 )
954 )
955 coreconfigitem(
955 coreconfigitem(
956 b'experimental',
956 b'experimental',
957 b'directaccess.revnums',
957 b'directaccess.revnums',
958 default=False,
958 default=False,
959 )
959 )
960 coreconfigitem(
960 coreconfigitem(
961 b'experimental',
961 b'experimental',
962 b'dirstate-tree.in-memory',
962 b'dirstate-tree.in-memory',
963 default=False,
963 default=False,
964 )
964 )
965 coreconfigitem(
965 coreconfigitem(
966 b'experimental',
966 b'experimental',
967 b'editortmpinhg',
967 b'editortmpinhg',
968 default=False,
968 default=False,
969 )
969 )
970 coreconfigitem(
970 coreconfigitem(
971 b'experimental',
971 b'experimental',
972 b'evolution',
972 b'evolution',
973 default=list,
973 default=list,
974 )
974 )
975 coreconfigitem(
975 coreconfigitem(
976 b'experimental',
976 b'experimental',
977 b'evolution.allowdivergence',
977 b'evolution.allowdivergence',
978 default=False,
978 default=False,
979 alias=[(b'experimental', b'allowdivergence')],
979 alias=[(b'experimental', b'allowdivergence')],
980 )
980 )
981 coreconfigitem(
981 coreconfigitem(
982 b'experimental',
982 b'experimental',
983 b'evolution.allowunstable',
983 b'evolution.allowunstable',
984 default=None,
984 default=None,
985 )
985 )
986 coreconfigitem(
986 coreconfigitem(
987 b'experimental',
987 b'experimental',
988 b'evolution.createmarkers',
988 b'evolution.createmarkers',
989 default=None,
989 default=None,
990 )
990 )
991 coreconfigitem(
991 coreconfigitem(
992 b'experimental',
992 b'experimental',
993 b'evolution.effect-flags',
993 b'evolution.effect-flags',
994 default=True,
994 default=True,
995 alias=[(b'experimental', b'effect-flags')],
995 alias=[(b'experimental', b'effect-flags')],
996 )
996 )
997 coreconfigitem(
997 coreconfigitem(
998 b'experimental',
998 b'experimental',
999 b'evolution.exchange',
999 b'evolution.exchange',
1000 default=None,
1000 default=None,
1001 )
1001 )
1002 coreconfigitem(
1002 coreconfigitem(
1003 b'experimental',
1003 b'experimental',
1004 b'evolution.bundle-obsmarker',
1004 b'evolution.bundle-obsmarker',
1005 default=False,
1005 default=False,
1006 )
1006 )
1007 coreconfigitem(
1007 coreconfigitem(
1008 b'experimental',
1008 b'experimental',
1009 b'evolution.bundle-obsmarker:mandatory',
1009 b'evolution.bundle-obsmarker:mandatory',
1010 default=True,
1010 default=True,
1011 )
1011 )
1012 coreconfigitem(
1012 coreconfigitem(
1013 b'experimental',
1013 b'experimental',
1014 b'log.topo',
1014 b'log.topo',
1015 default=False,
1015 default=False,
1016 )
1016 )
1017 coreconfigitem(
1017 coreconfigitem(
1018 b'experimental',
1018 b'experimental',
1019 b'evolution.report-instabilities',
1019 b'evolution.report-instabilities',
1020 default=True,
1020 default=True,
1021 )
1021 )
1022 coreconfigitem(
1022 coreconfigitem(
1023 b'experimental',
1023 b'experimental',
1024 b'evolution.track-operation',
1024 b'evolution.track-operation',
1025 default=True,
1025 default=True,
1026 )
1026 )
1027 # repo-level config to exclude a revset visibility
1027 # repo-level config to exclude a revset visibility
1028 #
1028 #
1029 # The target use case is to use `share` to expose different subset of the same
1029 # The target use case is to use `share` to expose different subset of the same
1030 # repository, especially server side. See also `server.view`.
1030 # repository, especially server side. See also `server.view`.
1031 coreconfigitem(
1031 coreconfigitem(
1032 b'experimental',
1032 b'experimental',
1033 b'extra-filter-revs',
1033 b'extra-filter-revs',
1034 default=None,
1034 default=None,
1035 )
1035 )
1036 coreconfigitem(
1036 coreconfigitem(
1037 b'experimental',
1037 b'experimental',
1038 b'maxdeltachainspan',
1038 b'maxdeltachainspan',
1039 default=-1,
1039 default=-1,
1040 )
1040 )
1041 # tracks files which were undeleted (merge might delete them but we explicitly
1041 # tracks files which were undeleted (merge might delete them but we explicitly
1042 # kept/undeleted them) and creates new filenodes for them
1042 # kept/undeleted them) and creates new filenodes for them
1043 coreconfigitem(
1043 coreconfigitem(
1044 b'experimental',
1044 b'experimental',
1045 b'merge-track-salvaged',
1045 b'merge-track-salvaged',
1046 default=False,
1046 default=False,
1047 )
1047 )
1048 coreconfigitem(
1048 coreconfigitem(
1049 b'experimental',
1049 b'experimental',
1050 b'mergetempdirprefix',
1050 b'mergetempdirprefix',
1051 default=None,
1051 default=None,
1052 )
1052 )
1053 coreconfigitem(
1053 coreconfigitem(
1054 b'experimental',
1054 b'experimental',
1055 b'mmapindexthreshold',
1055 b'mmapindexthreshold',
1056 default=None,
1056 default=None,
1057 )
1057 )
1058 coreconfigitem(
1058 coreconfigitem(
1059 b'experimental',
1059 b'experimental',
1060 b'narrow',
1060 b'narrow',
1061 default=False,
1061 default=False,
1062 )
1062 )
1063 coreconfigitem(
1063 coreconfigitem(
1064 b'experimental',
1064 b'experimental',
1065 b'nonnormalparanoidcheck',
1065 b'nonnormalparanoidcheck',
1066 default=False,
1066 default=False,
1067 )
1067 )
1068 coreconfigitem(
1068 coreconfigitem(
1069 b'experimental',
1069 b'experimental',
1070 b'exportableenviron',
1070 b'exportableenviron',
1071 default=list,
1071 default=list,
1072 )
1072 )
1073 coreconfigitem(
1073 coreconfigitem(
1074 b'experimental',
1074 b'experimental',
1075 b'extendedheader.index',
1075 b'extendedheader.index',
1076 default=None,
1076 default=None,
1077 )
1077 )
1078 coreconfigitem(
1078 coreconfigitem(
1079 b'experimental',
1079 b'experimental',
1080 b'extendedheader.similarity',
1080 b'extendedheader.similarity',
1081 default=False,
1081 default=False,
1082 )
1082 )
1083 coreconfigitem(
1083 coreconfigitem(
1084 b'experimental',
1084 b'experimental',
1085 b'graphshorten',
1085 b'graphshorten',
1086 default=False,
1086 default=False,
1087 )
1087 )
1088 coreconfigitem(
1088 coreconfigitem(
1089 b'experimental',
1089 b'experimental',
1090 b'graphstyle.parent',
1090 b'graphstyle.parent',
1091 default=dynamicdefault,
1091 default=dynamicdefault,
1092 )
1092 )
1093 coreconfigitem(
1093 coreconfigitem(
1094 b'experimental',
1094 b'experimental',
1095 b'graphstyle.missing',
1095 b'graphstyle.missing',
1096 default=dynamicdefault,
1096 default=dynamicdefault,
1097 )
1097 )
1098 coreconfigitem(
1098 coreconfigitem(
1099 b'experimental',
1099 b'experimental',
1100 b'graphstyle.grandparent',
1100 b'graphstyle.grandparent',
1101 default=dynamicdefault,
1101 default=dynamicdefault,
1102 )
1102 )
1103 coreconfigitem(
1103 coreconfigitem(
1104 b'experimental',
1104 b'experimental',
1105 b'hook-track-tags',
1105 b'hook-track-tags',
1106 default=False,
1106 default=False,
1107 )
1107 )
1108 coreconfigitem(
1108 coreconfigitem(
1109 b'experimental',
1109 b'experimental',
1110 b'httppeer.advertise-v2',
1110 b'httppeer.advertise-v2',
1111 default=False,
1111 default=False,
1112 )
1112 )
1113 coreconfigitem(
1113 coreconfigitem(
1114 b'experimental',
1114 b'experimental',
1115 b'httppeer.v2-encoder-order',
1115 b'httppeer.v2-encoder-order',
1116 default=None,
1116 default=None,
1117 )
1117 )
1118 coreconfigitem(
1118 coreconfigitem(
1119 b'experimental',
1119 b'experimental',
1120 b'httppostargs',
1120 b'httppostargs',
1121 default=False,
1121 default=False,
1122 )
1122 )
1123 coreconfigitem(b'experimental', b'nointerrupt', default=False)
1123 coreconfigitem(b'experimental', b'nointerrupt', default=False)
1124 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
1124 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
1125
1125
1126 coreconfigitem(
1126 coreconfigitem(
1127 b'experimental',
1127 b'experimental',
1128 b'obsmarkers-exchange-debug',
1128 b'obsmarkers-exchange-debug',
1129 default=False,
1129 default=False,
1130 )
1130 )
1131 coreconfigitem(
1131 coreconfigitem(
1132 b'experimental',
1132 b'experimental',
1133 b'remotenames',
1133 b'remotenames',
1134 default=False,
1134 default=False,
1135 )
1135 )
1136 coreconfigitem(
1136 coreconfigitem(
1137 b'experimental',
1137 b'experimental',
1138 b'removeemptydirs',
1138 b'removeemptydirs',
1139 default=True,
1139 default=True,
1140 )
1140 )
1141 coreconfigitem(
1141 coreconfigitem(
1142 b'experimental',
1142 b'experimental',
1143 b'revert.interactive.select-to-keep',
1143 b'revert.interactive.select-to-keep',
1144 default=False,
1144 default=False,
1145 )
1145 )
1146 coreconfigitem(
1146 coreconfigitem(
1147 b'experimental',
1147 b'experimental',
1148 b'revisions.prefixhexnode',
1148 b'revisions.prefixhexnode',
1149 default=False,
1149 default=False,
1150 )
1150 )
1151 # "out of experimental" todo list.
1151 # "out of experimental" todo list.
1152 #
1152 #
1153 # * include management of a persistent nodemap in the main docket
1153 # * include management of a persistent nodemap in the main docket
1154 # * enforce a "no-truncate" policy for mmap safety
1154 # * enforce a "no-truncate" policy for mmap safety
1155 # - for censoring operation
1155 # - for censoring operation
1156 # - for stripping operation
1156 # - for stripping operation
1157 # - for rollback operation
1157 # - for rollback operation
1158 # * proper streaming (race free) of the docket file
1158 # * proper streaming (race free) of the docket file
1159 # * track garbage data to evemtually allow rewriting -existing- sidedata.
1159 # * track garbage data to evemtually allow rewriting -existing- sidedata.
1160 # * Exchange-wise, we will also need to do something more efficient than
1160 # * Exchange-wise, we will also need to do something more efficient than
1161 # keeping references to the affected revlogs, especially memory-wise when
1161 # keeping references to the affected revlogs, especially memory-wise when
1162 # rewriting sidedata.
1162 # rewriting sidedata.
1163 # * introduce a proper solution to reduce the number of filelog related files.
1163 # * introduce a proper solution to reduce the number of filelog related files.
1164 # * use caching for reading sidedata (similar to what we do for data).
1164 # * use caching for reading sidedata (similar to what we do for data).
1165 # * no longer set offset=0 if sidedata_size=0 (simplify cutoff computation).
1165 # * no longer set offset=0 if sidedata_size=0 (simplify cutoff computation).
1166 # * Improvement to consider
1166 # * Improvement to consider
1167 # - avoid compression header in chunk using the default compression?
1167 # - avoid compression header in chunk using the default compression?
1168 # - forbid "inline" compression mode entirely?
1168 # - forbid "inline" compression mode entirely?
1169 # - split the data offset and flag field (the 2 bytes save are mostly trouble)
1169 # - split the data offset and flag field (the 2 bytes save are mostly trouble)
1170 # - keep track of uncompressed -chunk- size (to preallocate memory better)
1170 # - keep track of uncompressed -chunk- size (to preallocate memory better)
1171 # - keep track of chain base or size (probably not that useful anymore)
1171 # - keep track of chain base or size (probably not that useful anymore)
1172 coreconfigitem(
1172 coreconfigitem(
1173 b'experimental',
1173 b'experimental',
1174 b'revlogv2',
1174 b'revlogv2',
1175 default=None,
1175 default=None,
1176 )
1176 )
1177 coreconfigitem(
1177 coreconfigitem(
1178 b'experimental',
1178 b'experimental',
1179 b'revisions.disambiguatewithin',
1179 b'revisions.disambiguatewithin',
1180 default=None,
1180 default=None,
1181 )
1181 )
1182 coreconfigitem(
1182 coreconfigitem(
1183 b'experimental',
1183 b'experimental',
1184 b'rust.index',
1184 b'rust.index',
1185 default=False,
1185 default=False,
1186 )
1186 )
1187 coreconfigitem(
1187 coreconfigitem(
1188 b'experimental',
1188 b'experimental',
1189 b'server.filesdata.recommended-batch-size',
1189 b'server.filesdata.recommended-batch-size',
1190 default=50000,
1190 default=50000,
1191 )
1191 )
1192 coreconfigitem(
1192 coreconfigitem(
1193 b'experimental',
1193 b'experimental',
1194 b'server.manifestdata.recommended-batch-size',
1194 b'server.manifestdata.recommended-batch-size',
1195 default=100000,
1195 default=100000,
1196 )
1196 )
1197 coreconfigitem(
1197 coreconfigitem(
1198 b'experimental',
1198 b'experimental',
1199 b'server.stream-narrow-clones',
1199 b'server.stream-narrow-clones',
1200 default=False,
1200 default=False,
1201 )
1201 )
1202 coreconfigitem(
1202 coreconfigitem(
1203 b'experimental',
1203 b'experimental',
1204 b'single-head-per-branch',
1204 b'single-head-per-branch',
1205 default=False,
1205 default=False,
1206 )
1206 )
1207 coreconfigitem(
1207 coreconfigitem(
1208 b'experimental',
1208 b'experimental',
1209 b'single-head-per-branch:account-closed-heads',
1209 b'single-head-per-branch:account-closed-heads',
1210 default=False,
1210 default=False,
1211 )
1211 )
1212 coreconfigitem(
1212 coreconfigitem(
1213 b'experimental',
1213 b'experimental',
1214 b'single-head-per-branch:public-changes-only',
1214 b'single-head-per-branch:public-changes-only',
1215 default=False,
1215 default=False,
1216 )
1216 )
1217 coreconfigitem(
1217 coreconfigitem(
1218 b'experimental',
1218 b'experimental',
1219 b'sshserver.support-v2',
1219 b'sshserver.support-v2',
1220 default=False,
1220 default=False,
1221 )
1221 )
1222 coreconfigitem(
1222 coreconfigitem(
1223 b'experimental',
1223 b'experimental',
1224 b'sparse-read',
1224 b'sparse-read',
1225 default=False,
1225 default=False,
1226 )
1226 )
1227 coreconfigitem(
1227 coreconfigitem(
1228 b'experimental',
1228 b'experimental',
1229 b'sparse-read.density-threshold',
1229 b'sparse-read.density-threshold',
1230 default=0.50,
1230 default=0.50,
1231 )
1231 )
1232 coreconfigitem(
1232 coreconfigitem(
1233 b'experimental',
1233 b'experimental',
1234 b'sparse-read.min-gap-size',
1234 b'sparse-read.min-gap-size',
1235 default=b'65K',
1235 default=b'65K',
1236 )
1236 )
1237 coreconfigitem(
1237 coreconfigitem(
1238 b'experimental',
1238 b'experimental',
1239 b'treemanifest',
1239 b'treemanifest',
1240 default=False,
1240 default=False,
1241 )
1241 )
1242 coreconfigitem(
1242 coreconfigitem(
1243 b'experimental',
1243 b'experimental',
1244 b'update.atomic-file',
1244 b'update.atomic-file',
1245 default=False,
1245 default=False,
1246 )
1246 )
1247 coreconfigitem(
1247 coreconfigitem(
1248 b'experimental',
1248 b'experimental',
1249 b'sshpeer.advertise-v2',
1249 b'sshpeer.advertise-v2',
1250 default=False,
1250 default=False,
1251 )
1251 )
1252 coreconfigitem(
1252 coreconfigitem(
1253 b'experimental',
1253 b'experimental',
1254 b'web.apiserver',
1254 b'web.apiserver',
1255 default=False,
1255 default=False,
1256 )
1256 )
1257 coreconfigitem(
1257 coreconfigitem(
1258 b'experimental',
1258 b'experimental',
1259 b'web.api.http-v2',
1259 b'web.api.http-v2',
1260 default=False,
1260 default=False,
1261 )
1261 )
1262 coreconfigitem(
1262 coreconfigitem(
1263 b'experimental',
1263 b'experimental',
1264 b'web.api.debugreflect',
1264 b'web.api.debugreflect',
1265 default=False,
1265 default=False,
1266 )
1266 )
1267 coreconfigitem(
1267 coreconfigitem(
1268 b'experimental',
1268 b'experimental',
1269 b'worker.wdir-get-thread-safe',
1269 b'worker.wdir-get-thread-safe',
1270 default=False,
1270 default=False,
1271 )
1271 )
1272 coreconfigitem(
1272 coreconfigitem(
1273 b'experimental',
1273 b'experimental',
1274 b'worker.repository-upgrade',
1274 b'worker.repository-upgrade',
1275 default=False,
1275 default=False,
1276 )
1276 )
1277 coreconfigitem(
1277 coreconfigitem(
1278 b'experimental',
1278 b'experimental',
1279 b'xdiff',
1279 b'xdiff',
1280 default=False,
1280 default=False,
1281 )
1281 )
1282 coreconfigitem(
1282 coreconfigitem(
1283 b'extensions',
1283 b'extensions',
1284 b'.*',
1284 b'.*',
1285 default=None,
1285 default=None,
1286 generic=True,
1286 generic=True,
1287 )
1287 )
1288 coreconfigitem(
1288 coreconfigitem(
1289 b'extdata',
1289 b'extdata',
1290 b'.*',
1290 b'.*',
1291 default=None,
1291 default=None,
1292 generic=True,
1292 generic=True,
1293 )
1293 )
1294 coreconfigitem(
1294 coreconfigitem(
1295 b'format',
1295 b'format',
1296 b'bookmarks-in-store',
1296 b'bookmarks-in-store',
1297 default=False,
1297 default=False,
1298 )
1298 )
1299 coreconfigitem(
1299 coreconfigitem(
1300 b'format',
1300 b'format',
1301 b'chunkcachesize',
1301 b'chunkcachesize',
1302 default=None,
1302 default=None,
1303 experimental=True,
1303 experimental=True,
1304 )
1304 )
1305 coreconfigitem(
1305 coreconfigitem(
1306 # Enable this dirstate format *when creating a new repository*.
1306 # Enable this dirstate format *when creating a new repository*.
1307 # Which format to use for existing repos is controlled by .hg/requires
1307 # Which format to use for existing repos is controlled by .hg/requires
1308 b'format',
1308 b'format',
1309 b'exp-dirstate-v2',
1309 b'exp-dirstate-v2',
1310 default=False,
1310 default=False,
1311 experimental=True,
1311 experimental=True,
1312 )
1312 )
1313 coreconfigitem(
1313 coreconfigitem(
1314 b'format',
1314 b'format',
1315 b'dotencode',
1315 b'dotencode',
1316 default=True,
1316 default=True,
1317 )
1317 )
1318 coreconfigitem(
1318 coreconfigitem(
1319 b'format',
1319 b'format',
1320 b'generaldelta',
1320 b'generaldelta',
1321 default=False,
1321 default=False,
1322 experimental=True,
1322 experimental=True,
1323 )
1323 )
1324 coreconfigitem(
1324 coreconfigitem(
1325 b'format',
1325 b'format',
1326 b'manifestcachesize',
1326 b'manifestcachesize',
1327 default=None,
1327 default=None,
1328 experimental=True,
1328 experimental=True,
1329 )
1329 )
1330 coreconfigitem(
1330 coreconfigitem(
1331 b'format',
1331 b'format',
1332 b'maxchainlen',
1332 b'maxchainlen',
1333 default=dynamicdefault,
1333 default=dynamicdefault,
1334 experimental=True,
1334 experimental=True,
1335 )
1335 )
1336 coreconfigitem(
1336 coreconfigitem(
1337 b'format',
1337 b'format',
1338 b'obsstore-version',
1338 b'obsstore-version',
1339 default=None,
1339 default=None,
1340 )
1340 )
1341 coreconfigitem(
1341 coreconfigitem(
1342 b'format',
1342 b'format',
1343 b'sparse-revlog',
1343 b'sparse-revlog',
1344 default=True,
1344 default=True,
1345 )
1345 )
1346 coreconfigitem(
1346 coreconfigitem(
1347 b'format',
1347 b'format',
1348 b'revlog-compression',
1348 b'revlog-compression',
1349 default=lambda: [b'zstd', b'zlib'],
1349 default=lambda: [b'zstd', b'zlib'],
1350 alias=[(b'experimental', b'format.compression')],
1350 alias=[(b'experimental', b'format.compression')],
1351 )
1351 )
1352 # Experimental TODOs:
1352 # Experimental TODOs:
1353 #
1353 #
1354 # * Same as for evlogv2 (but for the reduction of the number of files)
1354 # * Same as for evlogv2 (but for the reduction of the number of files)
1355 # * Improvement to investigate
1355 # * Improvement to investigate
1356 # - storing .hgtags fnode
1356 # - storing .hgtags fnode
1357 # - storing `rank` of changesets
1357 # - storing `rank` of changesets
1358 # - storing branch related identifier
1358 # - storing branch related identifier
1359
1359
1360 coreconfigitem(
1360 coreconfigitem(
1361 b'format',
1361 b'format',
1362 b'exp-use-changelog-v2',
1362 b'exp-use-changelog-v2',
1363 default=None,
1363 default=None,
1364 experimental=True,
1364 experimental=True,
1365 )
1365 )
1366 coreconfigitem(
1366 coreconfigitem(
1367 b'format',
1367 b'format',
1368 b'usefncache',
1368 b'usefncache',
1369 default=True,
1369 default=True,
1370 )
1370 )
1371 coreconfigitem(
1371 coreconfigitem(
1372 b'format',
1372 b'format',
1373 b'usegeneraldelta',
1373 b'usegeneraldelta',
1374 default=True,
1374 default=True,
1375 )
1375 )
1376 coreconfigitem(
1376 coreconfigitem(
1377 b'format',
1377 b'format',
1378 b'usestore',
1378 b'usestore',
1379 default=True,
1379 default=True,
1380 )
1380 )
1381
1381
1382
1382
1383 def _persistent_nodemap_default():
1383 def _persistent_nodemap_default():
1384 """compute `use-persistent-nodemap` default value
1384 """compute `use-persistent-nodemap` default value
1385
1385
1386 The feature is disabled unless a fast implementation is available.
1386 The feature is disabled unless a fast implementation is available.
1387 """
1387 """
1388 from . import policy
1388 from . import policy
1389
1389
1390 return policy.importrust('revlog') is not None
1390 return policy.importrust('revlog') is not None
1391
1391
1392
1392
1393 coreconfigitem(
1393 coreconfigitem(
1394 b'format',
1394 b'format',
1395 b'use-persistent-nodemap',
1395 b'use-persistent-nodemap',
1396 default=_persistent_nodemap_default,
1396 default=_persistent_nodemap_default,
1397 )
1397 )
1398 coreconfigitem(
1398 coreconfigitem(
1399 b'format',
1399 b'format',
1400 b'exp-use-copies-side-data-changeset',
1400 b'exp-use-copies-side-data-changeset',
1401 default=False,
1401 default=False,
1402 experimental=True,
1402 experimental=True,
1403 )
1403 )
1404 coreconfigitem(
1404 coreconfigitem(
1405 b'format',
1405 b'format',
1406 b'use-share-safe',
1406 b'use-share-safe',
1407 default=False,
1407 default=False,
1408 )
1408 )
1409 coreconfigitem(
1409 coreconfigitem(
1410 b'format',
1410 b'format',
1411 b'internal-phase',
1411 b'internal-phase',
1412 default=False,
1412 default=False,
1413 experimental=True,
1413 experimental=True,
1414 )
1414 )
1415 coreconfigitem(
1415 coreconfigitem(
1416 b'fsmonitor',
1416 b'fsmonitor',
1417 b'warn_when_unused',
1417 b'warn_when_unused',
1418 default=True,
1418 default=True,
1419 )
1419 )
1420 coreconfigitem(
1420 coreconfigitem(
1421 b'fsmonitor',
1421 b'fsmonitor',
1422 b'warn_update_file_count',
1422 b'warn_update_file_count',
1423 default=50000,
1423 default=50000,
1424 )
1424 )
1425 coreconfigitem(
1425 coreconfigitem(
1426 b'fsmonitor',
1426 b'fsmonitor',
1427 b'warn_update_file_count_rust',
1427 b'warn_update_file_count_rust',
1428 default=400000,
1428 default=400000,
1429 )
1429 )
1430 coreconfigitem(
1430 coreconfigitem(
1431 b'help',
1431 b'help',
1432 br'hidden-command\..*',
1432 br'hidden-command\..*',
1433 default=False,
1433 default=False,
1434 generic=True,
1434 generic=True,
1435 )
1435 )
1436 coreconfigitem(
1436 coreconfigitem(
1437 b'help',
1437 b'help',
1438 br'hidden-topic\..*',
1438 br'hidden-topic\..*',
1439 default=False,
1439 default=False,
1440 generic=True,
1440 generic=True,
1441 )
1441 )
1442 coreconfigitem(
1442 coreconfigitem(
1443 b'hooks',
1443 b'hooks',
1444 b'[^:]*',
1444 b'[^:]*',
1445 default=dynamicdefault,
1445 default=dynamicdefault,
1446 generic=True,
1446 generic=True,
1447 )
1447 )
1448 coreconfigitem(
1448 coreconfigitem(
1449 b'hooks',
1449 b'hooks',
1450 b'.*:run-with-plain',
1450 b'.*:run-with-plain',
1451 default=True,
1451 default=True,
1452 generic=True,
1452 generic=True,
1453 )
1453 )
1454 coreconfigitem(
1454 coreconfigitem(
1455 b'hgweb-paths',
1455 b'hgweb-paths',
1456 b'.*',
1456 b'.*',
1457 default=list,
1457 default=list,
1458 generic=True,
1458 generic=True,
1459 )
1459 )
1460 coreconfigitem(
1460 coreconfigitem(
1461 b'hostfingerprints',
1461 b'hostfingerprints',
1462 b'.*',
1462 b'.*',
1463 default=list,
1463 default=list,
1464 generic=True,
1464 generic=True,
1465 )
1465 )
1466 coreconfigitem(
1466 coreconfigitem(
1467 b'hostsecurity',
1467 b'hostsecurity',
1468 b'ciphers',
1468 b'ciphers',
1469 default=None,
1469 default=None,
1470 )
1470 )
1471 coreconfigitem(
1471 coreconfigitem(
1472 b'hostsecurity',
1472 b'hostsecurity',
1473 b'minimumprotocol',
1473 b'minimumprotocol',
1474 default=dynamicdefault,
1474 default=dynamicdefault,
1475 )
1475 )
1476 coreconfigitem(
1476 coreconfigitem(
1477 b'hostsecurity',
1477 b'hostsecurity',
1478 b'.*:minimumprotocol$',
1478 b'.*:minimumprotocol$',
1479 default=dynamicdefault,
1479 default=dynamicdefault,
1480 generic=True,
1480 generic=True,
1481 )
1481 )
1482 coreconfigitem(
1482 coreconfigitem(
1483 b'hostsecurity',
1483 b'hostsecurity',
1484 b'.*:ciphers$',
1484 b'.*:ciphers$',
1485 default=dynamicdefault,
1485 default=dynamicdefault,
1486 generic=True,
1486 generic=True,
1487 )
1487 )
1488 coreconfigitem(
1488 coreconfigitem(
1489 b'hostsecurity',
1489 b'hostsecurity',
1490 b'.*:fingerprints$',
1490 b'.*:fingerprints$',
1491 default=list,
1491 default=list,
1492 generic=True,
1492 generic=True,
1493 )
1493 )
1494 coreconfigitem(
1494 coreconfigitem(
1495 b'hostsecurity',
1495 b'hostsecurity',
1496 b'.*:verifycertsfile$',
1496 b'.*:verifycertsfile$',
1497 default=None,
1497 default=None,
1498 generic=True,
1498 generic=True,
1499 )
1499 )
1500
1500
1501 coreconfigitem(
1501 coreconfigitem(
1502 b'http_proxy',
1502 b'http_proxy',
1503 b'always',
1503 b'always',
1504 default=False,
1504 default=False,
1505 )
1505 )
1506 coreconfigitem(
1506 coreconfigitem(
1507 b'http_proxy',
1507 b'http_proxy',
1508 b'host',
1508 b'host',
1509 default=None,
1509 default=None,
1510 )
1510 )
1511 coreconfigitem(
1511 coreconfigitem(
1512 b'http_proxy',
1512 b'http_proxy',
1513 b'no',
1513 b'no',
1514 default=list,
1514 default=list,
1515 )
1515 )
1516 coreconfigitem(
1516 coreconfigitem(
1517 b'http_proxy',
1517 b'http_proxy',
1518 b'passwd',
1518 b'passwd',
1519 default=None,
1519 default=None,
1520 )
1520 )
1521 coreconfigitem(
1521 coreconfigitem(
1522 b'http_proxy',
1522 b'http_proxy',
1523 b'user',
1523 b'user',
1524 default=None,
1524 default=None,
1525 )
1525 )
1526
1526
1527 coreconfigitem(
1527 coreconfigitem(
1528 b'http',
1528 b'http',
1529 b'timeout',
1529 b'timeout',
1530 default=None,
1530 default=None,
1531 )
1531 )
1532
1532
1533 coreconfigitem(
1533 coreconfigitem(
1534 b'logtoprocess',
1534 b'logtoprocess',
1535 b'commandexception',
1535 b'commandexception',
1536 default=None,
1536 default=None,
1537 )
1537 )
1538 coreconfigitem(
1538 coreconfigitem(
1539 b'logtoprocess',
1539 b'logtoprocess',
1540 b'commandfinish',
1540 b'commandfinish',
1541 default=None,
1541 default=None,
1542 )
1542 )
1543 coreconfigitem(
1543 coreconfigitem(
1544 b'logtoprocess',
1544 b'logtoprocess',
1545 b'command',
1545 b'command',
1546 default=None,
1546 default=None,
1547 )
1547 )
1548 coreconfigitem(
1548 coreconfigitem(
1549 b'logtoprocess',
1549 b'logtoprocess',
1550 b'develwarn',
1550 b'develwarn',
1551 default=None,
1551 default=None,
1552 )
1552 )
1553 coreconfigitem(
1553 coreconfigitem(
1554 b'logtoprocess',
1554 b'logtoprocess',
1555 b'uiblocked',
1555 b'uiblocked',
1556 default=None,
1556 default=None,
1557 )
1557 )
1558 coreconfigitem(
1558 coreconfigitem(
1559 b'merge',
1559 b'merge',
1560 b'checkunknown',
1560 b'checkunknown',
1561 default=b'abort',
1561 default=b'abort',
1562 )
1562 )
1563 coreconfigitem(
1563 coreconfigitem(
1564 b'merge',
1564 b'merge',
1565 b'checkignored',
1565 b'checkignored',
1566 default=b'abort',
1566 default=b'abort',
1567 )
1567 )
1568 coreconfigitem(
1568 coreconfigitem(
1569 b'experimental',
1569 b'experimental',
1570 b'merge.checkpathconflicts',
1570 b'merge.checkpathconflicts',
1571 default=False,
1571 default=False,
1572 )
1572 )
1573 coreconfigitem(
1573 coreconfigitem(
1574 b'merge',
1574 b'merge',
1575 b'followcopies',
1575 b'followcopies',
1576 default=True,
1576 default=True,
1577 )
1577 )
1578 coreconfigitem(
1578 coreconfigitem(
1579 b'merge',
1579 b'merge',
1580 b'on-failure',
1580 b'on-failure',
1581 default=b'continue',
1581 default=b'continue',
1582 )
1582 )
1583 coreconfigitem(
1583 coreconfigitem(
1584 b'merge',
1584 b'merge',
1585 b'preferancestor',
1585 b'preferancestor',
1586 default=lambda: [b'*'],
1586 default=lambda: [b'*'],
1587 experimental=True,
1587 experimental=True,
1588 )
1588 )
1589 coreconfigitem(
1589 coreconfigitem(
1590 b'merge',
1590 b'merge',
1591 b'strict-capability-check',
1591 b'strict-capability-check',
1592 default=False,
1592 default=False,
1593 )
1593 )
1594 coreconfigitem(
1594 coreconfigitem(
1595 b'merge-tools',
1595 b'merge-tools',
1596 b'.*',
1596 b'.*',
1597 default=None,
1597 default=None,
1598 generic=True,
1598 generic=True,
1599 )
1599 )
1600 coreconfigitem(
1600 coreconfigitem(
1601 b'merge-tools',
1601 b'merge-tools',
1602 br'.*\.args$',
1602 br'.*\.args$',
1603 default=b"$local $base $other",
1603 default=b"$local $base $other",
1604 generic=True,
1604 generic=True,
1605 priority=-1,
1605 priority=-1,
1606 )
1606 )
1607 coreconfigitem(
1607 coreconfigitem(
1608 b'merge-tools',
1608 b'merge-tools',
1609 br'.*\.binary$',
1609 br'.*\.binary$',
1610 default=False,
1610 default=False,
1611 generic=True,
1611 generic=True,
1612 priority=-1,
1612 priority=-1,
1613 )
1613 )
1614 coreconfigitem(
1614 coreconfigitem(
1615 b'merge-tools',
1615 b'merge-tools',
1616 br'.*\.check$',
1616 br'.*\.check$',
1617 default=list,
1617 default=list,
1618 generic=True,
1618 generic=True,
1619 priority=-1,
1619 priority=-1,
1620 )
1620 )
1621 coreconfigitem(
1621 coreconfigitem(
1622 b'merge-tools',
1622 b'merge-tools',
1623 br'.*\.checkchanged$',
1623 br'.*\.checkchanged$',
1624 default=False,
1624 default=False,
1625 generic=True,
1625 generic=True,
1626 priority=-1,
1626 priority=-1,
1627 )
1627 )
1628 coreconfigitem(
1628 coreconfigitem(
1629 b'merge-tools',
1629 b'merge-tools',
1630 br'.*\.executable$',
1630 br'.*\.executable$',
1631 default=dynamicdefault,
1631 default=dynamicdefault,
1632 generic=True,
1632 generic=True,
1633 priority=-1,
1633 priority=-1,
1634 )
1634 )
1635 coreconfigitem(
1635 coreconfigitem(
1636 b'merge-tools',
1636 b'merge-tools',
1637 br'.*\.fixeol$',
1637 br'.*\.fixeol$',
1638 default=False,
1638 default=False,
1639 generic=True,
1639 generic=True,
1640 priority=-1,
1640 priority=-1,
1641 )
1641 )
1642 coreconfigitem(
1642 coreconfigitem(
1643 b'merge-tools',
1643 b'merge-tools',
1644 br'.*\.gui$',
1644 br'.*\.gui$',
1645 default=False,
1645 default=False,
1646 generic=True,
1646 generic=True,
1647 priority=-1,
1647 priority=-1,
1648 )
1648 )
1649 coreconfigitem(
1649 coreconfigitem(
1650 b'merge-tools',
1650 b'merge-tools',
1651 br'.*\.mergemarkers$',
1651 br'.*\.mergemarkers$',
1652 default=b'basic',
1652 default=b'basic',
1653 generic=True,
1653 generic=True,
1654 priority=-1,
1654 priority=-1,
1655 )
1655 )
1656 coreconfigitem(
1656 coreconfigitem(
1657 b'merge-tools',
1657 b'merge-tools',
1658 br'.*\.mergemarkertemplate$',
1658 br'.*\.mergemarkertemplate$',
1659 default=dynamicdefault, # take from command-templates.mergemarker
1659 default=dynamicdefault, # take from command-templates.mergemarker
1660 generic=True,
1660 generic=True,
1661 priority=-1,
1661 priority=-1,
1662 )
1662 )
1663 coreconfigitem(
1663 coreconfigitem(
1664 b'merge-tools',
1664 b'merge-tools',
1665 br'.*\.priority$',
1665 br'.*\.priority$',
1666 default=0,
1666 default=0,
1667 generic=True,
1667 generic=True,
1668 priority=-1,
1668 priority=-1,
1669 )
1669 )
1670 coreconfigitem(
1670 coreconfigitem(
1671 b'merge-tools',
1671 b'merge-tools',
1672 br'.*\.premerge$',
1672 br'.*\.premerge$',
1673 default=dynamicdefault,
1673 default=dynamicdefault,
1674 generic=True,
1674 generic=True,
1675 priority=-1,
1675 priority=-1,
1676 )
1676 )
1677 coreconfigitem(
1677 coreconfigitem(
1678 b'merge-tools',
1678 b'merge-tools',
1679 br'.*\.symlink$',
1679 br'.*\.symlink$',
1680 default=False,
1680 default=False,
1681 generic=True,
1681 generic=True,
1682 priority=-1,
1682 priority=-1,
1683 )
1683 )
1684 coreconfigitem(
1684 coreconfigitem(
1685 b'pager',
1685 b'pager',
1686 b'attend-.*',
1686 b'attend-.*',
1687 default=dynamicdefault,
1687 default=dynamicdefault,
1688 generic=True,
1688 generic=True,
1689 )
1689 )
1690 coreconfigitem(
1690 coreconfigitem(
1691 b'pager',
1691 b'pager',
1692 b'ignore',
1692 b'ignore',
1693 default=list,
1693 default=list,
1694 )
1694 )
1695 coreconfigitem(
1695 coreconfigitem(
1696 b'pager',
1696 b'pager',
1697 b'pager',
1697 b'pager',
1698 default=dynamicdefault,
1698 default=dynamicdefault,
1699 )
1699 )
1700 coreconfigitem(
1700 coreconfigitem(
1701 b'patch',
1701 b'patch',
1702 b'eol',
1702 b'eol',
1703 default=b'strict',
1703 default=b'strict',
1704 )
1704 )
1705 coreconfigitem(
1705 coreconfigitem(
1706 b'patch',
1706 b'patch',
1707 b'fuzz',
1707 b'fuzz',
1708 default=2,
1708 default=2,
1709 )
1709 )
1710 coreconfigitem(
1710 coreconfigitem(
1711 b'paths',
1711 b'paths',
1712 b'default',
1712 b'default',
1713 default=None,
1713 default=None,
1714 )
1714 )
1715 coreconfigitem(
1715 coreconfigitem(
1716 b'paths',
1716 b'paths',
1717 b'default-push',
1717 b'default-push',
1718 default=None,
1718 default=None,
1719 )
1719 )
1720 coreconfigitem(
1720 coreconfigitem(
1721 b'paths',
1721 b'paths',
1722 b'.*',
1722 b'.*',
1723 default=None,
1723 default=None,
1724 generic=True,
1724 generic=True,
1725 )
1725 )
1726 coreconfigitem(
1726 coreconfigitem(
1727 b'phases',
1727 b'phases',
1728 b'checksubrepos',
1728 b'checksubrepos',
1729 default=b'follow',
1729 default=b'follow',
1730 )
1730 )
1731 coreconfigitem(
1731 coreconfigitem(
1732 b'phases',
1732 b'phases',
1733 b'new-commit',
1733 b'new-commit',
1734 default=b'draft',
1734 default=b'draft',
1735 )
1735 )
1736 coreconfigitem(
1736 coreconfigitem(
1737 b'phases',
1737 b'phases',
1738 b'publish',
1738 b'publish',
1739 default=True,
1739 default=True,
1740 )
1740 )
1741 coreconfigitem(
1741 coreconfigitem(
1742 b'profiling',
1742 b'profiling',
1743 b'enabled',
1743 b'enabled',
1744 default=False,
1744 default=False,
1745 )
1745 )
1746 coreconfigitem(
1746 coreconfigitem(
1747 b'profiling',
1747 b'profiling',
1748 b'format',
1748 b'format',
1749 default=b'text',
1749 default=b'text',
1750 )
1750 )
1751 coreconfigitem(
1751 coreconfigitem(
1752 b'profiling',
1752 b'profiling',
1753 b'freq',
1753 b'freq',
1754 default=1000,
1754 default=1000,
1755 )
1755 )
1756 coreconfigitem(
1756 coreconfigitem(
1757 b'profiling',
1757 b'profiling',
1758 b'limit',
1758 b'limit',
1759 default=30,
1759 default=30,
1760 )
1760 )
1761 coreconfigitem(
1761 coreconfigitem(
1762 b'profiling',
1762 b'profiling',
1763 b'nested',
1763 b'nested',
1764 default=0,
1764 default=0,
1765 )
1765 )
1766 coreconfigitem(
1766 coreconfigitem(
1767 b'profiling',
1767 b'profiling',
1768 b'output',
1768 b'output',
1769 default=None,
1769 default=None,
1770 )
1770 )
1771 coreconfigitem(
1771 coreconfigitem(
1772 b'profiling',
1772 b'profiling',
1773 b'showmax',
1773 b'showmax',
1774 default=0.999,
1774 default=0.999,
1775 )
1775 )
1776 coreconfigitem(
1776 coreconfigitem(
1777 b'profiling',
1777 b'profiling',
1778 b'showmin',
1778 b'showmin',
1779 default=dynamicdefault,
1779 default=dynamicdefault,
1780 )
1780 )
1781 coreconfigitem(
1781 coreconfigitem(
1782 b'profiling',
1782 b'profiling',
1783 b'showtime',
1783 b'showtime',
1784 default=True,
1784 default=True,
1785 )
1785 )
1786 coreconfigitem(
1786 coreconfigitem(
1787 b'profiling',
1787 b'profiling',
1788 b'sort',
1788 b'sort',
1789 default=b'inlinetime',
1789 default=b'inlinetime',
1790 )
1790 )
1791 coreconfigitem(
1791 coreconfigitem(
1792 b'profiling',
1792 b'profiling',
1793 b'statformat',
1793 b'statformat',
1794 default=b'hotpath',
1794 default=b'hotpath',
1795 )
1795 )
1796 coreconfigitem(
1796 coreconfigitem(
1797 b'profiling',
1797 b'profiling',
1798 b'time-track',
1798 b'time-track',
1799 default=dynamicdefault,
1799 default=dynamicdefault,
1800 )
1800 )
1801 coreconfigitem(
1801 coreconfigitem(
1802 b'profiling',
1802 b'profiling',
1803 b'type',
1803 b'type',
1804 default=b'stat',
1804 default=b'stat',
1805 )
1805 )
1806 coreconfigitem(
1806 coreconfigitem(
1807 b'progress',
1807 b'progress',
1808 b'assume-tty',
1808 b'assume-tty',
1809 default=False,
1809 default=False,
1810 )
1810 )
1811 coreconfigitem(
1811 coreconfigitem(
1812 b'progress',
1812 b'progress',
1813 b'changedelay',
1813 b'changedelay',
1814 default=1,
1814 default=1,
1815 )
1815 )
1816 coreconfigitem(
1816 coreconfigitem(
1817 b'progress',
1817 b'progress',
1818 b'clear-complete',
1818 b'clear-complete',
1819 default=True,
1819 default=True,
1820 )
1820 )
1821 coreconfigitem(
1821 coreconfigitem(
1822 b'progress',
1822 b'progress',
1823 b'debug',
1823 b'debug',
1824 default=False,
1824 default=False,
1825 )
1825 )
1826 coreconfigitem(
1826 coreconfigitem(
1827 b'progress',
1827 b'progress',
1828 b'delay',
1828 b'delay',
1829 default=3,
1829 default=3,
1830 )
1830 )
1831 coreconfigitem(
1831 coreconfigitem(
1832 b'progress',
1832 b'progress',
1833 b'disable',
1833 b'disable',
1834 default=False,
1834 default=False,
1835 )
1835 )
1836 coreconfigitem(
1836 coreconfigitem(
1837 b'progress',
1837 b'progress',
1838 b'estimateinterval',
1838 b'estimateinterval',
1839 default=60.0,
1839 default=60.0,
1840 )
1840 )
1841 coreconfigitem(
1841 coreconfigitem(
1842 b'progress',
1842 b'progress',
1843 b'format',
1843 b'format',
1844 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1844 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1845 )
1845 )
1846 coreconfigitem(
1846 coreconfigitem(
1847 b'progress',
1847 b'progress',
1848 b'refresh',
1848 b'refresh',
1849 default=0.1,
1849 default=0.1,
1850 )
1850 )
1851 coreconfigitem(
1851 coreconfigitem(
1852 b'progress',
1852 b'progress',
1853 b'width',
1853 b'width',
1854 default=dynamicdefault,
1854 default=dynamicdefault,
1855 )
1855 )
1856 coreconfigitem(
1856 coreconfigitem(
1857 b'pull',
1857 b'pull',
1858 b'confirm',
1858 b'confirm',
1859 default=False,
1859 default=False,
1860 )
1860 )
1861 coreconfigitem(
1861 coreconfigitem(
1862 b'push',
1862 b'push',
1863 b'pushvars.server',
1863 b'pushvars.server',
1864 default=False,
1864 default=False,
1865 )
1865 )
1866 coreconfigitem(
1866 coreconfigitem(
1867 b'rewrite',
1867 b'rewrite',
1868 b'backup-bundle',
1868 b'backup-bundle',
1869 default=True,
1869 default=True,
1870 alias=[(b'ui', b'history-editing-backup')],
1870 alias=[(b'ui', b'history-editing-backup')],
1871 )
1871 )
1872 coreconfigitem(
1872 coreconfigitem(
1873 b'rewrite',
1873 b'rewrite',
1874 b'update-timestamp',
1874 b'update-timestamp',
1875 default=False,
1875 default=False,
1876 )
1876 )
1877 coreconfigitem(
1877 coreconfigitem(
1878 b'rewrite',
1878 b'rewrite',
1879 b'empty-successor',
1879 b'empty-successor',
1880 default=b'skip',
1880 default=b'skip',
1881 experimental=True,
1881 experimental=True,
1882 )
1882 )
1883 coreconfigitem(
1883 coreconfigitem(
1884 b'storage',
1884 b'storage',
1885 b'new-repo-backend',
1885 b'new-repo-backend',
1886 default=b'revlogv1',
1886 default=b'revlogv1',
1887 experimental=True,
1887 experimental=True,
1888 )
1888 )
1889 coreconfigitem(
1889 coreconfigitem(
1890 b'storage',
1890 b'storage',
1891 b'revlog.optimize-delta-parent-choice',
1891 b'revlog.optimize-delta-parent-choice',
1892 default=True,
1892 default=True,
1893 alias=[(b'format', b'aggressivemergedeltas')],
1893 alias=[(b'format', b'aggressivemergedeltas')],
1894 )
1894 )
1895 coreconfigitem(
1896 b'storage',
1897 b'revlog.issue6528.fix-incoming',
1898 default=True,
1899 )
1895 # experimental as long as rust is experimental (or a C version is implemented)
1900 # experimental as long as rust is experimental (or a C version is implemented)
1896 coreconfigitem(
1901 coreconfigitem(
1897 b'storage',
1902 b'storage',
1898 b'revlog.persistent-nodemap.mmap',
1903 b'revlog.persistent-nodemap.mmap',
1899 default=True,
1904 default=True,
1900 )
1905 )
1901 # experimental as long as format.use-persistent-nodemap is.
1906 # experimental as long as format.use-persistent-nodemap is.
1902 coreconfigitem(
1907 coreconfigitem(
1903 b'storage',
1908 b'storage',
1904 b'revlog.persistent-nodemap.slow-path',
1909 b'revlog.persistent-nodemap.slow-path',
1905 default=b"abort",
1910 default=b"abort",
1906 )
1911 )
1907
1912
1908 coreconfigitem(
1913 coreconfigitem(
1909 b'storage',
1914 b'storage',
1910 b'revlog.reuse-external-delta',
1915 b'revlog.reuse-external-delta',
1911 default=True,
1916 default=True,
1912 )
1917 )
1913 coreconfigitem(
1918 coreconfigitem(
1914 b'storage',
1919 b'storage',
1915 b'revlog.reuse-external-delta-parent',
1920 b'revlog.reuse-external-delta-parent',
1916 default=None,
1921 default=None,
1917 )
1922 )
1918 coreconfigitem(
1923 coreconfigitem(
1919 b'storage',
1924 b'storage',
1920 b'revlog.zlib.level',
1925 b'revlog.zlib.level',
1921 default=None,
1926 default=None,
1922 )
1927 )
1923 coreconfigitem(
1928 coreconfigitem(
1924 b'storage',
1929 b'storage',
1925 b'revlog.zstd.level',
1930 b'revlog.zstd.level',
1926 default=None,
1931 default=None,
1927 )
1932 )
1928 coreconfigitem(
1933 coreconfigitem(
1929 b'server',
1934 b'server',
1930 b'bookmarks-pushkey-compat',
1935 b'bookmarks-pushkey-compat',
1931 default=True,
1936 default=True,
1932 )
1937 )
1933 coreconfigitem(
1938 coreconfigitem(
1934 b'server',
1939 b'server',
1935 b'bundle1',
1940 b'bundle1',
1936 default=True,
1941 default=True,
1937 )
1942 )
1938 coreconfigitem(
1943 coreconfigitem(
1939 b'server',
1944 b'server',
1940 b'bundle1gd',
1945 b'bundle1gd',
1941 default=None,
1946 default=None,
1942 )
1947 )
1943 coreconfigitem(
1948 coreconfigitem(
1944 b'server',
1949 b'server',
1945 b'bundle1.pull',
1950 b'bundle1.pull',
1946 default=None,
1951 default=None,
1947 )
1952 )
1948 coreconfigitem(
1953 coreconfigitem(
1949 b'server',
1954 b'server',
1950 b'bundle1gd.pull',
1955 b'bundle1gd.pull',
1951 default=None,
1956 default=None,
1952 )
1957 )
1953 coreconfigitem(
1958 coreconfigitem(
1954 b'server',
1959 b'server',
1955 b'bundle1.push',
1960 b'bundle1.push',
1956 default=None,
1961 default=None,
1957 )
1962 )
1958 coreconfigitem(
1963 coreconfigitem(
1959 b'server',
1964 b'server',
1960 b'bundle1gd.push',
1965 b'bundle1gd.push',
1961 default=None,
1966 default=None,
1962 )
1967 )
1963 coreconfigitem(
1968 coreconfigitem(
1964 b'server',
1969 b'server',
1965 b'bundle2.stream',
1970 b'bundle2.stream',
1966 default=True,
1971 default=True,
1967 alias=[(b'experimental', b'bundle2.stream')],
1972 alias=[(b'experimental', b'bundle2.stream')],
1968 )
1973 )
1969 coreconfigitem(
1974 coreconfigitem(
1970 b'server',
1975 b'server',
1971 b'compressionengines',
1976 b'compressionengines',
1972 default=list,
1977 default=list,
1973 )
1978 )
1974 coreconfigitem(
1979 coreconfigitem(
1975 b'server',
1980 b'server',
1976 b'concurrent-push-mode',
1981 b'concurrent-push-mode',
1977 default=b'check-related',
1982 default=b'check-related',
1978 )
1983 )
1979 coreconfigitem(
1984 coreconfigitem(
1980 b'server',
1985 b'server',
1981 b'disablefullbundle',
1986 b'disablefullbundle',
1982 default=False,
1987 default=False,
1983 )
1988 )
1984 coreconfigitem(
1989 coreconfigitem(
1985 b'server',
1990 b'server',
1986 b'maxhttpheaderlen',
1991 b'maxhttpheaderlen',
1987 default=1024,
1992 default=1024,
1988 )
1993 )
1989 coreconfigitem(
1994 coreconfigitem(
1990 b'server',
1995 b'server',
1991 b'pullbundle',
1996 b'pullbundle',
1992 default=False,
1997 default=False,
1993 )
1998 )
1994 coreconfigitem(
1999 coreconfigitem(
1995 b'server',
2000 b'server',
1996 b'preferuncompressed',
2001 b'preferuncompressed',
1997 default=False,
2002 default=False,
1998 )
2003 )
1999 coreconfigitem(
2004 coreconfigitem(
2000 b'server',
2005 b'server',
2001 b'streamunbundle',
2006 b'streamunbundle',
2002 default=False,
2007 default=False,
2003 )
2008 )
2004 coreconfigitem(
2009 coreconfigitem(
2005 b'server',
2010 b'server',
2006 b'uncompressed',
2011 b'uncompressed',
2007 default=True,
2012 default=True,
2008 )
2013 )
2009 coreconfigitem(
2014 coreconfigitem(
2010 b'server',
2015 b'server',
2011 b'uncompressedallowsecret',
2016 b'uncompressedallowsecret',
2012 default=False,
2017 default=False,
2013 )
2018 )
2014 coreconfigitem(
2019 coreconfigitem(
2015 b'server',
2020 b'server',
2016 b'view',
2021 b'view',
2017 default=b'served',
2022 default=b'served',
2018 )
2023 )
2019 coreconfigitem(
2024 coreconfigitem(
2020 b'server',
2025 b'server',
2021 b'validate',
2026 b'validate',
2022 default=False,
2027 default=False,
2023 )
2028 )
2024 coreconfigitem(
2029 coreconfigitem(
2025 b'server',
2030 b'server',
2026 b'zliblevel',
2031 b'zliblevel',
2027 default=-1,
2032 default=-1,
2028 )
2033 )
2029 coreconfigitem(
2034 coreconfigitem(
2030 b'server',
2035 b'server',
2031 b'zstdlevel',
2036 b'zstdlevel',
2032 default=3,
2037 default=3,
2033 )
2038 )
2034 coreconfigitem(
2039 coreconfigitem(
2035 b'share',
2040 b'share',
2036 b'pool',
2041 b'pool',
2037 default=None,
2042 default=None,
2038 )
2043 )
2039 coreconfigitem(
2044 coreconfigitem(
2040 b'share',
2045 b'share',
2041 b'poolnaming',
2046 b'poolnaming',
2042 default=b'identity',
2047 default=b'identity',
2043 )
2048 )
2044 coreconfigitem(
2049 coreconfigitem(
2045 b'share',
2050 b'share',
2046 b'safe-mismatch.source-not-safe',
2051 b'safe-mismatch.source-not-safe',
2047 default=b'abort',
2052 default=b'abort',
2048 )
2053 )
2049 coreconfigitem(
2054 coreconfigitem(
2050 b'share',
2055 b'share',
2051 b'safe-mismatch.source-safe',
2056 b'safe-mismatch.source-safe',
2052 default=b'abort',
2057 default=b'abort',
2053 )
2058 )
2054 coreconfigitem(
2059 coreconfigitem(
2055 b'share',
2060 b'share',
2056 b'safe-mismatch.source-not-safe.warn',
2061 b'safe-mismatch.source-not-safe.warn',
2057 default=True,
2062 default=True,
2058 )
2063 )
2059 coreconfigitem(
2064 coreconfigitem(
2060 b'share',
2065 b'share',
2061 b'safe-mismatch.source-safe.warn',
2066 b'safe-mismatch.source-safe.warn',
2062 default=True,
2067 default=True,
2063 )
2068 )
2064 coreconfigitem(
2069 coreconfigitem(
2065 b'shelve',
2070 b'shelve',
2066 b'maxbackups',
2071 b'maxbackups',
2067 default=10,
2072 default=10,
2068 )
2073 )
2069 coreconfigitem(
2074 coreconfigitem(
2070 b'smtp',
2075 b'smtp',
2071 b'host',
2076 b'host',
2072 default=None,
2077 default=None,
2073 )
2078 )
2074 coreconfigitem(
2079 coreconfigitem(
2075 b'smtp',
2080 b'smtp',
2076 b'local_hostname',
2081 b'local_hostname',
2077 default=None,
2082 default=None,
2078 )
2083 )
2079 coreconfigitem(
2084 coreconfigitem(
2080 b'smtp',
2085 b'smtp',
2081 b'password',
2086 b'password',
2082 default=None,
2087 default=None,
2083 )
2088 )
2084 coreconfigitem(
2089 coreconfigitem(
2085 b'smtp',
2090 b'smtp',
2086 b'port',
2091 b'port',
2087 default=dynamicdefault,
2092 default=dynamicdefault,
2088 )
2093 )
2089 coreconfigitem(
2094 coreconfigitem(
2090 b'smtp',
2095 b'smtp',
2091 b'tls',
2096 b'tls',
2092 default=b'none',
2097 default=b'none',
2093 )
2098 )
2094 coreconfigitem(
2099 coreconfigitem(
2095 b'smtp',
2100 b'smtp',
2096 b'username',
2101 b'username',
2097 default=None,
2102 default=None,
2098 )
2103 )
2099 coreconfigitem(
2104 coreconfigitem(
2100 b'sparse',
2105 b'sparse',
2101 b'missingwarning',
2106 b'missingwarning',
2102 default=True,
2107 default=True,
2103 experimental=True,
2108 experimental=True,
2104 )
2109 )
2105 coreconfigitem(
2110 coreconfigitem(
2106 b'subrepos',
2111 b'subrepos',
2107 b'allowed',
2112 b'allowed',
2108 default=dynamicdefault, # to make backporting simpler
2113 default=dynamicdefault, # to make backporting simpler
2109 )
2114 )
2110 coreconfigitem(
2115 coreconfigitem(
2111 b'subrepos',
2116 b'subrepos',
2112 b'hg:allowed',
2117 b'hg:allowed',
2113 default=dynamicdefault,
2118 default=dynamicdefault,
2114 )
2119 )
2115 coreconfigitem(
2120 coreconfigitem(
2116 b'subrepos',
2121 b'subrepos',
2117 b'git:allowed',
2122 b'git:allowed',
2118 default=dynamicdefault,
2123 default=dynamicdefault,
2119 )
2124 )
2120 coreconfigitem(
2125 coreconfigitem(
2121 b'subrepos',
2126 b'subrepos',
2122 b'svn:allowed',
2127 b'svn:allowed',
2123 default=dynamicdefault,
2128 default=dynamicdefault,
2124 )
2129 )
2125 coreconfigitem(
2130 coreconfigitem(
2126 b'templates',
2131 b'templates',
2127 b'.*',
2132 b'.*',
2128 default=None,
2133 default=None,
2129 generic=True,
2134 generic=True,
2130 )
2135 )
2131 coreconfigitem(
2136 coreconfigitem(
2132 b'templateconfig',
2137 b'templateconfig',
2133 b'.*',
2138 b'.*',
2134 default=dynamicdefault,
2139 default=dynamicdefault,
2135 generic=True,
2140 generic=True,
2136 )
2141 )
2137 coreconfigitem(
2142 coreconfigitem(
2138 b'trusted',
2143 b'trusted',
2139 b'groups',
2144 b'groups',
2140 default=list,
2145 default=list,
2141 )
2146 )
2142 coreconfigitem(
2147 coreconfigitem(
2143 b'trusted',
2148 b'trusted',
2144 b'users',
2149 b'users',
2145 default=list,
2150 default=list,
2146 )
2151 )
2147 coreconfigitem(
2152 coreconfigitem(
2148 b'ui',
2153 b'ui',
2149 b'_usedassubrepo',
2154 b'_usedassubrepo',
2150 default=False,
2155 default=False,
2151 )
2156 )
2152 coreconfigitem(
2157 coreconfigitem(
2153 b'ui',
2158 b'ui',
2154 b'allowemptycommit',
2159 b'allowemptycommit',
2155 default=False,
2160 default=False,
2156 )
2161 )
2157 coreconfigitem(
2162 coreconfigitem(
2158 b'ui',
2163 b'ui',
2159 b'archivemeta',
2164 b'archivemeta',
2160 default=True,
2165 default=True,
2161 )
2166 )
2162 coreconfigitem(
2167 coreconfigitem(
2163 b'ui',
2168 b'ui',
2164 b'askusername',
2169 b'askusername',
2165 default=False,
2170 default=False,
2166 )
2171 )
2167 coreconfigitem(
2172 coreconfigitem(
2168 b'ui',
2173 b'ui',
2169 b'available-memory',
2174 b'available-memory',
2170 default=None,
2175 default=None,
2171 )
2176 )
2172
2177
2173 coreconfigitem(
2178 coreconfigitem(
2174 b'ui',
2179 b'ui',
2175 b'clonebundlefallback',
2180 b'clonebundlefallback',
2176 default=False,
2181 default=False,
2177 )
2182 )
2178 coreconfigitem(
2183 coreconfigitem(
2179 b'ui',
2184 b'ui',
2180 b'clonebundleprefers',
2185 b'clonebundleprefers',
2181 default=list,
2186 default=list,
2182 )
2187 )
2183 coreconfigitem(
2188 coreconfigitem(
2184 b'ui',
2189 b'ui',
2185 b'clonebundles',
2190 b'clonebundles',
2186 default=True,
2191 default=True,
2187 )
2192 )
2188 coreconfigitem(
2193 coreconfigitem(
2189 b'ui',
2194 b'ui',
2190 b'color',
2195 b'color',
2191 default=b'auto',
2196 default=b'auto',
2192 )
2197 )
2193 coreconfigitem(
2198 coreconfigitem(
2194 b'ui',
2199 b'ui',
2195 b'commitsubrepos',
2200 b'commitsubrepos',
2196 default=False,
2201 default=False,
2197 )
2202 )
2198 coreconfigitem(
2203 coreconfigitem(
2199 b'ui',
2204 b'ui',
2200 b'debug',
2205 b'debug',
2201 default=False,
2206 default=False,
2202 )
2207 )
2203 coreconfigitem(
2208 coreconfigitem(
2204 b'ui',
2209 b'ui',
2205 b'debugger',
2210 b'debugger',
2206 default=None,
2211 default=None,
2207 )
2212 )
2208 coreconfigitem(
2213 coreconfigitem(
2209 b'ui',
2214 b'ui',
2210 b'editor',
2215 b'editor',
2211 default=dynamicdefault,
2216 default=dynamicdefault,
2212 )
2217 )
2213 coreconfigitem(
2218 coreconfigitem(
2214 b'ui',
2219 b'ui',
2215 b'detailed-exit-code',
2220 b'detailed-exit-code',
2216 default=False,
2221 default=False,
2217 experimental=True,
2222 experimental=True,
2218 )
2223 )
2219 coreconfigitem(
2224 coreconfigitem(
2220 b'ui',
2225 b'ui',
2221 b'fallbackencoding',
2226 b'fallbackencoding',
2222 default=None,
2227 default=None,
2223 )
2228 )
2224 coreconfigitem(
2229 coreconfigitem(
2225 b'ui',
2230 b'ui',
2226 b'forcecwd',
2231 b'forcecwd',
2227 default=None,
2232 default=None,
2228 )
2233 )
2229 coreconfigitem(
2234 coreconfigitem(
2230 b'ui',
2235 b'ui',
2231 b'forcemerge',
2236 b'forcemerge',
2232 default=None,
2237 default=None,
2233 )
2238 )
2234 coreconfigitem(
2239 coreconfigitem(
2235 b'ui',
2240 b'ui',
2236 b'formatdebug',
2241 b'formatdebug',
2237 default=False,
2242 default=False,
2238 )
2243 )
2239 coreconfigitem(
2244 coreconfigitem(
2240 b'ui',
2245 b'ui',
2241 b'formatjson',
2246 b'formatjson',
2242 default=False,
2247 default=False,
2243 )
2248 )
2244 coreconfigitem(
2249 coreconfigitem(
2245 b'ui',
2250 b'ui',
2246 b'formatted',
2251 b'formatted',
2247 default=None,
2252 default=None,
2248 )
2253 )
2249 coreconfigitem(
2254 coreconfigitem(
2250 b'ui',
2255 b'ui',
2251 b'interactive',
2256 b'interactive',
2252 default=None,
2257 default=None,
2253 )
2258 )
2254 coreconfigitem(
2259 coreconfigitem(
2255 b'ui',
2260 b'ui',
2256 b'interface',
2261 b'interface',
2257 default=None,
2262 default=None,
2258 )
2263 )
2259 coreconfigitem(
2264 coreconfigitem(
2260 b'ui',
2265 b'ui',
2261 b'interface.chunkselector',
2266 b'interface.chunkselector',
2262 default=None,
2267 default=None,
2263 )
2268 )
2264 coreconfigitem(
2269 coreconfigitem(
2265 b'ui',
2270 b'ui',
2266 b'large-file-limit',
2271 b'large-file-limit',
2267 default=10000000,
2272 default=10000000,
2268 )
2273 )
2269 coreconfigitem(
2274 coreconfigitem(
2270 b'ui',
2275 b'ui',
2271 b'logblockedtimes',
2276 b'logblockedtimes',
2272 default=False,
2277 default=False,
2273 )
2278 )
2274 coreconfigitem(
2279 coreconfigitem(
2275 b'ui',
2280 b'ui',
2276 b'merge',
2281 b'merge',
2277 default=None,
2282 default=None,
2278 )
2283 )
2279 coreconfigitem(
2284 coreconfigitem(
2280 b'ui',
2285 b'ui',
2281 b'mergemarkers',
2286 b'mergemarkers',
2282 default=b'basic',
2287 default=b'basic',
2283 )
2288 )
2284 coreconfigitem(
2289 coreconfigitem(
2285 b'ui',
2290 b'ui',
2286 b'message-output',
2291 b'message-output',
2287 default=b'stdio',
2292 default=b'stdio',
2288 )
2293 )
2289 coreconfigitem(
2294 coreconfigitem(
2290 b'ui',
2295 b'ui',
2291 b'nontty',
2296 b'nontty',
2292 default=False,
2297 default=False,
2293 )
2298 )
2294 coreconfigitem(
2299 coreconfigitem(
2295 b'ui',
2300 b'ui',
2296 b'origbackuppath',
2301 b'origbackuppath',
2297 default=None,
2302 default=None,
2298 )
2303 )
2299 coreconfigitem(
2304 coreconfigitem(
2300 b'ui',
2305 b'ui',
2301 b'paginate',
2306 b'paginate',
2302 default=True,
2307 default=True,
2303 )
2308 )
2304 coreconfigitem(
2309 coreconfigitem(
2305 b'ui',
2310 b'ui',
2306 b'patch',
2311 b'patch',
2307 default=None,
2312 default=None,
2308 )
2313 )
2309 coreconfigitem(
2314 coreconfigitem(
2310 b'ui',
2315 b'ui',
2311 b'portablefilenames',
2316 b'portablefilenames',
2312 default=b'warn',
2317 default=b'warn',
2313 )
2318 )
2314 coreconfigitem(
2319 coreconfigitem(
2315 b'ui',
2320 b'ui',
2316 b'promptecho',
2321 b'promptecho',
2317 default=False,
2322 default=False,
2318 )
2323 )
2319 coreconfigitem(
2324 coreconfigitem(
2320 b'ui',
2325 b'ui',
2321 b'quiet',
2326 b'quiet',
2322 default=False,
2327 default=False,
2323 )
2328 )
2324 coreconfigitem(
2329 coreconfigitem(
2325 b'ui',
2330 b'ui',
2326 b'quietbookmarkmove',
2331 b'quietbookmarkmove',
2327 default=False,
2332 default=False,
2328 )
2333 )
2329 coreconfigitem(
2334 coreconfigitem(
2330 b'ui',
2335 b'ui',
2331 b'relative-paths',
2336 b'relative-paths',
2332 default=b'legacy',
2337 default=b'legacy',
2333 )
2338 )
2334 coreconfigitem(
2339 coreconfigitem(
2335 b'ui',
2340 b'ui',
2336 b'remotecmd',
2341 b'remotecmd',
2337 default=b'hg',
2342 default=b'hg',
2338 )
2343 )
2339 coreconfigitem(
2344 coreconfigitem(
2340 b'ui',
2345 b'ui',
2341 b'report_untrusted',
2346 b'report_untrusted',
2342 default=True,
2347 default=True,
2343 )
2348 )
2344 coreconfigitem(
2349 coreconfigitem(
2345 b'ui',
2350 b'ui',
2346 b'rollback',
2351 b'rollback',
2347 default=True,
2352 default=True,
2348 )
2353 )
2349 coreconfigitem(
2354 coreconfigitem(
2350 b'ui',
2355 b'ui',
2351 b'signal-safe-lock',
2356 b'signal-safe-lock',
2352 default=True,
2357 default=True,
2353 )
2358 )
2354 coreconfigitem(
2359 coreconfigitem(
2355 b'ui',
2360 b'ui',
2356 b'slash',
2361 b'slash',
2357 default=False,
2362 default=False,
2358 )
2363 )
2359 coreconfigitem(
2364 coreconfigitem(
2360 b'ui',
2365 b'ui',
2361 b'ssh',
2366 b'ssh',
2362 default=b'ssh',
2367 default=b'ssh',
2363 )
2368 )
2364 coreconfigitem(
2369 coreconfigitem(
2365 b'ui',
2370 b'ui',
2366 b'ssherrorhint',
2371 b'ssherrorhint',
2367 default=None,
2372 default=None,
2368 )
2373 )
2369 coreconfigitem(
2374 coreconfigitem(
2370 b'ui',
2375 b'ui',
2371 b'statuscopies',
2376 b'statuscopies',
2372 default=False,
2377 default=False,
2373 )
2378 )
2374 coreconfigitem(
2379 coreconfigitem(
2375 b'ui',
2380 b'ui',
2376 b'strict',
2381 b'strict',
2377 default=False,
2382 default=False,
2378 )
2383 )
2379 coreconfigitem(
2384 coreconfigitem(
2380 b'ui',
2385 b'ui',
2381 b'style',
2386 b'style',
2382 default=b'',
2387 default=b'',
2383 )
2388 )
2384 coreconfigitem(
2389 coreconfigitem(
2385 b'ui',
2390 b'ui',
2386 b'supportcontact',
2391 b'supportcontact',
2387 default=None,
2392 default=None,
2388 )
2393 )
2389 coreconfigitem(
2394 coreconfigitem(
2390 b'ui',
2395 b'ui',
2391 b'textwidth',
2396 b'textwidth',
2392 default=78,
2397 default=78,
2393 )
2398 )
2394 coreconfigitem(
2399 coreconfigitem(
2395 b'ui',
2400 b'ui',
2396 b'timeout',
2401 b'timeout',
2397 default=b'600',
2402 default=b'600',
2398 )
2403 )
2399 coreconfigitem(
2404 coreconfigitem(
2400 b'ui',
2405 b'ui',
2401 b'timeout.warn',
2406 b'timeout.warn',
2402 default=0,
2407 default=0,
2403 )
2408 )
2404 coreconfigitem(
2409 coreconfigitem(
2405 b'ui',
2410 b'ui',
2406 b'timestamp-output',
2411 b'timestamp-output',
2407 default=False,
2412 default=False,
2408 )
2413 )
2409 coreconfigitem(
2414 coreconfigitem(
2410 b'ui',
2415 b'ui',
2411 b'traceback',
2416 b'traceback',
2412 default=False,
2417 default=False,
2413 )
2418 )
2414 coreconfigitem(
2419 coreconfigitem(
2415 b'ui',
2420 b'ui',
2416 b'tweakdefaults',
2421 b'tweakdefaults',
2417 default=False,
2422 default=False,
2418 )
2423 )
2419 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
2424 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
2420 coreconfigitem(
2425 coreconfigitem(
2421 b'ui',
2426 b'ui',
2422 b'verbose',
2427 b'verbose',
2423 default=False,
2428 default=False,
2424 )
2429 )
2425 coreconfigitem(
2430 coreconfigitem(
2426 b'verify',
2431 b'verify',
2427 b'skipflags',
2432 b'skipflags',
2428 default=None,
2433 default=None,
2429 )
2434 )
2430 coreconfigitem(
2435 coreconfigitem(
2431 b'web',
2436 b'web',
2432 b'allowbz2',
2437 b'allowbz2',
2433 default=False,
2438 default=False,
2434 )
2439 )
2435 coreconfigitem(
2440 coreconfigitem(
2436 b'web',
2441 b'web',
2437 b'allowgz',
2442 b'allowgz',
2438 default=False,
2443 default=False,
2439 )
2444 )
2440 coreconfigitem(
2445 coreconfigitem(
2441 b'web',
2446 b'web',
2442 b'allow-pull',
2447 b'allow-pull',
2443 alias=[(b'web', b'allowpull')],
2448 alias=[(b'web', b'allowpull')],
2444 default=True,
2449 default=True,
2445 )
2450 )
2446 coreconfigitem(
2451 coreconfigitem(
2447 b'web',
2452 b'web',
2448 b'allow-push',
2453 b'allow-push',
2449 alias=[(b'web', b'allow_push')],
2454 alias=[(b'web', b'allow_push')],
2450 default=list,
2455 default=list,
2451 )
2456 )
2452 coreconfigitem(
2457 coreconfigitem(
2453 b'web',
2458 b'web',
2454 b'allowzip',
2459 b'allowzip',
2455 default=False,
2460 default=False,
2456 )
2461 )
2457 coreconfigitem(
2462 coreconfigitem(
2458 b'web',
2463 b'web',
2459 b'archivesubrepos',
2464 b'archivesubrepos',
2460 default=False,
2465 default=False,
2461 )
2466 )
2462 coreconfigitem(
2467 coreconfigitem(
2463 b'web',
2468 b'web',
2464 b'cache',
2469 b'cache',
2465 default=True,
2470 default=True,
2466 )
2471 )
2467 coreconfigitem(
2472 coreconfigitem(
2468 b'web',
2473 b'web',
2469 b'comparisoncontext',
2474 b'comparisoncontext',
2470 default=5,
2475 default=5,
2471 )
2476 )
2472 coreconfigitem(
2477 coreconfigitem(
2473 b'web',
2478 b'web',
2474 b'contact',
2479 b'contact',
2475 default=None,
2480 default=None,
2476 )
2481 )
2477 coreconfigitem(
2482 coreconfigitem(
2478 b'web',
2483 b'web',
2479 b'deny_push',
2484 b'deny_push',
2480 default=list,
2485 default=list,
2481 )
2486 )
2482 coreconfigitem(
2487 coreconfigitem(
2483 b'web',
2488 b'web',
2484 b'guessmime',
2489 b'guessmime',
2485 default=False,
2490 default=False,
2486 )
2491 )
2487 coreconfigitem(
2492 coreconfigitem(
2488 b'web',
2493 b'web',
2489 b'hidden',
2494 b'hidden',
2490 default=False,
2495 default=False,
2491 )
2496 )
2492 coreconfigitem(
2497 coreconfigitem(
2493 b'web',
2498 b'web',
2494 b'labels',
2499 b'labels',
2495 default=list,
2500 default=list,
2496 )
2501 )
2497 coreconfigitem(
2502 coreconfigitem(
2498 b'web',
2503 b'web',
2499 b'logoimg',
2504 b'logoimg',
2500 default=b'hglogo.png',
2505 default=b'hglogo.png',
2501 )
2506 )
2502 coreconfigitem(
2507 coreconfigitem(
2503 b'web',
2508 b'web',
2504 b'logourl',
2509 b'logourl',
2505 default=b'https://mercurial-scm.org/',
2510 default=b'https://mercurial-scm.org/',
2506 )
2511 )
2507 coreconfigitem(
2512 coreconfigitem(
2508 b'web',
2513 b'web',
2509 b'accesslog',
2514 b'accesslog',
2510 default=b'-',
2515 default=b'-',
2511 )
2516 )
2512 coreconfigitem(
2517 coreconfigitem(
2513 b'web',
2518 b'web',
2514 b'address',
2519 b'address',
2515 default=b'',
2520 default=b'',
2516 )
2521 )
2517 coreconfigitem(
2522 coreconfigitem(
2518 b'web',
2523 b'web',
2519 b'allow-archive',
2524 b'allow-archive',
2520 alias=[(b'web', b'allow_archive')],
2525 alias=[(b'web', b'allow_archive')],
2521 default=list,
2526 default=list,
2522 )
2527 )
2523 coreconfigitem(
2528 coreconfigitem(
2524 b'web',
2529 b'web',
2525 b'allow_read',
2530 b'allow_read',
2526 default=list,
2531 default=list,
2527 )
2532 )
2528 coreconfigitem(
2533 coreconfigitem(
2529 b'web',
2534 b'web',
2530 b'baseurl',
2535 b'baseurl',
2531 default=None,
2536 default=None,
2532 )
2537 )
2533 coreconfigitem(
2538 coreconfigitem(
2534 b'web',
2539 b'web',
2535 b'cacerts',
2540 b'cacerts',
2536 default=None,
2541 default=None,
2537 )
2542 )
2538 coreconfigitem(
2543 coreconfigitem(
2539 b'web',
2544 b'web',
2540 b'certificate',
2545 b'certificate',
2541 default=None,
2546 default=None,
2542 )
2547 )
2543 coreconfigitem(
2548 coreconfigitem(
2544 b'web',
2549 b'web',
2545 b'collapse',
2550 b'collapse',
2546 default=False,
2551 default=False,
2547 )
2552 )
2548 coreconfigitem(
2553 coreconfigitem(
2549 b'web',
2554 b'web',
2550 b'csp',
2555 b'csp',
2551 default=None,
2556 default=None,
2552 )
2557 )
2553 coreconfigitem(
2558 coreconfigitem(
2554 b'web',
2559 b'web',
2555 b'deny_read',
2560 b'deny_read',
2556 default=list,
2561 default=list,
2557 )
2562 )
2558 coreconfigitem(
2563 coreconfigitem(
2559 b'web',
2564 b'web',
2560 b'descend',
2565 b'descend',
2561 default=True,
2566 default=True,
2562 )
2567 )
2563 coreconfigitem(
2568 coreconfigitem(
2564 b'web',
2569 b'web',
2565 b'description',
2570 b'description',
2566 default=b"",
2571 default=b"",
2567 )
2572 )
2568 coreconfigitem(
2573 coreconfigitem(
2569 b'web',
2574 b'web',
2570 b'encoding',
2575 b'encoding',
2571 default=lambda: encoding.encoding,
2576 default=lambda: encoding.encoding,
2572 )
2577 )
2573 coreconfigitem(
2578 coreconfigitem(
2574 b'web',
2579 b'web',
2575 b'errorlog',
2580 b'errorlog',
2576 default=b'-',
2581 default=b'-',
2577 )
2582 )
2578 coreconfigitem(
2583 coreconfigitem(
2579 b'web',
2584 b'web',
2580 b'ipv6',
2585 b'ipv6',
2581 default=False,
2586 default=False,
2582 )
2587 )
2583 coreconfigitem(
2588 coreconfigitem(
2584 b'web',
2589 b'web',
2585 b'maxchanges',
2590 b'maxchanges',
2586 default=10,
2591 default=10,
2587 )
2592 )
2588 coreconfigitem(
2593 coreconfigitem(
2589 b'web',
2594 b'web',
2590 b'maxfiles',
2595 b'maxfiles',
2591 default=10,
2596 default=10,
2592 )
2597 )
2593 coreconfigitem(
2598 coreconfigitem(
2594 b'web',
2599 b'web',
2595 b'maxshortchanges',
2600 b'maxshortchanges',
2596 default=60,
2601 default=60,
2597 )
2602 )
2598 coreconfigitem(
2603 coreconfigitem(
2599 b'web',
2604 b'web',
2600 b'motd',
2605 b'motd',
2601 default=b'',
2606 default=b'',
2602 )
2607 )
2603 coreconfigitem(
2608 coreconfigitem(
2604 b'web',
2609 b'web',
2605 b'name',
2610 b'name',
2606 default=dynamicdefault,
2611 default=dynamicdefault,
2607 )
2612 )
2608 coreconfigitem(
2613 coreconfigitem(
2609 b'web',
2614 b'web',
2610 b'port',
2615 b'port',
2611 default=8000,
2616 default=8000,
2612 )
2617 )
2613 coreconfigitem(
2618 coreconfigitem(
2614 b'web',
2619 b'web',
2615 b'prefix',
2620 b'prefix',
2616 default=b'',
2621 default=b'',
2617 )
2622 )
2618 coreconfigitem(
2623 coreconfigitem(
2619 b'web',
2624 b'web',
2620 b'push_ssl',
2625 b'push_ssl',
2621 default=True,
2626 default=True,
2622 )
2627 )
2623 coreconfigitem(
2628 coreconfigitem(
2624 b'web',
2629 b'web',
2625 b'refreshinterval',
2630 b'refreshinterval',
2626 default=20,
2631 default=20,
2627 )
2632 )
2628 coreconfigitem(
2633 coreconfigitem(
2629 b'web',
2634 b'web',
2630 b'server-header',
2635 b'server-header',
2631 default=None,
2636 default=None,
2632 )
2637 )
2633 coreconfigitem(
2638 coreconfigitem(
2634 b'web',
2639 b'web',
2635 b'static',
2640 b'static',
2636 default=None,
2641 default=None,
2637 )
2642 )
2638 coreconfigitem(
2643 coreconfigitem(
2639 b'web',
2644 b'web',
2640 b'staticurl',
2645 b'staticurl',
2641 default=None,
2646 default=None,
2642 )
2647 )
2643 coreconfigitem(
2648 coreconfigitem(
2644 b'web',
2649 b'web',
2645 b'stripes',
2650 b'stripes',
2646 default=1,
2651 default=1,
2647 )
2652 )
2648 coreconfigitem(
2653 coreconfigitem(
2649 b'web',
2654 b'web',
2650 b'style',
2655 b'style',
2651 default=b'paper',
2656 default=b'paper',
2652 )
2657 )
2653 coreconfigitem(
2658 coreconfigitem(
2654 b'web',
2659 b'web',
2655 b'templates',
2660 b'templates',
2656 default=None,
2661 default=None,
2657 )
2662 )
2658 coreconfigitem(
2663 coreconfigitem(
2659 b'web',
2664 b'web',
2660 b'view',
2665 b'view',
2661 default=b'served',
2666 default=b'served',
2662 experimental=True,
2667 experimental=True,
2663 )
2668 )
2664 coreconfigitem(
2669 coreconfigitem(
2665 b'worker',
2670 b'worker',
2666 b'backgroundclose',
2671 b'backgroundclose',
2667 default=dynamicdefault,
2672 default=dynamicdefault,
2668 )
2673 )
2669 # Windows defaults to a limit of 512 open files. A buffer of 128
2674 # Windows defaults to a limit of 512 open files. A buffer of 128
2670 # should give us enough headway.
2675 # should give us enough headway.
2671 coreconfigitem(
2676 coreconfigitem(
2672 b'worker',
2677 b'worker',
2673 b'backgroundclosemaxqueue',
2678 b'backgroundclosemaxqueue',
2674 default=384,
2679 default=384,
2675 )
2680 )
2676 coreconfigitem(
2681 coreconfigitem(
2677 b'worker',
2682 b'worker',
2678 b'backgroundcloseminfilecount',
2683 b'backgroundcloseminfilecount',
2679 default=2048,
2684 default=2048,
2680 )
2685 )
2681 coreconfigitem(
2686 coreconfigitem(
2682 b'worker',
2687 b'worker',
2683 b'backgroundclosethreadcount',
2688 b'backgroundclosethreadcount',
2684 default=4,
2689 default=4,
2685 )
2690 )
2686 coreconfigitem(
2691 coreconfigitem(
2687 b'worker',
2692 b'worker',
2688 b'enabled',
2693 b'enabled',
2689 default=True,
2694 default=True,
2690 )
2695 )
2691 coreconfigitem(
2696 coreconfigitem(
2692 b'worker',
2697 b'worker',
2693 b'numcpus',
2698 b'numcpus',
2694 default=None,
2699 default=None,
2695 )
2700 )
2696
2701
2697 # Rebase related configuration moved to core because other extension are doing
2702 # Rebase related configuration moved to core because other extension are doing
2698 # strange things. For example, shelve import the extensions to reuse some bit
2703 # strange things. For example, shelve import the extensions to reuse some bit
2699 # without formally loading it.
2704 # without formally loading it.
2700 coreconfigitem(
2705 coreconfigitem(
2701 b'commands',
2706 b'commands',
2702 b'rebase.requiredest',
2707 b'rebase.requiredest',
2703 default=False,
2708 default=False,
2704 )
2709 )
2705 coreconfigitem(
2710 coreconfigitem(
2706 b'experimental',
2711 b'experimental',
2707 b'rebaseskipobsolete',
2712 b'rebaseskipobsolete',
2708 default=True,
2713 default=True,
2709 )
2714 )
2710 coreconfigitem(
2715 coreconfigitem(
2711 b'rebase',
2716 b'rebase',
2712 b'singletransaction',
2717 b'singletransaction',
2713 default=False,
2718 default=False,
2714 )
2719 )
2715 coreconfigitem(
2720 coreconfigitem(
2716 b'rebase',
2721 b'rebase',
2717 b'experimental.inmemory',
2722 b'experimental.inmemory',
2718 default=False,
2723 default=False,
2719 )
2724 )
@@ -1,291 +1,294 b''
1 # filelog.py - file history class for mercurial
1 # filelog.py - file history class for mercurial
2 #
2 #
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from .i18n import _
10 from .i18n import _
11 from .node import nullrev
11 from .node import nullrev
12 from . import (
12 from . import (
13 error,
13 error,
14 revlog,
14 revlog,
15 )
15 )
16 from .interfaces import (
16 from .interfaces import (
17 repository,
17 repository,
18 util as interfaceutil,
18 util as interfaceutil,
19 )
19 )
20 from .utils import storageutil
20 from .utils import storageutil
21 from .revlogutils import (
21 from .revlogutils import (
22 constants as revlog_constants,
22 constants as revlog_constants,
23 rewrite,
23 rewrite,
24 )
24 )
25
25
26
26
27 @interfaceutil.implementer(repository.ifilestorage)
27 @interfaceutil.implementer(repository.ifilestorage)
28 class filelog(object):
28 class filelog(object):
29 def __init__(self, opener, path):
29 def __init__(self, opener, path):
30 self._revlog = revlog.revlog(
30 self._revlog = revlog.revlog(
31 opener,
31 opener,
32 # XXX should use the unencoded path
32 # XXX should use the unencoded path
33 target=(revlog_constants.KIND_FILELOG, path),
33 target=(revlog_constants.KIND_FILELOG, path),
34 radix=b'/'.join((b'data', path)),
34 radix=b'/'.join((b'data', path)),
35 censorable=True,
35 censorable=True,
36 )
36 )
37 # Full name of the user visible file, relative to the repository root.
37 # Full name of the user visible file, relative to the repository root.
38 # Used by LFS.
38 # Used by LFS.
39 self._revlog.filename = path
39 self._revlog.filename = path
40 self.nullid = self._revlog.nullid
40 self.nullid = self._revlog.nullid
41 opts = opener.options
42 self._fix_issue6528 = opts.get(b'issue6528.fix-incoming', True)
41
43
42 def __len__(self):
44 def __len__(self):
43 return len(self._revlog)
45 return len(self._revlog)
44
46
45 def __iter__(self):
47 def __iter__(self):
46 return self._revlog.__iter__()
48 return self._revlog.__iter__()
47
49
48 def hasnode(self, node):
50 def hasnode(self, node):
49 if node in (self.nullid, nullrev):
51 if node in (self.nullid, nullrev):
50 return False
52 return False
51
53
52 try:
54 try:
53 self._revlog.rev(node)
55 self._revlog.rev(node)
54 return True
56 return True
55 except (TypeError, ValueError, IndexError, error.LookupError):
57 except (TypeError, ValueError, IndexError, error.LookupError):
56 return False
58 return False
57
59
58 def revs(self, start=0, stop=None):
60 def revs(self, start=0, stop=None):
59 return self._revlog.revs(start=start, stop=stop)
61 return self._revlog.revs(start=start, stop=stop)
60
62
61 def parents(self, node):
63 def parents(self, node):
62 return self._revlog.parents(node)
64 return self._revlog.parents(node)
63
65
64 def parentrevs(self, rev):
66 def parentrevs(self, rev):
65 return self._revlog.parentrevs(rev)
67 return self._revlog.parentrevs(rev)
66
68
67 def rev(self, node):
69 def rev(self, node):
68 return self._revlog.rev(node)
70 return self._revlog.rev(node)
69
71
70 def node(self, rev):
72 def node(self, rev):
71 return self._revlog.node(rev)
73 return self._revlog.node(rev)
72
74
73 def lookup(self, node):
75 def lookup(self, node):
74 return storageutil.fileidlookup(
76 return storageutil.fileidlookup(
75 self._revlog, node, self._revlog.display_id
77 self._revlog, node, self._revlog.display_id
76 )
78 )
77
79
78 def linkrev(self, rev):
80 def linkrev(self, rev):
79 return self._revlog.linkrev(rev)
81 return self._revlog.linkrev(rev)
80
82
81 def commonancestorsheads(self, node1, node2):
83 def commonancestorsheads(self, node1, node2):
82 return self._revlog.commonancestorsheads(node1, node2)
84 return self._revlog.commonancestorsheads(node1, node2)
83
85
84 # Used by dagop.blockdescendants().
86 # Used by dagop.blockdescendants().
85 def descendants(self, revs):
87 def descendants(self, revs):
86 return self._revlog.descendants(revs)
88 return self._revlog.descendants(revs)
87
89
88 def heads(self, start=None, stop=None):
90 def heads(self, start=None, stop=None):
89 return self._revlog.heads(start, stop)
91 return self._revlog.heads(start, stop)
90
92
91 # Used by hgweb, children extension.
93 # Used by hgweb, children extension.
92 def children(self, node):
94 def children(self, node):
93 return self._revlog.children(node)
95 return self._revlog.children(node)
94
96
95 def iscensored(self, rev):
97 def iscensored(self, rev):
96 return self._revlog.iscensored(rev)
98 return self._revlog.iscensored(rev)
97
99
98 def revision(self, node, _df=None, raw=False):
100 def revision(self, node, _df=None, raw=False):
99 return self._revlog.revision(node, _df=_df, raw=raw)
101 return self._revlog.revision(node, _df=_df, raw=raw)
100
102
101 def rawdata(self, node, _df=None):
103 def rawdata(self, node, _df=None):
102 return self._revlog.rawdata(node, _df=_df)
104 return self._revlog.rawdata(node, _df=_df)
103
105
104 def emitrevisions(
106 def emitrevisions(
105 self,
107 self,
106 nodes,
108 nodes,
107 nodesorder=None,
109 nodesorder=None,
108 revisiondata=False,
110 revisiondata=False,
109 assumehaveparentrevisions=False,
111 assumehaveparentrevisions=False,
110 deltamode=repository.CG_DELTAMODE_STD,
112 deltamode=repository.CG_DELTAMODE_STD,
111 sidedata_helpers=None,
113 sidedata_helpers=None,
112 ):
114 ):
113 return self._revlog.emitrevisions(
115 return self._revlog.emitrevisions(
114 nodes,
116 nodes,
115 nodesorder=nodesorder,
117 nodesorder=nodesorder,
116 revisiondata=revisiondata,
118 revisiondata=revisiondata,
117 assumehaveparentrevisions=assumehaveparentrevisions,
119 assumehaveparentrevisions=assumehaveparentrevisions,
118 deltamode=deltamode,
120 deltamode=deltamode,
119 sidedata_helpers=sidedata_helpers,
121 sidedata_helpers=sidedata_helpers,
120 )
122 )
121
123
122 def addrevision(
124 def addrevision(
123 self,
125 self,
124 revisiondata,
126 revisiondata,
125 transaction,
127 transaction,
126 linkrev,
128 linkrev,
127 p1,
129 p1,
128 p2,
130 p2,
129 node=None,
131 node=None,
130 flags=revlog.REVIDX_DEFAULT_FLAGS,
132 flags=revlog.REVIDX_DEFAULT_FLAGS,
131 cachedelta=None,
133 cachedelta=None,
132 ):
134 ):
133 return self._revlog.addrevision(
135 return self._revlog.addrevision(
134 revisiondata,
136 revisiondata,
135 transaction,
137 transaction,
136 linkrev,
138 linkrev,
137 p1,
139 p1,
138 p2,
140 p2,
139 node=node,
141 node=node,
140 flags=flags,
142 flags=flags,
141 cachedelta=cachedelta,
143 cachedelta=cachedelta,
142 )
144 )
143
145
144 def addgroup(
146 def addgroup(
145 self,
147 self,
146 deltas,
148 deltas,
147 linkmapper,
149 linkmapper,
148 transaction,
150 transaction,
149 addrevisioncb=None,
151 addrevisioncb=None,
150 duplicaterevisioncb=None,
152 duplicaterevisioncb=None,
151 maybemissingparents=False,
153 maybemissingparents=False,
152 ):
154 ):
153 if maybemissingparents:
155 if maybemissingparents:
154 raise error.Abort(
156 raise error.Abort(
155 _(
157 _(
156 b'revlog storage does not support missing '
158 b'revlog storage does not support missing '
157 b'parents write mode'
159 b'parents write mode'
158 )
160 )
159 )
161 )
160
162
161 with self._revlog._writing(transaction):
163 with self._revlog._writing(transaction):
162
164
163 deltas = rewrite.filter_delta_issue6528(self._revlog, deltas)
165 if self._fix_issue6528:
166 deltas = rewrite.filter_delta_issue6528(self._revlog, deltas)
164
167
165 return self._revlog.addgroup(
168 return self._revlog.addgroup(
166 deltas,
169 deltas,
167 linkmapper,
170 linkmapper,
168 transaction,
171 transaction,
169 addrevisioncb=addrevisioncb,
172 addrevisioncb=addrevisioncb,
170 duplicaterevisioncb=duplicaterevisioncb,
173 duplicaterevisioncb=duplicaterevisioncb,
171 )
174 )
172
175
173 def getstrippoint(self, minlink):
176 def getstrippoint(self, minlink):
174 return self._revlog.getstrippoint(minlink)
177 return self._revlog.getstrippoint(minlink)
175
178
176 def strip(self, minlink, transaction):
179 def strip(self, minlink, transaction):
177 return self._revlog.strip(minlink, transaction)
180 return self._revlog.strip(minlink, transaction)
178
181
179 def censorrevision(self, tr, node, tombstone=b''):
182 def censorrevision(self, tr, node, tombstone=b''):
180 return self._revlog.censorrevision(tr, node, tombstone=tombstone)
183 return self._revlog.censorrevision(tr, node, tombstone=tombstone)
181
184
182 def files(self):
185 def files(self):
183 return self._revlog.files()
186 return self._revlog.files()
184
187
185 def read(self, node):
188 def read(self, node):
186 return storageutil.filtermetadata(self.revision(node))
189 return storageutil.filtermetadata(self.revision(node))
187
190
188 def add(self, text, meta, transaction, link, p1=None, p2=None):
191 def add(self, text, meta, transaction, link, p1=None, p2=None):
189 if meta or text.startswith(b'\1\n'):
192 if meta or text.startswith(b'\1\n'):
190 text = storageutil.packmeta(meta, text)
193 text = storageutil.packmeta(meta, text)
191 rev = self.addrevision(text, transaction, link, p1, p2)
194 rev = self.addrevision(text, transaction, link, p1, p2)
192 return self.node(rev)
195 return self.node(rev)
193
196
194 def renamed(self, node):
197 def renamed(self, node):
195 return storageutil.filerevisioncopied(self, node)
198 return storageutil.filerevisioncopied(self, node)
196
199
197 def size(self, rev):
200 def size(self, rev):
198 """return the size of a given revision"""
201 """return the size of a given revision"""
199
202
200 # for revisions with renames, we have to go the slow way
203 # for revisions with renames, we have to go the slow way
201 node = self.node(rev)
204 node = self.node(rev)
202 if self.renamed(node):
205 if self.renamed(node):
203 return len(self.read(node))
206 return len(self.read(node))
204 if self.iscensored(rev):
207 if self.iscensored(rev):
205 return 0
208 return 0
206
209
207 # XXX if self.read(node).startswith("\1\n"), this returns (size+4)
210 # XXX if self.read(node).startswith("\1\n"), this returns (size+4)
208 return self._revlog.size(rev)
211 return self._revlog.size(rev)
209
212
210 def cmp(self, node, text):
213 def cmp(self, node, text):
211 """compare text with a given file revision
214 """compare text with a given file revision
212
215
213 returns True if text is different than what is stored.
216 returns True if text is different than what is stored.
214 """
217 """
215 return not storageutil.filedataequivalent(self, node, text)
218 return not storageutil.filedataequivalent(self, node, text)
216
219
217 def verifyintegrity(self, state):
220 def verifyintegrity(self, state):
218 return self._revlog.verifyintegrity(state)
221 return self._revlog.verifyintegrity(state)
219
222
220 def storageinfo(
223 def storageinfo(
221 self,
224 self,
222 exclusivefiles=False,
225 exclusivefiles=False,
223 sharedfiles=False,
226 sharedfiles=False,
224 revisionscount=False,
227 revisionscount=False,
225 trackedsize=False,
228 trackedsize=False,
226 storedsize=False,
229 storedsize=False,
227 ):
230 ):
228 return self._revlog.storageinfo(
231 return self._revlog.storageinfo(
229 exclusivefiles=exclusivefiles,
232 exclusivefiles=exclusivefiles,
230 sharedfiles=sharedfiles,
233 sharedfiles=sharedfiles,
231 revisionscount=revisionscount,
234 revisionscount=revisionscount,
232 trackedsize=trackedsize,
235 trackedsize=trackedsize,
233 storedsize=storedsize,
236 storedsize=storedsize,
234 )
237 )
235
238
236 # Used by repo upgrade.
239 # Used by repo upgrade.
237 def clone(self, tr, destrevlog, **kwargs):
240 def clone(self, tr, destrevlog, **kwargs):
238 if not isinstance(destrevlog, filelog):
241 if not isinstance(destrevlog, filelog):
239 raise error.ProgrammingError(b'expected filelog to clone()')
242 raise error.ProgrammingError(b'expected filelog to clone()')
240
243
241 return self._revlog.clone(tr, destrevlog._revlog, **kwargs)
244 return self._revlog.clone(tr, destrevlog._revlog, **kwargs)
242
245
243
246
244 class narrowfilelog(filelog):
247 class narrowfilelog(filelog):
245 """Filelog variation to be used with narrow stores."""
248 """Filelog variation to be used with narrow stores."""
246
249
247 def __init__(self, opener, path, narrowmatch):
250 def __init__(self, opener, path, narrowmatch):
248 super(narrowfilelog, self).__init__(opener, path)
251 super(narrowfilelog, self).__init__(opener, path)
249 self._narrowmatch = narrowmatch
252 self._narrowmatch = narrowmatch
250
253
251 def renamed(self, node):
254 def renamed(self, node):
252 res = super(narrowfilelog, self).renamed(node)
255 res = super(narrowfilelog, self).renamed(node)
253
256
254 # Renames that come from outside the narrowspec are problematic
257 # Renames that come from outside the narrowspec are problematic
255 # because we may lack the base text for the rename. This can result
258 # because we may lack the base text for the rename. This can result
256 # in code attempting to walk the ancestry or compute a diff
259 # in code attempting to walk the ancestry or compute a diff
257 # encountering a missing revision. We address this by silently
260 # encountering a missing revision. We address this by silently
258 # removing rename metadata if the source file is outside the
261 # removing rename metadata if the source file is outside the
259 # narrow spec.
262 # narrow spec.
260 #
263 #
261 # A better solution would be to see if the base revision is available,
264 # A better solution would be to see if the base revision is available,
262 # rather than assuming it isn't.
265 # rather than assuming it isn't.
263 #
266 #
264 # An even better solution would be to teach all consumers of rename
267 # An even better solution would be to teach all consumers of rename
265 # metadata that the base revision may not be available.
268 # metadata that the base revision may not be available.
266 #
269 #
267 # TODO consider better ways of doing this.
270 # TODO consider better ways of doing this.
268 if res and not self._narrowmatch(res[0]):
271 if res and not self._narrowmatch(res[0]):
269 return None
272 return None
270
273
271 return res
274 return res
272
275
273 def size(self, rev):
276 def size(self, rev):
274 # Because we have a custom renamed() that may lie, we need to call
277 # Because we have a custom renamed() that may lie, we need to call
275 # the base renamed() to report accurate results.
278 # the base renamed() to report accurate results.
276 node = self.node(rev)
279 node = self.node(rev)
277 if super(narrowfilelog, self).renamed(node):
280 if super(narrowfilelog, self).renamed(node):
278 return len(self.read(node))
281 return len(self.read(node))
279 else:
282 else:
280 return super(narrowfilelog, self).size(rev)
283 return super(narrowfilelog, self).size(rev)
281
284
282 def cmp(self, node, text):
285 def cmp(self, node, text):
283 # We don't call `super` because narrow parents can be buggy in case of a
286 # We don't call `super` because narrow parents can be buggy in case of a
284 # ambiguous dirstate. Always take the slow path until there is a better
287 # ambiguous dirstate. Always take the slow path until there is a better
285 # fix, see issue6150.
288 # fix, see issue6150.
286
289
287 # Censored files compare against the empty file.
290 # Censored files compare against the empty file.
288 if self.iscensored(self.rev(node)):
291 if self.iscensored(self.rev(node)):
289 return text != b''
292 return text != b''
290
293
291 return self.read(node) != text
294 return self.read(node) != text
@@ -1,3093 +1,3108 b''
1 The Mercurial system uses a set of configuration files to control
1 The Mercurial system uses a set of configuration files to control
2 aspects of its behavior.
2 aspects of its behavior.
3
3
4 Troubleshooting
4 Troubleshooting
5 ===============
5 ===============
6
6
7 If you're having problems with your configuration,
7 If you're having problems with your configuration,
8 :hg:`config --source` can help you understand what is introducing
8 :hg:`config --source` can help you understand what is introducing
9 a setting into your environment.
9 a setting into your environment.
10
10
11 See :hg:`help config.syntax` and :hg:`help config.files`
11 See :hg:`help config.syntax` and :hg:`help config.files`
12 for information about how and where to override things.
12 for information about how and where to override things.
13
13
14 Structure
14 Structure
15 =========
15 =========
16
16
17 The configuration files use a simple ini-file format. A configuration
17 The configuration files use a simple ini-file format. A configuration
18 file consists of sections, led by a ``[section]`` header and followed
18 file consists of sections, led by a ``[section]`` header and followed
19 by ``name = value`` entries::
19 by ``name = value`` entries::
20
20
21 [ui]
21 [ui]
22 username = Firstname Lastname <firstname.lastname@example.net>
22 username = Firstname Lastname <firstname.lastname@example.net>
23 verbose = True
23 verbose = True
24
24
25 The above entries will be referred to as ``ui.username`` and
25 The above entries will be referred to as ``ui.username`` and
26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
26 ``ui.verbose``, respectively. See :hg:`help config.syntax`.
27
27
28 Files
28 Files
29 =====
29 =====
30
30
31 Mercurial reads configuration data from several files, if they exist.
31 Mercurial reads configuration data from several files, if they exist.
32 These files do not exist by default and you will have to create the
32 These files do not exist by default and you will have to create the
33 appropriate configuration files yourself:
33 appropriate configuration files yourself:
34
34
35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
35 Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file.
36
36
37 Global configuration like the username setting is typically put into:
37 Global configuration like the username setting is typically put into:
38
38
39 .. container:: windows
39 .. container:: windows
40
40
41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
41 - ``%USERPROFILE%\mercurial.ini`` (on Windows)
42
42
43 .. container:: unix.plan9
43 .. container:: unix.plan9
44
44
45 - ``$HOME/.hgrc`` (on Unix, Plan9)
45 - ``$HOME/.hgrc`` (on Unix, Plan9)
46
46
47 The names of these files depend on the system on which Mercurial is
47 The names of these files depend on the system on which Mercurial is
48 installed. ``*.rc`` files from a single directory are read in
48 installed. ``*.rc`` files from a single directory are read in
49 alphabetical order, later ones overriding earlier ones. Where multiple
49 alphabetical order, later ones overriding earlier ones. Where multiple
50 paths are given below, settings from earlier paths override later
50 paths are given below, settings from earlier paths override later
51 ones.
51 ones.
52
52
53 .. container:: verbose.unix
53 .. container:: verbose.unix
54
54
55 On Unix, the following files are consulted:
55 On Unix, the following files are consulted:
56
56
57 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
57 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
58 - ``<repo>/.hg/hgrc`` (per-repository)
58 - ``<repo>/.hg/hgrc`` (per-repository)
59 - ``$HOME/.hgrc`` (per-user)
59 - ``$HOME/.hgrc`` (per-user)
60 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
61 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
62 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
63 - ``/etc/mercurial/hgrc`` (per-system)
63 - ``/etc/mercurial/hgrc`` (per-system)
64 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
65 - ``<internal>/*.rc`` (defaults)
65 - ``<internal>/*.rc`` (defaults)
66
66
67 .. container:: verbose.windows
67 .. container:: verbose.windows
68
68
69 On Windows, the following files are consulted:
69 On Windows, the following files are consulted:
70
70
71 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
71 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
72 - ``<repo>/.hg/hgrc`` (per-repository)
72 - ``<repo>/.hg/hgrc`` (per-repository)
73 - ``%USERPROFILE%\.hgrc`` (per-user)
73 - ``%USERPROFILE%\.hgrc`` (per-user)
74 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
74 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
75 - ``%HOME%\.hgrc`` (per-user)
75 - ``%HOME%\.hgrc`` (per-user)
76 - ``%HOME%\Mercurial.ini`` (per-user)
76 - ``%HOME%\Mercurial.ini`` (per-user)
77 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-system)
77 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-system)
78 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
78 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
79 - ``<install-dir>\Mercurial.ini`` (per-installation)
79 - ``<install-dir>\Mercurial.ini`` (per-installation)
80 - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system)
80 - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system)
81 - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system)
81 - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system)
82 - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system)
82 - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system)
83 - ``<internal>/*.rc`` (defaults)
83 - ``<internal>/*.rc`` (defaults)
84
84
85 .. note::
85 .. note::
86
86
87 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
87 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
88 is used when running 32-bit Python on 64-bit Windows.
88 is used when running 32-bit Python on 64-bit Windows.
89
89
90 .. container:: verbose.plan9
90 .. container:: verbose.plan9
91
91
92 On Plan9, the following files are consulted:
92 On Plan9, the following files are consulted:
93
93
94 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
94 - ``<repo>/.hg/hgrc-not-shared`` (per-repository)
95 - ``<repo>/.hg/hgrc`` (per-repository)
95 - ``<repo>/.hg/hgrc`` (per-repository)
96 - ``$home/lib/hgrc`` (per-user)
96 - ``$home/lib/hgrc`` (per-user)
97 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
97 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
98 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
98 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
99 - ``/lib/mercurial/hgrc`` (per-system)
99 - ``/lib/mercurial/hgrc`` (per-system)
100 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
100 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
101 - ``<internal>/*.rc`` (defaults)
101 - ``<internal>/*.rc`` (defaults)
102
102
103 Per-repository configuration options only apply in a
103 Per-repository configuration options only apply in a
104 particular repository. This file is not version-controlled, and
104 particular repository. This file is not version-controlled, and
105 will not get transferred during a "clone" operation. Options in
105 will not get transferred during a "clone" operation. Options in
106 this file override options in all other configuration files.
106 this file override options in all other configuration files.
107
107
108 .. container:: unix.plan9
108 .. container:: unix.plan9
109
109
110 On Plan 9 and Unix, most of this file will be ignored if it doesn't
110 On Plan 9 and Unix, most of this file will be ignored if it doesn't
111 belong to a trusted user or to a trusted group. See
111 belong to a trusted user or to a trusted group. See
112 :hg:`help config.trusted` for more details.
112 :hg:`help config.trusted` for more details.
113
113
114 Per-user configuration file(s) are for the user running Mercurial. Options
114 Per-user configuration file(s) are for the user running Mercurial. Options
115 in these files apply to all Mercurial commands executed by this user in any
115 in these files apply to all Mercurial commands executed by this user in any
116 directory. Options in these files override per-system and per-installation
116 directory. Options in these files override per-system and per-installation
117 options.
117 options.
118
118
119 Per-installation configuration files are searched for in the
119 Per-installation configuration files are searched for in the
120 directory where Mercurial is installed. ``<install-root>`` is the
120 directory where Mercurial is installed. ``<install-root>`` is the
121 parent directory of the **hg** executable (or symlink) being run.
121 parent directory of the **hg** executable (or symlink) being run.
122
122
123 .. container:: unix.plan9
123 .. container:: unix.plan9
124
124
125 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
125 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
126 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
126 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
127 files apply to all Mercurial commands executed by any user in any
127 files apply to all Mercurial commands executed by any user in any
128 directory.
128 directory.
129
129
130 Per-installation configuration files are for the system on
130 Per-installation configuration files are for the system on
131 which Mercurial is running. Options in these files apply to all
131 which Mercurial is running. Options in these files apply to all
132 Mercurial commands executed by any user in any directory. Registry
132 Mercurial commands executed by any user in any directory. Registry
133 keys contain PATH-like strings, every part of which must reference
133 keys contain PATH-like strings, every part of which must reference
134 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
134 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
135 be read. Mercurial checks each of these locations in the specified
135 be read. Mercurial checks each of these locations in the specified
136 order until one or more configuration files are detected.
136 order until one or more configuration files are detected.
137
137
138 Per-system configuration files are for the system on which Mercurial
138 Per-system configuration files are for the system on which Mercurial
139 is running. Options in these files apply to all Mercurial commands
139 is running. Options in these files apply to all Mercurial commands
140 executed by any user in any directory. Options in these files
140 executed by any user in any directory. Options in these files
141 override per-installation options.
141 override per-installation options.
142
142
143 Mercurial comes with some default configuration. The default configuration
143 Mercurial comes with some default configuration. The default configuration
144 files are installed with Mercurial and will be overwritten on upgrades. Default
144 files are installed with Mercurial and will be overwritten on upgrades. Default
145 configuration files should never be edited by users or administrators but can
145 configuration files should never be edited by users or administrators but can
146 be overridden in other configuration files. So far the directory only contains
146 be overridden in other configuration files. So far the directory only contains
147 merge tool configuration but packagers can also put other default configuration
147 merge tool configuration but packagers can also put other default configuration
148 there.
148 there.
149
149
150 On versions 5.7 and later, if share-safe functionality is enabled,
150 On versions 5.7 and later, if share-safe functionality is enabled,
151 shares will read config file of share source too.
151 shares will read config file of share source too.
152 `<share-source/.hg/hgrc>` is read before reading `<repo/.hg/hgrc>`.
152 `<share-source/.hg/hgrc>` is read before reading `<repo/.hg/hgrc>`.
153
153
154 For configs which should not be shared, `<repo/.hg/hgrc-not-shared>`
154 For configs which should not be shared, `<repo/.hg/hgrc-not-shared>`
155 should be used.
155 should be used.
156
156
157 Syntax
157 Syntax
158 ======
158 ======
159
159
160 A configuration file consists of sections, led by a ``[section]`` header
160 A configuration file consists of sections, led by a ``[section]`` header
161 and followed by ``name = value`` entries (sometimes called
161 and followed by ``name = value`` entries (sometimes called
162 ``configuration keys``)::
162 ``configuration keys``)::
163
163
164 [spam]
164 [spam]
165 eggs=ham
165 eggs=ham
166 green=
166 green=
167 eggs
167 eggs
168
168
169 Each line contains one entry. If the lines that follow are indented,
169 Each line contains one entry. If the lines that follow are indented,
170 they are treated as continuations of that entry. Leading whitespace is
170 they are treated as continuations of that entry. Leading whitespace is
171 removed from values. Empty lines are skipped. Lines beginning with
171 removed from values. Empty lines are skipped. Lines beginning with
172 ``#`` or ``;`` are ignored and may be used to provide comments.
172 ``#`` or ``;`` are ignored and may be used to provide comments.
173
173
174 Configuration keys can be set multiple times, in which case Mercurial
174 Configuration keys can be set multiple times, in which case Mercurial
175 will use the value that was configured last. As an example::
175 will use the value that was configured last. As an example::
176
176
177 [spam]
177 [spam]
178 eggs=large
178 eggs=large
179 ham=serrano
179 ham=serrano
180 eggs=small
180 eggs=small
181
181
182 This would set the configuration key named ``eggs`` to ``small``.
182 This would set the configuration key named ``eggs`` to ``small``.
183
183
184 It is also possible to define a section multiple times. A section can
184 It is also possible to define a section multiple times. A section can
185 be redefined on the same and/or on different configuration files. For
185 be redefined on the same and/or on different configuration files. For
186 example::
186 example::
187
187
188 [foo]
188 [foo]
189 eggs=large
189 eggs=large
190 ham=serrano
190 ham=serrano
191 eggs=small
191 eggs=small
192
192
193 [bar]
193 [bar]
194 eggs=ham
194 eggs=ham
195 green=
195 green=
196 eggs
196 eggs
197
197
198 [foo]
198 [foo]
199 ham=prosciutto
199 ham=prosciutto
200 eggs=medium
200 eggs=medium
201 bread=toasted
201 bread=toasted
202
202
203 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
203 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
204 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
204 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
205 respectively. As you can see there only thing that matters is the last
205 respectively. As you can see there only thing that matters is the last
206 value that was set for each of the configuration keys.
206 value that was set for each of the configuration keys.
207
207
208 If a configuration key is set multiple times in different
208 If a configuration key is set multiple times in different
209 configuration files the final value will depend on the order in which
209 configuration files the final value will depend on the order in which
210 the different configuration files are read, with settings from earlier
210 the different configuration files are read, with settings from earlier
211 paths overriding later ones as described on the ``Files`` section
211 paths overriding later ones as described on the ``Files`` section
212 above.
212 above.
213
213
214 A line of the form ``%include file`` will include ``file`` into the
214 A line of the form ``%include file`` will include ``file`` into the
215 current configuration file. The inclusion is recursive, which means
215 current configuration file. The inclusion is recursive, which means
216 that included files can include other files. Filenames are relative to
216 that included files can include other files. Filenames are relative to
217 the configuration file in which the ``%include`` directive is found.
217 the configuration file in which the ``%include`` directive is found.
218 Environment variables and ``~user`` constructs are expanded in
218 Environment variables and ``~user`` constructs are expanded in
219 ``file``. This lets you do something like::
219 ``file``. This lets you do something like::
220
220
221 %include ~/.hgrc.d/$HOST.rc
221 %include ~/.hgrc.d/$HOST.rc
222
222
223 to include a different configuration file on each computer you use.
223 to include a different configuration file on each computer you use.
224
224
225 A line with ``%unset name`` will remove ``name`` from the current
225 A line with ``%unset name`` will remove ``name`` from the current
226 section, if it has been set previously.
226 section, if it has been set previously.
227
227
228 The values are either free-form text strings, lists of text strings,
228 The values are either free-form text strings, lists of text strings,
229 or Boolean values. Boolean values can be set to true using any of "1",
229 or Boolean values. Boolean values can be set to true using any of "1",
230 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
230 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
231 (all case insensitive).
231 (all case insensitive).
232
232
233 List values are separated by whitespace or comma, except when values are
233 List values are separated by whitespace or comma, except when values are
234 placed in double quotation marks::
234 placed in double quotation marks::
235
235
236 allow_read = "John Doe, PhD", brian, betty
236 allow_read = "John Doe, PhD", brian, betty
237
237
238 Quotation marks can be escaped by prefixing them with a backslash. Only
238 Quotation marks can be escaped by prefixing them with a backslash. Only
239 quotation marks at the beginning of a word is counted as a quotation
239 quotation marks at the beginning of a word is counted as a quotation
240 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
240 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
241
241
242 Sections
242 Sections
243 ========
243 ========
244
244
245 This section describes the different sections that may appear in a
245 This section describes the different sections that may appear in a
246 Mercurial configuration file, the purpose of each section, its possible
246 Mercurial configuration file, the purpose of each section, its possible
247 keys, and their possible values.
247 keys, and their possible values.
248
248
249 ``alias``
249 ``alias``
250 ---------
250 ---------
251
251
252 Defines command aliases.
252 Defines command aliases.
253
253
254 Aliases allow you to define your own commands in terms of other
254 Aliases allow you to define your own commands in terms of other
255 commands (or aliases), optionally including arguments. Positional
255 commands (or aliases), optionally including arguments. Positional
256 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
256 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
257 are expanded by Mercurial before execution. Positional arguments not
257 are expanded by Mercurial before execution. Positional arguments not
258 already used by ``$N`` in the definition are put at the end of the
258 already used by ``$N`` in the definition are put at the end of the
259 command to be executed.
259 command to be executed.
260
260
261 Alias definitions consist of lines of the form::
261 Alias definitions consist of lines of the form::
262
262
263 <alias> = <command> [<argument>]...
263 <alias> = <command> [<argument>]...
264
264
265 For example, this definition::
265 For example, this definition::
266
266
267 latest = log --limit 5
267 latest = log --limit 5
268
268
269 creates a new command ``latest`` that shows only the five most recent
269 creates a new command ``latest`` that shows only the five most recent
270 changesets. You can define subsequent aliases using earlier ones::
270 changesets. You can define subsequent aliases using earlier ones::
271
271
272 stable5 = latest -b stable
272 stable5 = latest -b stable
273
273
274 .. note::
274 .. note::
275
275
276 It is possible to create aliases with the same names as
276 It is possible to create aliases with the same names as
277 existing commands, which will then override the original
277 existing commands, which will then override the original
278 definitions. This is almost always a bad idea!
278 definitions. This is almost always a bad idea!
279
279
280 An alias can start with an exclamation point (``!``) to make it a
280 An alias can start with an exclamation point (``!``) to make it a
281 shell alias. A shell alias is executed with the shell and will let you
281 shell alias. A shell alias is executed with the shell and will let you
282 run arbitrary commands. As an example, ::
282 run arbitrary commands. As an example, ::
283
283
284 echo = !echo $@
284 echo = !echo $@
285
285
286 will let you do ``hg echo foo`` to have ``foo`` printed in your
286 will let you do ``hg echo foo`` to have ``foo`` printed in your
287 terminal. A better example might be::
287 terminal. A better example might be::
288
288
289 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
289 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
290
290
291 which will make ``hg purge`` delete all unknown files in the
291 which will make ``hg purge`` delete all unknown files in the
292 repository in the same manner as the purge extension.
292 repository in the same manner as the purge extension.
293
293
294 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
294 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
295 expand to the command arguments. Unmatched arguments are
295 expand to the command arguments. Unmatched arguments are
296 removed. ``$0`` expands to the alias name and ``$@`` expands to all
296 removed. ``$0`` expands to the alias name and ``$@`` expands to all
297 arguments separated by a space. ``"$@"`` (with quotes) expands to all
297 arguments separated by a space. ``"$@"`` (with quotes) expands to all
298 arguments quoted individually and separated by a space. These expansions
298 arguments quoted individually and separated by a space. These expansions
299 happen before the command is passed to the shell.
299 happen before the command is passed to the shell.
300
300
301 Shell aliases are executed in an environment where ``$HG`` expands to
301 Shell aliases are executed in an environment where ``$HG`` expands to
302 the path of the Mercurial that was used to execute the alias. This is
302 the path of the Mercurial that was used to execute the alias. This is
303 useful when you want to call further Mercurial commands in a shell
303 useful when you want to call further Mercurial commands in a shell
304 alias, as was done above for the purge alias. In addition,
304 alias, as was done above for the purge alias. In addition,
305 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
305 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
306 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
306 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
307
307
308 .. note::
308 .. note::
309
309
310 Some global configuration options such as ``-R`` are
310 Some global configuration options such as ``-R`` are
311 processed before shell aliases and will thus not be passed to
311 processed before shell aliases and will thus not be passed to
312 aliases.
312 aliases.
313
313
314
314
315 ``annotate``
315 ``annotate``
316 ------------
316 ------------
317
317
318 Settings used when displaying file annotations. All values are
318 Settings used when displaying file annotations. All values are
319 Booleans and default to False. See :hg:`help config.diff` for
319 Booleans and default to False. See :hg:`help config.diff` for
320 related options for the diff command.
320 related options for the diff command.
321
321
322 ``ignorews``
322 ``ignorews``
323 Ignore white space when comparing lines.
323 Ignore white space when comparing lines.
324
324
325 ``ignorewseol``
325 ``ignorewseol``
326 Ignore white space at the end of a line when comparing lines.
326 Ignore white space at the end of a line when comparing lines.
327
327
328 ``ignorewsamount``
328 ``ignorewsamount``
329 Ignore changes in the amount of white space.
329 Ignore changes in the amount of white space.
330
330
331 ``ignoreblanklines``
331 ``ignoreblanklines``
332 Ignore changes whose lines are all blank.
332 Ignore changes whose lines are all blank.
333
333
334
334
335 ``auth``
335 ``auth``
336 --------
336 --------
337
337
338 Authentication credentials and other authentication-like configuration
338 Authentication credentials and other authentication-like configuration
339 for HTTP connections. This section allows you to store usernames and
339 for HTTP connections. This section allows you to store usernames and
340 passwords for use when logging *into* HTTP servers. See
340 passwords for use when logging *into* HTTP servers. See
341 :hg:`help config.web` if you want to configure *who* can login to
341 :hg:`help config.web` if you want to configure *who* can login to
342 your HTTP server.
342 your HTTP server.
343
343
344 The following options apply to all hosts.
344 The following options apply to all hosts.
345
345
346 ``cookiefile``
346 ``cookiefile``
347 Path to a file containing HTTP cookie lines. Cookies matching a
347 Path to a file containing HTTP cookie lines. Cookies matching a
348 host will be sent automatically.
348 host will be sent automatically.
349
349
350 The file format uses the Mozilla cookies.txt format, which defines cookies
350 The file format uses the Mozilla cookies.txt format, which defines cookies
351 on their own lines. Each line contains 7 fields delimited by the tab
351 on their own lines. Each line contains 7 fields delimited by the tab
352 character (domain, is_domain_cookie, path, is_secure, expires, name,
352 character (domain, is_domain_cookie, path, is_secure, expires, name,
353 value). For more info, do an Internet search for "Netscape cookies.txt
353 value). For more info, do an Internet search for "Netscape cookies.txt
354 format."
354 format."
355
355
356 Note: the cookies parser does not handle port numbers on domains. You
356 Note: the cookies parser does not handle port numbers on domains. You
357 will need to remove ports from the domain for the cookie to be recognized.
357 will need to remove ports from the domain for the cookie to be recognized.
358 This could result in a cookie being disclosed to an unwanted server.
358 This could result in a cookie being disclosed to an unwanted server.
359
359
360 The cookies file is read-only.
360 The cookies file is read-only.
361
361
362 Other options in this section are grouped by name and have the following
362 Other options in this section are grouped by name and have the following
363 format::
363 format::
364
364
365 <name>.<argument> = <value>
365 <name>.<argument> = <value>
366
366
367 where ``<name>`` is used to group arguments into authentication
367 where ``<name>`` is used to group arguments into authentication
368 entries. Example::
368 entries. Example::
369
369
370 foo.prefix = hg.intevation.de/mercurial
370 foo.prefix = hg.intevation.de/mercurial
371 foo.username = foo
371 foo.username = foo
372 foo.password = bar
372 foo.password = bar
373 foo.schemes = http https
373 foo.schemes = http https
374
374
375 bar.prefix = secure.example.org
375 bar.prefix = secure.example.org
376 bar.key = path/to/file.key
376 bar.key = path/to/file.key
377 bar.cert = path/to/file.cert
377 bar.cert = path/to/file.cert
378 bar.schemes = https
378 bar.schemes = https
379
379
380 Supported arguments:
380 Supported arguments:
381
381
382 ``prefix``
382 ``prefix``
383 Either ``*`` or a URI prefix with or without the scheme part.
383 Either ``*`` or a URI prefix with or without the scheme part.
384 The authentication entry with the longest matching prefix is used
384 The authentication entry with the longest matching prefix is used
385 (where ``*`` matches everything and counts as a match of length
385 (where ``*`` matches everything and counts as a match of length
386 1). If the prefix doesn't include a scheme, the match is performed
386 1). If the prefix doesn't include a scheme, the match is performed
387 against the URI with its scheme stripped as well, and the schemes
387 against the URI with its scheme stripped as well, and the schemes
388 argument, q.v., is then subsequently consulted.
388 argument, q.v., is then subsequently consulted.
389
389
390 ``username``
390 ``username``
391 Optional. Username to authenticate with. If not given, and the
391 Optional. Username to authenticate with. If not given, and the
392 remote site requires basic or digest authentication, the user will
392 remote site requires basic or digest authentication, the user will
393 be prompted for it. Environment variables are expanded in the
393 be prompted for it. Environment variables are expanded in the
394 username letting you do ``foo.username = $USER``. If the URI
394 username letting you do ``foo.username = $USER``. If the URI
395 includes a username, only ``[auth]`` entries with a matching
395 includes a username, only ``[auth]`` entries with a matching
396 username or without a username will be considered.
396 username or without a username will be considered.
397
397
398 ``password``
398 ``password``
399 Optional. Password to authenticate with. If not given, and the
399 Optional. Password to authenticate with. If not given, and the
400 remote site requires basic or digest authentication, the user
400 remote site requires basic or digest authentication, the user
401 will be prompted for it.
401 will be prompted for it.
402
402
403 ``key``
403 ``key``
404 Optional. PEM encoded client certificate key file. Environment
404 Optional. PEM encoded client certificate key file. Environment
405 variables are expanded in the filename.
405 variables are expanded in the filename.
406
406
407 ``cert``
407 ``cert``
408 Optional. PEM encoded client certificate chain file. Environment
408 Optional. PEM encoded client certificate chain file. Environment
409 variables are expanded in the filename.
409 variables are expanded in the filename.
410
410
411 ``schemes``
411 ``schemes``
412 Optional. Space separated list of URI schemes to use this
412 Optional. Space separated list of URI schemes to use this
413 authentication entry with. Only used if the prefix doesn't include
413 authentication entry with. Only used if the prefix doesn't include
414 a scheme. Supported schemes are http and https. They will match
414 a scheme. Supported schemes are http and https. They will match
415 static-http and static-https respectively, as well.
415 static-http and static-https respectively, as well.
416 (default: https)
416 (default: https)
417
417
418 If no suitable authentication entry is found, the user is prompted
418 If no suitable authentication entry is found, the user is prompted
419 for credentials as usual if required by the remote.
419 for credentials as usual if required by the remote.
420
420
421 ``cmdserver``
421 ``cmdserver``
422 -------------
422 -------------
423
423
424 Controls command server settings. (ADVANCED)
424 Controls command server settings. (ADVANCED)
425
425
426 ``message-encodings``
426 ``message-encodings``
427 List of encodings for the ``m`` (message) channel. The first encoding
427 List of encodings for the ``m`` (message) channel. The first encoding
428 supported by the server will be selected and advertised in the hello
428 supported by the server will be selected and advertised in the hello
429 message. This is useful only when ``ui.message-output`` is set to
429 message. This is useful only when ``ui.message-output`` is set to
430 ``channel``. Supported encodings are ``cbor``.
430 ``channel``. Supported encodings are ``cbor``.
431
431
432 ``shutdown-on-interrupt``
432 ``shutdown-on-interrupt``
433 If set to false, the server's main loop will continue running after
433 If set to false, the server's main loop will continue running after
434 SIGINT received. ``runcommand`` requests can still be interrupted by
434 SIGINT received. ``runcommand`` requests can still be interrupted by
435 SIGINT. Close the write end of the pipe to shut down the server
435 SIGINT. Close the write end of the pipe to shut down the server
436 process gracefully.
436 process gracefully.
437 (default: True)
437 (default: True)
438
438
439 ``color``
439 ``color``
440 ---------
440 ---------
441
441
442 Configure the Mercurial color mode. For details about how to define your custom
442 Configure the Mercurial color mode. For details about how to define your custom
443 effect and style see :hg:`help color`.
443 effect and style see :hg:`help color`.
444
444
445 ``mode``
445 ``mode``
446 String: control the method used to output color. One of ``auto``, ``ansi``,
446 String: control the method used to output color. One of ``auto``, ``ansi``,
447 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
447 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
448 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
448 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
449 terminal. Any invalid value will disable color.
449 terminal. Any invalid value will disable color.
450
450
451 ``pagermode``
451 ``pagermode``
452 String: optional override of ``color.mode`` used with pager.
452 String: optional override of ``color.mode`` used with pager.
453
453
454 On some systems, terminfo mode may cause problems when using
454 On some systems, terminfo mode may cause problems when using
455 color with ``less -R`` as a pager program. less with the -R option
455 color with ``less -R`` as a pager program. less with the -R option
456 will only display ECMA-48 color codes, and terminfo mode may sometimes
456 will only display ECMA-48 color codes, and terminfo mode may sometimes
457 emit codes that less doesn't understand. You can work around this by
457 emit codes that less doesn't understand. You can work around this by
458 either using ansi mode (or auto mode), or by using less -r (which will
458 either using ansi mode (or auto mode), or by using less -r (which will
459 pass through all terminal control codes, not just color control
459 pass through all terminal control codes, not just color control
460 codes).
460 codes).
461
461
462 On some systems (such as MSYS in Windows), the terminal may support
462 On some systems (such as MSYS in Windows), the terminal may support
463 a different color mode than the pager program.
463 a different color mode than the pager program.
464
464
465 ``commands``
465 ``commands``
466 ------------
466 ------------
467
467
468 ``commit.post-status``
468 ``commit.post-status``
469 Show status of files in the working directory after successful commit.
469 Show status of files in the working directory after successful commit.
470 (default: False)
470 (default: False)
471
471
472 ``merge.require-rev``
472 ``merge.require-rev``
473 Require that the revision to merge the current commit with be specified on
473 Require that the revision to merge the current commit with be specified on
474 the command line. If this is enabled and a revision is not specified, the
474 the command line. If this is enabled and a revision is not specified, the
475 command aborts.
475 command aborts.
476 (default: False)
476 (default: False)
477
477
478 ``push.require-revs``
478 ``push.require-revs``
479 Require revisions to push be specified using one or more mechanisms such as
479 Require revisions to push be specified using one or more mechanisms such as
480 specifying them positionally on the command line, using ``-r``, ``-b``,
480 specifying them positionally on the command line, using ``-r``, ``-b``,
481 and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
481 and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the
482 configuration. If this is enabled and revisions are not specified, the
482 configuration. If this is enabled and revisions are not specified, the
483 command aborts.
483 command aborts.
484 (default: False)
484 (default: False)
485
485
486 ``resolve.confirm``
486 ``resolve.confirm``
487 Confirm before performing action if no filename is passed.
487 Confirm before performing action if no filename is passed.
488 (default: False)
488 (default: False)
489
489
490 ``resolve.explicit-re-merge``
490 ``resolve.explicit-re-merge``
491 Require uses of ``hg resolve`` to specify which action it should perform,
491 Require uses of ``hg resolve`` to specify which action it should perform,
492 instead of re-merging files by default.
492 instead of re-merging files by default.
493 (default: False)
493 (default: False)
494
494
495 ``resolve.mark-check``
495 ``resolve.mark-check``
496 Determines what level of checking :hg:`resolve --mark` will perform before
496 Determines what level of checking :hg:`resolve --mark` will perform before
497 marking files as resolved. Valid values are ``none`, ``warn``, and
497 marking files as resolved. Valid values are ``none`, ``warn``, and
498 ``abort``. ``warn`` will output a warning listing the file(s) that still
498 ``abort``. ``warn`` will output a warning listing the file(s) that still
499 have conflict markers in them, but will still mark everything resolved.
499 have conflict markers in them, but will still mark everything resolved.
500 ``abort`` will output the same warning but will not mark things as resolved.
500 ``abort`` will output the same warning but will not mark things as resolved.
501 If --all is passed and this is set to ``abort``, only a warning will be
501 If --all is passed and this is set to ``abort``, only a warning will be
502 shown (an error will not be raised).
502 shown (an error will not be raised).
503 (default: ``none``)
503 (default: ``none``)
504
504
505 ``status.relative``
505 ``status.relative``
506 Make paths in :hg:`status` output relative to the current directory.
506 Make paths in :hg:`status` output relative to the current directory.
507 (default: False)
507 (default: False)
508
508
509 ``status.terse``
509 ``status.terse``
510 Default value for the --terse flag, which condenses status output.
510 Default value for the --terse flag, which condenses status output.
511 (default: empty)
511 (default: empty)
512
512
513 ``update.check``
513 ``update.check``
514 Determines what level of checking :hg:`update` will perform before moving
514 Determines what level of checking :hg:`update` will perform before moving
515 to a destination revision. Valid values are ``abort``, ``none``,
515 to a destination revision. Valid values are ``abort``, ``none``,
516 ``linear``, and ``noconflict``. ``abort`` always fails if the working
516 ``linear``, and ``noconflict``. ``abort`` always fails if the working
517 directory has uncommitted changes. ``none`` performs no checking, and may
517 directory has uncommitted changes. ``none`` performs no checking, and may
518 result in a merge with uncommitted changes. ``linear`` allows any update
518 result in a merge with uncommitted changes. ``linear`` allows any update
519 as long as it follows a straight line in the revision history, and may
519 as long as it follows a straight line in the revision history, and may
520 trigger a merge with uncommitted changes. ``noconflict`` will allow any
520 trigger a merge with uncommitted changes. ``noconflict`` will allow any
521 update which would not trigger a merge with uncommitted changes, if any
521 update which would not trigger a merge with uncommitted changes, if any
522 are present.
522 are present.
523 (default: ``linear``)
523 (default: ``linear``)
524
524
525 ``update.requiredest``
525 ``update.requiredest``
526 Require that the user pass a destination when running :hg:`update`.
526 Require that the user pass a destination when running :hg:`update`.
527 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
527 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
528 will be disallowed.
528 will be disallowed.
529 (default: False)
529 (default: False)
530
530
531 ``committemplate``
531 ``committemplate``
532 ------------------
532 ------------------
533
533
534 ``changeset``
534 ``changeset``
535 String: configuration in this section is used as the template to
535 String: configuration in this section is used as the template to
536 customize the text shown in the editor when committing.
536 customize the text shown in the editor when committing.
537
537
538 In addition to pre-defined template keywords, commit log specific one
538 In addition to pre-defined template keywords, commit log specific one
539 below can be used for customization:
539 below can be used for customization:
540
540
541 ``extramsg``
541 ``extramsg``
542 String: Extra message (typically 'Leave message empty to abort
542 String: Extra message (typically 'Leave message empty to abort
543 commit.'). This may be changed by some commands or extensions.
543 commit.'). This may be changed by some commands or extensions.
544
544
545 For example, the template configuration below shows as same text as
545 For example, the template configuration below shows as same text as
546 one shown by default::
546 one shown by default::
547
547
548 [committemplate]
548 [committemplate]
549 changeset = {desc}\n\n
549 changeset = {desc}\n\n
550 HG: Enter commit message. Lines beginning with 'HG:' are removed.
550 HG: Enter commit message. Lines beginning with 'HG:' are removed.
551 HG: {extramsg}
551 HG: {extramsg}
552 HG: --
552 HG: --
553 HG: user: {author}\n{ifeq(p2rev, "-1", "",
553 HG: user: {author}\n{ifeq(p2rev, "-1", "",
554 "HG: branch merge\n")
554 "HG: branch merge\n")
555 }HG: branch '{branch}'\n{if(activebookmark,
555 }HG: branch '{branch}'\n{if(activebookmark,
556 "HG: bookmark '{activebookmark}'\n") }{subrepos %
556 "HG: bookmark '{activebookmark}'\n") }{subrepos %
557 "HG: subrepo {subrepo}\n" }{file_adds %
557 "HG: subrepo {subrepo}\n" }{file_adds %
558 "HG: added {file}\n" }{file_mods %
558 "HG: added {file}\n" }{file_mods %
559 "HG: changed {file}\n" }{file_dels %
559 "HG: changed {file}\n" }{file_dels %
560 "HG: removed {file}\n" }{if(files, "",
560 "HG: removed {file}\n" }{if(files, "",
561 "HG: no files changed\n")}
561 "HG: no files changed\n")}
562
562
563 ``diff()``
563 ``diff()``
564 String: show the diff (see :hg:`help templates` for detail)
564 String: show the diff (see :hg:`help templates` for detail)
565
565
566 Sometimes it is helpful to show the diff of the changeset in the editor without
566 Sometimes it is helpful to show the diff of the changeset in the editor without
567 having to prefix 'HG: ' to each line so that highlighting works correctly. For
567 having to prefix 'HG: ' to each line so that highlighting works correctly. For
568 this, Mercurial provides a special string which will ignore everything below
568 this, Mercurial provides a special string which will ignore everything below
569 it::
569 it::
570
570
571 HG: ------------------------ >8 ------------------------
571 HG: ------------------------ >8 ------------------------
572
572
573 For example, the template configuration below will show the diff below the
573 For example, the template configuration below will show the diff below the
574 extra message::
574 extra message::
575
575
576 [committemplate]
576 [committemplate]
577 changeset = {desc}\n\n
577 changeset = {desc}\n\n
578 HG: Enter commit message. Lines beginning with 'HG:' are removed.
578 HG: Enter commit message. Lines beginning with 'HG:' are removed.
579 HG: {extramsg}
579 HG: {extramsg}
580 HG: ------------------------ >8 ------------------------
580 HG: ------------------------ >8 ------------------------
581 HG: Do not touch the line above.
581 HG: Do not touch the line above.
582 HG: Everything below will be removed.
582 HG: Everything below will be removed.
583 {diff()}
583 {diff()}
584
584
585 .. note::
585 .. note::
586
586
587 For some problematic encodings (see :hg:`help win32mbcs` for
587 For some problematic encodings (see :hg:`help win32mbcs` for
588 detail), this customization should be configured carefully, to
588 detail), this customization should be configured carefully, to
589 avoid showing broken characters.
589 avoid showing broken characters.
590
590
591 For example, if a multibyte character ending with backslash (0x5c) is
591 For example, if a multibyte character ending with backslash (0x5c) is
592 followed by the ASCII character 'n' in the customized template,
592 followed by the ASCII character 'n' in the customized template,
593 the sequence of backslash and 'n' is treated as line-feed unexpectedly
593 the sequence of backslash and 'n' is treated as line-feed unexpectedly
594 (and the multibyte character is broken, too).
594 (and the multibyte character is broken, too).
595
595
596 Customized template is used for commands below (``--edit`` may be
596 Customized template is used for commands below (``--edit`` may be
597 required):
597 required):
598
598
599 - :hg:`backout`
599 - :hg:`backout`
600 - :hg:`commit`
600 - :hg:`commit`
601 - :hg:`fetch` (for merge commit only)
601 - :hg:`fetch` (for merge commit only)
602 - :hg:`graft`
602 - :hg:`graft`
603 - :hg:`histedit`
603 - :hg:`histedit`
604 - :hg:`import`
604 - :hg:`import`
605 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
605 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
606 - :hg:`rebase`
606 - :hg:`rebase`
607 - :hg:`shelve`
607 - :hg:`shelve`
608 - :hg:`sign`
608 - :hg:`sign`
609 - :hg:`tag`
609 - :hg:`tag`
610 - :hg:`transplant`
610 - :hg:`transplant`
611
611
612 Configuring items below instead of ``changeset`` allows showing
612 Configuring items below instead of ``changeset`` allows showing
613 customized message only for specific actions, or showing different
613 customized message only for specific actions, or showing different
614 messages for each action.
614 messages for each action.
615
615
616 - ``changeset.backout`` for :hg:`backout`
616 - ``changeset.backout`` for :hg:`backout`
617 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
617 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
618 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
618 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
619 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
619 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
620 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
620 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
621 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
621 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
622 - ``changeset.gpg.sign`` for :hg:`sign`
622 - ``changeset.gpg.sign`` for :hg:`sign`
623 - ``changeset.graft`` for :hg:`graft`
623 - ``changeset.graft`` for :hg:`graft`
624 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
624 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
625 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
625 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
626 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
626 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
627 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
627 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
628 - ``changeset.import.bypass`` for :hg:`import --bypass`
628 - ``changeset.import.bypass`` for :hg:`import --bypass`
629 - ``changeset.import.normal.merge`` for :hg:`import` on merges
629 - ``changeset.import.normal.merge`` for :hg:`import` on merges
630 - ``changeset.import.normal.normal`` for :hg:`import` on other
630 - ``changeset.import.normal.normal`` for :hg:`import` on other
631 - ``changeset.mq.qnew`` for :hg:`qnew`
631 - ``changeset.mq.qnew`` for :hg:`qnew`
632 - ``changeset.mq.qfold`` for :hg:`qfold`
632 - ``changeset.mq.qfold`` for :hg:`qfold`
633 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
633 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
634 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
634 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
635 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
635 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
636 - ``changeset.rebase.normal`` for :hg:`rebase` on other
636 - ``changeset.rebase.normal`` for :hg:`rebase` on other
637 - ``changeset.shelve.shelve`` for :hg:`shelve`
637 - ``changeset.shelve.shelve`` for :hg:`shelve`
638 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
638 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
639 - ``changeset.tag.remove`` for :hg:`tag --remove`
639 - ``changeset.tag.remove`` for :hg:`tag --remove`
640 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
640 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
641 - ``changeset.transplant.normal`` for :hg:`transplant` on other
641 - ``changeset.transplant.normal`` for :hg:`transplant` on other
642
642
643 These dot-separated lists of names are treated as hierarchical ones.
643 These dot-separated lists of names are treated as hierarchical ones.
644 For example, ``changeset.tag.remove`` customizes the commit message
644 For example, ``changeset.tag.remove`` customizes the commit message
645 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
645 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
646 commit message for :hg:`tag` regardless of ``--remove`` option.
646 commit message for :hg:`tag` regardless of ``--remove`` option.
647
647
648 When the external editor is invoked for a commit, the corresponding
648 When the external editor is invoked for a commit, the corresponding
649 dot-separated list of names without the ``changeset.`` prefix
649 dot-separated list of names without the ``changeset.`` prefix
650 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
650 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
651 variable.
651 variable.
652
652
653 In this section, items other than ``changeset`` can be referred from
653 In this section, items other than ``changeset`` can be referred from
654 others. For example, the configuration to list committed files up
654 others. For example, the configuration to list committed files up
655 below can be referred as ``{listupfiles}``::
655 below can be referred as ``{listupfiles}``::
656
656
657 [committemplate]
657 [committemplate]
658 listupfiles = {file_adds %
658 listupfiles = {file_adds %
659 "HG: added {file}\n" }{file_mods %
659 "HG: added {file}\n" }{file_mods %
660 "HG: changed {file}\n" }{file_dels %
660 "HG: changed {file}\n" }{file_dels %
661 "HG: removed {file}\n" }{if(files, "",
661 "HG: removed {file}\n" }{if(files, "",
662 "HG: no files changed\n")}
662 "HG: no files changed\n")}
663
663
664 ``decode/encode``
664 ``decode/encode``
665 -----------------
665 -----------------
666
666
667 Filters for transforming files on checkout/checkin. This would
667 Filters for transforming files on checkout/checkin. This would
668 typically be used for newline processing or other
668 typically be used for newline processing or other
669 localization/canonicalization of files.
669 localization/canonicalization of files.
670
670
671 Filters consist of a filter pattern followed by a filter command.
671 Filters consist of a filter pattern followed by a filter command.
672 Filter patterns are globs by default, rooted at the repository root.
672 Filter patterns are globs by default, rooted at the repository root.
673 For example, to match any file ending in ``.txt`` in the root
673 For example, to match any file ending in ``.txt`` in the root
674 directory only, use the pattern ``*.txt``. To match any file ending
674 directory only, use the pattern ``*.txt``. To match any file ending
675 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
675 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
676 For each file only the first matching filter applies.
676 For each file only the first matching filter applies.
677
677
678 The filter command can start with a specifier, either ``pipe:`` or
678 The filter command can start with a specifier, either ``pipe:`` or
679 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
679 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
680
680
681 A ``pipe:`` command must accept data on stdin and return the transformed
681 A ``pipe:`` command must accept data on stdin and return the transformed
682 data on stdout.
682 data on stdout.
683
683
684 Pipe example::
684 Pipe example::
685
685
686 [encode]
686 [encode]
687 # uncompress gzip files on checkin to improve delta compression
687 # uncompress gzip files on checkin to improve delta compression
688 # note: not necessarily a good idea, just an example
688 # note: not necessarily a good idea, just an example
689 *.gz = pipe: gunzip
689 *.gz = pipe: gunzip
690
690
691 [decode]
691 [decode]
692 # recompress gzip files when writing them to the working dir (we
692 # recompress gzip files when writing them to the working dir (we
693 # can safely omit "pipe:", because it's the default)
693 # can safely omit "pipe:", because it's the default)
694 *.gz = gzip
694 *.gz = gzip
695
695
696 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
696 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
697 with the name of a temporary file that contains the data to be
697 with the name of a temporary file that contains the data to be
698 filtered by the command. The string ``OUTFILE`` is replaced with the name
698 filtered by the command. The string ``OUTFILE`` is replaced with the name
699 of an empty temporary file, where the filtered data must be written by
699 of an empty temporary file, where the filtered data must be written by
700 the command.
700 the command.
701
701
702 .. container:: windows
702 .. container:: windows
703
703
704 .. note::
704 .. note::
705
705
706 The tempfile mechanism is recommended for Windows systems,
706 The tempfile mechanism is recommended for Windows systems,
707 where the standard shell I/O redirection operators often have
707 where the standard shell I/O redirection operators often have
708 strange effects and may corrupt the contents of your files.
708 strange effects and may corrupt the contents of your files.
709
709
710 This filter mechanism is used internally by the ``eol`` extension to
710 This filter mechanism is used internally by the ``eol`` extension to
711 translate line ending characters between Windows (CRLF) and Unix (LF)
711 translate line ending characters between Windows (CRLF) and Unix (LF)
712 format. We suggest you use the ``eol`` extension for convenience.
712 format. We suggest you use the ``eol`` extension for convenience.
713
713
714
714
715 ``defaults``
715 ``defaults``
716 ------------
716 ------------
717
717
718 (defaults are deprecated. Don't use them. Use aliases instead.)
718 (defaults are deprecated. Don't use them. Use aliases instead.)
719
719
720 Use the ``[defaults]`` section to define command defaults, i.e. the
720 Use the ``[defaults]`` section to define command defaults, i.e. the
721 default options/arguments to pass to the specified commands.
721 default options/arguments to pass to the specified commands.
722
722
723 The following example makes :hg:`log` run in verbose mode, and
723 The following example makes :hg:`log` run in verbose mode, and
724 :hg:`status` show only the modified files, by default::
724 :hg:`status` show only the modified files, by default::
725
725
726 [defaults]
726 [defaults]
727 log = -v
727 log = -v
728 status = -m
728 status = -m
729
729
730 The actual commands, instead of their aliases, must be used when
730 The actual commands, instead of their aliases, must be used when
731 defining command defaults. The command defaults will also be applied
731 defining command defaults. The command defaults will also be applied
732 to the aliases of the commands defined.
732 to the aliases of the commands defined.
733
733
734
734
735 ``diff``
735 ``diff``
736 --------
736 --------
737
737
738 Settings used when displaying diffs. Everything except for ``unified``
738 Settings used when displaying diffs. Everything except for ``unified``
739 is a Boolean and defaults to False. See :hg:`help config.annotate`
739 is a Boolean and defaults to False. See :hg:`help config.annotate`
740 for related options for the annotate command.
740 for related options for the annotate command.
741
741
742 ``git``
742 ``git``
743 Use git extended diff format.
743 Use git extended diff format.
744
744
745 ``nobinary``
745 ``nobinary``
746 Omit git binary patches.
746 Omit git binary patches.
747
747
748 ``nodates``
748 ``nodates``
749 Don't include dates in diff headers.
749 Don't include dates in diff headers.
750
750
751 ``noprefix``
751 ``noprefix``
752 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
752 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
753
753
754 ``showfunc``
754 ``showfunc``
755 Show which function each change is in.
755 Show which function each change is in.
756
756
757 ``ignorews``
757 ``ignorews``
758 Ignore white space when comparing lines.
758 Ignore white space when comparing lines.
759
759
760 ``ignorewsamount``
760 ``ignorewsamount``
761 Ignore changes in the amount of white space.
761 Ignore changes in the amount of white space.
762
762
763 ``ignoreblanklines``
763 ``ignoreblanklines``
764 Ignore changes whose lines are all blank.
764 Ignore changes whose lines are all blank.
765
765
766 ``unified``
766 ``unified``
767 Number of lines of context to show.
767 Number of lines of context to show.
768
768
769 ``word-diff``
769 ``word-diff``
770 Highlight changed words.
770 Highlight changed words.
771
771
772 ``email``
772 ``email``
773 ---------
773 ---------
774
774
775 Settings for extensions that send email messages.
775 Settings for extensions that send email messages.
776
776
777 ``from``
777 ``from``
778 Optional. Email address to use in "From" header and SMTP envelope
778 Optional. Email address to use in "From" header and SMTP envelope
779 of outgoing messages.
779 of outgoing messages.
780
780
781 ``to``
781 ``to``
782 Optional. Comma-separated list of recipients' email addresses.
782 Optional. Comma-separated list of recipients' email addresses.
783
783
784 ``cc``
784 ``cc``
785 Optional. Comma-separated list of carbon copy recipients'
785 Optional. Comma-separated list of carbon copy recipients'
786 email addresses.
786 email addresses.
787
787
788 ``bcc``
788 ``bcc``
789 Optional. Comma-separated list of blind carbon copy recipients'
789 Optional. Comma-separated list of blind carbon copy recipients'
790 email addresses.
790 email addresses.
791
791
792 ``method``
792 ``method``
793 Optional. Method to use to send email messages. If value is ``smtp``
793 Optional. Method to use to send email messages. If value is ``smtp``
794 (default), use SMTP (see the ``[smtp]`` section for configuration).
794 (default), use SMTP (see the ``[smtp]`` section for configuration).
795 Otherwise, use as name of program to run that acts like sendmail
795 Otherwise, use as name of program to run that acts like sendmail
796 (takes ``-f`` option for sender, list of recipients on command line,
796 (takes ``-f`` option for sender, list of recipients on command line,
797 message on stdin). Normally, setting this to ``sendmail`` or
797 message on stdin). Normally, setting this to ``sendmail`` or
798 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
798 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
799
799
800 ``charsets``
800 ``charsets``
801 Optional. Comma-separated list of character sets considered
801 Optional. Comma-separated list of character sets considered
802 convenient for recipients. Addresses, headers, and parts not
802 convenient for recipients. Addresses, headers, and parts not
803 containing patches of outgoing messages will be encoded in the
803 containing patches of outgoing messages will be encoded in the
804 first character set to which conversion from local encoding
804 first character set to which conversion from local encoding
805 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
805 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
806 conversion fails, the text in question is sent as is.
806 conversion fails, the text in question is sent as is.
807 (default: '')
807 (default: '')
808
808
809 Order of outgoing email character sets:
809 Order of outgoing email character sets:
810
810
811 1. ``us-ascii``: always first, regardless of settings
811 1. ``us-ascii``: always first, regardless of settings
812 2. ``email.charsets``: in order given by user
812 2. ``email.charsets``: in order given by user
813 3. ``ui.fallbackencoding``: if not in email.charsets
813 3. ``ui.fallbackencoding``: if not in email.charsets
814 4. ``$HGENCODING``: if not in email.charsets
814 4. ``$HGENCODING``: if not in email.charsets
815 5. ``utf-8``: always last, regardless of settings
815 5. ``utf-8``: always last, regardless of settings
816
816
817 Email example::
817 Email example::
818
818
819 [email]
819 [email]
820 from = Joseph User <joe.user@example.com>
820 from = Joseph User <joe.user@example.com>
821 method = /usr/sbin/sendmail
821 method = /usr/sbin/sendmail
822 # charsets for western Europeans
822 # charsets for western Europeans
823 # us-ascii, utf-8 omitted, as they are tried first and last
823 # us-ascii, utf-8 omitted, as they are tried first and last
824 charsets = iso-8859-1, iso-8859-15, windows-1252
824 charsets = iso-8859-1, iso-8859-15, windows-1252
825
825
826
826
827 ``extensions``
827 ``extensions``
828 --------------
828 --------------
829
829
830 Mercurial has an extension mechanism for adding new features. To
830 Mercurial has an extension mechanism for adding new features. To
831 enable an extension, create an entry for it in this section.
831 enable an extension, create an entry for it in this section.
832
832
833 If you know that the extension is already in Python's search path,
833 If you know that the extension is already in Python's search path,
834 you can give the name of the module, followed by ``=``, with nothing
834 you can give the name of the module, followed by ``=``, with nothing
835 after the ``=``.
835 after the ``=``.
836
836
837 Otherwise, give a name that you choose, followed by ``=``, followed by
837 Otherwise, give a name that you choose, followed by ``=``, followed by
838 the path to the ``.py`` file (including the file name extension) that
838 the path to the ``.py`` file (including the file name extension) that
839 defines the extension.
839 defines the extension.
840
840
841 To explicitly disable an extension that is enabled in an hgrc of
841 To explicitly disable an extension that is enabled in an hgrc of
842 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
842 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
843 or ``foo = !`` when path is not supplied.
843 or ``foo = !`` when path is not supplied.
844
844
845 Example for ``~/.hgrc``::
845 Example for ``~/.hgrc``::
846
846
847 [extensions]
847 [extensions]
848 # (the churn extension will get loaded from Mercurial's path)
848 # (the churn extension will get loaded from Mercurial's path)
849 churn =
849 churn =
850 # (this extension will get loaded from the file specified)
850 # (this extension will get loaded from the file specified)
851 myfeature = ~/.hgext/myfeature.py
851 myfeature = ~/.hgext/myfeature.py
852
852
853
853
854 ``format``
854 ``format``
855 ----------
855 ----------
856
856
857 Configuration that controls the repository format. Newer format options are more
857 Configuration that controls the repository format. Newer format options are more
858 powerful, but incompatible with some older versions of Mercurial. Format options
858 powerful, but incompatible with some older versions of Mercurial. Format options
859 are considered at repository initialization only. You need to make a new clone
859 are considered at repository initialization only. You need to make a new clone
860 for config changes to be taken into account.
860 for config changes to be taken into account.
861
861
862 For more details about repository format and version compatibility, see
862 For more details about repository format and version compatibility, see
863 https://www.mercurial-scm.org/wiki/MissingRequirement
863 https://www.mercurial-scm.org/wiki/MissingRequirement
864
864
865 ``usegeneraldelta``
865 ``usegeneraldelta``
866 Enable or disable the "generaldelta" repository format which improves
866 Enable or disable the "generaldelta" repository format which improves
867 repository compression by allowing "revlog" to store deltas against
867 repository compression by allowing "revlog" to store deltas against
868 arbitrary revisions instead of the previously stored one. This provides
868 arbitrary revisions instead of the previously stored one. This provides
869 significant improvement for repositories with branches.
869 significant improvement for repositories with branches.
870
870
871 Repositories with this on-disk format require Mercurial version 1.9.
871 Repositories with this on-disk format require Mercurial version 1.9.
872
872
873 Enabled by default.
873 Enabled by default.
874
874
875 ``dotencode``
875 ``dotencode``
876 Enable or disable the "dotencode" repository format which enhances
876 Enable or disable the "dotencode" repository format which enhances
877 the "fncache" repository format (which has to be enabled to use
877 the "fncache" repository format (which has to be enabled to use
878 dotencode) to avoid issues with filenames starting with "._" on
878 dotencode) to avoid issues with filenames starting with "._" on
879 Mac OS X and spaces on Windows.
879 Mac OS X and spaces on Windows.
880
880
881 Repositories with this on-disk format require Mercurial version 1.7.
881 Repositories with this on-disk format require Mercurial version 1.7.
882
882
883 Enabled by default.
883 Enabled by default.
884
884
885 ``usefncache``
885 ``usefncache``
886 Enable or disable the "fncache" repository format which enhances
886 Enable or disable the "fncache" repository format which enhances
887 the "store" repository format (which has to be enabled to use
887 the "store" repository format (which has to be enabled to use
888 fncache) to allow longer filenames and avoids using Windows
888 fncache) to allow longer filenames and avoids using Windows
889 reserved names, e.g. "nul".
889 reserved names, e.g. "nul".
890
890
891 Repositories with this on-disk format require Mercurial version 1.1.
891 Repositories with this on-disk format require Mercurial version 1.1.
892
892
893 Enabled by default.
893 Enabled by default.
894
894
895 ``use-persistent-nodemap``
895 ``use-persistent-nodemap``
896 Enable or disable the "persistent-nodemap" feature which improves
896 Enable or disable the "persistent-nodemap" feature which improves
897 performance if the rust extensions are available.
897 performance if the rust extensions are available.
898
898
899 The "persistence-nodemap" persist the "node -> rev" on disk removing the
899 The "persistence-nodemap" persist the "node -> rev" on disk removing the
900 need to dynamically build that mapping for each Mercurial invocation. This
900 need to dynamically build that mapping for each Mercurial invocation. This
901 significantly reduce the startup cost of various local and server-side
901 significantly reduce the startup cost of various local and server-side
902 operation for larger repository.
902 operation for larger repository.
903
903
904 The performance improving version of this feature is currently only
904 The performance improving version of this feature is currently only
905 implemented in Rust, so people not using a version of Mercurial compiled
905 implemented in Rust, so people not using a version of Mercurial compiled
906 with the Rust part might actually suffer some slowdown. For this reason,
906 with the Rust part might actually suffer some slowdown. For this reason,
907 Such version will by default refuse to access such repositories. That
907 Such version will by default refuse to access such repositories. That
908 behavior can be controlled by configuration. Check
908 behavior can be controlled by configuration. Check
909 :hg:`help config.storage.revlog.persistent-nodemap.slow-path` for details.
909 :hg:`help config.storage.revlog.persistent-nodemap.slow-path` for details.
910
910
911 Repository with this on-disk format require Mercurial version 5.4 or above.
911 Repository with this on-disk format require Mercurial version 5.4 or above.
912
912
913 By default this format variant is disabled if fast implementation is not
913 By default this format variant is disabled if fast implementation is not
914 available and enabled by default if the fast implementation is available.
914 available and enabled by default if the fast implementation is available.
915
915
916 To accomodate install of Mercurial without the fast implementation you can
916 To accomodate install of Mercurial without the fast implementation you can
917 downgrade your repository. To do so run the following command:
917 downgrade your repository. To do so run the following command:
918
918
919 $ hg debugupgraderepo \
919 $ hg debugupgraderepo \
920 --run \
920 --run \
921 --config format.use-persistent-nodemap=False \
921 --config format.use-persistent-nodemap=False \
922 --config storage.revlog.persistent-nodemap.slow-path=allow
922 --config storage.revlog.persistent-nodemap.slow-path=allow
923
923
924 ``use-share-safe``
924 ``use-share-safe``
925 Enforce "safe" behaviors for all "shares" that access this repository.
925 Enforce "safe" behaviors for all "shares" that access this repository.
926
926
927 With this feature, "shares" using this repository as a source will:
927 With this feature, "shares" using this repository as a source will:
928
928
929 * read the source repository's configuration (`<source>/.hg/hgrc`).
929 * read the source repository's configuration (`<source>/.hg/hgrc`).
930 * read and use the source repository's "requirements"
930 * read and use the source repository's "requirements"
931 (except the working copy specific one).
931 (except the working copy specific one).
932
932
933 Without this feature, "shares" using this repository as a source will:
933 Without this feature, "shares" using this repository as a source will:
934
934
935 * keep tracking the repository "requirements" in the share only, ignoring
935 * keep tracking the repository "requirements" in the share only, ignoring
936 the source "requirements", possibly diverging from them.
936 the source "requirements", possibly diverging from them.
937 * ignore source repository config. This can create problems, like silently
937 * ignore source repository config. This can create problems, like silently
938 ignoring important hooks.
938 ignoring important hooks.
939
939
940 Beware that existing shares will not be upgraded/downgraded, and by
940 Beware that existing shares will not be upgraded/downgraded, and by
941 default, Mercurial will refuse to interact with them until the mismatch
941 default, Mercurial will refuse to interact with them until the mismatch
942 is resolved. See :hg:`help config share.safe-mismatch.source-safe` and
942 is resolved. See :hg:`help config share.safe-mismatch.source-safe` and
943 :hg:`help config share.safe-mismatch.source-not-safe` for details.
943 :hg:`help config share.safe-mismatch.source-not-safe` for details.
944
944
945 Introduced in Mercurial 5.7.
945 Introduced in Mercurial 5.7.
946
946
947 Disabled by default.
947 Disabled by default.
948
948
949 ``usestore``
949 ``usestore``
950 Enable or disable the "store" repository format which improves
950 Enable or disable the "store" repository format which improves
951 compatibility with systems that fold case or otherwise mangle
951 compatibility with systems that fold case or otherwise mangle
952 filenames. Disabling this option will allow you to store longer filenames
952 filenames. Disabling this option will allow you to store longer filenames
953 in some situations at the expense of compatibility.
953 in some situations at the expense of compatibility.
954
954
955 Repositories with this on-disk format require Mercurial version 0.9.4.
955 Repositories with this on-disk format require Mercurial version 0.9.4.
956
956
957 Enabled by default.
957 Enabled by default.
958
958
959 ``sparse-revlog``
959 ``sparse-revlog``
960 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
960 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
961 delta re-use inside revlog. For very branchy repositories, it results in a
961 delta re-use inside revlog. For very branchy repositories, it results in a
962 smaller store. For repositories with many revisions, it also helps
962 smaller store. For repositories with many revisions, it also helps
963 performance (by using shortened delta chains.)
963 performance (by using shortened delta chains.)
964
964
965 Repositories with this on-disk format require Mercurial version 4.7
965 Repositories with this on-disk format require Mercurial version 4.7
966
966
967 Enabled by default.
967 Enabled by default.
968
968
969 ``revlog-compression``
969 ``revlog-compression``
970 Compression algorithm used by revlog. Supported values are `zlib` and
970 Compression algorithm used by revlog. Supported values are `zlib` and
971 `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
971 `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
972 a newer format that is usually a net win over `zlib`, operating faster at
972 a newer format that is usually a net win over `zlib`, operating faster at
973 better compression rates. Use `zstd` to reduce CPU usage. Multiple values
973 better compression rates. Use `zstd` to reduce CPU usage. Multiple values
974 can be specified, the first available one will be used.
974 can be specified, the first available one will be used.
975
975
976 On some systems, the Mercurial installation may lack `zstd` support.
976 On some systems, the Mercurial installation may lack `zstd` support.
977
977
978 Default is `zstd` if available, `zlib` otherwise.
978 Default is `zstd` if available, `zlib` otherwise.
979
979
980 ``bookmarks-in-store``
980 ``bookmarks-in-store``
981 Store bookmarks in .hg/store/. This means that bookmarks are shared when
981 Store bookmarks in .hg/store/. This means that bookmarks are shared when
982 using `hg share` regardless of the `-B` option.
982 using `hg share` regardless of the `-B` option.
983
983
984 Repositories with this on-disk format require Mercurial version 5.1.
984 Repositories with this on-disk format require Mercurial version 5.1.
985
985
986 Disabled by default.
986 Disabled by default.
987
987
988
988
989 ``graph``
989 ``graph``
990 ---------
990 ---------
991
991
992 Web graph view configuration. This section let you change graph
992 Web graph view configuration. This section let you change graph
993 elements display properties by branches, for instance to make the
993 elements display properties by branches, for instance to make the
994 ``default`` branch stand out.
994 ``default`` branch stand out.
995
995
996 Each line has the following format::
996 Each line has the following format::
997
997
998 <branch>.<argument> = <value>
998 <branch>.<argument> = <value>
999
999
1000 where ``<branch>`` is the name of the branch being
1000 where ``<branch>`` is the name of the branch being
1001 customized. Example::
1001 customized. Example::
1002
1002
1003 [graph]
1003 [graph]
1004 # 2px width
1004 # 2px width
1005 default.width = 2
1005 default.width = 2
1006 # red color
1006 # red color
1007 default.color = FF0000
1007 default.color = FF0000
1008
1008
1009 Supported arguments:
1009 Supported arguments:
1010
1010
1011 ``width``
1011 ``width``
1012 Set branch edges width in pixels.
1012 Set branch edges width in pixels.
1013
1013
1014 ``color``
1014 ``color``
1015 Set branch edges color in hexadecimal RGB notation.
1015 Set branch edges color in hexadecimal RGB notation.
1016
1016
1017 ``hooks``
1017 ``hooks``
1018 ---------
1018 ---------
1019
1019
1020 Commands or Python functions that get automatically executed by
1020 Commands or Python functions that get automatically executed by
1021 various actions such as starting or finishing a commit. Multiple
1021 various actions such as starting or finishing a commit. Multiple
1022 hooks can be run for the same action by appending a suffix to the
1022 hooks can be run for the same action by appending a suffix to the
1023 action. Overriding a site-wide hook can be done by changing its
1023 action. Overriding a site-wide hook can be done by changing its
1024 value or setting it to an empty string. Hooks can be prioritized
1024 value or setting it to an empty string. Hooks can be prioritized
1025 by adding a prefix of ``priority.`` to the hook name on a new line
1025 by adding a prefix of ``priority.`` to the hook name on a new line
1026 and setting the priority. The default priority is 0.
1026 and setting the priority. The default priority is 0.
1027
1027
1028 Example ``.hg/hgrc``::
1028 Example ``.hg/hgrc``::
1029
1029
1030 [hooks]
1030 [hooks]
1031 # update working directory after adding changesets
1031 # update working directory after adding changesets
1032 changegroup.update = hg update
1032 changegroup.update = hg update
1033 # do not use the site-wide hook
1033 # do not use the site-wide hook
1034 incoming =
1034 incoming =
1035 incoming.email = /my/email/hook
1035 incoming.email = /my/email/hook
1036 incoming.autobuild = /my/build/hook
1036 incoming.autobuild = /my/build/hook
1037 # force autobuild hook to run before other incoming hooks
1037 # force autobuild hook to run before other incoming hooks
1038 priority.incoming.autobuild = 1
1038 priority.incoming.autobuild = 1
1039 ### control HGPLAIN setting when running autobuild hook
1039 ### control HGPLAIN setting when running autobuild hook
1040 # HGPLAIN always set (default from Mercurial 5.7)
1040 # HGPLAIN always set (default from Mercurial 5.7)
1041 incoming.autobuild:run-with-plain = yes
1041 incoming.autobuild:run-with-plain = yes
1042 # HGPLAIN never set
1042 # HGPLAIN never set
1043 incoming.autobuild:run-with-plain = no
1043 incoming.autobuild:run-with-plain = no
1044 # HGPLAIN inherited from environment (default before Mercurial 5.7)
1044 # HGPLAIN inherited from environment (default before Mercurial 5.7)
1045 incoming.autobuild:run-with-plain = auto
1045 incoming.autobuild:run-with-plain = auto
1046
1046
1047 Most hooks are run with environment variables set that give useful
1047 Most hooks are run with environment variables set that give useful
1048 additional information. For each hook below, the environment variables
1048 additional information. For each hook below, the environment variables
1049 it is passed are listed with names in the form ``$HG_foo``. The
1049 it is passed are listed with names in the form ``$HG_foo``. The
1050 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
1050 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
1051 They contain the type of hook which triggered the run and the full name
1051 They contain the type of hook which triggered the run and the full name
1052 of the hook in the config, respectively. In the example above, this will
1052 of the hook in the config, respectively. In the example above, this will
1053 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
1053 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
1054
1054
1055 .. container:: windows
1055 .. container:: windows
1056
1056
1057 Some basic Unix syntax can be enabled for portability, including ``$VAR``
1057 Some basic Unix syntax can be enabled for portability, including ``$VAR``
1058 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
1058 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
1059 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
1059 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
1060 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
1060 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
1061 slash or inside of a strong quote. Strong quotes will be replaced by
1061 slash or inside of a strong quote. Strong quotes will be replaced by
1062 double quotes after processing.
1062 double quotes after processing.
1063
1063
1064 This feature is enabled by adding a prefix of ``tonative.`` to the hook
1064 This feature is enabled by adding a prefix of ``tonative.`` to the hook
1065 name on a new line, and setting it to ``True``. For example::
1065 name on a new line, and setting it to ``True``. For example::
1066
1066
1067 [hooks]
1067 [hooks]
1068 incoming.autobuild = /my/build/hook
1068 incoming.autobuild = /my/build/hook
1069 # enable translation to cmd.exe syntax for autobuild hook
1069 # enable translation to cmd.exe syntax for autobuild hook
1070 tonative.incoming.autobuild = True
1070 tonative.incoming.autobuild = True
1071
1071
1072 ``changegroup``
1072 ``changegroup``
1073 Run after a changegroup has been added via push, pull or unbundle. The ID of
1073 Run after a changegroup has been added via push, pull or unbundle. The ID of
1074 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
1074 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
1075 The URL from which changes came is in ``$HG_URL``.
1075 The URL from which changes came is in ``$HG_URL``.
1076
1076
1077 ``commit``
1077 ``commit``
1078 Run after a changeset has been created in the local repository. The ID
1078 Run after a changeset has been created in the local repository. The ID
1079 of the newly created changeset is in ``$HG_NODE``. Parent changeset
1079 of the newly created changeset is in ``$HG_NODE``. Parent changeset
1080 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1080 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1081
1081
1082 ``incoming``
1082 ``incoming``
1083 Run after a changeset has been pulled, pushed, or unbundled into
1083 Run after a changeset has been pulled, pushed, or unbundled into
1084 the local repository. The ID of the newly arrived changeset is in
1084 the local repository. The ID of the newly arrived changeset is in
1085 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1085 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1086
1086
1087 ``outgoing``
1087 ``outgoing``
1088 Run after sending changes from the local repository to another. The ID of
1088 Run after sending changes from the local repository to another. The ID of
1089 first changeset sent is in ``$HG_NODE``. The source of operation is in
1089 first changeset sent is in ``$HG_NODE``. The source of operation is in
1090 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1090 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1091
1091
1092 ``post-<command>``
1092 ``post-<command>``
1093 Run after successful invocations of the associated command. The
1093 Run after successful invocations of the associated command. The
1094 contents of the command line are passed as ``$HG_ARGS`` and the result
1094 contents of the command line are passed as ``$HG_ARGS`` and the result
1095 code in ``$HG_RESULT``. Parsed command line arguments are passed as
1095 code in ``$HG_RESULT``. Parsed command line arguments are passed as
1096 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1096 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1097 the python data internally passed to <command>. ``$HG_OPTS`` is a
1097 the python data internally passed to <command>. ``$HG_OPTS`` is a
1098 dictionary of options (with unspecified options set to their defaults).
1098 dictionary of options (with unspecified options set to their defaults).
1099 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1099 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1100
1100
1101 ``fail-<command>``
1101 ``fail-<command>``
1102 Run after a failed invocation of an associated command. The contents
1102 Run after a failed invocation of an associated command. The contents
1103 of the command line are passed as ``$HG_ARGS``. Parsed command line
1103 of the command line are passed as ``$HG_ARGS``. Parsed command line
1104 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1104 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1105 string representations of the python data internally passed to
1105 string representations of the python data internally passed to
1106 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1106 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1107 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1107 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1108 Hook failure is ignored.
1108 Hook failure is ignored.
1109
1109
1110 ``pre-<command>``
1110 ``pre-<command>``
1111 Run before executing the associated command. The contents of the
1111 Run before executing the associated command. The contents of the
1112 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1112 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1113 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1113 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1114 representations of the data internally passed to <command>. ``$HG_OPTS``
1114 representations of the data internally passed to <command>. ``$HG_OPTS``
1115 is a dictionary of options (with unspecified options set to their
1115 is a dictionary of options (with unspecified options set to their
1116 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1116 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1117 failure, the command doesn't execute and Mercurial returns the failure
1117 failure, the command doesn't execute and Mercurial returns the failure
1118 code.
1118 code.
1119
1119
1120 ``prechangegroup``
1120 ``prechangegroup``
1121 Run before a changegroup is added via push, pull or unbundle. Exit
1121 Run before a changegroup is added via push, pull or unbundle. Exit
1122 status 0 allows the changegroup to proceed. A non-zero status will
1122 status 0 allows the changegroup to proceed. A non-zero status will
1123 cause the push, pull or unbundle to fail. The URL from which changes
1123 cause the push, pull or unbundle to fail. The URL from which changes
1124 will come is in ``$HG_URL``.
1124 will come is in ``$HG_URL``.
1125
1125
1126 ``precommit``
1126 ``precommit``
1127 Run before starting a local commit. Exit status 0 allows the
1127 Run before starting a local commit. Exit status 0 allows the
1128 commit to proceed. A non-zero status will cause the commit to fail.
1128 commit to proceed. A non-zero status will cause the commit to fail.
1129 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1129 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1130
1130
1131 ``prelistkeys``
1131 ``prelistkeys``
1132 Run before listing pushkeys (like bookmarks) in the
1132 Run before listing pushkeys (like bookmarks) in the
1133 repository. A non-zero status will cause failure. The key namespace is
1133 repository. A non-zero status will cause failure. The key namespace is
1134 in ``$HG_NAMESPACE``.
1134 in ``$HG_NAMESPACE``.
1135
1135
1136 ``preoutgoing``
1136 ``preoutgoing``
1137 Run before collecting changes to send from the local repository to
1137 Run before collecting changes to send from the local repository to
1138 another. A non-zero status will cause failure. This lets you prevent
1138 another. A non-zero status will cause failure. This lets you prevent
1139 pull over HTTP or SSH. It can also prevent propagating commits (via
1139 pull over HTTP or SSH. It can also prevent propagating commits (via
1140 local pull, push (outbound) or bundle commands), but not completely,
1140 local pull, push (outbound) or bundle commands), but not completely,
1141 since you can just copy files instead. The source of operation is in
1141 since you can just copy files instead. The source of operation is in
1142 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1142 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1143 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1143 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1144 is happening on behalf of a repository on same system.
1144 is happening on behalf of a repository on same system.
1145
1145
1146 ``prepushkey``
1146 ``prepushkey``
1147 Run before a pushkey (like a bookmark) is added to the
1147 Run before a pushkey (like a bookmark) is added to the
1148 repository. A non-zero status will cause the key to be rejected. The
1148 repository. A non-zero status will cause the key to be rejected. The
1149 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1149 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1150 the old value (if any) is in ``$HG_OLD``, and the new value is in
1150 the old value (if any) is in ``$HG_OLD``, and the new value is in
1151 ``$HG_NEW``.
1151 ``$HG_NEW``.
1152
1152
1153 ``pretag``
1153 ``pretag``
1154 Run before creating a tag. Exit status 0 allows the tag to be
1154 Run before creating a tag. Exit status 0 allows the tag to be
1155 created. A non-zero status will cause the tag to fail. The ID of the
1155 created. A non-zero status will cause the tag to fail. The ID of the
1156 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1156 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1157 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1157 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1158
1158
1159 ``pretxnopen``
1159 ``pretxnopen``
1160 Run before any new repository transaction is open. The reason for the
1160 Run before any new repository transaction is open. The reason for the
1161 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1161 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1162 transaction will be in ``$HG_TXNID``. A non-zero status will prevent the
1162 transaction will be in ``$HG_TXNID``. A non-zero status will prevent the
1163 transaction from being opened.
1163 transaction from being opened.
1164
1164
1165 ``pretxnclose``
1165 ``pretxnclose``
1166 Run right before the transaction is actually finalized. Any repository change
1166 Run right before the transaction is actually finalized. Any repository change
1167 will be visible to the hook program. This lets you validate the transaction
1167 will be visible to the hook program. This lets you validate the transaction
1168 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1168 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1169 status will cause the transaction to be rolled back. The reason for the
1169 status will cause the transaction to be rolled back. The reason for the
1170 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1170 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1171 the transaction will be in ``$HG_TXNID``. The rest of the available data will
1171 the transaction will be in ``$HG_TXNID``. The rest of the available data will
1172 vary according the transaction type. Changes unbundled to the repository will
1172 vary according the transaction type. Changes unbundled to the repository will
1173 add ``$HG_URL`` and ``$HG_SOURCE``. New changesets will add ``$HG_NODE`` (the
1173 add ``$HG_URL`` and ``$HG_SOURCE``. New changesets will add ``$HG_NODE`` (the
1174 ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last added
1174 ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last added
1175 changeset). Bookmark and phase changes will set ``$HG_BOOKMARK_MOVED`` and
1175 changeset). Bookmark and phase changes will set ``$HG_BOOKMARK_MOVED`` and
1176 ``$HG_PHASES_MOVED`` to ``1`` respectively. The number of new obsmarkers, if
1176 ``$HG_PHASES_MOVED`` to ``1`` respectively. The number of new obsmarkers, if
1177 any, will be in ``$HG_NEW_OBSMARKERS``, etc.
1177 any, will be in ``$HG_NEW_OBSMARKERS``, etc.
1178
1178
1179 ``pretxnclose-bookmark``
1179 ``pretxnclose-bookmark``
1180 Run right before a bookmark change is actually finalized. Any repository
1180 Run right before a bookmark change is actually finalized. Any repository
1181 change will be visible to the hook program. This lets you validate the
1181 change will be visible to the hook program. This lets you validate the
1182 transaction content or change it. Exit status 0 allows the commit to
1182 transaction content or change it. Exit status 0 allows the commit to
1183 proceed. A non-zero status will cause the transaction to be rolled back.
1183 proceed. A non-zero status will cause the transaction to be rolled back.
1184 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1184 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1185 bookmark location will be available in ``$HG_NODE`` while the previous
1185 bookmark location will be available in ``$HG_NODE`` while the previous
1186 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1186 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1187 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1187 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1188 will be empty.
1188 will be empty.
1189 In addition, the reason for the transaction opening will be in
1189 In addition, the reason for the transaction opening will be in
1190 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1190 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1191 ``$HG_TXNID``.
1191 ``$HG_TXNID``.
1192
1192
1193 ``pretxnclose-phase``
1193 ``pretxnclose-phase``
1194 Run right before a phase change is actually finalized. Any repository change
1194 Run right before a phase change is actually finalized. Any repository change
1195 will be visible to the hook program. This lets you validate the transaction
1195 will be visible to the hook program. This lets you validate the transaction
1196 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1196 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1197 status will cause the transaction to be rolled back. The hook is called
1197 status will cause the transaction to be rolled back. The hook is called
1198 multiple times, once for each revision affected by a phase change.
1198 multiple times, once for each revision affected by a phase change.
1199 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1199 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1200 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1200 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1201 will be empty. In addition, the reason for the transaction opening will be in
1201 will be empty. In addition, the reason for the transaction opening will be in
1202 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1202 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1203 ``$HG_TXNID``. The hook is also run for newly added revisions. In this case
1203 ``$HG_TXNID``. The hook is also run for newly added revisions. In this case
1204 the ``$HG_OLDPHASE`` entry will be empty.
1204 the ``$HG_OLDPHASE`` entry will be empty.
1205
1205
1206 ``txnclose``
1206 ``txnclose``
1207 Run after any repository transaction has been committed. At this
1207 Run after any repository transaction has been committed. At this
1208 point, the transaction can no longer be rolled back. The hook will run
1208 point, the transaction can no longer be rolled back. The hook will run
1209 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1209 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1210 details about available variables.
1210 details about available variables.
1211
1211
1212 ``txnclose-bookmark``
1212 ``txnclose-bookmark``
1213 Run after any bookmark change has been committed. At this point, the
1213 Run after any bookmark change has been committed. At this point, the
1214 transaction can no longer be rolled back. The hook will run after the lock
1214 transaction can no longer be rolled back. The hook will run after the lock
1215 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1215 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1216 about available variables.
1216 about available variables.
1217
1217
1218 ``txnclose-phase``
1218 ``txnclose-phase``
1219 Run after any phase change has been committed. At this point, the
1219 Run after any phase change has been committed. At this point, the
1220 transaction can no longer be rolled back. The hook will run after the lock
1220 transaction can no longer be rolled back. The hook will run after the lock
1221 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1221 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1222 available variables.
1222 available variables.
1223
1223
1224 ``txnabort``
1224 ``txnabort``
1225 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1225 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1226 for details about available variables.
1226 for details about available variables.
1227
1227
1228 ``pretxnchangegroup``
1228 ``pretxnchangegroup``
1229 Run after a changegroup has been added via push, pull or unbundle, but before
1229 Run after a changegroup has been added via push, pull or unbundle, but before
1230 the transaction has been committed. The changegroup is visible to the hook
1230 the transaction has been committed. The changegroup is visible to the hook
1231 program. This allows validation of incoming changes before accepting them.
1231 program. This allows validation of incoming changes before accepting them.
1232 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1232 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1233 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1233 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1234 status will cause the transaction to be rolled back, and the push, pull or
1234 status will cause the transaction to be rolled back, and the push, pull or
1235 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1235 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1236
1236
1237 ``pretxncommit``
1237 ``pretxncommit``
1238 Run after a changeset has been created, but before the transaction is
1238 Run after a changeset has been created, but before the transaction is
1239 committed. The changeset is visible to the hook program. This allows
1239 committed. The changeset is visible to the hook program. This allows
1240 validation of the commit message and changes. Exit status 0 allows the
1240 validation of the commit message and changes. Exit status 0 allows the
1241 commit to proceed. A non-zero status will cause the transaction to
1241 commit to proceed. A non-zero status will cause the transaction to
1242 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1242 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1243 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1243 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1244
1244
1245 ``preupdate``
1245 ``preupdate``
1246 Run before updating the working directory. Exit status 0 allows
1246 Run before updating the working directory. Exit status 0 allows
1247 the update to proceed. A non-zero status will prevent the update.
1247 the update to proceed. A non-zero status will prevent the update.
1248 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1248 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1249 merge, the ID of second new parent is in ``$HG_PARENT2``.
1249 merge, the ID of second new parent is in ``$HG_PARENT2``.
1250
1250
1251 ``listkeys``
1251 ``listkeys``
1252 Run after listing pushkeys (like bookmarks) in the repository. The
1252 Run after listing pushkeys (like bookmarks) in the repository. The
1253 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1253 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1254 dictionary containing the keys and values.
1254 dictionary containing the keys and values.
1255
1255
1256 ``pushkey``
1256 ``pushkey``
1257 Run after a pushkey (like a bookmark) is added to the
1257 Run after a pushkey (like a bookmark) is added to the
1258 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1258 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1259 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1259 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1260 value is in ``$HG_NEW``.
1260 value is in ``$HG_NEW``.
1261
1261
1262 ``tag``
1262 ``tag``
1263 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1263 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1264 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1264 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1265 the repository if ``$HG_LOCAL=0``.
1265 the repository if ``$HG_LOCAL=0``.
1266
1266
1267 ``update``
1267 ``update``
1268 Run after updating the working directory. The changeset ID of first
1268 Run after updating the working directory. The changeset ID of first
1269 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1269 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1270 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1270 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1271 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1271 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1272
1272
1273 .. note::
1273 .. note::
1274
1274
1275 It is generally better to use standard hooks rather than the
1275 It is generally better to use standard hooks rather than the
1276 generic pre- and post- command hooks, as they are guaranteed to be
1276 generic pre- and post- command hooks, as they are guaranteed to be
1277 called in the appropriate contexts for influencing transactions.
1277 called in the appropriate contexts for influencing transactions.
1278 Also, hooks like "commit" will be called in all contexts that
1278 Also, hooks like "commit" will be called in all contexts that
1279 generate a commit (e.g. tag) and not just the commit command.
1279 generate a commit (e.g. tag) and not just the commit command.
1280
1280
1281 .. note::
1281 .. note::
1282
1282
1283 Environment variables with empty values may not be passed to
1283 Environment variables with empty values may not be passed to
1284 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1284 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1285 will have an empty value under Unix-like platforms for non-merge
1285 will have an empty value under Unix-like platforms for non-merge
1286 changesets, while it will not be available at all under Windows.
1286 changesets, while it will not be available at all under Windows.
1287
1287
1288 The syntax for Python hooks is as follows::
1288 The syntax for Python hooks is as follows::
1289
1289
1290 hookname = python:modulename.submodule.callable
1290 hookname = python:modulename.submodule.callable
1291 hookname = python:/path/to/python/module.py:callable
1291 hookname = python:/path/to/python/module.py:callable
1292
1292
1293 Python hooks are run within the Mercurial process. Each hook is
1293 Python hooks are run within the Mercurial process. Each hook is
1294 called with at least three keyword arguments: a ui object (keyword
1294 called with at least three keyword arguments: a ui object (keyword
1295 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1295 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1296 keyword that tells what kind of hook is used. Arguments listed as
1296 keyword that tells what kind of hook is used. Arguments listed as
1297 environment variables above are passed as keyword arguments, with no
1297 environment variables above are passed as keyword arguments, with no
1298 ``HG_`` prefix, and names in lower case.
1298 ``HG_`` prefix, and names in lower case.
1299
1299
1300 If a Python hook returns a "true" value or raises an exception, this
1300 If a Python hook returns a "true" value or raises an exception, this
1301 is treated as a failure.
1301 is treated as a failure.
1302
1302
1303
1303
1304 ``hostfingerprints``
1304 ``hostfingerprints``
1305 --------------------
1305 --------------------
1306
1306
1307 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1307 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1308
1308
1309 Fingerprints of the certificates of known HTTPS servers.
1309 Fingerprints of the certificates of known HTTPS servers.
1310
1310
1311 A HTTPS connection to a server with a fingerprint configured here will
1311 A HTTPS connection to a server with a fingerprint configured here will
1312 only succeed if the servers certificate matches the fingerprint.
1312 only succeed if the servers certificate matches the fingerprint.
1313 This is very similar to how ssh known hosts works.
1313 This is very similar to how ssh known hosts works.
1314
1314
1315 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1315 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1316 Multiple values can be specified (separated by spaces or commas). This can
1316 Multiple values can be specified (separated by spaces or commas). This can
1317 be used to define both old and new fingerprints while a host transitions
1317 be used to define both old and new fingerprints while a host transitions
1318 to a new certificate.
1318 to a new certificate.
1319
1319
1320 The CA chain and web.cacerts is not used for servers with a fingerprint.
1320 The CA chain and web.cacerts is not used for servers with a fingerprint.
1321
1321
1322 For example::
1322 For example::
1323
1323
1324 [hostfingerprints]
1324 [hostfingerprints]
1325 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1325 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1326 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1326 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1327
1327
1328 ``hostsecurity``
1328 ``hostsecurity``
1329 ----------------
1329 ----------------
1330
1330
1331 Used to specify global and per-host security settings for connecting to
1331 Used to specify global and per-host security settings for connecting to
1332 other machines.
1332 other machines.
1333
1333
1334 The following options control default behavior for all hosts.
1334 The following options control default behavior for all hosts.
1335
1335
1336 ``ciphers``
1336 ``ciphers``
1337 Defines the cryptographic ciphers to use for connections.
1337 Defines the cryptographic ciphers to use for connections.
1338
1338
1339 Value must be a valid OpenSSL Cipher List Format as documented at
1339 Value must be a valid OpenSSL Cipher List Format as documented at
1340 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1340 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1341
1341
1342 This setting is for advanced users only. Setting to incorrect values
1342 This setting is for advanced users only. Setting to incorrect values
1343 can significantly lower connection security or decrease performance.
1343 can significantly lower connection security or decrease performance.
1344 You have been warned.
1344 You have been warned.
1345
1345
1346 This option requires Python 2.7.
1346 This option requires Python 2.7.
1347
1347
1348 ``minimumprotocol``
1348 ``minimumprotocol``
1349 Defines the minimum channel encryption protocol to use.
1349 Defines the minimum channel encryption protocol to use.
1350
1350
1351 By default, the highest version of TLS supported by both client and server
1351 By default, the highest version of TLS supported by both client and server
1352 is used.
1352 is used.
1353
1353
1354 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1354 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1355
1355
1356 When running on an old Python version, only ``tls1.0`` is allowed since
1356 When running on an old Python version, only ``tls1.0`` is allowed since
1357 old versions of Python only support up to TLS 1.0.
1357 old versions of Python only support up to TLS 1.0.
1358
1358
1359 When running a Python that supports modern TLS versions, the default is
1359 When running a Python that supports modern TLS versions, the default is
1360 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1360 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1361 weakens security and should only be used as a feature of last resort if
1361 weakens security and should only be used as a feature of last resort if
1362 a server does not support TLS 1.1+.
1362 a server does not support TLS 1.1+.
1363
1363
1364 Options in the ``[hostsecurity]`` section can have the form
1364 Options in the ``[hostsecurity]`` section can have the form
1365 ``hostname``:``setting``. This allows multiple settings to be defined on a
1365 ``hostname``:``setting``. This allows multiple settings to be defined on a
1366 per-host basis.
1366 per-host basis.
1367
1367
1368 The following per-host settings can be defined.
1368 The following per-host settings can be defined.
1369
1369
1370 ``ciphers``
1370 ``ciphers``
1371 This behaves like ``ciphers`` as described above except it only applies
1371 This behaves like ``ciphers`` as described above except it only applies
1372 to the host on which it is defined.
1372 to the host on which it is defined.
1373
1373
1374 ``fingerprints``
1374 ``fingerprints``
1375 A list of hashes of the DER encoded peer/remote certificate. Values have
1375 A list of hashes of the DER encoded peer/remote certificate. Values have
1376 the form ``algorithm``:``fingerprint``. e.g.
1376 the form ``algorithm``:``fingerprint``. e.g.
1377 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1377 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1378 In addition, colons (``:``) can appear in the fingerprint part.
1378 In addition, colons (``:``) can appear in the fingerprint part.
1379
1379
1380 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1380 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1381 ``sha512``.
1381 ``sha512``.
1382
1382
1383 Use of ``sha256`` or ``sha512`` is preferred.
1383 Use of ``sha256`` or ``sha512`` is preferred.
1384
1384
1385 If a fingerprint is specified, the CA chain is not validated for this
1385 If a fingerprint is specified, the CA chain is not validated for this
1386 host and Mercurial will require the remote certificate to match one
1386 host and Mercurial will require the remote certificate to match one
1387 of the fingerprints specified. This means if the server updates its
1387 of the fingerprints specified. This means if the server updates its
1388 certificate, Mercurial will abort until a new fingerprint is defined.
1388 certificate, Mercurial will abort until a new fingerprint is defined.
1389 This can provide stronger security than traditional CA-based validation
1389 This can provide stronger security than traditional CA-based validation
1390 at the expense of convenience.
1390 at the expense of convenience.
1391
1391
1392 This option takes precedence over ``verifycertsfile``.
1392 This option takes precedence over ``verifycertsfile``.
1393
1393
1394 ``minimumprotocol``
1394 ``minimumprotocol``
1395 This behaves like ``minimumprotocol`` as described above except it
1395 This behaves like ``minimumprotocol`` as described above except it
1396 only applies to the host on which it is defined.
1396 only applies to the host on which it is defined.
1397
1397
1398 ``verifycertsfile``
1398 ``verifycertsfile``
1399 Path to file a containing a list of PEM encoded certificates used to
1399 Path to file a containing a list of PEM encoded certificates used to
1400 verify the server certificate. Environment variables and ``~user``
1400 verify the server certificate. Environment variables and ``~user``
1401 constructs are expanded in the filename.
1401 constructs are expanded in the filename.
1402
1402
1403 The server certificate or the certificate's certificate authority (CA)
1403 The server certificate or the certificate's certificate authority (CA)
1404 must match a certificate from this file or certificate verification
1404 must match a certificate from this file or certificate verification
1405 will fail and connections to the server will be refused.
1405 will fail and connections to the server will be refused.
1406
1406
1407 If defined, only certificates provided by this file will be used:
1407 If defined, only certificates provided by this file will be used:
1408 ``web.cacerts`` and any system/default certificates will not be
1408 ``web.cacerts`` and any system/default certificates will not be
1409 used.
1409 used.
1410
1410
1411 This option has no effect if the per-host ``fingerprints`` option
1411 This option has no effect if the per-host ``fingerprints`` option
1412 is set.
1412 is set.
1413
1413
1414 The format of the file is as follows::
1414 The format of the file is as follows::
1415
1415
1416 -----BEGIN CERTIFICATE-----
1416 -----BEGIN CERTIFICATE-----
1417 ... (certificate in base64 PEM encoding) ...
1417 ... (certificate in base64 PEM encoding) ...
1418 -----END CERTIFICATE-----
1418 -----END CERTIFICATE-----
1419 -----BEGIN CERTIFICATE-----
1419 -----BEGIN CERTIFICATE-----
1420 ... (certificate in base64 PEM encoding) ...
1420 ... (certificate in base64 PEM encoding) ...
1421 -----END CERTIFICATE-----
1421 -----END CERTIFICATE-----
1422
1422
1423 For example::
1423 For example::
1424
1424
1425 [hostsecurity]
1425 [hostsecurity]
1426 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1426 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1427 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
1427 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
1428 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
1428 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
1429 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1429 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1430
1430
1431 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1431 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1432 when connecting to ``hg.example.com``::
1432 when connecting to ``hg.example.com``::
1433
1433
1434 [hostsecurity]
1434 [hostsecurity]
1435 minimumprotocol = tls1.2
1435 minimumprotocol = tls1.2
1436 hg.example.com:minimumprotocol = tls1.1
1436 hg.example.com:minimumprotocol = tls1.1
1437
1437
1438 ``http_proxy``
1438 ``http_proxy``
1439 --------------
1439 --------------
1440
1440
1441 Used to access web-based Mercurial repositories through a HTTP
1441 Used to access web-based Mercurial repositories through a HTTP
1442 proxy.
1442 proxy.
1443
1443
1444 ``host``
1444 ``host``
1445 Host name and (optional) port of the proxy server, for example
1445 Host name and (optional) port of the proxy server, for example
1446 "myproxy:8000".
1446 "myproxy:8000".
1447
1447
1448 ``no``
1448 ``no``
1449 Optional. Comma-separated list of host names that should bypass
1449 Optional. Comma-separated list of host names that should bypass
1450 the proxy.
1450 the proxy.
1451
1451
1452 ``passwd``
1452 ``passwd``
1453 Optional. Password to authenticate with at the proxy server.
1453 Optional. Password to authenticate with at the proxy server.
1454
1454
1455 ``user``
1455 ``user``
1456 Optional. User name to authenticate with at the proxy server.
1456 Optional. User name to authenticate with at the proxy server.
1457
1457
1458 ``always``
1458 ``always``
1459 Optional. Always use the proxy, even for localhost and any entries
1459 Optional. Always use the proxy, even for localhost and any entries
1460 in ``http_proxy.no``. (default: False)
1460 in ``http_proxy.no``. (default: False)
1461
1461
1462 ``http``
1462 ``http``
1463 ----------
1463 ----------
1464
1464
1465 Used to configure access to Mercurial repositories via HTTP.
1465 Used to configure access to Mercurial repositories via HTTP.
1466
1466
1467 ``timeout``
1467 ``timeout``
1468 If set, blocking operations will timeout after that many seconds.
1468 If set, blocking operations will timeout after that many seconds.
1469 (default: None)
1469 (default: None)
1470
1470
1471 ``merge``
1471 ``merge``
1472 ---------
1472 ---------
1473
1473
1474 This section specifies behavior during merges and updates.
1474 This section specifies behavior during merges and updates.
1475
1475
1476 ``checkignored``
1476 ``checkignored``
1477 Controls behavior when an ignored file on disk has the same name as a tracked
1477 Controls behavior when an ignored file on disk has the same name as a tracked
1478 file in the changeset being merged or updated to, and has different
1478 file in the changeset being merged or updated to, and has different
1479 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1479 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1480 abort on such files. With ``warn``, warn on such files and back them up as
1480 abort on such files. With ``warn``, warn on such files and back them up as
1481 ``.orig``. With ``ignore``, don't print a warning and back them up as
1481 ``.orig``. With ``ignore``, don't print a warning and back them up as
1482 ``.orig``. (default: ``abort``)
1482 ``.orig``. (default: ``abort``)
1483
1483
1484 ``checkunknown``
1484 ``checkunknown``
1485 Controls behavior when an unknown file that isn't ignored has the same name
1485 Controls behavior when an unknown file that isn't ignored has the same name
1486 as a tracked file in the changeset being merged or updated to, and has
1486 as a tracked file in the changeset being merged or updated to, and has
1487 different contents. Similar to ``merge.checkignored``, except for files that
1487 different contents. Similar to ``merge.checkignored``, except for files that
1488 are not ignored. (default: ``abort``)
1488 are not ignored. (default: ``abort``)
1489
1489
1490 ``on-failure``
1490 ``on-failure``
1491 When set to ``continue`` (the default), the merge process attempts to
1491 When set to ``continue`` (the default), the merge process attempts to
1492 merge all unresolved files using the merge chosen tool, regardless of
1492 merge all unresolved files using the merge chosen tool, regardless of
1493 whether previous file merge attempts during the process succeeded or not.
1493 whether previous file merge attempts during the process succeeded or not.
1494 Setting this to ``prompt`` will prompt after any merge failure continue
1494 Setting this to ``prompt`` will prompt after any merge failure continue
1495 or halt the merge process. Setting this to ``halt`` will automatically
1495 or halt the merge process. Setting this to ``halt`` will automatically
1496 halt the merge process on any merge tool failure. The merge process
1496 halt the merge process on any merge tool failure. The merge process
1497 can be restarted by using the ``resolve`` command. When a merge is
1497 can be restarted by using the ``resolve`` command. When a merge is
1498 halted, the repository is left in a normal ``unresolved`` merge state.
1498 halted, the repository is left in a normal ``unresolved`` merge state.
1499 (default: ``continue``)
1499 (default: ``continue``)
1500
1500
1501 ``strict-capability-check``
1501 ``strict-capability-check``
1502 Whether capabilities of internal merge tools are checked strictly
1502 Whether capabilities of internal merge tools are checked strictly
1503 or not, while examining rules to decide merge tool to be used.
1503 or not, while examining rules to decide merge tool to be used.
1504 (default: False)
1504 (default: False)
1505
1505
1506 ``merge-patterns``
1506 ``merge-patterns``
1507 ------------------
1507 ------------------
1508
1508
1509 This section specifies merge tools to associate with particular file
1509 This section specifies merge tools to associate with particular file
1510 patterns. Tools matched here will take precedence over the default
1510 patterns. Tools matched here will take precedence over the default
1511 merge tool. Patterns are globs by default, rooted at the repository
1511 merge tool. Patterns are globs by default, rooted at the repository
1512 root.
1512 root.
1513
1513
1514 Example::
1514 Example::
1515
1515
1516 [merge-patterns]
1516 [merge-patterns]
1517 **.c = kdiff3
1517 **.c = kdiff3
1518 **.jpg = myimgmerge
1518 **.jpg = myimgmerge
1519
1519
1520 ``merge-tools``
1520 ``merge-tools``
1521 ---------------
1521 ---------------
1522
1522
1523 This section configures external merge tools to use for file-level
1523 This section configures external merge tools to use for file-level
1524 merges. This section has likely been preconfigured at install time.
1524 merges. This section has likely been preconfigured at install time.
1525 Use :hg:`config merge-tools` to check the existing configuration.
1525 Use :hg:`config merge-tools` to check the existing configuration.
1526 Also see :hg:`help merge-tools` for more details.
1526 Also see :hg:`help merge-tools` for more details.
1527
1527
1528 Example ``~/.hgrc``::
1528 Example ``~/.hgrc``::
1529
1529
1530 [merge-tools]
1530 [merge-tools]
1531 # Override stock tool location
1531 # Override stock tool location
1532 kdiff3.executable = ~/bin/kdiff3
1532 kdiff3.executable = ~/bin/kdiff3
1533 # Specify command line
1533 # Specify command line
1534 kdiff3.args = $base $local $other -o $output
1534 kdiff3.args = $base $local $other -o $output
1535 # Give higher priority
1535 # Give higher priority
1536 kdiff3.priority = 1
1536 kdiff3.priority = 1
1537
1537
1538 # Changing the priority of preconfigured tool
1538 # Changing the priority of preconfigured tool
1539 meld.priority = 0
1539 meld.priority = 0
1540
1540
1541 # Disable a preconfigured tool
1541 # Disable a preconfigured tool
1542 vimdiff.disabled = yes
1542 vimdiff.disabled = yes
1543
1543
1544 # Define new tool
1544 # Define new tool
1545 myHtmlTool.args = -m $local $other $base $output
1545 myHtmlTool.args = -m $local $other $base $output
1546 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1546 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1547 myHtmlTool.priority = 1
1547 myHtmlTool.priority = 1
1548
1548
1549 Supported arguments:
1549 Supported arguments:
1550
1550
1551 ``priority``
1551 ``priority``
1552 The priority in which to evaluate this tool.
1552 The priority in which to evaluate this tool.
1553 (default: 0)
1553 (default: 0)
1554
1554
1555 ``executable``
1555 ``executable``
1556 Either just the name of the executable or its pathname.
1556 Either just the name of the executable or its pathname.
1557
1557
1558 .. container:: windows
1558 .. container:: windows
1559
1559
1560 On Windows, the path can use environment variables with ${ProgramFiles}
1560 On Windows, the path can use environment variables with ${ProgramFiles}
1561 syntax.
1561 syntax.
1562
1562
1563 (default: the tool name)
1563 (default: the tool name)
1564
1564
1565 ``args``
1565 ``args``
1566 The arguments to pass to the tool executable. You can refer to the
1566 The arguments to pass to the tool executable. You can refer to the
1567 files being merged as well as the output file through these
1567 files being merged as well as the output file through these
1568 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1568 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1569
1569
1570 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1570 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1571 being performed. During an update or merge, ``$local`` represents the original
1571 being performed. During an update or merge, ``$local`` represents the original
1572 state of the file, while ``$other`` represents the commit you are updating to or
1572 state of the file, while ``$other`` represents the commit you are updating to or
1573 the commit you are merging with. During a rebase, ``$local`` represents the
1573 the commit you are merging with. During a rebase, ``$local`` represents the
1574 destination of the rebase, and ``$other`` represents the commit being rebased.
1574 destination of the rebase, and ``$other`` represents the commit being rebased.
1575
1575
1576 Some operations define custom labels to assist with identifying the revisions,
1576 Some operations define custom labels to assist with identifying the revisions,
1577 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1577 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1578 labels are not available, these will be ``local``, ``other``, and ``base``,
1578 labels are not available, these will be ``local``, ``other``, and ``base``,
1579 respectively.
1579 respectively.
1580 (default: ``$local $base $other``)
1580 (default: ``$local $base $other``)
1581
1581
1582 ``premerge``
1582 ``premerge``
1583 Attempt to run internal non-interactive 3-way merge tool before
1583 Attempt to run internal non-interactive 3-way merge tool before
1584 launching external tool. Options are ``true``, ``false``, ``keep``,
1584 launching external tool. Options are ``true``, ``false``, ``keep``,
1585 ``keep-merge3``, or ``keep-mergediff`` (experimental). The ``keep`` option
1585 ``keep-merge3``, or ``keep-mergediff`` (experimental). The ``keep`` option
1586 will leave markers in the file if the premerge fails. The ``keep-merge3``
1586 will leave markers in the file if the premerge fails. The ``keep-merge3``
1587 will do the same but include information about the base of the merge in the
1587 will do the same but include information about the base of the merge in the
1588 marker (see internal :merge3 in :hg:`help merge-tools`). The
1588 marker (see internal :merge3 in :hg:`help merge-tools`). The
1589 ``keep-mergediff`` option is similar but uses a different marker style
1589 ``keep-mergediff`` option is similar but uses a different marker style
1590 (see internal :merge3 in :hg:`help merge-tools`). (default: True)
1590 (see internal :merge3 in :hg:`help merge-tools`). (default: True)
1591
1591
1592 ``binary``
1592 ``binary``
1593 This tool can merge binary files. (default: False, unless tool
1593 This tool can merge binary files. (default: False, unless tool
1594 was selected by file pattern match)
1594 was selected by file pattern match)
1595
1595
1596 ``symlink``
1596 ``symlink``
1597 This tool can merge symlinks. (default: False)
1597 This tool can merge symlinks. (default: False)
1598
1598
1599 ``check``
1599 ``check``
1600 A list of merge success-checking options:
1600 A list of merge success-checking options:
1601
1601
1602 ``changed``
1602 ``changed``
1603 Ask whether merge was successful when the merged file shows no changes.
1603 Ask whether merge was successful when the merged file shows no changes.
1604 ``conflicts``
1604 ``conflicts``
1605 Check whether there are conflicts even though the tool reported success.
1605 Check whether there are conflicts even though the tool reported success.
1606 ``prompt``
1606 ``prompt``
1607 Always prompt for merge success, regardless of success reported by tool.
1607 Always prompt for merge success, regardless of success reported by tool.
1608
1608
1609 ``fixeol``
1609 ``fixeol``
1610 Attempt to fix up EOL changes caused by the merge tool.
1610 Attempt to fix up EOL changes caused by the merge tool.
1611 (default: False)
1611 (default: False)
1612
1612
1613 ``gui``
1613 ``gui``
1614 This tool requires a graphical interface to run. (default: False)
1614 This tool requires a graphical interface to run. (default: False)
1615
1615
1616 ``mergemarkers``
1616 ``mergemarkers``
1617 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1617 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1618 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1618 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1619 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1619 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1620 markers generated during premerge will be ``detailed`` if either this option or
1620 markers generated during premerge will be ``detailed`` if either this option or
1621 the corresponding option in the ``[ui]`` section is ``detailed``.
1621 the corresponding option in the ``[ui]`` section is ``detailed``.
1622 (default: ``basic``)
1622 (default: ``basic``)
1623
1623
1624 ``mergemarkertemplate``
1624 ``mergemarkertemplate``
1625 This setting can be used to override ``mergemarker`` from the
1625 This setting can be used to override ``mergemarker`` from the
1626 ``[command-templates]`` section on a per-tool basis; this applies to the
1626 ``[command-templates]`` section on a per-tool basis; this applies to the
1627 ``$label``-prefixed variables and to the conflict markers that are generated
1627 ``$label``-prefixed variables and to the conflict markers that are generated
1628 if ``premerge`` is ``keep` or ``keep-merge3``. See the corresponding variable
1628 if ``premerge`` is ``keep` or ``keep-merge3``. See the corresponding variable
1629 in ``[ui]`` for more information.
1629 in ``[ui]`` for more information.
1630
1630
1631 .. container:: windows
1631 .. container:: windows
1632
1632
1633 ``regkey``
1633 ``regkey``
1634 Windows registry key which describes install location of this
1634 Windows registry key which describes install location of this
1635 tool. Mercurial will search for this key first under
1635 tool. Mercurial will search for this key first under
1636 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1636 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1637 (default: None)
1637 (default: None)
1638
1638
1639 ``regkeyalt``
1639 ``regkeyalt``
1640 An alternate Windows registry key to try if the first key is not
1640 An alternate Windows registry key to try if the first key is not
1641 found. The alternate key uses the same ``regname`` and ``regappend``
1641 found. The alternate key uses the same ``regname`` and ``regappend``
1642 semantics of the primary key. The most common use for this key
1642 semantics of the primary key. The most common use for this key
1643 is to search for 32bit applications on 64bit operating systems.
1643 is to search for 32bit applications on 64bit operating systems.
1644 (default: None)
1644 (default: None)
1645
1645
1646 ``regname``
1646 ``regname``
1647 Name of value to read from specified registry key.
1647 Name of value to read from specified registry key.
1648 (default: the unnamed (default) value)
1648 (default: the unnamed (default) value)
1649
1649
1650 ``regappend``
1650 ``regappend``
1651 String to append to the value read from the registry, typically
1651 String to append to the value read from the registry, typically
1652 the executable name of the tool.
1652 the executable name of the tool.
1653 (default: None)
1653 (default: None)
1654
1654
1655 ``pager``
1655 ``pager``
1656 ---------
1656 ---------
1657
1657
1658 Setting used to control when to paginate and with what external tool. See
1658 Setting used to control when to paginate and with what external tool. See
1659 :hg:`help pager` for details.
1659 :hg:`help pager` for details.
1660
1660
1661 ``pager``
1661 ``pager``
1662 Define the external tool used as pager.
1662 Define the external tool used as pager.
1663
1663
1664 If no pager is set, Mercurial uses the environment variable $PAGER.
1664 If no pager is set, Mercurial uses the environment variable $PAGER.
1665 If neither pager.pager, nor $PAGER is set, a default pager will be
1665 If neither pager.pager, nor $PAGER is set, a default pager will be
1666 used, typically `less` on Unix and `more` on Windows. Example::
1666 used, typically `less` on Unix and `more` on Windows. Example::
1667
1667
1668 [pager]
1668 [pager]
1669 pager = less -FRX
1669 pager = less -FRX
1670
1670
1671 ``ignore``
1671 ``ignore``
1672 List of commands to disable the pager for. Example::
1672 List of commands to disable the pager for. Example::
1673
1673
1674 [pager]
1674 [pager]
1675 ignore = version, help, update
1675 ignore = version, help, update
1676
1676
1677 ``patch``
1677 ``patch``
1678 ---------
1678 ---------
1679
1679
1680 Settings used when applying patches, for instance through the 'import'
1680 Settings used when applying patches, for instance through the 'import'
1681 command or with Mercurial Queues extension.
1681 command or with Mercurial Queues extension.
1682
1682
1683 ``eol``
1683 ``eol``
1684 When set to 'strict' patch content and patched files end of lines
1684 When set to 'strict' patch content and patched files end of lines
1685 are preserved. When set to ``lf`` or ``crlf``, both files end of
1685 are preserved. When set to ``lf`` or ``crlf``, both files end of
1686 lines are ignored when patching and the result line endings are
1686 lines are ignored when patching and the result line endings are
1687 normalized to either LF (Unix) or CRLF (Windows). When set to
1687 normalized to either LF (Unix) or CRLF (Windows). When set to
1688 ``auto``, end of lines are again ignored while patching but line
1688 ``auto``, end of lines are again ignored while patching but line
1689 endings in patched files are normalized to their original setting
1689 endings in patched files are normalized to their original setting
1690 on a per-file basis. If target file does not exist or has no end
1690 on a per-file basis. If target file does not exist or has no end
1691 of line, patch line endings are preserved.
1691 of line, patch line endings are preserved.
1692 (default: strict)
1692 (default: strict)
1693
1693
1694 ``fuzz``
1694 ``fuzz``
1695 The number of lines of 'fuzz' to allow when applying patches. This
1695 The number of lines of 'fuzz' to allow when applying patches. This
1696 controls how much context the patcher is allowed to ignore when
1696 controls how much context the patcher is allowed to ignore when
1697 trying to apply a patch.
1697 trying to apply a patch.
1698 (default: 2)
1698 (default: 2)
1699
1699
1700 ``paths``
1700 ``paths``
1701 ---------
1701 ---------
1702
1702
1703 Assigns symbolic names and behavior to repositories.
1703 Assigns symbolic names and behavior to repositories.
1704
1704
1705 Options are symbolic names defining the URL or directory that is the
1705 Options are symbolic names defining the URL or directory that is the
1706 location of the repository. Example::
1706 location of the repository. Example::
1707
1707
1708 [paths]
1708 [paths]
1709 my_server = https://example.com/my_repo
1709 my_server = https://example.com/my_repo
1710 local_path = /home/me/repo
1710 local_path = /home/me/repo
1711
1711
1712 These symbolic names can be used from the command line. To pull
1712 These symbolic names can be used from the command line. To pull
1713 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1713 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1714 :hg:`push local_path`. You can check :hg:`help urls` for details about
1714 :hg:`push local_path`. You can check :hg:`help urls` for details about
1715 valid URLs.
1715 valid URLs.
1716
1716
1717 Options containing colons (``:``) denote sub-options that can influence
1717 Options containing colons (``:``) denote sub-options that can influence
1718 behavior for that specific path. Example::
1718 behavior for that specific path. Example::
1719
1719
1720 [paths]
1720 [paths]
1721 my_server = https://example.com/my_path
1721 my_server = https://example.com/my_path
1722 my_server:pushurl = ssh://example.com/my_path
1722 my_server:pushurl = ssh://example.com/my_path
1723
1723
1724 Paths using the `path://otherpath` scheme will inherit the sub-options value from
1724 Paths using the `path://otherpath` scheme will inherit the sub-options value from
1725 the path they point to.
1725 the path they point to.
1726
1726
1727 The following sub-options can be defined:
1727 The following sub-options can be defined:
1728
1728
1729 ``multi-urls``
1729 ``multi-urls``
1730 A boolean option. When enabled the value of the `[paths]` entry will be
1730 A boolean option. When enabled the value of the `[paths]` entry will be
1731 parsed as a list and the alias will resolve to multiple destination. If some
1731 parsed as a list and the alias will resolve to multiple destination. If some
1732 of the list entry use the `path://` syntax, the suboption will be inherited
1732 of the list entry use the `path://` syntax, the suboption will be inherited
1733 individually.
1733 individually.
1734
1734
1735 ``pushurl``
1735 ``pushurl``
1736 The URL to use for push operations. If not defined, the location
1736 The URL to use for push operations. If not defined, the location
1737 defined by the path's main entry is used.
1737 defined by the path's main entry is used.
1738
1738
1739 ``pushrev``
1739 ``pushrev``
1740 A revset defining which revisions to push by default.
1740 A revset defining which revisions to push by default.
1741
1741
1742 When :hg:`push` is executed without a ``-r`` argument, the revset
1742 When :hg:`push` is executed without a ``-r`` argument, the revset
1743 defined by this sub-option is evaluated to determine what to push.
1743 defined by this sub-option is evaluated to determine what to push.
1744
1744
1745 For example, a value of ``.`` will push the working directory's
1745 For example, a value of ``.`` will push the working directory's
1746 revision by default.
1746 revision by default.
1747
1747
1748 Revsets specifying bookmarks will not result in the bookmark being
1748 Revsets specifying bookmarks will not result in the bookmark being
1749 pushed.
1749 pushed.
1750
1750
1751 The following special named paths exist:
1751 The following special named paths exist:
1752
1752
1753 ``default``
1753 ``default``
1754 The URL or directory to use when no source or remote is specified.
1754 The URL or directory to use when no source or remote is specified.
1755
1755
1756 :hg:`clone` will automatically define this path to the location the
1756 :hg:`clone` will automatically define this path to the location the
1757 repository was cloned from.
1757 repository was cloned from.
1758
1758
1759 ``default-push``
1759 ``default-push``
1760 (deprecated) The URL or directory for the default :hg:`push` location.
1760 (deprecated) The URL or directory for the default :hg:`push` location.
1761 ``default:pushurl`` should be used instead.
1761 ``default:pushurl`` should be used instead.
1762
1762
1763 ``phases``
1763 ``phases``
1764 ----------
1764 ----------
1765
1765
1766 Specifies default handling of phases. See :hg:`help phases` for more
1766 Specifies default handling of phases. See :hg:`help phases` for more
1767 information about working with phases.
1767 information about working with phases.
1768
1768
1769 ``publish``
1769 ``publish``
1770 Controls draft phase behavior when working as a server. When true,
1770 Controls draft phase behavior when working as a server. When true,
1771 pushed changesets are set to public in both client and server and
1771 pushed changesets are set to public in both client and server and
1772 pulled or cloned changesets are set to public in the client.
1772 pulled or cloned changesets are set to public in the client.
1773 (default: True)
1773 (default: True)
1774
1774
1775 ``new-commit``
1775 ``new-commit``
1776 Phase of newly-created commits.
1776 Phase of newly-created commits.
1777 (default: draft)
1777 (default: draft)
1778
1778
1779 ``checksubrepos``
1779 ``checksubrepos``
1780 Check the phase of the current revision of each subrepository. Allowed
1780 Check the phase of the current revision of each subrepository. Allowed
1781 values are "ignore", "follow" and "abort". For settings other than
1781 values are "ignore", "follow" and "abort". For settings other than
1782 "ignore", the phase of the current revision of each subrepository is
1782 "ignore", the phase of the current revision of each subrepository is
1783 checked before committing the parent repository. If any of those phases is
1783 checked before committing the parent repository. If any of those phases is
1784 greater than the phase of the parent repository (e.g. if a subrepo is in a
1784 greater than the phase of the parent repository (e.g. if a subrepo is in a
1785 "secret" phase while the parent repo is in "draft" phase), the commit is
1785 "secret" phase while the parent repo is in "draft" phase), the commit is
1786 either aborted (if checksubrepos is set to "abort") or the higher phase is
1786 either aborted (if checksubrepos is set to "abort") or the higher phase is
1787 used for the parent repository commit (if set to "follow").
1787 used for the parent repository commit (if set to "follow").
1788 (default: follow)
1788 (default: follow)
1789
1789
1790
1790
1791 ``profiling``
1791 ``profiling``
1792 -------------
1792 -------------
1793
1793
1794 Specifies profiling type, format, and file output. Two profilers are
1794 Specifies profiling type, format, and file output. Two profilers are
1795 supported: an instrumenting profiler (named ``ls``), and a sampling
1795 supported: an instrumenting profiler (named ``ls``), and a sampling
1796 profiler (named ``stat``).
1796 profiler (named ``stat``).
1797
1797
1798 In this section description, 'profiling data' stands for the raw data
1798 In this section description, 'profiling data' stands for the raw data
1799 collected during profiling, while 'profiling report' stands for a
1799 collected during profiling, while 'profiling report' stands for a
1800 statistical text report generated from the profiling data.
1800 statistical text report generated from the profiling data.
1801
1801
1802 ``enabled``
1802 ``enabled``
1803 Enable the profiler.
1803 Enable the profiler.
1804 (default: false)
1804 (default: false)
1805
1805
1806 This is equivalent to passing ``--profile`` on the command line.
1806 This is equivalent to passing ``--profile`` on the command line.
1807
1807
1808 ``type``
1808 ``type``
1809 The type of profiler to use.
1809 The type of profiler to use.
1810 (default: stat)
1810 (default: stat)
1811
1811
1812 ``ls``
1812 ``ls``
1813 Use Python's built-in instrumenting profiler. This profiler
1813 Use Python's built-in instrumenting profiler. This profiler
1814 works on all platforms, but each line number it reports is the
1814 works on all platforms, but each line number it reports is the
1815 first line of a function. This restriction makes it difficult to
1815 first line of a function. This restriction makes it difficult to
1816 identify the expensive parts of a non-trivial function.
1816 identify the expensive parts of a non-trivial function.
1817 ``stat``
1817 ``stat``
1818 Use a statistical profiler, statprof. This profiler is most
1818 Use a statistical profiler, statprof. This profiler is most
1819 useful for profiling commands that run for longer than about 0.1
1819 useful for profiling commands that run for longer than about 0.1
1820 seconds.
1820 seconds.
1821
1821
1822 ``format``
1822 ``format``
1823 Profiling format. Specific to the ``ls`` instrumenting profiler.
1823 Profiling format. Specific to the ``ls`` instrumenting profiler.
1824 (default: text)
1824 (default: text)
1825
1825
1826 ``text``
1826 ``text``
1827 Generate a profiling report. When saving to a file, it should be
1827 Generate a profiling report. When saving to a file, it should be
1828 noted that only the report is saved, and the profiling data is
1828 noted that only the report is saved, and the profiling data is
1829 not kept.
1829 not kept.
1830 ``kcachegrind``
1830 ``kcachegrind``
1831 Format profiling data for kcachegrind use: when saving to a
1831 Format profiling data for kcachegrind use: when saving to a
1832 file, the generated file can directly be loaded into
1832 file, the generated file can directly be loaded into
1833 kcachegrind.
1833 kcachegrind.
1834
1834
1835 ``statformat``
1835 ``statformat``
1836 Profiling format for the ``stat`` profiler.
1836 Profiling format for the ``stat`` profiler.
1837 (default: hotpath)
1837 (default: hotpath)
1838
1838
1839 ``hotpath``
1839 ``hotpath``
1840 Show a tree-based display containing the hot path of execution (where
1840 Show a tree-based display containing the hot path of execution (where
1841 most time was spent).
1841 most time was spent).
1842 ``bymethod``
1842 ``bymethod``
1843 Show a table of methods ordered by how frequently they are active.
1843 Show a table of methods ordered by how frequently they are active.
1844 ``byline``
1844 ``byline``
1845 Show a table of lines in files ordered by how frequently they are active.
1845 Show a table of lines in files ordered by how frequently they are active.
1846 ``json``
1846 ``json``
1847 Render profiling data as JSON.
1847 Render profiling data as JSON.
1848
1848
1849 ``freq``
1849 ``freq``
1850 Sampling frequency. Specific to the ``stat`` sampling profiler.
1850 Sampling frequency. Specific to the ``stat`` sampling profiler.
1851 (default: 1000)
1851 (default: 1000)
1852
1852
1853 ``output``
1853 ``output``
1854 File path where profiling data or report should be saved. If the
1854 File path where profiling data or report should be saved. If the
1855 file exists, it is replaced. (default: None, data is printed on
1855 file exists, it is replaced. (default: None, data is printed on
1856 stderr)
1856 stderr)
1857
1857
1858 ``sort``
1858 ``sort``
1859 Sort field. Specific to the ``ls`` instrumenting profiler.
1859 Sort field. Specific to the ``ls`` instrumenting profiler.
1860 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1860 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1861 ``inlinetime``.
1861 ``inlinetime``.
1862 (default: inlinetime)
1862 (default: inlinetime)
1863
1863
1864 ``time-track``
1864 ``time-track``
1865 Control if the stat profiler track ``cpu`` or ``real`` time.
1865 Control if the stat profiler track ``cpu`` or ``real`` time.
1866 (default: ``cpu`` on Windows, otherwise ``real``)
1866 (default: ``cpu`` on Windows, otherwise ``real``)
1867
1867
1868 ``limit``
1868 ``limit``
1869 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1869 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1870 (default: 30)
1870 (default: 30)
1871
1871
1872 ``nested``
1872 ``nested``
1873 Show at most this number of lines of drill-down info after each main entry.
1873 Show at most this number of lines of drill-down info after each main entry.
1874 This can help explain the difference between Total and Inline.
1874 This can help explain the difference between Total and Inline.
1875 Specific to the ``ls`` instrumenting profiler.
1875 Specific to the ``ls`` instrumenting profiler.
1876 (default: 0)
1876 (default: 0)
1877
1877
1878 ``showmin``
1878 ``showmin``
1879 Minimum fraction of samples an entry must have for it to be displayed.
1879 Minimum fraction of samples an entry must have for it to be displayed.
1880 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1880 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1881 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1881 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1882
1882
1883 Only used by the ``stat`` profiler.
1883 Only used by the ``stat`` profiler.
1884
1884
1885 For the ``hotpath`` format, default is ``0.05``.
1885 For the ``hotpath`` format, default is ``0.05``.
1886 For the ``chrome`` format, default is ``0.005``.
1886 For the ``chrome`` format, default is ``0.005``.
1887
1887
1888 The option is unused on other formats.
1888 The option is unused on other formats.
1889
1889
1890 ``showmax``
1890 ``showmax``
1891 Maximum fraction of samples an entry can have before it is ignored in
1891 Maximum fraction of samples an entry can have before it is ignored in
1892 display. Values format is the same as ``showmin``.
1892 display. Values format is the same as ``showmin``.
1893
1893
1894 Only used by the ``stat`` profiler.
1894 Only used by the ``stat`` profiler.
1895
1895
1896 For the ``chrome`` format, default is ``0.999``.
1896 For the ``chrome`` format, default is ``0.999``.
1897
1897
1898 The option is unused on other formats.
1898 The option is unused on other formats.
1899
1899
1900 ``showtime``
1900 ``showtime``
1901 Show time taken as absolute durations, in addition to percentages.
1901 Show time taken as absolute durations, in addition to percentages.
1902 Only used by the ``hotpath`` format.
1902 Only used by the ``hotpath`` format.
1903 (default: true)
1903 (default: true)
1904
1904
1905 ``progress``
1905 ``progress``
1906 ------------
1906 ------------
1907
1907
1908 Mercurial commands can draw progress bars that are as informative as
1908 Mercurial commands can draw progress bars that are as informative as
1909 possible. Some progress bars only offer indeterminate information, while others
1909 possible. Some progress bars only offer indeterminate information, while others
1910 have a definite end point.
1910 have a definite end point.
1911
1911
1912 ``debug``
1912 ``debug``
1913 Whether to print debug info when updating the progress bar. (default: False)
1913 Whether to print debug info when updating the progress bar. (default: False)
1914
1914
1915 ``delay``
1915 ``delay``
1916 Number of seconds (float) before showing the progress bar. (default: 3)
1916 Number of seconds (float) before showing the progress bar. (default: 3)
1917
1917
1918 ``changedelay``
1918 ``changedelay``
1919 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1919 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1920 that value will be used instead. (default: 1)
1920 that value will be used instead. (default: 1)
1921
1921
1922 ``estimateinterval``
1922 ``estimateinterval``
1923 Maximum sampling interval in seconds for speed and estimated time
1923 Maximum sampling interval in seconds for speed and estimated time
1924 calculation. (default: 60)
1924 calculation. (default: 60)
1925
1925
1926 ``refresh``
1926 ``refresh``
1927 Time in seconds between refreshes of the progress bar. (default: 0.1)
1927 Time in seconds between refreshes of the progress bar. (default: 0.1)
1928
1928
1929 ``format``
1929 ``format``
1930 Format of the progress bar.
1930 Format of the progress bar.
1931
1931
1932 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1932 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1933 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1933 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1934 last 20 characters of the item, but this can be changed by adding either
1934 last 20 characters of the item, but this can be changed by adding either
1935 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1935 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1936 first num characters.
1936 first num characters.
1937
1937
1938 (default: topic bar number estimate)
1938 (default: topic bar number estimate)
1939
1939
1940 ``width``
1940 ``width``
1941 If set, the maximum width of the progress information (that is, min(width,
1941 If set, the maximum width of the progress information (that is, min(width,
1942 term width) will be used).
1942 term width) will be used).
1943
1943
1944 ``clear-complete``
1944 ``clear-complete``
1945 Clear the progress bar after it's done. (default: True)
1945 Clear the progress bar after it's done. (default: True)
1946
1946
1947 ``disable``
1947 ``disable``
1948 If true, don't show a progress bar.
1948 If true, don't show a progress bar.
1949
1949
1950 ``assume-tty``
1950 ``assume-tty``
1951 If true, ALWAYS show a progress bar, unless disable is given.
1951 If true, ALWAYS show a progress bar, unless disable is given.
1952
1952
1953 ``rebase``
1953 ``rebase``
1954 ----------
1954 ----------
1955
1955
1956 ``evolution.allowdivergence``
1956 ``evolution.allowdivergence``
1957 Default to False, when True allow creating divergence when performing
1957 Default to False, when True allow creating divergence when performing
1958 rebase of obsolete changesets.
1958 rebase of obsolete changesets.
1959
1959
1960 ``revsetalias``
1960 ``revsetalias``
1961 ---------------
1961 ---------------
1962
1962
1963 Alias definitions for revsets. See :hg:`help revsets` for details.
1963 Alias definitions for revsets. See :hg:`help revsets` for details.
1964
1964
1965 ``rewrite``
1965 ``rewrite``
1966 -----------
1966 -----------
1967
1967
1968 ``backup-bundle``
1968 ``backup-bundle``
1969 Whether to save stripped changesets to a bundle file. (default: True)
1969 Whether to save stripped changesets to a bundle file. (default: True)
1970
1970
1971 ``update-timestamp``
1971 ``update-timestamp``
1972 If true, updates the date and time of the changeset to current. It is only
1972 If true, updates the date and time of the changeset to current. It is only
1973 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
1973 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
1974 current version.
1974 current version.
1975
1975
1976 ``empty-successor``
1976 ``empty-successor``
1977
1977
1978 Control what happens with empty successors that are the result of rewrite
1978 Control what happens with empty successors that are the result of rewrite
1979 operations. If set to ``skip``, the successor is not created. If set to
1979 operations. If set to ``skip``, the successor is not created. If set to
1980 ``keep``, the empty successor is created and kept.
1980 ``keep``, the empty successor is created and kept.
1981
1981
1982 Currently, only the rebase and absorb commands consider this configuration.
1982 Currently, only the rebase and absorb commands consider this configuration.
1983 (EXPERIMENTAL)
1983 (EXPERIMENTAL)
1984
1984
1985 ``share``
1985 ``share``
1986 ---------
1986 ---------
1987
1987
1988 ``safe-mismatch.source-safe``
1988 ``safe-mismatch.source-safe``
1989
1989
1990 Controls what happens when the shared repository does not use the
1990 Controls what happens when the shared repository does not use the
1991 share-safe mechanism but its source repository does.
1991 share-safe mechanism but its source repository does.
1992
1992
1993 Possible values are `abort` (default), `allow`, `upgrade-abort` and
1993 Possible values are `abort` (default), `allow`, `upgrade-abort` and
1994 `upgrade-abort`.
1994 `upgrade-abort`.
1995
1995
1996 ``abort``
1996 ``abort``
1997 Disallows running any command and aborts
1997 Disallows running any command and aborts
1998 ``allow``
1998 ``allow``
1999 Respects the feature presence in the share source
1999 Respects the feature presence in the share source
2000 ``upgrade-abort``
2000 ``upgrade-abort``
2001 tries to upgrade the share to use share-safe; if it fails, aborts
2001 tries to upgrade the share to use share-safe; if it fails, aborts
2002 ``upgrade-allow``
2002 ``upgrade-allow``
2003 tries to upgrade the share; if it fails, continue by
2003 tries to upgrade the share; if it fails, continue by
2004 respecting the share source setting
2004 respecting the share source setting
2005
2005
2006 Check :hg:`help config format.use-share-safe` for details about the
2006 Check :hg:`help config format.use-share-safe` for details about the
2007 share-safe feature.
2007 share-safe feature.
2008
2008
2009 ``safe-mismatch.source-safe.warn``
2009 ``safe-mismatch.source-safe.warn``
2010 Shows a warning on operations if the shared repository does not use
2010 Shows a warning on operations if the shared repository does not use
2011 share-safe, but the source repository does.
2011 share-safe, but the source repository does.
2012 (default: True)
2012 (default: True)
2013
2013
2014 ``safe-mismatch.source-not-safe``
2014 ``safe-mismatch.source-not-safe``
2015
2015
2016 Controls what happens when the shared repository uses the share-safe
2016 Controls what happens when the shared repository uses the share-safe
2017 mechanism but its source does not.
2017 mechanism but its source does not.
2018
2018
2019 Possible values are `abort` (default), `allow`, `downgrade-abort` and
2019 Possible values are `abort` (default), `allow`, `downgrade-abort` and
2020 `downgrade-abort`.
2020 `downgrade-abort`.
2021
2021
2022 ``abort``
2022 ``abort``
2023 Disallows running any command and aborts
2023 Disallows running any command and aborts
2024 ``allow``
2024 ``allow``
2025 Respects the feature presence in the share source
2025 Respects the feature presence in the share source
2026 ``downgrade-abort``
2026 ``downgrade-abort``
2027 tries to downgrade the share to not use share-safe; if it fails, aborts
2027 tries to downgrade the share to not use share-safe; if it fails, aborts
2028 ``downgrade-allow``
2028 ``downgrade-allow``
2029 tries to downgrade the share to not use share-safe;
2029 tries to downgrade the share to not use share-safe;
2030 if it fails, continue by respecting the shared source setting
2030 if it fails, continue by respecting the shared source setting
2031
2031
2032 Check :hg:`help config format.use-share-safe` for details about the
2032 Check :hg:`help config format.use-share-safe` for details about the
2033 share-safe feature.
2033 share-safe feature.
2034
2034
2035 ``safe-mismatch.source-not-safe.warn``
2035 ``safe-mismatch.source-not-safe.warn``
2036 Shows a warning on operations if the shared repository uses share-safe,
2036 Shows a warning on operations if the shared repository uses share-safe,
2037 but the source repository does not.
2037 but the source repository does not.
2038 (default: True)
2038 (default: True)
2039
2039
2040 ``storage``
2040 ``storage``
2041 -----------
2041 -----------
2042
2042
2043 Control the strategy Mercurial uses internally to store history. Options in this
2043 Control the strategy Mercurial uses internally to store history. Options in this
2044 category impact performance and repository size.
2044 category impact performance and repository size.
2045
2045
2046 ``revlog.issue6528.fix-incoming``
2047 Version 5.8 of Mercurial had a bug leading to altering the parent of file
2048 revision with copy information (or any other metadata) on exchange. This
2049 leads to the copy metadata to be overlooked by various internal logic. The
2050 issue was fixed in Mercurial 5.8.1.
2051 (See https://bz.mercurial-scm.org/show_bug.cgi?id=6528 for details)
2052
2053 As a result Mercurial is now checking and fixing incoming file revisions to
2054 make sure there parents are in the right order. This behavior can be
2055 disabled by setting this option to `no`. This apply to revisions added
2056 through push, pull, clone and unbundle.
2057
2058 To fix affected revisions that already exist within the repository, one can
2059 use :hg:`debug-repair-issue-6528`.
2060
2046 ``revlog.optimize-delta-parent-choice``
2061 ``revlog.optimize-delta-parent-choice``
2047 When storing a merge revision, both parents will be equally considered as
2062 When storing a merge revision, both parents will be equally considered as
2048 a possible delta base. This results in better delta selection and improved
2063 a possible delta base. This results in better delta selection and improved
2049 revlog compression. This option is enabled by default.
2064 revlog compression. This option is enabled by default.
2050
2065
2051 Turning this option off can result in large increase of repository size for
2066 Turning this option off can result in large increase of repository size for
2052 repository with many merges.
2067 repository with many merges.
2053
2068
2054 ``revlog.persistent-nodemap.mmap``
2069 ``revlog.persistent-nodemap.mmap``
2055 Whether to use the Operating System "memory mapping" feature (when
2070 Whether to use the Operating System "memory mapping" feature (when
2056 possible) to access the persistent nodemap data. This improve performance
2071 possible) to access the persistent nodemap data. This improve performance
2057 and reduce memory pressure.
2072 and reduce memory pressure.
2058
2073
2059 Default to True.
2074 Default to True.
2060
2075
2061 For details on the "persistent-nodemap" feature, see:
2076 For details on the "persistent-nodemap" feature, see:
2062 :hg:`help config format.use-persistent-nodemap`.
2077 :hg:`help config format.use-persistent-nodemap`.
2063
2078
2064 ``revlog.persistent-nodemap.slow-path``
2079 ``revlog.persistent-nodemap.slow-path``
2065 Control the behavior of Merucrial when using a repository with "persistent"
2080 Control the behavior of Merucrial when using a repository with "persistent"
2066 nodemap with an installation of Mercurial without a fast implementation for
2081 nodemap with an installation of Mercurial without a fast implementation for
2067 the feature:
2082 the feature:
2068
2083
2069 ``allow``: Silently use the slower implementation to access the repository.
2084 ``allow``: Silently use the slower implementation to access the repository.
2070 ``warn``: Warn, but use the slower implementation to access the repository.
2085 ``warn``: Warn, but use the slower implementation to access the repository.
2071 ``abort``: Prevent access to such repositories. (This is the default)
2086 ``abort``: Prevent access to such repositories. (This is the default)
2072
2087
2073 For details on the "persistent-nodemap" feature, see:
2088 For details on the "persistent-nodemap" feature, see:
2074 :hg:`help config format.use-persistent-nodemap`.
2089 :hg:`help config format.use-persistent-nodemap`.
2075
2090
2076 ``revlog.reuse-external-delta-parent``
2091 ``revlog.reuse-external-delta-parent``
2077 Control the order in which delta parents are considered when adding new
2092 Control the order in which delta parents are considered when adding new
2078 revisions from an external source.
2093 revisions from an external source.
2079 (typically: apply bundle from `hg pull` or `hg push`).
2094 (typically: apply bundle from `hg pull` or `hg push`).
2080
2095
2081 New revisions are usually provided as a delta against other revisions. By
2096 New revisions are usually provided as a delta against other revisions. By
2082 default, Mercurial will try to reuse this delta first, therefore using the
2097 default, Mercurial will try to reuse this delta first, therefore using the
2083 same "delta parent" as the source. Directly using delta's from the source
2098 same "delta parent" as the source. Directly using delta's from the source
2084 reduces CPU usage and usually speeds up operation. However, in some case,
2099 reduces CPU usage and usually speeds up operation. However, in some case,
2085 the source might have sub-optimal delta bases and forcing their reevaluation
2100 the source might have sub-optimal delta bases and forcing their reevaluation
2086 is useful. For example, pushes from an old client could have sub-optimal
2101 is useful. For example, pushes from an old client could have sub-optimal
2087 delta's parent that the server want to optimize. (lack of general delta, bad
2102 delta's parent that the server want to optimize. (lack of general delta, bad
2088 parents, choice, lack of sparse-revlog, etc).
2103 parents, choice, lack of sparse-revlog, etc).
2089
2104
2090 This option is enabled by default. Turning it off will ensure bad delta
2105 This option is enabled by default. Turning it off will ensure bad delta
2091 parent choices from older client do not propagate to this repository, at
2106 parent choices from older client do not propagate to this repository, at
2092 the cost of a small increase in CPU consumption.
2107 the cost of a small increase in CPU consumption.
2093
2108
2094 Note: this option only control the order in which delta parents are
2109 Note: this option only control the order in which delta parents are
2095 considered. Even when disabled, the existing delta from the source will be
2110 considered. Even when disabled, the existing delta from the source will be
2096 reused if the same delta parent is selected.
2111 reused if the same delta parent is selected.
2097
2112
2098 ``revlog.reuse-external-delta``
2113 ``revlog.reuse-external-delta``
2099 Control the reuse of delta from external source.
2114 Control the reuse of delta from external source.
2100 (typically: apply bundle from `hg pull` or `hg push`).
2115 (typically: apply bundle from `hg pull` or `hg push`).
2101
2116
2102 New revisions are usually provided as a delta against another revision. By
2117 New revisions are usually provided as a delta against another revision. By
2103 default, Mercurial will not recompute the same delta again, trusting
2118 default, Mercurial will not recompute the same delta again, trusting
2104 externally provided deltas. There have been rare cases of small adjustment
2119 externally provided deltas. There have been rare cases of small adjustment
2105 to the diffing algorithm in the past. So in some rare case, recomputing
2120 to the diffing algorithm in the past. So in some rare case, recomputing
2106 delta provided by ancient clients can provides better results. Disabling
2121 delta provided by ancient clients can provides better results. Disabling
2107 this option means going through a full delta recomputation for all incoming
2122 this option means going through a full delta recomputation for all incoming
2108 revisions. It means a large increase in CPU usage and will slow operations
2123 revisions. It means a large increase in CPU usage and will slow operations
2109 down.
2124 down.
2110
2125
2111 This option is enabled by default. When disabled, it also disables the
2126 This option is enabled by default. When disabled, it also disables the
2112 related ``storage.revlog.reuse-external-delta-parent`` option.
2127 related ``storage.revlog.reuse-external-delta-parent`` option.
2113
2128
2114 ``revlog.zlib.level``
2129 ``revlog.zlib.level``
2115 Zlib compression level used when storing data into the repository. Accepted
2130 Zlib compression level used when storing data into the repository. Accepted
2116 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
2131 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
2117 default value is 6.
2132 default value is 6.
2118
2133
2119
2134
2120 ``revlog.zstd.level``
2135 ``revlog.zstd.level``
2121 zstd compression level used when storing data into the repository. Accepted
2136 zstd compression level used when storing data into the repository. Accepted
2122 Value range from 1 (lowest compression) to 22 (highest compression).
2137 Value range from 1 (lowest compression) to 22 (highest compression).
2123 (default 3)
2138 (default 3)
2124
2139
2125 ``server``
2140 ``server``
2126 ----------
2141 ----------
2127
2142
2128 Controls generic server settings.
2143 Controls generic server settings.
2129
2144
2130 ``bookmarks-pushkey-compat``
2145 ``bookmarks-pushkey-compat``
2131 Trigger pushkey hook when being pushed bookmark updates. This config exist
2146 Trigger pushkey hook when being pushed bookmark updates. This config exist
2132 for compatibility purpose (default to True)
2147 for compatibility purpose (default to True)
2133
2148
2134 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
2149 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
2135 movement we recommend you migrate them to ``txnclose-bookmark`` and
2150 movement we recommend you migrate them to ``txnclose-bookmark`` and
2136 ``pretxnclose-bookmark``.
2151 ``pretxnclose-bookmark``.
2137
2152
2138 ``compressionengines``
2153 ``compressionengines``
2139 List of compression engines and their relative priority to advertise
2154 List of compression engines and their relative priority to advertise
2140 to clients.
2155 to clients.
2141
2156
2142 The order of compression engines determines their priority, the first
2157 The order of compression engines determines their priority, the first
2143 having the highest priority. If a compression engine is not listed
2158 having the highest priority. If a compression engine is not listed
2144 here, it won't be advertised to clients.
2159 here, it won't be advertised to clients.
2145
2160
2146 If not set (the default), built-in defaults are used. Run
2161 If not set (the default), built-in defaults are used. Run
2147 :hg:`debuginstall` to list available compression engines and their
2162 :hg:`debuginstall` to list available compression engines and their
2148 default wire protocol priority.
2163 default wire protocol priority.
2149
2164
2150 Older Mercurial clients only support zlib compression and this setting
2165 Older Mercurial clients only support zlib compression and this setting
2151 has no effect for legacy clients.
2166 has no effect for legacy clients.
2152
2167
2153 ``uncompressed``
2168 ``uncompressed``
2154 Whether to allow clients to clone a repository using the
2169 Whether to allow clients to clone a repository using the
2155 uncompressed streaming protocol. This transfers about 40% more
2170 uncompressed streaming protocol. This transfers about 40% more
2156 data than a regular clone, but uses less memory and CPU on both
2171 data than a regular clone, but uses less memory and CPU on both
2157 server and client. Over a LAN (100 Mbps or better) or a very fast
2172 server and client. Over a LAN (100 Mbps or better) or a very fast
2158 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
2173 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
2159 regular clone. Over most WAN connections (anything slower than
2174 regular clone. Over most WAN connections (anything slower than
2160 about 6 Mbps), uncompressed streaming is slower, because of the
2175 about 6 Mbps), uncompressed streaming is slower, because of the
2161 extra data transfer overhead. This mode will also temporarily hold
2176 extra data transfer overhead. This mode will also temporarily hold
2162 the write lock while determining what data to transfer.
2177 the write lock while determining what data to transfer.
2163 (default: True)
2178 (default: True)
2164
2179
2165 ``uncompressedallowsecret``
2180 ``uncompressedallowsecret``
2166 Whether to allow stream clones when the repository contains secret
2181 Whether to allow stream clones when the repository contains secret
2167 changesets. (default: False)
2182 changesets. (default: False)
2168
2183
2169 ``preferuncompressed``
2184 ``preferuncompressed``
2170 When set, clients will try to use the uncompressed streaming
2185 When set, clients will try to use the uncompressed streaming
2171 protocol. (default: False)
2186 protocol. (default: False)
2172
2187
2173 ``disablefullbundle``
2188 ``disablefullbundle``
2174 When set, servers will refuse attempts to do pull-based clones.
2189 When set, servers will refuse attempts to do pull-based clones.
2175 If this option is set, ``preferuncompressed`` and/or clone bundles
2190 If this option is set, ``preferuncompressed`` and/or clone bundles
2176 are highly recommended. Partial clones will still be allowed.
2191 are highly recommended. Partial clones will still be allowed.
2177 (default: False)
2192 (default: False)
2178
2193
2179 ``streamunbundle``
2194 ``streamunbundle``
2180 When set, servers will apply data sent from the client directly,
2195 When set, servers will apply data sent from the client directly,
2181 otherwise it will be written to a temporary file first. This option
2196 otherwise it will be written to a temporary file first. This option
2182 effectively prevents concurrent pushes.
2197 effectively prevents concurrent pushes.
2183
2198
2184 ``pullbundle``
2199 ``pullbundle``
2185 When set, the server will check pullbundle.manifest for bundles
2200 When set, the server will check pullbundle.manifest for bundles
2186 covering the requested heads and common nodes. The first matching
2201 covering the requested heads and common nodes. The first matching
2187 entry will be streamed to the client.
2202 entry will be streamed to the client.
2188
2203
2189 For HTTP transport, the stream will still use zlib compression
2204 For HTTP transport, the stream will still use zlib compression
2190 for older clients.
2205 for older clients.
2191
2206
2192 ``concurrent-push-mode``
2207 ``concurrent-push-mode``
2193 Level of allowed race condition between two pushing clients.
2208 Level of allowed race condition between two pushing clients.
2194
2209
2195 - 'strict': push is abort if another client touched the repository
2210 - 'strict': push is abort if another client touched the repository
2196 while the push was preparing.
2211 while the push was preparing.
2197 - 'check-related': push is only aborted if it affects head that got also
2212 - 'check-related': push is only aborted if it affects head that got also
2198 affected while the push was preparing. (default since 5.4)
2213 affected while the push was preparing. (default since 5.4)
2199
2214
2200 'check-related' only takes effect for compatible clients (version
2215 'check-related' only takes effect for compatible clients (version
2201 4.3 and later). Older clients will use 'strict'.
2216 4.3 and later). Older clients will use 'strict'.
2202
2217
2203 ``validate``
2218 ``validate``
2204 Whether to validate the completeness of pushed changesets by
2219 Whether to validate the completeness of pushed changesets by
2205 checking that all new file revisions specified in manifests are
2220 checking that all new file revisions specified in manifests are
2206 present. (default: False)
2221 present. (default: False)
2207
2222
2208 ``maxhttpheaderlen``
2223 ``maxhttpheaderlen``
2209 Instruct HTTP clients not to send request headers longer than this
2224 Instruct HTTP clients not to send request headers longer than this
2210 many bytes. (default: 1024)
2225 many bytes. (default: 1024)
2211
2226
2212 ``bundle1``
2227 ``bundle1``
2213 Whether to allow clients to push and pull using the legacy bundle1
2228 Whether to allow clients to push and pull using the legacy bundle1
2214 exchange format. (default: True)
2229 exchange format. (default: True)
2215
2230
2216 ``bundle1gd``
2231 ``bundle1gd``
2217 Like ``bundle1`` but only used if the repository is using the
2232 Like ``bundle1`` but only used if the repository is using the
2218 *generaldelta* storage format. (default: True)
2233 *generaldelta* storage format. (default: True)
2219
2234
2220 ``bundle1.push``
2235 ``bundle1.push``
2221 Whether to allow clients to push using the legacy bundle1 exchange
2236 Whether to allow clients to push using the legacy bundle1 exchange
2222 format. (default: True)
2237 format. (default: True)
2223
2238
2224 ``bundle1gd.push``
2239 ``bundle1gd.push``
2225 Like ``bundle1.push`` but only used if the repository is using the
2240 Like ``bundle1.push`` but only used if the repository is using the
2226 *generaldelta* storage format. (default: True)
2241 *generaldelta* storage format. (default: True)
2227
2242
2228 ``bundle1.pull``
2243 ``bundle1.pull``
2229 Whether to allow clients to pull using the legacy bundle1 exchange
2244 Whether to allow clients to pull using the legacy bundle1 exchange
2230 format. (default: True)
2245 format. (default: True)
2231
2246
2232 ``bundle1gd.pull``
2247 ``bundle1gd.pull``
2233 Like ``bundle1.pull`` but only used if the repository is using the
2248 Like ``bundle1.pull`` but only used if the repository is using the
2234 *generaldelta* storage format. (default: True)
2249 *generaldelta* storage format. (default: True)
2235
2250
2236 Large repositories using the *generaldelta* storage format should
2251 Large repositories using the *generaldelta* storage format should
2237 consider setting this option because converting *generaldelta*
2252 consider setting this option because converting *generaldelta*
2238 repositories to the exchange format required by the bundle1 data
2253 repositories to the exchange format required by the bundle1 data
2239 format can consume a lot of CPU.
2254 format can consume a lot of CPU.
2240
2255
2241 ``bundle2.stream``
2256 ``bundle2.stream``
2242 Whether to allow clients to pull using the bundle2 streaming protocol.
2257 Whether to allow clients to pull using the bundle2 streaming protocol.
2243 (default: True)
2258 (default: True)
2244
2259
2245 ``zliblevel``
2260 ``zliblevel``
2246 Integer between ``-1`` and ``9`` that controls the zlib compression level
2261 Integer between ``-1`` and ``9`` that controls the zlib compression level
2247 for wire protocol commands that send zlib compressed output (notably the
2262 for wire protocol commands that send zlib compressed output (notably the
2248 commands that send repository history data).
2263 commands that send repository history data).
2249
2264
2250 The default (``-1``) uses the default zlib compression level, which is
2265 The default (``-1``) uses the default zlib compression level, which is
2251 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2266 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2252 maximum compression.
2267 maximum compression.
2253
2268
2254 Setting this option allows server operators to make trade-offs between
2269 Setting this option allows server operators to make trade-offs between
2255 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2270 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2256 but sends more bytes to clients.
2271 but sends more bytes to clients.
2257
2272
2258 This option only impacts the HTTP server.
2273 This option only impacts the HTTP server.
2259
2274
2260 ``zstdlevel``
2275 ``zstdlevel``
2261 Integer between ``1`` and ``22`` that controls the zstd compression level
2276 Integer between ``1`` and ``22`` that controls the zstd compression level
2262 for wire protocol commands. ``1`` is the minimal amount of compression and
2277 for wire protocol commands. ``1`` is the minimal amount of compression and
2263 ``22`` is the highest amount of compression.
2278 ``22`` is the highest amount of compression.
2264
2279
2265 The default (``3``) should be significantly faster than zlib while likely
2280 The default (``3``) should be significantly faster than zlib while likely
2266 delivering better compression ratios.
2281 delivering better compression ratios.
2267
2282
2268 This option only impacts the HTTP server.
2283 This option only impacts the HTTP server.
2269
2284
2270 See also ``server.zliblevel``.
2285 See also ``server.zliblevel``.
2271
2286
2272 ``view``
2287 ``view``
2273 Repository filter used when exchanging revisions with the peer.
2288 Repository filter used when exchanging revisions with the peer.
2274
2289
2275 The default view (``served``) excludes secret and hidden changesets.
2290 The default view (``served``) excludes secret and hidden changesets.
2276 Another useful value is ``immutable`` (no draft, secret or hidden
2291 Another useful value is ``immutable`` (no draft, secret or hidden
2277 changesets). (EXPERIMENTAL)
2292 changesets). (EXPERIMENTAL)
2278
2293
2279 ``smtp``
2294 ``smtp``
2280 --------
2295 --------
2281
2296
2282 Configuration for extensions that need to send email messages.
2297 Configuration for extensions that need to send email messages.
2283
2298
2284 ``host``
2299 ``host``
2285 Host name of mail server, e.g. "mail.example.com".
2300 Host name of mail server, e.g. "mail.example.com".
2286
2301
2287 ``port``
2302 ``port``
2288 Optional. Port to connect to on mail server. (default: 465 if
2303 Optional. Port to connect to on mail server. (default: 465 if
2289 ``tls`` is smtps; 25 otherwise)
2304 ``tls`` is smtps; 25 otherwise)
2290
2305
2291 ``tls``
2306 ``tls``
2292 Optional. Method to enable TLS when connecting to mail server: starttls,
2307 Optional. Method to enable TLS when connecting to mail server: starttls,
2293 smtps or none. (default: none)
2308 smtps or none. (default: none)
2294
2309
2295 ``username``
2310 ``username``
2296 Optional. User name for authenticating with the SMTP server.
2311 Optional. User name for authenticating with the SMTP server.
2297 (default: None)
2312 (default: None)
2298
2313
2299 ``password``
2314 ``password``
2300 Optional. Password for authenticating with the SMTP server. If not
2315 Optional. Password for authenticating with the SMTP server. If not
2301 specified, interactive sessions will prompt the user for a
2316 specified, interactive sessions will prompt the user for a
2302 password; non-interactive sessions will fail. (default: None)
2317 password; non-interactive sessions will fail. (default: None)
2303
2318
2304 ``local_hostname``
2319 ``local_hostname``
2305 Optional. The hostname that the sender can use to identify
2320 Optional. The hostname that the sender can use to identify
2306 itself to the MTA.
2321 itself to the MTA.
2307
2322
2308
2323
2309 ``subpaths``
2324 ``subpaths``
2310 ------------
2325 ------------
2311
2326
2312 Subrepository source URLs can go stale if a remote server changes name
2327 Subrepository source URLs can go stale if a remote server changes name
2313 or becomes temporarily unavailable. This section lets you define
2328 or becomes temporarily unavailable. This section lets you define
2314 rewrite rules of the form::
2329 rewrite rules of the form::
2315
2330
2316 <pattern> = <replacement>
2331 <pattern> = <replacement>
2317
2332
2318 where ``pattern`` is a regular expression matching a subrepository
2333 where ``pattern`` is a regular expression matching a subrepository
2319 source URL and ``replacement`` is the replacement string used to
2334 source URL and ``replacement`` is the replacement string used to
2320 rewrite it. Groups can be matched in ``pattern`` and referenced in
2335 rewrite it. Groups can be matched in ``pattern`` and referenced in
2321 ``replacements``. For instance::
2336 ``replacements``. For instance::
2322
2337
2323 http://server/(.*)-hg/ = http://hg.server/\1/
2338 http://server/(.*)-hg/ = http://hg.server/\1/
2324
2339
2325 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2340 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2326
2341
2327 Relative subrepository paths are first made absolute, and the
2342 Relative subrepository paths are first made absolute, and the
2328 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2343 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2329 doesn't match the full path, an attempt is made to apply it on the
2344 doesn't match the full path, an attempt is made to apply it on the
2330 relative path alone. The rules are applied in definition order.
2345 relative path alone. The rules are applied in definition order.
2331
2346
2332 ``subrepos``
2347 ``subrepos``
2333 ------------
2348 ------------
2334
2349
2335 This section contains options that control the behavior of the
2350 This section contains options that control the behavior of the
2336 subrepositories feature. See also :hg:`help subrepos`.
2351 subrepositories feature. See also :hg:`help subrepos`.
2337
2352
2338 Security note: auditing in Mercurial is known to be insufficient to
2353 Security note: auditing in Mercurial is known to be insufficient to
2339 prevent clone-time code execution with carefully constructed Git
2354 prevent clone-time code execution with carefully constructed Git
2340 subrepos. It is unknown if a similar detect is present in Subversion
2355 subrepos. It is unknown if a similar detect is present in Subversion
2341 subrepos. Both Git and Subversion subrepos are disabled by default
2356 subrepos. Both Git and Subversion subrepos are disabled by default
2342 out of security concerns. These subrepo types can be enabled using
2357 out of security concerns. These subrepo types can be enabled using
2343 the respective options below.
2358 the respective options below.
2344
2359
2345 ``allowed``
2360 ``allowed``
2346 Whether subrepositories are allowed in the working directory.
2361 Whether subrepositories are allowed in the working directory.
2347
2362
2348 When false, commands involving subrepositories (like :hg:`update`)
2363 When false, commands involving subrepositories (like :hg:`update`)
2349 will fail for all subrepository types.
2364 will fail for all subrepository types.
2350 (default: true)
2365 (default: true)
2351
2366
2352 ``hg:allowed``
2367 ``hg:allowed``
2353 Whether Mercurial subrepositories are allowed in the working
2368 Whether Mercurial subrepositories are allowed in the working
2354 directory. This option only has an effect if ``subrepos.allowed``
2369 directory. This option only has an effect if ``subrepos.allowed``
2355 is true.
2370 is true.
2356 (default: true)
2371 (default: true)
2357
2372
2358 ``git:allowed``
2373 ``git:allowed``
2359 Whether Git subrepositories are allowed in the working directory.
2374 Whether Git subrepositories are allowed in the working directory.
2360 This option only has an effect if ``subrepos.allowed`` is true.
2375 This option only has an effect if ``subrepos.allowed`` is true.
2361
2376
2362 See the security note above before enabling Git subrepos.
2377 See the security note above before enabling Git subrepos.
2363 (default: false)
2378 (default: false)
2364
2379
2365 ``svn:allowed``
2380 ``svn:allowed``
2366 Whether Subversion subrepositories are allowed in the working
2381 Whether Subversion subrepositories are allowed in the working
2367 directory. This option only has an effect if ``subrepos.allowed``
2382 directory. This option only has an effect if ``subrepos.allowed``
2368 is true.
2383 is true.
2369
2384
2370 See the security note above before enabling Subversion subrepos.
2385 See the security note above before enabling Subversion subrepos.
2371 (default: false)
2386 (default: false)
2372
2387
2373 ``templatealias``
2388 ``templatealias``
2374 -----------------
2389 -----------------
2375
2390
2376 Alias definitions for templates. See :hg:`help templates` for details.
2391 Alias definitions for templates. See :hg:`help templates` for details.
2377
2392
2378 ``templates``
2393 ``templates``
2379 -------------
2394 -------------
2380
2395
2381 Use the ``[templates]`` section to define template strings.
2396 Use the ``[templates]`` section to define template strings.
2382 See :hg:`help templates` for details.
2397 See :hg:`help templates` for details.
2383
2398
2384 ``trusted``
2399 ``trusted``
2385 -----------
2400 -----------
2386
2401
2387 Mercurial will not use the settings in the
2402 Mercurial will not use the settings in the
2388 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2403 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2389 user or to a trusted group, as various hgrc features allow arbitrary
2404 user or to a trusted group, as various hgrc features allow arbitrary
2390 commands to be run. This issue is often encountered when configuring
2405 commands to be run. This issue is often encountered when configuring
2391 hooks or extensions for shared repositories or servers. However,
2406 hooks or extensions for shared repositories or servers. However,
2392 the web interface will use some safe settings from the ``[web]``
2407 the web interface will use some safe settings from the ``[web]``
2393 section.
2408 section.
2394
2409
2395 This section specifies what users and groups are trusted. The
2410 This section specifies what users and groups are trusted. The
2396 current user is always trusted. To trust everybody, list a user or a
2411 current user is always trusted. To trust everybody, list a user or a
2397 group with name ``*``. These settings must be placed in an
2412 group with name ``*``. These settings must be placed in an
2398 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2413 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2399 user or service running Mercurial.
2414 user or service running Mercurial.
2400
2415
2401 ``users``
2416 ``users``
2402 Comma-separated list of trusted users.
2417 Comma-separated list of trusted users.
2403
2418
2404 ``groups``
2419 ``groups``
2405 Comma-separated list of trusted groups.
2420 Comma-separated list of trusted groups.
2406
2421
2407
2422
2408 ``ui``
2423 ``ui``
2409 ------
2424 ------
2410
2425
2411 User interface controls.
2426 User interface controls.
2412
2427
2413 ``archivemeta``
2428 ``archivemeta``
2414 Whether to include the .hg_archival.txt file containing meta data
2429 Whether to include the .hg_archival.txt file containing meta data
2415 (hashes for the repository base and for tip) in archives created
2430 (hashes for the repository base and for tip) in archives created
2416 by the :hg:`archive` command or downloaded via hgweb.
2431 by the :hg:`archive` command or downloaded via hgweb.
2417 (default: True)
2432 (default: True)
2418
2433
2419 ``askusername``
2434 ``askusername``
2420 Whether to prompt for a username when committing. If True, and
2435 Whether to prompt for a username when committing. If True, and
2421 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2436 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2422 be prompted to enter a username. If no username is entered, the
2437 be prompted to enter a username. If no username is entered, the
2423 default ``USER@HOST`` is used instead.
2438 default ``USER@HOST`` is used instead.
2424 (default: False)
2439 (default: False)
2425
2440
2426 ``clonebundles``
2441 ``clonebundles``
2427 Whether the "clone bundles" feature is enabled.
2442 Whether the "clone bundles" feature is enabled.
2428
2443
2429 When enabled, :hg:`clone` may download and apply a server-advertised
2444 When enabled, :hg:`clone` may download and apply a server-advertised
2430 bundle file from a URL instead of using the normal exchange mechanism.
2445 bundle file from a URL instead of using the normal exchange mechanism.
2431
2446
2432 This can likely result in faster and more reliable clones.
2447 This can likely result in faster and more reliable clones.
2433
2448
2434 (default: True)
2449 (default: True)
2435
2450
2436 ``clonebundlefallback``
2451 ``clonebundlefallback``
2437 Whether failure to apply an advertised "clone bundle" from a server
2452 Whether failure to apply an advertised "clone bundle" from a server
2438 should result in fallback to a regular clone.
2453 should result in fallback to a regular clone.
2439
2454
2440 This is disabled by default because servers advertising "clone
2455 This is disabled by default because servers advertising "clone
2441 bundles" often do so to reduce server load. If advertised bundles
2456 bundles" often do so to reduce server load. If advertised bundles
2442 start mass failing and clients automatically fall back to a regular
2457 start mass failing and clients automatically fall back to a regular
2443 clone, this would add significant and unexpected load to the server
2458 clone, this would add significant and unexpected load to the server
2444 since the server is expecting clone operations to be offloaded to
2459 since the server is expecting clone operations to be offloaded to
2445 pre-generated bundles. Failing fast (the default behavior) ensures
2460 pre-generated bundles. Failing fast (the default behavior) ensures
2446 clients don't overwhelm the server when "clone bundle" application
2461 clients don't overwhelm the server when "clone bundle" application
2447 fails.
2462 fails.
2448
2463
2449 (default: False)
2464 (default: False)
2450
2465
2451 ``clonebundleprefers``
2466 ``clonebundleprefers``
2452 Defines preferences for which "clone bundles" to use.
2467 Defines preferences for which "clone bundles" to use.
2453
2468
2454 Servers advertising "clone bundles" may advertise multiple available
2469 Servers advertising "clone bundles" may advertise multiple available
2455 bundles. Each bundle may have different attributes, such as the bundle
2470 bundles. Each bundle may have different attributes, such as the bundle
2456 type and compression format. This option is used to prefer a particular
2471 type and compression format. This option is used to prefer a particular
2457 bundle over another.
2472 bundle over another.
2458
2473
2459 The following keys are defined by Mercurial:
2474 The following keys are defined by Mercurial:
2460
2475
2461 BUNDLESPEC
2476 BUNDLESPEC
2462 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2477 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2463 e.g. ``gzip-v2`` or ``bzip2-v1``.
2478 e.g. ``gzip-v2`` or ``bzip2-v1``.
2464
2479
2465 COMPRESSION
2480 COMPRESSION
2466 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2481 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2467
2482
2468 Server operators may define custom keys.
2483 Server operators may define custom keys.
2469
2484
2470 Example values: ``COMPRESSION=bzip2``,
2485 Example values: ``COMPRESSION=bzip2``,
2471 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2486 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2472
2487
2473 By default, the first bundle advertised by the server is used.
2488 By default, the first bundle advertised by the server is used.
2474
2489
2475 ``color``
2490 ``color``
2476 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2491 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2477 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2492 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2478 seems possible. See :hg:`help color` for details.
2493 seems possible. See :hg:`help color` for details.
2479
2494
2480 ``commitsubrepos``
2495 ``commitsubrepos``
2481 Whether to commit modified subrepositories when committing the
2496 Whether to commit modified subrepositories when committing the
2482 parent repository. If False and one subrepository has uncommitted
2497 parent repository. If False and one subrepository has uncommitted
2483 changes, abort the commit.
2498 changes, abort the commit.
2484 (default: False)
2499 (default: False)
2485
2500
2486 ``debug``
2501 ``debug``
2487 Print debugging information. (default: False)
2502 Print debugging information. (default: False)
2488
2503
2489 ``editor``
2504 ``editor``
2490 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2505 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2491
2506
2492 ``fallbackencoding``
2507 ``fallbackencoding``
2493 Encoding to try if it's not possible to decode the changelog using
2508 Encoding to try if it's not possible to decode the changelog using
2494 UTF-8. (default: ISO-8859-1)
2509 UTF-8. (default: ISO-8859-1)
2495
2510
2496 ``graphnodetemplate``
2511 ``graphnodetemplate``
2497 (DEPRECATED) Use ``command-templates.graphnode`` instead.
2512 (DEPRECATED) Use ``command-templates.graphnode`` instead.
2498
2513
2499 ``ignore``
2514 ``ignore``
2500 A file to read per-user ignore patterns from. This file should be
2515 A file to read per-user ignore patterns from. This file should be
2501 in the same format as a repository-wide .hgignore file. Filenames
2516 in the same format as a repository-wide .hgignore file. Filenames
2502 are relative to the repository root. This option supports hook syntax,
2517 are relative to the repository root. This option supports hook syntax,
2503 so if you want to specify multiple ignore files, you can do so by
2518 so if you want to specify multiple ignore files, you can do so by
2504 setting something like ``ignore.other = ~/.hgignore2``. For details
2519 setting something like ``ignore.other = ~/.hgignore2``. For details
2505 of the ignore file format, see the ``hgignore(5)`` man page.
2520 of the ignore file format, see the ``hgignore(5)`` man page.
2506
2521
2507 ``interactive``
2522 ``interactive``
2508 Allow to prompt the user. (default: True)
2523 Allow to prompt the user. (default: True)
2509
2524
2510 ``interface``
2525 ``interface``
2511 Select the default interface for interactive features (default: text).
2526 Select the default interface for interactive features (default: text).
2512 Possible values are 'text' and 'curses'.
2527 Possible values are 'text' and 'curses'.
2513
2528
2514 ``interface.chunkselector``
2529 ``interface.chunkselector``
2515 Select the interface for change recording (e.g. :hg:`commit -i`).
2530 Select the interface for change recording (e.g. :hg:`commit -i`).
2516 Possible values are 'text' and 'curses'.
2531 Possible values are 'text' and 'curses'.
2517 This config overrides the interface specified by ui.interface.
2532 This config overrides the interface specified by ui.interface.
2518
2533
2519 ``large-file-limit``
2534 ``large-file-limit``
2520 Largest file size that gives no memory use warning.
2535 Largest file size that gives no memory use warning.
2521 Possible values are integers or 0 to disable the check.
2536 Possible values are integers or 0 to disable the check.
2522 (default: 10000000)
2537 (default: 10000000)
2523
2538
2524 ``logtemplate``
2539 ``logtemplate``
2525 (DEPRECATED) Use ``command-templates.log`` instead.
2540 (DEPRECATED) Use ``command-templates.log`` instead.
2526
2541
2527 ``merge``
2542 ``merge``
2528 The conflict resolution program to use during a manual merge.
2543 The conflict resolution program to use during a manual merge.
2529 For more information on merge tools see :hg:`help merge-tools`.
2544 For more information on merge tools see :hg:`help merge-tools`.
2530 For configuring merge tools see the ``[merge-tools]`` section.
2545 For configuring merge tools see the ``[merge-tools]`` section.
2531
2546
2532 ``mergemarkers``
2547 ``mergemarkers``
2533 Sets the merge conflict marker label styling. The ``detailed`` style
2548 Sets the merge conflict marker label styling. The ``detailed`` style
2534 uses the ``command-templates.mergemarker`` setting to style the labels.
2549 uses the ``command-templates.mergemarker`` setting to style the labels.
2535 The ``basic`` style just uses 'local' and 'other' as the marker label.
2550 The ``basic`` style just uses 'local' and 'other' as the marker label.
2536 One of ``basic`` or ``detailed``.
2551 One of ``basic`` or ``detailed``.
2537 (default: ``basic``)
2552 (default: ``basic``)
2538
2553
2539 ``mergemarkertemplate``
2554 ``mergemarkertemplate``
2540 (DEPRECATED) Use ``command-templates.mergemarker`` instead.
2555 (DEPRECATED) Use ``command-templates.mergemarker`` instead.
2541
2556
2542 ``message-output``
2557 ``message-output``
2543 Where to write status and error messages. (default: ``stdio``)
2558 Where to write status and error messages. (default: ``stdio``)
2544
2559
2545 ``channel``
2560 ``channel``
2546 Use separate channel for structured output. (Command-server only)
2561 Use separate channel for structured output. (Command-server only)
2547 ``stderr``
2562 ``stderr``
2548 Everything to stderr.
2563 Everything to stderr.
2549 ``stdio``
2564 ``stdio``
2550 Status to stdout, and error to stderr.
2565 Status to stdout, and error to stderr.
2551
2566
2552 ``origbackuppath``
2567 ``origbackuppath``
2553 The path to a directory used to store generated .orig files. If the path is
2568 The path to a directory used to store generated .orig files. If the path is
2554 not a directory, one will be created. If set, files stored in this
2569 not a directory, one will be created. If set, files stored in this
2555 directory have the same name as the original file and do not have a .orig
2570 directory have the same name as the original file and do not have a .orig
2556 suffix.
2571 suffix.
2557
2572
2558 ``paginate``
2573 ``paginate``
2559 Control the pagination of command output (default: True). See :hg:`help pager`
2574 Control the pagination of command output (default: True). See :hg:`help pager`
2560 for details.
2575 for details.
2561
2576
2562 ``patch``
2577 ``patch``
2563 An optional external tool that ``hg import`` and some extensions
2578 An optional external tool that ``hg import`` and some extensions
2564 will use for applying patches. By default Mercurial uses an
2579 will use for applying patches. By default Mercurial uses an
2565 internal patch utility. The external tool must work as the common
2580 internal patch utility. The external tool must work as the common
2566 Unix ``patch`` program. In particular, it must accept a ``-p``
2581 Unix ``patch`` program. In particular, it must accept a ``-p``
2567 argument to strip patch headers, a ``-d`` argument to specify the
2582 argument to strip patch headers, a ``-d`` argument to specify the
2568 current directory, a file name to patch, and a patch file to take
2583 current directory, a file name to patch, and a patch file to take
2569 from stdin.
2584 from stdin.
2570
2585
2571 It is possible to specify a patch tool together with extra
2586 It is possible to specify a patch tool together with extra
2572 arguments. For example, setting this option to ``patch --merge``
2587 arguments. For example, setting this option to ``patch --merge``
2573 will use the ``patch`` program with its 2-way merge option.
2588 will use the ``patch`` program with its 2-way merge option.
2574
2589
2575 ``portablefilenames``
2590 ``portablefilenames``
2576 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2591 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2577 (default: ``warn``)
2592 (default: ``warn``)
2578
2593
2579 ``warn``
2594 ``warn``
2580 Print a warning message on POSIX platforms, if a file with a non-portable
2595 Print a warning message on POSIX platforms, if a file with a non-portable
2581 filename is added (e.g. a file with a name that can't be created on
2596 filename is added (e.g. a file with a name that can't be created on
2582 Windows because it contains reserved parts like ``AUX``, reserved
2597 Windows because it contains reserved parts like ``AUX``, reserved
2583 characters like ``:``, or would cause a case collision with an existing
2598 characters like ``:``, or would cause a case collision with an existing
2584 file).
2599 file).
2585
2600
2586 ``ignore``
2601 ``ignore``
2587 Don't print a warning.
2602 Don't print a warning.
2588
2603
2589 ``abort``
2604 ``abort``
2590 The command is aborted.
2605 The command is aborted.
2591
2606
2592 ``true``
2607 ``true``
2593 Alias for ``warn``.
2608 Alias for ``warn``.
2594
2609
2595 ``false``
2610 ``false``
2596 Alias for ``ignore``.
2611 Alias for ``ignore``.
2597
2612
2598 .. container:: windows
2613 .. container:: windows
2599
2614
2600 On Windows, this configuration option is ignored and the command aborted.
2615 On Windows, this configuration option is ignored and the command aborted.
2601
2616
2602 ``pre-merge-tool-output-template``
2617 ``pre-merge-tool-output-template``
2603 (DEPRECATED) Use ``command-template.pre-merge-tool-output`` instead.
2618 (DEPRECATED) Use ``command-template.pre-merge-tool-output`` instead.
2604
2619
2605 ``quiet``
2620 ``quiet``
2606 Reduce the amount of output printed.
2621 Reduce the amount of output printed.
2607 (default: False)
2622 (default: False)
2608
2623
2609 ``relative-paths``
2624 ``relative-paths``
2610 Prefer relative paths in the UI.
2625 Prefer relative paths in the UI.
2611
2626
2612 ``remotecmd``
2627 ``remotecmd``
2613 Remote command to use for clone/push/pull operations.
2628 Remote command to use for clone/push/pull operations.
2614 (default: ``hg``)
2629 (default: ``hg``)
2615
2630
2616 ``report_untrusted``
2631 ``report_untrusted``
2617 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2632 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2618 trusted user or group.
2633 trusted user or group.
2619 (default: True)
2634 (default: True)
2620
2635
2621 ``slash``
2636 ``slash``
2622 (Deprecated. Use ``slashpath`` template filter instead.)
2637 (Deprecated. Use ``slashpath`` template filter instead.)
2623
2638
2624 Display paths using a slash (``/``) as the path separator. This
2639 Display paths using a slash (``/``) as the path separator. This
2625 only makes a difference on systems where the default path
2640 only makes a difference on systems where the default path
2626 separator is not the slash character (e.g. Windows uses the
2641 separator is not the slash character (e.g. Windows uses the
2627 backslash character (``\``)).
2642 backslash character (``\``)).
2628 (default: False)
2643 (default: False)
2629
2644
2630 ``statuscopies``
2645 ``statuscopies``
2631 Display copies in the status command.
2646 Display copies in the status command.
2632
2647
2633 ``ssh``
2648 ``ssh``
2634 Command to use for SSH connections. (default: ``ssh``)
2649 Command to use for SSH connections. (default: ``ssh``)
2635
2650
2636 ``ssherrorhint``
2651 ``ssherrorhint``
2637 A hint shown to the user in the case of SSH error (e.g.
2652 A hint shown to the user in the case of SSH error (e.g.
2638 ``Please see http://company/internalwiki/ssh.html``)
2653 ``Please see http://company/internalwiki/ssh.html``)
2639
2654
2640 ``strict``
2655 ``strict``
2641 Require exact command names, instead of allowing unambiguous
2656 Require exact command names, instead of allowing unambiguous
2642 abbreviations. (default: False)
2657 abbreviations. (default: False)
2643
2658
2644 ``style``
2659 ``style``
2645 Name of style to use for command output.
2660 Name of style to use for command output.
2646
2661
2647 ``supportcontact``
2662 ``supportcontact``
2648 A URL where users should report a Mercurial traceback. Use this if you are a
2663 A URL where users should report a Mercurial traceback. Use this if you are a
2649 large organisation with its own Mercurial deployment process and crash
2664 large organisation with its own Mercurial deployment process and crash
2650 reports should be addressed to your internal support.
2665 reports should be addressed to your internal support.
2651
2666
2652 ``textwidth``
2667 ``textwidth``
2653 Maximum width of help text. A longer line generated by ``hg help`` or
2668 Maximum width of help text. A longer line generated by ``hg help`` or
2654 ``hg subcommand --help`` will be broken after white space to get this
2669 ``hg subcommand --help`` will be broken after white space to get this
2655 width or the terminal width, whichever comes first.
2670 width or the terminal width, whichever comes first.
2656 A non-positive value will disable this and the terminal width will be
2671 A non-positive value will disable this and the terminal width will be
2657 used. (default: 78)
2672 used. (default: 78)
2658
2673
2659 ``timeout``
2674 ``timeout``
2660 The timeout used when a lock is held (in seconds), a negative value
2675 The timeout used when a lock is held (in seconds), a negative value
2661 means no timeout. (default: 600)
2676 means no timeout. (default: 600)
2662
2677
2663 ``timeout.warn``
2678 ``timeout.warn``
2664 Time (in seconds) before a warning is printed about held lock. A negative
2679 Time (in seconds) before a warning is printed about held lock. A negative
2665 value means no warning. (default: 0)
2680 value means no warning. (default: 0)
2666
2681
2667 ``traceback``
2682 ``traceback``
2668 Mercurial always prints a traceback when an unknown exception
2683 Mercurial always prints a traceback when an unknown exception
2669 occurs. Setting this to True will make Mercurial print a traceback
2684 occurs. Setting this to True will make Mercurial print a traceback
2670 on all exceptions, even those recognized by Mercurial (such as
2685 on all exceptions, even those recognized by Mercurial (such as
2671 IOError or MemoryError). (default: False)
2686 IOError or MemoryError). (default: False)
2672
2687
2673 ``tweakdefaults``
2688 ``tweakdefaults``
2674
2689
2675 By default Mercurial's behavior changes very little from release
2690 By default Mercurial's behavior changes very little from release
2676 to release, but over time the recommended config settings
2691 to release, but over time the recommended config settings
2677 shift. Enable this config to opt in to get automatic tweaks to
2692 shift. Enable this config to opt in to get automatic tweaks to
2678 Mercurial's behavior over time. This config setting will have no
2693 Mercurial's behavior over time. This config setting will have no
2679 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2694 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2680 not include ``tweakdefaults``. (default: False)
2695 not include ``tweakdefaults``. (default: False)
2681
2696
2682 It currently means::
2697 It currently means::
2683
2698
2684 .. tweakdefaultsmarker
2699 .. tweakdefaultsmarker
2685
2700
2686 ``username``
2701 ``username``
2687 The committer of a changeset created when running "commit".
2702 The committer of a changeset created when running "commit".
2688 Typically a person's name and email address, e.g. ``Fred Widget
2703 Typically a person's name and email address, e.g. ``Fred Widget
2689 <fred@example.com>``. Environment variables in the
2704 <fred@example.com>``. Environment variables in the
2690 username are expanded.
2705 username are expanded.
2691
2706
2692 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2707 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2693 hgrc is empty, e.g. if the system admin set ``username =`` in the
2708 hgrc is empty, e.g. if the system admin set ``username =`` in the
2694 system hgrc, it has to be specified manually or in a different
2709 system hgrc, it has to be specified manually or in a different
2695 hgrc file)
2710 hgrc file)
2696
2711
2697 ``verbose``
2712 ``verbose``
2698 Increase the amount of output printed. (default: False)
2713 Increase the amount of output printed. (default: False)
2699
2714
2700
2715
2701 ``command-templates``
2716 ``command-templates``
2702 ---------------------
2717 ---------------------
2703
2718
2704 Templates used for customizing the output of commands.
2719 Templates used for customizing the output of commands.
2705
2720
2706 ``graphnode``
2721 ``graphnode``
2707 The template used to print changeset nodes in an ASCII revision graph.
2722 The template used to print changeset nodes in an ASCII revision graph.
2708 (default: ``{graphnode}``)
2723 (default: ``{graphnode}``)
2709
2724
2710 ``log``
2725 ``log``
2711 Template string for commands that print changesets.
2726 Template string for commands that print changesets.
2712
2727
2713 ``mergemarker``
2728 ``mergemarker``
2714 The template used to print the commit description next to each conflict
2729 The template used to print the commit description next to each conflict
2715 marker during merge conflicts. See :hg:`help templates` for the template
2730 marker during merge conflicts. See :hg:`help templates` for the template
2716 format.
2731 format.
2717
2732
2718 Defaults to showing the hash, tags, branches, bookmarks, author, and
2733 Defaults to showing the hash, tags, branches, bookmarks, author, and
2719 the first line of the commit description.
2734 the first line of the commit description.
2720
2735
2721 If you use non-ASCII characters in names for tags, branches, bookmarks,
2736 If you use non-ASCII characters in names for tags, branches, bookmarks,
2722 authors, and/or commit descriptions, you must pay attention to encodings of
2737 authors, and/or commit descriptions, you must pay attention to encodings of
2723 managed files. At template expansion, non-ASCII characters use the encoding
2738 managed files. At template expansion, non-ASCII characters use the encoding
2724 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2739 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2725 environment variables that govern your locale. If the encoding of the merge
2740 environment variables that govern your locale. If the encoding of the merge
2726 markers is different from the encoding of the merged files,
2741 markers is different from the encoding of the merged files,
2727 serious problems may occur.
2742 serious problems may occur.
2728
2743
2729 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2744 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2730
2745
2731 ``oneline-summary``
2746 ``oneline-summary``
2732 A template used by `hg rebase` and other commands for showing a one-line
2747 A template used by `hg rebase` and other commands for showing a one-line
2733 summary of a commit. If the template configured here is longer than one
2748 summary of a commit. If the template configured here is longer than one
2734 line, then only the first line is used.
2749 line, then only the first line is used.
2735
2750
2736 The template can be overridden per command by defining a template in
2751 The template can be overridden per command by defining a template in
2737 `oneline-summary.<command>`, where `<command>` can be e.g. "rebase".
2752 `oneline-summary.<command>`, where `<command>` can be e.g. "rebase".
2738
2753
2739 ``pre-merge-tool-output``
2754 ``pre-merge-tool-output``
2740 A template that is printed before executing an external merge tool. This can
2755 A template that is printed before executing an external merge tool. This can
2741 be used to print out additional context that might be useful to have during
2756 be used to print out additional context that might be useful to have during
2742 the conflict resolution, such as the description of the various commits
2757 the conflict resolution, such as the description of the various commits
2743 involved or bookmarks/tags.
2758 involved or bookmarks/tags.
2744
2759
2745 Additional information is available in the ``local`, ``base``, and ``other``
2760 Additional information is available in the ``local`, ``base``, and ``other``
2746 dicts. For example: ``{local.label}``, ``{base.name}``, or
2761 dicts. For example: ``{local.label}``, ``{base.name}``, or
2747 ``{other.islink}``.
2762 ``{other.islink}``.
2748
2763
2749
2764
2750 ``web``
2765 ``web``
2751 -------
2766 -------
2752
2767
2753 Web interface configuration. The settings in this section apply to
2768 Web interface configuration. The settings in this section apply to
2754 both the builtin webserver (started by :hg:`serve`) and the script you
2769 both the builtin webserver (started by :hg:`serve`) and the script you
2755 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2770 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2756 and WSGI).
2771 and WSGI).
2757
2772
2758 The Mercurial webserver does no authentication (it does not prompt for
2773 The Mercurial webserver does no authentication (it does not prompt for
2759 usernames and passwords to validate *who* users are), but it does do
2774 usernames and passwords to validate *who* users are), but it does do
2760 authorization (it grants or denies access for *authenticated users*
2775 authorization (it grants or denies access for *authenticated users*
2761 based on settings in this section). You must either configure your
2776 based on settings in this section). You must either configure your
2762 webserver to do authentication for you, or disable the authorization
2777 webserver to do authentication for you, or disable the authorization
2763 checks.
2778 checks.
2764
2779
2765 For a quick setup in a trusted environment, e.g., a private LAN, where
2780 For a quick setup in a trusted environment, e.g., a private LAN, where
2766 you want it to accept pushes from anybody, you can use the following
2781 you want it to accept pushes from anybody, you can use the following
2767 command line::
2782 command line::
2768
2783
2769 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2784 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2770
2785
2771 Note that this will allow anybody to push anything to the server and
2786 Note that this will allow anybody to push anything to the server and
2772 that this should not be used for public servers.
2787 that this should not be used for public servers.
2773
2788
2774 The full set of options is:
2789 The full set of options is:
2775
2790
2776 ``accesslog``
2791 ``accesslog``
2777 Where to output the access log. (default: stdout)
2792 Where to output the access log. (default: stdout)
2778
2793
2779 ``address``
2794 ``address``
2780 Interface address to bind to. (default: all)
2795 Interface address to bind to. (default: all)
2781
2796
2782 ``allow-archive``
2797 ``allow-archive``
2783 List of archive format (bz2, gz, zip) allowed for downloading.
2798 List of archive format (bz2, gz, zip) allowed for downloading.
2784 (default: empty)
2799 (default: empty)
2785
2800
2786 ``allowbz2``
2801 ``allowbz2``
2787 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2802 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2788 revisions.
2803 revisions.
2789 (default: False)
2804 (default: False)
2790
2805
2791 ``allowgz``
2806 ``allowgz``
2792 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2807 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2793 revisions.
2808 revisions.
2794 (default: False)
2809 (default: False)
2795
2810
2796 ``allow-pull``
2811 ``allow-pull``
2797 Whether to allow pulling from the repository. (default: True)
2812 Whether to allow pulling from the repository. (default: True)
2798
2813
2799 ``allow-push``
2814 ``allow-push``
2800 Whether to allow pushing to the repository. If empty or not set,
2815 Whether to allow pushing to the repository. If empty or not set,
2801 pushing is not allowed. If the special value ``*``, any remote
2816 pushing is not allowed. If the special value ``*``, any remote
2802 user can push, including unauthenticated users. Otherwise, the
2817 user can push, including unauthenticated users. Otherwise, the
2803 remote user must have been authenticated, and the authenticated
2818 remote user must have been authenticated, and the authenticated
2804 user name must be present in this list. The contents of the
2819 user name must be present in this list. The contents of the
2805 allow-push list are examined after the deny_push list.
2820 allow-push list are examined after the deny_push list.
2806
2821
2807 ``allow_read``
2822 ``allow_read``
2808 If the user has not already been denied repository access due to
2823 If the user has not already been denied repository access due to
2809 the contents of deny_read, this list determines whether to grant
2824 the contents of deny_read, this list determines whether to grant
2810 repository access to the user. If this list is not empty, and the
2825 repository access to the user. If this list is not empty, and the
2811 user is unauthenticated or not present in the list, then access is
2826 user is unauthenticated or not present in the list, then access is
2812 denied for the user. If the list is empty or not set, then access
2827 denied for the user. If the list is empty or not set, then access
2813 is permitted to all users by default. Setting allow_read to the
2828 is permitted to all users by default. Setting allow_read to the
2814 special value ``*`` is equivalent to it not being set (i.e. access
2829 special value ``*`` is equivalent to it not being set (i.e. access
2815 is permitted to all users). The contents of the allow_read list are
2830 is permitted to all users). The contents of the allow_read list are
2816 examined after the deny_read list.
2831 examined after the deny_read list.
2817
2832
2818 ``allowzip``
2833 ``allowzip``
2819 (DEPRECATED) Whether to allow .zip downloading of repository
2834 (DEPRECATED) Whether to allow .zip downloading of repository
2820 revisions. This feature creates temporary files.
2835 revisions. This feature creates temporary files.
2821 (default: False)
2836 (default: False)
2822
2837
2823 ``archivesubrepos``
2838 ``archivesubrepos``
2824 Whether to recurse into subrepositories when archiving.
2839 Whether to recurse into subrepositories when archiving.
2825 (default: False)
2840 (default: False)
2826
2841
2827 ``baseurl``
2842 ``baseurl``
2828 Base URL to use when publishing URLs in other locations, so
2843 Base URL to use when publishing URLs in other locations, so
2829 third-party tools like email notification hooks can construct
2844 third-party tools like email notification hooks can construct
2830 URLs. Example: ``http://hgserver/repos/``.
2845 URLs. Example: ``http://hgserver/repos/``.
2831
2846
2832 ``cacerts``
2847 ``cacerts``
2833 Path to file containing a list of PEM encoded certificate
2848 Path to file containing a list of PEM encoded certificate
2834 authority certificates. Environment variables and ``~user``
2849 authority certificates. Environment variables and ``~user``
2835 constructs are expanded in the filename. If specified on the
2850 constructs are expanded in the filename. If specified on the
2836 client, then it will verify the identity of remote HTTPS servers
2851 client, then it will verify the identity of remote HTTPS servers
2837 with these certificates.
2852 with these certificates.
2838
2853
2839 To disable SSL verification temporarily, specify ``--insecure`` from
2854 To disable SSL verification temporarily, specify ``--insecure`` from
2840 command line.
2855 command line.
2841
2856
2842 You can use OpenSSL's CA certificate file if your platform has
2857 You can use OpenSSL's CA certificate file if your platform has
2843 one. On most Linux systems this will be
2858 one. On most Linux systems this will be
2844 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2859 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2845 generate this file manually. The form must be as follows::
2860 generate this file manually. The form must be as follows::
2846
2861
2847 -----BEGIN CERTIFICATE-----
2862 -----BEGIN CERTIFICATE-----
2848 ... (certificate in base64 PEM encoding) ...
2863 ... (certificate in base64 PEM encoding) ...
2849 -----END CERTIFICATE-----
2864 -----END CERTIFICATE-----
2850 -----BEGIN CERTIFICATE-----
2865 -----BEGIN CERTIFICATE-----
2851 ... (certificate in base64 PEM encoding) ...
2866 ... (certificate in base64 PEM encoding) ...
2852 -----END CERTIFICATE-----
2867 -----END CERTIFICATE-----
2853
2868
2854 ``cache``
2869 ``cache``
2855 Whether to support caching in hgweb. (default: True)
2870 Whether to support caching in hgweb. (default: True)
2856
2871
2857 ``certificate``
2872 ``certificate``
2858 Certificate to use when running :hg:`serve`.
2873 Certificate to use when running :hg:`serve`.
2859
2874
2860 ``collapse``
2875 ``collapse``
2861 With ``descend`` enabled, repositories in subdirectories are shown at
2876 With ``descend`` enabled, repositories in subdirectories are shown at
2862 a single level alongside repositories in the current path. With
2877 a single level alongside repositories in the current path. With
2863 ``collapse`` also enabled, repositories residing at a deeper level than
2878 ``collapse`` also enabled, repositories residing at a deeper level than
2864 the current path are grouped behind navigable directory entries that
2879 the current path are grouped behind navigable directory entries that
2865 lead to the locations of these repositories. In effect, this setting
2880 lead to the locations of these repositories. In effect, this setting
2866 collapses each collection of repositories found within a subdirectory
2881 collapses each collection of repositories found within a subdirectory
2867 into a single entry for that subdirectory. (default: False)
2882 into a single entry for that subdirectory. (default: False)
2868
2883
2869 ``comparisoncontext``
2884 ``comparisoncontext``
2870 Number of lines of context to show in side-by-side file comparison. If
2885 Number of lines of context to show in side-by-side file comparison. If
2871 negative or the value ``full``, whole files are shown. (default: 5)
2886 negative or the value ``full``, whole files are shown. (default: 5)
2872
2887
2873 This setting can be overridden by a ``context`` request parameter to the
2888 This setting can be overridden by a ``context`` request parameter to the
2874 ``comparison`` command, taking the same values.
2889 ``comparison`` command, taking the same values.
2875
2890
2876 ``contact``
2891 ``contact``
2877 Name or email address of the person in charge of the repository.
2892 Name or email address of the person in charge of the repository.
2878 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2893 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2879
2894
2880 ``csp``
2895 ``csp``
2881 Send a ``Content-Security-Policy`` HTTP header with this value.
2896 Send a ``Content-Security-Policy`` HTTP header with this value.
2882
2897
2883 The value may contain a special string ``%nonce%``, which will be replaced
2898 The value may contain a special string ``%nonce%``, which will be replaced
2884 by a randomly-generated one-time use value. If the value contains
2899 by a randomly-generated one-time use value. If the value contains
2885 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2900 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2886 one-time property of the nonce. This nonce will also be inserted into
2901 one-time property of the nonce. This nonce will also be inserted into
2887 ``<script>`` elements containing inline JavaScript.
2902 ``<script>`` elements containing inline JavaScript.
2888
2903
2889 Note: lots of HTML content sent by the server is derived from repository
2904 Note: lots of HTML content sent by the server is derived from repository
2890 data. Please consider the potential for malicious repository data to
2905 data. Please consider the potential for malicious repository data to
2891 "inject" itself into generated HTML content as part of your security
2906 "inject" itself into generated HTML content as part of your security
2892 threat model.
2907 threat model.
2893
2908
2894 ``deny_push``
2909 ``deny_push``
2895 Whether to deny pushing to the repository. If empty or not set,
2910 Whether to deny pushing to the repository. If empty or not set,
2896 push is not denied. If the special value ``*``, all remote users are
2911 push is not denied. If the special value ``*``, all remote users are
2897 denied push. Otherwise, unauthenticated users are all denied, and
2912 denied push. Otherwise, unauthenticated users are all denied, and
2898 any authenticated user name present in this list is also denied. The
2913 any authenticated user name present in this list is also denied. The
2899 contents of the deny_push list are examined before the allow-push list.
2914 contents of the deny_push list are examined before the allow-push list.
2900
2915
2901 ``deny_read``
2916 ``deny_read``
2902 Whether to deny reading/viewing of the repository. If this list is
2917 Whether to deny reading/viewing of the repository. If this list is
2903 not empty, unauthenticated users are all denied, and any
2918 not empty, unauthenticated users are all denied, and any
2904 authenticated user name present in this list is also denied access to
2919 authenticated user name present in this list is also denied access to
2905 the repository. If set to the special value ``*``, all remote users
2920 the repository. If set to the special value ``*``, all remote users
2906 are denied access (rarely needed ;). If deny_read is empty or not set,
2921 are denied access (rarely needed ;). If deny_read is empty or not set,
2907 the determination of repository access depends on the presence and
2922 the determination of repository access depends on the presence and
2908 content of the allow_read list (see description). If both
2923 content of the allow_read list (see description). If both
2909 deny_read and allow_read are empty or not set, then access is
2924 deny_read and allow_read are empty or not set, then access is
2910 permitted to all users by default. If the repository is being
2925 permitted to all users by default. If the repository is being
2911 served via hgwebdir, denied users will not be able to see it in
2926 served via hgwebdir, denied users will not be able to see it in
2912 the list of repositories. The contents of the deny_read list have
2927 the list of repositories. The contents of the deny_read list have
2913 priority over (are examined before) the contents of the allow_read
2928 priority over (are examined before) the contents of the allow_read
2914 list.
2929 list.
2915
2930
2916 ``descend``
2931 ``descend``
2917 hgwebdir indexes will not descend into subdirectories. Only repositories
2932 hgwebdir indexes will not descend into subdirectories. Only repositories
2918 directly in the current path will be shown (other repositories are still
2933 directly in the current path will be shown (other repositories are still
2919 available from the index corresponding to their containing path).
2934 available from the index corresponding to their containing path).
2920
2935
2921 ``description``
2936 ``description``
2922 Textual description of the repository's purpose or contents.
2937 Textual description of the repository's purpose or contents.
2923 (default: "unknown")
2938 (default: "unknown")
2924
2939
2925 ``encoding``
2940 ``encoding``
2926 Character encoding name. (default: the current locale charset)
2941 Character encoding name. (default: the current locale charset)
2927 Example: "UTF-8".
2942 Example: "UTF-8".
2928
2943
2929 ``errorlog``
2944 ``errorlog``
2930 Where to output the error log. (default: stderr)
2945 Where to output the error log. (default: stderr)
2931
2946
2932 ``guessmime``
2947 ``guessmime``
2933 Control MIME types for raw download of file content.
2948 Control MIME types for raw download of file content.
2934 Set to True to let hgweb guess the content type from the file
2949 Set to True to let hgweb guess the content type from the file
2935 extension. This will serve HTML files as ``text/html`` and might
2950 extension. This will serve HTML files as ``text/html`` and might
2936 allow cross-site scripting attacks when serving untrusted
2951 allow cross-site scripting attacks when serving untrusted
2937 repositories. (default: False)
2952 repositories. (default: False)
2938
2953
2939 ``hidden``
2954 ``hidden``
2940 Whether to hide the repository in the hgwebdir index.
2955 Whether to hide the repository in the hgwebdir index.
2941 (default: False)
2956 (default: False)
2942
2957
2943 ``ipv6``
2958 ``ipv6``
2944 Whether to use IPv6. (default: False)
2959 Whether to use IPv6. (default: False)
2945
2960
2946 ``labels``
2961 ``labels``
2947 List of string *labels* associated with the repository.
2962 List of string *labels* associated with the repository.
2948
2963
2949 Labels are exposed as a template keyword and can be used to customize
2964 Labels are exposed as a template keyword and can be used to customize
2950 output. e.g. the ``index`` template can group or filter repositories
2965 output. e.g. the ``index`` template can group or filter repositories
2951 by labels and the ``summary`` template can display additional content
2966 by labels and the ``summary`` template can display additional content
2952 if a specific label is present.
2967 if a specific label is present.
2953
2968
2954 ``logoimg``
2969 ``logoimg``
2955 File name of the logo image that some templates display on each page.
2970 File name of the logo image that some templates display on each page.
2956 The file name is relative to ``staticurl``. That is, the full path to
2971 The file name is relative to ``staticurl``. That is, the full path to
2957 the logo image is "staticurl/logoimg".
2972 the logo image is "staticurl/logoimg".
2958 If unset, ``hglogo.png`` will be used.
2973 If unset, ``hglogo.png`` will be used.
2959
2974
2960 ``logourl``
2975 ``logourl``
2961 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2976 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2962 will be used.
2977 will be used.
2963
2978
2964 ``maxchanges``
2979 ``maxchanges``
2965 Maximum number of changes to list on the changelog. (default: 10)
2980 Maximum number of changes to list on the changelog. (default: 10)
2966
2981
2967 ``maxfiles``
2982 ``maxfiles``
2968 Maximum number of files to list per changeset. (default: 10)
2983 Maximum number of files to list per changeset. (default: 10)
2969
2984
2970 ``maxshortchanges``
2985 ``maxshortchanges``
2971 Maximum number of changes to list on the shortlog, graph or filelog
2986 Maximum number of changes to list on the shortlog, graph or filelog
2972 pages. (default: 60)
2987 pages. (default: 60)
2973
2988
2974 ``name``
2989 ``name``
2975 Repository name to use in the web interface.
2990 Repository name to use in the web interface.
2976 (default: current working directory)
2991 (default: current working directory)
2977
2992
2978 ``port``
2993 ``port``
2979 Port to listen on. (default: 8000)
2994 Port to listen on. (default: 8000)
2980
2995
2981 ``prefix``
2996 ``prefix``
2982 Prefix path to serve from. (default: '' (server root))
2997 Prefix path to serve from. (default: '' (server root))
2983
2998
2984 ``push_ssl``
2999 ``push_ssl``
2985 Whether to require that inbound pushes be transported over SSL to
3000 Whether to require that inbound pushes be transported over SSL to
2986 prevent password sniffing. (default: True)
3001 prevent password sniffing. (default: True)
2987
3002
2988 ``refreshinterval``
3003 ``refreshinterval``
2989 How frequently directory listings re-scan the filesystem for new
3004 How frequently directory listings re-scan the filesystem for new
2990 repositories, in seconds. This is relevant when wildcards are used
3005 repositories, in seconds. This is relevant when wildcards are used
2991 to define paths. Depending on how much filesystem traversal is
3006 to define paths. Depending on how much filesystem traversal is
2992 required, refreshing may negatively impact performance.
3007 required, refreshing may negatively impact performance.
2993
3008
2994 Values less than or equal to 0 always refresh.
3009 Values less than or equal to 0 always refresh.
2995 (default: 20)
3010 (default: 20)
2996
3011
2997 ``server-header``
3012 ``server-header``
2998 Value for HTTP ``Server`` response header.
3013 Value for HTTP ``Server`` response header.
2999
3014
3000 ``static``
3015 ``static``
3001 Directory where static files are served from.
3016 Directory where static files are served from.
3002
3017
3003 ``staticurl``
3018 ``staticurl``
3004 Base URL to use for static files. If unset, static files (e.g. the
3019 Base URL to use for static files. If unset, static files (e.g. the
3005 hgicon.png favicon) will be served by the CGI script itself. Use
3020 hgicon.png favicon) will be served by the CGI script itself. Use
3006 this setting to serve them directly with the HTTP server.
3021 this setting to serve them directly with the HTTP server.
3007 Example: ``http://hgserver/static/``.
3022 Example: ``http://hgserver/static/``.
3008
3023
3009 ``stripes``
3024 ``stripes``
3010 How many lines a "zebra stripe" should span in multi-line output.
3025 How many lines a "zebra stripe" should span in multi-line output.
3011 Set to 0 to disable. (default: 1)
3026 Set to 0 to disable. (default: 1)
3012
3027
3013 ``style``
3028 ``style``
3014 Which template map style to use. The available options are the names of
3029 Which template map style to use. The available options are the names of
3015 subdirectories in the HTML templates path. (default: ``paper``)
3030 subdirectories in the HTML templates path. (default: ``paper``)
3016 Example: ``monoblue``.
3031 Example: ``monoblue``.
3017
3032
3018 ``templates``
3033 ``templates``
3019 Where to find the HTML templates. The default path to the HTML templates
3034 Where to find the HTML templates. The default path to the HTML templates
3020 can be obtained from ``hg debuginstall``.
3035 can be obtained from ``hg debuginstall``.
3021
3036
3022 ``websub``
3037 ``websub``
3023 ----------
3038 ----------
3024
3039
3025 Web substitution filter definition. You can use this section to
3040 Web substitution filter definition. You can use this section to
3026 define a set of regular expression substitution patterns which
3041 define a set of regular expression substitution patterns which
3027 let you automatically modify the hgweb server output.
3042 let you automatically modify the hgweb server output.
3028
3043
3029 The default hgweb templates only apply these substitution patterns
3044 The default hgweb templates only apply these substitution patterns
3030 on the revision description fields. You can apply them anywhere
3045 on the revision description fields. You can apply them anywhere
3031 you want when you create your own templates by adding calls to the
3046 you want when you create your own templates by adding calls to the
3032 "websub" filter (usually after calling the "escape" filter).
3047 "websub" filter (usually after calling the "escape" filter).
3033
3048
3034 This can be used, for example, to convert issue references to links
3049 This can be used, for example, to convert issue references to links
3035 to your issue tracker, or to convert "markdown-like" syntax into
3050 to your issue tracker, or to convert "markdown-like" syntax into
3036 HTML (see the examples below).
3051 HTML (see the examples below).
3037
3052
3038 Each entry in this section names a substitution filter.
3053 Each entry in this section names a substitution filter.
3039 The value of each entry defines the substitution expression itself.
3054 The value of each entry defines the substitution expression itself.
3040 The websub expressions follow the old interhg extension syntax,
3055 The websub expressions follow the old interhg extension syntax,
3041 which in turn imitates the Unix sed replacement syntax::
3056 which in turn imitates the Unix sed replacement syntax::
3042
3057
3043 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
3058 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
3044
3059
3045 You can use any separator other than "/". The final "i" is optional
3060 You can use any separator other than "/". The final "i" is optional
3046 and indicates that the search must be case insensitive.
3061 and indicates that the search must be case insensitive.
3047
3062
3048 Examples::
3063 Examples::
3049
3064
3050 [websub]
3065 [websub]
3051 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
3066 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
3052 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
3067 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
3053 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
3068 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
3054
3069
3055 ``worker``
3070 ``worker``
3056 ----------
3071 ----------
3057
3072
3058 Parallel master/worker configuration. We currently perform working
3073 Parallel master/worker configuration. We currently perform working
3059 directory updates in parallel on Unix-like systems, which greatly
3074 directory updates in parallel on Unix-like systems, which greatly
3060 helps performance.
3075 helps performance.
3061
3076
3062 ``enabled``
3077 ``enabled``
3063 Whether to enable workers code to be used.
3078 Whether to enable workers code to be used.
3064 (default: true)
3079 (default: true)
3065
3080
3066 ``numcpus``
3081 ``numcpus``
3067 Number of CPUs to use for parallel operations. A zero or
3082 Number of CPUs to use for parallel operations. A zero or
3068 negative value is treated as ``use the default``.
3083 negative value is treated as ``use the default``.
3069 (default: 4 or the number of CPUs on the system, whichever is larger)
3084 (default: 4 or the number of CPUs on the system, whichever is larger)
3070
3085
3071 ``backgroundclose``
3086 ``backgroundclose``
3072 Whether to enable closing file handles on background threads during certain
3087 Whether to enable closing file handles on background threads during certain
3073 operations. Some platforms aren't very efficient at closing file
3088 operations. Some platforms aren't very efficient at closing file
3074 handles that have been written or appended to. By performing file closing
3089 handles that have been written or appended to. By performing file closing
3075 on background threads, file write rate can increase substantially.
3090 on background threads, file write rate can increase substantially.
3076 (default: true on Windows, false elsewhere)
3091 (default: true on Windows, false elsewhere)
3077
3092
3078 ``backgroundcloseminfilecount``
3093 ``backgroundcloseminfilecount``
3079 Minimum number of files required to trigger background file closing.
3094 Minimum number of files required to trigger background file closing.
3080 Operations not writing this many files won't start background close
3095 Operations not writing this many files won't start background close
3081 threads.
3096 threads.
3082 (default: 2048)
3097 (default: 2048)
3083
3098
3084 ``backgroundclosemaxqueue``
3099 ``backgroundclosemaxqueue``
3085 The maximum number of opened file handles waiting to be closed in the
3100 The maximum number of opened file handles waiting to be closed in the
3086 background. This option only has an effect if ``backgroundclose`` is
3101 background. This option only has an effect if ``backgroundclose`` is
3087 enabled.
3102 enabled.
3088 (default: 384)
3103 (default: 384)
3089
3104
3090 ``backgroundclosethreadcount``
3105 ``backgroundclosethreadcount``
3091 Number of threads to process background file closes. Only relevant if
3106 Number of threads to process background file closes. Only relevant if
3092 ``backgroundclose`` is enabled.
3107 ``backgroundclose`` is enabled.
3093 (default: 4)
3108 (default: 4)
@@ -1,3848 +1,3851 b''
1 # localrepo.py - read/write repository class for mercurial
1 # localrepo.py - read/write repository class for mercurial
2 #
2 #
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import errno
10 import errno
11 import functools
11 import functools
12 import os
12 import os
13 import random
13 import random
14 import sys
14 import sys
15 import time
15 import time
16 import weakref
16 import weakref
17
17
18 from .i18n import _
18 from .i18n import _
19 from .node import (
19 from .node import (
20 bin,
20 bin,
21 hex,
21 hex,
22 nullrev,
22 nullrev,
23 sha1nodeconstants,
23 sha1nodeconstants,
24 short,
24 short,
25 )
25 )
26 from .pycompat import (
26 from .pycompat import (
27 delattr,
27 delattr,
28 getattr,
28 getattr,
29 )
29 )
30 from . import (
30 from . import (
31 bookmarks,
31 bookmarks,
32 branchmap,
32 branchmap,
33 bundle2,
33 bundle2,
34 bundlecaches,
34 bundlecaches,
35 changegroup,
35 changegroup,
36 color,
36 color,
37 commit,
37 commit,
38 context,
38 context,
39 dirstate,
39 dirstate,
40 dirstateguard,
40 dirstateguard,
41 discovery,
41 discovery,
42 encoding,
42 encoding,
43 error,
43 error,
44 exchange,
44 exchange,
45 extensions,
45 extensions,
46 filelog,
46 filelog,
47 hook,
47 hook,
48 lock as lockmod,
48 lock as lockmod,
49 match as matchmod,
49 match as matchmod,
50 mergestate as mergestatemod,
50 mergestate as mergestatemod,
51 mergeutil,
51 mergeutil,
52 namespaces,
52 namespaces,
53 narrowspec,
53 narrowspec,
54 obsolete,
54 obsolete,
55 pathutil,
55 pathutil,
56 phases,
56 phases,
57 pushkey,
57 pushkey,
58 pycompat,
58 pycompat,
59 rcutil,
59 rcutil,
60 repoview,
60 repoview,
61 requirements as requirementsmod,
61 requirements as requirementsmod,
62 revlog,
62 revlog,
63 revset,
63 revset,
64 revsetlang,
64 revsetlang,
65 scmutil,
65 scmutil,
66 sparse,
66 sparse,
67 store as storemod,
67 store as storemod,
68 subrepoutil,
68 subrepoutil,
69 tags as tagsmod,
69 tags as tagsmod,
70 transaction,
70 transaction,
71 txnutil,
71 txnutil,
72 util,
72 util,
73 vfs as vfsmod,
73 vfs as vfsmod,
74 wireprototypes,
74 wireprototypes,
75 )
75 )
76
76
77 from .interfaces import (
77 from .interfaces import (
78 repository,
78 repository,
79 util as interfaceutil,
79 util as interfaceutil,
80 )
80 )
81
81
82 from .utils import (
82 from .utils import (
83 hashutil,
83 hashutil,
84 procutil,
84 procutil,
85 stringutil,
85 stringutil,
86 urlutil,
86 urlutil,
87 )
87 )
88
88
89 from .revlogutils import (
89 from .revlogutils import (
90 concurrency_checker as revlogchecker,
90 concurrency_checker as revlogchecker,
91 constants as revlogconst,
91 constants as revlogconst,
92 sidedata as sidedatamod,
92 sidedata as sidedatamod,
93 )
93 )
94
94
95 release = lockmod.release
95 release = lockmod.release
96 urlerr = util.urlerr
96 urlerr = util.urlerr
97 urlreq = util.urlreq
97 urlreq = util.urlreq
98
98
99 # set of (path, vfs-location) tuples. vfs-location is:
99 # set of (path, vfs-location) tuples. vfs-location is:
100 # - 'plain for vfs relative paths
100 # - 'plain for vfs relative paths
101 # - '' for svfs relative paths
101 # - '' for svfs relative paths
102 _cachedfiles = set()
102 _cachedfiles = set()
103
103
104
104
105 class _basefilecache(scmutil.filecache):
105 class _basefilecache(scmutil.filecache):
106 """All filecache usage on repo are done for logic that should be unfiltered"""
106 """All filecache usage on repo are done for logic that should be unfiltered"""
107
107
108 def __get__(self, repo, type=None):
108 def __get__(self, repo, type=None):
109 if repo is None:
109 if repo is None:
110 return self
110 return self
111 # proxy to unfiltered __dict__ since filtered repo has no entry
111 # proxy to unfiltered __dict__ since filtered repo has no entry
112 unfi = repo.unfiltered()
112 unfi = repo.unfiltered()
113 try:
113 try:
114 return unfi.__dict__[self.sname]
114 return unfi.__dict__[self.sname]
115 except KeyError:
115 except KeyError:
116 pass
116 pass
117 return super(_basefilecache, self).__get__(unfi, type)
117 return super(_basefilecache, self).__get__(unfi, type)
118
118
119 def set(self, repo, value):
119 def set(self, repo, value):
120 return super(_basefilecache, self).set(repo.unfiltered(), value)
120 return super(_basefilecache, self).set(repo.unfiltered(), value)
121
121
122
122
123 class repofilecache(_basefilecache):
123 class repofilecache(_basefilecache):
124 """filecache for files in .hg but outside of .hg/store"""
124 """filecache for files in .hg but outside of .hg/store"""
125
125
126 def __init__(self, *paths):
126 def __init__(self, *paths):
127 super(repofilecache, self).__init__(*paths)
127 super(repofilecache, self).__init__(*paths)
128 for path in paths:
128 for path in paths:
129 _cachedfiles.add((path, b'plain'))
129 _cachedfiles.add((path, b'plain'))
130
130
131 def join(self, obj, fname):
131 def join(self, obj, fname):
132 return obj.vfs.join(fname)
132 return obj.vfs.join(fname)
133
133
134
134
135 class storecache(_basefilecache):
135 class storecache(_basefilecache):
136 """filecache for files in the store"""
136 """filecache for files in the store"""
137
137
138 def __init__(self, *paths):
138 def __init__(self, *paths):
139 super(storecache, self).__init__(*paths)
139 super(storecache, self).__init__(*paths)
140 for path in paths:
140 for path in paths:
141 _cachedfiles.add((path, b''))
141 _cachedfiles.add((path, b''))
142
142
143 def join(self, obj, fname):
143 def join(self, obj, fname):
144 return obj.sjoin(fname)
144 return obj.sjoin(fname)
145
145
146
146
147 class mixedrepostorecache(_basefilecache):
147 class mixedrepostorecache(_basefilecache):
148 """filecache for a mix files in .hg/store and outside"""
148 """filecache for a mix files in .hg/store and outside"""
149
149
150 def __init__(self, *pathsandlocations):
150 def __init__(self, *pathsandlocations):
151 # scmutil.filecache only uses the path for passing back into our
151 # scmutil.filecache only uses the path for passing back into our
152 # join(), so we can safely pass a list of paths and locations
152 # join(), so we can safely pass a list of paths and locations
153 super(mixedrepostorecache, self).__init__(*pathsandlocations)
153 super(mixedrepostorecache, self).__init__(*pathsandlocations)
154 _cachedfiles.update(pathsandlocations)
154 _cachedfiles.update(pathsandlocations)
155
155
156 def join(self, obj, fnameandlocation):
156 def join(self, obj, fnameandlocation):
157 fname, location = fnameandlocation
157 fname, location = fnameandlocation
158 if location == b'plain':
158 if location == b'plain':
159 return obj.vfs.join(fname)
159 return obj.vfs.join(fname)
160 else:
160 else:
161 if location != b'':
161 if location != b'':
162 raise error.ProgrammingError(
162 raise error.ProgrammingError(
163 b'unexpected location: %s' % location
163 b'unexpected location: %s' % location
164 )
164 )
165 return obj.sjoin(fname)
165 return obj.sjoin(fname)
166
166
167
167
168 def isfilecached(repo, name):
168 def isfilecached(repo, name):
169 """check if a repo has already cached "name" filecache-ed property
169 """check if a repo has already cached "name" filecache-ed property
170
170
171 This returns (cachedobj-or-None, iscached) tuple.
171 This returns (cachedobj-or-None, iscached) tuple.
172 """
172 """
173 cacheentry = repo.unfiltered()._filecache.get(name, None)
173 cacheentry = repo.unfiltered()._filecache.get(name, None)
174 if not cacheentry:
174 if not cacheentry:
175 return None, False
175 return None, False
176 return cacheentry.obj, True
176 return cacheentry.obj, True
177
177
178
178
179 class unfilteredpropertycache(util.propertycache):
179 class unfilteredpropertycache(util.propertycache):
180 """propertycache that apply to unfiltered repo only"""
180 """propertycache that apply to unfiltered repo only"""
181
181
182 def __get__(self, repo, type=None):
182 def __get__(self, repo, type=None):
183 unfi = repo.unfiltered()
183 unfi = repo.unfiltered()
184 if unfi is repo:
184 if unfi is repo:
185 return super(unfilteredpropertycache, self).__get__(unfi)
185 return super(unfilteredpropertycache, self).__get__(unfi)
186 return getattr(unfi, self.name)
186 return getattr(unfi, self.name)
187
187
188
188
189 class filteredpropertycache(util.propertycache):
189 class filteredpropertycache(util.propertycache):
190 """propertycache that must take filtering in account"""
190 """propertycache that must take filtering in account"""
191
191
192 def cachevalue(self, obj, value):
192 def cachevalue(self, obj, value):
193 object.__setattr__(obj, self.name, value)
193 object.__setattr__(obj, self.name, value)
194
194
195
195
196 def hasunfilteredcache(repo, name):
196 def hasunfilteredcache(repo, name):
197 """check if a repo has an unfilteredpropertycache value for <name>"""
197 """check if a repo has an unfilteredpropertycache value for <name>"""
198 return name in vars(repo.unfiltered())
198 return name in vars(repo.unfiltered())
199
199
200
200
201 def unfilteredmethod(orig):
201 def unfilteredmethod(orig):
202 """decorate method that always need to be run on unfiltered version"""
202 """decorate method that always need to be run on unfiltered version"""
203
203
204 @functools.wraps(orig)
204 @functools.wraps(orig)
205 def wrapper(repo, *args, **kwargs):
205 def wrapper(repo, *args, **kwargs):
206 return orig(repo.unfiltered(), *args, **kwargs)
206 return orig(repo.unfiltered(), *args, **kwargs)
207
207
208 return wrapper
208 return wrapper
209
209
210
210
211 moderncaps = {
211 moderncaps = {
212 b'lookup',
212 b'lookup',
213 b'branchmap',
213 b'branchmap',
214 b'pushkey',
214 b'pushkey',
215 b'known',
215 b'known',
216 b'getbundle',
216 b'getbundle',
217 b'unbundle',
217 b'unbundle',
218 }
218 }
219 legacycaps = moderncaps.union({b'changegroupsubset'})
219 legacycaps = moderncaps.union({b'changegroupsubset'})
220
220
221
221
222 @interfaceutil.implementer(repository.ipeercommandexecutor)
222 @interfaceutil.implementer(repository.ipeercommandexecutor)
223 class localcommandexecutor(object):
223 class localcommandexecutor(object):
224 def __init__(self, peer):
224 def __init__(self, peer):
225 self._peer = peer
225 self._peer = peer
226 self._sent = False
226 self._sent = False
227 self._closed = False
227 self._closed = False
228
228
229 def __enter__(self):
229 def __enter__(self):
230 return self
230 return self
231
231
232 def __exit__(self, exctype, excvalue, exctb):
232 def __exit__(self, exctype, excvalue, exctb):
233 self.close()
233 self.close()
234
234
235 def callcommand(self, command, args):
235 def callcommand(self, command, args):
236 if self._sent:
236 if self._sent:
237 raise error.ProgrammingError(
237 raise error.ProgrammingError(
238 b'callcommand() cannot be used after sendcommands()'
238 b'callcommand() cannot be used after sendcommands()'
239 )
239 )
240
240
241 if self._closed:
241 if self._closed:
242 raise error.ProgrammingError(
242 raise error.ProgrammingError(
243 b'callcommand() cannot be used after close()'
243 b'callcommand() cannot be used after close()'
244 )
244 )
245
245
246 # We don't need to support anything fancy. Just call the named
246 # We don't need to support anything fancy. Just call the named
247 # method on the peer and return a resolved future.
247 # method on the peer and return a resolved future.
248 fn = getattr(self._peer, pycompat.sysstr(command))
248 fn = getattr(self._peer, pycompat.sysstr(command))
249
249
250 f = pycompat.futures.Future()
250 f = pycompat.futures.Future()
251
251
252 try:
252 try:
253 result = fn(**pycompat.strkwargs(args))
253 result = fn(**pycompat.strkwargs(args))
254 except Exception:
254 except Exception:
255 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
255 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
256 else:
256 else:
257 f.set_result(result)
257 f.set_result(result)
258
258
259 return f
259 return f
260
260
261 def sendcommands(self):
261 def sendcommands(self):
262 self._sent = True
262 self._sent = True
263
263
264 def close(self):
264 def close(self):
265 self._closed = True
265 self._closed = True
266
266
267
267
268 @interfaceutil.implementer(repository.ipeercommands)
268 @interfaceutil.implementer(repository.ipeercommands)
269 class localpeer(repository.peer):
269 class localpeer(repository.peer):
270 '''peer for a local repo; reflects only the most recent API'''
270 '''peer for a local repo; reflects only the most recent API'''
271
271
272 def __init__(self, repo, caps=None):
272 def __init__(self, repo, caps=None):
273 super(localpeer, self).__init__()
273 super(localpeer, self).__init__()
274
274
275 if caps is None:
275 if caps is None:
276 caps = moderncaps.copy()
276 caps = moderncaps.copy()
277 self._repo = repo.filtered(b'served')
277 self._repo = repo.filtered(b'served')
278 self.ui = repo.ui
278 self.ui = repo.ui
279
279
280 if repo._wanted_sidedata:
280 if repo._wanted_sidedata:
281 formatted = bundle2.format_remote_wanted_sidedata(repo)
281 formatted = bundle2.format_remote_wanted_sidedata(repo)
282 caps.add(b'exp-wanted-sidedata=' + formatted)
282 caps.add(b'exp-wanted-sidedata=' + formatted)
283
283
284 self._caps = repo._restrictcapabilities(caps)
284 self._caps = repo._restrictcapabilities(caps)
285
285
286 # Begin of _basepeer interface.
286 # Begin of _basepeer interface.
287
287
288 def url(self):
288 def url(self):
289 return self._repo.url()
289 return self._repo.url()
290
290
291 def local(self):
291 def local(self):
292 return self._repo
292 return self._repo
293
293
294 def peer(self):
294 def peer(self):
295 return self
295 return self
296
296
297 def canpush(self):
297 def canpush(self):
298 return True
298 return True
299
299
300 def close(self):
300 def close(self):
301 self._repo.close()
301 self._repo.close()
302
302
303 # End of _basepeer interface.
303 # End of _basepeer interface.
304
304
305 # Begin of _basewirecommands interface.
305 # Begin of _basewirecommands interface.
306
306
307 def branchmap(self):
307 def branchmap(self):
308 return self._repo.branchmap()
308 return self._repo.branchmap()
309
309
310 def capabilities(self):
310 def capabilities(self):
311 return self._caps
311 return self._caps
312
312
313 def clonebundles(self):
313 def clonebundles(self):
314 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
314 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
315
315
316 def debugwireargs(self, one, two, three=None, four=None, five=None):
316 def debugwireargs(self, one, two, three=None, four=None, five=None):
317 """Used to test argument passing over the wire"""
317 """Used to test argument passing over the wire"""
318 return b"%s %s %s %s %s" % (
318 return b"%s %s %s %s %s" % (
319 one,
319 one,
320 two,
320 two,
321 pycompat.bytestr(three),
321 pycompat.bytestr(three),
322 pycompat.bytestr(four),
322 pycompat.bytestr(four),
323 pycompat.bytestr(five),
323 pycompat.bytestr(five),
324 )
324 )
325
325
326 def getbundle(
326 def getbundle(
327 self,
327 self,
328 source,
328 source,
329 heads=None,
329 heads=None,
330 common=None,
330 common=None,
331 bundlecaps=None,
331 bundlecaps=None,
332 remote_sidedata=None,
332 remote_sidedata=None,
333 **kwargs
333 **kwargs
334 ):
334 ):
335 chunks = exchange.getbundlechunks(
335 chunks = exchange.getbundlechunks(
336 self._repo,
336 self._repo,
337 source,
337 source,
338 heads=heads,
338 heads=heads,
339 common=common,
339 common=common,
340 bundlecaps=bundlecaps,
340 bundlecaps=bundlecaps,
341 remote_sidedata=remote_sidedata,
341 remote_sidedata=remote_sidedata,
342 **kwargs
342 **kwargs
343 )[1]
343 )[1]
344 cb = util.chunkbuffer(chunks)
344 cb = util.chunkbuffer(chunks)
345
345
346 if exchange.bundle2requested(bundlecaps):
346 if exchange.bundle2requested(bundlecaps):
347 # When requesting a bundle2, getbundle returns a stream to make the
347 # When requesting a bundle2, getbundle returns a stream to make the
348 # wire level function happier. We need to build a proper object
348 # wire level function happier. We need to build a proper object
349 # from it in local peer.
349 # from it in local peer.
350 return bundle2.getunbundler(self.ui, cb)
350 return bundle2.getunbundler(self.ui, cb)
351 else:
351 else:
352 return changegroup.getunbundler(b'01', cb, None)
352 return changegroup.getunbundler(b'01', cb, None)
353
353
354 def heads(self):
354 def heads(self):
355 return self._repo.heads()
355 return self._repo.heads()
356
356
357 def known(self, nodes):
357 def known(self, nodes):
358 return self._repo.known(nodes)
358 return self._repo.known(nodes)
359
359
360 def listkeys(self, namespace):
360 def listkeys(self, namespace):
361 return self._repo.listkeys(namespace)
361 return self._repo.listkeys(namespace)
362
362
363 def lookup(self, key):
363 def lookup(self, key):
364 return self._repo.lookup(key)
364 return self._repo.lookup(key)
365
365
366 def pushkey(self, namespace, key, old, new):
366 def pushkey(self, namespace, key, old, new):
367 return self._repo.pushkey(namespace, key, old, new)
367 return self._repo.pushkey(namespace, key, old, new)
368
368
369 def stream_out(self):
369 def stream_out(self):
370 raise error.Abort(_(b'cannot perform stream clone against local peer'))
370 raise error.Abort(_(b'cannot perform stream clone against local peer'))
371
371
372 def unbundle(self, bundle, heads, url):
372 def unbundle(self, bundle, heads, url):
373 """apply a bundle on a repo
373 """apply a bundle on a repo
374
374
375 This function handles the repo locking itself."""
375 This function handles the repo locking itself."""
376 try:
376 try:
377 try:
377 try:
378 bundle = exchange.readbundle(self.ui, bundle, None)
378 bundle = exchange.readbundle(self.ui, bundle, None)
379 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
379 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
380 if util.safehasattr(ret, b'getchunks'):
380 if util.safehasattr(ret, b'getchunks'):
381 # This is a bundle20 object, turn it into an unbundler.
381 # This is a bundle20 object, turn it into an unbundler.
382 # This little dance should be dropped eventually when the
382 # This little dance should be dropped eventually when the
383 # API is finally improved.
383 # API is finally improved.
384 stream = util.chunkbuffer(ret.getchunks())
384 stream = util.chunkbuffer(ret.getchunks())
385 ret = bundle2.getunbundler(self.ui, stream)
385 ret = bundle2.getunbundler(self.ui, stream)
386 return ret
386 return ret
387 except Exception as exc:
387 except Exception as exc:
388 # If the exception contains output salvaged from a bundle2
388 # If the exception contains output salvaged from a bundle2
389 # reply, we need to make sure it is printed before continuing
389 # reply, we need to make sure it is printed before continuing
390 # to fail. So we build a bundle2 with such output and consume
390 # to fail. So we build a bundle2 with such output and consume
391 # it directly.
391 # it directly.
392 #
392 #
393 # This is not very elegant but allows a "simple" solution for
393 # This is not very elegant but allows a "simple" solution for
394 # issue4594
394 # issue4594
395 output = getattr(exc, '_bundle2salvagedoutput', ())
395 output = getattr(exc, '_bundle2salvagedoutput', ())
396 if output:
396 if output:
397 bundler = bundle2.bundle20(self._repo.ui)
397 bundler = bundle2.bundle20(self._repo.ui)
398 for out in output:
398 for out in output:
399 bundler.addpart(out)
399 bundler.addpart(out)
400 stream = util.chunkbuffer(bundler.getchunks())
400 stream = util.chunkbuffer(bundler.getchunks())
401 b = bundle2.getunbundler(self.ui, stream)
401 b = bundle2.getunbundler(self.ui, stream)
402 bundle2.processbundle(self._repo, b)
402 bundle2.processbundle(self._repo, b)
403 raise
403 raise
404 except error.PushRaced as exc:
404 except error.PushRaced as exc:
405 raise error.ResponseError(
405 raise error.ResponseError(
406 _(b'push failed:'), stringutil.forcebytestr(exc)
406 _(b'push failed:'), stringutil.forcebytestr(exc)
407 )
407 )
408
408
409 # End of _basewirecommands interface.
409 # End of _basewirecommands interface.
410
410
411 # Begin of peer interface.
411 # Begin of peer interface.
412
412
413 def commandexecutor(self):
413 def commandexecutor(self):
414 return localcommandexecutor(self)
414 return localcommandexecutor(self)
415
415
416 # End of peer interface.
416 # End of peer interface.
417
417
418
418
419 @interfaceutil.implementer(repository.ipeerlegacycommands)
419 @interfaceutil.implementer(repository.ipeerlegacycommands)
420 class locallegacypeer(localpeer):
420 class locallegacypeer(localpeer):
421 """peer extension which implements legacy methods too; used for tests with
421 """peer extension which implements legacy methods too; used for tests with
422 restricted capabilities"""
422 restricted capabilities"""
423
423
424 def __init__(self, repo):
424 def __init__(self, repo):
425 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
425 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
426
426
427 # Begin of baselegacywirecommands interface.
427 # Begin of baselegacywirecommands interface.
428
428
429 def between(self, pairs):
429 def between(self, pairs):
430 return self._repo.between(pairs)
430 return self._repo.between(pairs)
431
431
432 def branches(self, nodes):
432 def branches(self, nodes):
433 return self._repo.branches(nodes)
433 return self._repo.branches(nodes)
434
434
435 def changegroup(self, nodes, source):
435 def changegroup(self, nodes, source):
436 outgoing = discovery.outgoing(
436 outgoing = discovery.outgoing(
437 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
437 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
438 )
438 )
439 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
439 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
440
440
441 def changegroupsubset(self, bases, heads, source):
441 def changegroupsubset(self, bases, heads, source):
442 outgoing = discovery.outgoing(
442 outgoing = discovery.outgoing(
443 self._repo, missingroots=bases, ancestorsof=heads
443 self._repo, missingroots=bases, ancestorsof=heads
444 )
444 )
445 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
445 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
446
446
447 # End of baselegacywirecommands interface.
447 # End of baselegacywirecommands interface.
448
448
449
449
450 # Functions receiving (ui, features) that extensions can register to impact
450 # Functions receiving (ui, features) that extensions can register to impact
451 # the ability to load repositories with custom requirements. Only
451 # the ability to load repositories with custom requirements. Only
452 # functions defined in loaded extensions are called.
452 # functions defined in loaded extensions are called.
453 #
453 #
454 # The function receives a set of requirement strings that the repository
454 # The function receives a set of requirement strings that the repository
455 # is capable of opening. Functions will typically add elements to the
455 # is capable of opening. Functions will typically add elements to the
456 # set to reflect that the extension knows how to handle that requirements.
456 # set to reflect that the extension knows how to handle that requirements.
457 featuresetupfuncs = set()
457 featuresetupfuncs = set()
458
458
459
459
460 def _getsharedvfs(hgvfs, requirements):
460 def _getsharedvfs(hgvfs, requirements):
461 """returns the vfs object pointing to root of shared source
461 """returns the vfs object pointing to root of shared source
462 repo for a shared repository
462 repo for a shared repository
463
463
464 hgvfs is vfs pointing at .hg/ of current repo (shared one)
464 hgvfs is vfs pointing at .hg/ of current repo (shared one)
465 requirements is a set of requirements of current repo (shared one)
465 requirements is a set of requirements of current repo (shared one)
466 """
466 """
467 # The ``shared`` or ``relshared`` requirements indicate the
467 # The ``shared`` or ``relshared`` requirements indicate the
468 # store lives in the path contained in the ``.hg/sharedpath`` file.
468 # store lives in the path contained in the ``.hg/sharedpath`` file.
469 # This is an absolute path for ``shared`` and relative to
469 # This is an absolute path for ``shared`` and relative to
470 # ``.hg/`` for ``relshared``.
470 # ``.hg/`` for ``relshared``.
471 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
471 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
472 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
472 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
473 sharedpath = util.normpath(hgvfs.join(sharedpath))
473 sharedpath = util.normpath(hgvfs.join(sharedpath))
474
474
475 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
475 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
476
476
477 if not sharedvfs.exists():
477 if not sharedvfs.exists():
478 raise error.RepoError(
478 raise error.RepoError(
479 _(b'.hg/sharedpath points to nonexistent directory %s')
479 _(b'.hg/sharedpath points to nonexistent directory %s')
480 % sharedvfs.base
480 % sharedvfs.base
481 )
481 )
482 return sharedvfs
482 return sharedvfs
483
483
484
484
485 def _readrequires(vfs, allowmissing):
485 def _readrequires(vfs, allowmissing):
486 """reads the require file present at root of this vfs
486 """reads the require file present at root of this vfs
487 and return a set of requirements
487 and return a set of requirements
488
488
489 If allowmissing is True, we suppress ENOENT if raised"""
489 If allowmissing is True, we suppress ENOENT if raised"""
490 # requires file contains a newline-delimited list of
490 # requires file contains a newline-delimited list of
491 # features/capabilities the opener (us) must have in order to use
491 # features/capabilities the opener (us) must have in order to use
492 # the repository. This file was introduced in Mercurial 0.9.2,
492 # the repository. This file was introduced in Mercurial 0.9.2,
493 # which means very old repositories may not have one. We assume
493 # which means very old repositories may not have one. We assume
494 # a missing file translates to no requirements.
494 # a missing file translates to no requirements.
495 try:
495 try:
496 requirements = set(vfs.read(b'requires').splitlines())
496 requirements = set(vfs.read(b'requires').splitlines())
497 except IOError as e:
497 except IOError as e:
498 if not (allowmissing and e.errno == errno.ENOENT):
498 if not (allowmissing and e.errno == errno.ENOENT):
499 raise
499 raise
500 requirements = set()
500 requirements = set()
501 return requirements
501 return requirements
502
502
503
503
504 def makelocalrepository(baseui, path, intents=None):
504 def makelocalrepository(baseui, path, intents=None):
505 """Create a local repository object.
505 """Create a local repository object.
506
506
507 Given arguments needed to construct a local repository, this function
507 Given arguments needed to construct a local repository, this function
508 performs various early repository loading functionality (such as
508 performs various early repository loading functionality (such as
509 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
509 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
510 the repository can be opened, derives a type suitable for representing
510 the repository can be opened, derives a type suitable for representing
511 that repository, and returns an instance of it.
511 that repository, and returns an instance of it.
512
512
513 The returned object conforms to the ``repository.completelocalrepository``
513 The returned object conforms to the ``repository.completelocalrepository``
514 interface.
514 interface.
515
515
516 The repository type is derived by calling a series of factory functions
516 The repository type is derived by calling a series of factory functions
517 for each aspect/interface of the final repository. These are defined by
517 for each aspect/interface of the final repository. These are defined by
518 ``REPO_INTERFACES``.
518 ``REPO_INTERFACES``.
519
519
520 Each factory function is called to produce a type implementing a specific
520 Each factory function is called to produce a type implementing a specific
521 interface. The cumulative list of returned types will be combined into a
521 interface. The cumulative list of returned types will be combined into a
522 new type and that type will be instantiated to represent the local
522 new type and that type will be instantiated to represent the local
523 repository.
523 repository.
524
524
525 The factory functions each receive various state that may be consulted
525 The factory functions each receive various state that may be consulted
526 as part of deriving a type.
526 as part of deriving a type.
527
527
528 Extensions should wrap these factory functions to customize repository type
528 Extensions should wrap these factory functions to customize repository type
529 creation. Note that an extension's wrapped function may be called even if
529 creation. Note that an extension's wrapped function may be called even if
530 that extension is not loaded for the repo being constructed. Extensions
530 that extension is not loaded for the repo being constructed. Extensions
531 should check if their ``__name__`` appears in the
531 should check if their ``__name__`` appears in the
532 ``extensionmodulenames`` set passed to the factory function and no-op if
532 ``extensionmodulenames`` set passed to the factory function and no-op if
533 not.
533 not.
534 """
534 """
535 ui = baseui.copy()
535 ui = baseui.copy()
536 # Prevent copying repo configuration.
536 # Prevent copying repo configuration.
537 ui.copy = baseui.copy
537 ui.copy = baseui.copy
538
538
539 # Working directory VFS rooted at repository root.
539 # Working directory VFS rooted at repository root.
540 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
540 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
541
541
542 # Main VFS for .hg/ directory.
542 # Main VFS for .hg/ directory.
543 hgpath = wdirvfs.join(b'.hg')
543 hgpath = wdirvfs.join(b'.hg')
544 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
544 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
545 # Whether this repository is shared one or not
545 # Whether this repository is shared one or not
546 shared = False
546 shared = False
547 # If this repository is shared, vfs pointing to shared repo
547 # If this repository is shared, vfs pointing to shared repo
548 sharedvfs = None
548 sharedvfs = None
549
549
550 # The .hg/ path should exist and should be a directory. All other
550 # The .hg/ path should exist and should be a directory. All other
551 # cases are errors.
551 # cases are errors.
552 if not hgvfs.isdir():
552 if not hgvfs.isdir():
553 try:
553 try:
554 hgvfs.stat()
554 hgvfs.stat()
555 except OSError as e:
555 except OSError as e:
556 if e.errno != errno.ENOENT:
556 if e.errno != errno.ENOENT:
557 raise
557 raise
558 except ValueError as e:
558 except ValueError as e:
559 # Can be raised on Python 3.8 when path is invalid.
559 # Can be raised on Python 3.8 when path is invalid.
560 raise error.Abort(
560 raise error.Abort(
561 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
561 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
562 )
562 )
563
563
564 raise error.RepoError(_(b'repository %s not found') % path)
564 raise error.RepoError(_(b'repository %s not found') % path)
565
565
566 requirements = _readrequires(hgvfs, True)
566 requirements = _readrequires(hgvfs, True)
567 shared = (
567 shared = (
568 requirementsmod.SHARED_REQUIREMENT in requirements
568 requirementsmod.SHARED_REQUIREMENT in requirements
569 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
569 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
570 )
570 )
571 storevfs = None
571 storevfs = None
572 if shared:
572 if shared:
573 # This is a shared repo
573 # This is a shared repo
574 sharedvfs = _getsharedvfs(hgvfs, requirements)
574 sharedvfs = _getsharedvfs(hgvfs, requirements)
575 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
575 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
576 else:
576 else:
577 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
577 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
578
578
579 # if .hg/requires contains the sharesafe requirement, it means
579 # if .hg/requires contains the sharesafe requirement, it means
580 # there exists a `.hg/store/requires` too and we should read it
580 # there exists a `.hg/store/requires` too and we should read it
581 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
581 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
582 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
582 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
583 # is not present, refer checkrequirementscompat() for that
583 # is not present, refer checkrequirementscompat() for that
584 #
584 #
585 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
585 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
586 # repository was shared the old way. We check the share source .hg/requires
586 # repository was shared the old way. We check the share source .hg/requires
587 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
587 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
588 # to be reshared
588 # to be reshared
589 hint = _(b"see `hg help config.format.use-share-safe` for more information")
589 hint = _(b"see `hg help config.format.use-share-safe` for more information")
590 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
590 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
591
591
592 if (
592 if (
593 shared
593 shared
594 and requirementsmod.SHARESAFE_REQUIREMENT
594 and requirementsmod.SHARESAFE_REQUIREMENT
595 not in _readrequires(sharedvfs, True)
595 not in _readrequires(sharedvfs, True)
596 ):
596 ):
597 mismatch_warn = ui.configbool(
597 mismatch_warn = ui.configbool(
598 b'share', b'safe-mismatch.source-not-safe.warn'
598 b'share', b'safe-mismatch.source-not-safe.warn'
599 )
599 )
600 mismatch_config = ui.config(
600 mismatch_config = ui.config(
601 b'share', b'safe-mismatch.source-not-safe'
601 b'share', b'safe-mismatch.source-not-safe'
602 )
602 )
603 if mismatch_config in (
603 if mismatch_config in (
604 b'downgrade-allow',
604 b'downgrade-allow',
605 b'allow',
605 b'allow',
606 b'downgrade-abort',
606 b'downgrade-abort',
607 ):
607 ):
608 # prevent cyclic import localrepo -> upgrade -> localrepo
608 # prevent cyclic import localrepo -> upgrade -> localrepo
609 from . import upgrade
609 from . import upgrade
610
610
611 upgrade.downgrade_share_to_non_safe(
611 upgrade.downgrade_share_to_non_safe(
612 ui,
612 ui,
613 hgvfs,
613 hgvfs,
614 sharedvfs,
614 sharedvfs,
615 requirements,
615 requirements,
616 mismatch_config,
616 mismatch_config,
617 mismatch_warn,
617 mismatch_warn,
618 )
618 )
619 elif mismatch_config == b'abort':
619 elif mismatch_config == b'abort':
620 raise error.Abort(
620 raise error.Abort(
621 _(b"share source does not support share-safe requirement"),
621 _(b"share source does not support share-safe requirement"),
622 hint=hint,
622 hint=hint,
623 )
623 )
624 else:
624 else:
625 raise error.Abort(
625 raise error.Abort(
626 _(
626 _(
627 b"share-safe mismatch with source.\nUnrecognized"
627 b"share-safe mismatch with source.\nUnrecognized"
628 b" value '%s' of `share.safe-mismatch.source-not-safe`"
628 b" value '%s' of `share.safe-mismatch.source-not-safe`"
629 b" set."
629 b" set."
630 )
630 )
631 % mismatch_config,
631 % mismatch_config,
632 hint=hint,
632 hint=hint,
633 )
633 )
634 else:
634 else:
635 requirements |= _readrequires(storevfs, False)
635 requirements |= _readrequires(storevfs, False)
636 elif shared:
636 elif shared:
637 sourcerequires = _readrequires(sharedvfs, False)
637 sourcerequires = _readrequires(sharedvfs, False)
638 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
638 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
639 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
639 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
640 mismatch_warn = ui.configbool(
640 mismatch_warn = ui.configbool(
641 b'share', b'safe-mismatch.source-safe.warn'
641 b'share', b'safe-mismatch.source-safe.warn'
642 )
642 )
643 if mismatch_config in (
643 if mismatch_config in (
644 b'upgrade-allow',
644 b'upgrade-allow',
645 b'allow',
645 b'allow',
646 b'upgrade-abort',
646 b'upgrade-abort',
647 ):
647 ):
648 # prevent cyclic import localrepo -> upgrade -> localrepo
648 # prevent cyclic import localrepo -> upgrade -> localrepo
649 from . import upgrade
649 from . import upgrade
650
650
651 upgrade.upgrade_share_to_safe(
651 upgrade.upgrade_share_to_safe(
652 ui,
652 ui,
653 hgvfs,
653 hgvfs,
654 storevfs,
654 storevfs,
655 requirements,
655 requirements,
656 mismatch_config,
656 mismatch_config,
657 mismatch_warn,
657 mismatch_warn,
658 )
658 )
659 elif mismatch_config == b'abort':
659 elif mismatch_config == b'abort':
660 raise error.Abort(
660 raise error.Abort(
661 _(
661 _(
662 b'version mismatch: source uses share-safe'
662 b'version mismatch: source uses share-safe'
663 b' functionality while the current share does not'
663 b' functionality while the current share does not'
664 ),
664 ),
665 hint=hint,
665 hint=hint,
666 )
666 )
667 else:
667 else:
668 raise error.Abort(
668 raise error.Abort(
669 _(
669 _(
670 b"share-safe mismatch with source.\nUnrecognized"
670 b"share-safe mismatch with source.\nUnrecognized"
671 b" value '%s' of `share.safe-mismatch.source-safe` set."
671 b" value '%s' of `share.safe-mismatch.source-safe` set."
672 )
672 )
673 % mismatch_config,
673 % mismatch_config,
674 hint=hint,
674 hint=hint,
675 )
675 )
676
676
677 # The .hg/hgrc file may load extensions or contain config options
677 # The .hg/hgrc file may load extensions or contain config options
678 # that influence repository construction. Attempt to load it and
678 # that influence repository construction. Attempt to load it and
679 # process any new extensions that it may have pulled in.
679 # process any new extensions that it may have pulled in.
680 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
680 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
681 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
681 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
682 extensions.loadall(ui)
682 extensions.loadall(ui)
683 extensions.populateui(ui)
683 extensions.populateui(ui)
684
684
685 # Set of module names of extensions loaded for this repository.
685 # Set of module names of extensions loaded for this repository.
686 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
686 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
687
687
688 supportedrequirements = gathersupportedrequirements(ui)
688 supportedrequirements = gathersupportedrequirements(ui)
689
689
690 # We first validate the requirements are known.
690 # We first validate the requirements are known.
691 ensurerequirementsrecognized(requirements, supportedrequirements)
691 ensurerequirementsrecognized(requirements, supportedrequirements)
692
692
693 # Then we validate that the known set is reasonable to use together.
693 # Then we validate that the known set is reasonable to use together.
694 ensurerequirementscompatible(ui, requirements)
694 ensurerequirementscompatible(ui, requirements)
695
695
696 # TODO there are unhandled edge cases related to opening repositories with
696 # TODO there are unhandled edge cases related to opening repositories with
697 # shared storage. If storage is shared, we should also test for requirements
697 # shared storage. If storage is shared, we should also test for requirements
698 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
698 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
699 # that repo, as that repo may load extensions needed to open it. This is a
699 # that repo, as that repo may load extensions needed to open it. This is a
700 # bit complicated because we don't want the other hgrc to overwrite settings
700 # bit complicated because we don't want the other hgrc to overwrite settings
701 # in this hgrc.
701 # in this hgrc.
702 #
702 #
703 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
703 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
704 # file when sharing repos. But if a requirement is added after the share is
704 # file when sharing repos. But if a requirement is added after the share is
705 # performed, thereby introducing a new requirement for the opener, we may
705 # performed, thereby introducing a new requirement for the opener, we may
706 # will not see that and could encounter a run-time error interacting with
706 # will not see that and could encounter a run-time error interacting with
707 # that shared store since it has an unknown-to-us requirement.
707 # that shared store since it has an unknown-to-us requirement.
708
708
709 # At this point, we know we should be capable of opening the repository.
709 # At this point, we know we should be capable of opening the repository.
710 # Now get on with doing that.
710 # Now get on with doing that.
711
711
712 features = set()
712 features = set()
713
713
714 # The "store" part of the repository holds versioned data. How it is
714 # The "store" part of the repository holds versioned data. How it is
715 # accessed is determined by various requirements. If `shared` or
715 # accessed is determined by various requirements. If `shared` or
716 # `relshared` requirements are present, this indicates current repository
716 # `relshared` requirements are present, this indicates current repository
717 # is a share and store exists in path mentioned in `.hg/sharedpath`
717 # is a share and store exists in path mentioned in `.hg/sharedpath`
718 if shared:
718 if shared:
719 storebasepath = sharedvfs.base
719 storebasepath = sharedvfs.base
720 cachepath = sharedvfs.join(b'cache')
720 cachepath = sharedvfs.join(b'cache')
721 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
721 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
722 else:
722 else:
723 storebasepath = hgvfs.base
723 storebasepath = hgvfs.base
724 cachepath = hgvfs.join(b'cache')
724 cachepath = hgvfs.join(b'cache')
725 wcachepath = hgvfs.join(b'wcache')
725 wcachepath = hgvfs.join(b'wcache')
726
726
727 # The store has changed over time and the exact layout is dictated by
727 # The store has changed over time and the exact layout is dictated by
728 # requirements. The store interface abstracts differences across all
728 # requirements. The store interface abstracts differences across all
729 # of them.
729 # of them.
730 store = makestore(
730 store = makestore(
731 requirements,
731 requirements,
732 storebasepath,
732 storebasepath,
733 lambda base: vfsmod.vfs(base, cacheaudited=True),
733 lambda base: vfsmod.vfs(base, cacheaudited=True),
734 )
734 )
735 hgvfs.createmode = store.createmode
735 hgvfs.createmode = store.createmode
736
736
737 storevfs = store.vfs
737 storevfs = store.vfs
738 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
738 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
739
739
740 if (
740 if (
741 requirementsmod.REVLOGV2_REQUIREMENT in requirements
741 requirementsmod.REVLOGV2_REQUIREMENT in requirements
742 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
742 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
743 ):
743 ):
744 features.add(repository.REPO_FEATURE_SIDE_DATA)
744 features.add(repository.REPO_FEATURE_SIDE_DATA)
745 # the revlogv2 docket introduced race condition that we need to fix
745 # the revlogv2 docket introduced race condition that we need to fix
746 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
746 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
747
747
748 # The cache vfs is used to manage cache files.
748 # The cache vfs is used to manage cache files.
749 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
749 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
750 cachevfs.createmode = store.createmode
750 cachevfs.createmode = store.createmode
751 # The cache vfs is used to manage cache files related to the working copy
751 # The cache vfs is used to manage cache files related to the working copy
752 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
752 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
753 wcachevfs.createmode = store.createmode
753 wcachevfs.createmode = store.createmode
754
754
755 # Now resolve the type for the repository object. We do this by repeatedly
755 # Now resolve the type for the repository object. We do this by repeatedly
756 # calling a factory function to produces types for specific aspects of the
756 # calling a factory function to produces types for specific aspects of the
757 # repo's operation. The aggregate returned types are used as base classes
757 # repo's operation. The aggregate returned types are used as base classes
758 # for a dynamically-derived type, which will represent our new repository.
758 # for a dynamically-derived type, which will represent our new repository.
759
759
760 bases = []
760 bases = []
761 extrastate = {}
761 extrastate = {}
762
762
763 for iface, fn in REPO_INTERFACES:
763 for iface, fn in REPO_INTERFACES:
764 # We pass all potentially useful state to give extensions tons of
764 # We pass all potentially useful state to give extensions tons of
765 # flexibility.
765 # flexibility.
766 typ = fn()(
766 typ = fn()(
767 ui=ui,
767 ui=ui,
768 intents=intents,
768 intents=intents,
769 requirements=requirements,
769 requirements=requirements,
770 features=features,
770 features=features,
771 wdirvfs=wdirvfs,
771 wdirvfs=wdirvfs,
772 hgvfs=hgvfs,
772 hgvfs=hgvfs,
773 store=store,
773 store=store,
774 storevfs=storevfs,
774 storevfs=storevfs,
775 storeoptions=storevfs.options,
775 storeoptions=storevfs.options,
776 cachevfs=cachevfs,
776 cachevfs=cachevfs,
777 wcachevfs=wcachevfs,
777 wcachevfs=wcachevfs,
778 extensionmodulenames=extensionmodulenames,
778 extensionmodulenames=extensionmodulenames,
779 extrastate=extrastate,
779 extrastate=extrastate,
780 baseclasses=bases,
780 baseclasses=bases,
781 )
781 )
782
782
783 if not isinstance(typ, type):
783 if not isinstance(typ, type):
784 raise error.ProgrammingError(
784 raise error.ProgrammingError(
785 b'unable to construct type for %s' % iface
785 b'unable to construct type for %s' % iface
786 )
786 )
787
787
788 bases.append(typ)
788 bases.append(typ)
789
789
790 # type() allows you to use characters in type names that wouldn't be
790 # type() allows you to use characters in type names that wouldn't be
791 # recognized as Python symbols in source code. We abuse that to add
791 # recognized as Python symbols in source code. We abuse that to add
792 # rich information about our constructed repo.
792 # rich information about our constructed repo.
793 name = pycompat.sysstr(
793 name = pycompat.sysstr(
794 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
794 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
795 )
795 )
796
796
797 cls = type(name, tuple(bases), {})
797 cls = type(name, tuple(bases), {})
798
798
799 return cls(
799 return cls(
800 baseui=baseui,
800 baseui=baseui,
801 ui=ui,
801 ui=ui,
802 origroot=path,
802 origroot=path,
803 wdirvfs=wdirvfs,
803 wdirvfs=wdirvfs,
804 hgvfs=hgvfs,
804 hgvfs=hgvfs,
805 requirements=requirements,
805 requirements=requirements,
806 supportedrequirements=supportedrequirements,
806 supportedrequirements=supportedrequirements,
807 sharedpath=storebasepath,
807 sharedpath=storebasepath,
808 store=store,
808 store=store,
809 cachevfs=cachevfs,
809 cachevfs=cachevfs,
810 wcachevfs=wcachevfs,
810 wcachevfs=wcachevfs,
811 features=features,
811 features=features,
812 intents=intents,
812 intents=intents,
813 )
813 )
814
814
815
815
816 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
816 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
817 """Load hgrc files/content into a ui instance.
817 """Load hgrc files/content into a ui instance.
818
818
819 This is called during repository opening to load any additional
819 This is called during repository opening to load any additional
820 config files or settings relevant to the current repository.
820 config files or settings relevant to the current repository.
821
821
822 Returns a bool indicating whether any additional configs were loaded.
822 Returns a bool indicating whether any additional configs were loaded.
823
823
824 Extensions should monkeypatch this function to modify how per-repo
824 Extensions should monkeypatch this function to modify how per-repo
825 configs are loaded. For example, an extension may wish to pull in
825 configs are loaded. For example, an extension may wish to pull in
826 configs from alternate files or sources.
826 configs from alternate files or sources.
827
827
828 sharedvfs is vfs object pointing to source repo if the current one is a
828 sharedvfs is vfs object pointing to source repo if the current one is a
829 shared one
829 shared one
830 """
830 """
831 if not rcutil.use_repo_hgrc():
831 if not rcutil.use_repo_hgrc():
832 return False
832 return False
833
833
834 ret = False
834 ret = False
835 # first load config from shared source if we has to
835 # first load config from shared source if we has to
836 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
836 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
837 try:
837 try:
838 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
838 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
839 ret = True
839 ret = True
840 except IOError:
840 except IOError:
841 pass
841 pass
842
842
843 try:
843 try:
844 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
844 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
845 ret = True
845 ret = True
846 except IOError:
846 except IOError:
847 pass
847 pass
848
848
849 try:
849 try:
850 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
850 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
851 ret = True
851 ret = True
852 except IOError:
852 except IOError:
853 pass
853 pass
854
854
855 return ret
855 return ret
856
856
857
857
858 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
858 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
859 """Perform additional actions after .hg/hgrc is loaded.
859 """Perform additional actions after .hg/hgrc is loaded.
860
860
861 This function is called during repository loading immediately after
861 This function is called during repository loading immediately after
862 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
862 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
863
863
864 The function can be used to validate configs, automatically add
864 The function can be used to validate configs, automatically add
865 options (including extensions) based on requirements, etc.
865 options (including extensions) based on requirements, etc.
866 """
866 """
867
867
868 # Map of requirements to list of extensions to load automatically when
868 # Map of requirements to list of extensions to load automatically when
869 # requirement is present.
869 # requirement is present.
870 autoextensions = {
870 autoextensions = {
871 b'git': [b'git'],
871 b'git': [b'git'],
872 b'largefiles': [b'largefiles'],
872 b'largefiles': [b'largefiles'],
873 b'lfs': [b'lfs'],
873 b'lfs': [b'lfs'],
874 }
874 }
875
875
876 for requirement, names in sorted(autoextensions.items()):
876 for requirement, names in sorted(autoextensions.items()):
877 if requirement not in requirements:
877 if requirement not in requirements:
878 continue
878 continue
879
879
880 for name in names:
880 for name in names:
881 if not ui.hasconfig(b'extensions', name):
881 if not ui.hasconfig(b'extensions', name):
882 ui.setconfig(b'extensions', name, b'', source=b'autoload')
882 ui.setconfig(b'extensions', name, b'', source=b'autoload')
883
883
884
884
885 def gathersupportedrequirements(ui):
885 def gathersupportedrequirements(ui):
886 """Determine the complete set of recognized requirements."""
886 """Determine the complete set of recognized requirements."""
887 # Start with all requirements supported by this file.
887 # Start with all requirements supported by this file.
888 supported = set(localrepository._basesupported)
888 supported = set(localrepository._basesupported)
889
889
890 if dirstate.SUPPORTS_DIRSTATE_V2:
890 if dirstate.SUPPORTS_DIRSTATE_V2:
891 supported.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
891 supported.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
892
892
893 # Execute ``featuresetupfuncs`` entries if they belong to an extension
893 # Execute ``featuresetupfuncs`` entries if they belong to an extension
894 # relevant to this ui instance.
894 # relevant to this ui instance.
895 modules = {m.__name__ for n, m in extensions.extensions(ui)}
895 modules = {m.__name__ for n, m in extensions.extensions(ui)}
896
896
897 for fn in featuresetupfuncs:
897 for fn in featuresetupfuncs:
898 if fn.__module__ in modules:
898 if fn.__module__ in modules:
899 fn(ui, supported)
899 fn(ui, supported)
900
900
901 # Add derived requirements from registered compression engines.
901 # Add derived requirements from registered compression engines.
902 for name in util.compengines:
902 for name in util.compengines:
903 engine = util.compengines[name]
903 engine = util.compengines[name]
904 if engine.available() and engine.revlogheader():
904 if engine.available() and engine.revlogheader():
905 supported.add(b'exp-compression-%s' % name)
905 supported.add(b'exp-compression-%s' % name)
906 if engine.name() == b'zstd':
906 if engine.name() == b'zstd':
907 supported.add(b'revlog-compression-zstd')
907 supported.add(b'revlog-compression-zstd')
908
908
909 return supported
909 return supported
910
910
911
911
912 def ensurerequirementsrecognized(requirements, supported):
912 def ensurerequirementsrecognized(requirements, supported):
913 """Validate that a set of local requirements is recognized.
913 """Validate that a set of local requirements is recognized.
914
914
915 Receives a set of requirements. Raises an ``error.RepoError`` if there
915 Receives a set of requirements. Raises an ``error.RepoError`` if there
916 exists any requirement in that set that currently loaded code doesn't
916 exists any requirement in that set that currently loaded code doesn't
917 recognize.
917 recognize.
918
918
919 Returns a set of supported requirements.
919 Returns a set of supported requirements.
920 """
920 """
921 missing = set()
921 missing = set()
922
922
923 for requirement in requirements:
923 for requirement in requirements:
924 if requirement in supported:
924 if requirement in supported:
925 continue
925 continue
926
926
927 if not requirement or not requirement[0:1].isalnum():
927 if not requirement or not requirement[0:1].isalnum():
928 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
928 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
929
929
930 missing.add(requirement)
930 missing.add(requirement)
931
931
932 if missing:
932 if missing:
933 raise error.RequirementError(
933 raise error.RequirementError(
934 _(b'repository requires features unknown to this Mercurial: %s')
934 _(b'repository requires features unknown to this Mercurial: %s')
935 % b' '.join(sorted(missing)),
935 % b' '.join(sorted(missing)),
936 hint=_(
936 hint=_(
937 b'see https://mercurial-scm.org/wiki/MissingRequirement '
937 b'see https://mercurial-scm.org/wiki/MissingRequirement '
938 b'for more information'
938 b'for more information'
939 ),
939 ),
940 )
940 )
941
941
942
942
943 def ensurerequirementscompatible(ui, requirements):
943 def ensurerequirementscompatible(ui, requirements):
944 """Validates that a set of recognized requirements is mutually compatible.
944 """Validates that a set of recognized requirements is mutually compatible.
945
945
946 Some requirements may not be compatible with others or require
946 Some requirements may not be compatible with others or require
947 config options that aren't enabled. This function is called during
947 config options that aren't enabled. This function is called during
948 repository opening to ensure that the set of requirements needed
948 repository opening to ensure that the set of requirements needed
949 to open a repository is sane and compatible with config options.
949 to open a repository is sane and compatible with config options.
950
950
951 Extensions can monkeypatch this function to perform additional
951 Extensions can monkeypatch this function to perform additional
952 checking.
952 checking.
953
953
954 ``error.RepoError`` should be raised on failure.
954 ``error.RepoError`` should be raised on failure.
955 """
955 """
956 if (
956 if (
957 requirementsmod.SPARSE_REQUIREMENT in requirements
957 requirementsmod.SPARSE_REQUIREMENT in requirements
958 and not sparse.enabled
958 and not sparse.enabled
959 ):
959 ):
960 raise error.RepoError(
960 raise error.RepoError(
961 _(
961 _(
962 b'repository is using sparse feature but '
962 b'repository is using sparse feature but '
963 b'sparse is not enabled; enable the '
963 b'sparse is not enabled; enable the '
964 b'"sparse" extensions to access'
964 b'"sparse" extensions to access'
965 )
965 )
966 )
966 )
967
967
968
968
969 def makestore(requirements, path, vfstype):
969 def makestore(requirements, path, vfstype):
970 """Construct a storage object for a repository."""
970 """Construct a storage object for a repository."""
971 if requirementsmod.STORE_REQUIREMENT in requirements:
971 if requirementsmod.STORE_REQUIREMENT in requirements:
972 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
972 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
973 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
973 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
974 return storemod.fncachestore(path, vfstype, dotencode)
974 return storemod.fncachestore(path, vfstype, dotencode)
975
975
976 return storemod.encodedstore(path, vfstype)
976 return storemod.encodedstore(path, vfstype)
977
977
978 return storemod.basicstore(path, vfstype)
978 return storemod.basicstore(path, vfstype)
979
979
980
980
981 def resolvestorevfsoptions(ui, requirements, features):
981 def resolvestorevfsoptions(ui, requirements, features):
982 """Resolve the options to pass to the store vfs opener.
982 """Resolve the options to pass to the store vfs opener.
983
983
984 The returned dict is used to influence behavior of the storage layer.
984 The returned dict is used to influence behavior of the storage layer.
985 """
985 """
986 options = {}
986 options = {}
987
987
988 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
988 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
989 options[b'treemanifest'] = True
989 options[b'treemanifest'] = True
990
990
991 # experimental config: format.manifestcachesize
991 # experimental config: format.manifestcachesize
992 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
992 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
993 if manifestcachesize is not None:
993 if manifestcachesize is not None:
994 options[b'manifestcachesize'] = manifestcachesize
994 options[b'manifestcachesize'] = manifestcachesize
995
995
996 # In the absence of another requirement superseding a revlog-related
996 # In the absence of another requirement superseding a revlog-related
997 # requirement, we have to assume the repo is using revlog version 0.
997 # requirement, we have to assume the repo is using revlog version 0.
998 # This revlog format is super old and we don't bother trying to parse
998 # This revlog format is super old and we don't bother trying to parse
999 # opener options for it because those options wouldn't do anything
999 # opener options for it because those options wouldn't do anything
1000 # meaningful on such old repos.
1000 # meaningful on such old repos.
1001 if (
1001 if (
1002 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1002 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1003 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1003 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1004 ):
1004 ):
1005 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1005 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1006 else: # explicitly mark repo as using revlogv0
1006 else: # explicitly mark repo as using revlogv0
1007 options[b'revlogv0'] = True
1007 options[b'revlogv0'] = True
1008
1008
1009 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1009 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1010 options[b'copies-storage'] = b'changeset-sidedata'
1010 options[b'copies-storage'] = b'changeset-sidedata'
1011 else:
1011 else:
1012 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1012 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1013 copiesextramode = (b'changeset-only', b'compatibility')
1013 copiesextramode = (b'changeset-only', b'compatibility')
1014 if writecopiesto in copiesextramode:
1014 if writecopiesto in copiesextramode:
1015 options[b'copies-storage'] = b'extra'
1015 options[b'copies-storage'] = b'extra'
1016
1016
1017 return options
1017 return options
1018
1018
1019
1019
1020 def resolverevlogstorevfsoptions(ui, requirements, features):
1020 def resolverevlogstorevfsoptions(ui, requirements, features):
1021 """Resolve opener options specific to revlogs."""
1021 """Resolve opener options specific to revlogs."""
1022
1022
1023 options = {}
1023 options = {}
1024 options[b'flagprocessors'] = {}
1024 options[b'flagprocessors'] = {}
1025
1025
1026 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1026 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1027 options[b'revlogv1'] = True
1027 options[b'revlogv1'] = True
1028 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1028 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1029 options[b'revlogv2'] = True
1029 options[b'revlogv2'] = True
1030 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1030 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1031 options[b'changelogv2'] = True
1031 options[b'changelogv2'] = True
1032
1032
1033 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1033 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1034 options[b'generaldelta'] = True
1034 options[b'generaldelta'] = True
1035
1035
1036 # experimental config: format.chunkcachesize
1036 # experimental config: format.chunkcachesize
1037 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1037 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1038 if chunkcachesize is not None:
1038 if chunkcachesize is not None:
1039 options[b'chunkcachesize'] = chunkcachesize
1039 options[b'chunkcachesize'] = chunkcachesize
1040
1040
1041 deltabothparents = ui.configbool(
1041 deltabothparents = ui.configbool(
1042 b'storage', b'revlog.optimize-delta-parent-choice'
1042 b'storage', b'revlog.optimize-delta-parent-choice'
1043 )
1043 )
1044 options[b'deltabothparents'] = deltabothparents
1044 options[b'deltabothparents'] = deltabothparents
1045
1045
1046 issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming')
1047 options[b'issue6528.fix-incoming'] = issue6528
1048
1046 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1049 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1047 lazydeltabase = False
1050 lazydeltabase = False
1048 if lazydelta:
1051 if lazydelta:
1049 lazydeltabase = ui.configbool(
1052 lazydeltabase = ui.configbool(
1050 b'storage', b'revlog.reuse-external-delta-parent'
1053 b'storage', b'revlog.reuse-external-delta-parent'
1051 )
1054 )
1052 if lazydeltabase is None:
1055 if lazydeltabase is None:
1053 lazydeltabase = not scmutil.gddeltaconfig(ui)
1056 lazydeltabase = not scmutil.gddeltaconfig(ui)
1054 options[b'lazydelta'] = lazydelta
1057 options[b'lazydelta'] = lazydelta
1055 options[b'lazydeltabase'] = lazydeltabase
1058 options[b'lazydeltabase'] = lazydeltabase
1056
1059
1057 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1060 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1058 if 0 <= chainspan:
1061 if 0 <= chainspan:
1059 options[b'maxdeltachainspan'] = chainspan
1062 options[b'maxdeltachainspan'] = chainspan
1060
1063
1061 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1064 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1062 if mmapindexthreshold is not None:
1065 if mmapindexthreshold is not None:
1063 options[b'mmapindexthreshold'] = mmapindexthreshold
1066 options[b'mmapindexthreshold'] = mmapindexthreshold
1064
1067
1065 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1068 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1066 srdensitythres = float(
1069 srdensitythres = float(
1067 ui.config(b'experimental', b'sparse-read.density-threshold')
1070 ui.config(b'experimental', b'sparse-read.density-threshold')
1068 )
1071 )
1069 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1072 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1070 options[b'with-sparse-read'] = withsparseread
1073 options[b'with-sparse-read'] = withsparseread
1071 options[b'sparse-read-density-threshold'] = srdensitythres
1074 options[b'sparse-read-density-threshold'] = srdensitythres
1072 options[b'sparse-read-min-gap-size'] = srmingapsize
1075 options[b'sparse-read-min-gap-size'] = srmingapsize
1073
1076
1074 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1077 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1075 options[b'sparse-revlog'] = sparserevlog
1078 options[b'sparse-revlog'] = sparserevlog
1076 if sparserevlog:
1079 if sparserevlog:
1077 options[b'generaldelta'] = True
1080 options[b'generaldelta'] = True
1078
1081
1079 maxchainlen = None
1082 maxchainlen = None
1080 if sparserevlog:
1083 if sparserevlog:
1081 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1084 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1082 # experimental config: format.maxchainlen
1085 # experimental config: format.maxchainlen
1083 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1086 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1084 if maxchainlen is not None:
1087 if maxchainlen is not None:
1085 options[b'maxchainlen'] = maxchainlen
1088 options[b'maxchainlen'] = maxchainlen
1086
1089
1087 for r in requirements:
1090 for r in requirements:
1088 # we allow multiple compression engine requirement to co-exist because
1091 # we allow multiple compression engine requirement to co-exist because
1089 # strickly speaking, revlog seems to support mixed compression style.
1092 # strickly speaking, revlog seems to support mixed compression style.
1090 #
1093 #
1091 # The compression used for new entries will be "the last one"
1094 # The compression used for new entries will be "the last one"
1092 prefix = r.startswith
1095 prefix = r.startswith
1093 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1096 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1094 options[b'compengine'] = r.split(b'-', 2)[2]
1097 options[b'compengine'] = r.split(b'-', 2)[2]
1095
1098
1096 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1099 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1097 if options[b'zlib.level'] is not None:
1100 if options[b'zlib.level'] is not None:
1098 if not (0 <= options[b'zlib.level'] <= 9):
1101 if not (0 <= options[b'zlib.level'] <= 9):
1099 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1102 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1100 raise error.Abort(msg % options[b'zlib.level'])
1103 raise error.Abort(msg % options[b'zlib.level'])
1101 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1104 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1102 if options[b'zstd.level'] is not None:
1105 if options[b'zstd.level'] is not None:
1103 if not (0 <= options[b'zstd.level'] <= 22):
1106 if not (0 <= options[b'zstd.level'] <= 22):
1104 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1107 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1105 raise error.Abort(msg % options[b'zstd.level'])
1108 raise error.Abort(msg % options[b'zstd.level'])
1106
1109
1107 if requirementsmod.NARROW_REQUIREMENT in requirements:
1110 if requirementsmod.NARROW_REQUIREMENT in requirements:
1108 options[b'enableellipsis'] = True
1111 options[b'enableellipsis'] = True
1109
1112
1110 if ui.configbool(b'experimental', b'rust.index'):
1113 if ui.configbool(b'experimental', b'rust.index'):
1111 options[b'rust.index'] = True
1114 options[b'rust.index'] = True
1112 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1115 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1113 slow_path = ui.config(
1116 slow_path = ui.config(
1114 b'storage', b'revlog.persistent-nodemap.slow-path'
1117 b'storage', b'revlog.persistent-nodemap.slow-path'
1115 )
1118 )
1116 if slow_path not in (b'allow', b'warn', b'abort'):
1119 if slow_path not in (b'allow', b'warn', b'abort'):
1117 default = ui.config_default(
1120 default = ui.config_default(
1118 b'storage', b'revlog.persistent-nodemap.slow-path'
1121 b'storage', b'revlog.persistent-nodemap.slow-path'
1119 )
1122 )
1120 msg = _(
1123 msg = _(
1121 b'unknown value for config '
1124 b'unknown value for config '
1122 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1125 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1123 )
1126 )
1124 ui.warn(msg % slow_path)
1127 ui.warn(msg % slow_path)
1125 if not ui.quiet:
1128 if not ui.quiet:
1126 ui.warn(_(b'falling back to default value: %s\n') % default)
1129 ui.warn(_(b'falling back to default value: %s\n') % default)
1127 slow_path = default
1130 slow_path = default
1128
1131
1129 msg = _(
1132 msg = _(
1130 b"accessing `persistent-nodemap` repository without associated "
1133 b"accessing `persistent-nodemap` repository without associated "
1131 b"fast implementation."
1134 b"fast implementation."
1132 )
1135 )
1133 hint = _(
1136 hint = _(
1134 b"check `hg help config.format.use-persistent-nodemap` "
1137 b"check `hg help config.format.use-persistent-nodemap` "
1135 b"for details"
1138 b"for details"
1136 )
1139 )
1137 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1140 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1138 if slow_path == b'warn':
1141 if slow_path == b'warn':
1139 msg = b"warning: " + msg + b'\n'
1142 msg = b"warning: " + msg + b'\n'
1140 ui.warn(msg)
1143 ui.warn(msg)
1141 if not ui.quiet:
1144 if not ui.quiet:
1142 hint = b'(' + hint + b')\n'
1145 hint = b'(' + hint + b')\n'
1143 ui.warn(hint)
1146 ui.warn(hint)
1144 if slow_path == b'abort':
1147 if slow_path == b'abort':
1145 raise error.Abort(msg, hint=hint)
1148 raise error.Abort(msg, hint=hint)
1146 options[b'persistent-nodemap'] = True
1149 options[b'persistent-nodemap'] = True
1147 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1150 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1148 options[b'persistent-nodemap.mmap'] = True
1151 options[b'persistent-nodemap.mmap'] = True
1149 if ui.configbool(b'devel', b'persistent-nodemap'):
1152 if ui.configbool(b'devel', b'persistent-nodemap'):
1150 options[b'devel-force-nodemap'] = True
1153 options[b'devel-force-nodemap'] = True
1151
1154
1152 return options
1155 return options
1153
1156
1154
1157
1155 def makemain(**kwargs):
1158 def makemain(**kwargs):
1156 """Produce a type conforming to ``ilocalrepositorymain``."""
1159 """Produce a type conforming to ``ilocalrepositorymain``."""
1157 return localrepository
1160 return localrepository
1158
1161
1159
1162
1160 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1163 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1161 class revlogfilestorage(object):
1164 class revlogfilestorage(object):
1162 """File storage when using revlogs."""
1165 """File storage when using revlogs."""
1163
1166
1164 def file(self, path):
1167 def file(self, path):
1165 if path.startswith(b'/'):
1168 if path.startswith(b'/'):
1166 path = path[1:]
1169 path = path[1:]
1167
1170
1168 return filelog.filelog(self.svfs, path)
1171 return filelog.filelog(self.svfs, path)
1169
1172
1170
1173
1171 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1174 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1172 class revlognarrowfilestorage(object):
1175 class revlognarrowfilestorage(object):
1173 """File storage when using revlogs and narrow files."""
1176 """File storage when using revlogs and narrow files."""
1174
1177
1175 def file(self, path):
1178 def file(self, path):
1176 if path.startswith(b'/'):
1179 if path.startswith(b'/'):
1177 path = path[1:]
1180 path = path[1:]
1178
1181
1179 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1182 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1180
1183
1181
1184
1182 def makefilestorage(requirements, features, **kwargs):
1185 def makefilestorage(requirements, features, **kwargs):
1183 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1186 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1184 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1187 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1185 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1188 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1186
1189
1187 if requirementsmod.NARROW_REQUIREMENT in requirements:
1190 if requirementsmod.NARROW_REQUIREMENT in requirements:
1188 return revlognarrowfilestorage
1191 return revlognarrowfilestorage
1189 else:
1192 else:
1190 return revlogfilestorage
1193 return revlogfilestorage
1191
1194
1192
1195
1193 # List of repository interfaces and factory functions for them. Each
1196 # List of repository interfaces and factory functions for them. Each
1194 # will be called in order during ``makelocalrepository()`` to iteratively
1197 # will be called in order during ``makelocalrepository()`` to iteratively
1195 # derive the final type for a local repository instance. We capture the
1198 # derive the final type for a local repository instance. We capture the
1196 # function as a lambda so we don't hold a reference and the module-level
1199 # function as a lambda so we don't hold a reference and the module-level
1197 # functions can be wrapped.
1200 # functions can be wrapped.
1198 REPO_INTERFACES = [
1201 REPO_INTERFACES = [
1199 (repository.ilocalrepositorymain, lambda: makemain),
1202 (repository.ilocalrepositorymain, lambda: makemain),
1200 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1203 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1201 ]
1204 ]
1202
1205
1203
1206
1204 @interfaceutil.implementer(repository.ilocalrepositorymain)
1207 @interfaceutil.implementer(repository.ilocalrepositorymain)
1205 class localrepository(object):
1208 class localrepository(object):
1206 """Main class for representing local repositories.
1209 """Main class for representing local repositories.
1207
1210
1208 All local repositories are instances of this class.
1211 All local repositories are instances of this class.
1209
1212
1210 Constructed on its own, instances of this class are not usable as
1213 Constructed on its own, instances of this class are not usable as
1211 repository objects. To obtain a usable repository object, call
1214 repository objects. To obtain a usable repository object, call
1212 ``hg.repository()``, ``localrepo.instance()``, or
1215 ``hg.repository()``, ``localrepo.instance()``, or
1213 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1216 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1214 ``instance()`` adds support for creating new repositories.
1217 ``instance()`` adds support for creating new repositories.
1215 ``hg.repository()`` adds more extension integration, including calling
1218 ``hg.repository()`` adds more extension integration, including calling
1216 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1219 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1217 used.
1220 used.
1218 """
1221 """
1219
1222
1220 # obsolete experimental requirements:
1223 # obsolete experimental requirements:
1221 # - manifestv2: An experimental new manifest format that allowed
1224 # - manifestv2: An experimental new manifest format that allowed
1222 # for stem compression of long paths. Experiment ended up not
1225 # for stem compression of long paths. Experiment ended up not
1223 # being successful (repository sizes went up due to worse delta
1226 # being successful (repository sizes went up due to worse delta
1224 # chains), and the code was deleted in 4.6.
1227 # chains), and the code was deleted in 4.6.
1225 supportedformats = {
1228 supportedformats = {
1226 requirementsmod.REVLOGV1_REQUIREMENT,
1229 requirementsmod.REVLOGV1_REQUIREMENT,
1227 requirementsmod.GENERALDELTA_REQUIREMENT,
1230 requirementsmod.GENERALDELTA_REQUIREMENT,
1228 requirementsmod.TREEMANIFEST_REQUIREMENT,
1231 requirementsmod.TREEMANIFEST_REQUIREMENT,
1229 requirementsmod.COPIESSDC_REQUIREMENT,
1232 requirementsmod.COPIESSDC_REQUIREMENT,
1230 requirementsmod.REVLOGV2_REQUIREMENT,
1233 requirementsmod.REVLOGV2_REQUIREMENT,
1231 requirementsmod.CHANGELOGV2_REQUIREMENT,
1234 requirementsmod.CHANGELOGV2_REQUIREMENT,
1232 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1235 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1233 requirementsmod.NODEMAP_REQUIREMENT,
1236 requirementsmod.NODEMAP_REQUIREMENT,
1234 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1237 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1235 requirementsmod.SHARESAFE_REQUIREMENT,
1238 requirementsmod.SHARESAFE_REQUIREMENT,
1236 }
1239 }
1237 _basesupported = supportedformats | {
1240 _basesupported = supportedformats | {
1238 requirementsmod.STORE_REQUIREMENT,
1241 requirementsmod.STORE_REQUIREMENT,
1239 requirementsmod.FNCACHE_REQUIREMENT,
1242 requirementsmod.FNCACHE_REQUIREMENT,
1240 requirementsmod.SHARED_REQUIREMENT,
1243 requirementsmod.SHARED_REQUIREMENT,
1241 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1244 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1242 requirementsmod.DOTENCODE_REQUIREMENT,
1245 requirementsmod.DOTENCODE_REQUIREMENT,
1243 requirementsmod.SPARSE_REQUIREMENT,
1246 requirementsmod.SPARSE_REQUIREMENT,
1244 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1247 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1245 }
1248 }
1246
1249
1247 # list of prefix for file which can be written without 'wlock'
1250 # list of prefix for file which can be written without 'wlock'
1248 # Extensions should extend this list when needed
1251 # Extensions should extend this list when needed
1249 _wlockfreeprefix = {
1252 _wlockfreeprefix = {
1250 # We migh consider requiring 'wlock' for the next
1253 # We migh consider requiring 'wlock' for the next
1251 # two, but pretty much all the existing code assume
1254 # two, but pretty much all the existing code assume
1252 # wlock is not needed so we keep them excluded for
1255 # wlock is not needed so we keep them excluded for
1253 # now.
1256 # now.
1254 b'hgrc',
1257 b'hgrc',
1255 b'requires',
1258 b'requires',
1256 # XXX cache is a complicatged business someone
1259 # XXX cache is a complicatged business someone
1257 # should investigate this in depth at some point
1260 # should investigate this in depth at some point
1258 b'cache/',
1261 b'cache/',
1259 # XXX shouldn't be dirstate covered by the wlock?
1262 # XXX shouldn't be dirstate covered by the wlock?
1260 b'dirstate',
1263 b'dirstate',
1261 # XXX bisect was still a bit too messy at the time
1264 # XXX bisect was still a bit too messy at the time
1262 # this changeset was introduced. Someone should fix
1265 # this changeset was introduced. Someone should fix
1263 # the remainig bit and drop this line
1266 # the remainig bit and drop this line
1264 b'bisect.state',
1267 b'bisect.state',
1265 }
1268 }
1266
1269
1267 def __init__(
1270 def __init__(
1268 self,
1271 self,
1269 baseui,
1272 baseui,
1270 ui,
1273 ui,
1271 origroot,
1274 origroot,
1272 wdirvfs,
1275 wdirvfs,
1273 hgvfs,
1276 hgvfs,
1274 requirements,
1277 requirements,
1275 supportedrequirements,
1278 supportedrequirements,
1276 sharedpath,
1279 sharedpath,
1277 store,
1280 store,
1278 cachevfs,
1281 cachevfs,
1279 wcachevfs,
1282 wcachevfs,
1280 features,
1283 features,
1281 intents=None,
1284 intents=None,
1282 ):
1285 ):
1283 """Create a new local repository instance.
1286 """Create a new local repository instance.
1284
1287
1285 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1288 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1286 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1289 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1287 object.
1290 object.
1288
1291
1289 Arguments:
1292 Arguments:
1290
1293
1291 baseui
1294 baseui
1292 ``ui.ui`` instance that ``ui`` argument was based off of.
1295 ``ui.ui`` instance that ``ui`` argument was based off of.
1293
1296
1294 ui
1297 ui
1295 ``ui.ui`` instance for use by the repository.
1298 ``ui.ui`` instance for use by the repository.
1296
1299
1297 origroot
1300 origroot
1298 ``bytes`` path to working directory root of this repository.
1301 ``bytes`` path to working directory root of this repository.
1299
1302
1300 wdirvfs
1303 wdirvfs
1301 ``vfs.vfs`` rooted at the working directory.
1304 ``vfs.vfs`` rooted at the working directory.
1302
1305
1303 hgvfs
1306 hgvfs
1304 ``vfs.vfs`` rooted at .hg/
1307 ``vfs.vfs`` rooted at .hg/
1305
1308
1306 requirements
1309 requirements
1307 ``set`` of bytestrings representing repository opening requirements.
1310 ``set`` of bytestrings representing repository opening requirements.
1308
1311
1309 supportedrequirements
1312 supportedrequirements
1310 ``set`` of bytestrings representing repository requirements that we
1313 ``set`` of bytestrings representing repository requirements that we
1311 know how to open. May be a supetset of ``requirements``.
1314 know how to open. May be a supetset of ``requirements``.
1312
1315
1313 sharedpath
1316 sharedpath
1314 ``bytes`` Defining path to storage base directory. Points to a
1317 ``bytes`` Defining path to storage base directory. Points to a
1315 ``.hg/`` directory somewhere.
1318 ``.hg/`` directory somewhere.
1316
1319
1317 store
1320 store
1318 ``store.basicstore`` (or derived) instance providing access to
1321 ``store.basicstore`` (or derived) instance providing access to
1319 versioned storage.
1322 versioned storage.
1320
1323
1321 cachevfs
1324 cachevfs
1322 ``vfs.vfs`` used for cache files.
1325 ``vfs.vfs`` used for cache files.
1323
1326
1324 wcachevfs
1327 wcachevfs
1325 ``vfs.vfs`` used for cache files related to the working copy.
1328 ``vfs.vfs`` used for cache files related to the working copy.
1326
1329
1327 features
1330 features
1328 ``set`` of bytestrings defining features/capabilities of this
1331 ``set`` of bytestrings defining features/capabilities of this
1329 instance.
1332 instance.
1330
1333
1331 intents
1334 intents
1332 ``set`` of system strings indicating what this repo will be used
1335 ``set`` of system strings indicating what this repo will be used
1333 for.
1336 for.
1334 """
1337 """
1335 self.baseui = baseui
1338 self.baseui = baseui
1336 self.ui = ui
1339 self.ui = ui
1337 self.origroot = origroot
1340 self.origroot = origroot
1338 # vfs rooted at working directory.
1341 # vfs rooted at working directory.
1339 self.wvfs = wdirvfs
1342 self.wvfs = wdirvfs
1340 self.root = wdirvfs.base
1343 self.root = wdirvfs.base
1341 # vfs rooted at .hg/. Used to access most non-store paths.
1344 # vfs rooted at .hg/. Used to access most non-store paths.
1342 self.vfs = hgvfs
1345 self.vfs = hgvfs
1343 self.path = hgvfs.base
1346 self.path = hgvfs.base
1344 self.requirements = requirements
1347 self.requirements = requirements
1345 self.nodeconstants = sha1nodeconstants
1348 self.nodeconstants = sha1nodeconstants
1346 self.nullid = self.nodeconstants.nullid
1349 self.nullid = self.nodeconstants.nullid
1347 self.supported = supportedrequirements
1350 self.supported = supportedrequirements
1348 self.sharedpath = sharedpath
1351 self.sharedpath = sharedpath
1349 self.store = store
1352 self.store = store
1350 self.cachevfs = cachevfs
1353 self.cachevfs = cachevfs
1351 self.wcachevfs = wcachevfs
1354 self.wcachevfs = wcachevfs
1352 self.features = features
1355 self.features = features
1353
1356
1354 self.filtername = None
1357 self.filtername = None
1355
1358
1356 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1359 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1357 b'devel', b'check-locks'
1360 b'devel', b'check-locks'
1358 ):
1361 ):
1359 self.vfs.audit = self._getvfsward(self.vfs.audit)
1362 self.vfs.audit = self._getvfsward(self.vfs.audit)
1360 # A list of callback to shape the phase if no data were found.
1363 # A list of callback to shape the phase if no data were found.
1361 # Callback are in the form: func(repo, roots) --> processed root.
1364 # Callback are in the form: func(repo, roots) --> processed root.
1362 # This list it to be filled by extension during repo setup
1365 # This list it to be filled by extension during repo setup
1363 self._phasedefaults = []
1366 self._phasedefaults = []
1364
1367
1365 color.setup(self.ui)
1368 color.setup(self.ui)
1366
1369
1367 self.spath = self.store.path
1370 self.spath = self.store.path
1368 self.svfs = self.store.vfs
1371 self.svfs = self.store.vfs
1369 self.sjoin = self.store.join
1372 self.sjoin = self.store.join
1370 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1373 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1371 b'devel', b'check-locks'
1374 b'devel', b'check-locks'
1372 ):
1375 ):
1373 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1376 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1374 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1377 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1375 else: # standard vfs
1378 else: # standard vfs
1376 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1379 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1377
1380
1378 self._dirstatevalidatewarned = False
1381 self._dirstatevalidatewarned = False
1379
1382
1380 self._branchcaches = branchmap.BranchMapCache()
1383 self._branchcaches = branchmap.BranchMapCache()
1381 self._revbranchcache = None
1384 self._revbranchcache = None
1382 self._filterpats = {}
1385 self._filterpats = {}
1383 self._datafilters = {}
1386 self._datafilters = {}
1384 self._transref = self._lockref = self._wlockref = None
1387 self._transref = self._lockref = self._wlockref = None
1385
1388
1386 # A cache for various files under .hg/ that tracks file changes,
1389 # A cache for various files under .hg/ that tracks file changes,
1387 # (used by the filecache decorator)
1390 # (used by the filecache decorator)
1388 #
1391 #
1389 # Maps a property name to its util.filecacheentry
1392 # Maps a property name to its util.filecacheentry
1390 self._filecache = {}
1393 self._filecache = {}
1391
1394
1392 # hold sets of revision to be filtered
1395 # hold sets of revision to be filtered
1393 # should be cleared when something might have changed the filter value:
1396 # should be cleared when something might have changed the filter value:
1394 # - new changesets,
1397 # - new changesets,
1395 # - phase change,
1398 # - phase change,
1396 # - new obsolescence marker,
1399 # - new obsolescence marker,
1397 # - working directory parent change,
1400 # - working directory parent change,
1398 # - bookmark changes
1401 # - bookmark changes
1399 self.filteredrevcache = {}
1402 self.filteredrevcache = {}
1400
1403
1401 # post-dirstate-status hooks
1404 # post-dirstate-status hooks
1402 self._postdsstatus = []
1405 self._postdsstatus = []
1403
1406
1404 # generic mapping between names and nodes
1407 # generic mapping between names and nodes
1405 self.names = namespaces.namespaces()
1408 self.names = namespaces.namespaces()
1406
1409
1407 # Key to signature value.
1410 # Key to signature value.
1408 self._sparsesignaturecache = {}
1411 self._sparsesignaturecache = {}
1409 # Signature to cached matcher instance.
1412 # Signature to cached matcher instance.
1410 self._sparsematchercache = {}
1413 self._sparsematchercache = {}
1411
1414
1412 self._extrafilterid = repoview.extrafilter(ui)
1415 self._extrafilterid = repoview.extrafilter(ui)
1413
1416
1414 self.filecopiesmode = None
1417 self.filecopiesmode = None
1415 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1418 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1416 self.filecopiesmode = b'changeset-sidedata'
1419 self.filecopiesmode = b'changeset-sidedata'
1417
1420
1418 self._wanted_sidedata = set()
1421 self._wanted_sidedata = set()
1419 self._sidedata_computers = {}
1422 self._sidedata_computers = {}
1420 sidedatamod.set_sidedata_spec_for_repo(self)
1423 sidedatamod.set_sidedata_spec_for_repo(self)
1421
1424
1422 def _getvfsward(self, origfunc):
1425 def _getvfsward(self, origfunc):
1423 """build a ward for self.vfs"""
1426 """build a ward for self.vfs"""
1424 rref = weakref.ref(self)
1427 rref = weakref.ref(self)
1425
1428
1426 def checkvfs(path, mode=None):
1429 def checkvfs(path, mode=None):
1427 ret = origfunc(path, mode=mode)
1430 ret = origfunc(path, mode=mode)
1428 repo = rref()
1431 repo = rref()
1429 if (
1432 if (
1430 repo is None
1433 repo is None
1431 or not util.safehasattr(repo, b'_wlockref')
1434 or not util.safehasattr(repo, b'_wlockref')
1432 or not util.safehasattr(repo, b'_lockref')
1435 or not util.safehasattr(repo, b'_lockref')
1433 ):
1436 ):
1434 return
1437 return
1435 if mode in (None, b'r', b'rb'):
1438 if mode in (None, b'r', b'rb'):
1436 return
1439 return
1437 if path.startswith(repo.path):
1440 if path.startswith(repo.path):
1438 # truncate name relative to the repository (.hg)
1441 # truncate name relative to the repository (.hg)
1439 path = path[len(repo.path) + 1 :]
1442 path = path[len(repo.path) + 1 :]
1440 if path.startswith(b'cache/'):
1443 if path.startswith(b'cache/'):
1441 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1444 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1442 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1445 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1443 # path prefixes covered by 'lock'
1446 # path prefixes covered by 'lock'
1444 vfs_path_prefixes = (
1447 vfs_path_prefixes = (
1445 b'journal.',
1448 b'journal.',
1446 b'undo.',
1449 b'undo.',
1447 b'strip-backup/',
1450 b'strip-backup/',
1448 b'cache/',
1451 b'cache/',
1449 )
1452 )
1450 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1453 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1451 if repo._currentlock(repo._lockref) is None:
1454 if repo._currentlock(repo._lockref) is None:
1452 repo.ui.develwarn(
1455 repo.ui.develwarn(
1453 b'write with no lock: "%s"' % path,
1456 b'write with no lock: "%s"' % path,
1454 stacklevel=3,
1457 stacklevel=3,
1455 config=b'check-locks',
1458 config=b'check-locks',
1456 )
1459 )
1457 elif repo._currentlock(repo._wlockref) is None:
1460 elif repo._currentlock(repo._wlockref) is None:
1458 # rest of vfs files are covered by 'wlock'
1461 # rest of vfs files are covered by 'wlock'
1459 #
1462 #
1460 # exclude special files
1463 # exclude special files
1461 for prefix in self._wlockfreeprefix:
1464 for prefix in self._wlockfreeprefix:
1462 if path.startswith(prefix):
1465 if path.startswith(prefix):
1463 return
1466 return
1464 repo.ui.develwarn(
1467 repo.ui.develwarn(
1465 b'write with no wlock: "%s"' % path,
1468 b'write with no wlock: "%s"' % path,
1466 stacklevel=3,
1469 stacklevel=3,
1467 config=b'check-locks',
1470 config=b'check-locks',
1468 )
1471 )
1469 return ret
1472 return ret
1470
1473
1471 return checkvfs
1474 return checkvfs
1472
1475
1473 def _getsvfsward(self, origfunc):
1476 def _getsvfsward(self, origfunc):
1474 """build a ward for self.svfs"""
1477 """build a ward for self.svfs"""
1475 rref = weakref.ref(self)
1478 rref = weakref.ref(self)
1476
1479
1477 def checksvfs(path, mode=None):
1480 def checksvfs(path, mode=None):
1478 ret = origfunc(path, mode=mode)
1481 ret = origfunc(path, mode=mode)
1479 repo = rref()
1482 repo = rref()
1480 if repo is None or not util.safehasattr(repo, b'_lockref'):
1483 if repo is None or not util.safehasattr(repo, b'_lockref'):
1481 return
1484 return
1482 if mode in (None, b'r', b'rb'):
1485 if mode in (None, b'r', b'rb'):
1483 return
1486 return
1484 if path.startswith(repo.sharedpath):
1487 if path.startswith(repo.sharedpath):
1485 # truncate name relative to the repository (.hg)
1488 # truncate name relative to the repository (.hg)
1486 path = path[len(repo.sharedpath) + 1 :]
1489 path = path[len(repo.sharedpath) + 1 :]
1487 if repo._currentlock(repo._lockref) is None:
1490 if repo._currentlock(repo._lockref) is None:
1488 repo.ui.develwarn(
1491 repo.ui.develwarn(
1489 b'write with no lock: "%s"' % path, stacklevel=4
1492 b'write with no lock: "%s"' % path, stacklevel=4
1490 )
1493 )
1491 return ret
1494 return ret
1492
1495
1493 return checksvfs
1496 return checksvfs
1494
1497
1495 def close(self):
1498 def close(self):
1496 self._writecaches()
1499 self._writecaches()
1497
1500
1498 def _writecaches(self):
1501 def _writecaches(self):
1499 if self._revbranchcache:
1502 if self._revbranchcache:
1500 self._revbranchcache.write()
1503 self._revbranchcache.write()
1501
1504
1502 def _restrictcapabilities(self, caps):
1505 def _restrictcapabilities(self, caps):
1503 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1506 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1504 caps = set(caps)
1507 caps = set(caps)
1505 capsblob = bundle2.encodecaps(
1508 capsblob = bundle2.encodecaps(
1506 bundle2.getrepocaps(self, role=b'client')
1509 bundle2.getrepocaps(self, role=b'client')
1507 )
1510 )
1508 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1511 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1509 if self.ui.configbool(b'experimental', b'narrow'):
1512 if self.ui.configbool(b'experimental', b'narrow'):
1510 caps.add(wireprototypes.NARROWCAP)
1513 caps.add(wireprototypes.NARROWCAP)
1511 return caps
1514 return caps
1512
1515
1513 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1516 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1514 # self -> auditor -> self._checknested -> self
1517 # self -> auditor -> self._checknested -> self
1515
1518
1516 @property
1519 @property
1517 def auditor(self):
1520 def auditor(self):
1518 # This is only used by context.workingctx.match in order to
1521 # This is only used by context.workingctx.match in order to
1519 # detect files in subrepos.
1522 # detect files in subrepos.
1520 return pathutil.pathauditor(self.root, callback=self._checknested)
1523 return pathutil.pathauditor(self.root, callback=self._checknested)
1521
1524
1522 @property
1525 @property
1523 def nofsauditor(self):
1526 def nofsauditor(self):
1524 # This is only used by context.basectx.match in order to detect
1527 # This is only used by context.basectx.match in order to detect
1525 # files in subrepos.
1528 # files in subrepos.
1526 return pathutil.pathauditor(
1529 return pathutil.pathauditor(
1527 self.root, callback=self._checknested, realfs=False, cached=True
1530 self.root, callback=self._checknested, realfs=False, cached=True
1528 )
1531 )
1529
1532
1530 def _checknested(self, path):
1533 def _checknested(self, path):
1531 """Determine if path is a legal nested repository."""
1534 """Determine if path is a legal nested repository."""
1532 if not path.startswith(self.root):
1535 if not path.startswith(self.root):
1533 return False
1536 return False
1534 subpath = path[len(self.root) + 1 :]
1537 subpath = path[len(self.root) + 1 :]
1535 normsubpath = util.pconvert(subpath)
1538 normsubpath = util.pconvert(subpath)
1536
1539
1537 # XXX: Checking against the current working copy is wrong in
1540 # XXX: Checking against the current working copy is wrong in
1538 # the sense that it can reject things like
1541 # the sense that it can reject things like
1539 #
1542 #
1540 # $ hg cat -r 10 sub/x.txt
1543 # $ hg cat -r 10 sub/x.txt
1541 #
1544 #
1542 # if sub/ is no longer a subrepository in the working copy
1545 # if sub/ is no longer a subrepository in the working copy
1543 # parent revision.
1546 # parent revision.
1544 #
1547 #
1545 # However, it can of course also allow things that would have
1548 # However, it can of course also allow things that would have
1546 # been rejected before, such as the above cat command if sub/
1549 # been rejected before, such as the above cat command if sub/
1547 # is a subrepository now, but was a normal directory before.
1550 # is a subrepository now, but was a normal directory before.
1548 # The old path auditor would have rejected by mistake since it
1551 # The old path auditor would have rejected by mistake since it
1549 # panics when it sees sub/.hg/.
1552 # panics when it sees sub/.hg/.
1550 #
1553 #
1551 # All in all, checking against the working copy seems sensible
1554 # All in all, checking against the working copy seems sensible
1552 # since we want to prevent access to nested repositories on
1555 # since we want to prevent access to nested repositories on
1553 # the filesystem *now*.
1556 # the filesystem *now*.
1554 ctx = self[None]
1557 ctx = self[None]
1555 parts = util.splitpath(subpath)
1558 parts = util.splitpath(subpath)
1556 while parts:
1559 while parts:
1557 prefix = b'/'.join(parts)
1560 prefix = b'/'.join(parts)
1558 if prefix in ctx.substate:
1561 if prefix in ctx.substate:
1559 if prefix == normsubpath:
1562 if prefix == normsubpath:
1560 return True
1563 return True
1561 else:
1564 else:
1562 sub = ctx.sub(prefix)
1565 sub = ctx.sub(prefix)
1563 return sub.checknested(subpath[len(prefix) + 1 :])
1566 return sub.checknested(subpath[len(prefix) + 1 :])
1564 else:
1567 else:
1565 parts.pop()
1568 parts.pop()
1566 return False
1569 return False
1567
1570
1568 def peer(self):
1571 def peer(self):
1569 return localpeer(self) # not cached to avoid reference cycle
1572 return localpeer(self) # not cached to avoid reference cycle
1570
1573
1571 def unfiltered(self):
1574 def unfiltered(self):
1572 """Return unfiltered version of the repository
1575 """Return unfiltered version of the repository
1573
1576
1574 Intended to be overwritten by filtered repo."""
1577 Intended to be overwritten by filtered repo."""
1575 return self
1578 return self
1576
1579
1577 def filtered(self, name, visibilityexceptions=None):
1580 def filtered(self, name, visibilityexceptions=None):
1578 """Return a filtered version of a repository
1581 """Return a filtered version of a repository
1579
1582
1580 The `name` parameter is the identifier of the requested view. This
1583 The `name` parameter is the identifier of the requested view. This
1581 will return a repoview object set "exactly" to the specified view.
1584 will return a repoview object set "exactly" to the specified view.
1582
1585
1583 This function does not apply recursive filtering to a repository. For
1586 This function does not apply recursive filtering to a repository. For
1584 example calling `repo.filtered("served")` will return a repoview using
1587 example calling `repo.filtered("served")` will return a repoview using
1585 the "served" view, regardless of the initial view used by `repo`.
1588 the "served" view, regardless of the initial view used by `repo`.
1586
1589
1587 In other word, there is always only one level of `repoview` "filtering".
1590 In other word, there is always only one level of `repoview` "filtering".
1588 """
1591 """
1589 if self._extrafilterid is not None and b'%' not in name:
1592 if self._extrafilterid is not None and b'%' not in name:
1590 name = name + b'%' + self._extrafilterid
1593 name = name + b'%' + self._extrafilterid
1591
1594
1592 cls = repoview.newtype(self.unfiltered().__class__)
1595 cls = repoview.newtype(self.unfiltered().__class__)
1593 return cls(self, name, visibilityexceptions)
1596 return cls(self, name, visibilityexceptions)
1594
1597
1595 @mixedrepostorecache(
1598 @mixedrepostorecache(
1596 (b'bookmarks', b'plain'),
1599 (b'bookmarks', b'plain'),
1597 (b'bookmarks.current', b'plain'),
1600 (b'bookmarks.current', b'plain'),
1598 (b'bookmarks', b''),
1601 (b'bookmarks', b''),
1599 (b'00changelog.i', b''),
1602 (b'00changelog.i', b''),
1600 )
1603 )
1601 def _bookmarks(self):
1604 def _bookmarks(self):
1602 # Since the multiple files involved in the transaction cannot be
1605 # Since the multiple files involved in the transaction cannot be
1603 # written atomically (with current repository format), there is a race
1606 # written atomically (with current repository format), there is a race
1604 # condition here.
1607 # condition here.
1605 #
1608 #
1606 # 1) changelog content A is read
1609 # 1) changelog content A is read
1607 # 2) outside transaction update changelog to content B
1610 # 2) outside transaction update changelog to content B
1608 # 3) outside transaction update bookmark file referring to content B
1611 # 3) outside transaction update bookmark file referring to content B
1609 # 4) bookmarks file content is read and filtered against changelog-A
1612 # 4) bookmarks file content is read and filtered against changelog-A
1610 #
1613 #
1611 # When this happens, bookmarks against nodes missing from A are dropped.
1614 # When this happens, bookmarks against nodes missing from A are dropped.
1612 #
1615 #
1613 # Having this happening during read is not great, but it become worse
1616 # Having this happening during read is not great, but it become worse
1614 # when this happen during write because the bookmarks to the "unknown"
1617 # when this happen during write because the bookmarks to the "unknown"
1615 # nodes will be dropped for good. However, writes happen within locks.
1618 # nodes will be dropped for good. However, writes happen within locks.
1616 # This locking makes it possible to have a race free consistent read.
1619 # This locking makes it possible to have a race free consistent read.
1617 # For this purpose data read from disc before locking are
1620 # For this purpose data read from disc before locking are
1618 # "invalidated" right after the locks are taken. This invalidations are
1621 # "invalidated" right after the locks are taken. This invalidations are
1619 # "light", the `filecache` mechanism keep the data in memory and will
1622 # "light", the `filecache` mechanism keep the data in memory and will
1620 # reuse them if the underlying files did not changed. Not parsing the
1623 # reuse them if the underlying files did not changed. Not parsing the
1621 # same data multiple times helps performances.
1624 # same data multiple times helps performances.
1622 #
1625 #
1623 # Unfortunately in the case describe above, the files tracked by the
1626 # Unfortunately in the case describe above, the files tracked by the
1624 # bookmarks file cache might not have changed, but the in-memory
1627 # bookmarks file cache might not have changed, but the in-memory
1625 # content is still "wrong" because we used an older changelog content
1628 # content is still "wrong" because we used an older changelog content
1626 # to process the on-disk data. So after locking, the changelog would be
1629 # to process the on-disk data. So after locking, the changelog would be
1627 # refreshed but `_bookmarks` would be preserved.
1630 # refreshed but `_bookmarks` would be preserved.
1628 # Adding `00changelog.i` to the list of tracked file is not
1631 # Adding `00changelog.i` to the list of tracked file is not
1629 # enough, because at the time we build the content for `_bookmarks` in
1632 # enough, because at the time we build the content for `_bookmarks` in
1630 # (4), the changelog file has already diverged from the content used
1633 # (4), the changelog file has already diverged from the content used
1631 # for loading `changelog` in (1)
1634 # for loading `changelog` in (1)
1632 #
1635 #
1633 # To prevent the issue, we force the changelog to be explicitly
1636 # To prevent the issue, we force the changelog to be explicitly
1634 # reloaded while computing `_bookmarks`. The data race can still happen
1637 # reloaded while computing `_bookmarks`. The data race can still happen
1635 # without the lock (with a narrower window), but it would no longer go
1638 # without the lock (with a narrower window), but it would no longer go
1636 # undetected during the lock time refresh.
1639 # undetected during the lock time refresh.
1637 #
1640 #
1638 # The new schedule is as follow
1641 # The new schedule is as follow
1639 #
1642 #
1640 # 1) filecache logic detect that `_bookmarks` needs to be computed
1643 # 1) filecache logic detect that `_bookmarks` needs to be computed
1641 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1644 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1642 # 3) We force `changelog` filecache to be tested
1645 # 3) We force `changelog` filecache to be tested
1643 # 4) cachestat for `changelog` are captured (for changelog)
1646 # 4) cachestat for `changelog` are captured (for changelog)
1644 # 5) `_bookmarks` is computed and cached
1647 # 5) `_bookmarks` is computed and cached
1645 #
1648 #
1646 # The step in (3) ensure we have a changelog at least as recent as the
1649 # The step in (3) ensure we have a changelog at least as recent as the
1647 # cache stat computed in (1). As a result at locking time:
1650 # cache stat computed in (1). As a result at locking time:
1648 # * if the changelog did not changed since (1) -> we can reuse the data
1651 # * if the changelog did not changed since (1) -> we can reuse the data
1649 # * otherwise -> the bookmarks get refreshed.
1652 # * otherwise -> the bookmarks get refreshed.
1650 self._refreshchangelog()
1653 self._refreshchangelog()
1651 return bookmarks.bmstore(self)
1654 return bookmarks.bmstore(self)
1652
1655
1653 def _refreshchangelog(self):
1656 def _refreshchangelog(self):
1654 """make sure the in memory changelog match the on-disk one"""
1657 """make sure the in memory changelog match the on-disk one"""
1655 if 'changelog' in vars(self) and self.currenttransaction() is None:
1658 if 'changelog' in vars(self) and self.currenttransaction() is None:
1656 del self.changelog
1659 del self.changelog
1657
1660
1658 @property
1661 @property
1659 def _activebookmark(self):
1662 def _activebookmark(self):
1660 return self._bookmarks.active
1663 return self._bookmarks.active
1661
1664
1662 # _phasesets depend on changelog. what we need is to call
1665 # _phasesets depend on changelog. what we need is to call
1663 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1666 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1664 # can't be easily expressed in filecache mechanism.
1667 # can't be easily expressed in filecache mechanism.
1665 @storecache(b'phaseroots', b'00changelog.i')
1668 @storecache(b'phaseroots', b'00changelog.i')
1666 def _phasecache(self):
1669 def _phasecache(self):
1667 return phases.phasecache(self, self._phasedefaults)
1670 return phases.phasecache(self, self._phasedefaults)
1668
1671
1669 @storecache(b'obsstore')
1672 @storecache(b'obsstore')
1670 def obsstore(self):
1673 def obsstore(self):
1671 return obsolete.makestore(self.ui, self)
1674 return obsolete.makestore(self.ui, self)
1672
1675
1673 @storecache(b'00changelog.i')
1676 @storecache(b'00changelog.i')
1674 def changelog(self):
1677 def changelog(self):
1675 # load dirstate before changelog to avoid race see issue6303
1678 # load dirstate before changelog to avoid race see issue6303
1676 self.dirstate.prefetch_parents()
1679 self.dirstate.prefetch_parents()
1677 return self.store.changelog(
1680 return self.store.changelog(
1678 txnutil.mayhavepending(self.root),
1681 txnutil.mayhavepending(self.root),
1679 concurrencychecker=revlogchecker.get_checker(self.ui, b'changelog'),
1682 concurrencychecker=revlogchecker.get_checker(self.ui, b'changelog'),
1680 )
1683 )
1681
1684
1682 @storecache(b'00manifest.i')
1685 @storecache(b'00manifest.i')
1683 def manifestlog(self):
1686 def manifestlog(self):
1684 return self.store.manifestlog(self, self._storenarrowmatch)
1687 return self.store.manifestlog(self, self._storenarrowmatch)
1685
1688
1686 @repofilecache(b'dirstate')
1689 @repofilecache(b'dirstate')
1687 def dirstate(self):
1690 def dirstate(self):
1688 return self._makedirstate()
1691 return self._makedirstate()
1689
1692
1690 def _makedirstate(self):
1693 def _makedirstate(self):
1691 """Extension point for wrapping the dirstate per-repo."""
1694 """Extension point for wrapping the dirstate per-repo."""
1692 sparsematchfn = lambda: sparse.matcher(self)
1695 sparsematchfn = lambda: sparse.matcher(self)
1693 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1696 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1694 use_dirstate_v2 = v2_req in self.requirements
1697 use_dirstate_v2 = v2_req in self.requirements
1695
1698
1696 return dirstate.dirstate(
1699 return dirstate.dirstate(
1697 self.vfs,
1700 self.vfs,
1698 self.ui,
1701 self.ui,
1699 self.root,
1702 self.root,
1700 self._dirstatevalidate,
1703 self._dirstatevalidate,
1701 sparsematchfn,
1704 sparsematchfn,
1702 self.nodeconstants,
1705 self.nodeconstants,
1703 use_dirstate_v2,
1706 use_dirstate_v2,
1704 )
1707 )
1705
1708
1706 def _dirstatevalidate(self, node):
1709 def _dirstatevalidate(self, node):
1707 try:
1710 try:
1708 self.changelog.rev(node)
1711 self.changelog.rev(node)
1709 return node
1712 return node
1710 except error.LookupError:
1713 except error.LookupError:
1711 if not self._dirstatevalidatewarned:
1714 if not self._dirstatevalidatewarned:
1712 self._dirstatevalidatewarned = True
1715 self._dirstatevalidatewarned = True
1713 self.ui.warn(
1716 self.ui.warn(
1714 _(b"warning: ignoring unknown working parent %s!\n")
1717 _(b"warning: ignoring unknown working parent %s!\n")
1715 % short(node)
1718 % short(node)
1716 )
1719 )
1717 return self.nullid
1720 return self.nullid
1718
1721
1719 @storecache(narrowspec.FILENAME)
1722 @storecache(narrowspec.FILENAME)
1720 def narrowpats(self):
1723 def narrowpats(self):
1721 """matcher patterns for this repository's narrowspec
1724 """matcher patterns for this repository's narrowspec
1722
1725
1723 A tuple of (includes, excludes).
1726 A tuple of (includes, excludes).
1724 """
1727 """
1725 return narrowspec.load(self)
1728 return narrowspec.load(self)
1726
1729
1727 @storecache(narrowspec.FILENAME)
1730 @storecache(narrowspec.FILENAME)
1728 def _storenarrowmatch(self):
1731 def _storenarrowmatch(self):
1729 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1732 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1730 return matchmod.always()
1733 return matchmod.always()
1731 include, exclude = self.narrowpats
1734 include, exclude = self.narrowpats
1732 return narrowspec.match(self.root, include=include, exclude=exclude)
1735 return narrowspec.match(self.root, include=include, exclude=exclude)
1733
1736
1734 @storecache(narrowspec.FILENAME)
1737 @storecache(narrowspec.FILENAME)
1735 def _narrowmatch(self):
1738 def _narrowmatch(self):
1736 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1739 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1737 return matchmod.always()
1740 return matchmod.always()
1738 narrowspec.checkworkingcopynarrowspec(self)
1741 narrowspec.checkworkingcopynarrowspec(self)
1739 include, exclude = self.narrowpats
1742 include, exclude = self.narrowpats
1740 return narrowspec.match(self.root, include=include, exclude=exclude)
1743 return narrowspec.match(self.root, include=include, exclude=exclude)
1741
1744
1742 def narrowmatch(self, match=None, includeexact=False):
1745 def narrowmatch(self, match=None, includeexact=False):
1743 """matcher corresponding the the repo's narrowspec
1746 """matcher corresponding the the repo's narrowspec
1744
1747
1745 If `match` is given, then that will be intersected with the narrow
1748 If `match` is given, then that will be intersected with the narrow
1746 matcher.
1749 matcher.
1747
1750
1748 If `includeexact` is True, then any exact matches from `match` will
1751 If `includeexact` is True, then any exact matches from `match` will
1749 be included even if they're outside the narrowspec.
1752 be included even if they're outside the narrowspec.
1750 """
1753 """
1751 if match:
1754 if match:
1752 if includeexact and not self._narrowmatch.always():
1755 if includeexact and not self._narrowmatch.always():
1753 # do not exclude explicitly-specified paths so that they can
1756 # do not exclude explicitly-specified paths so that they can
1754 # be warned later on
1757 # be warned later on
1755 em = matchmod.exact(match.files())
1758 em = matchmod.exact(match.files())
1756 nm = matchmod.unionmatcher([self._narrowmatch, em])
1759 nm = matchmod.unionmatcher([self._narrowmatch, em])
1757 return matchmod.intersectmatchers(match, nm)
1760 return matchmod.intersectmatchers(match, nm)
1758 return matchmod.intersectmatchers(match, self._narrowmatch)
1761 return matchmod.intersectmatchers(match, self._narrowmatch)
1759 return self._narrowmatch
1762 return self._narrowmatch
1760
1763
1761 def setnarrowpats(self, newincludes, newexcludes):
1764 def setnarrowpats(self, newincludes, newexcludes):
1762 narrowspec.save(self, newincludes, newexcludes)
1765 narrowspec.save(self, newincludes, newexcludes)
1763 self.invalidate(clearfilecache=True)
1766 self.invalidate(clearfilecache=True)
1764
1767
1765 @unfilteredpropertycache
1768 @unfilteredpropertycache
1766 def _quick_access_changeid_null(self):
1769 def _quick_access_changeid_null(self):
1767 return {
1770 return {
1768 b'null': (nullrev, self.nodeconstants.nullid),
1771 b'null': (nullrev, self.nodeconstants.nullid),
1769 nullrev: (nullrev, self.nodeconstants.nullid),
1772 nullrev: (nullrev, self.nodeconstants.nullid),
1770 self.nullid: (nullrev, self.nullid),
1773 self.nullid: (nullrev, self.nullid),
1771 }
1774 }
1772
1775
1773 @unfilteredpropertycache
1776 @unfilteredpropertycache
1774 def _quick_access_changeid_wc(self):
1777 def _quick_access_changeid_wc(self):
1775 # also fast path access to the working copy parents
1778 # also fast path access to the working copy parents
1776 # however, only do it for filter that ensure wc is visible.
1779 # however, only do it for filter that ensure wc is visible.
1777 quick = self._quick_access_changeid_null.copy()
1780 quick = self._quick_access_changeid_null.copy()
1778 cl = self.unfiltered().changelog
1781 cl = self.unfiltered().changelog
1779 for node in self.dirstate.parents():
1782 for node in self.dirstate.parents():
1780 if node == self.nullid:
1783 if node == self.nullid:
1781 continue
1784 continue
1782 rev = cl.index.get_rev(node)
1785 rev = cl.index.get_rev(node)
1783 if rev is None:
1786 if rev is None:
1784 # unknown working copy parent case:
1787 # unknown working copy parent case:
1785 #
1788 #
1786 # skip the fast path and let higher code deal with it
1789 # skip the fast path and let higher code deal with it
1787 continue
1790 continue
1788 pair = (rev, node)
1791 pair = (rev, node)
1789 quick[rev] = pair
1792 quick[rev] = pair
1790 quick[node] = pair
1793 quick[node] = pair
1791 # also add the parents of the parents
1794 # also add the parents of the parents
1792 for r in cl.parentrevs(rev):
1795 for r in cl.parentrevs(rev):
1793 if r == nullrev:
1796 if r == nullrev:
1794 continue
1797 continue
1795 n = cl.node(r)
1798 n = cl.node(r)
1796 pair = (r, n)
1799 pair = (r, n)
1797 quick[r] = pair
1800 quick[r] = pair
1798 quick[n] = pair
1801 quick[n] = pair
1799 p1node = self.dirstate.p1()
1802 p1node = self.dirstate.p1()
1800 if p1node != self.nullid:
1803 if p1node != self.nullid:
1801 quick[b'.'] = quick[p1node]
1804 quick[b'.'] = quick[p1node]
1802 return quick
1805 return quick
1803
1806
1804 @unfilteredmethod
1807 @unfilteredmethod
1805 def _quick_access_changeid_invalidate(self):
1808 def _quick_access_changeid_invalidate(self):
1806 if '_quick_access_changeid_wc' in vars(self):
1809 if '_quick_access_changeid_wc' in vars(self):
1807 del self.__dict__['_quick_access_changeid_wc']
1810 del self.__dict__['_quick_access_changeid_wc']
1808
1811
1809 @property
1812 @property
1810 def _quick_access_changeid(self):
1813 def _quick_access_changeid(self):
1811 """an helper dictionnary for __getitem__ calls
1814 """an helper dictionnary for __getitem__ calls
1812
1815
1813 This contains a list of symbol we can recognise right away without
1816 This contains a list of symbol we can recognise right away without
1814 further processing.
1817 further processing.
1815 """
1818 """
1816 if self.filtername in repoview.filter_has_wc:
1819 if self.filtername in repoview.filter_has_wc:
1817 return self._quick_access_changeid_wc
1820 return self._quick_access_changeid_wc
1818 return self._quick_access_changeid_null
1821 return self._quick_access_changeid_null
1819
1822
1820 def __getitem__(self, changeid):
1823 def __getitem__(self, changeid):
1821 # dealing with special cases
1824 # dealing with special cases
1822 if changeid is None:
1825 if changeid is None:
1823 return context.workingctx(self)
1826 return context.workingctx(self)
1824 if isinstance(changeid, context.basectx):
1827 if isinstance(changeid, context.basectx):
1825 return changeid
1828 return changeid
1826
1829
1827 # dealing with multiple revisions
1830 # dealing with multiple revisions
1828 if isinstance(changeid, slice):
1831 if isinstance(changeid, slice):
1829 # wdirrev isn't contiguous so the slice shouldn't include it
1832 # wdirrev isn't contiguous so the slice shouldn't include it
1830 return [
1833 return [
1831 self[i]
1834 self[i]
1832 for i in pycompat.xrange(*changeid.indices(len(self)))
1835 for i in pycompat.xrange(*changeid.indices(len(self)))
1833 if i not in self.changelog.filteredrevs
1836 if i not in self.changelog.filteredrevs
1834 ]
1837 ]
1835
1838
1836 # dealing with some special values
1839 # dealing with some special values
1837 quick_access = self._quick_access_changeid.get(changeid)
1840 quick_access = self._quick_access_changeid.get(changeid)
1838 if quick_access is not None:
1841 if quick_access is not None:
1839 rev, node = quick_access
1842 rev, node = quick_access
1840 return context.changectx(self, rev, node, maybe_filtered=False)
1843 return context.changectx(self, rev, node, maybe_filtered=False)
1841 if changeid == b'tip':
1844 if changeid == b'tip':
1842 node = self.changelog.tip()
1845 node = self.changelog.tip()
1843 rev = self.changelog.rev(node)
1846 rev = self.changelog.rev(node)
1844 return context.changectx(self, rev, node)
1847 return context.changectx(self, rev, node)
1845
1848
1846 # dealing with arbitrary values
1849 # dealing with arbitrary values
1847 try:
1850 try:
1848 if isinstance(changeid, int):
1851 if isinstance(changeid, int):
1849 node = self.changelog.node(changeid)
1852 node = self.changelog.node(changeid)
1850 rev = changeid
1853 rev = changeid
1851 elif changeid == b'.':
1854 elif changeid == b'.':
1852 # this is a hack to delay/avoid loading obsmarkers
1855 # this is a hack to delay/avoid loading obsmarkers
1853 # when we know that '.' won't be hidden
1856 # when we know that '.' won't be hidden
1854 node = self.dirstate.p1()
1857 node = self.dirstate.p1()
1855 rev = self.unfiltered().changelog.rev(node)
1858 rev = self.unfiltered().changelog.rev(node)
1856 elif len(changeid) == self.nodeconstants.nodelen:
1859 elif len(changeid) == self.nodeconstants.nodelen:
1857 try:
1860 try:
1858 node = changeid
1861 node = changeid
1859 rev = self.changelog.rev(changeid)
1862 rev = self.changelog.rev(changeid)
1860 except error.FilteredLookupError:
1863 except error.FilteredLookupError:
1861 changeid = hex(changeid) # for the error message
1864 changeid = hex(changeid) # for the error message
1862 raise
1865 raise
1863 except LookupError:
1866 except LookupError:
1864 # check if it might have come from damaged dirstate
1867 # check if it might have come from damaged dirstate
1865 #
1868 #
1866 # XXX we could avoid the unfiltered if we had a recognizable
1869 # XXX we could avoid the unfiltered if we had a recognizable
1867 # exception for filtered changeset access
1870 # exception for filtered changeset access
1868 if (
1871 if (
1869 self.local()
1872 self.local()
1870 and changeid in self.unfiltered().dirstate.parents()
1873 and changeid in self.unfiltered().dirstate.parents()
1871 ):
1874 ):
1872 msg = _(b"working directory has unknown parent '%s'!")
1875 msg = _(b"working directory has unknown parent '%s'!")
1873 raise error.Abort(msg % short(changeid))
1876 raise error.Abort(msg % short(changeid))
1874 changeid = hex(changeid) # for the error message
1877 changeid = hex(changeid) # for the error message
1875 raise
1878 raise
1876
1879
1877 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1880 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1878 node = bin(changeid)
1881 node = bin(changeid)
1879 rev = self.changelog.rev(node)
1882 rev = self.changelog.rev(node)
1880 else:
1883 else:
1881 raise error.ProgrammingError(
1884 raise error.ProgrammingError(
1882 b"unsupported changeid '%s' of type %s"
1885 b"unsupported changeid '%s' of type %s"
1883 % (changeid, pycompat.bytestr(type(changeid)))
1886 % (changeid, pycompat.bytestr(type(changeid)))
1884 )
1887 )
1885
1888
1886 return context.changectx(self, rev, node)
1889 return context.changectx(self, rev, node)
1887
1890
1888 except (error.FilteredIndexError, error.FilteredLookupError):
1891 except (error.FilteredIndexError, error.FilteredLookupError):
1889 raise error.FilteredRepoLookupError(
1892 raise error.FilteredRepoLookupError(
1890 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1893 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1891 )
1894 )
1892 except (IndexError, LookupError):
1895 except (IndexError, LookupError):
1893 raise error.RepoLookupError(
1896 raise error.RepoLookupError(
1894 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1897 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1895 )
1898 )
1896 except error.WdirUnsupported:
1899 except error.WdirUnsupported:
1897 return context.workingctx(self)
1900 return context.workingctx(self)
1898
1901
1899 def __contains__(self, changeid):
1902 def __contains__(self, changeid):
1900 """True if the given changeid exists"""
1903 """True if the given changeid exists"""
1901 try:
1904 try:
1902 self[changeid]
1905 self[changeid]
1903 return True
1906 return True
1904 except error.RepoLookupError:
1907 except error.RepoLookupError:
1905 return False
1908 return False
1906
1909
1907 def __nonzero__(self):
1910 def __nonzero__(self):
1908 return True
1911 return True
1909
1912
1910 __bool__ = __nonzero__
1913 __bool__ = __nonzero__
1911
1914
1912 def __len__(self):
1915 def __len__(self):
1913 # no need to pay the cost of repoview.changelog
1916 # no need to pay the cost of repoview.changelog
1914 unfi = self.unfiltered()
1917 unfi = self.unfiltered()
1915 return len(unfi.changelog)
1918 return len(unfi.changelog)
1916
1919
1917 def __iter__(self):
1920 def __iter__(self):
1918 return iter(self.changelog)
1921 return iter(self.changelog)
1919
1922
1920 def revs(self, expr, *args):
1923 def revs(self, expr, *args):
1921 """Find revisions matching a revset.
1924 """Find revisions matching a revset.
1922
1925
1923 The revset is specified as a string ``expr`` that may contain
1926 The revset is specified as a string ``expr`` that may contain
1924 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1927 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1925
1928
1926 Revset aliases from the configuration are not expanded. To expand
1929 Revset aliases from the configuration are not expanded. To expand
1927 user aliases, consider calling ``scmutil.revrange()`` or
1930 user aliases, consider calling ``scmutil.revrange()`` or
1928 ``repo.anyrevs([expr], user=True)``.
1931 ``repo.anyrevs([expr], user=True)``.
1929
1932
1930 Returns a smartset.abstractsmartset, which is a list-like interface
1933 Returns a smartset.abstractsmartset, which is a list-like interface
1931 that contains integer revisions.
1934 that contains integer revisions.
1932 """
1935 """
1933 tree = revsetlang.spectree(expr, *args)
1936 tree = revsetlang.spectree(expr, *args)
1934 return revset.makematcher(tree)(self)
1937 return revset.makematcher(tree)(self)
1935
1938
1936 def set(self, expr, *args):
1939 def set(self, expr, *args):
1937 """Find revisions matching a revset and emit changectx instances.
1940 """Find revisions matching a revset and emit changectx instances.
1938
1941
1939 This is a convenience wrapper around ``revs()`` that iterates the
1942 This is a convenience wrapper around ``revs()`` that iterates the
1940 result and is a generator of changectx instances.
1943 result and is a generator of changectx instances.
1941
1944
1942 Revset aliases from the configuration are not expanded. To expand
1945 Revset aliases from the configuration are not expanded. To expand
1943 user aliases, consider calling ``scmutil.revrange()``.
1946 user aliases, consider calling ``scmutil.revrange()``.
1944 """
1947 """
1945 for r in self.revs(expr, *args):
1948 for r in self.revs(expr, *args):
1946 yield self[r]
1949 yield self[r]
1947
1950
1948 def anyrevs(self, specs, user=False, localalias=None):
1951 def anyrevs(self, specs, user=False, localalias=None):
1949 """Find revisions matching one of the given revsets.
1952 """Find revisions matching one of the given revsets.
1950
1953
1951 Revset aliases from the configuration are not expanded by default. To
1954 Revset aliases from the configuration are not expanded by default. To
1952 expand user aliases, specify ``user=True``. To provide some local
1955 expand user aliases, specify ``user=True``. To provide some local
1953 definitions overriding user aliases, set ``localalias`` to
1956 definitions overriding user aliases, set ``localalias`` to
1954 ``{name: definitionstring}``.
1957 ``{name: definitionstring}``.
1955 """
1958 """
1956 if specs == [b'null']:
1959 if specs == [b'null']:
1957 return revset.baseset([nullrev])
1960 return revset.baseset([nullrev])
1958 if specs == [b'.']:
1961 if specs == [b'.']:
1959 quick_data = self._quick_access_changeid.get(b'.')
1962 quick_data = self._quick_access_changeid.get(b'.')
1960 if quick_data is not None:
1963 if quick_data is not None:
1961 return revset.baseset([quick_data[0]])
1964 return revset.baseset([quick_data[0]])
1962 if user:
1965 if user:
1963 m = revset.matchany(
1966 m = revset.matchany(
1964 self.ui,
1967 self.ui,
1965 specs,
1968 specs,
1966 lookup=revset.lookupfn(self),
1969 lookup=revset.lookupfn(self),
1967 localalias=localalias,
1970 localalias=localalias,
1968 )
1971 )
1969 else:
1972 else:
1970 m = revset.matchany(None, specs, localalias=localalias)
1973 m = revset.matchany(None, specs, localalias=localalias)
1971 return m(self)
1974 return m(self)
1972
1975
1973 def url(self):
1976 def url(self):
1974 return b'file:' + self.root
1977 return b'file:' + self.root
1975
1978
1976 def hook(self, name, throw=False, **args):
1979 def hook(self, name, throw=False, **args):
1977 """Call a hook, passing this repo instance.
1980 """Call a hook, passing this repo instance.
1978
1981
1979 This a convenience method to aid invoking hooks. Extensions likely
1982 This a convenience method to aid invoking hooks. Extensions likely
1980 won't call this unless they have registered a custom hook or are
1983 won't call this unless they have registered a custom hook or are
1981 replacing code that is expected to call a hook.
1984 replacing code that is expected to call a hook.
1982 """
1985 """
1983 return hook.hook(self.ui, self, name, throw, **args)
1986 return hook.hook(self.ui, self, name, throw, **args)
1984
1987
1985 @filteredpropertycache
1988 @filteredpropertycache
1986 def _tagscache(self):
1989 def _tagscache(self):
1987 """Returns a tagscache object that contains various tags related
1990 """Returns a tagscache object that contains various tags related
1988 caches."""
1991 caches."""
1989
1992
1990 # This simplifies its cache management by having one decorated
1993 # This simplifies its cache management by having one decorated
1991 # function (this one) and the rest simply fetch things from it.
1994 # function (this one) and the rest simply fetch things from it.
1992 class tagscache(object):
1995 class tagscache(object):
1993 def __init__(self):
1996 def __init__(self):
1994 # These two define the set of tags for this repository. tags
1997 # These two define the set of tags for this repository. tags
1995 # maps tag name to node; tagtypes maps tag name to 'global' or
1998 # maps tag name to node; tagtypes maps tag name to 'global' or
1996 # 'local'. (Global tags are defined by .hgtags across all
1999 # 'local'. (Global tags are defined by .hgtags across all
1997 # heads, and local tags are defined in .hg/localtags.)
2000 # heads, and local tags are defined in .hg/localtags.)
1998 # They constitute the in-memory cache of tags.
2001 # They constitute the in-memory cache of tags.
1999 self.tags = self.tagtypes = None
2002 self.tags = self.tagtypes = None
2000
2003
2001 self.nodetagscache = self.tagslist = None
2004 self.nodetagscache = self.tagslist = None
2002
2005
2003 cache = tagscache()
2006 cache = tagscache()
2004 cache.tags, cache.tagtypes = self._findtags()
2007 cache.tags, cache.tagtypes = self._findtags()
2005
2008
2006 return cache
2009 return cache
2007
2010
2008 def tags(self):
2011 def tags(self):
2009 '''return a mapping of tag to node'''
2012 '''return a mapping of tag to node'''
2010 t = {}
2013 t = {}
2011 if self.changelog.filteredrevs:
2014 if self.changelog.filteredrevs:
2012 tags, tt = self._findtags()
2015 tags, tt = self._findtags()
2013 else:
2016 else:
2014 tags = self._tagscache.tags
2017 tags = self._tagscache.tags
2015 rev = self.changelog.rev
2018 rev = self.changelog.rev
2016 for k, v in pycompat.iteritems(tags):
2019 for k, v in pycompat.iteritems(tags):
2017 try:
2020 try:
2018 # ignore tags to unknown nodes
2021 # ignore tags to unknown nodes
2019 rev(v)
2022 rev(v)
2020 t[k] = v
2023 t[k] = v
2021 except (error.LookupError, ValueError):
2024 except (error.LookupError, ValueError):
2022 pass
2025 pass
2023 return t
2026 return t
2024
2027
2025 def _findtags(self):
2028 def _findtags(self):
2026 """Do the hard work of finding tags. Return a pair of dicts
2029 """Do the hard work of finding tags. Return a pair of dicts
2027 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2030 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2028 maps tag name to a string like \'global\' or \'local\'.
2031 maps tag name to a string like \'global\' or \'local\'.
2029 Subclasses or extensions are free to add their own tags, but
2032 Subclasses or extensions are free to add their own tags, but
2030 should be aware that the returned dicts will be retained for the
2033 should be aware that the returned dicts will be retained for the
2031 duration of the localrepo object."""
2034 duration of the localrepo object."""
2032
2035
2033 # XXX what tagtype should subclasses/extensions use? Currently
2036 # XXX what tagtype should subclasses/extensions use? Currently
2034 # mq and bookmarks add tags, but do not set the tagtype at all.
2037 # mq and bookmarks add tags, but do not set the tagtype at all.
2035 # Should each extension invent its own tag type? Should there
2038 # Should each extension invent its own tag type? Should there
2036 # be one tagtype for all such "virtual" tags? Or is the status
2039 # be one tagtype for all such "virtual" tags? Or is the status
2037 # quo fine?
2040 # quo fine?
2038
2041
2039 # map tag name to (node, hist)
2042 # map tag name to (node, hist)
2040 alltags = tagsmod.findglobaltags(self.ui, self)
2043 alltags = tagsmod.findglobaltags(self.ui, self)
2041 # map tag name to tag type
2044 # map tag name to tag type
2042 tagtypes = {tag: b'global' for tag in alltags}
2045 tagtypes = {tag: b'global' for tag in alltags}
2043
2046
2044 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2047 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2045
2048
2046 # Build the return dicts. Have to re-encode tag names because
2049 # Build the return dicts. Have to re-encode tag names because
2047 # the tags module always uses UTF-8 (in order not to lose info
2050 # the tags module always uses UTF-8 (in order not to lose info
2048 # writing to the cache), but the rest of Mercurial wants them in
2051 # writing to the cache), but the rest of Mercurial wants them in
2049 # local encoding.
2052 # local encoding.
2050 tags = {}
2053 tags = {}
2051 for (name, (node, hist)) in pycompat.iteritems(alltags):
2054 for (name, (node, hist)) in pycompat.iteritems(alltags):
2052 if node != self.nullid:
2055 if node != self.nullid:
2053 tags[encoding.tolocal(name)] = node
2056 tags[encoding.tolocal(name)] = node
2054 tags[b'tip'] = self.changelog.tip()
2057 tags[b'tip'] = self.changelog.tip()
2055 tagtypes = {
2058 tagtypes = {
2056 encoding.tolocal(name): value
2059 encoding.tolocal(name): value
2057 for (name, value) in pycompat.iteritems(tagtypes)
2060 for (name, value) in pycompat.iteritems(tagtypes)
2058 }
2061 }
2059 return (tags, tagtypes)
2062 return (tags, tagtypes)
2060
2063
2061 def tagtype(self, tagname):
2064 def tagtype(self, tagname):
2062 """
2065 """
2063 return the type of the given tag. result can be:
2066 return the type of the given tag. result can be:
2064
2067
2065 'local' : a local tag
2068 'local' : a local tag
2066 'global' : a global tag
2069 'global' : a global tag
2067 None : tag does not exist
2070 None : tag does not exist
2068 """
2071 """
2069
2072
2070 return self._tagscache.tagtypes.get(tagname)
2073 return self._tagscache.tagtypes.get(tagname)
2071
2074
2072 def tagslist(self):
2075 def tagslist(self):
2073 '''return a list of tags ordered by revision'''
2076 '''return a list of tags ordered by revision'''
2074 if not self._tagscache.tagslist:
2077 if not self._tagscache.tagslist:
2075 l = []
2078 l = []
2076 for t, n in pycompat.iteritems(self.tags()):
2079 for t, n in pycompat.iteritems(self.tags()):
2077 l.append((self.changelog.rev(n), t, n))
2080 l.append((self.changelog.rev(n), t, n))
2078 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2081 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2079
2082
2080 return self._tagscache.tagslist
2083 return self._tagscache.tagslist
2081
2084
2082 def nodetags(self, node):
2085 def nodetags(self, node):
2083 '''return the tags associated with a node'''
2086 '''return the tags associated with a node'''
2084 if not self._tagscache.nodetagscache:
2087 if not self._tagscache.nodetagscache:
2085 nodetagscache = {}
2088 nodetagscache = {}
2086 for t, n in pycompat.iteritems(self._tagscache.tags):
2089 for t, n in pycompat.iteritems(self._tagscache.tags):
2087 nodetagscache.setdefault(n, []).append(t)
2090 nodetagscache.setdefault(n, []).append(t)
2088 for tags in pycompat.itervalues(nodetagscache):
2091 for tags in pycompat.itervalues(nodetagscache):
2089 tags.sort()
2092 tags.sort()
2090 self._tagscache.nodetagscache = nodetagscache
2093 self._tagscache.nodetagscache = nodetagscache
2091 return self._tagscache.nodetagscache.get(node, [])
2094 return self._tagscache.nodetagscache.get(node, [])
2092
2095
2093 def nodebookmarks(self, node):
2096 def nodebookmarks(self, node):
2094 """return the list of bookmarks pointing to the specified node"""
2097 """return the list of bookmarks pointing to the specified node"""
2095 return self._bookmarks.names(node)
2098 return self._bookmarks.names(node)
2096
2099
2097 def branchmap(self):
2100 def branchmap(self):
2098 """returns a dictionary {branch: [branchheads]} with branchheads
2101 """returns a dictionary {branch: [branchheads]} with branchheads
2099 ordered by increasing revision number"""
2102 ordered by increasing revision number"""
2100 return self._branchcaches[self]
2103 return self._branchcaches[self]
2101
2104
2102 @unfilteredmethod
2105 @unfilteredmethod
2103 def revbranchcache(self):
2106 def revbranchcache(self):
2104 if not self._revbranchcache:
2107 if not self._revbranchcache:
2105 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2108 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2106 return self._revbranchcache
2109 return self._revbranchcache
2107
2110
2108 def register_changeset(self, rev, changelogrevision):
2111 def register_changeset(self, rev, changelogrevision):
2109 self.revbranchcache().setdata(rev, changelogrevision)
2112 self.revbranchcache().setdata(rev, changelogrevision)
2110
2113
2111 def branchtip(self, branch, ignoremissing=False):
2114 def branchtip(self, branch, ignoremissing=False):
2112 """return the tip node for a given branch
2115 """return the tip node for a given branch
2113
2116
2114 If ignoremissing is True, then this method will not raise an error.
2117 If ignoremissing is True, then this method will not raise an error.
2115 This is helpful for callers that only expect None for a missing branch
2118 This is helpful for callers that only expect None for a missing branch
2116 (e.g. namespace).
2119 (e.g. namespace).
2117
2120
2118 """
2121 """
2119 try:
2122 try:
2120 return self.branchmap().branchtip(branch)
2123 return self.branchmap().branchtip(branch)
2121 except KeyError:
2124 except KeyError:
2122 if not ignoremissing:
2125 if not ignoremissing:
2123 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2126 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2124 else:
2127 else:
2125 pass
2128 pass
2126
2129
2127 def lookup(self, key):
2130 def lookup(self, key):
2128 node = scmutil.revsymbol(self, key).node()
2131 node = scmutil.revsymbol(self, key).node()
2129 if node is None:
2132 if node is None:
2130 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2133 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2131 return node
2134 return node
2132
2135
2133 def lookupbranch(self, key):
2136 def lookupbranch(self, key):
2134 if self.branchmap().hasbranch(key):
2137 if self.branchmap().hasbranch(key):
2135 return key
2138 return key
2136
2139
2137 return scmutil.revsymbol(self, key).branch()
2140 return scmutil.revsymbol(self, key).branch()
2138
2141
2139 def known(self, nodes):
2142 def known(self, nodes):
2140 cl = self.changelog
2143 cl = self.changelog
2141 get_rev = cl.index.get_rev
2144 get_rev = cl.index.get_rev
2142 filtered = cl.filteredrevs
2145 filtered = cl.filteredrevs
2143 result = []
2146 result = []
2144 for n in nodes:
2147 for n in nodes:
2145 r = get_rev(n)
2148 r = get_rev(n)
2146 resp = not (r is None or r in filtered)
2149 resp = not (r is None or r in filtered)
2147 result.append(resp)
2150 result.append(resp)
2148 return result
2151 return result
2149
2152
2150 def local(self):
2153 def local(self):
2151 return self
2154 return self
2152
2155
2153 def publishing(self):
2156 def publishing(self):
2154 # it's safe (and desirable) to trust the publish flag unconditionally
2157 # it's safe (and desirable) to trust the publish flag unconditionally
2155 # so that we don't finalize changes shared between users via ssh or nfs
2158 # so that we don't finalize changes shared between users via ssh or nfs
2156 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2159 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2157
2160
2158 def cancopy(self):
2161 def cancopy(self):
2159 # so statichttprepo's override of local() works
2162 # so statichttprepo's override of local() works
2160 if not self.local():
2163 if not self.local():
2161 return False
2164 return False
2162 if not self.publishing():
2165 if not self.publishing():
2163 return True
2166 return True
2164 # if publishing we can't copy if there is filtered content
2167 # if publishing we can't copy if there is filtered content
2165 return not self.filtered(b'visible').changelog.filteredrevs
2168 return not self.filtered(b'visible').changelog.filteredrevs
2166
2169
2167 def shared(self):
2170 def shared(self):
2168 '''the type of shared repository (None if not shared)'''
2171 '''the type of shared repository (None if not shared)'''
2169 if self.sharedpath != self.path:
2172 if self.sharedpath != self.path:
2170 return b'store'
2173 return b'store'
2171 return None
2174 return None
2172
2175
2173 def wjoin(self, f, *insidef):
2176 def wjoin(self, f, *insidef):
2174 return self.vfs.reljoin(self.root, f, *insidef)
2177 return self.vfs.reljoin(self.root, f, *insidef)
2175
2178
2176 def setparents(self, p1, p2=None):
2179 def setparents(self, p1, p2=None):
2177 if p2 is None:
2180 if p2 is None:
2178 p2 = self.nullid
2181 p2 = self.nullid
2179 self[None].setparents(p1, p2)
2182 self[None].setparents(p1, p2)
2180 self._quick_access_changeid_invalidate()
2183 self._quick_access_changeid_invalidate()
2181
2184
2182 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2185 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2183 """changeid must be a changeset revision, if specified.
2186 """changeid must be a changeset revision, if specified.
2184 fileid can be a file revision or node."""
2187 fileid can be a file revision or node."""
2185 return context.filectx(
2188 return context.filectx(
2186 self, path, changeid, fileid, changectx=changectx
2189 self, path, changeid, fileid, changectx=changectx
2187 )
2190 )
2188
2191
2189 def getcwd(self):
2192 def getcwd(self):
2190 return self.dirstate.getcwd()
2193 return self.dirstate.getcwd()
2191
2194
2192 def pathto(self, f, cwd=None):
2195 def pathto(self, f, cwd=None):
2193 return self.dirstate.pathto(f, cwd)
2196 return self.dirstate.pathto(f, cwd)
2194
2197
2195 def _loadfilter(self, filter):
2198 def _loadfilter(self, filter):
2196 if filter not in self._filterpats:
2199 if filter not in self._filterpats:
2197 l = []
2200 l = []
2198 for pat, cmd in self.ui.configitems(filter):
2201 for pat, cmd in self.ui.configitems(filter):
2199 if cmd == b'!':
2202 if cmd == b'!':
2200 continue
2203 continue
2201 mf = matchmod.match(self.root, b'', [pat])
2204 mf = matchmod.match(self.root, b'', [pat])
2202 fn = None
2205 fn = None
2203 params = cmd
2206 params = cmd
2204 for name, filterfn in pycompat.iteritems(self._datafilters):
2207 for name, filterfn in pycompat.iteritems(self._datafilters):
2205 if cmd.startswith(name):
2208 if cmd.startswith(name):
2206 fn = filterfn
2209 fn = filterfn
2207 params = cmd[len(name) :].lstrip()
2210 params = cmd[len(name) :].lstrip()
2208 break
2211 break
2209 if not fn:
2212 if not fn:
2210 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2213 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2211 fn.__name__ = 'commandfilter'
2214 fn.__name__ = 'commandfilter'
2212 # Wrap old filters not supporting keyword arguments
2215 # Wrap old filters not supporting keyword arguments
2213 if not pycompat.getargspec(fn)[2]:
2216 if not pycompat.getargspec(fn)[2]:
2214 oldfn = fn
2217 oldfn = fn
2215 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2218 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2216 fn.__name__ = 'compat-' + oldfn.__name__
2219 fn.__name__ = 'compat-' + oldfn.__name__
2217 l.append((mf, fn, params))
2220 l.append((mf, fn, params))
2218 self._filterpats[filter] = l
2221 self._filterpats[filter] = l
2219 return self._filterpats[filter]
2222 return self._filterpats[filter]
2220
2223
2221 def _filter(self, filterpats, filename, data):
2224 def _filter(self, filterpats, filename, data):
2222 for mf, fn, cmd in filterpats:
2225 for mf, fn, cmd in filterpats:
2223 if mf(filename):
2226 if mf(filename):
2224 self.ui.debug(
2227 self.ui.debug(
2225 b"filtering %s through %s\n"
2228 b"filtering %s through %s\n"
2226 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2229 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2227 )
2230 )
2228 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2231 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2229 break
2232 break
2230
2233
2231 return data
2234 return data
2232
2235
2233 @unfilteredpropertycache
2236 @unfilteredpropertycache
2234 def _encodefilterpats(self):
2237 def _encodefilterpats(self):
2235 return self._loadfilter(b'encode')
2238 return self._loadfilter(b'encode')
2236
2239
2237 @unfilteredpropertycache
2240 @unfilteredpropertycache
2238 def _decodefilterpats(self):
2241 def _decodefilterpats(self):
2239 return self._loadfilter(b'decode')
2242 return self._loadfilter(b'decode')
2240
2243
2241 def adddatafilter(self, name, filter):
2244 def adddatafilter(self, name, filter):
2242 self._datafilters[name] = filter
2245 self._datafilters[name] = filter
2243
2246
2244 def wread(self, filename):
2247 def wread(self, filename):
2245 if self.wvfs.islink(filename):
2248 if self.wvfs.islink(filename):
2246 data = self.wvfs.readlink(filename)
2249 data = self.wvfs.readlink(filename)
2247 else:
2250 else:
2248 data = self.wvfs.read(filename)
2251 data = self.wvfs.read(filename)
2249 return self._filter(self._encodefilterpats, filename, data)
2252 return self._filter(self._encodefilterpats, filename, data)
2250
2253
2251 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2254 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2252 """write ``data`` into ``filename`` in the working directory
2255 """write ``data`` into ``filename`` in the working directory
2253
2256
2254 This returns length of written (maybe decoded) data.
2257 This returns length of written (maybe decoded) data.
2255 """
2258 """
2256 data = self._filter(self._decodefilterpats, filename, data)
2259 data = self._filter(self._decodefilterpats, filename, data)
2257 if b'l' in flags:
2260 if b'l' in flags:
2258 self.wvfs.symlink(data, filename)
2261 self.wvfs.symlink(data, filename)
2259 else:
2262 else:
2260 self.wvfs.write(
2263 self.wvfs.write(
2261 filename, data, backgroundclose=backgroundclose, **kwargs
2264 filename, data, backgroundclose=backgroundclose, **kwargs
2262 )
2265 )
2263 if b'x' in flags:
2266 if b'x' in flags:
2264 self.wvfs.setflags(filename, False, True)
2267 self.wvfs.setflags(filename, False, True)
2265 else:
2268 else:
2266 self.wvfs.setflags(filename, False, False)
2269 self.wvfs.setflags(filename, False, False)
2267 return len(data)
2270 return len(data)
2268
2271
2269 def wwritedata(self, filename, data):
2272 def wwritedata(self, filename, data):
2270 return self._filter(self._decodefilterpats, filename, data)
2273 return self._filter(self._decodefilterpats, filename, data)
2271
2274
2272 def currenttransaction(self):
2275 def currenttransaction(self):
2273 """return the current transaction or None if non exists"""
2276 """return the current transaction or None if non exists"""
2274 if self._transref:
2277 if self._transref:
2275 tr = self._transref()
2278 tr = self._transref()
2276 else:
2279 else:
2277 tr = None
2280 tr = None
2278
2281
2279 if tr and tr.running():
2282 if tr and tr.running():
2280 return tr
2283 return tr
2281 return None
2284 return None
2282
2285
2283 def transaction(self, desc, report=None):
2286 def transaction(self, desc, report=None):
2284 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2287 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2285 b'devel', b'check-locks'
2288 b'devel', b'check-locks'
2286 ):
2289 ):
2287 if self._currentlock(self._lockref) is None:
2290 if self._currentlock(self._lockref) is None:
2288 raise error.ProgrammingError(b'transaction requires locking')
2291 raise error.ProgrammingError(b'transaction requires locking')
2289 tr = self.currenttransaction()
2292 tr = self.currenttransaction()
2290 if tr is not None:
2293 if tr is not None:
2291 return tr.nest(name=desc)
2294 return tr.nest(name=desc)
2292
2295
2293 # abort here if the journal already exists
2296 # abort here if the journal already exists
2294 if self.svfs.exists(b"journal"):
2297 if self.svfs.exists(b"journal"):
2295 raise error.RepoError(
2298 raise error.RepoError(
2296 _(b"abandoned transaction found"),
2299 _(b"abandoned transaction found"),
2297 hint=_(b"run 'hg recover' to clean up transaction"),
2300 hint=_(b"run 'hg recover' to clean up transaction"),
2298 )
2301 )
2299
2302
2300 idbase = b"%.40f#%f" % (random.random(), time.time())
2303 idbase = b"%.40f#%f" % (random.random(), time.time())
2301 ha = hex(hashutil.sha1(idbase).digest())
2304 ha = hex(hashutil.sha1(idbase).digest())
2302 txnid = b'TXN:' + ha
2305 txnid = b'TXN:' + ha
2303 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2306 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2304
2307
2305 self._writejournal(desc)
2308 self._writejournal(desc)
2306 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2309 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2307 if report:
2310 if report:
2308 rp = report
2311 rp = report
2309 else:
2312 else:
2310 rp = self.ui.warn
2313 rp = self.ui.warn
2311 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2314 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2312 # we must avoid cyclic reference between repo and transaction.
2315 # we must avoid cyclic reference between repo and transaction.
2313 reporef = weakref.ref(self)
2316 reporef = weakref.ref(self)
2314 # Code to track tag movement
2317 # Code to track tag movement
2315 #
2318 #
2316 # Since tags are all handled as file content, it is actually quite hard
2319 # Since tags are all handled as file content, it is actually quite hard
2317 # to track these movement from a code perspective. So we fallback to a
2320 # to track these movement from a code perspective. So we fallback to a
2318 # tracking at the repository level. One could envision to track changes
2321 # tracking at the repository level. One could envision to track changes
2319 # to the '.hgtags' file through changegroup apply but that fails to
2322 # to the '.hgtags' file through changegroup apply but that fails to
2320 # cope with case where transaction expose new heads without changegroup
2323 # cope with case where transaction expose new heads without changegroup
2321 # being involved (eg: phase movement).
2324 # being involved (eg: phase movement).
2322 #
2325 #
2323 # For now, We gate the feature behind a flag since this likely comes
2326 # For now, We gate the feature behind a flag since this likely comes
2324 # with performance impacts. The current code run more often than needed
2327 # with performance impacts. The current code run more often than needed
2325 # and do not use caches as much as it could. The current focus is on
2328 # and do not use caches as much as it could. The current focus is on
2326 # the behavior of the feature so we disable it by default. The flag
2329 # the behavior of the feature so we disable it by default. The flag
2327 # will be removed when we are happy with the performance impact.
2330 # will be removed when we are happy with the performance impact.
2328 #
2331 #
2329 # Once this feature is no longer experimental move the following
2332 # Once this feature is no longer experimental move the following
2330 # documentation to the appropriate help section:
2333 # documentation to the appropriate help section:
2331 #
2334 #
2332 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2335 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2333 # tags (new or changed or deleted tags). In addition the details of
2336 # tags (new or changed or deleted tags). In addition the details of
2334 # these changes are made available in a file at:
2337 # these changes are made available in a file at:
2335 # ``REPOROOT/.hg/changes/tags.changes``.
2338 # ``REPOROOT/.hg/changes/tags.changes``.
2336 # Make sure you check for HG_TAG_MOVED before reading that file as it
2339 # Make sure you check for HG_TAG_MOVED before reading that file as it
2337 # might exist from a previous transaction even if no tag were touched
2340 # might exist from a previous transaction even if no tag were touched
2338 # in this one. Changes are recorded in a line base format::
2341 # in this one. Changes are recorded in a line base format::
2339 #
2342 #
2340 # <action> <hex-node> <tag-name>\n
2343 # <action> <hex-node> <tag-name>\n
2341 #
2344 #
2342 # Actions are defined as follow:
2345 # Actions are defined as follow:
2343 # "-R": tag is removed,
2346 # "-R": tag is removed,
2344 # "+A": tag is added,
2347 # "+A": tag is added,
2345 # "-M": tag is moved (old value),
2348 # "-M": tag is moved (old value),
2346 # "+M": tag is moved (new value),
2349 # "+M": tag is moved (new value),
2347 tracktags = lambda x: None
2350 tracktags = lambda x: None
2348 # experimental config: experimental.hook-track-tags
2351 # experimental config: experimental.hook-track-tags
2349 shouldtracktags = self.ui.configbool(
2352 shouldtracktags = self.ui.configbool(
2350 b'experimental', b'hook-track-tags'
2353 b'experimental', b'hook-track-tags'
2351 )
2354 )
2352 if desc != b'strip' and shouldtracktags:
2355 if desc != b'strip' and shouldtracktags:
2353 oldheads = self.changelog.headrevs()
2356 oldheads = self.changelog.headrevs()
2354
2357
2355 def tracktags(tr2):
2358 def tracktags(tr2):
2356 repo = reporef()
2359 repo = reporef()
2357 assert repo is not None # help pytype
2360 assert repo is not None # help pytype
2358 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2361 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2359 newheads = repo.changelog.headrevs()
2362 newheads = repo.changelog.headrevs()
2360 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2363 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2361 # notes: we compare lists here.
2364 # notes: we compare lists here.
2362 # As we do it only once buiding set would not be cheaper
2365 # As we do it only once buiding set would not be cheaper
2363 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2366 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2364 if changes:
2367 if changes:
2365 tr2.hookargs[b'tag_moved'] = b'1'
2368 tr2.hookargs[b'tag_moved'] = b'1'
2366 with repo.vfs(
2369 with repo.vfs(
2367 b'changes/tags.changes', b'w', atomictemp=True
2370 b'changes/tags.changes', b'w', atomictemp=True
2368 ) as changesfile:
2371 ) as changesfile:
2369 # note: we do not register the file to the transaction
2372 # note: we do not register the file to the transaction
2370 # because we needs it to still exist on the transaction
2373 # because we needs it to still exist on the transaction
2371 # is close (for txnclose hooks)
2374 # is close (for txnclose hooks)
2372 tagsmod.writediff(changesfile, changes)
2375 tagsmod.writediff(changesfile, changes)
2373
2376
2374 def validate(tr2):
2377 def validate(tr2):
2375 """will run pre-closing hooks"""
2378 """will run pre-closing hooks"""
2376 # XXX the transaction API is a bit lacking here so we take a hacky
2379 # XXX the transaction API is a bit lacking here so we take a hacky
2377 # path for now
2380 # path for now
2378 #
2381 #
2379 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2382 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2380 # dict is copied before these run. In addition we needs the data
2383 # dict is copied before these run. In addition we needs the data
2381 # available to in memory hooks too.
2384 # available to in memory hooks too.
2382 #
2385 #
2383 # Moreover, we also need to make sure this runs before txnclose
2386 # Moreover, we also need to make sure this runs before txnclose
2384 # hooks and there is no "pending" mechanism that would execute
2387 # hooks and there is no "pending" mechanism that would execute
2385 # logic only if hooks are about to run.
2388 # logic only if hooks are about to run.
2386 #
2389 #
2387 # Fixing this limitation of the transaction is also needed to track
2390 # Fixing this limitation of the transaction is also needed to track
2388 # other families of changes (bookmarks, phases, obsolescence).
2391 # other families of changes (bookmarks, phases, obsolescence).
2389 #
2392 #
2390 # This will have to be fixed before we remove the experimental
2393 # This will have to be fixed before we remove the experimental
2391 # gating.
2394 # gating.
2392 tracktags(tr2)
2395 tracktags(tr2)
2393 repo = reporef()
2396 repo = reporef()
2394 assert repo is not None # help pytype
2397 assert repo is not None # help pytype
2395
2398
2396 singleheadopt = (b'experimental', b'single-head-per-branch')
2399 singleheadopt = (b'experimental', b'single-head-per-branch')
2397 singlehead = repo.ui.configbool(*singleheadopt)
2400 singlehead = repo.ui.configbool(*singleheadopt)
2398 if singlehead:
2401 if singlehead:
2399 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2402 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2400 accountclosed = singleheadsub.get(
2403 accountclosed = singleheadsub.get(
2401 b"account-closed-heads", False
2404 b"account-closed-heads", False
2402 )
2405 )
2403 if singleheadsub.get(b"public-changes-only", False):
2406 if singleheadsub.get(b"public-changes-only", False):
2404 filtername = b"immutable"
2407 filtername = b"immutable"
2405 else:
2408 else:
2406 filtername = b"visible"
2409 filtername = b"visible"
2407 scmutil.enforcesinglehead(
2410 scmutil.enforcesinglehead(
2408 repo, tr2, desc, accountclosed, filtername
2411 repo, tr2, desc, accountclosed, filtername
2409 )
2412 )
2410 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2413 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2411 for name, (old, new) in sorted(
2414 for name, (old, new) in sorted(
2412 tr.changes[b'bookmarks'].items()
2415 tr.changes[b'bookmarks'].items()
2413 ):
2416 ):
2414 args = tr.hookargs.copy()
2417 args = tr.hookargs.copy()
2415 args.update(bookmarks.preparehookargs(name, old, new))
2418 args.update(bookmarks.preparehookargs(name, old, new))
2416 repo.hook(
2419 repo.hook(
2417 b'pretxnclose-bookmark',
2420 b'pretxnclose-bookmark',
2418 throw=True,
2421 throw=True,
2419 **pycompat.strkwargs(args)
2422 **pycompat.strkwargs(args)
2420 )
2423 )
2421 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2424 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2422 cl = repo.unfiltered().changelog
2425 cl = repo.unfiltered().changelog
2423 for revs, (old, new) in tr.changes[b'phases']:
2426 for revs, (old, new) in tr.changes[b'phases']:
2424 for rev in revs:
2427 for rev in revs:
2425 args = tr.hookargs.copy()
2428 args = tr.hookargs.copy()
2426 node = hex(cl.node(rev))
2429 node = hex(cl.node(rev))
2427 args.update(phases.preparehookargs(node, old, new))
2430 args.update(phases.preparehookargs(node, old, new))
2428 repo.hook(
2431 repo.hook(
2429 b'pretxnclose-phase',
2432 b'pretxnclose-phase',
2430 throw=True,
2433 throw=True,
2431 **pycompat.strkwargs(args)
2434 **pycompat.strkwargs(args)
2432 )
2435 )
2433
2436
2434 repo.hook(
2437 repo.hook(
2435 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2438 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2436 )
2439 )
2437
2440
2438 def releasefn(tr, success):
2441 def releasefn(tr, success):
2439 repo = reporef()
2442 repo = reporef()
2440 if repo is None:
2443 if repo is None:
2441 # If the repo has been GC'd (and this release function is being
2444 # If the repo has been GC'd (and this release function is being
2442 # called from transaction.__del__), there's not much we can do,
2445 # called from transaction.__del__), there's not much we can do,
2443 # so just leave the unfinished transaction there and let the
2446 # so just leave the unfinished transaction there and let the
2444 # user run `hg recover`.
2447 # user run `hg recover`.
2445 return
2448 return
2446 if success:
2449 if success:
2447 # this should be explicitly invoked here, because
2450 # this should be explicitly invoked here, because
2448 # in-memory changes aren't written out at closing
2451 # in-memory changes aren't written out at closing
2449 # transaction, if tr.addfilegenerator (via
2452 # transaction, if tr.addfilegenerator (via
2450 # dirstate.write or so) isn't invoked while
2453 # dirstate.write or so) isn't invoked while
2451 # transaction running
2454 # transaction running
2452 repo.dirstate.write(None)
2455 repo.dirstate.write(None)
2453 else:
2456 else:
2454 # discard all changes (including ones already written
2457 # discard all changes (including ones already written
2455 # out) in this transaction
2458 # out) in this transaction
2456 narrowspec.restorebackup(self, b'journal.narrowspec')
2459 narrowspec.restorebackup(self, b'journal.narrowspec')
2457 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2460 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2458 repo.dirstate.restorebackup(None, b'journal.dirstate')
2461 repo.dirstate.restorebackup(None, b'journal.dirstate')
2459
2462
2460 repo.invalidate(clearfilecache=True)
2463 repo.invalidate(clearfilecache=True)
2461
2464
2462 tr = transaction.transaction(
2465 tr = transaction.transaction(
2463 rp,
2466 rp,
2464 self.svfs,
2467 self.svfs,
2465 vfsmap,
2468 vfsmap,
2466 b"journal",
2469 b"journal",
2467 b"undo",
2470 b"undo",
2468 aftertrans(renames),
2471 aftertrans(renames),
2469 self.store.createmode,
2472 self.store.createmode,
2470 validator=validate,
2473 validator=validate,
2471 releasefn=releasefn,
2474 releasefn=releasefn,
2472 checkambigfiles=_cachedfiles,
2475 checkambigfiles=_cachedfiles,
2473 name=desc,
2476 name=desc,
2474 )
2477 )
2475 tr.changes[b'origrepolen'] = len(self)
2478 tr.changes[b'origrepolen'] = len(self)
2476 tr.changes[b'obsmarkers'] = set()
2479 tr.changes[b'obsmarkers'] = set()
2477 tr.changes[b'phases'] = []
2480 tr.changes[b'phases'] = []
2478 tr.changes[b'bookmarks'] = {}
2481 tr.changes[b'bookmarks'] = {}
2479
2482
2480 tr.hookargs[b'txnid'] = txnid
2483 tr.hookargs[b'txnid'] = txnid
2481 tr.hookargs[b'txnname'] = desc
2484 tr.hookargs[b'txnname'] = desc
2482 tr.hookargs[b'changes'] = tr.changes
2485 tr.hookargs[b'changes'] = tr.changes
2483 # note: writing the fncache only during finalize mean that the file is
2486 # note: writing the fncache only during finalize mean that the file is
2484 # outdated when running hooks. As fncache is used for streaming clone,
2487 # outdated when running hooks. As fncache is used for streaming clone,
2485 # this is not expected to break anything that happen during the hooks.
2488 # this is not expected to break anything that happen during the hooks.
2486 tr.addfinalize(b'flush-fncache', self.store.write)
2489 tr.addfinalize(b'flush-fncache', self.store.write)
2487
2490
2488 def txnclosehook(tr2):
2491 def txnclosehook(tr2):
2489 """To be run if transaction is successful, will schedule a hook run"""
2492 """To be run if transaction is successful, will schedule a hook run"""
2490 # Don't reference tr2 in hook() so we don't hold a reference.
2493 # Don't reference tr2 in hook() so we don't hold a reference.
2491 # This reduces memory consumption when there are multiple
2494 # This reduces memory consumption when there are multiple
2492 # transactions per lock. This can likely go away if issue5045
2495 # transactions per lock. This can likely go away if issue5045
2493 # fixes the function accumulation.
2496 # fixes the function accumulation.
2494 hookargs = tr2.hookargs
2497 hookargs = tr2.hookargs
2495
2498
2496 def hookfunc(unused_success):
2499 def hookfunc(unused_success):
2497 repo = reporef()
2500 repo = reporef()
2498 assert repo is not None # help pytype
2501 assert repo is not None # help pytype
2499
2502
2500 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2503 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2501 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2504 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2502 for name, (old, new) in bmchanges:
2505 for name, (old, new) in bmchanges:
2503 args = tr.hookargs.copy()
2506 args = tr.hookargs.copy()
2504 args.update(bookmarks.preparehookargs(name, old, new))
2507 args.update(bookmarks.preparehookargs(name, old, new))
2505 repo.hook(
2508 repo.hook(
2506 b'txnclose-bookmark',
2509 b'txnclose-bookmark',
2507 throw=False,
2510 throw=False,
2508 **pycompat.strkwargs(args)
2511 **pycompat.strkwargs(args)
2509 )
2512 )
2510
2513
2511 if hook.hashook(repo.ui, b'txnclose-phase'):
2514 if hook.hashook(repo.ui, b'txnclose-phase'):
2512 cl = repo.unfiltered().changelog
2515 cl = repo.unfiltered().changelog
2513 phasemv = sorted(
2516 phasemv = sorted(
2514 tr.changes[b'phases'], key=lambda r: r[0][0]
2517 tr.changes[b'phases'], key=lambda r: r[0][0]
2515 )
2518 )
2516 for revs, (old, new) in phasemv:
2519 for revs, (old, new) in phasemv:
2517 for rev in revs:
2520 for rev in revs:
2518 args = tr.hookargs.copy()
2521 args = tr.hookargs.copy()
2519 node = hex(cl.node(rev))
2522 node = hex(cl.node(rev))
2520 args.update(phases.preparehookargs(node, old, new))
2523 args.update(phases.preparehookargs(node, old, new))
2521 repo.hook(
2524 repo.hook(
2522 b'txnclose-phase',
2525 b'txnclose-phase',
2523 throw=False,
2526 throw=False,
2524 **pycompat.strkwargs(args)
2527 **pycompat.strkwargs(args)
2525 )
2528 )
2526
2529
2527 repo.hook(
2530 repo.hook(
2528 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2531 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2529 )
2532 )
2530
2533
2531 repo = reporef()
2534 repo = reporef()
2532 assert repo is not None # help pytype
2535 assert repo is not None # help pytype
2533 repo._afterlock(hookfunc)
2536 repo._afterlock(hookfunc)
2534
2537
2535 tr.addfinalize(b'txnclose-hook', txnclosehook)
2538 tr.addfinalize(b'txnclose-hook', txnclosehook)
2536 # Include a leading "-" to make it happen before the transaction summary
2539 # Include a leading "-" to make it happen before the transaction summary
2537 # reports registered via scmutil.registersummarycallback() whose names
2540 # reports registered via scmutil.registersummarycallback() whose names
2538 # are 00-txnreport etc. That way, the caches will be warm when the
2541 # are 00-txnreport etc. That way, the caches will be warm when the
2539 # callbacks run.
2542 # callbacks run.
2540 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2543 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2541
2544
2542 def txnaborthook(tr2):
2545 def txnaborthook(tr2):
2543 """To be run if transaction is aborted"""
2546 """To be run if transaction is aborted"""
2544 repo = reporef()
2547 repo = reporef()
2545 assert repo is not None # help pytype
2548 assert repo is not None # help pytype
2546 repo.hook(
2549 repo.hook(
2547 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2550 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2548 )
2551 )
2549
2552
2550 tr.addabort(b'txnabort-hook', txnaborthook)
2553 tr.addabort(b'txnabort-hook', txnaborthook)
2551 # avoid eager cache invalidation. in-memory data should be identical
2554 # avoid eager cache invalidation. in-memory data should be identical
2552 # to stored data if transaction has no error.
2555 # to stored data if transaction has no error.
2553 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2556 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2554 self._transref = weakref.ref(tr)
2557 self._transref = weakref.ref(tr)
2555 scmutil.registersummarycallback(self, tr, desc)
2558 scmutil.registersummarycallback(self, tr, desc)
2556 return tr
2559 return tr
2557
2560
2558 def _journalfiles(self):
2561 def _journalfiles(self):
2559 return (
2562 return (
2560 (self.svfs, b'journal'),
2563 (self.svfs, b'journal'),
2561 (self.svfs, b'journal.narrowspec'),
2564 (self.svfs, b'journal.narrowspec'),
2562 (self.vfs, b'journal.narrowspec.dirstate'),
2565 (self.vfs, b'journal.narrowspec.dirstate'),
2563 (self.vfs, b'journal.dirstate'),
2566 (self.vfs, b'journal.dirstate'),
2564 (self.vfs, b'journal.branch'),
2567 (self.vfs, b'journal.branch'),
2565 (self.vfs, b'journal.desc'),
2568 (self.vfs, b'journal.desc'),
2566 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2569 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2567 (self.svfs, b'journal.phaseroots'),
2570 (self.svfs, b'journal.phaseroots'),
2568 )
2571 )
2569
2572
2570 def undofiles(self):
2573 def undofiles(self):
2571 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2574 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2572
2575
2573 @unfilteredmethod
2576 @unfilteredmethod
2574 def _writejournal(self, desc):
2577 def _writejournal(self, desc):
2575 self.dirstate.savebackup(None, b'journal.dirstate')
2578 self.dirstate.savebackup(None, b'journal.dirstate')
2576 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2579 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2577 narrowspec.savebackup(self, b'journal.narrowspec')
2580 narrowspec.savebackup(self, b'journal.narrowspec')
2578 self.vfs.write(
2581 self.vfs.write(
2579 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2582 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2580 )
2583 )
2581 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2584 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2582 bookmarksvfs = bookmarks.bookmarksvfs(self)
2585 bookmarksvfs = bookmarks.bookmarksvfs(self)
2583 bookmarksvfs.write(
2586 bookmarksvfs.write(
2584 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2587 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2585 )
2588 )
2586 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2589 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2587
2590
2588 def recover(self):
2591 def recover(self):
2589 with self.lock():
2592 with self.lock():
2590 if self.svfs.exists(b"journal"):
2593 if self.svfs.exists(b"journal"):
2591 self.ui.status(_(b"rolling back interrupted transaction\n"))
2594 self.ui.status(_(b"rolling back interrupted transaction\n"))
2592 vfsmap = {
2595 vfsmap = {
2593 b'': self.svfs,
2596 b'': self.svfs,
2594 b'plain': self.vfs,
2597 b'plain': self.vfs,
2595 }
2598 }
2596 transaction.rollback(
2599 transaction.rollback(
2597 self.svfs,
2600 self.svfs,
2598 vfsmap,
2601 vfsmap,
2599 b"journal",
2602 b"journal",
2600 self.ui.warn,
2603 self.ui.warn,
2601 checkambigfiles=_cachedfiles,
2604 checkambigfiles=_cachedfiles,
2602 )
2605 )
2603 self.invalidate()
2606 self.invalidate()
2604 return True
2607 return True
2605 else:
2608 else:
2606 self.ui.warn(_(b"no interrupted transaction available\n"))
2609 self.ui.warn(_(b"no interrupted transaction available\n"))
2607 return False
2610 return False
2608
2611
2609 def rollback(self, dryrun=False, force=False):
2612 def rollback(self, dryrun=False, force=False):
2610 wlock = lock = dsguard = None
2613 wlock = lock = dsguard = None
2611 try:
2614 try:
2612 wlock = self.wlock()
2615 wlock = self.wlock()
2613 lock = self.lock()
2616 lock = self.lock()
2614 if self.svfs.exists(b"undo"):
2617 if self.svfs.exists(b"undo"):
2615 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2618 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2616
2619
2617 return self._rollback(dryrun, force, dsguard)
2620 return self._rollback(dryrun, force, dsguard)
2618 else:
2621 else:
2619 self.ui.warn(_(b"no rollback information available\n"))
2622 self.ui.warn(_(b"no rollback information available\n"))
2620 return 1
2623 return 1
2621 finally:
2624 finally:
2622 release(dsguard, lock, wlock)
2625 release(dsguard, lock, wlock)
2623
2626
2624 @unfilteredmethod # Until we get smarter cache management
2627 @unfilteredmethod # Until we get smarter cache management
2625 def _rollback(self, dryrun, force, dsguard):
2628 def _rollback(self, dryrun, force, dsguard):
2626 ui = self.ui
2629 ui = self.ui
2627 try:
2630 try:
2628 args = self.vfs.read(b'undo.desc').splitlines()
2631 args = self.vfs.read(b'undo.desc').splitlines()
2629 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2632 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2630 if len(args) >= 3:
2633 if len(args) >= 3:
2631 detail = args[2]
2634 detail = args[2]
2632 oldtip = oldlen - 1
2635 oldtip = oldlen - 1
2633
2636
2634 if detail and ui.verbose:
2637 if detail and ui.verbose:
2635 msg = _(
2638 msg = _(
2636 b'repository tip rolled back to revision %d'
2639 b'repository tip rolled back to revision %d'
2637 b' (undo %s: %s)\n'
2640 b' (undo %s: %s)\n'
2638 ) % (oldtip, desc, detail)
2641 ) % (oldtip, desc, detail)
2639 else:
2642 else:
2640 msg = _(
2643 msg = _(
2641 b'repository tip rolled back to revision %d (undo %s)\n'
2644 b'repository tip rolled back to revision %d (undo %s)\n'
2642 ) % (oldtip, desc)
2645 ) % (oldtip, desc)
2643 except IOError:
2646 except IOError:
2644 msg = _(b'rolling back unknown transaction\n')
2647 msg = _(b'rolling back unknown transaction\n')
2645 desc = None
2648 desc = None
2646
2649
2647 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2650 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2648 raise error.Abort(
2651 raise error.Abort(
2649 _(
2652 _(
2650 b'rollback of last commit while not checked out '
2653 b'rollback of last commit while not checked out '
2651 b'may lose data'
2654 b'may lose data'
2652 ),
2655 ),
2653 hint=_(b'use -f to force'),
2656 hint=_(b'use -f to force'),
2654 )
2657 )
2655
2658
2656 ui.status(msg)
2659 ui.status(msg)
2657 if dryrun:
2660 if dryrun:
2658 return 0
2661 return 0
2659
2662
2660 parents = self.dirstate.parents()
2663 parents = self.dirstate.parents()
2661 self.destroying()
2664 self.destroying()
2662 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2665 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2663 transaction.rollback(
2666 transaction.rollback(
2664 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2667 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2665 )
2668 )
2666 bookmarksvfs = bookmarks.bookmarksvfs(self)
2669 bookmarksvfs = bookmarks.bookmarksvfs(self)
2667 if bookmarksvfs.exists(b'undo.bookmarks'):
2670 if bookmarksvfs.exists(b'undo.bookmarks'):
2668 bookmarksvfs.rename(
2671 bookmarksvfs.rename(
2669 b'undo.bookmarks', b'bookmarks', checkambig=True
2672 b'undo.bookmarks', b'bookmarks', checkambig=True
2670 )
2673 )
2671 if self.svfs.exists(b'undo.phaseroots'):
2674 if self.svfs.exists(b'undo.phaseroots'):
2672 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2675 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2673 self.invalidate()
2676 self.invalidate()
2674
2677
2675 has_node = self.changelog.index.has_node
2678 has_node = self.changelog.index.has_node
2676 parentgone = any(not has_node(p) for p in parents)
2679 parentgone = any(not has_node(p) for p in parents)
2677 if parentgone:
2680 if parentgone:
2678 # prevent dirstateguard from overwriting already restored one
2681 # prevent dirstateguard from overwriting already restored one
2679 dsguard.close()
2682 dsguard.close()
2680
2683
2681 narrowspec.restorebackup(self, b'undo.narrowspec')
2684 narrowspec.restorebackup(self, b'undo.narrowspec')
2682 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2685 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2683 self.dirstate.restorebackup(None, b'undo.dirstate')
2686 self.dirstate.restorebackup(None, b'undo.dirstate')
2684 try:
2687 try:
2685 branch = self.vfs.read(b'undo.branch')
2688 branch = self.vfs.read(b'undo.branch')
2686 self.dirstate.setbranch(encoding.tolocal(branch))
2689 self.dirstate.setbranch(encoding.tolocal(branch))
2687 except IOError:
2690 except IOError:
2688 ui.warn(
2691 ui.warn(
2689 _(
2692 _(
2690 b'named branch could not be reset: '
2693 b'named branch could not be reset: '
2691 b'current branch is still \'%s\'\n'
2694 b'current branch is still \'%s\'\n'
2692 )
2695 )
2693 % self.dirstate.branch()
2696 % self.dirstate.branch()
2694 )
2697 )
2695
2698
2696 parents = tuple([p.rev() for p in self[None].parents()])
2699 parents = tuple([p.rev() for p in self[None].parents()])
2697 if len(parents) > 1:
2700 if len(parents) > 1:
2698 ui.status(
2701 ui.status(
2699 _(
2702 _(
2700 b'working directory now based on '
2703 b'working directory now based on '
2701 b'revisions %d and %d\n'
2704 b'revisions %d and %d\n'
2702 )
2705 )
2703 % parents
2706 % parents
2704 )
2707 )
2705 else:
2708 else:
2706 ui.status(
2709 ui.status(
2707 _(b'working directory now based on revision %d\n') % parents
2710 _(b'working directory now based on revision %d\n') % parents
2708 )
2711 )
2709 mergestatemod.mergestate.clean(self)
2712 mergestatemod.mergestate.clean(self)
2710
2713
2711 # TODO: if we know which new heads may result from this rollback, pass
2714 # TODO: if we know which new heads may result from this rollback, pass
2712 # them to destroy(), which will prevent the branchhead cache from being
2715 # them to destroy(), which will prevent the branchhead cache from being
2713 # invalidated.
2716 # invalidated.
2714 self.destroyed()
2717 self.destroyed()
2715 return 0
2718 return 0
2716
2719
2717 def _buildcacheupdater(self, newtransaction):
2720 def _buildcacheupdater(self, newtransaction):
2718 """called during transaction to build the callback updating cache
2721 """called during transaction to build the callback updating cache
2719
2722
2720 Lives on the repository to help extension who might want to augment
2723 Lives on the repository to help extension who might want to augment
2721 this logic. For this purpose, the created transaction is passed to the
2724 this logic. For this purpose, the created transaction is passed to the
2722 method.
2725 method.
2723 """
2726 """
2724 # we must avoid cyclic reference between repo and transaction.
2727 # we must avoid cyclic reference between repo and transaction.
2725 reporef = weakref.ref(self)
2728 reporef = weakref.ref(self)
2726
2729
2727 def updater(tr):
2730 def updater(tr):
2728 repo = reporef()
2731 repo = reporef()
2729 assert repo is not None # help pytype
2732 assert repo is not None # help pytype
2730 repo.updatecaches(tr)
2733 repo.updatecaches(tr)
2731
2734
2732 return updater
2735 return updater
2733
2736
2734 @unfilteredmethod
2737 @unfilteredmethod
2735 def updatecaches(self, tr=None, full=False, caches=None):
2738 def updatecaches(self, tr=None, full=False, caches=None):
2736 """warm appropriate caches
2739 """warm appropriate caches
2737
2740
2738 If this function is called after a transaction closed. The transaction
2741 If this function is called after a transaction closed. The transaction
2739 will be available in the 'tr' argument. This can be used to selectively
2742 will be available in the 'tr' argument. This can be used to selectively
2740 update caches relevant to the changes in that transaction.
2743 update caches relevant to the changes in that transaction.
2741
2744
2742 If 'full' is set, make sure all caches the function knows about have
2745 If 'full' is set, make sure all caches the function knows about have
2743 up-to-date data. Even the ones usually loaded more lazily.
2746 up-to-date data. Even the ones usually loaded more lazily.
2744
2747
2745 The `full` argument can take a special "post-clone" value. In this case
2748 The `full` argument can take a special "post-clone" value. In this case
2746 the cache warming is made after a clone and of the slower cache might
2749 the cache warming is made after a clone and of the slower cache might
2747 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2750 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2748 as we plan for a cleaner way to deal with this for 5.9.
2751 as we plan for a cleaner way to deal with this for 5.9.
2749 """
2752 """
2750 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2753 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2751 # During strip, many caches are invalid but
2754 # During strip, many caches are invalid but
2752 # later call to `destroyed` will refresh them.
2755 # later call to `destroyed` will refresh them.
2753 return
2756 return
2754
2757
2755 unfi = self.unfiltered()
2758 unfi = self.unfiltered()
2756
2759
2757 if full:
2760 if full:
2758 msg = (
2761 msg = (
2759 "`full` argument for `repo.updatecaches` is deprecated\n"
2762 "`full` argument for `repo.updatecaches` is deprecated\n"
2760 "(use `caches=repository.CACHE_ALL` instead)"
2763 "(use `caches=repository.CACHE_ALL` instead)"
2761 )
2764 )
2762 self.ui.deprecwarn(msg, b"5.9")
2765 self.ui.deprecwarn(msg, b"5.9")
2763 caches = repository.CACHES_ALL
2766 caches = repository.CACHES_ALL
2764 if full == b"post-clone":
2767 if full == b"post-clone":
2765 caches = repository.CACHES_POST_CLONE
2768 caches = repository.CACHES_POST_CLONE
2766 caches = repository.CACHES_ALL
2769 caches = repository.CACHES_ALL
2767 elif caches is None:
2770 elif caches is None:
2768 caches = repository.CACHES_DEFAULT
2771 caches = repository.CACHES_DEFAULT
2769
2772
2770 if repository.CACHE_BRANCHMAP_SERVED in caches:
2773 if repository.CACHE_BRANCHMAP_SERVED in caches:
2771 if tr is None or tr.changes[b'origrepolen'] < len(self):
2774 if tr is None or tr.changes[b'origrepolen'] < len(self):
2772 # accessing the 'served' branchmap should refresh all the others,
2775 # accessing the 'served' branchmap should refresh all the others,
2773 self.ui.debug(b'updating the branch cache\n')
2776 self.ui.debug(b'updating the branch cache\n')
2774 self.filtered(b'served').branchmap()
2777 self.filtered(b'served').branchmap()
2775 self.filtered(b'served.hidden').branchmap()
2778 self.filtered(b'served.hidden').branchmap()
2776
2779
2777 if repository.CACHE_CHANGELOG_CACHE in caches:
2780 if repository.CACHE_CHANGELOG_CACHE in caches:
2778 self.changelog.update_caches(transaction=tr)
2781 self.changelog.update_caches(transaction=tr)
2779
2782
2780 if repository.CACHE_MANIFESTLOG_CACHE in caches:
2783 if repository.CACHE_MANIFESTLOG_CACHE in caches:
2781 self.manifestlog.update_caches(transaction=tr)
2784 self.manifestlog.update_caches(transaction=tr)
2782
2785
2783 if repository.CACHE_REV_BRANCH in caches:
2786 if repository.CACHE_REV_BRANCH in caches:
2784 rbc = unfi.revbranchcache()
2787 rbc = unfi.revbranchcache()
2785 for r in unfi.changelog:
2788 for r in unfi.changelog:
2786 rbc.branchinfo(r)
2789 rbc.branchinfo(r)
2787 rbc.write()
2790 rbc.write()
2788
2791
2789 if repository.CACHE_FULL_MANIFEST in caches:
2792 if repository.CACHE_FULL_MANIFEST in caches:
2790 # ensure the working copy parents are in the manifestfulltextcache
2793 # ensure the working copy parents are in the manifestfulltextcache
2791 for ctx in self[b'.'].parents():
2794 for ctx in self[b'.'].parents():
2792 ctx.manifest() # accessing the manifest is enough
2795 ctx.manifest() # accessing the manifest is enough
2793
2796
2794 if repository.CACHE_FILE_NODE_TAGS in caches:
2797 if repository.CACHE_FILE_NODE_TAGS in caches:
2795 # accessing fnode cache warms the cache
2798 # accessing fnode cache warms the cache
2796 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2799 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2797
2800
2798 if repository.CACHE_TAGS_DEFAULT in caches:
2801 if repository.CACHE_TAGS_DEFAULT in caches:
2799 # accessing tags warm the cache
2802 # accessing tags warm the cache
2800 self.tags()
2803 self.tags()
2801 if repository.CACHE_TAGS_SERVED in caches:
2804 if repository.CACHE_TAGS_SERVED in caches:
2802 self.filtered(b'served').tags()
2805 self.filtered(b'served').tags()
2803
2806
2804 if repository.CACHE_BRANCHMAP_ALL in caches:
2807 if repository.CACHE_BRANCHMAP_ALL in caches:
2805 # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
2808 # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
2806 # so we're forcing a write to cause these caches to be warmed up
2809 # so we're forcing a write to cause these caches to be warmed up
2807 # even if they haven't explicitly been requested yet (if they've
2810 # even if they haven't explicitly been requested yet (if they've
2808 # never been used by hg, they won't ever have been written, even if
2811 # never been used by hg, they won't ever have been written, even if
2809 # they're a subset of another kind of cache that *has* been used).
2812 # they're a subset of another kind of cache that *has* been used).
2810 for filt in repoview.filtertable.keys():
2813 for filt in repoview.filtertable.keys():
2811 filtered = self.filtered(filt)
2814 filtered = self.filtered(filt)
2812 filtered.branchmap().write(filtered)
2815 filtered.branchmap().write(filtered)
2813
2816
2814 def invalidatecaches(self):
2817 def invalidatecaches(self):
2815
2818
2816 if '_tagscache' in vars(self):
2819 if '_tagscache' in vars(self):
2817 # can't use delattr on proxy
2820 # can't use delattr on proxy
2818 del self.__dict__['_tagscache']
2821 del self.__dict__['_tagscache']
2819
2822
2820 self._branchcaches.clear()
2823 self._branchcaches.clear()
2821 self.invalidatevolatilesets()
2824 self.invalidatevolatilesets()
2822 self._sparsesignaturecache.clear()
2825 self._sparsesignaturecache.clear()
2823
2826
2824 def invalidatevolatilesets(self):
2827 def invalidatevolatilesets(self):
2825 self.filteredrevcache.clear()
2828 self.filteredrevcache.clear()
2826 obsolete.clearobscaches(self)
2829 obsolete.clearobscaches(self)
2827 self._quick_access_changeid_invalidate()
2830 self._quick_access_changeid_invalidate()
2828
2831
2829 def invalidatedirstate(self):
2832 def invalidatedirstate(self):
2830 """Invalidates the dirstate, causing the next call to dirstate
2833 """Invalidates the dirstate, causing the next call to dirstate
2831 to check if it was modified since the last time it was read,
2834 to check if it was modified since the last time it was read,
2832 rereading it if it has.
2835 rereading it if it has.
2833
2836
2834 This is different to dirstate.invalidate() that it doesn't always
2837 This is different to dirstate.invalidate() that it doesn't always
2835 rereads the dirstate. Use dirstate.invalidate() if you want to
2838 rereads the dirstate. Use dirstate.invalidate() if you want to
2836 explicitly read the dirstate again (i.e. restoring it to a previous
2839 explicitly read the dirstate again (i.e. restoring it to a previous
2837 known good state)."""
2840 known good state)."""
2838 if hasunfilteredcache(self, 'dirstate'):
2841 if hasunfilteredcache(self, 'dirstate'):
2839 for k in self.dirstate._filecache:
2842 for k in self.dirstate._filecache:
2840 try:
2843 try:
2841 delattr(self.dirstate, k)
2844 delattr(self.dirstate, k)
2842 except AttributeError:
2845 except AttributeError:
2843 pass
2846 pass
2844 delattr(self.unfiltered(), 'dirstate')
2847 delattr(self.unfiltered(), 'dirstate')
2845
2848
2846 def invalidate(self, clearfilecache=False):
2849 def invalidate(self, clearfilecache=False):
2847 """Invalidates both store and non-store parts other than dirstate
2850 """Invalidates both store and non-store parts other than dirstate
2848
2851
2849 If a transaction is running, invalidation of store is omitted,
2852 If a transaction is running, invalidation of store is omitted,
2850 because discarding in-memory changes might cause inconsistency
2853 because discarding in-memory changes might cause inconsistency
2851 (e.g. incomplete fncache causes unintentional failure, but
2854 (e.g. incomplete fncache causes unintentional failure, but
2852 redundant one doesn't).
2855 redundant one doesn't).
2853 """
2856 """
2854 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2857 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2855 for k in list(self._filecache.keys()):
2858 for k in list(self._filecache.keys()):
2856 # dirstate is invalidated separately in invalidatedirstate()
2859 # dirstate is invalidated separately in invalidatedirstate()
2857 if k == b'dirstate':
2860 if k == b'dirstate':
2858 continue
2861 continue
2859 if (
2862 if (
2860 k == b'changelog'
2863 k == b'changelog'
2861 and self.currenttransaction()
2864 and self.currenttransaction()
2862 and self.changelog._delayed
2865 and self.changelog._delayed
2863 ):
2866 ):
2864 # The changelog object may store unwritten revisions. We don't
2867 # The changelog object may store unwritten revisions. We don't
2865 # want to lose them.
2868 # want to lose them.
2866 # TODO: Solve the problem instead of working around it.
2869 # TODO: Solve the problem instead of working around it.
2867 continue
2870 continue
2868
2871
2869 if clearfilecache:
2872 if clearfilecache:
2870 del self._filecache[k]
2873 del self._filecache[k]
2871 try:
2874 try:
2872 delattr(unfiltered, k)
2875 delattr(unfiltered, k)
2873 except AttributeError:
2876 except AttributeError:
2874 pass
2877 pass
2875 self.invalidatecaches()
2878 self.invalidatecaches()
2876 if not self.currenttransaction():
2879 if not self.currenttransaction():
2877 # TODO: Changing contents of store outside transaction
2880 # TODO: Changing contents of store outside transaction
2878 # causes inconsistency. We should make in-memory store
2881 # causes inconsistency. We should make in-memory store
2879 # changes detectable, and abort if changed.
2882 # changes detectable, and abort if changed.
2880 self.store.invalidatecaches()
2883 self.store.invalidatecaches()
2881
2884
2882 def invalidateall(self):
2885 def invalidateall(self):
2883 """Fully invalidates both store and non-store parts, causing the
2886 """Fully invalidates both store and non-store parts, causing the
2884 subsequent operation to reread any outside changes."""
2887 subsequent operation to reread any outside changes."""
2885 # extension should hook this to invalidate its caches
2888 # extension should hook this to invalidate its caches
2886 self.invalidate()
2889 self.invalidate()
2887 self.invalidatedirstate()
2890 self.invalidatedirstate()
2888
2891
2889 @unfilteredmethod
2892 @unfilteredmethod
2890 def _refreshfilecachestats(self, tr):
2893 def _refreshfilecachestats(self, tr):
2891 """Reload stats of cached files so that they are flagged as valid"""
2894 """Reload stats of cached files so that they are flagged as valid"""
2892 for k, ce in self._filecache.items():
2895 for k, ce in self._filecache.items():
2893 k = pycompat.sysstr(k)
2896 k = pycompat.sysstr(k)
2894 if k == 'dirstate' or k not in self.__dict__:
2897 if k == 'dirstate' or k not in self.__dict__:
2895 continue
2898 continue
2896 ce.refresh()
2899 ce.refresh()
2897
2900
2898 def _lock(
2901 def _lock(
2899 self,
2902 self,
2900 vfs,
2903 vfs,
2901 lockname,
2904 lockname,
2902 wait,
2905 wait,
2903 releasefn,
2906 releasefn,
2904 acquirefn,
2907 acquirefn,
2905 desc,
2908 desc,
2906 ):
2909 ):
2907 timeout = 0
2910 timeout = 0
2908 warntimeout = 0
2911 warntimeout = 0
2909 if wait:
2912 if wait:
2910 timeout = self.ui.configint(b"ui", b"timeout")
2913 timeout = self.ui.configint(b"ui", b"timeout")
2911 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2914 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2912 # internal config: ui.signal-safe-lock
2915 # internal config: ui.signal-safe-lock
2913 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2916 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2914
2917
2915 l = lockmod.trylock(
2918 l = lockmod.trylock(
2916 self.ui,
2919 self.ui,
2917 vfs,
2920 vfs,
2918 lockname,
2921 lockname,
2919 timeout,
2922 timeout,
2920 warntimeout,
2923 warntimeout,
2921 releasefn=releasefn,
2924 releasefn=releasefn,
2922 acquirefn=acquirefn,
2925 acquirefn=acquirefn,
2923 desc=desc,
2926 desc=desc,
2924 signalsafe=signalsafe,
2927 signalsafe=signalsafe,
2925 )
2928 )
2926 return l
2929 return l
2927
2930
2928 def _afterlock(self, callback):
2931 def _afterlock(self, callback):
2929 """add a callback to be run when the repository is fully unlocked
2932 """add a callback to be run when the repository is fully unlocked
2930
2933
2931 The callback will be executed when the outermost lock is released
2934 The callback will be executed when the outermost lock is released
2932 (with wlock being higher level than 'lock')."""
2935 (with wlock being higher level than 'lock')."""
2933 for ref in (self._wlockref, self._lockref):
2936 for ref in (self._wlockref, self._lockref):
2934 l = ref and ref()
2937 l = ref and ref()
2935 if l and l.held:
2938 if l and l.held:
2936 l.postrelease.append(callback)
2939 l.postrelease.append(callback)
2937 break
2940 break
2938 else: # no lock have been found.
2941 else: # no lock have been found.
2939 callback(True)
2942 callback(True)
2940
2943
2941 def lock(self, wait=True):
2944 def lock(self, wait=True):
2942 """Lock the repository store (.hg/store) and return a weak reference
2945 """Lock the repository store (.hg/store) and return a weak reference
2943 to the lock. Use this before modifying the store (e.g. committing or
2946 to the lock. Use this before modifying the store (e.g. committing or
2944 stripping). If you are opening a transaction, get a lock as well.)
2947 stripping). If you are opening a transaction, get a lock as well.)
2945
2948
2946 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2949 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2947 'wlock' first to avoid a dead-lock hazard."""
2950 'wlock' first to avoid a dead-lock hazard."""
2948 l = self._currentlock(self._lockref)
2951 l = self._currentlock(self._lockref)
2949 if l is not None:
2952 if l is not None:
2950 l.lock()
2953 l.lock()
2951 return l
2954 return l
2952
2955
2953 l = self._lock(
2956 l = self._lock(
2954 vfs=self.svfs,
2957 vfs=self.svfs,
2955 lockname=b"lock",
2958 lockname=b"lock",
2956 wait=wait,
2959 wait=wait,
2957 releasefn=None,
2960 releasefn=None,
2958 acquirefn=self.invalidate,
2961 acquirefn=self.invalidate,
2959 desc=_(b'repository %s') % self.origroot,
2962 desc=_(b'repository %s') % self.origroot,
2960 )
2963 )
2961 self._lockref = weakref.ref(l)
2964 self._lockref = weakref.ref(l)
2962 return l
2965 return l
2963
2966
2964 def wlock(self, wait=True):
2967 def wlock(self, wait=True):
2965 """Lock the non-store parts of the repository (everything under
2968 """Lock the non-store parts of the repository (everything under
2966 .hg except .hg/store) and return a weak reference to the lock.
2969 .hg except .hg/store) and return a weak reference to the lock.
2967
2970
2968 Use this before modifying files in .hg.
2971 Use this before modifying files in .hg.
2969
2972
2970 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2973 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2971 'wlock' first to avoid a dead-lock hazard."""
2974 'wlock' first to avoid a dead-lock hazard."""
2972 l = self._wlockref() if self._wlockref else None
2975 l = self._wlockref() if self._wlockref else None
2973 if l is not None and l.held:
2976 if l is not None and l.held:
2974 l.lock()
2977 l.lock()
2975 return l
2978 return l
2976
2979
2977 # We do not need to check for non-waiting lock acquisition. Such
2980 # We do not need to check for non-waiting lock acquisition. Such
2978 # acquisition would not cause dead-lock as they would just fail.
2981 # acquisition would not cause dead-lock as they would just fail.
2979 if wait and (
2982 if wait and (
2980 self.ui.configbool(b'devel', b'all-warnings')
2983 self.ui.configbool(b'devel', b'all-warnings')
2981 or self.ui.configbool(b'devel', b'check-locks')
2984 or self.ui.configbool(b'devel', b'check-locks')
2982 ):
2985 ):
2983 if self._currentlock(self._lockref) is not None:
2986 if self._currentlock(self._lockref) is not None:
2984 self.ui.develwarn(b'"wlock" acquired after "lock"')
2987 self.ui.develwarn(b'"wlock" acquired after "lock"')
2985
2988
2986 def unlock():
2989 def unlock():
2987 if self.dirstate.pendingparentchange():
2990 if self.dirstate.pendingparentchange():
2988 self.dirstate.invalidate()
2991 self.dirstate.invalidate()
2989 else:
2992 else:
2990 self.dirstate.write(None)
2993 self.dirstate.write(None)
2991
2994
2992 self._filecache[b'dirstate'].refresh()
2995 self._filecache[b'dirstate'].refresh()
2993
2996
2994 l = self._lock(
2997 l = self._lock(
2995 self.vfs,
2998 self.vfs,
2996 b"wlock",
2999 b"wlock",
2997 wait,
3000 wait,
2998 unlock,
3001 unlock,
2999 self.invalidatedirstate,
3002 self.invalidatedirstate,
3000 _(b'working directory of %s') % self.origroot,
3003 _(b'working directory of %s') % self.origroot,
3001 )
3004 )
3002 self._wlockref = weakref.ref(l)
3005 self._wlockref = weakref.ref(l)
3003 return l
3006 return l
3004
3007
3005 def _currentlock(self, lockref):
3008 def _currentlock(self, lockref):
3006 """Returns the lock if it's held, or None if it's not."""
3009 """Returns the lock if it's held, or None if it's not."""
3007 if lockref is None:
3010 if lockref is None:
3008 return None
3011 return None
3009 l = lockref()
3012 l = lockref()
3010 if l is None or not l.held:
3013 if l is None or not l.held:
3011 return None
3014 return None
3012 return l
3015 return l
3013
3016
3014 def currentwlock(self):
3017 def currentwlock(self):
3015 """Returns the wlock if it's held, or None if it's not."""
3018 """Returns the wlock if it's held, or None if it's not."""
3016 return self._currentlock(self._wlockref)
3019 return self._currentlock(self._wlockref)
3017
3020
3018 def checkcommitpatterns(self, wctx, match, status, fail):
3021 def checkcommitpatterns(self, wctx, match, status, fail):
3019 """check for commit arguments that aren't committable"""
3022 """check for commit arguments that aren't committable"""
3020 if match.isexact() or match.prefix():
3023 if match.isexact() or match.prefix():
3021 matched = set(status.modified + status.added + status.removed)
3024 matched = set(status.modified + status.added + status.removed)
3022
3025
3023 for f in match.files():
3026 for f in match.files():
3024 f = self.dirstate.normalize(f)
3027 f = self.dirstate.normalize(f)
3025 if f == b'.' or f in matched or f in wctx.substate:
3028 if f == b'.' or f in matched or f in wctx.substate:
3026 continue
3029 continue
3027 if f in status.deleted:
3030 if f in status.deleted:
3028 fail(f, _(b'file not found!'))
3031 fail(f, _(b'file not found!'))
3029 # Is it a directory that exists or used to exist?
3032 # Is it a directory that exists or used to exist?
3030 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3033 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3031 d = f + b'/'
3034 d = f + b'/'
3032 for mf in matched:
3035 for mf in matched:
3033 if mf.startswith(d):
3036 if mf.startswith(d):
3034 break
3037 break
3035 else:
3038 else:
3036 fail(f, _(b"no match under directory!"))
3039 fail(f, _(b"no match under directory!"))
3037 elif f not in self.dirstate:
3040 elif f not in self.dirstate:
3038 fail(f, _(b"file not tracked!"))
3041 fail(f, _(b"file not tracked!"))
3039
3042
3040 @unfilteredmethod
3043 @unfilteredmethod
3041 def commit(
3044 def commit(
3042 self,
3045 self,
3043 text=b"",
3046 text=b"",
3044 user=None,
3047 user=None,
3045 date=None,
3048 date=None,
3046 match=None,
3049 match=None,
3047 force=False,
3050 force=False,
3048 editor=None,
3051 editor=None,
3049 extra=None,
3052 extra=None,
3050 ):
3053 ):
3051 """Add a new revision to current repository.
3054 """Add a new revision to current repository.
3052
3055
3053 Revision information is gathered from the working directory,
3056 Revision information is gathered from the working directory,
3054 match can be used to filter the committed files. If editor is
3057 match can be used to filter the committed files. If editor is
3055 supplied, it is called to get a commit message.
3058 supplied, it is called to get a commit message.
3056 """
3059 """
3057 if extra is None:
3060 if extra is None:
3058 extra = {}
3061 extra = {}
3059
3062
3060 def fail(f, msg):
3063 def fail(f, msg):
3061 raise error.InputError(b'%s: %s' % (f, msg))
3064 raise error.InputError(b'%s: %s' % (f, msg))
3062
3065
3063 if not match:
3066 if not match:
3064 match = matchmod.always()
3067 match = matchmod.always()
3065
3068
3066 if not force:
3069 if not force:
3067 match.bad = fail
3070 match.bad = fail
3068
3071
3069 # lock() for recent changelog (see issue4368)
3072 # lock() for recent changelog (see issue4368)
3070 with self.wlock(), self.lock():
3073 with self.wlock(), self.lock():
3071 wctx = self[None]
3074 wctx = self[None]
3072 merge = len(wctx.parents()) > 1
3075 merge = len(wctx.parents()) > 1
3073
3076
3074 if not force and merge and not match.always():
3077 if not force and merge and not match.always():
3075 raise error.Abort(
3078 raise error.Abort(
3076 _(
3079 _(
3077 b'cannot partially commit a merge '
3080 b'cannot partially commit a merge '
3078 b'(do not specify files or patterns)'
3081 b'(do not specify files or patterns)'
3079 )
3082 )
3080 )
3083 )
3081
3084
3082 status = self.status(match=match, clean=force)
3085 status = self.status(match=match, clean=force)
3083 if force:
3086 if force:
3084 status.modified.extend(
3087 status.modified.extend(
3085 status.clean
3088 status.clean
3086 ) # mq may commit clean files
3089 ) # mq may commit clean files
3087
3090
3088 # check subrepos
3091 # check subrepos
3089 subs, commitsubs, newstate = subrepoutil.precommit(
3092 subs, commitsubs, newstate = subrepoutil.precommit(
3090 self.ui, wctx, status, match, force=force
3093 self.ui, wctx, status, match, force=force
3091 )
3094 )
3092
3095
3093 # make sure all explicit patterns are matched
3096 # make sure all explicit patterns are matched
3094 if not force:
3097 if not force:
3095 self.checkcommitpatterns(wctx, match, status, fail)
3098 self.checkcommitpatterns(wctx, match, status, fail)
3096
3099
3097 cctx = context.workingcommitctx(
3100 cctx = context.workingcommitctx(
3098 self, status, text, user, date, extra
3101 self, status, text, user, date, extra
3099 )
3102 )
3100
3103
3101 ms = mergestatemod.mergestate.read(self)
3104 ms = mergestatemod.mergestate.read(self)
3102 mergeutil.checkunresolved(ms)
3105 mergeutil.checkunresolved(ms)
3103
3106
3104 # internal config: ui.allowemptycommit
3107 # internal config: ui.allowemptycommit
3105 if cctx.isempty() and not self.ui.configbool(
3108 if cctx.isempty() and not self.ui.configbool(
3106 b'ui', b'allowemptycommit'
3109 b'ui', b'allowemptycommit'
3107 ):
3110 ):
3108 self.ui.debug(b'nothing to commit, clearing merge state\n')
3111 self.ui.debug(b'nothing to commit, clearing merge state\n')
3109 ms.reset()
3112 ms.reset()
3110 return None
3113 return None
3111
3114
3112 if merge and cctx.deleted():
3115 if merge and cctx.deleted():
3113 raise error.Abort(_(b"cannot commit merge with missing files"))
3116 raise error.Abort(_(b"cannot commit merge with missing files"))
3114
3117
3115 if editor:
3118 if editor:
3116 cctx._text = editor(self, cctx, subs)
3119 cctx._text = editor(self, cctx, subs)
3117 edited = text != cctx._text
3120 edited = text != cctx._text
3118
3121
3119 # Save commit message in case this transaction gets rolled back
3122 # Save commit message in case this transaction gets rolled back
3120 # (e.g. by a pretxncommit hook). Leave the content alone on
3123 # (e.g. by a pretxncommit hook). Leave the content alone on
3121 # the assumption that the user will use the same editor again.
3124 # the assumption that the user will use the same editor again.
3122 msgfn = self.savecommitmessage(cctx._text)
3125 msgfn = self.savecommitmessage(cctx._text)
3123
3126
3124 # commit subs and write new state
3127 # commit subs and write new state
3125 if subs:
3128 if subs:
3126 uipathfn = scmutil.getuipathfn(self)
3129 uipathfn = scmutil.getuipathfn(self)
3127 for s in sorted(commitsubs):
3130 for s in sorted(commitsubs):
3128 sub = wctx.sub(s)
3131 sub = wctx.sub(s)
3129 self.ui.status(
3132 self.ui.status(
3130 _(b'committing subrepository %s\n')
3133 _(b'committing subrepository %s\n')
3131 % uipathfn(subrepoutil.subrelpath(sub))
3134 % uipathfn(subrepoutil.subrelpath(sub))
3132 )
3135 )
3133 sr = sub.commit(cctx._text, user, date)
3136 sr = sub.commit(cctx._text, user, date)
3134 newstate[s] = (newstate[s][0], sr)
3137 newstate[s] = (newstate[s][0], sr)
3135 subrepoutil.writestate(self, newstate)
3138 subrepoutil.writestate(self, newstate)
3136
3139
3137 p1, p2 = self.dirstate.parents()
3140 p1, p2 = self.dirstate.parents()
3138 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3141 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3139 try:
3142 try:
3140 self.hook(
3143 self.hook(
3141 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3144 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3142 )
3145 )
3143 with self.transaction(b'commit'):
3146 with self.transaction(b'commit'):
3144 ret = self.commitctx(cctx, True)
3147 ret = self.commitctx(cctx, True)
3145 # update bookmarks, dirstate and mergestate
3148 # update bookmarks, dirstate and mergestate
3146 bookmarks.update(self, [p1, p2], ret)
3149 bookmarks.update(self, [p1, p2], ret)
3147 cctx.markcommitted(ret)
3150 cctx.markcommitted(ret)
3148 ms.reset()
3151 ms.reset()
3149 except: # re-raises
3152 except: # re-raises
3150 if edited:
3153 if edited:
3151 self.ui.write(
3154 self.ui.write(
3152 _(b'note: commit message saved in %s\n') % msgfn
3155 _(b'note: commit message saved in %s\n') % msgfn
3153 )
3156 )
3154 self.ui.write(
3157 self.ui.write(
3155 _(
3158 _(
3156 b"note: use 'hg commit --logfile "
3159 b"note: use 'hg commit --logfile "
3157 b".hg/last-message.txt --edit' to reuse it\n"
3160 b".hg/last-message.txt --edit' to reuse it\n"
3158 )
3161 )
3159 )
3162 )
3160 raise
3163 raise
3161
3164
3162 def commithook(unused_success):
3165 def commithook(unused_success):
3163 # hack for command that use a temporary commit (eg: histedit)
3166 # hack for command that use a temporary commit (eg: histedit)
3164 # temporary commit got stripped before hook release
3167 # temporary commit got stripped before hook release
3165 if self.changelog.hasnode(ret):
3168 if self.changelog.hasnode(ret):
3166 self.hook(
3169 self.hook(
3167 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3170 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3168 )
3171 )
3169
3172
3170 self._afterlock(commithook)
3173 self._afterlock(commithook)
3171 return ret
3174 return ret
3172
3175
3173 @unfilteredmethod
3176 @unfilteredmethod
3174 def commitctx(self, ctx, error=False, origctx=None):
3177 def commitctx(self, ctx, error=False, origctx=None):
3175 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3178 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3176
3179
3177 @unfilteredmethod
3180 @unfilteredmethod
3178 def destroying(self):
3181 def destroying(self):
3179 """Inform the repository that nodes are about to be destroyed.
3182 """Inform the repository that nodes are about to be destroyed.
3180 Intended for use by strip and rollback, so there's a common
3183 Intended for use by strip and rollback, so there's a common
3181 place for anything that has to be done before destroying history.
3184 place for anything that has to be done before destroying history.
3182
3185
3183 This is mostly useful for saving state that is in memory and waiting
3186 This is mostly useful for saving state that is in memory and waiting
3184 to be flushed when the current lock is released. Because a call to
3187 to be flushed when the current lock is released. Because a call to
3185 destroyed is imminent, the repo will be invalidated causing those
3188 destroyed is imminent, the repo will be invalidated causing those
3186 changes to stay in memory (waiting for the next unlock), or vanish
3189 changes to stay in memory (waiting for the next unlock), or vanish
3187 completely.
3190 completely.
3188 """
3191 """
3189 # When using the same lock to commit and strip, the phasecache is left
3192 # When using the same lock to commit and strip, the phasecache is left
3190 # dirty after committing. Then when we strip, the repo is invalidated,
3193 # dirty after committing. Then when we strip, the repo is invalidated,
3191 # causing those changes to disappear.
3194 # causing those changes to disappear.
3192 if '_phasecache' in vars(self):
3195 if '_phasecache' in vars(self):
3193 self._phasecache.write()
3196 self._phasecache.write()
3194
3197
3195 @unfilteredmethod
3198 @unfilteredmethod
3196 def destroyed(self):
3199 def destroyed(self):
3197 """Inform the repository that nodes have been destroyed.
3200 """Inform the repository that nodes have been destroyed.
3198 Intended for use by strip and rollback, so there's a common
3201 Intended for use by strip and rollback, so there's a common
3199 place for anything that has to be done after destroying history.
3202 place for anything that has to be done after destroying history.
3200 """
3203 """
3201 # When one tries to:
3204 # When one tries to:
3202 # 1) destroy nodes thus calling this method (e.g. strip)
3205 # 1) destroy nodes thus calling this method (e.g. strip)
3203 # 2) use phasecache somewhere (e.g. commit)
3206 # 2) use phasecache somewhere (e.g. commit)
3204 #
3207 #
3205 # then 2) will fail because the phasecache contains nodes that were
3208 # then 2) will fail because the phasecache contains nodes that were
3206 # removed. We can either remove phasecache from the filecache,
3209 # removed. We can either remove phasecache from the filecache,
3207 # causing it to reload next time it is accessed, or simply filter
3210 # causing it to reload next time it is accessed, or simply filter
3208 # the removed nodes now and write the updated cache.
3211 # the removed nodes now and write the updated cache.
3209 self._phasecache.filterunknown(self)
3212 self._phasecache.filterunknown(self)
3210 self._phasecache.write()
3213 self._phasecache.write()
3211
3214
3212 # refresh all repository caches
3215 # refresh all repository caches
3213 self.updatecaches()
3216 self.updatecaches()
3214
3217
3215 # Ensure the persistent tag cache is updated. Doing it now
3218 # Ensure the persistent tag cache is updated. Doing it now
3216 # means that the tag cache only has to worry about destroyed
3219 # means that the tag cache only has to worry about destroyed
3217 # heads immediately after a strip/rollback. That in turn
3220 # heads immediately after a strip/rollback. That in turn
3218 # guarantees that "cachetip == currenttip" (comparing both rev
3221 # guarantees that "cachetip == currenttip" (comparing both rev
3219 # and node) always means no nodes have been added or destroyed.
3222 # and node) always means no nodes have been added or destroyed.
3220
3223
3221 # XXX this is suboptimal when qrefresh'ing: we strip the current
3224 # XXX this is suboptimal when qrefresh'ing: we strip the current
3222 # head, refresh the tag cache, then immediately add a new head.
3225 # head, refresh the tag cache, then immediately add a new head.
3223 # But I think doing it this way is necessary for the "instant
3226 # But I think doing it this way is necessary for the "instant
3224 # tag cache retrieval" case to work.
3227 # tag cache retrieval" case to work.
3225 self.invalidate()
3228 self.invalidate()
3226
3229
3227 def status(
3230 def status(
3228 self,
3231 self,
3229 node1=b'.',
3232 node1=b'.',
3230 node2=None,
3233 node2=None,
3231 match=None,
3234 match=None,
3232 ignored=False,
3235 ignored=False,
3233 clean=False,
3236 clean=False,
3234 unknown=False,
3237 unknown=False,
3235 listsubrepos=False,
3238 listsubrepos=False,
3236 ):
3239 ):
3237 '''a convenience method that calls node1.status(node2)'''
3240 '''a convenience method that calls node1.status(node2)'''
3238 return self[node1].status(
3241 return self[node1].status(
3239 node2, match, ignored, clean, unknown, listsubrepos
3242 node2, match, ignored, clean, unknown, listsubrepos
3240 )
3243 )
3241
3244
3242 def addpostdsstatus(self, ps):
3245 def addpostdsstatus(self, ps):
3243 """Add a callback to run within the wlock, at the point at which status
3246 """Add a callback to run within the wlock, at the point at which status
3244 fixups happen.
3247 fixups happen.
3245
3248
3246 On status completion, callback(wctx, status) will be called with the
3249 On status completion, callback(wctx, status) will be called with the
3247 wlock held, unless the dirstate has changed from underneath or the wlock
3250 wlock held, unless the dirstate has changed from underneath or the wlock
3248 couldn't be grabbed.
3251 couldn't be grabbed.
3249
3252
3250 Callbacks should not capture and use a cached copy of the dirstate --
3253 Callbacks should not capture and use a cached copy of the dirstate --
3251 it might change in the meanwhile. Instead, they should access the
3254 it might change in the meanwhile. Instead, they should access the
3252 dirstate via wctx.repo().dirstate.
3255 dirstate via wctx.repo().dirstate.
3253
3256
3254 This list is emptied out after each status run -- extensions should
3257 This list is emptied out after each status run -- extensions should
3255 make sure it adds to this list each time dirstate.status is called.
3258 make sure it adds to this list each time dirstate.status is called.
3256 Extensions should also make sure they don't call this for statuses
3259 Extensions should also make sure they don't call this for statuses
3257 that don't involve the dirstate.
3260 that don't involve the dirstate.
3258 """
3261 """
3259
3262
3260 # The list is located here for uniqueness reasons -- it is actually
3263 # The list is located here for uniqueness reasons -- it is actually
3261 # managed by the workingctx, but that isn't unique per-repo.
3264 # managed by the workingctx, but that isn't unique per-repo.
3262 self._postdsstatus.append(ps)
3265 self._postdsstatus.append(ps)
3263
3266
3264 def postdsstatus(self):
3267 def postdsstatus(self):
3265 """Used by workingctx to get the list of post-dirstate-status hooks."""
3268 """Used by workingctx to get the list of post-dirstate-status hooks."""
3266 return self._postdsstatus
3269 return self._postdsstatus
3267
3270
3268 def clearpostdsstatus(self):
3271 def clearpostdsstatus(self):
3269 """Used by workingctx to clear post-dirstate-status hooks."""
3272 """Used by workingctx to clear post-dirstate-status hooks."""
3270 del self._postdsstatus[:]
3273 del self._postdsstatus[:]
3271
3274
3272 def heads(self, start=None):
3275 def heads(self, start=None):
3273 if start is None:
3276 if start is None:
3274 cl = self.changelog
3277 cl = self.changelog
3275 headrevs = reversed(cl.headrevs())
3278 headrevs = reversed(cl.headrevs())
3276 return [cl.node(rev) for rev in headrevs]
3279 return [cl.node(rev) for rev in headrevs]
3277
3280
3278 heads = self.changelog.heads(start)
3281 heads = self.changelog.heads(start)
3279 # sort the output in rev descending order
3282 # sort the output in rev descending order
3280 return sorted(heads, key=self.changelog.rev, reverse=True)
3283 return sorted(heads, key=self.changelog.rev, reverse=True)
3281
3284
3282 def branchheads(self, branch=None, start=None, closed=False):
3285 def branchheads(self, branch=None, start=None, closed=False):
3283 """return a (possibly filtered) list of heads for the given branch
3286 """return a (possibly filtered) list of heads for the given branch
3284
3287
3285 Heads are returned in topological order, from newest to oldest.
3288 Heads are returned in topological order, from newest to oldest.
3286 If branch is None, use the dirstate branch.
3289 If branch is None, use the dirstate branch.
3287 If start is not None, return only heads reachable from start.
3290 If start is not None, return only heads reachable from start.
3288 If closed is True, return heads that are marked as closed as well.
3291 If closed is True, return heads that are marked as closed as well.
3289 """
3292 """
3290 if branch is None:
3293 if branch is None:
3291 branch = self[None].branch()
3294 branch = self[None].branch()
3292 branches = self.branchmap()
3295 branches = self.branchmap()
3293 if not branches.hasbranch(branch):
3296 if not branches.hasbranch(branch):
3294 return []
3297 return []
3295 # the cache returns heads ordered lowest to highest
3298 # the cache returns heads ordered lowest to highest
3296 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3299 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3297 if start is not None:
3300 if start is not None:
3298 # filter out the heads that cannot be reached from startrev
3301 # filter out the heads that cannot be reached from startrev
3299 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3302 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3300 bheads = [h for h in bheads if h in fbheads]
3303 bheads = [h for h in bheads if h in fbheads]
3301 return bheads
3304 return bheads
3302
3305
3303 def branches(self, nodes):
3306 def branches(self, nodes):
3304 if not nodes:
3307 if not nodes:
3305 nodes = [self.changelog.tip()]
3308 nodes = [self.changelog.tip()]
3306 b = []
3309 b = []
3307 for n in nodes:
3310 for n in nodes:
3308 t = n
3311 t = n
3309 while True:
3312 while True:
3310 p = self.changelog.parents(n)
3313 p = self.changelog.parents(n)
3311 if p[1] != self.nullid or p[0] == self.nullid:
3314 if p[1] != self.nullid or p[0] == self.nullid:
3312 b.append((t, n, p[0], p[1]))
3315 b.append((t, n, p[0], p[1]))
3313 break
3316 break
3314 n = p[0]
3317 n = p[0]
3315 return b
3318 return b
3316
3319
3317 def between(self, pairs):
3320 def between(self, pairs):
3318 r = []
3321 r = []
3319
3322
3320 for top, bottom in pairs:
3323 for top, bottom in pairs:
3321 n, l, i = top, [], 0
3324 n, l, i = top, [], 0
3322 f = 1
3325 f = 1
3323
3326
3324 while n != bottom and n != self.nullid:
3327 while n != bottom and n != self.nullid:
3325 p = self.changelog.parents(n)[0]
3328 p = self.changelog.parents(n)[0]
3326 if i == f:
3329 if i == f:
3327 l.append(n)
3330 l.append(n)
3328 f = f * 2
3331 f = f * 2
3329 n = p
3332 n = p
3330 i += 1
3333 i += 1
3331
3334
3332 r.append(l)
3335 r.append(l)
3333
3336
3334 return r
3337 return r
3335
3338
3336 def checkpush(self, pushop):
3339 def checkpush(self, pushop):
3337 """Extensions can override this function if additional checks have
3340 """Extensions can override this function if additional checks have
3338 to be performed before pushing, or call it if they override push
3341 to be performed before pushing, or call it if they override push
3339 command.
3342 command.
3340 """
3343 """
3341
3344
3342 @unfilteredpropertycache
3345 @unfilteredpropertycache
3343 def prepushoutgoinghooks(self):
3346 def prepushoutgoinghooks(self):
3344 """Return util.hooks consists of a pushop with repo, remote, outgoing
3347 """Return util.hooks consists of a pushop with repo, remote, outgoing
3345 methods, which are called before pushing changesets.
3348 methods, which are called before pushing changesets.
3346 """
3349 """
3347 return util.hooks()
3350 return util.hooks()
3348
3351
3349 def pushkey(self, namespace, key, old, new):
3352 def pushkey(self, namespace, key, old, new):
3350 try:
3353 try:
3351 tr = self.currenttransaction()
3354 tr = self.currenttransaction()
3352 hookargs = {}
3355 hookargs = {}
3353 if tr is not None:
3356 if tr is not None:
3354 hookargs.update(tr.hookargs)
3357 hookargs.update(tr.hookargs)
3355 hookargs = pycompat.strkwargs(hookargs)
3358 hookargs = pycompat.strkwargs(hookargs)
3356 hookargs['namespace'] = namespace
3359 hookargs['namespace'] = namespace
3357 hookargs['key'] = key
3360 hookargs['key'] = key
3358 hookargs['old'] = old
3361 hookargs['old'] = old
3359 hookargs['new'] = new
3362 hookargs['new'] = new
3360 self.hook(b'prepushkey', throw=True, **hookargs)
3363 self.hook(b'prepushkey', throw=True, **hookargs)
3361 except error.HookAbort as exc:
3364 except error.HookAbort as exc:
3362 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3365 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3363 if exc.hint:
3366 if exc.hint:
3364 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3367 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3365 return False
3368 return False
3366 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3369 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3367 ret = pushkey.push(self, namespace, key, old, new)
3370 ret = pushkey.push(self, namespace, key, old, new)
3368
3371
3369 def runhook(unused_success):
3372 def runhook(unused_success):
3370 self.hook(
3373 self.hook(
3371 b'pushkey',
3374 b'pushkey',
3372 namespace=namespace,
3375 namespace=namespace,
3373 key=key,
3376 key=key,
3374 old=old,
3377 old=old,
3375 new=new,
3378 new=new,
3376 ret=ret,
3379 ret=ret,
3377 )
3380 )
3378
3381
3379 self._afterlock(runhook)
3382 self._afterlock(runhook)
3380 return ret
3383 return ret
3381
3384
3382 def listkeys(self, namespace):
3385 def listkeys(self, namespace):
3383 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3386 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3384 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3387 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3385 values = pushkey.list(self, namespace)
3388 values = pushkey.list(self, namespace)
3386 self.hook(b'listkeys', namespace=namespace, values=values)
3389 self.hook(b'listkeys', namespace=namespace, values=values)
3387 return values
3390 return values
3388
3391
3389 def debugwireargs(self, one, two, three=None, four=None, five=None):
3392 def debugwireargs(self, one, two, three=None, four=None, five=None):
3390 '''used to test argument passing over the wire'''
3393 '''used to test argument passing over the wire'''
3391 return b"%s %s %s %s %s" % (
3394 return b"%s %s %s %s %s" % (
3392 one,
3395 one,
3393 two,
3396 two,
3394 pycompat.bytestr(three),
3397 pycompat.bytestr(three),
3395 pycompat.bytestr(four),
3398 pycompat.bytestr(four),
3396 pycompat.bytestr(five),
3399 pycompat.bytestr(five),
3397 )
3400 )
3398
3401
3399 def savecommitmessage(self, text):
3402 def savecommitmessage(self, text):
3400 fp = self.vfs(b'last-message.txt', b'wb')
3403 fp = self.vfs(b'last-message.txt', b'wb')
3401 try:
3404 try:
3402 fp.write(text)
3405 fp.write(text)
3403 finally:
3406 finally:
3404 fp.close()
3407 fp.close()
3405 return self.pathto(fp.name[len(self.root) + 1 :])
3408 return self.pathto(fp.name[len(self.root) + 1 :])
3406
3409
3407 def register_wanted_sidedata(self, category):
3410 def register_wanted_sidedata(self, category):
3408 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3411 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3409 # Only revlogv2 repos can want sidedata.
3412 # Only revlogv2 repos can want sidedata.
3410 return
3413 return
3411 self._wanted_sidedata.add(pycompat.bytestr(category))
3414 self._wanted_sidedata.add(pycompat.bytestr(category))
3412
3415
3413 def register_sidedata_computer(
3416 def register_sidedata_computer(
3414 self, kind, category, keys, computer, flags, replace=False
3417 self, kind, category, keys, computer, flags, replace=False
3415 ):
3418 ):
3416 if kind not in revlogconst.ALL_KINDS:
3419 if kind not in revlogconst.ALL_KINDS:
3417 msg = _(b"unexpected revlog kind '%s'.")
3420 msg = _(b"unexpected revlog kind '%s'.")
3418 raise error.ProgrammingError(msg % kind)
3421 raise error.ProgrammingError(msg % kind)
3419 category = pycompat.bytestr(category)
3422 category = pycompat.bytestr(category)
3420 already_registered = category in self._sidedata_computers.get(kind, [])
3423 already_registered = category in self._sidedata_computers.get(kind, [])
3421 if already_registered and not replace:
3424 if already_registered and not replace:
3422 msg = _(
3425 msg = _(
3423 b"cannot register a sidedata computer twice for category '%s'."
3426 b"cannot register a sidedata computer twice for category '%s'."
3424 )
3427 )
3425 raise error.ProgrammingError(msg % category)
3428 raise error.ProgrammingError(msg % category)
3426 if replace and not already_registered:
3429 if replace and not already_registered:
3427 msg = _(
3430 msg = _(
3428 b"cannot replace a sidedata computer that isn't registered "
3431 b"cannot replace a sidedata computer that isn't registered "
3429 b"for category '%s'."
3432 b"for category '%s'."
3430 )
3433 )
3431 raise error.ProgrammingError(msg % category)
3434 raise error.ProgrammingError(msg % category)
3432 self._sidedata_computers.setdefault(kind, {})
3435 self._sidedata_computers.setdefault(kind, {})
3433 self._sidedata_computers[kind][category] = (keys, computer, flags)
3436 self._sidedata_computers[kind][category] = (keys, computer, flags)
3434
3437
3435
3438
3436 # used to avoid circular references so destructors work
3439 # used to avoid circular references so destructors work
3437 def aftertrans(files):
3440 def aftertrans(files):
3438 renamefiles = [tuple(t) for t in files]
3441 renamefiles = [tuple(t) for t in files]
3439
3442
3440 def a():
3443 def a():
3441 for vfs, src, dest in renamefiles:
3444 for vfs, src, dest in renamefiles:
3442 # if src and dest refer to a same file, vfs.rename is a no-op,
3445 # if src and dest refer to a same file, vfs.rename is a no-op,
3443 # leaving both src and dest on disk. delete dest to make sure
3446 # leaving both src and dest on disk. delete dest to make sure
3444 # the rename couldn't be such a no-op.
3447 # the rename couldn't be such a no-op.
3445 vfs.tryunlink(dest)
3448 vfs.tryunlink(dest)
3446 try:
3449 try:
3447 vfs.rename(src, dest)
3450 vfs.rename(src, dest)
3448 except OSError as exc: # journal file does not yet exist
3451 except OSError as exc: # journal file does not yet exist
3449 if exc.errno != errno.ENOENT:
3452 if exc.errno != errno.ENOENT:
3450 raise
3453 raise
3451
3454
3452 return a
3455 return a
3453
3456
3454
3457
3455 def undoname(fn):
3458 def undoname(fn):
3456 base, name = os.path.split(fn)
3459 base, name = os.path.split(fn)
3457 assert name.startswith(b'journal')
3460 assert name.startswith(b'journal')
3458 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3461 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3459
3462
3460
3463
3461 def instance(ui, path, create, intents=None, createopts=None):
3464 def instance(ui, path, create, intents=None, createopts=None):
3462 localpath = urlutil.urllocalpath(path)
3465 localpath = urlutil.urllocalpath(path)
3463 if create:
3466 if create:
3464 createrepository(ui, localpath, createopts=createopts)
3467 createrepository(ui, localpath, createopts=createopts)
3465
3468
3466 return makelocalrepository(ui, localpath, intents=intents)
3469 return makelocalrepository(ui, localpath, intents=intents)
3467
3470
3468
3471
3469 def islocal(path):
3472 def islocal(path):
3470 return True
3473 return True
3471
3474
3472
3475
3473 def defaultcreateopts(ui, createopts=None):
3476 def defaultcreateopts(ui, createopts=None):
3474 """Populate the default creation options for a repository.
3477 """Populate the default creation options for a repository.
3475
3478
3476 A dictionary of explicitly requested creation options can be passed
3479 A dictionary of explicitly requested creation options can be passed
3477 in. Missing keys will be populated.
3480 in. Missing keys will be populated.
3478 """
3481 """
3479 createopts = dict(createopts or {})
3482 createopts = dict(createopts or {})
3480
3483
3481 if b'backend' not in createopts:
3484 if b'backend' not in createopts:
3482 # experimental config: storage.new-repo-backend
3485 # experimental config: storage.new-repo-backend
3483 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3486 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3484
3487
3485 return createopts
3488 return createopts
3486
3489
3487
3490
3488 def clone_requirements(ui, createopts, srcrepo):
3491 def clone_requirements(ui, createopts, srcrepo):
3489 """clone the requirements of a local repo for a local clone
3492 """clone the requirements of a local repo for a local clone
3490
3493
3491 The store requirements are unchanged while the working copy requirements
3494 The store requirements are unchanged while the working copy requirements
3492 depends on the configuration
3495 depends on the configuration
3493 """
3496 """
3494 target_requirements = set()
3497 target_requirements = set()
3495 createopts = defaultcreateopts(ui, createopts=createopts)
3498 createopts = defaultcreateopts(ui, createopts=createopts)
3496 for r in newreporequirements(ui, createopts):
3499 for r in newreporequirements(ui, createopts):
3497 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
3500 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
3498 target_requirements.add(r)
3501 target_requirements.add(r)
3499
3502
3500 for r in srcrepo.requirements:
3503 for r in srcrepo.requirements:
3501 if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
3504 if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
3502 target_requirements.add(r)
3505 target_requirements.add(r)
3503 return target_requirements
3506 return target_requirements
3504
3507
3505
3508
3506 def newreporequirements(ui, createopts):
3509 def newreporequirements(ui, createopts):
3507 """Determine the set of requirements for a new local repository.
3510 """Determine the set of requirements for a new local repository.
3508
3511
3509 Extensions can wrap this function to specify custom requirements for
3512 Extensions can wrap this function to specify custom requirements for
3510 new repositories.
3513 new repositories.
3511 """
3514 """
3512 # If the repo is being created from a shared repository, we copy
3515 # If the repo is being created from a shared repository, we copy
3513 # its requirements.
3516 # its requirements.
3514 if b'sharedrepo' in createopts:
3517 if b'sharedrepo' in createopts:
3515 requirements = set(createopts[b'sharedrepo'].requirements)
3518 requirements = set(createopts[b'sharedrepo'].requirements)
3516 if createopts.get(b'sharedrelative'):
3519 if createopts.get(b'sharedrelative'):
3517 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3520 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3518 else:
3521 else:
3519 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3522 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3520
3523
3521 return requirements
3524 return requirements
3522
3525
3523 if b'backend' not in createopts:
3526 if b'backend' not in createopts:
3524 raise error.ProgrammingError(
3527 raise error.ProgrammingError(
3525 b'backend key not present in createopts; '
3528 b'backend key not present in createopts; '
3526 b'was defaultcreateopts() called?'
3529 b'was defaultcreateopts() called?'
3527 )
3530 )
3528
3531
3529 if createopts[b'backend'] != b'revlogv1':
3532 if createopts[b'backend'] != b'revlogv1':
3530 raise error.Abort(
3533 raise error.Abort(
3531 _(
3534 _(
3532 b'unable to determine repository requirements for '
3535 b'unable to determine repository requirements for '
3533 b'storage backend: %s'
3536 b'storage backend: %s'
3534 )
3537 )
3535 % createopts[b'backend']
3538 % createopts[b'backend']
3536 )
3539 )
3537
3540
3538 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3541 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3539 if ui.configbool(b'format', b'usestore'):
3542 if ui.configbool(b'format', b'usestore'):
3540 requirements.add(requirementsmod.STORE_REQUIREMENT)
3543 requirements.add(requirementsmod.STORE_REQUIREMENT)
3541 if ui.configbool(b'format', b'usefncache'):
3544 if ui.configbool(b'format', b'usefncache'):
3542 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3545 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3543 if ui.configbool(b'format', b'dotencode'):
3546 if ui.configbool(b'format', b'dotencode'):
3544 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3547 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3545
3548
3546 compengines = ui.configlist(b'format', b'revlog-compression')
3549 compengines = ui.configlist(b'format', b'revlog-compression')
3547 for compengine in compengines:
3550 for compengine in compengines:
3548 if compengine in util.compengines:
3551 if compengine in util.compengines:
3549 engine = util.compengines[compengine]
3552 engine = util.compengines[compengine]
3550 if engine.available() and engine.revlogheader():
3553 if engine.available() and engine.revlogheader():
3551 break
3554 break
3552 else:
3555 else:
3553 raise error.Abort(
3556 raise error.Abort(
3554 _(
3557 _(
3555 b'compression engines %s defined by '
3558 b'compression engines %s defined by '
3556 b'format.revlog-compression not available'
3559 b'format.revlog-compression not available'
3557 )
3560 )
3558 % b', '.join(b'"%s"' % e for e in compengines),
3561 % b', '.join(b'"%s"' % e for e in compengines),
3559 hint=_(
3562 hint=_(
3560 b'run "hg debuginstall" to list available '
3563 b'run "hg debuginstall" to list available '
3561 b'compression engines'
3564 b'compression engines'
3562 ),
3565 ),
3563 )
3566 )
3564
3567
3565 # zlib is the historical default and doesn't need an explicit requirement.
3568 # zlib is the historical default and doesn't need an explicit requirement.
3566 if compengine == b'zstd':
3569 if compengine == b'zstd':
3567 requirements.add(b'revlog-compression-zstd')
3570 requirements.add(b'revlog-compression-zstd')
3568 elif compengine != b'zlib':
3571 elif compengine != b'zlib':
3569 requirements.add(b'exp-compression-%s' % compengine)
3572 requirements.add(b'exp-compression-%s' % compengine)
3570
3573
3571 if scmutil.gdinitconfig(ui):
3574 if scmutil.gdinitconfig(ui):
3572 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3575 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3573 if ui.configbool(b'format', b'sparse-revlog'):
3576 if ui.configbool(b'format', b'sparse-revlog'):
3574 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3577 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3575
3578
3576 # experimental config: format.exp-dirstate-v2
3579 # experimental config: format.exp-dirstate-v2
3577 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3580 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3578 if ui.configbool(b'format', b'exp-dirstate-v2'):
3581 if ui.configbool(b'format', b'exp-dirstate-v2'):
3579 if dirstate.SUPPORTS_DIRSTATE_V2:
3582 if dirstate.SUPPORTS_DIRSTATE_V2:
3580 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3583 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3581 else:
3584 else:
3582 raise error.Abort(
3585 raise error.Abort(
3583 _(
3586 _(
3584 b"dirstate v2 format requested by config "
3587 b"dirstate v2 format requested by config "
3585 b"but not supported (requires Rust extensions)"
3588 b"but not supported (requires Rust extensions)"
3586 )
3589 )
3587 )
3590 )
3588
3591
3589 # experimental config: format.exp-use-copies-side-data-changeset
3592 # experimental config: format.exp-use-copies-side-data-changeset
3590 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3593 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3591 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3594 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3592 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3595 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3593 if ui.configbool(b'experimental', b'treemanifest'):
3596 if ui.configbool(b'experimental', b'treemanifest'):
3594 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3597 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3595
3598
3596 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3599 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3597 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3600 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3598 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3601 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3599
3602
3600 revlogv2 = ui.config(b'experimental', b'revlogv2')
3603 revlogv2 = ui.config(b'experimental', b'revlogv2')
3601 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3604 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3602 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3605 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3603 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3606 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3604 # experimental config: format.internal-phase
3607 # experimental config: format.internal-phase
3605 if ui.configbool(b'format', b'internal-phase'):
3608 if ui.configbool(b'format', b'internal-phase'):
3606 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3609 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3607
3610
3608 if createopts.get(b'narrowfiles'):
3611 if createopts.get(b'narrowfiles'):
3609 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3612 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3610
3613
3611 if createopts.get(b'lfs'):
3614 if createopts.get(b'lfs'):
3612 requirements.add(b'lfs')
3615 requirements.add(b'lfs')
3613
3616
3614 if ui.configbool(b'format', b'bookmarks-in-store'):
3617 if ui.configbool(b'format', b'bookmarks-in-store'):
3615 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3618 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3616
3619
3617 if ui.configbool(b'format', b'use-persistent-nodemap'):
3620 if ui.configbool(b'format', b'use-persistent-nodemap'):
3618 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3621 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3619
3622
3620 # if share-safe is enabled, let's create the new repository with the new
3623 # if share-safe is enabled, let's create the new repository with the new
3621 # requirement
3624 # requirement
3622 if ui.configbool(b'format', b'use-share-safe'):
3625 if ui.configbool(b'format', b'use-share-safe'):
3623 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3626 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3624
3627
3625 return requirements
3628 return requirements
3626
3629
3627
3630
3628 def checkrequirementscompat(ui, requirements):
3631 def checkrequirementscompat(ui, requirements):
3629 """Checks compatibility of repository requirements enabled and disabled.
3632 """Checks compatibility of repository requirements enabled and disabled.
3630
3633
3631 Returns a set of requirements which needs to be dropped because dependend
3634 Returns a set of requirements which needs to be dropped because dependend
3632 requirements are not enabled. Also warns users about it"""
3635 requirements are not enabled. Also warns users about it"""
3633
3636
3634 dropped = set()
3637 dropped = set()
3635
3638
3636 if requirementsmod.STORE_REQUIREMENT not in requirements:
3639 if requirementsmod.STORE_REQUIREMENT not in requirements:
3637 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3640 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3638 ui.warn(
3641 ui.warn(
3639 _(
3642 _(
3640 b'ignoring enabled \'format.bookmarks-in-store\' config '
3643 b'ignoring enabled \'format.bookmarks-in-store\' config '
3641 b'beacuse it is incompatible with disabled '
3644 b'beacuse it is incompatible with disabled '
3642 b'\'format.usestore\' config\n'
3645 b'\'format.usestore\' config\n'
3643 )
3646 )
3644 )
3647 )
3645 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3648 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3646
3649
3647 if (
3650 if (
3648 requirementsmod.SHARED_REQUIREMENT in requirements
3651 requirementsmod.SHARED_REQUIREMENT in requirements
3649 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3652 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3650 ):
3653 ):
3651 raise error.Abort(
3654 raise error.Abort(
3652 _(
3655 _(
3653 b"cannot create shared repository as source was created"
3656 b"cannot create shared repository as source was created"
3654 b" with 'format.usestore' config disabled"
3657 b" with 'format.usestore' config disabled"
3655 )
3658 )
3656 )
3659 )
3657
3660
3658 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3661 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3659 ui.warn(
3662 ui.warn(
3660 _(
3663 _(
3661 b"ignoring enabled 'format.use-share-safe' config because "
3664 b"ignoring enabled 'format.use-share-safe' config because "
3662 b"it is incompatible with disabled 'format.usestore'"
3665 b"it is incompatible with disabled 'format.usestore'"
3663 b" config\n"
3666 b" config\n"
3664 )
3667 )
3665 )
3668 )
3666 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3669 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3667
3670
3668 return dropped
3671 return dropped
3669
3672
3670
3673
3671 def filterknowncreateopts(ui, createopts):
3674 def filterknowncreateopts(ui, createopts):
3672 """Filters a dict of repo creation options against options that are known.
3675 """Filters a dict of repo creation options against options that are known.
3673
3676
3674 Receives a dict of repo creation options and returns a dict of those
3677 Receives a dict of repo creation options and returns a dict of those
3675 options that we don't know how to handle.
3678 options that we don't know how to handle.
3676
3679
3677 This function is called as part of repository creation. If the
3680 This function is called as part of repository creation. If the
3678 returned dict contains any items, repository creation will not
3681 returned dict contains any items, repository creation will not
3679 be allowed, as it means there was a request to create a repository
3682 be allowed, as it means there was a request to create a repository
3680 with options not recognized by loaded code.
3683 with options not recognized by loaded code.
3681
3684
3682 Extensions can wrap this function to filter out creation options
3685 Extensions can wrap this function to filter out creation options
3683 they know how to handle.
3686 they know how to handle.
3684 """
3687 """
3685 known = {
3688 known = {
3686 b'backend',
3689 b'backend',
3687 b'lfs',
3690 b'lfs',
3688 b'narrowfiles',
3691 b'narrowfiles',
3689 b'sharedrepo',
3692 b'sharedrepo',
3690 b'sharedrelative',
3693 b'sharedrelative',
3691 b'shareditems',
3694 b'shareditems',
3692 b'shallowfilestore',
3695 b'shallowfilestore',
3693 }
3696 }
3694
3697
3695 return {k: v for k, v in createopts.items() if k not in known}
3698 return {k: v for k, v in createopts.items() if k not in known}
3696
3699
3697
3700
3698 def createrepository(ui, path, createopts=None, requirements=None):
3701 def createrepository(ui, path, createopts=None, requirements=None):
3699 """Create a new repository in a vfs.
3702 """Create a new repository in a vfs.
3700
3703
3701 ``path`` path to the new repo's working directory.
3704 ``path`` path to the new repo's working directory.
3702 ``createopts`` options for the new repository.
3705 ``createopts`` options for the new repository.
3703 ``requirement`` predefined set of requirements.
3706 ``requirement`` predefined set of requirements.
3704 (incompatible with ``createopts``)
3707 (incompatible with ``createopts``)
3705
3708
3706 The following keys for ``createopts`` are recognized:
3709 The following keys for ``createopts`` are recognized:
3707
3710
3708 backend
3711 backend
3709 The storage backend to use.
3712 The storage backend to use.
3710 lfs
3713 lfs
3711 Repository will be created with ``lfs`` requirement. The lfs extension
3714 Repository will be created with ``lfs`` requirement. The lfs extension
3712 will automatically be loaded when the repository is accessed.
3715 will automatically be loaded when the repository is accessed.
3713 narrowfiles
3716 narrowfiles
3714 Set up repository to support narrow file storage.
3717 Set up repository to support narrow file storage.
3715 sharedrepo
3718 sharedrepo
3716 Repository object from which storage should be shared.
3719 Repository object from which storage should be shared.
3717 sharedrelative
3720 sharedrelative
3718 Boolean indicating if the path to the shared repo should be
3721 Boolean indicating if the path to the shared repo should be
3719 stored as relative. By default, the pointer to the "parent" repo
3722 stored as relative. By default, the pointer to the "parent" repo
3720 is stored as an absolute path.
3723 is stored as an absolute path.
3721 shareditems
3724 shareditems
3722 Set of items to share to the new repository (in addition to storage).
3725 Set of items to share to the new repository (in addition to storage).
3723 shallowfilestore
3726 shallowfilestore
3724 Indicates that storage for files should be shallow (not all ancestor
3727 Indicates that storage for files should be shallow (not all ancestor
3725 revisions are known).
3728 revisions are known).
3726 """
3729 """
3727
3730
3728 if requirements is not None:
3731 if requirements is not None:
3729 if createopts is not None:
3732 if createopts is not None:
3730 msg = b'cannot specify both createopts and requirements'
3733 msg = b'cannot specify both createopts and requirements'
3731 raise error.ProgrammingError(msg)
3734 raise error.ProgrammingError(msg)
3732 createopts = {}
3735 createopts = {}
3733 else:
3736 else:
3734 createopts = defaultcreateopts(ui, createopts=createopts)
3737 createopts = defaultcreateopts(ui, createopts=createopts)
3735
3738
3736 unknownopts = filterknowncreateopts(ui, createopts)
3739 unknownopts = filterknowncreateopts(ui, createopts)
3737
3740
3738 if not isinstance(unknownopts, dict):
3741 if not isinstance(unknownopts, dict):
3739 raise error.ProgrammingError(
3742 raise error.ProgrammingError(
3740 b'filterknowncreateopts() did not return a dict'
3743 b'filterknowncreateopts() did not return a dict'
3741 )
3744 )
3742
3745
3743 if unknownopts:
3746 if unknownopts:
3744 raise error.Abort(
3747 raise error.Abort(
3745 _(
3748 _(
3746 b'unable to create repository because of unknown '
3749 b'unable to create repository because of unknown '
3747 b'creation option: %s'
3750 b'creation option: %s'
3748 )
3751 )
3749 % b', '.join(sorted(unknownopts)),
3752 % b', '.join(sorted(unknownopts)),
3750 hint=_(b'is a required extension not loaded?'),
3753 hint=_(b'is a required extension not loaded?'),
3751 )
3754 )
3752
3755
3753 requirements = newreporequirements(ui, createopts=createopts)
3756 requirements = newreporequirements(ui, createopts=createopts)
3754 requirements -= checkrequirementscompat(ui, requirements)
3757 requirements -= checkrequirementscompat(ui, requirements)
3755
3758
3756 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3759 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3757
3760
3758 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3761 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3759 if hgvfs.exists():
3762 if hgvfs.exists():
3760 raise error.RepoError(_(b'repository %s already exists') % path)
3763 raise error.RepoError(_(b'repository %s already exists') % path)
3761
3764
3762 if b'sharedrepo' in createopts:
3765 if b'sharedrepo' in createopts:
3763 sharedpath = createopts[b'sharedrepo'].sharedpath
3766 sharedpath = createopts[b'sharedrepo'].sharedpath
3764
3767
3765 if createopts.get(b'sharedrelative'):
3768 if createopts.get(b'sharedrelative'):
3766 try:
3769 try:
3767 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3770 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3768 sharedpath = util.pconvert(sharedpath)
3771 sharedpath = util.pconvert(sharedpath)
3769 except (IOError, ValueError) as e:
3772 except (IOError, ValueError) as e:
3770 # ValueError is raised on Windows if the drive letters differ
3773 # ValueError is raised on Windows if the drive letters differ
3771 # on each path.
3774 # on each path.
3772 raise error.Abort(
3775 raise error.Abort(
3773 _(b'cannot calculate relative path'),
3776 _(b'cannot calculate relative path'),
3774 hint=stringutil.forcebytestr(e),
3777 hint=stringutil.forcebytestr(e),
3775 )
3778 )
3776
3779
3777 if not wdirvfs.exists():
3780 if not wdirvfs.exists():
3778 wdirvfs.makedirs()
3781 wdirvfs.makedirs()
3779
3782
3780 hgvfs.makedir(notindexed=True)
3783 hgvfs.makedir(notindexed=True)
3781 if b'sharedrepo' not in createopts:
3784 if b'sharedrepo' not in createopts:
3782 hgvfs.mkdir(b'cache')
3785 hgvfs.mkdir(b'cache')
3783 hgvfs.mkdir(b'wcache')
3786 hgvfs.mkdir(b'wcache')
3784
3787
3785 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3788 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3786 if has_store and b'sharedrepo' not in createopts:
3789 if has_store and b'sharedrepo' not in createopts:
3787 hgvfs.mkdir(b'store')
3790 hgvfs.mkdir(b'store')
3788
3791
3789 # We create an invalid changelog outside the store so very old
3792 # We create an invalid changelog outside the store so very old
3790 # Mercurial versions (which didn't know about the requirements
3793 # Mercurial versions (which didn't know about the requirements
3791 # file) encounter an error on reading the changelog. This
3794 # file) encounter an error on reading the changelog. This
3792 # effectively locks out old clients and prevents them from
3795 # effectively locks out old clients and prevents them from
3793 # mucking with a repo in an unknown format.
3796 # mucking with a repo in an unknown format.
3794 #
3797 #
3795 # The revlog header has version 65535, which won't be recognized by
3798 # The revlog header has version 65535, which won't be recognized by
3796 # such old clients.
3799 # such old clients.
3797 hgvfs.append(
3800 hgvfs.append(
3798 b'00changelog.i',
3801 b'00changelog.i',
3799 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3802 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3800 b'layout',
3803 b'layout',
3801 )
3804 )
3802
3805
3803 # Filter the requirements into working copy and store ones
3806 # Filter the requirements into working copy and store ones
3804 wcreq, storereq = scmutil.filterrequirements(requirements)
3807 wcreq, storereq = scmutil.filterrequirements(requirements)
3805 # write working copy ones
3808 # write working copy ones
3806 scmutil.writerequires(hgvfs, wcreq)
3809 scmutil.writerequires(hgvfs, wcreq)
3807 # If there are store requirements and the current repository
3810 # If there are store requirements and the current repository
3808 # is not a shared one, write stored requirements
3811 # is not a shared one, write stored requirements
3809 # For new shared repository, we don't need to write the store
3812 # For new shared repository, we don't need to write the store
3810 # requirements as they are already present in store requires
3813 # requirements as they are already present in store requires
3811 if storereq and b'sharedrepo' not in createopts:
3814 if storereq and b'sharedrepo' not in createopts:
3812 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3815 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3813 scmutil.writerequires(storevfs, storereq)
3816 scmutil.writerequires(storevfs, storereq)
3814
3817
3815 # Write out file telling readers where to find the shared store.
3818 # Write out file telling readers where to find the shared store.
3816 if b'sharedrepo' in createopts:
3819 if b'sharedrepo' in createopts:
3817 hgvfs.write(b'sharedpath', sharedpath)
3820 hgvfs.write(b'sharedpath', sharedpath)
3818
3821
3819 if createopts.get(b'shareditems'):
3822 if createopts.get(b'shareditems'):
3820 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3823 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3821 hgvfs.write(b'shared', shared)
3824 hgvfs.write(b'shared', shared)
3822
3825
3823
3826
3824 def poisonrepository(repo):
3827 def poisonrepository(repo):
3825 """Poison a repository instance so it can no longer be used."""
3828 """Poison a repository instance so it can no longer be used."""
3826 # Perform any cleanup on the instance.
3829 # Perform any cleanup on the instance.
3827 repo.close()
3830 repo.close()
3828
3831
3829 # Our strategy is to replace the type of the object with one that
3832 # Our strategy is to replace the type of the object with one that
3830 # has all attribute lookups result in error.
3833 # has all attribute lookups result in error.
3831 #
3834 #
3832 # But we have to allow the close() method because some constructors
3835 # But we have to allow the close() method because some constructors
3833 # of repos call close() on repo references.
3836 # of repos call close() on repo references.
3834 class poisonedrepository(object):
3837 class poisonedrepository(object):
3835 def __getattribute__(self, item):
3838 def __getattribute__(self, item):
3836 if item == 'close':
3839 if item == 'close':
3837 return object.__getattribute__(self, item)
3840 return object.__getattribute__(self, item)
3838
3841
3839 raise error.ProgrammingError(
3842 raise error.ProgrammingError(
3840 b'repo instances should not be used after unshare'
3843 b'repo instances should not be used after unshare'
3841 )
3844 )
3842
3845
3843 def close(self):
3846 def close(self):
3844 pass
3847 pass
3845
3848
3846 # We may have a repoview, which intercepts __setattr__. So be sure
3849 # We may have a repoview, which intercepts __setattr__. So be sure
3847 # we operate at the lowest level possible.
3850 # we operate at the lowest level possible.
3848 object.__setattr__(repo, '__class__', poisonedrepository)
3851 object.__setattr__(repo, '__class__', poisonedrepository)
@@ -1,526 +1,627 b''
1 ===============================================================
1 ===============================================================
2 Test non-regression on the corruption associated with issue6528
2 Test non-regression on the corruption associated with issue6528
3 ===============================================================
3 ===============================================================
4
4
5 Setup
5 Setup
6 =====
6 =====
7
7
8 $ hg init base-repo
8 $ hg init base-repo
9 $ cd base-repo
9 $ cd base-repo
10
10
11 $ cat <<EOF > a.txt
11 $ cat <<EOF > a.txt
12 > 1
12 > 1
13 > 2
13 > 2
14 > 3
14 > 3
15 > 4
15 > 4
16 > 5
16 > 5
17 > 6
17 > 6
18 > EOF
18 > EOF
19
19
20 $ hg add a.txt
20 $ hg add a.txt
21 $ hg commit -m 'c_base_c - create a.txt'
21 $ hg commit -m 'c_base_c - create a.txt'
22
22
23 Modify a.txt
23 Modify a.txt
24
24
25 $ sed -e 's/1/foo/' a.txt > a.tmp; mv a.tmp a.txt
25 $ sed -e 's/1/foo/' a.txt > a.tmp; mv a.tmp a.txt
26 $ hg commit -m 'c_modify_c - modify a.txt'
26 $ hg commit -m 'c_modify_c - modify a.txt'
27
27
28 Modify and rename a.txt to b.txt
28 Modify and rename a.txt to b.txt
29
29
30 $ hg up -r "desc('c_base_c')"
30 $ hg up -r "desc('c_base_c')"
31 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
31 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 $ sed -e 's/6/bar/' a.txt > a.tmp; mv a.tmp a.txt
32 $ sed -e 's/6/bar/' a.txt > a.tmp; mv a.tmp a.txt
33 $ hg mv a.txt b.txt
33 $ hg mv a.txt b.txt
34 $ hg commit -m 'c_rename_c - rename and modify a.txt to b.txt'
34 $ hg commit -m 'c_rename_c - rename and modify a.txt to b.txt'
35 created new head
35 created new head
36
36
37 Merge each branch
37 Merge each branch
38
38
39 $ hg merge -r "desc('c_modify_c')"
39 $ hg merge -r "desc('c_modify_c')"
40 merging b.txt and a.txt to b.txt
40 merging b.txt and a.txt to b.txt
41 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
41 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
42 (branch merge, don't forget to commit)
42 (branch merge, don't forget to commit)
43 $ hg commit -m 'c_merge_c: commit merge'
43 $ hg commit -m 'c_merge_c: commit merge'
44
44
45 $ hg debugrevlogindex b.txt
45 $ hg debugrevlogindex b.txt
46 rev linkrev nodeid p1 p2
46 rev linkrev nodeid p1 p2
47 0 2 05b806ebe5ea 000000000000 000000000000
47 0 2 05b806ebe5ea 000000000000 000000000000
48 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
48 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
49
49
50 Check commit Graph
50 Check commit Graph
51
51
52 $ hg log -G
52 $ hg log -G
53 @ changeset: 3:a1cc2bdca0aa
53 @ changeset: 3:a1cc2bdca0aa
54 |\ tag: tip
54 |\ tag: tip
55 | | parent: 2:615c6ccefd15
55 | | parent: 2:615c6ccefd15
56 | | parent: 1:373d507f4667
56 | | parent: 1:373d507f4667
57 | | user: test
57 | | user: test
58 | | date: Thu Jan 01 00:00:00 1970 +0000
58 | | date: Thu Jan 01 00:00:00 1970 +0000
59 | | summary: c_merge_c: commit merge
59 | | summary: c_merge_c: commit merge
60 | |
60 | |
61 | o changeset: 2:615c6ccefd15
61 | o changeset: 2:615c6ccefd15
62 | | parent: 0:f5a5a568022f
62 | | parent: 0:f5a5a568022f
63 | | user: test
63 | | user: test
64 | | date: Thu Jan 01 00:00:00 1970 +0000
64 | | date: Thu Jan 01 00:00:00 1970 +0000
65 | | summary: c_rename_c - rename and modify a.txt to b.txt
65 | | summary: c_rename_c - rename and modify a.txt to b.txt
66 | |
66 | |
67 o | changeset: 1:373d507f4667
67 o | changeset: 1:373d507f4667
68 |/ user: test
68 |/ user: test
69 | date: Thu Jan 01 00:00:00 1970 +0000
69 | date: Thu Jan 01 00:00:00 1970 +0000
70 | summary: c_modify_c - modify a.txt
70 | summary: c_modify_c - modify a.txt
71 |
71 |
72 o changeset: 0:f5a5a568022f
72 o changeset: 0:f5a5a568022f
73 user: test
73 user: test
74 date: Thu Jan 01 00:00:00 1970 +0000
74 date: Thu Jan 01 00:00:00 1970 +0000
75 summary: c_base_c - create a.txt
75 summary: c_base_c - create a.txt
76
76
77
77
78 $ hg cat -r . b.txt
78 $ hg cat -r . b.txt
79 foo
79 foo
80 2
80 2
81 3
81 3
82 4
82 4
83 5
83 5
84 bar
84 bar
85 $ cat b.txt
85 $ cat b.txt
86 foo
86 foo
87 2
87 2
88 3
88 3
89 4
89 4
90 5
90 5
91 bar
91 bar
92 $ cd ..
92 $ cd ..
93
93
94
94
95 Check the lack of corruption
95 Check the lack of corruption
96 ============================
96 ============================
97
97
98 $ hg clone --pull base-repo cloned
98 $ hg clone --pull base-repo cloned
99 requesting all changes
99 requesting all changes
100 adding changesets
100 adding changesets
101 adding manifests
101 adding manifests
102 adding file changes
102 adding file changes
103 added 4 changesets with 4 changes to 2 files
103 added 4 changesets with 4 changes to 2 files
104 new changesets f5a5a568022f:a1cc2bdca0aa
104 new changesets f5a5a568022f:a1cc2bdca0aa
105 updating to branch default
105 updating to branch default
106 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
106 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
107 $ cd cloned
107 $ cd cloned
108 $ hg up -r "desc('c_merge_c')"
108 $ hg up -r "desc('c_merge_c')"
109 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
110
110
111
111
112 Status is buggy, even with debugrebuilddirstate
112 Status is buggy, even with debugrebuilddirstate
113
113
114 $ hg cat -r . b.txt
114 $ hg cat -r . b.txt
115 foo
115 foo
116 2
116 2
117 3
117 3
118 4
118 4
119 5
119 5
120 bar
120 bar
121 $ cat b.txt
121 $ cat b.txt
122 foo
122 foo
123 2
123 2
124 3
124 3
125 4
125 4
126 5
126 5
127 bar
127 bar
128 $ hg status
128 $ hg status
129 $ hg debugrebuilddirstate
129 $ hg debugrebuilddirstate
130 $ hg status
130 $ hg status
131
131
132 the history was altered
132 the history was altered
133
133
134 in theory p1/p2 order does not matter but in practice p1 == nullid is used as a
134 in theory p1/p2 order does not matter but in practice p1 == nullid is used as a
135 marker that some metadata are present and should be fetched.
135 marker that some metadata are present and should be fetched.
136
136
137 $ hg debugrevlogindex b.txt
137 $ hg debugrevlogindex b.txt
138 rev linkrev nodeid p1 p2
138 rev linkrev nodeid p1 p2
139 0 2 05b806ebe5ea 000000000000 000000000000
139 0 2 05b806ebe5ea 000000000000 000000000000
140 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
140 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
141
141
142 Check commit Graph
142 Check commit Graph
143
143
144 $ hg log -G
144 $ hg log -G
145 @ changeset: 3:a1cc2bdca0aa
145 @ changeset: 3:a1cc2bdca0aa
146 |\ tag: tip
146 |\ tag: tip
147 | | parent: 2:615c6ccefd15
147 | | parent: 2:615c6ccefd15
148 | | parent: 1:373d507f4667
148 | | parent: 1:373d507f4667
149 | | user: test
149 | | user: test
150 | | date: Thu Jan 01 00:00:00 1970 +0000
150 | | date: Thu Jan 01 00:00:00 1970 +0000
151 | | summary: c_merge_c: commit merge
151 | | summary: c_merge_c: commit merge
152 | |
152 | |
153 | o changeset: 2:615c6ccefd15
153 | o changeset: 2:615c6ccefd15
154 | | parent: 0:f5a5a568022f
154 | | parent: 0:f5a5a568022f
155 | | user: test
155 | | user: test
156 | | date: Thu Jan 01 00:00:00 1970 +0000
156 | | date: Thu Jan 01 00:00:00 1970 +0000
157 | | summary: c_rename_c - rename and modify a.txt to b.txt
157 | | summary: c_rename_c - rename and modify a.txt to b.txt
158 | |
158 | |
159 o | changeset: 1:373d507f4667
159 o | changeset: 1:373d507f4667
160 |/ user: test
160 |/ user: test
161 | date: Thu Jan 01 00:00:00 1970 +0000
161 | date: Thu Jan 01 00:00:00 1970 +0000
162 | summary: c_modify_c - modify a.txt
162 | summary: c_modify_c - modify a.txt
163 |
163 |
164 o changeset: 0:f5a5a568022f
164 o changeset: 0:f5a5a568022f
165 user: test
165 user: test
166 date: Thu Jan 01 00:00:00 1970 +0000
166 date: Thu Jan 01 00:00:00 1970 +0000
167 summary: c_base_c - create a.txt
167 summary: c_base_c - create a.txt
168
168
169
169
170 Test the command that fixes the issue
170 Test the command that fixes the issue
171 =====================================
171 =====================================
172
172
173 Restore a broken repository with multiple broken revisions and a filename that
173 Restore a broken repository with multiple broken revisions and a filename that
174 would get encoded to test the `report` options.
174 would get encoded to test the `report` options.
175 It's a tarball because unbundle might magically fix the issue later.
175 It's a tarball because unbundle might magically fix the issue later.
176
176
177 $ cd ..
177 $ cd ..
178 $ mkdir repo-to-fix
178 $ mkdir repo-to-fix
179 $ cd repo-to-fix
179 $ cd repo-to-fix
180 #if windows
180 #if windows
181 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
181 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
182 only since some versions of tar don't have this flag.
182 only since some versions of tar don't have this flag.
183
183
184 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
184 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
185 #else
185 #else
186 $ tar xf $TESTDIR/bundles/issue6528.tar
186 $ tar xf $TESTDIR/bundles/issue6528.tar
187 #endif
187 #endif
188
188
189 Check that the issue is present
189 Check that the issue is present
190 $ hg st
190 $ hg st
191 M D.txt
191 M D.txt
192 M b.txt
192 M b.txt
193 $ hg debugrevlogindex b.txt
193 $ hg debugrevlogindex b.txt
194 rev linkrev nodeid p1 p2
194 rev linkrev nodeid p1 p2
195 0 2 05b806ebe5ea 000000000000 000000000000
195 0 2 05b806ebe5ea 000000000000 000000000000
196 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
196 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
197 2 6 216a5fe8b8ed 000000000000 000000000000
197 2 6 216a5fe8b8ed 000000000000 000000000000
198 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
198 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
199 $ hg debugrevlogindex D.txt
199 $ hg debugrevlogindex D.txt
200 rev linkrev nodeid p1 p2
200 rev linkrev nodeid p1 p2
201 0 6 2a8d3833f2fb 000000000000 000000000000
201 0 6 2a8d3833f2fb 000000000000 000000000000
202 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
202 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
203
203
204 Dry-run the fix
204 Dry-run the fix
205 $ hg debug-repair-issue6528 --dry-run
205 $ hg debug-repair-issue6528 --dry-run
206 found affected revision 1 for filelog 'data/D.txt.i'
206 found affected revision 1 for filelog 'data/D.txt.i'
207 found affected revision 1 for filelog 'data/b.txt.i'
207 found affected revision 1 for filelog 'data/b.txt.i'
208 found affected revision 3 for filelog 'data/b.txt.i'
208 found affected revision 3 for filelog 'data/b.txt.i'
209 $ hg st
209 $ hg st
210 M D.txt
210 M D.txt
211 M b.txt
211 M b.txt
212 $ hg debugrevlogindex b.txt
212 $ hg debugrevlogindex b.txt
213 rev linkrev nodeid p1 p2
213 rev linkrev nodeid p1 p2
214 0 2 05b806ebe5ea 000000000000 000000000000
214 0 2 05b806ebe5ea 000000000000 000000000000
215 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
215 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
216 2 6 216a5fe8b8ed 000000000000 000000000000
216 2 6 216a5fe8b8ed 000000000000 000000000000
217 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
217 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
218 $ hg debugrevlogindex D.txt
218 $ hg debugrevlogindex D.txt
219 rev linkrev nodeid p1 p2
219 rev linkrev nodeid p1 p2
220 0 6 2a8d3833f2fb 000000000000 000000000000
220 0 6 2a8d3833f2fb 000000000000 000000000000
221 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
221 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
222
222
223 Test the --paranoid option
223 Test the --paranoid option
224 $ hg debug-repair-issue6528 --dry-run --paranoid
224 $ hg debug-repair-issue6528 --dry-run --paranoid
225 found affected revision 1 for filelog 'data/D.txt.i'
225 found affected revision 1 for filelog 'data/D.txt.i'
226 found affected revision 1 for filelog 'data/b.txt.i'
226 found affected revision 1 for filelog 'data/b.txt.i'
227 found affected revision 3 for filelog 'data/b.txt.i'
227 found affected revision 3 for filelog 'data/b.txt.i'
228 $ hg st
228 $ hg st
229 M D.txt
229 M D.txt
230 M b.txt
230 M b.txt
231 $ hg debugrevlogindex b.txt
231 $ hg debugrevlogindex b.txt
232 rev linkrev nodeid p1 p2
232 rev linkrev nodeid p1 p2
233 0 2 05b806ebe5ea 000000000000 000000000000
233 0 2 05b806ebe5ea 000000000000 000000000000
234 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
234 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
235 2 6 216a5fe8b8ed 000000000000 000000000000
235 2 6 216a5fe8b8ed 000000000000 000000000000
236 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
236 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
237 $ hg debugrevlogindex D.txt
237 $ hg debugrevlogindex D.txt
238 rev linkrev nodeid p1 p2
238 rev linkrev nodeid p1 p2
239 0 6 2a8d3833f2fb 000000000000 000000000000
239 0 6 2a8d3833f2fb 000000000000 000000000000
240 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
240 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
241
241
242 Run the fix
242 Run the fix
243 $ hg debug-repair-issue6528
243 $ hg debug-repair-issue6528
244 found affected revision 1 for filelog 'data/D.txt.i'
244 found affected revision 1 for filelog 'data/D.txt.i'
245 repaired revision 1 of 'filelog data/D.txt.i'
245 repaired revision 1 of 'filelog data/D.txt.i'
246 found affected revision 1 for filelog 'data/b.txt.i'
246 found affected revision 1 for filelog 'data/b.txt.i'
247 found affected revision 3 for filelog 'data/b.txt.i'
247 found affected revision 3 for filelog 'data/b.txt.i'
248 repaired revision 1 of 'filelog data/b.txt.i'
248 repaired revision 1 of 'filelog data/b.txt.i'
249 repaired revision 3 of 'filelog data/b.txt.i'
249 repaired revision 3 of 'filelog data/b.txt.i'
250
250
251 Check that the fix worked and that running it twice does nothing
251 Check that the fix worked and that running it twice does nothing
252 $ hg st
252 $ hg st
253 $ hg debugrevlogindex b.txt
253 $ hg debugrevlogindex b.txt
254 rev linkrev nodeid p1 p2
254 rev linkrev nodeid p1 p2
255 0 2 05b806ebe5ea 000000000000 000000000000
255 0 2 05b806ebe5ea 000000000000 000000000000
256 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
256 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
257 2 6 216a5fe8b8ed 000000000000 000000000000
257 2 6 216a5fe8b8ed 000000000000 000000000000
258 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
258 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
259 $ hg debugrevlogindex D.txt
259 $ hg debugrevlogindex D.txt
260 rev linkrev nodeid p1 p2
260 rev linkrev nodeid p1 p2
261 0 6 2a8d3833f2fb 000000000000 000000000000
261 0 6 2a8d3833f2fb 000000000000 000000000000
262 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
262 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
263 $ hg debug-repair-issue6528
263 $ hg debug-repair-issue6528
264 no affected revisions were found
264 no affected revisions were found
265 $ hg st
265 $ hg st
266 $ hg debugrevlogindex b.txt
266 $ hg debugrevlogindex b.txt
267 rev linkrev nodeid p1 p2
267 rev linkrev nodeid p1 p2
268 0 2 05b806ebe5ea 000000000000 000000000000
268 0 2 05b806ebe5ea 000000000000 000000000000
269 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
269 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
270 2 6 216a5fe8b8ed 000000000000 000000000000
270 2 6 216a5fe8b8ed 000000000000 000000000000
271 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
271 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
272 $ hg debugrevlogindex D.txt
272 $ hg debugrevlogindex D.txt
273 rev linkrev nodeid p1 p2
273 rev linkrev nodeid p1 p2
274 0 6 2a8d3833f2fb 000000000000 000000000000
274 0 6 2a8d3833f2fb 000000000000 000000000000
275 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
275 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
276
276
277 Try the using the report options
277 Try the using the report options
278 --------------------------------
278 --------------------------------
279
279
280 $ cd ..
280 $ cd ..
281 $ mkdir repo-to-fix-report
281 $ mkdir repo-to-fix-report
282 $ cd repo-to-fix
282 $ cd repo-to-fix
283 #if windows
283 #if windows
284 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
284 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
285 only since some versions of tar don't have this flag.
285 only since some versions of tar don't have this flag.
286
286
287 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
287 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
288 #else
288 #else
289 $ tar xf $TESTDIR/bundles/issue6528.tar
289 $ tar xf $TESTDIR/bundles/issue6528.tar
290 #endif
290 #endif
291
291
292 $ hg debug-repair-issue6528 --to-report $TESTTMP/report.txt
292 $ hg debug-repair-issue6528 --to-report $TESTTMP/report.txt
293 found affected revision 1 for filelog 'data/D.txt.i'
293 found affected revision 1 for filelog 'data/D.txt.i'
294 found affected revision 1 for filelog 'data/b.txt.i'
294 found affected revision 1 for filelog 'data/b.txt.i'
295 found affected revision 3 for filelog 'data/b.txt.i'
295 found affected revision 3 for filelog 'data/b.txt.i'
296 $ cat $TESTTMP/report.txt
296 $ cat $TESTTMP/report.txt
297 2a80419dfc31d7dfb308ac40f3f138282de7d73b D.txt
297 2a80419dfc31d7dfb308ac40f3f138282de7d73b D.txt
298 a58b36ad6b6545195952793099613c2116f3563b,ea4f2f2463cca5b29ddf3461012b8ce5c6dac175 b.txt
298 a58b36ad6b6545195952793099613c2116f3563b,ea4f2f2463cca5b29ddf3461012b8ce5c6dac175 b.txt
299
299
300 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt --dry-run
300 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt --dry-run
301 loading report file '$TESTTMP/report.txt'
301 loading report file '$TESTTMP/report.txt'
302 found affected revision 1 for filelog 'D.txt'
302 found affected revision 1 for filelog 'D.txt'
303 found affected revision 1 for filelog 'b.txt'
303 found affected revision 1 for filelog 'b.txt'
304 found affected revision 3 for filelog 'b.txt'
304 found affected revision 3 for filelog 'b.txt'
305 $ hg st
305 $ hg st
306 M D.txt
306 M D.txt
307 M b.txt
307 M b.txt
308 $ hg debugrevlogindex b.txt
308 $ hg debugrevlogindex b.txt
309 rev linkrev nodeid p1 p2
309 rev linkrev nodeid p1 p2
310 0 2 05b806ebe5ea 000000000000 000000000000
310 0 2 05b806ebe5ea 000000000000 000000000000
311 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
311 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
312 2 6 216a5fe8b8ed 000000000000 000000000000
312 2 6 216a5fe8b8ed 000000000000 000000000000
313 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
313 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
314 $ hg debugrevlogindex D.txt
314 $ hg debugrevlogindex D.txt
315 rev linkrev nodeid p1 p2
315 rev linkrev nodeid p1 p2
316 0 6 2a8d3833f2fb 000000000000 000000000000
316 0 6 2a8d3833f2fb 000000000000 000000000000
317 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
317 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
318
318
319 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt
319 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt
320 loading report file '$TESTTMP/report.txt'
320 loading report file '$TESTTMP/report.txt'
321 found affected revision 1 for filelog 'D.txt'
321 found affected revision 1 for filelog 'D.txt'
322 repaired revision 1 of 'filelog data/D.txt.i'
322 repaired revision 1 of 'filelog data/D.txt.i'
323 found affected revision 1 for filelog 'b.txt'
323 found affected revision 1 for filelog 'b.txt'
324 found affected revision 3 for filelog 'b.txt'
324 found affected revision 3 for filelog 'b.txt'
325 repaired revision 1 of 'filelog data/b.txt.i'
325 repaired revision 1 of 'filelog data/b.txt.i'
326 repaired revision 3 of 'filelog data/b.txt.i'
326 repaired revision 3 of 'filelog data/b.txt.i'
327 $ hg st
327 $ hg st
328 $ hg debugrevlogindex b.txt
328 $ hg debugrevlogindex b.txt
329 rev linkrev nodeid p1 p2
329 rev linkrev nodeid p1 p2
330 0 2 05b806ebe5ea 000000000000 000000000000
330 0 2 05b806ebe5ea 000000000000 000000000000
331 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
331 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
332 2 6 216a5fe8b8ed 000000000000 000000000000
332 2 6 216a5fe8b8ed 000000000000 000000000000
333 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
333 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
334 $ hg debugrevlogindex D.txt
334 $ hg debugrevlogindex D.txt
335 rev linkrev nodeid p1 p2
335 rev linkrev nodeid p1 p2
336 0 6 2a8d3833f2fb 000000000000 000000000000
336 0 6 2a8d3833f2fb 000000000000 000000000000
337 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
337 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
338
338
339 Check that the revision is not "fixed" again
339 Check that the revision is not "fixed" again
340
340
341 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt
341 $ hg debug-repair-issue6528 --from-report $TESTTMP/report.txt
342 loading report file '$TESTTMP/report.txt'
342 loading report file '$TESTTMP/report.txt'
343 revision 2a80419dfc31d7dfb308ac40f3f138282de7d73b of file 'D.txt' is not affected
343 revision 2a80419dfc31d7dfb308ac40f3f138282de7d73b of file 'D.txt' is not affected
344 no affected revisions were found for 'D.txt'
344 no affected revisions were found for 'D.txt'
345 revision a58b36ad6b6545195952793099613c2116f3563b of file 'b.txt' is not affected
345 revision a58b36ad6b6545195952793099613c2116f3563b of file 'b.txt' is not affected
346 revision ea4f2f2463cca5b29ddf3461012b8ce5c6dac175 of file 'b.txt' is not affected
346 revision ea4f2f2463cca5b29ddf3461012b8ce5c6dac175 of file 'b.txt' is not affected
347 no affected revisions were found for 'b.txt'
347 no affected revisions were found for 'b.txt'
348 $ hg st
348 $ hg st
349 $ hg debugrevlogindex b.txt
349 $ hg debugrevlogindex b.txt
350 rev linkrev nodeid p1 p2
350 rev linkrev nodeid p1 p2
351 0 2 05b806ebe5ea 000000000000 000000000000
351 0 2 05b806ebe5ea 000000000000 000000000000
352 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
352 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
353 2 6 216a5fe8b8ed 000000000000 000000000000
353 2 6 216a5fe8b8ed 000000000000 000000000000
354 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
354 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
355 $ hg debugrevlogindex D.txt
355 $ hg debugrevlogindex D.txt
356 rev linkrev nodeid p1 p2
356 rev linkrev nodeid p1 p2
357 0 6 2a8d3833f2fb 000000000000 000000000000
357 0 6 2a8d3833f2fb 000000000000 000000000000
358 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
358 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
359
359
360 Try it with a non-inline revlog
360 Try it with a non-inline revlog
361 -------------------------------
361 -------------------------------
362
362
363 $ cd ..
363 $ cd ..
364 $ mkdir $TESTTMP/ext
364 $ mkdir $TESTTMP/ext
365 $ cat << EOF > $TESTTMP/ext/small_inline.py
365 $ cat << EOF > $TESTTMP/ext/small_inline.py
366 > from mercurial import revlog
366 > from mercurial import revlog
367 > revlog._maxinline = 8
367 > revlog._maxinline = 8
368 > EOF
368 > EOF
369
369
370 $ cat << EOF >> $HGRCPATH
370 $ cat << EOF >> $HGRCPATH
371 > [extensions]
371 > [extensions]
372 > small_inline=$TESTTMP/ext/small_inline.py
372 > small_inline=$TESTTMP/ext/small_inline.py
373 > EOF
373 > EOF
374
374
375 $ mkdir repo-to-fix-not-inline
375 $ mkdir repo-to-fix-not-inline
376 $ cd repo-to-fix-not-inline
376 $ cd repo-to-fix-not-inline
377 #if windows
377 #if windows
378 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
378 tar interprets `:` in paths (like `C:`) as being remote, force local on Windows
379 only since some versions of tar don't have this flag.
379 only since some versions of tar don't have this flag.
380
380
381 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
381 $ tar --force-local -xf $TESTDIR/bundles/issue6528.tar
382 #else
382 #else
383 $ tar xf $TESTDIR/bundles/issue6528.tar
383 $ tar xf $TESTDIR/bundles/issue6528.tar
384 #endif
384 #endif
385 $ echo b >> b.txt
385 $ echo b >> b.txt
386 $ hg commit -qm "inline -> separate"
386 $ hg commit -qm "inline -> separate"
387 $ find .hg -name *b.txt.d
387 $ find .hg -name *b.txt.d
388 .hg/store/data/b.txt.d
388 .hg/store/data/b.txt.d
389
389
390 Status is correct, but the problem is still there, in the earlier revision
390 Status is correct, but the problem is still there, in the earlier revision
391 $ hg st
391 $ hg st
392 $ hg up 3
392 $ hg up 3
393 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
393 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
394 $ hg st
394 $ hg st
395 M b.txt
395 M b.txt
396 $ hg debugrevlogindex b.txt
396 $ hg debugrevlogindex b.txt
397 rev linkrev nodeid p1 p2
397 rev linkrev nodeid p1 p2
398 0 2 05b806ebe5ea 000000000000 000000000000
398 0 2 05b806ebe5ea 000000000000 000000000000
399 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
399 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
400 2 6 216a5fe8b8ed 000000000000 000000000000
400 2 6 216a5fe8b8ed 000000000000 000000000000
401 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
401 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
402 4 8 db234885e2fe ea4f2f2463cc 000000000000
402 4 8 db234885e2fe ea4f2f2463cc 000000000000
403 $ hg debugrevlogindex D.txt
403 $ hg debugrevlogindex D.txt
404 rev linkrev nodeid p1 p2
404 rev linkrev nodeid p1 p2
405 0 6 2a8d3833f2fb 000000000000 000000000000
405 0 6 2a8d3833f2fb 000000000000 000000000000
406 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
406 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
407 2 8 65aecc89bb5d 2a80419dfc31 000000000000
407 2 8 65aecc89bb5d 2a80419dfc31 000000000000
408
408
409 Run the fix on the non-inline revlog
409 Run the fix on the non-inline revlog
410 $ hg debug-repair-issue6528
410 $ hg debug-repair-issue6528
411 found affected revision 1 for filelog 'data/D.txt.i'
411 found affected revision 1 for filelog 'data/D.txt.i'
412 repaired revision 1 of 'filelog data/D.txt.i'
412 repaired revision 1 of 'filelog data/D.txt.i'
413 found affected revision 1 for filelog 'data/b.txt.i'
413 found affected revision 1 for filelog 'data/b.txt.i'
414 found affected revision 3 for filelog 'data/b.txt.i'
414 found affected revision 3 for filelog 'data/b.txt.i'
415 repaired revision 1 of 'filelog data/b.txt.i'
415 repaired revision 1 of 'filelog data/b.txt.i'
416 repaired revision 3 of 'filelog data/b.txt.i'
416 repaired revision 3 of 'filelog data/b.txt.i'
417
417
418 Check that it worked
418 Check that it worked
419 $ hg debugrevlogindex b.txt
419 $ hg debugrevlogindex b.txt
420 rev linkrev nodeid p1 p2
420 rev linkrev nodeid p1 p2
421 0 2 05b806ebe5ea 000000000000 000000000000
421 0 2 05b806ebe5ea 000000000000 000000000000
422 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
422 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
423 2 6 216a5fe8b8ed 000000000000 000000000000
423 2 6 216a5fe8b8ed 000000000000 000000000000
424 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
424 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
425 4 8 db234885e2fe ea4f2f2463cc 000000000000
425 4 8 db234885e2fe ea4f2f2463cc 000000000000
426 $ hg debugrevlogindex D.txt
426 $ hg debugrevlogindex D.txt
427 rev linkrev nodeid p1 p2
427 rev linkrev nodeid p1 p2
428 0 6 2a8d3833f2fb 000000000000 000000000000
428 0 6 2a8d3833f2fb 000000000000 000000000000
429 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
429 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
430 2 8 65aecc89bb5d 2a80419dfc31 000000000000
430 2 8 65aecc89bb5d 2a80419dfc31 000000000000
431 $ hg debug-repair-issue6528
431 $ hg debug-repair-issue6528
432 no affected revisions were found
432 no affected revisions were found
433 $ hg st
433 $ hg st
434
434
435 $ cd ..
435 $ cd ..
436
436
437 Applying a bad bundle should fix it on the fly
437 Applying a bad bundle should fix it on the fly
438 ----------------------------------------------
438 ----------------------------------------------
439
439
440 from a v1 bundle
440 from a v1 bundle
441 ~~~~~~~~~~~~~~~~
441 ~~~~~~~~~~~~~~~~
442
442
443 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v1
443 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v1
444 bzip2-v1
444 bzip2-v1
445
445
446 $ hg init unbundle-v1
446 $ hg init unbundle-v1
447 $ cd unbundle-v1
447 $ cd unbundle-v1
448
448
449 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v1
449 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v1
450 adding changesets
450 adding changesets
451 adding manifests
451 adding manifests
452 adding file changes
452 adding file changes
453 added 8 changesets with 12 changes to 4 files
453 added 8 changesets with 12 changes to 4 files
454 new changesets f5a5a568022f:3beabb508514 (8 drafts)
454 new changesets f5a5a568022f:3beabb508514 (8 drafts)
455 (run 'hg update' to get a working copy)
455 (run 'hg update' to get a working copy)
456
456
457 Check that revision were fixed on the fly
457 Check that revision were fixed on the fly
458
458
459 $ hg debugrevlogindex b.txt
459 $ hg debugrevlogindex b.txt
460 rev linkrev nodeid p1 p2
460 rev linkrev nodeid p1 p2
461 0 2 05b806ebe5ea 000000000000 000000000000
461 0 2 05b806ebe5ea 000000000000 000000000000
462 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
462 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
463 2 6 216a5fe8b8ed 000000000000 000000000000
463 2 6 216a5fe8b8ed 000000000000 000000000000
464 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
464 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
465
465
466 $ hg debugrevlogindex D.txt
466 $ hg debugrevlogindex D.txt
467 rev linkrev nodeid p1 p2
467 rev linkrev nodeid p1 p2
468 0 6 2a8d3833f2fb 000000000000 000000000000
468 0 6 2a8d3833f2fb 000000000000 000000000000
469 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
469 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
470
470
471 That we don't see the symptoms of the bug
471 That we don't see the symptoms of the bug
472
472
473 $ hg up -- -1
473 $ hg up -- -1
474 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
474 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
475 $ hg status
475 $ hg status
476
476
477 And that the repair command does not find anything to fix
477 And that the repair command does not find anything to fix
478
478
479 $ hg debug-repair-issue6528
479 $ hg debug-repair-issue6528
480 no affected revisions were found
480 no affected revisions were found
481
481
482 $ cd ..
482 $ cd ..
483
483
484 from a v2 bundle
484 from a v2 bundle
485 ~~~~~~~~~~~~~~~~
485 ~~~~~~~~~~~~~~~~
486
486
487 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v2
487 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v2
488 bzip2-v2
488 bzip2-v2
489
489
490 $ hg init unbundle-v2
490 $ hg init unbundle-v2
491 $ cd unbundle-v2
491 $ cd unbundle-v2
492
492
493 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v2
493 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v2
494 adding changesets
494 adding changesets
495 adding manifests
495 adding manifests
496 adding file changes
496 adding file changes
497 added 8 changesets with 12 changes to 4 files
497 added 8 changesets with 12 changes to 4 files
498 new changesets f5a5a568022f:3beabb508514 (8 drafts)
498 new changesets f5a5a568022f:3beabb508514 (8 drafts)
499 (run 'hg update' to get a working copy)
499 (run 'hg update' to get a working copy)
500
500
501 Check that revision were fixed on the fly
501 Check that revision were fixed on the fly
502
502
503 $ hg debugrevlogindex b.txt
503 $ hg debugrevlogindex b.txt
504 rev linkrev nodeid p1 p2
504 rev linkrev nodeid p1 p2
505 0 2 05b806ebe5ea 000000000000 000000000000
505 0 2 05b806ebe5ea 000000000000 000000000000
506 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
506 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
507 2 6 216a5fe8b8ed 000000000000 000000000000
507 2 6 216a5fe8b8ed 000000000000 000000000000
508 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
508 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
509
509
510 $ hg debugrevlogindex D.txt
510 $ hg debugrevlogindex D.txt
511 rev linkrev nodeid p1 p2
511 rev linkrev nodeid p1 p2
512 0 6 2a8d3833f2fb 000000000000 000000000000
512 0 6 2a8d3833f2fb 000000000000 000000000000
513 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
513 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
514
514
515 That we don't see the symptoms of the bug
515 That we don't see the symptoms of the bug
516
516
517 $ hg up -- -1
517 $ hg up -- -1
518 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
518 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
519 $ hg status
519 $ hg status
520
520
521 And that the repair command does not find anything to fix
521 And that the repair command does not find anything to fix
522
522
523 $ hg debug-repair-issue6528
523 $ hg debug-repair-issue6528
524 no affected revisions were found
524 no affected revisions were found
525
525
526 $ cd ..
526 $ cd ..
527
528 A config option can disable the fixing of the bad bundle on the fly
529 -------------------------------------------------------------------
530
531
532
533 from a v1 bundle
534 ~~~~~~~~~~~~~~~~
535
536 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v1
537 bzip2-v1
538
539 $ hg init unbundle-v1-no-fix
540 $ cd unbundle-v1-no-fix
541
542 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v1 --config storage.revlog.issue6528.fix-incoming=no
543 adding changesets
544 adding manifests
545 adding file changes
546 added 8 changesets with 12 changes to 4 files
547 new changesets f5a5a568022f:3beabb508514 (8 drafts)
548 (run 'hg update' to get a working copy)
549
550 Check that revision were not fixed on the fly
551
552 $ hg debugrevlogindex b.txt
553 rev linkrev nodeid p1 p2
554 0 2 05b806ebe5ea 000000000000 000000000000
555 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
556 2 6 216a5fe8b8ed 000000000000 000000000000
557 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
558
559 $ hg debugrevlogindex D.txt
560 rev linkrev nodeid p1 p2
561 0 6 2a8d3833f2fb 000000000000 000000000000
562 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
563
564 That we do see the symptoms of the bug
565
566 $ hg up -- -1
567 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
568 $ hg status
569 M D.txt (?)
570 M b.txt (?)
571
572 And that the repair command find issue to fix.
573
574 $ hg debug-repair-issue6528 --dry-run
575 found affected revision 1 for filelog 'data/D.txt.i'
576 found affected revision 1 for filelog 'data/b.txt.i'
577 found affected revision 3 for filelog 'data/b.txt.i'
578
579 $ cd ..
580
581 from a v2 bundle
582 ~~~~~~~~~~~~~~~~
583
584 $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v2
585 bzip2-v2
586
587 $ hg init unbundle-v2-no-fix
588 $ cd unbundle-v2-no-fix
589
590 $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v2 --config storage.revlog.issue6528.fix-incoming=no
591 adding changesets
592 adding manifests
593 adding file changes
594 added 8 changesets with 12 changes to 4 files
595 new changesets f5a5a568022f:3beabb508514 (8 drafts)
596 (run 'hg update' to get a working copy)
597
598 Check that revision were not fixed on the fly
599
600 $ hg debugrevlogindex b.txt
601 rev linkrev nodeid p1 p2
602 0 2 05b806ebe5ea 000000000000 000000000000
603 1 3 a58b36ad6b65 05b806ebe5ea 000000000000
604 2 6 216a5fe8b8ed 000000000000 000000000000
605 3 7 ea4f2f2463cc 216a5fe8b8ed 000000000000
606
607 $ hg debugrevlogindex D.txt
608 rev linkrev nodeid p1 p2
609 0 6 2a8d3833f2fb 000000000000 000000000000
610 1 7 2a80419dfc31 2a8d3833f2fb 000000000000
611
612 That we do see the symptoms of the bug
613
614 $ hg up -- -1
615 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
616 $ hg status
617 M D.txt (?)
618 M b.txt (?)
619
620 And that the repair command find issue to fix.
621
622 $ hg debug-repair-issue6528 --dry-run
623 found affected revision 1 for filelog 'data/D.txt.i'
624 found affected revision 1 for filelog 'data/b.txt.i'
625 found affected revision 3 for filelog 'data/b.txt.i'
626
627 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now