##// END OF EJS Templates
dirstate-v2: rename the configuration to enable the format...
marmoute -
r49523:f7086f61 stable
parent child Browse files
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,2731 +1,2732 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'editortmpinhg',
962 b'editortmpinhg',
963 default=False,
963 default=False,
964 )
964 )
965 coreconfigitem(
965 coreconfigitem(
966 b'experimental',
966 b'experimental',
967 b'evolution',
967 b'evolution',
968 default=list,
968 default=list,
969 )
969 )
970 coreconfigitem(
970 coreconfigitem(
971 b'experimental',
971 b'experimental',
972 b'evolution.allowdivergence',
972 b'evolution.allowdivergence',
973 default=False,
973 default=False,
974 alias=[(b'experimental', b'allowdivergence')],
974 alias=[(b'experimental', b'allowdivergence')],
975 )
975 )
976 coreconfigitem(
976 coreconfigitem(
977 b'experimental',
977 b'experimental',
978 b'evolution.allowunstable',
978 b'evolution.allowunstable',
979 default=None,
979 default=None,
980 )
980 )
981 coreconfigitem(
981 coreconfigitem(
982 b'experimental',
982 b'experimental',
983 b'evolution.createmarkers',
983 b'evolution.createmarkers',
984 default=None,
984 default=None,
985 )
985 )
986 coreconfigitem(
986 coreconfigitem(
987 b'experimental',
987 b'experimental',
988 b'evolution.effect-flags',
988 b'evolution.effect-flags',
989 default=True,
989 default=True,
990 alias=[(b'experimental', b'effect-flags')],
990 alias=[(b'experimental', b'effect-flags')],
991 )
991 )
992 coreconfigitem(
992 coreconfigitem(
993 b'experimental',
993 b'experimental',
994 b'evolution.exchange',
994 b'evolution.exchange',
995 default=None,
995 default=None,
996 )
996 )
997 coreconfigitem(
997 coreconfigitem(
998 b'experimental',
998 b'experimental',
999 b'evolution.bundle-obsmarker',
999 b'evolution.bundle-obsmarker',
1000 default=False,
1000 default=False,
1001 )
1001 )
1002 coreconfigitem(
1002 coreconfigitem(
1003 b'experimental',
1003 b'experimental',
1004 b'evolution.bundle-obsmarker:mandatory',
1004 b'evolution.bundle-obsmarker:mandatory',
1005 default=True,
1005 default=True,
1006 )
1006 )
1007 coreconfigitem(
1007 coreconfigitem(
1008 b'experimental',
1008 b'experimental',
1009 b'log.topo',
1009 b'log.topo',
1010 default=False,
1010 default=False,
1011 )
1011 )
1012 coreconfigitem(
1012 coreconfigitem(
1013 b'experimental',
1013 b'experimental',
1014 b'evolution.report-instabilities',
1014 b'evolution.report-instabilities',
1015 default=True,
1015 default=True,
1016 )
1016 )
1017 coreconfigitem(
1017 coreconfigitem(
1018 b'experimental',
1018 b'experimental',
1019 b'evolution.track-operation',
1019 b'evolution.track-operation',
1020 default=True,
1020 default=True,
1021 )
1021 )
1022 # repo-level config to exclude a revset visibility
1022 # repo-level config to exclude a revset visibility
1023 #
1023 #
1024 # The target use case is to use `share` to expose different subset of the same
1024 # The target use case is to use `share` to expose different subset of the same
1025 # repository, especially server side. See also `server.view`.
1025 # repository, especially server side. See also `server.view`.
1026 coreconfigitem(
1026 coreconfigitem(
1027 b'experimental',
1027 b'experimental',
1028 b'extra-filter-revs',
1028 b'extra-filter-revs',
1029 default=None,
1029 default=None,
1030 )
1030 )
1031 coreconfigitem(
1031 coreconfigitem(
1032 b'experimental',
1032 b'experimental',
1033 b'maxdeltachainspan',
1033 b'maxdeltachainspan',
1034 default=-1,
1034 default=-1,
1035 )
1035 )
1036 # tracks files which were undeleted (merge might delete them but we explicitly
1036 # tracks files which were undeleted (merge might delete them but we explicitly
1037 # kept/undeleted them) and creates new filenodes for them
1037 # kept/undeleted them) and creates new filenodes for them
1038 coreconfigitem(
1038 coreconfigitem(
1039 b'experimental',
1039 b'experimental',
1040 b'merge-track-salvaged',
1040 b'merge-track-salvaged',
1041 default=False,
1041 default=False,
1042 )
1042 )
1043 coreconfigitem(
1043 coreconfigitem(
1044 b'experimental',
1044 b'experimental',
1045 b'mergetempdirprefix',
1045 b'mergetempdirprefix',
1046 default=None,
1046 default=None,
1047 )
1047 )
1048 coreconfigitem(
1048 coreconfigitem(
1049 b'experimental',
1049 b'experimental',
1050 b'mmapindexthreshold',
1050 b'mmapindexthreshold',
1051 default=None,
1051 default=None,
1052 )
1052 )
1053 coreconfigitem(
1053 coreconfigitem(
1054 b'experimental',
1054 b'experimental',
1055 b'narrow',
1055 b'narrow',
1056 default=False,
1056 default=False,
1057 )
1057 )
1058 coreconfigitem(
1058 coreconfigitem(
1059 b'experimental',
1059 b'experimental',
1060 b'nonnormalparanoidcheck',
1060 b'nonnormalparanoidcheck',
1061 default=False,
1061 default=False,
1062 )
1062 )
1063 coreconfigitem(
1063 coreconfigitem(
1064 b'experimental',
1064 b'experimental',
1065 b'exportableenviron',
1065 b'exportableenviron',
1066 default=list,
1066 default=list,
1067 )
1067 )
1068 coreconfigitem(
1068 coreconfigitem(
1069 b'experimental',
1069 b'experimental',
1070 b'extendedheader.index',
1070 b'extendedheader.index',
1071 default=None,
1071 default=None,
1072 )
1072 )
1073 coreconfigitem(
1073 coreconfigitem(
1074 b'experimental',
1074 b'experimental',
1075 b'extendedheader.similarity',
1075 b'extendedheader.similarity',
1076 default=False,
1076 default=False,
1077 )
1077 )
1078 coreconfigitem(
1078 coreconfigitem(
1079 b'experimental',
1079 b'experimental',
1080 b'graphshorten',
1080 b'graphshorten',
1081 default=False,
1081 default=False,
1082 )
1082 )
1083 coreconfigitem(
1083 coreconfigitem(
1084 b'experimental',
1084 b'experimental',
1085 b'graphstyle.parent',
1085 b'graphstyle.parent',
1086 default=dynamicdefault,
1086 default=dynamicdefault,
1087 )
1087 )
1088 coreconfigitem(
1088 coreconfigitem(
1089 b'experimental',
1089 b'experimental',
1090 b'graphstyle.missing',
1090 b'graphstyle.missing',
1091 default=dynamicdefault,
1091 default=dynamicdefault,
1092 )
1092 )
1093 coreconfigitem(
1093 coreconfigitem(
1094 b'experimental',
1094 b'experimental',
1095 b'graphstyle.grandparent',
1095 b'graphstyle.grandparent',
1096 default=dynamicdefault,
1096 default=dynamicdefault,
1097 )
1097 )
1098 coreconfigitem(
1098 coreconfigitem(
1099 b'experimental',
1099 b'experimental',
1100 b'hook-track-tags',
1100 b'hook-track-tags',
1101 default=False,
1101 default=False,
1102 )
1102 )
1103 coreconfigitem(
1103 coreconfigitem(
1104 b'experimental',
1104 b'experimental',
1105 b'httppeer.advertise-v2',
1105 b'httppeer.advertise-v2',
1106 default=False,
1106 default=False,
1107 )
1107 )
1108 coreconfigitem(
1108 coreconfigitem(
1109 b'experimental',
1109 b'experimental',
1110 b'httppeer.v2-encoder-order',
1110 b'httppeer.v2-encoder-order',
1111 default=None,
1111 default=None,
1112 )
1112 )
1113 coreconfigitem(
1113 coreconfigitem(
1114 b'experimental',
1114 b'experimental',
1115 b'httppostargs',
1115 b'httppostargs',
1116 default=False,
1116 default=False,
1117 )
1117 )
1118 coreconfigitem(b'experimental', b'nointerrupt', default=False)
1118 coreconfigitem(b'experimental', b'nointerrupt', default=False)
1119 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
1119 coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True)
1120
1120
1121 coreconfigitem(
1121 coreconfigitem(
1122 b'experimental',
1122 b'experimental',
1123 b'obsmarkers-exchange-debug',
1123 b'obsmarkers-exchange-debug',
1124 default=False,
1124 default=False,
1125 )
1125 )
1126 coreconfigitem(
1126 coreconfigitem(
1127 b'experimental',
1127 b'experimental',
1128 b'remotenames',
1128 b'remotenames',
1129 default=False,
1129 default=False,
1130 )
1130 )
1131 coreconfigitem(
1131 coreconfigitem(
1132 b'experimental',
1132 b'experimental',
1133 b'removeemptydirs',
1133 b'removeemptydirs',
1134 default=True,
1134 default=True,
1135 )
1135 )
1136 coreconfigitem(
1136 coreconfigitem(
1137 b'experimental',
1137 b'experimental',
1138 b'revert.interactive.select-to-keep',
1138 b'revert.interactive.select-to-keep',
1139 default=False,
1139 default=False,
1140 )
1140 )
1141 coreconfigitem(
1141 coreconfigitem(
1142 b'experimental',
1142 b'experimental',
1143 b'revisions.prefixhexnode',
1143 b'revisions.prefixhexnode',
1144 default=False,
1144 default=False,
1145 )
1145 )
1146 # "out of experimental" todo list.
1146 # "out of experimental" todo list.
1147 #
1147 #
1148 # * include management of a persistent nodemap in the main docket
1148 # * include management of a persistent nodemap in the main docket
1149 # * enforce a "no-truncate" policy for mmap safety
1149 # * enforce a "no-truncate" policy for mmap safety
1150 # - for censoring operation
1150 # - for censoring operation
1151 # - for stripping operation
1151 # - for stripping operation
1152 # - for rollback operation
1152 # - for rollback operation
1153 # * proper streaming (race free) of the docket file
1153 # * proper streaming (race free) of the docket file
1154 # * track garbage data to evemtually allow rewriting -existing- sidedata.
1154 # * track garbage data to evemtually allow rewriting -existing- sidedata.
1155 # * Exchange-wise, we will also need to do something more efficient than
1155 # * Exchange-wise, we will also need to do something more efficient than
1156 # keeping references to the affected revlogs, especially memory-wise when
1156 # keeping references to the affected revlogs, especially memory-wise when
1157 # rewriting sidedata.
1157 # rewriting sidedata.
1158 # * introduce a proper solution to reduce the number of filelog related files.
1158 # * introduce a proper solution to reduce the number of filelog related files.
1159 # * use caching for reading sidedata (similar to what we do for data).
1159 # * use caching for reading sidedata (similar to what we do for data).
1160 # * no longer set offset=0 if sidedata_size=0 (simplify cutoff computation).
1160 # * no longer set offset=0 if sidedata_size=0 (simplify cutoff computation).
1161 # * Improvement to consider
1161 # * Improvement to consider
1162 # - avoid compression header in chunk using the default compression?
1162 # - avoid compression header in chunk using the default compression?
1163 # - forbid "inline" compression mode entirely?
1163 # - forbid "inline" compression mode entirely?
1164 # - split the data offset and flag field (the 2 bytes save are mostly trouble)
1164 # - split the data offset and flag field (the 2 bytes save are mostly trouble)
1165 # - keep track of uncompressed -chunk- size (to preallocate memory better)
1165 # - keep track of uncompressed -chunk- size (to preallocate memory better)
1166 # - keep track of chain base or size (probably not that useful anymore)
1166 # - keep track of chain base or size (probably not that useful anymore)
1167 coreconfigitem(
1167 coreconfigitem(
1168 b'experimental',
1168 b'experimental',
1169 b'revlogv2',
1169 b'revlogv2',
1170 default=None,
1170 default=None,
1171 )
1171 )
1172 coreconfigitem(
1172 coreconfigitem(
1173 b'experimental',
1173 b'experimental',
1174 b'revisions.disambiguatewithin',
1174 b'revisions.disambiguatewithin',
1175 default=None,
1175 default=None,
1176 )
1176 )
1177 coreconfigitem(
1177 coreconfigitem(
1178 b'experimental',
1178 b'experimental',
1179 b'rust.index',
1179 b'rust.index',
1180 default=False,
1180 default=False,
1181 )
1181 )
1182 coreconfigitem(
1182 coreconfigitem(
1183 b'experimental',
1183 b'experimental',
1184 b'server.filesdata.recommended-batch-size',
1184 b'server.filesdata.recommended-batch-size',
1185 default=50000,
1185 default=50000,
1186 )
1186 )
1187 coreconfigitem(
1187 coreconfigitem(
1188 b'experimental',
1188 b'experimental',
1189 b'server.manifestdata.recommended-batch-size',
1189 b'server.manifestdata.recommended-batch-size',
1190 default=100000,
1190 default=100000,
1191 )
1191 )
1192 coreconfigitem(
1192 coreconfigitem(
1193 b'experimental',
1193 b'experimental',
1194 b'server.stream-narrow-clones',
1194 b'server.stream-narrow-clones',
1195 default=False,
1195 default=False,
1196 )
1196 )
1197 coreconfigitem(
1197 coreconfigitem(
1198 b'experimental',
1198 b'experimental',
1199 b'single-head-per-branch',
1199 b'single-head-per-branch',
1200 default=False,
1200 default=False,
1201 )
1201 )
1202 coreconfigitem(
1202 coreconfigitem(
1203 b'experimental',
1203 b'experimental',
1204 b'single-head-per-branch:account-closed-heads',
1204 b'single-head-per-branch:account-closed-heads',
1205 default=False,
1205 default=False,
1206 )
1206 )
1207 coreconfigitem(
1207 coreconfigitem(
1208 b'experimental',
1208 b'experimental',
1209 b'single-head-per-branch:public-changes-only',
1209 b'single-head-per-branch:public-changes-only',
1210 default=False,
1210 default=False,
1211 )
1211 )
1212 coreconfigitem(
1212 coreconfigitem(
1213 b'experimental',
1213 b'experimental',
1214 b'sshserver.support-v2',
1214 b'sshserver.support-v2',
1215 default=False,
1215 default=False,
1216 )
1216 )
1217 coreconfigitem(
1217 coreconfigitem(
1218 b'experimental',
1218 b'experimental',
1219 b'sparse-read',
1219 b'sparse-read',
1220 default=False,
1220 default=False,
1221 )
1221 )
1222 coreconfigitem(
1222 coreconfigitem(
1223 b'experimental',
1223 b'experimental',
1224 b'sparse-read.density-threshold',
1224 b'sparse-read.density-threshold',
1225 default=0.50,
1225 default=0.50,
1226 )
1226 )
1227 coreconfigitem(
1227 coreconfigitem(
1228 b'experimental',
1228 b'experimental',
1229 b'sparse-read.min-gap-size',
1229 b'sparse-read.min-gap-size',
1230 default=b'65K',
1230 default=b'65K',
1231 )
1231 )
1232 coreconfigitem(
1232 coreconfigitem(
1233 b'experimental',
1233 b'experimental',
1234 b'treemanifest',
1234 b'treemanifest',
1235 default=False,
1235 default=False,
1236 )
1236 )
1237 coreconfigitem(
1237 coreconfigitem(
1238 b'experimental',
1238 b'experimental',
1239 b'update.atomic-file',
1239 b'update.atomic-file',
1240 default=False,
1240 default=False,
1241 )
1241 )
1242 coreconfigitem(
1242 coreconfigitem(
1243 b'experimental',
1243 b'experimental',
1244 b'sshpeer.advertise-v2',
1244 b'sshpeer.advertise-v2',
1245 default=False,
1245 default=False,
1246 )
1246 )
1247 coreconfigitem(
1247 coreconfigitem(
1248 b'experimental',
1248 b'experimental',
1249 b'web.apiserver',
1249 b'web.apiserver',
1250 default=False,
1250 default=False,
1251 )
1251 )
1252 coreconfigitem(
1252 coreconfigitem(
1253 b'experimental',
1253 b'experimental',
1254 b'web.api.http-v2',
1254 b'web.api.http-v2',
1255 default=False,
1255 default=False,
1256 )
1256 )
1257 coreconfigitem(
1257 coreconfigitem(
1258 b'experimental',
1258 b'experimental',
1259 b'web.api.debugreflect',
1259 b'web.api.debugreflect',
1260 default=False,
1260 default=False,
1261 )
1261 )
1262 coreconfigitem(
1262 coreconfigitem(
1263 b'experimental',
1263 b'experimental',
1264 b'web.full-garbage-collection-rate',
1264 b'web.full-garbage-collection-rate',
1265 default=1, # still forcing a full collection on each request
1265 default=1, # still forcing a full collection on each request
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-rc-dirstate-v2',
1309 b'use-dirstate-v2',
1310 default=False,
1310 default=False,
1311 experimental=True,
1311 experimental=True,
1312 alias=[(b'format', b'exp-rc-dirstate-v2')],
1312 )
1313 )
1313 coreconfigitem(
1314 coreconfigitem(
1314 b'format',
1315 b'format',
1315 b'dotencode',
1316 b'dotencode',
1316 default=True,
1317 default=True,
1317 )
1318 )
1318 coreconfigitem(
1319 coreconfigitem(
1319 b'format',
1320 b'format',
1320 b'generaldelta',
1321 b'generaldelta',
1321 default=False,
1322 default=False,
1322 experimental=True,
1323 experimental=True,
1323 )
1324 )
1324 coreconfigitem(
1325 coreconfigitem(
1325 b'format',
1326 b'format',
1326 b'manifestcachesize',
1327 b'manifestcachesize',
1327 default=None,
1328 default=None,
1328 experimental=True,
1329 experimental=True,
1329 )
1330 )
1330 coreconfigitem(
1331 coreconfigitem(
1331 b'format',
1332 b'format',
1332 b'maxchainlen',
1333 b'maxchainlen',
1333 default=dynamicdefault,
1334 default=dynamicdefault,
1334 experimental=True,
1335 experimental=True,
1335 )
1336 )
1336 coreconfigitem(
1337 coreconfigitem(
1337 b'format',
1338 b'format',
1338 b'obsstore-version',
1339 b'obsstore-version',
1339 default=None,
1340 default=None,
1340 )
1341 )
1341 coreconfigitem(
1342 coreconfigitem(
1342 b'format',
1343 b'format',
1343 b'sparse-revlog',
1344 b'sparse-revlog',
1344 default=True,
1345 default=True,
1345 )
1346 )
1346 coreconfigitem(
1347 coreconfigitem(
1347 b'format',
1348 b'format',
1348 b'revlog-compression',
1349 b'revlog-compression',
1349 default=lambda: [b'zstd', b'zlib'],
1350 default=lambda: [b'zstd', b'zlib'],
1350 alias=[(b'experimental', b'format.compression')],
1351 alias=[(b'experimental', b'format.compression')],
1351 )
1352 )
1352 # Experimental TODOs:
1353 # Experimental TODOs:
1353 #
1354 #
1354 # * Same as for evlogv2 (but for the reduction of the number of files)
1355 # * Same as for evlogv2 (but for the reduction of the number of files)
1355 # * Improvement to investigate
1356 # * Improvement to investigate
1356 # - storing .hgtags fnode
1357 # - storing .hgtags fnode
1357 # - storing `rank` of changesets
1358 # - storing `rank` of changesets
1358 # - storing branch related identifier
1359 # - storing branch related identifier
1359
1360
1360 coreconfigitem(
1361 coreconfigitem(
1361 b'format',
1362 b'format',
1362 b'exp-use-changelog-v2',
1363 b'exp-use-changelog-v2',
1363 default=None,
1364 default=None,
1364 experimental=True,
1365 experimental=True,
1365 )
1366 )
1366 coreconfigitem(
1367 coreconfigitem(
1367 b'format',
1368 b'format',
1368 b'usefncache',
1369 b'usefncache',
1369 default=True,
1370 default=True,
1370 )
1371 )
1371 coreconfigitem(
1372 coreconfigitem(
1372 b'format',
1373 b'format',
1373 b'usegeneraldelta',
1374 b'usegeneraldelta',
1374 default=True,
1375 default=True,
1375 )
1376 )
1376 coreconfigitem(
1377 coreconfigitem(
1377 b'format',
1378 b'format',
1378 b'usestore',
1379 b'usestore',
1379 default=True,
1380 default=True,
1380 )
1381 )
1381
1382
1382
1383
1383 def _persistent_nodemap_default():
1384 def _persistent_nodemap_default():
1384 """compute `use-persistent-nodemap` default value
1385 """compute `use-persistent-nodemap` default value
1385
1386
1386 The feature is disabled unless a fast implementation is available.
1387 The feature is disabled unless a fast implementation is available.
1387 """
1388 """
1388 from . import policy
1389 from . import policy
1389
1390
1390 return policy.importrust('revlog') is not None
1391 return policy.importrust('revlog') is not None
1391
1392
1392
1393
1393 coreconfigitem(
1394 coreconfigitem(
1394 b'format',
1395 b'format',
1395 b'use-persistent-nodemap',
1396 b'use-persistent-nodemap',
1396 default=_persistent_nodemap_default,
1397 default=_persistent_nodemap_default,
1397 )
1398 )
1398 coreconfigitem(
1399 coreconfigitem(
1399 b'format',
1400 b'format',
1400 b'exp-use-copies-side-data-changeset',
1401 b'exp-use-copies-side-data-changeset',
1401 default=False,
1402 default=False,
1402 experimental=True,
1403 experimental=True,
1403 )
1404 )
1404 coreconfigitem(
1405 coreconfigitem(
1405 b'format',
1406 b'format',
1406 b'use-share-safe',
1407 b'use-share-safe',
1407 default=False,
1408 default=False,
1408 )
1409 )
1409 coreconfigitem(
1410 coreconfigitem(
1410 b'format',
1411 b'format',
1411 b'internal-phase',
1412 b'internal-phase',
1412 default=False,
1413 default=False,
1413 experimental=True,
1414 experimental=True,
1414 )
1415 )
1415 coreconfigitem(
1416 coreconfigitem(
1416 b'fsmonitor',
1417 b'fsmonitor',
1417 b'warn_when_unused',
1418 b'warn_when_unused',
1418 default=True,
1419 default=True,
1419 )
1420 )
1420 coreconfigitem(
1421 coreconfigitem(
1421 b'fsmonitor',
1422 b'fsmonitor',
1422 b'warn_update_file_count',
1423 b'warn_update_file_count',
1423 default=50000,
1424 default=50000,
1424 )
1425 )
1425 coreconfigitem(
1426 coreconfigitem(
1426 b'fsmonitor',
1427 b'fsmonitor',
1427 b'warn_update_file_count_rust',
1428 b'warn_update_file_count_rust',
1428 default=400000,
1429 default=400000,
1429 )
1430 )
1430 coreconfigitem(
1431 coreconfigitem(
1431 b'help',
1432 b'help',
1432 br'hidden-command\..*',
1433 br'hidden-command\..*',
1433 default=False,
1434 default=False,
1434 generic=True,
1435 generic=True,
1435 )
1436 )
1436 coreconfigitem(
1437 coreconfigitem(
1437 b'help',
1438 b'help',
1438 br'hidden-topic\..*',
1439 br'hidden-topic\..*',
1439 default=False,
1440 default=False,
1440 generic=True,
1441 generic=True,
1441 )
1442 )
1442 coreconfigitem(
1443 coreconfigitem(
1443 b'hooks',
1444 b'hooks',
1444 b'[^:]*',
1445 b'[^:]*',
1445 default=dynamicdefault,
1446 default=dynamicdefault,
1446 generic=True,
1447 generic=True,
1447 )
1448 )
1448 coreconfigitem(
1449 coreconfigitem(
1449 b'hooks',
1450 b'hooks',
1450 b'.*:run-with-plain',
1451 b'.*:run-with-plain',
1451 default=True,
1452 default=True,
1452 generic=True,
1453 generic=True,
1453 )
1454 )
1454 coreconfigitem(
1455 coreconfigitem(
1455 b'hgweb-paths',
1456 b'hgweb-paths',
1456 b'.*',
1457 b'.*',
1457 default=list,
1458 default=list,
1458 generic=True,
1459 generic=True,
1459 )
1460 )
1460 coreconfigitem(
1461 coreconfigitem(
1461 b'hostfingerprints',
1462 b'hostfingerprints',
1462 b'.*',
1463 b'.*',
1463 default=list,
1464 default=list,
1464 generic=True,
1465 generic=True,
1465 )
1466 )
1466 coreconfigitem(
1467 coreconfigitem(
1467 b'hostsecurity',
1468 b'hostsecurity',
1468 b'ciphers',
1469 b'ciphers',
1469 default=None,
1470 default=None,
1470 )
1471 )
1471 coreconfigitem(
1472 coreconfigitem(
1472 b'hostsecurity',
1473 b'hostsecurity',
1473 b'minimumprotocol',
1474 b'minimumprotocol',
1474 default=dynamicdefault,
1475 default=dynamicdefault,
1475 )
1476 )
1476 coreconfigitem(
1477 coreconfigitem(
1477 b'hostsecurity',
1478 b'hostsecurity',
1478 b'.*:minimumprotocol$',
1479 b'.*:minimumprotocol$',
1479 default=dynamicdefault,
1480 default=dynamicdefault,
1480 generic=True,
1481 generic=True,
1481 )
1482 )
1482 coreconfigitem(
1483 coreconfigitem(
1483 b'hostsecurity',
1484 b'hostsecurity',
1484 b'.*:ciphers$',
1485 b'.*:ciphers$',
1485 default=dynamicdefault,
1486 default=dynamicdefault,
1486 generic=True,
1487 generic=True,
1487 )
1488 )
1488 coreconfigitem(
1489 coreconfigitem(
1489 b'hostsecurity',
1490 b'hostsecurity',
1490 b'.*:fingerprints$',
1491 b'.*:fingerprints$',
1491 default=list,
1492 default=list,
1492 generic=True,
1493 generic=True,
1493 )
1494 )
1494 coreconfigitem(
1495 coreconfigitem(
1495 b'hostsecurity',
1496 b'hostsecurity',
1496 b'.*:verifycertsfile$',
1497 b'.*:verifycertsfile$',
1497 default=None,
1498 default=None,
1498 generic=True,
1499 generic=True,
1499 )
1500 )
1500
1501
1501 coreconfigitem(
1502 coreconfigitem(
1502 b'http_proxy',
1503 b'http_proxy',
1503 b'always',
1504 b'always',
1504 default=False,
1505 default=False,
1505 )
1506 )
1506 coreconfigitem(
1507 coreconfigitem(
1507 b'http_proxy',
1508 b'http_proxy',
1508 b'host',
1509 b'host',
1509 default=None,
1510 default=None,
1510 )
1511 )
1511 coreconfigitem(
1512 coreconfigitem(
1512 b'http_proxy',
1513 b'http_proxy',
1513 b'no',
1514 b'no',
1514 default=list,
1515 default=list,
1515 )
1516 )
1516 coreconfigitem(
1517 coreconfigitem(
1517 b'http_proxy',
1518 b'http_proxy',
1518 b'passwd',
1519 b'passwd',
1519 default=None,
1520 default=None,
1520 )
1521 )
1521 coreconfigitem(
1522 coreconfigitem(
1522 b'http_proxy',
1523 b'http_proxy',
1523 b'user',
1524 b'user',
1524 default=None,
1525 default=None,
1525 )
1526 )
1526
1527
1527 coreconfigitem(
1528 coreconfigitem(
1528 b'http',
1529 b'http',
1529 b'timeout',
1530 b'timeout',
1530 default=None,
1531 default=None,
1531 )
1532 )
1532
1533
1533 coreconfigitem(
1534 coreconfigitem(
1534 b'logtoprocess',
1535 b'logtoprocess',
1535 b'commandexception',
1536 b'commandexception',
1536 default=None,
1537 default=None,
1537 )
1538 )
1538 coreconfigitem(
1539 coreconfigitem(
1539 b'logtoprocess',
1540 b'logtoprocess',
1540 b'commandfinish',
1541 b'commandfinish',
1541 default=None,
1542 default=None,
1542 )
1543 )
1543 coreconfigitem(
1544 coreconfigitem(
1544 b'logtoprocess',
1545 b'logtoprocess',
1545 b'command',
1546 b'command',
1546 default=None,
1547 default=None,
1547 )
1548 )
1548 coreconfigitem(
1549 coreconfigitem(
1549 b'logtoprocess',
1550 b'logtoprocess',
1550 b'develwarn',
1551 b'develwarn',
1551 default=None,
1552 default=None,
1552 )
1553 )
1553 coreconfigitem(
1554 coreconfigitem(
1554 b'logtoprocess',
1555 b'logtoprocess',
1555 b'uiblocked',
1556 b'uiblocked',
1556 default=None,
1557 default=None,
1557 )
1558 )
1558 coreconfigitem(
1559 coreconfigitem(
1559 b'merge',
1560 b'merge',
1560 b'checkunknown',
1561 b'checkunknown',
1561 default=b'abort',
1562 default=b'abort',
1562 )
1563 )
1563 coreconfigitem(
1564 coreconfigitem(
1564 b'merge',
1565 b'merge',
1565 b'checkignored',
1566 b'checkignored',
1566 default=b'abort',
1567 default=b'abort',
1567 )
1568 )
1568 coreconfigitem(
1569 coreconfigitem(
1569 b'experimental',
1570 b'experimental',
1570 b'merge.checkpathconflicts',
1571 b'merge.checkpathconflicts',
1571 default=False,
1572 default=False,
1572 )
1573 )
1573 coreconfigitem(
1574 coreconfigitem(
1574 b'merge',
1575 b'merge',
1575 b'followcopies',
1576 b'followcopies',
1576 default=True,
1577 default=True,
1577 )
1578 )
1578 coreconfigitem(
1579 coreconfigitem(
1579 b'merge',
1580 b'merge',
1580 b'on-failure',
1581 b'on-failure',
1581 default=b'continue',
1582 default=b'continue',
1582 )
1583 )
1583 coreconfigitem(
1584 coreconfigitem(
1584 b'merge',
1585 b'merge',
1585 b'preferancestor',
1586 b'preferancestor',
1586 default=lambda: [b'*'],
1587 default=lambda: [b'*'],
1587 experimental=True,
1588 experimental=True,
1588 )
1589 )
1589 coreconfigitem(
1590 coreconfigitem(
1590 b'merge',
1591 b'merge',
1591 b'strict-capability-check',
1592 b'strict-capability-check',
1592 default=False,
1593 default=False,
1593 )
1594 )
1594 coreconfigitem(
1595 coreconfigitem(
1595 b'merge-tools',
1596 b'merge-tools',
1596 b'.*',
1597 b'.*',
1597 default=None,
1598 default=None,
1598 generic=True,
1599 generic=True,
1599 )
1600 )
1600 coreconfigitem(
1601 coreconfigitem(
1601 b'merge-tools',
1602 b'merge-tools',
1602 br'.*\.args$',
1603 br'.*\.args$',
1603 default=b"$local $base $other",
1604 default=b"$local $base $other",
1604 generic=True,
1605 generic=True,
1605 priority=-1,
1606 priority=-1,
1606 )
1607 )
1607 coreconfigitem(
1608 coreconfigitem(
1608 b'merge-tools',
1609 b'merge-tools',
1609 br'.*\.binary$',
1610 br'.*\.binary$',
1610 default=False,
1611 default=False,
1611 generic=True,
1612 generic=True,
1612 priority=-1,
1613 priority=-1,
1613 )
1614 )
1614 coreconfigitem(
1615 coreconfigitem(
1615 b'merge-tools',
1616 b'merge-tools',
1616 br'.*\.check$',
1617 br'.*\.check$',
1617 default=list,
1618 default=list,
1618 generic=True,
1619 generic=True,
1619 priority=-1,
1620 priority=-1,
1620 )
1621 )
1621 coreconfigitem(
1622 coreconfigitem(
1622 b'merge-tools',
1623 b'merge-tools',
1623 br'.*\.checkchanged$',
1624 br'.*\.checkchanged$',
1624 default=False,
1625 default=False,
1625 generic=True,
1626 generic=True,
1626 priority=-1,
1627 priority=-1,
1627 )
1628 )
1628 coreconfigitem(
1629 coreconfigitem(
1629 b'merge-tools',
1630 b'merge-tools',
1630 br'.*\.executable$',
1631 br'.*\.executable$',
1631 default=dynamicdefault,
1632 default=dynamicdefault,
1632 generic=True,
1633 generic=True,
1633 priority=-1,
1634 priority=-1,
1634 )
1635 )
1635 coreconfigitem(
1636 coreconfigitem(
1636 b'merge-tools',
1637 b'merge-tools',
1637 br'.*\.fixeol$',
1638 br'.*\.fixeol$',
1638 default=False,
1639 default=False,
1639 generic=True,
1640 generic=True,
1640 priority=-1,
1641 priority=-1,
1641 )
1642 )
1642 coreconfigitem(
1643 coreconfigitem(
1643 b'merge-tools',
1644 b'merge-tools',
1644 br'.*\.gui$',
1645 br'.*\.gui$',
1645 default=False,
1646 default=False,
1646 generic=True,
1647 generic=True,
1647 priority=-1,
1648 priority=-1,
1648 )
1649 )
1649 coreconfigitem(
1650 coreconfigitem(
1650 b'merge-tools',
1651 b'merge-tools',
1651 br'.*\.mergemarkers$',
1652 br'.*\.mergemarkers$',
1652 default=b'basic',
1653 default=b'basic',
1653 generic=True,
1654 generic=True,
1654 priority=-1,
1655 priority=-1,
1655 )
1656 )
1656 coreconfigitem(
1657 coreconfigitem(
1657 b'merge-tools',
1658 b'merge-tools',
1658 br'.*\.mergemarkertemplate$',
1659 br'.*\.mergemarkertemplate$',
1659 default=dynamicdefault, # take from command-templates.mergemarker
1660 default=dynamicdefault, # take from command-templates.mergemarker
1660 generic=True,
1661 generic=True,
1661 priority=-1,
1662 priority=-1,
1662 )
1663 )
1663 coreconfigitem(
1664 coreconfigitem(
1664 b'merge-tools',
1665 b'merge-tools',
1665 br'.*\.priority$',
1666 br'.*\.priority$',
1666 default=0,
1667 default=0,
1667 generic=True,
1668 generic=True,
1668 priority=-1,
1669 priority=-1,
1669 )
1670 )
1670 coreconfigitem(
1671 coreconfigitem(
1671 b'merge-tools',
1672 b'merge-tools',
1672 br'.*\.premerge$',
1673 br'.*\.premerge$',
1673 default=dynamicdefault,
1674 default=dynamicdefault,
1674 generic=True,
1675 generic=True,
1675 priority=-1,
1676 priority=-1,
1676 )
1677 )
1677 coreconfigitem(
1678 coreconfigitem(
1678 b'merge-tools',
1679 b'merge-tools',
1679 br'.*\.symlink$',
1680 br'.*\.symlink$',
1680 default=False,
1681 default=False,
1681 generic=True,
1682 generic=True,
1682 priority=-1,
1683 priority=-1,
1683 )
1684 )
1684 coreconfigitem(
1685 coreconfigitem(
1685 b'pager',
1686 b'pager',
1686 b'attend-.*',
1687 b'attend-.*',
1687 default=dynamicdefault,
1688 default=dynamicdefault,
1688 generic=True,
1689 generic=True,
1689 )
1690 )
1690 coreconfigitem(
1691 coreconfigitem(
1691 b'pager',
1692 b'pager',
1692 b'ignore',
1693 b'ignore',
1693 default=list,
1694 default=list,
1694 )
1695 )
1695 coreconfigitem(
1696 coreconfigitem(
1696 b'pager',
1697 b'pager',
1697 b'pager',
1698 b'pager',
1698 default=dynamicdefault,
1699 default=dynamicdefault,
1699 )
1700 )
1700 coreconfigitem(
1701 coreconfigitem(
1701 b'patch',
1702 b'patch',
1702 b'eol',
1703 b'eol',
1703 default=b'strict',
1704 default=b'strict',
1704 )
1705 )
1705 coreconfigitem(
1706 coreconfigitem(
1706 b'patch',
1707 b'patch',
1707 b'fuzz',
1708 b'fuzz',
1708 default=2,
1709 default=2,
1709 )
1710 )
1710 coreconfigitem(
1711 coreconfigitem(
1711 b'paths',
1712 b'paths',
1712 b'default',
1713 b'default',
1713 default=None,
1714 default=None,
1714 )
1715 )
1715 coreconfigitem(
1716 coreconfigitem(
1716 b'paths',
1717 b'paths',
1717 b'default-push',
1718 b'default-push',
1718 default=None,
1719 default=None,
1719 )
1720 )
1720 coreconfigitem(
1721 coreconfigitem(
1721 b'paths',
1722 b'paths',
1722 b'.*',
1723 b'.*',
1723 default=None,
1724 default=None,
1724 generic=True,
1725 generic=True,
1725 )
1726 )
1726 coreconfigitem(
1727 coreconfigitem(
1727 b'phases',
1728 b'phases',
1728 b'checksubrepos',
1729 b'checksubrepos',
1729 default=b'follow',
1730 default=b'follow',
1730 )
1731 )
1731 coreconfigitem(
1732 coreconfigitem(
1732 b'phases',
1733 b'phases',
1733 b'new-commit',
1734 b'new-commit',
1734 default=b'draft',
1735 default=b'draft',
1735 )
1736 )
1736 coreconfigitem(
1737 coreconfigitem(
1737 b'phases',
1738 b'phases',
1738 b'publish',
1739 b'publish',
1739 default=True,
1740 default=True,
1740 )
1741 )
1741 coreconfigitem(
1742 coreconfigitem(
1742 b'profiling',
1743 b'profiling',
1743 b'enabled',
1744 b'enabled',
1744 default=False,
1745 default=False,
1745 )
1746 )
1746 coreconfigitem(
1747 coreconfigitem(
1747 b'profiling',
1748 b'profiling',
1748 b'format',
1749 b'format',
1749 default=b'text',
1750 default=b'text',
1750 )
1751 )
1751 coreconfigitem(
1752 coreconfigitem(
1752 b'profiling',
1753 b'profiling',
1753 b'freq',
1754 b'freq',
1754 default=1000,
1755 default=1000,
1755 )
1756 )
1756 coreconfigitem(
1757 coreconfigitem(
1757 b'profiling',
1758 b'profiling',
1758 b'limit',
1759 b'limit',
1759 default=30,
1760 default=30,
1760 )
1761 )
1761 coreconfigitem(
1762 coreconfigitem(
1762 b'profiling',
1763 b'profiling',
1763 b'nested',
1764 b'nested',
1764 default=0,
1765 default=0,
1765 )
1766 )
1766 coreconfigitem(
1767 coreconfigitem(
1767 b'profiling',
1768 b'profiling',
1768 b'output',
1769 b'output',
1769 default=None,
1770 default=None,
1770 )
1771 )
1771 coreconfigitem(
1772 coreconfigitem(
1772 b'profiling',
1773 b'profiling',
1773 b'showmax',
1774 b'showmax',
1774 default=0.999,
1775 default=0.999,
1775 )
1776 )
1776 coreconfigitem(
1777 coreconfigitem(
1777 b'profiling',
1778 b'profiling',
1778 b'showmin',
1779 b'showmin',
1779 default=dynamicdefault,
1780 default=dynamicdefault,
1780 )
1781 )
1781 coreconfigitem(
1782 coreconfigitem(
1782 b'profiling',
1783 b'profiling',
1783 b'showtime',
1784 b'showtime',
1784 default=True,
1785 default=True,
1785 )
1786 )
1786 coreconfigitem(
1787 coreconfigitem(
1787 b'profiling',
1788 b'profiling',
1788 b'sort',
1789 b'sort',
1789 default=b'inlinetime',
1790 default=b'inlinetime',
1790 )
1791 )
1791 coreconfigitem(
1792 coreconfigitem(
1792 b'profiling',
1793 b'profiling',
1793 b'statformat',
1794 b'statformat',
1794 default=b'hotpath',
1795 default=b'hotpath',
1795 )
1796 )
1796 coreconfigitem(
1797 coreconfigitem(
1797 b'profiling',
1798 b'profiling',
1798 b'time-track',
1799 b'time-track',
1799 default=dynamicdefault,
1800 default=dynamicdefault,
1800 )
1801 )
1801 coreconfigitem(
1802 coreconfigitem(
1802 b'profiling',
1803 b'profiling',
1803 b'type',
1804 b'type',
1804 default=b'stat',
1805 default=b'stat',
1805 )
1806 )
1806 coreconfigitem(
1807 coreconfigitem(
1807 b'progress',
1808 b'progress',
1808 b'assume-tty',
1809 b'assume-tty',
1809 default=False,
1810 default=False,
1810 )
1811 )
1811 coreconfigitem(
1812 coreconfigitem(
1812 b'progress',
1813 b'progress',
1813 b'changedelay',
1814 b'changedelay',
1814 default=1,
1815 default=1,
1815 )
1816 )
1816 coreconfigitem(
1817 coreconfigitem(
1817 b'progress',
1818 b'progress',
1818 b'clear-complete',
1819 b'clear-complete',
1819 default=True,
1820 default=True,
1820 )
1821 )
1821 coreconfigitem(
1822 coreconfigitem(
1822 b'progress',
1823 b'progress',
1823 b'debug',
1824 b'debug',
1824 default=False,
1825 default=False,
1825 )
1826 )
1826 coreconfigitem(
1827 coreconfigitem(
1827 b'progress',
1828 b'progress',
1828 b'delay',
1829 b'delay',
1829 default=3,
1830 default=3,
1830 )
1831 )
1831 coreconfigitem(
1832 coreconfigitem(
1832 b'progress',
1833 b'progress',
1833 b'disable',
1834 b'disable',
1834 default=False,
1835 default=False,
1835 )
1836 )
1836 coreconfigitem(
1837 coreconfigitem(
1837 b'progress',
1838 b'progress',
1838 b'estimateinterval',
1839 b'estimateinterval',
1839 default=60.0,
1840 default=60.0,
1840 )
1841 )
1841 coreconfigitem(
1842 coreconfigitem(
1842 b'progress',
1843 b'progress',
1843 b'format',
1844 b'format',
1844 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1845 default=lambda: [b'topic', b'bar', b'number', b'estimate'],
1845 )
1846 )
1846 coreconfigitem(
1847 coreconfigitem(
1847 b'progress',
1848 b'progress',
1848 b'refresh',
1849 b'refresh',
1849 default=0.1,
1850 default=0.1,
1850 )
1851 )
1851 coreconfigitem(
1852 coreconfigitem(
1852 b'progress',
1853 b'progress',
1853 b'width',
1854 b'width',
1854 default=dynamicdefault,
1855 default=dynamicdefault,
1855 )
1856 )
1856 coreconfigitem(
1857 coreconfigitem(
1857 b'pull',
1858 b'pull',
1858 b'confirm',
1859 b'confirm',
1859 default=False,
1860 default=False,
1860 )
1861 )
1861 coreconfigitem(
1862 coreconfigitem(
1862 b'push',
1863 b'push',
1863 b'pushvars.server',
1864 b'pushvars.server',
1864 default=False,
1865 default=False,
1865 )
1866 )
1866 coreconfigitem(
1867 coreconfigitem(
1867 b'rewrite',
1868 b'rewrite',
1868 b'backup-bundle',
1869 b'backup-bundle',
1869 default=True,
1870 default=True,
1870 alias=[(b'ui', b'history-editing-backup')],
1871 alias=[(b'ui', b'history-editing-backup')],
1871 )
1872 )
1872 coreconfigitem(
1873 coreconfigitem(
1873 b'rewrite',
1874 b'rewrite',
1874 b'update-timestamp',
1875 b'update-timestamp',
1875 default=False,
1876 default=False,
1876 )
1877 )
1877 coreconfigitem(
1878 coreconfigitem(
1878 b'rewrite',
1879 b'rewrite',
1879 b'empty-successor',
1880 b'empty-successor',
1880 default=b'skip',
1881 default=b'skip',
1881 experimental=True,
1882 experimental=True,
1882 )
1883 )
1883 # experimental as long as format.exp-rc-dirstate-v2 is.
1884 # experimental as long as format.use-dirstate-v2 is.
1884 coreconfigitem(
1885 coreconfigitem(
1885 b'storage',
1886 b'storage',
1886 b'dirstate-v2.slow-path',
1887 b'dirstate-v2.slow-path',
1887 default=b"abort",
1888 default=b"abort",
1888 experimental=True,
1889 experimental=True,
1889 )
1890 )
1890 coreconfigitem(
1891 coreconfigitem(
1891 b'storage',
1892 b'storage',
1892 b'new-repo-backend',
1893 b'new-repo-backend',
1893 default=b'revlogv1',
1894 default=b'revlogv1',
1894 experimental=True,
1895 experimental=True,
1895 )
1896 )
1896 coreconfigitem(
1897 coreconfigitem(
1897 b'storage',
1898 b'storage',
1898 b'revlog.optimize-delta-parent-choice',
1899 b'revlog.optimize-delta-parent-choice',
1899 default=True,
1900 default=True,
1900 alias=[(b'format', b'aggressivemergedeltas')],
1901 alias=[(b'format', b'aggressivemergedeltas')],
1901 )
1902 )
1902 coreconfigitem(
1903 coreconfigitem(
1903 b'storage',
1904 b'storage',
1904 b'revlog.issue6528.fix-incoming',
1905 b'revlog.issue6528.fix-incoming',
1905 default=True,
1906 default=True,
1906 )
1907 )
1907 # experimental as long as rust is experimental (or a C version is implemented)
1908 # experimental as long as rust is experimental (or a C version is implemented)
1908 coreconfigitem(
1909 coreconfigitem(
1909 b'storage',
1910 b'storage',
1910 b'revlog.persistent-nodemap.mmap',
1911 b'revlog.persistent-nodemap.mmap',
1911 default=True,
1912 default=True,
1912 )
1913 )
1913 # experimental as long as format.use-persistent-nodemap is.
1914 # experimental as long as format.use-persistent-nodemap is.
1914 coreconfigitem(
1915 coreconfigitem(
1915 b'storage',
1916 b'storage',
1916 b'revlog.persistent-nodemap.slow-path',
1917 b'revlog.persistent-nodemap.slow-path',
1917 default=b"abort",
1918 default=b"abort",
1918 )
1919 )
1919
1920
1920 coreconfigitem(
1921 coreconfigitem(
1921 b'storage',
1922 b'storage',
1922 b'revlog.reuse-external-delta',
1923 b'revlog.reuse-external-delta',
1923 default=True,
1924 default=True,
1924 )
1925 )
1925 coreconfigitem(
1926 coreconfigitem(
1926 b'storage',
1927 b'storage',
1927 b'revlog.reuse-external-delta-parent',
1928 b'revlog.reuse-external-delta-parent',
1928 default=None,
1929 default=None,
1929 )
1930 )
1930 coreconfigitem(
1931 coreconfigitem(
1931 b'storage',
1932 b'storage',
1932 b'revlog.zlib.level',
1933 b'revlog.zlib.level',
1933 default=None,
1934 default=None,
1934 )
1935 )
1935 coreconfigitem(
1936 coreconfigitem(
1936 b'storage',
1937 b'storage',
1937 b'revlog.zstd.level',
1938 b'revlog.zstd.level',
1938 default=None,
1939 default=None,
1939 )
1940 )
1940 coreconfigitem(
1941 coreconfigitem(
1941 b'server',
1942 b'server',
1942 b'bookmarks-pushkey-compat',
1943 b'bookmarks-pushkey-compat',
1943 default=True,
1944 default=True,
1944 )
1945 )
1945 coreconfigitem(
1946 coreconfigitem(
1946 b'server',
1947 b'server',
1947 b'bundle1',
1948 b'bundle1',
1948 default=True,
1949 default=True,
1949 )
1950 )
1950 coreconfigitem(
1951 coreconfigitem(
1951 b'server',
1952 b'server',
1952 b'bundle1gd',
1953 b'bundle1gd',
1953 default=None,
1954 default=None,
1954 )
1955 )
1955 coreconfigitem(
1956 coreconfigitem(
1956 b'server',
1957 b'server',
1957 b'bundle1.pull',
1958 b'bundle1.pull',
1958 default=None,
1959 default=None,
1959 )
1960 )
1960 coreconfigitem(
1961 coreconfigitem(
1961 b'server',
1962 b'server',
1962 b'bundle1gd.pull',
1963 b'bundle1gd.pull',
1963 default=None,
1964 default=None,
1964 )
1965 )
1965 coreconfigitem(
1966 coreconfigitem(
1966 b'server',
1967 b'server',
1967 b'bundle1.push',
1968 b'bundle1.push',
1968 default=None,
1969 default=None,
1969 )
1970 )
1970 coreconfigitem(
1971 coreconfigitem(
1971 b'server',
1972 b'server',
1972 b'bundle1gd.push',
1973 b'bundle1gd.push',
1973 default=None,
1974 default=None,
1974 )
1975 )
1975 coreconfigitem(
1976 coreconfigitem(
1976 b'server',
1977 b'server',
1977 b'bundle2.stream',
1978 b'bundle2.stream',
1978 default=True,
1979 default=True,
1979 alias=[(b'experimental', b'bundle2.stream')],
1980 alias=[(b'experimental', b'bundle2.stream')],
1980 )
1981 )
1981 coreconfigitem(
1982 coreconfigitem(
1982 b'server',
1983 b'server',
1983 b'compressionengines',
1984 b'compressionengines',
1984 default=list,
1985 default=list,
1985 )
1986 )
1986 coreconfigitem(
1987 coreconfigitem(
1987 b'server',
1988 b'server',
1988 b'concurrent-push-mode',
1989 b'concurrent-push-mode',
1989 default=b'check-related',
1990 default=b'check-related',
1990 )
1991 )
1991 coreconfigitem(
1992 coreconfigitem(
1992 b'server',
1993 b'server',
1993 b'disablefullbundle',
1994 b'disablefullbundle',
1994 default=False,
1995 default=False,
1995 )
1996 )
1996 coreconfigitem(
1997 coreconfigitem(
1997 b'server',
1998 b'server',
1998 b'maxhttpheaderlen',
1999 b'maxhttpheaderlen',
1999 default=1024,
2000 default=1024,
2000 )
2001 )
2001 coreconfigitem(
2002 coreconfigitem(
2002 b'server',
2003 b'server',
2003 b'pullbundle',
2004 b'pullbundle',
2004 default=False,
2005 default=False,
2005 )
2006 )
2006 coreconfigitem(
2007 coreconfigitem(
2007 b'server',
2008 b'server',
2008 b'preferuncompressed',
2009 b'preferuncompressed',
2009 default=False,
2010 default=False,
2010 )
2011 )
2011 coreconfigitem(
2012 coreconfigitem(
2012 b'server',
2013 b'server',
2013 b'streamunbundle',
2014 b'streamunbundle',
2014 default=False,
2015 default=False,
2015 )
2016 )
2016 coreconfigitem(
2017 coreconfigitem(
2017 b'server',
2018 b'server',
2018 b'uncompressed',
2019 b'uncompressed',
2019 default=True,
2020 default=True,
2020 )
2021 )
2021 coreconfigitem(
2022 coreconfigitem(
2022 b'server',
2023 b'server',
2023 b'uncompressedallowsecret',
2024 b'uncompressedallowsecret',
2024 default=False,
2025 default=False,
2025 )
2026 )
2026 coreconfigitem(
2027 coreconfigitem(
2027 b'server',
2028 b'server',
2028 b'view',
2029 b'view',
2029 default=b'served',
2030 default=b'served',
2030 )
2031 )
2031 coreconfigitem(
2032 coreconfigitem(
2032 b'server',
2033 b'server',
2033 b'validate',
2034 b'validate',
2034 default=False,
2035 default=False,
2035 )
2036 )
2036 coreconfigitem(
2037 coreconfigitem(
2037 b'server',
2038 b'server',
2038 b'zliblevel',
2039 b'zliblevel',
2039 default=-1,
2040 default=-1,
2040 )
2041 )
2041 coreconfigitem(
2042 coreconfigitem(
2042 b'server',
2043 b'server',
2043 b'zstdlevel',
2044 b'zstdlevel',
2044 default=3,
2045 default=3,
2045 )
2046 )
2046 coreconfigitem(
2047 coreconfigitem(
2047 b'share',
2048 b'share',
2048 b'pool',
2049 b'pool',
2049 default=None,
2050 default=None,
2050 )
2051 )
2051 coreconfigitem(
2052 coreconfigitem(
2052 b'share',
2053 b'share',
2053 b'poolnaming',
2054 b'poolnaming',
2054 default=b'identity',
2055 default=b'identity',
2055 )
2056 )
2056 coreconfigitem(
2057 coreconfigitem(
2057 b'share',
2058 b'share',
2058 b'safe-mismatch.source-not-safe',
2059 b'safe-mismatch.source-not-safe',
2059 default=b'abort',
2060 default=b'abort',
2060 )
2061 )
2061 coreconfigitem(
2062 coreconfigitem(
2062 b'share',
2063 b'share',
2063 b'safe-mismatch.source-safe',
2064 b'safe-mismatch.source-safe',
2064 default=b'abort',
2065 default=b'abort',
2065 )
2066 )
2066 coreconfigitem(
2067 coreconfigitem(
2067 b'share',
2068 b'share',
2068 b'safe-mismatch.source-not-safe.warn',
2069 b'safe-mismatch.source-not-safe.warn',
2069 default=True,
2070 default=True,
2070 )
2071 )
2071 coreconfigitem(
2072 coreconfigitem(
2072 b'share',
2073 b'share',
2073 b'safe-mismatch.source-safe.warn',
2074 b'safe-mismatch.source-safe.warn',
2074 default=True,
2075 default=True,
2075 )
2076 )
2076 coreconfigitem(
2077 coreconfigitem(
2077 b'shelve',
2078 b'shelve',
2078 b'maxbackups',
2079 b'maxbackups',
2079 default=10,
2080 default=10,
2080 )
2081 )
2081 coreconfigitem(
2082 coreconfigitem(
2082 b'smtp',
2083 b'smtp',
2083 b'host',
2084 b'host',
2084 default=None,
2085 default=None,
2085 )
2086 )
2086 coreconfigitem(
2087 coreconfigitem(
2087 b'smtp',
2088 b'smtp',
2088 b'local_hostname',
2089 b'local_hostname',
2089 default=None,
2090 default=None,
2090 )
2091 )
2091 coreconfigitem(
2092 coreconfigitem(
2092 b'smtp',
2093 b'smtp',
2093 b'password',
2094 b'password',
2094 default=None,
2095 default=None,
2095 )
2096 )
2096 coreconfigitem(
2097 coreconfigitem(
2097 b'smtp',
2098 b'smtp',
2098 b'port',
2099 b'port',
2099 default=dynamicdefault,
2100 default=dynamicdefault,
2100 )
2101 )
2101 coreconfigitem(
2102 coreconfigitem(
2102 b'smtp',
2103 b'smtp',
2103 b'tls',
2104 b'tls',
2104 default=b'none',
2105 default=b'none',
2105 )
2106 )
2106 coreconfigitem(
2107 coreconfigitem(
2107 b'smtp',
2108 b'smtp',
2108 b'username',
2109 b'username',
2109 default=None,
2110 default=None,
2110 )
2111 )
2111 coreconfigitem(
2112 coreconfigitem(
2112 b'sparse',
2113 b'sparse',
2113 b'missingwarning',
2114 b'missingwarning',
2114 default=True,
2115 default=True,
2115 experimental=True,
2116 experimental=True,
2116 )
2117 )
2117 coreconfigitem(
2118 coreconfigitem(
2118 b'subrepos',
2119 b'subrepos',
2119 b'allowed',
2120 b'allowed',
2120 default=dynamicdefault, # to make backporting simpler
2121 default=dynamicdefault, # to make backporting simpler
2121 )
2122 )
2122 coreconfigitem(
2123 coreconfigitem(
2123 b'subrepos',
2124 b'subrepos',
2124 b'hg:allowed',
2125 b'hg:allowed',
2125 default=dynamicdefault,
2126 default=dynamicdefault,
2126 )
2127 )
2127 coreconfigitem(
2128 coreconfigitem(
2128 b'subrepos',
2129 b'subrepos',
2129 b'git:allowed',
2130 b'git:allowed',
2130 default=dynamicdefault,
2131 default=dynamicdefault,
2131 )
2132 )
2132 coreconfigitem(
2133 coreconfigitem(
2133 b'subrepos',
2134 b'subrepos',
2134 b'svn:allowed',
2135 b'svn:allowed',
2135 default=dynamicdefault,
2136 default=dynamicdefault,
2136 )
2137 )
2137 coreconfigitem(
2138 coreconfigitem(
2138 b'templates',
2139 b'templates',
2139 b'.*',
2140 b'.*',
2140 default=None,
2141 default=None,
2141 generic=True,
2142 generic=True,
2142 )
2143 )
2143 coreconfigitem(
2144 coreconfigitem(
2144 b'templateconfig',
2145 b'templateconfig',
2145 b'.*',
2146 b'.*',
2146 default=dynamicdefault,
2147 default=dynamicdefault,
2147 generic=True,
2148 generic=True,
2148 )
2149 )
2149 coreconfigitem(
2150 coreconfigitem(
2150 b'trusted',
2151 b'trusted',
2151 b'groups',
2152 b'groups',
2152 default=list,
2153 default=list,
2153 )
2154 )
2154 coreconfigitem(
2155 coreconfigitem(
2155 b'trusted',
2156 b'trusted',
2156 b'users',
2157 b'users',
2157 default=list,
2158 default=list,
2158 )
2159 )
2159 coreconfigitem(
2160 coreconfigitem(
2160 b'ui',
2161 b'ui',
2161 b'_usedassubrepo',
2162 b'_usedassubrepo',
2162 default=False,
2163 default=False,
2163 )
2164 )
2164 coreconfigitem(
2165 coreconfigitem(
2165 b'ui',
2166 b'ui',
2166 b'allowemptycommit',
2167 b'allowemptycommit',
2167 default=False,
2168 default=False,
2168 )
2169 )
2169 coreconfigitem(
2170 coreconfigitem(
2170 b'ui',
2171 b'ui',
2171 b'archivemeta',
2172 b'archivemeta',
2172 default=True,
2173 default=True,
2173 )
2174 )
2174 coreconfigitem(
2175 coreconfigitem(
2175 b'ui',
2176 b'ui',
2176 b'askusername',
2177 b'askusername',
2177 default=False,
2178 default=False,
2178 )
2179 )
2179 coreconfigitem(
2180 coreconfigitem(
2180 b'ui',
2181 b'ui',
2181 b'available-memory',
2182 b'available-memory',
2182 default=None,
2183 default=None,
2183 )
2184 )
2184
2185
2185 coreconfigitem(
2186 coreconfigitem(
2186 b'ui',
2187 b'ui',
2187 b'clonebundlefallback',
2188 b'clonebundlefallback',
2188 default=False,
2189 default=False,
2189 )
2190 )
2190 coreconfigitem(
2191 coreconfigitem(
2191 b'ui',
2192 b'ui',
2192 b'clonebundleprefers',
2193 b'clonebundleprefers',
2193 default=list,
2194 default=list,
2194 )
2195 )
2195 coreconfigitem(
2196 coreconfigitem(
2196 b'ui',
2197 b'ui',
2197 b'clonebundles',
2198 b'clonebundles',
2198 default=True,
2199 default=True,
2199 )
2200 )
2200 coreconfigitem(
2201 coreconfigitem(
2201 b'ui',
2202 b'ui',
2202 b'color',
2203 b'color',
2203 default=b'auto',
2204 default=b'auto',
2204 )
2205 )
2205 coreconfigitem(
2206 coreconfigitem(
2206 b'ui',
2207 b'ui',
2207 b'commitsubrepos',
2208 b'commitsubrepos',
2208 default=False,
2209 default=False,
2209 )
2210 )
2210 coreconfigitem(
2211 coreconfigitem(
2211 b'ui',
2212 b'ui',
2212 b'debug',
2213 b'debug',
2213 default=False,
2214 default=False,
2214 )
2215 )
2215 coreconfigitem(
2216 coreconfigitem(
2216 b'ui',
2217 b'ui',
2217 b'debugger',
2218 b'debugger',
2218 default=None,
2219 default=None,
2219 )
2220 )
2220 coreconfigitem(
2221 coreconfigitem(
2221 b'ui',
2222 b'ui',
2222 b'editor',
2223 b'editor',
2223 default=dynamicdefault,
2224 default=dynamicdefault,
2224 )
2225 )
2225 coreconfigitem(
2226 coreconfigitem(
2226 b'ui',
2227 b'ui',
2227 b'detailed-exit-code',
2228 b'detailed-exit-code',
2228 default=False,
2229 default=False,
2229 experimental=True,
2230 experimental=True,
2230 )
2231 )
2231 coreconfigitem(
2232 coreconfigitem(
2232 b'ui',
2233 b'ui',
2233 b'fallbackencoding',
2234 b'fallbackencoding',
2234 default=None,
2235 default=None,
2235 )
2236 )
2236 coreconfigitem(
2237 coreconfigitem(
2237 b'ui',
2238 b'ui',
2238 b'forcecwd',
2239 b'forcecwd',
2239 default=None,
2240 default=None,
2240 )
2241 )
2241 coreconfigitem(
2242 coreconfigitem(
2242 b'ui',
2243 b'ui',
2243 b'forcemerge',
2244 b'forcemerge',
2244 default=None,
2245 default=None,
2245 )
2246 )
2246 coreconfigitem(
2247 coreconfigitem(
2247 b'ui',
2248 b'ui',
2248 b'formatdebug',
2249 b'formatdebug',
2249 default=False,
2250 default=False,
2250 )
2251 )
2251 coreconfigitem(
2252 coreconfigitem(
2252 b'ui',
2253 b'ui',
2253 b'formatjson',
2254 b'formatjson',
2254 default=False,
2255 default=False,
2255 )
2256 )
2256 coreconfigitem(
2257 coreconfigitem(
2257 b'ui',
2258 b'ui',
2258 b'formatted',
2259 b'formatted',
2259 default=None,
2260 default=None,
2260 )
2261 )
2261 coreconfigitem(
2262 coreconfigitem(
2262 b'ui',
2263 b'ui',
2263 b'interactive',
2264 b'interactive',
2264 default=None,
2265 default=None,
2265 )
2266 )
2266 coreconfigitem(
2267 coreconfigitem(
2267 b'ui',
2268 b'ui',
2268 b'interface',
2269 b'interface',
2269 default=None,
2270 default=None,
2270 )
2271 )
2271 coreconfigitem(
2272 coreconfigitem(
2272 b'ui',
2273 b'ui',
2273 b'interface.chunkselector',
2274 b'interface.chunkselector',
2274 default=None,
2275 default=None,
2275 )
2276 )
2276 coreconfigitem(
2277 coreconfigitem(
2277 b'ui',
2278 b'ui',
2278 b'large-file-limit',
2279 b'large-file-limit',
2279 default=10000000,
2280 default=10000000,
2280 )
2281 )
2281 coreconfigitem(
2282 coreconfigitem(
2282 b'ui',
2283 b'ui',
2283 b'logblockedtimes',
2284 b'logblockedtimes',
2284 default=False,
2285 default=False,
2285 )
2286 )
2286 coreconfigitem(
2287 coreconfigitem(
2287 b'ui',
2288 b'ui',
2288 b'merge',
2289 b'merge',
2289 default=None,
2290 default=None,
2290 )
2291 )
2291 coreconfigitem(
2292 coreconfigitem(
2292 b'ui',
2293 b'ui',
2293 b'mergemarkers',
2294 b'mergemarkers',
2294 default=b'basic',
2295 default=b'basic',
2295 )
2296 )
2296 coreconfigitem(
2297 coreconfigitem(
2297 b'ui',
2298 b'ui',
2298 b'message-output',
2299 b'message-output',
2299 default=b'stdio',
2300 default=b'stdio',
2300 )
2301 )
2301 coreconfigitem(
2302 coreconfigitem(
2302 b'ui',
2303 b'ui',
2303 b'nontty',
2304 b'nontty',
2304 default=False,
2305 default=False,
2305 )
2306 )
2306 coreconfigitem(
2307 coreconfigitem(
2307 b'ui',
2308 b'ui',
2308 b'origbackuppath',
2309 b'origbackuppath',
2309 default=None,
2310 default=None,
2310 )
2311 )
2311 coreconfigitem(
2312 coreconfigitem(
2312 b'ui',
2313 b'ui',
2313 b'paginate',
2314 b'paginate',
2314 default=True,
2315 default=True,
2315 )
2316 )
2316 coreconfigitem(
2317 coreconfigitem(
2317 b'ui',
2318 b'ui',
2318 b'patch',
2319 b'patch',
2319 default=None,
2320 default=None,
2320 )
2321 )
2321 coreconfigitem(
2322 coreconfigitem(
2322 b'ui',
2323 b'ui',
2323 b'portablefilenames',
2324 b'portablefilenames',
2324 default=b'warn',
2325 default=b'warn',
2325 )
2326 )
2326 coreconfigitem(
2327 coreconfigitem(
2327 b'ui',
2328 b'ui',
2328 b'promptecho',
2329 b'promptecho',
2329 default=False,
2330 default=False,
2330 )
2331 )
2331 coreconfigitem(
2332 coreconfigitem(
2332 b'ui',
2333 b'ui',
2333 b'quiet',
2334 b'quiet',
2334 default=False,
2335 default=False,
2335 )
2336 )
2336 coreconfigitem(
2337 coreconfigitem(
2337 b'ui',
2338 b'ui',
2338 b'quietbookmarkmove',
2339 b'quietbookmarkmove',
2339 default=False,
2340 default=False,
2340 )
2341 )
2341 coreconfigitem(
2342 coreconfigitem(
2342 b'ui',
2343 b'ui',
2343 b'relative-paths',
2344 b'relative-paths',
2344 default=b'legacy',
2345 default=b'legacy',
2345 )
2346 )
2346 coreconfigitem(
2347 coreconfigitem(
2347 b'ui',
2348 b'ui',
2348 b'remotecmd',
2349 b'remotecmd',
2349 default=b'hg',
2350 default=b'hg',
2350 )
2351 )
2351 coreconfigitem(
2352 coreconfigitem(
2352 b'ui',
2353 b'ui',
2353 b'report_untrusted',
2354 b'report_untrusted',
2354 default=True,
2355 default=True,
2355 )
2356 )
2356 coreconfigitem(
2357 coreconfigitem(
2357 b'ui',
2358 b'ui',
2358 b'rollback',
2359 b'rollback',
2359 default=True,
2360 default=True,
2360 )
2361 )
2361 coreconfigitem(
2362 coreconfigitem(
2362 b'ui',
2363 b'ui',
2363 b'signal-safe-lock',
2364 b'signal-safe-lock',
2364 default=True,
2365 default=True,
2365 )
2366 )
2366 coreconfigitem(
2367 coreconfigitem(
2367 b'ui',
2368 b'ui',
2368 b'slash',
2369 b'slash',
2369 default=False,
2370 default=False,
2370 )
2371 )
2371 coreconfigitem(
2372 coreconfigitem(
2372 b'ui',
2373 b'ui',
2373 b'ssh',
2374 b'ssh',
2374 default=b'ssh',
2375 default=b'ssh',
2375 )
2376 )
2376 coreconfigitem(
2377 coreconfigitem(
2377 b'ui',
2378 b'ui',
2378 b'ssherrorhint',
2379 b'ssherrorhint',
2379 default=None,
2380 default=None,
2380 )
2381 )
2381 coreconfigitem(
2382 coreconfigitem(
2382 b'ui',
2383 b'ui',
2383 b'statuscopies',
2384 b'statuscopies',
2384 default=False,
2385 default=False,
2385 )
2386 )
2386 coreconfigitem(
2387 coreconfigitem(
2387 b'ui',
2388 b'ui',
2388 b'strict',
2389 b'strict',
2389 default=False,
2390 default=False,
2390 )
2391 )
2391 coreconfigitem(
2392 coreconfigitem(
2392 b'ui',
2393 b'ui',
2393 b'style',
2394 b'style',
2394 default=b'',
2395 default=b'',
2395 )
2396 )
2396 coreconfigitem(
2397 coreconfigitem(
2397 b'ui',
2398 b'ui',
2398 b'supportcontact',
2399 b'supportcontact',
2399 default=None,
2400 default=None,
2400 )
2401 )
2401 coreconfigitem(
2402 coreconfigitem(
2402 b'ui',
2403 b'ui',
2403 b'textwidth',
2404 b'textwidth',
2404 default=78,
2405 default=78,
2405 )
2406 )
2406 coreconfigitem(
2407 coreconfigitem(
2407 b'ui',
2408 b'ui',
2408 b'timeout',
2409 b'timeout',
2409 default=b'600',
2410 default=b'600',
2410 )
2411 )
2411 coreconfigitem(
2412 coreconfigitem(
2412 b'ui',
2413 b'ui',
2413 b'timeout.warn',
2414 b'timeout.warn',
2414 default=0,
2415 default=0,
2415 )
2416 )
2416 coreconfigitem(
2417 coreconfigitem(
2417 b'ui',
2418 b'ui',
2418 b'timestamp-output',
2419 b'timestamp-output',
2419 default=False,
2420 default=False,
2420 )
2421 )
2421 coreconfigitem(
2422 coreconfigitem(
2422 b'ui',
2423 b'ui',
2423 b'traceback',
2424 b'traceback',
2424 default=False,
2425 default=False,
2425 )
2426 )
2426 coreconfigitem(
2427 coreconfigitem(
2427 b'ui',
2428 b'ui',
2428 b'tweakdefaults',
2429 b'tweakdefaults',
2429 default=False,
2430 default=False,
2430 )
2431 )
2431 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
2432 coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')])
2432 coreconfigitem(
2433 coreconfigitem(
2433 b'ui',
2434 b'ui',
2434 b'verbose',
2435 b'verbose',
2435 default=False,
2436 default=False,
2436 )
2437 )
2437 coreconfigitem(
2438 coreconfigitem(
2438 b'verify',
2439 b'verify',
2439 b'skipflags',
2440 b'skipflags',
2440 default=None,
2441 default=None,
2441 )
2442 )
2442 coreconfigitem(
2443 coreconfigitem(
2443 b'web',
2444 b'web',
2444 b'allowbz2',
2445 b'allowbz2',
2445 default=False,
2446 default=False,
2446 )
2447 )
2447 coreconfigitem(
2448 coreconfigitem(
2448 b'web',
2449 b'web',
2449 b'allowgz',
2450 b'allowgz',
2450 default=False,
2451 default=False,
2451 )
2452 )
2452 coreconfigitem(
2453 coreconfigitem(
2453 b'web',
2454 b'web',
2454 b'allow-pull',
2455 b'allow-pull',
2455 alias=[(b'web', b'allowpull')],
2456 alias=[(b'web', b'allowpull')],
2456 default=True,
2457 default=True,
2457 )
2458 )
2458 coreconfigitem(
2459 coreconfigitem(
2459 b'web',
2460 b'web',
2460 b'allow-push',
2461 b'allow-push',
2461 alias=[(b'web', b'allow_push')],
2462 alias=[(b'web', b'allow_push')],
2462 default=list,
2463 default=list,
2463 )
2464 )
2464 coreconfigitem(
2465 coreconfigitem(
2465 b'web',
2466 b'web',
2466 b'allowzip',
2467 b'allowzip',
2467 default=False,
2468 default=False,
2468 )
2469 )
2469 coreconfigitem(
2470 coreconfigitem(
2470 b'web',
2471 b'web',
2471 b'archivesubrepos',
2472 b'archivesubrepos',
2472 default=False,
2473 default=False,
2473 )
2474 )
2474 coreconfigitem(
2475 coreconfigitem(
2475 b'web',
2476 b'web',
2476 b'cache',
2477 b'cache',
2477 default=True,
2478 default=True,
2478 )
2479 )
2479 coreconfigitem(
2480 coreconfigitem(
2480 b'web',
2481 b'web',
2481 b'comparisoncontext',
2482 b'comparisoncontext',
2482 default=5,
2483 default=5,
2483 )
2484 )
2484 coreconfigitem(
2485 coreconfigitem(
2485 b'web',
2486 b'web',
2486 b'contact',
2487 b'contact',
2487 default=None,
2488 default=None,
2488 )
2489 )
2489 coreconfigitem(
2490 coreconfigitem(
2490 b'web',
2491 b'web',
2491 b'deny_push',
2492 b'deny_push',
2492 default=list,
2493 default=list,
2493 )
2494 )
2494 coreconfigitem(
2495 coreconfigitem(
2495 b'web',
2496 b'web',
2496 b'guessmime',
2497 b'guessmime',
2497 default=False,
2498 default=False,
2498 )
2499 )
2499 coreconfigitem(
2500 coreconfigitem(
2500 b'web',
2501 b'web',
2501 b'hidden',
2502 b'hidden',
2502 default=False,
2503 default=False,
2503 )
2504 )
2504 coreconfigitem(
2505 coreconfigitem(
2505 b'web',
2506 b'web',
2506 b'labels',
2507 b'labels',
2507 default=list,
2508 default=list,
2508 )
2509 )
2509 coreconfigitem(
2510 coreconfigitem(
2510 b'web',
2511 b'web',
2511 b'logoimg',
2512 b'logoimg',
2512 default=b'hglogo.png',
2513 default=b'hglogo.png',
2513 )
2514 )
2514 coreconfigitem(
2515 coreconfigitem(
2515 b'web',
2516 b'web',
2516 b'logourl',
2517 b'logourl',
2517 default=b'https://mercurial-scm.org/',
2518 default=b'https://mercurial-scm.org/',
2518 )
2519 )
2519 coreconfigitem(
2520 coreconfigitem(
2520 b'web',
2521 b'web',
2521 b'accesslog',
2522 b'accesslog',
2522 default=b'-',
2523 default=b'-',
2523 )
2524 )
2524 coreconfigitem(
2525 coreconfigitem(
2525 b'web',
2526 b'web',
2526 b'address',
2527 b'address',
2527 default=b'',
2528 default=b'',
2528 )
2529 )
2529 coreconfigitem(
2530 coreconfigitem(
2530 b'web',
2531 b'web',
2531 b'allow-archive',
2532 b'allow-archive',
2532 alias=[(b'web', b'allow_archive')],
2533 alias=[(b'web', b'allow_archive')],
2533 default=list,
2534 default=list,
2534 )
2535 )
2535 coreconfigitem(
2536 coreconfigitem(
2536 b'web',
2537 b'web',
2537 b'allow_read',
2538 b'allow_read',
2538 default=list,
2539 default=list,
2539 )
2540 )
2540 coreconfigitem(
2541 coreconfigitem(
2541 b'web',
2542 b'web',
2542 b'baseurl',
2543 b'baseurl',
2543 default=None,
2544 default=None,
2544 )
2545 )
2545 coreconfigitem(
2546 coreconfigitem(
2546 b'web',
2547 b'web',
2547 b'cacerts',
2548 b'cacerts',
2548 default=None,
2549 default=None,
2549 )
2550 )
2550 coreconfigitem(
2551 coreconfigitem(
2551 b'web',
2552 b'web',
2552 b'certificate',
2553 b'certificate',
2553 default=None,
2554 default=None,
2554 )
2555 )
2555 coreconfigitem(
2556 coreconfigitem(
2556 b'web',
2557 b'web',
2557 b'collapse',
2558 b'collapse',
2558 default=False,
2559 default=False,
2559 )
2560 )
2560 coreconfigitem(
2561 coreconfigitem(
2561 b'web',
2562 b'web',
2562 b'csp',
2563 b'csp',
2563 default=None,
2564 default=None,
2564 )
2565 )
2565 coreconfigitem(
2566 coreconfigitem(
2566 b'web',
2567 b'web',
2567 b'deny_read',
2568 b'deny_read',
2568 default=list,
2569 default=list,
2569 )
2570 )
2570 coreconfigitem(
2571 coreconfigitem(
2571 b'web',
2572 b'web',
2572 b'descend',
2573 b'descend',
2573 default=True,
2574 default=True,
2574 )
2575 )
2575 coreconfigitem(
2576 coreconfigitem(
2576 b'web',
2577 b'web',
2577 b'description',
2578 b'description',
2578 default=b"",
2579 default=b"",
2579 )
2580 )
2580 coreconfigitem(
2581 coreconfigitem(
2581 b'web',
2582 b'web',
2582 b'encoding',
2583 b'encoding',
2583 default=lambda: encoding.encoding,
2584 default=lambda: encoding.encoding,
2584 )
2585 )
2585 coreconfigitem(
2586 coreconfigitem(
2586 b'web',
2587 b'web',
2587 b'errorlog',
2588 b'errorlog',
2588 default=b'-',
2589 default=b'-',
2589 )
2590 )
2590 coreconfigitem(
2591 coreconfigitem(
2591 b'web',
2592 b'web',
2592 b'ipv6',
2593 b'ipv6',
2593 default=False,
2594 default=False,
2594 )
2595 )
2595 coreconfigitem(
2596 coreconfigitem(
2596 b'web',
2597 b'web',
2597 b'maxchanges',
2598 b'maxchanges',
2598 default=10,
2599 default=10,
2599 )
2600 )
2600 coreconfigitem(
2601 coreconfigitem(
2601 b'web',
2602 b'web',
2602 b'maxfiles',
2603 b'maxfiles',
2603 default=10,
2604 default=10,
2604 )
2605 )
2605 coreconfigitem(
2606 coreconfigitem(
2606 b'web',
2607 b'web',
2607 b'maxshortchanges',
2608 b'maxshortchanges',
2608 default=60,
2609 default=60,
2609 )
2610 )
2610 coreconfigitem(
2611 coreconfigitem(
2611 b'web',
2612 b'web',
2612 b'motd',
2613 b'motd',
2613 default=b'',
2614 default=b'',
2614 )
2615 )
2615 coreconfigitem(
2616 coreconfigitem(
2616 b'web',
2617 b'web',
2617 b'name',
2618 b'name',
2618 default=dynamicdefault,
2619 default=dynamicdefault,
2619 )
2620 )
2620 coreconfigitem(
2621 coreconfigitem(
2621 b'web',
2622 b'web',
2622 b'port',
2623 b'port',
2623 default=8000,
2624 default=8000,
2624 )
2625 )
2625 coreconfigitem(
2626 coreconfigitem(
2626 b'web',
2627 b'web',
2627 b'prefix',
2628 b'prefix',
2628 default=b'',
2629 default=b'',
2629 )
2630 )
2630 coreconfigitem(
2631 coreconfigitem(
2631 b'web',
2632 b'web',
2632 b'push_ssl',
2633 b'push_ssl',
2633 default=True,
2634 default=True,
2634 )
2635 )
2635 coreconfigitem(
2636 coreconfigitem(
2636 b'web',
2637 b'web',
2637 b'refreshinterval',
2638 b'refreshinterval',
2638 default=20,
2639 default=20,
2639 )
2640 )
2640 coreconfigitem(
2641 coreconfigitem(
2641 b'web',
2642 b'web',
2642 b'server-header',
2643 b'server-header',
2643 default=None,
2644 default=None,
2644 )
2645 )
2645 coreconfigitem(
2646 coreconfigitem(
2646 b'web',
2647 b'web',
2647 b'static',
2648 b'static',
2648 default=None,
2649 default=None,
2649 )
2650 )
2650 coreconfigitem(
2651 coreconfigitem(
2651 b'web',
2652 b'web',
2652 b'staticurl',
2653 b'staticurl',
2653 default=None,
2654 default=None,
2654 )
2655 )
2655 coreconfigitem(
2656 coreconfigitem(
2656 b'web',
2657 b'web',
2657 b'stripes',
2658 b'stripes',
2658 default=1,
2659 default=1,
2659 )
2660 )
2660 coreconfigitem(
2661 coreconfigitem(
2661 b'web',
2662 b'web',
2662 b'style',
2663 b'style',
2663 default=b'paper',
2664 default=b'paper',
2664 )
2665 )
2665 coreconfigitem(
2666 coreconfigitem(
2666 b'web',
2667 b'web',
2667 b'templates',
2668 b'templates',
2668 default=None,
2669 default=None,
2669 )
2670 )
2670 coreconfigitem(
2671 coreconfigitem(
2671 b'web',
2672 b'web',
2672 b'view',
2673 b'view',
2673 default=b'served',
2674 default=b'served',
2674 experimental=True,
2675 experimental=True,
2675 )
2676 )
2676 coreconfigitem(
2677 coreconfigitem(
2677 b'worker',
2678 b'worker',
2678 b'backgroundclose',
2679 b'backgroundclose',
2679 default=dynamicdefault,
2680 default=dynamicdefault,
2680 )
2681 )
2681 # Windows defaults to a limit of 512 open files. A buffer of 128
2682 # Windows defaults to a limit of 512 open files. A buffer of 128
2682 # should give us enough headway.
2683 # should give us enough headway.
2683 coreconfigitem(
2684 coreconfigitem(
2684 b'worker',
2685 b'worker',
2685 b'backgroundclosemaxqueue',
2686 b'backgroundclosemaxqueue',
2686 default=384,
2687 default=384,
2687 )
2688 )
2688 coreconfigitem(
2689 coreconfigitem(
2689 b'worker',
2690 b'worker',
2690 b'backgroundcloseminfilecount',
2691 b'backgroundcloseminfilecount',
2691 default=2048,
2692 default=2048,
2692 )
2693 )
2693 coreconfigitem(
2694 coreconfigitem(
2694 b'worker',
2695 b'worker',
2695 b'backgroundclosethreadcount',
2696 b'backgroundclosethreadcount',
2696 default=4,
2697 default=4,
2697 )
2698 )
2698 coreconfigitem(
2699 coreconfigitem(
2699 b'worker',
2700 b'worker',
2700 b'enabled',
2701 b'enabled',
2701 default=True,
2702 default=True,
2702 )
2703 )
2703 coreconfigitem(
2704 coreconfigitem(
2704 b'worker',
2705 b'worker',
2705 b'numcpus',
2706 b'numcpus',
2706 default=None,
2707 default=None,
2707 )
2708 )
2708
2709
2709 # Rebase related configuration moved to core because other extension are doing
2710 # Rebase related configuration moved to core because other extension are doing
2710 # strange things. For example, shelve import the extensions to reuse some bit
2711 # strange things. For example, shelve import the extensions to reuse some bit
2711 # without formally loading it.
2712 # without formally loading it.
2712 coreconfigitem(
2713 coreconfigitem(
2713 b'commands',
2714 b'commands',
2714 b'rebase.requiredest',
2715 b'rebase.requiredest',
2715 default=False,
2716 default=False,
2716 )
2717 )
2717 coreconfigitem(
2718 coreconfigitem(
2718 b'experimental',
2719 b'experimental',
2719 b'rebaseskipobsolete',
2720 b'rebaseskipobsolete',
2720 default=True,
2721 default=True,
2721 )
2722 )
2722 coreconfigitem(
2723 coreconfigitem(
2723 b'rebase',
2724 b'rebase',
2724 b'singletransaction',
2725 b'singletransaction',
2725 default=False,
2726 default=False,
2726 )
2727 )
2727 coreconfigitem(
2728 coreconfigitem(
2728 b'rebase',
2729 b'rebase',
2729 b'experimental.inmemory',
2730 b'experimental.inmemory',
2730 default=False,
2731 default=False,
2731 )
2732 )
@@ -1,3151 +1,3151 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 ``exp-rc-dirstate-v2``
895 ``use-dirstate-v2``
896 Enable or disable the experimental "dirstate-v2" feature. The dirstate
896 Enable or disable the experimental "dirstate-v2" feature. The dirstate
897 functionality is shared by all commands interacting with the working copy.
897 functionality is shared by all commands interacting with the working copy.
898 The new version is more robust, faster and stores more information.
898 The new version is more robust, faster and stores more information.
899
899
900 The performance-improving version of this feature is currently only
900 The performance-improving version of this feature is currently only
901 implemented in Rust (see :hg:`help rust`), so people not using a version of
901 implemented in Rust (see :hg:`help rust`), so people not using a version of
902 Mercurial compiled with the Rust parts might actually suffer some slowdown.
902 Mercurial compiled with the Rust parts might actually suffer some slowdown.
903 For this reason, such versions will by default refuse to access repositories
903 For this reason, such versions will by default refuse to access repositories
904 with "dirstate-v2" enabled.
904 with "dirstate-v2" enabled.
905
905
906 This behavior can be adjusted via configuration: check
906 This behavior can be adjusted via configuration: check
907 :hg:`help config.storage.dirstate-v2.slow-path` for details.
907 :hg:`help config.storage.dirstate-v2.slow-path` for details.
908
908
909 Repositories with this on-disk format require Mercurial 6.0 or above.
909 Repositories with this on-disk format require Mercurial 6.0 or above.
910
910
911 By default this format variant is disabled if the fast implementation is not
911 By default this format variant is disabled if the fast implementation is not
912 available, and enabled by default if the fast implementation is available.
912 available, and enabled by default if the fast implementation is available.
913
913
914 To accomodate installations of Mercurial without the fast implementation,
914 To accomodate installations of Mercurial without the fast implementation,
915 you can downgrade your repository. To do so run the following command:
915 you can downgrade your repository. To do so run the following command:
916
916
917 $ hg debugupgraderepo \
917 $ hg debugupgraderepo \
918 --run \
918 --run \
919 --config format.exp-rc-dirstate-v2=False \
919 --config format.use-dirstate-v2=False \
920 --config storage.dirstate-v2.slow-path=allow
920 --config storage.dirstate-v2.slow-path=allow
921
921
922 For a more comprehensive guide, see :hg:`help internals.dirstate-v2`.
922 For a more comprehensive guide, see :hg:`help internals.dirstate-v2`.
923
923
924 ``use-persistent-nodemap``
924 ``use-persistent-nodemap``
925 Enable or disable the "persistent-nodemap" feature which improves
925 Enable or disable the "persistent-nodemap" feature which improves
926 performance if the Rust extensions are available.
926 performance if the Rust extensions are available.
927
927
928 The "persistent-nodemap" persist the "node -> rev" on disk removing the
928 The "persistent-nodemap" persist the "node -> rev" on disk removing the
929 need to dynamically build that mapping for each Mercurial invocation. This
929 need to dynamically build that mapping for each Mercurial invocation. This
930 significantly reduces the startup cost of various local and server-side
930 significantly reduces the startup cost of various local and server-side
931 operation for larger repositories.
931 operation for larger repositories.
932
932
933 The performance-improving version of this feature is currently only
933 The performance-improving version of this feature is currently only
934 implemented in Rust (see :hg:`help rust`), so people not using a version of
934 implemented in Rust (see :hg:`help rust`), so people not using a version of
935 Mercurial compiled with the Rust parts might actually suffer some slowdown.
935 Mercurial compiled with the Rust parts might actually suffer some slowdown.
936 For this reason, such versions will by default refuse to access repositories
936 For this reason, such versions will by default refuse to access repositories
937 with "persistent-nodemap".
937 with "persistent-nodemap".
938
938
939 This behavior can be adjusted via configuration: check
939 This behavior can be adjusted via configuration: check
940 :hg:`help config.storage.revlog.persistent-nodemap.slow-path` for details.
940 :hg:`help config.storage.revlog.persistent-nodemap.slow-path` for details.
941
941
942 Repositories with this on-disk format require Mercurial 5.4 or above.
942 Repositories with this on-disk format require Mercurial 5.4 or above.
943
943
944 By default this format variant is disabled if the fast implementation is not
944 By default this format variant is disabled if the fast implementation is not
945 available, and enabled by default if the fast implementation is available.
945 available, and enabled by default if the fast implementation is available.
946
946
947 To accomodate installations of Mercurial without the fast implementation,
947 To accomodate installations of Mercurial without the fast implementation,
948 you can downgrade your repository. To do so run the following command:
948 you can downgrade your repository. To do so run the following command:
949
949
950 $ hg debugupgraderepo \
950 $ hg debugupgraderepo \
951 --run \
951 --run \
952 --config format.use-persistent-nodemap=False \
952 --config format.use-persistent-nodemap=False \
953 --config storage.revlog.persistent-nodemap.slow-path=allow
953 --config storage.revlog.persistent-nodemap.slow-path=allow
954
954
955 ``use-share-safe``
955 ``use-share-safe``
956 Enforce "safe" behaviors for all "shares" that access this repository.
956 Enforce "safe" behaviors for all "shares" that access this repository.
957
957
958 With this feature, "shares" using this repository as a source will:
958 With this feature, "shares" using this repository as a source will:
959
959
960 * read the source repository's configuration (`<source>/.hg/hgrc`).
960 * read the source repository's configuration (`<source>/.hg/hgrc`).
961 * read and use the source repository's "requirements"
961 * read and use the source repository's "requirements"
962 (except the working copy specific one).
962 (except the working copy specific one).
963
963
964 Without this feature, "shares" using this repository as a source will:
964 Without this feature, "shares" using this repository as a source will:
965
965
966 * keep tracking the repository "requirements" in the share only, ignoring
966 * keep tracking the repository "requirements" in the share only, ignoring
967 the source "requirements", possibly diverging from them.
967 the source "requirements", possibly diverging from them.
968 * ignore source repository config. This can create problems, like silently
968 * ignore source repository config. This can create problems, like silently
969 ignoring important hooks.
969 ignoring important hooks.
970
970
971 Beware that existing shares will not be upgraded/downgraded, and by
971 Beware that existing shares will not be upgraded/downgraded, and by
972 default, Mercurial will refuse to interact with them until the mismatch
972 default, Mercurial will refuse to interact with them until the mismatch
973 is resolved. See :hg:`help config share.safe-mismatch.source-safe` and
973 is resolved. See :hg:`help config share.safe-mismatch.source-safe` and
974 :hg:`help config share.safe-mismatch.source-not-safe` for details.
974 :hg:`help config share.safe-mismatch.source-not-safe` for details.
975
975
976 Introduced in Mercurial 5.7.
976 Introduced in Mercurial 5.7.
977
977
978 Disabled by default.
978 Disabled by default.
979
979
980 ``usestore``
980 ``usestore``
981 Enable or disable the "store" repository format which improves
981 Enable or disable the "store" repository format which improves
982 compatibility with systems that fold case or otherwise mangle
982 compatibility with systems that fold case or otherwise mangle
983 filenames. Disabling this option will allow you to store longer filenames
983 filenames. Disabling this option will allow you to store longer filenames
984 in some situations at the expense of compatibility.
984 in some situations at the expense of compatibility.
985
985
986 Repositories with this on-disk format require Mercurial version 0.9.4.
986 Repositories with this on-disk format require Mercurial version 0.9.4.
987
987
988 Enabled by default.
988 Enabled by default.
989
989
990 ``sparse-revlog``
990 ``sparse-revlog``
991 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
991 Enable or disable the ``sparse-revlog`` delta strategy. This format improves
992 delta re-use inside revlog. For very branchy repositories, it results in a
992 delta re-use inside revlog. For very branchy repositories, it results in a
993 smaller store. For repositories with many revisions, it also helps
993 smaller store. For repositories with many revisions, it also helps
994 performance (by using shortened delta chains.)
994 performance (by using shortened delta chains.)
995
995
996 Repositories with this on-disk format require Mercurial version 4.7
996 Repositories with this on-disk format require Mercurial version 4.7
997
997
998 Enabled by default.
998 Enabled by default.
999
999
1000 ``revlog-compression``
1000 ``revlog-compression``
1001 Compression algorithm used by revlog. Supported values are `zlib` and
1001 Compression algorithm used by revlog. Supported values are `zlib` and
1002 `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
1002 `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is
1003 a newer format that is usually a net win over `zlib`, operating faster at
1003 a newer format that is usually a net win over `zlib`, operating faster at
1004 better compression rates. Use `zstd` to reduce CPU usage. Multiple values
1004 better compression rates. Use `zstd` to reduce CPU usage. Multiple values
1005 can be specified, the first available one will be used.
1005 can be specified, the first available one will be used.
1006
1006
1007 On some systems, the Mercurial installation may lack `zstd` support.
1007 On some systems, the Mercurial installation may lack `zstd` support.
1008
1008
1009 Default is `zstd` if available, `zlib` otherwise.
1009 Default is `zstd` if available, `zlib` otherwise.
1010
1010
1011 ``bookmarks-in-store``
1011 ``bookmarks-in-store``
1012 Store bookmarks in .hg/store/. This means that bookmarks are shared when
1012 Store bookmarks in .hg/store/. This means that bookmarks are shared when
1013 using `hg share` regardless of the `-B` option.
1013 using `hg share` regardless of the `-B` option.
1014
1014
1015 Repositories with this on-disk format require Mercurial version 5.1.
1015 Repositories with this on-disk format require Mercurial version 5.1.
1016
1016
1017 Disabled by default.
1017 Disabled by default.
1018
1018
1019
1019
1020 ``graph``
1020 ``graph``
1021 ---------
1021 ---------
1022
1022
1023 Web graph view configuration. This section let you change graph
1023 Web graph view configuration. This section let you change graph
1024 elements display properties by branches, for instance to make the
1024 elements display properties by branches, for instance to make the
1025 ``default`` branch stand out.
1025 ``default`` branch stand out.
1026
1026
1027 Each line has the following format::
1027 Each line has the following format::
1028
1028
1029 <branch>.<argument> = <value>
1029 <branch>.<argument> = <value>
1030
1030
1031 where ``<branch>`` is the name of the branch being
1031 where ``<branch>`` is the name of the branch being
1032 customized. Example::
1032 customized. Example::
1033
1033
1034 [graph]
1034 [graph]
1035 # 2px width
1035 # 2px width
1036 default.width = 2
1036 default.width = 2
1037 # red color
1037 # red color
1038 default.color = FF0000
1038 default.color = FF0000
1039
1039
1040 Supported arguments:
1040 Supported arguments:
1041
1041
1042 ``width``
1042 ``width``
1043 Set branch edges width in pixels.
1043 Set branch edges width in pixels.
1044
1044
1045 ``color``
1045 ``color``
1046 Set branch edges color in hexadecimal RGB notation.
1046 Set branch edges color in hexadecimal RGB notation.
1047
1047
1048 ``hooks``
1048 ``hooks``
1049 ---------
1049 ---------
1050
1050
1051 Commands or Python functions that get automatically executed by
1051 Commands or Python functions that get automatically executed by
1052 various actions such as starting or finishing a commit. Multiple
1052 various actions such as starting or finishing a commit. Multiple
1053 hooks can be run for the same action by appending a suffix to the
1053 hooks can be run for the same action by appending a suffix to the
1054 action. Overriding a site-wide hook can be done by changing its
1054 action. Overriding a site-wide hook can be done by changing its
1055 value or setting it to an empty string. Hooks can be prioritized
1055 value or setting it to an empty string. Hooks can be prioritized
1056 by adding a prefix of ``priority.`` to the hook name on a new line
1056 by adding a prefix of ``priority.`` to the hook name on a new line
1057 and setting the priority. The default priority is 0.
1057 and setting the priority. The default priority is 0.
1058
1058
1059 Example ``.hg/hgrc``::
1059 Example ``.hg/hgrc``::
1060
1060
1061 [hooks]
1061 [hooks]
1062 # update working directory after adding changesets
1062 # update working directory after adding changesets
1063 changegroup.update = hg update
1063 changegroup.update = hg update
1064 # do not use the site-wide hook
1064 # do not use the site-wide hook
1065 incoming =
1065 incoming =
1066 incoming.email = /my/email/hook
1066 incoming.email = /my/email/hook
1067 incoming.autobuild = /my/build/hook
1067 incoming.autobuild = /my/build/hook
1068 # force autobuild hook to run before other incoming hooks
1068 # force autobuild hook to run before other incoming hooks
1069 priority.incoming.autobuild = 1
1069 priority.incoming.autobuild = 1
1070 ### control HGPLAIN setting when running autobuild hook
1070 ### control HGPLAIN setting when running autobuild hook
1071 # HGPLAIN always set (default from Mercurial 5.7)
1071 # HGPLAIN always set (default from Mercurial 5.7)
1072 incoming.autobuild:run-with-plain = yes
1072 incoming.autobuild:run-with-plain = yes
1073 # HGPLAIN never set
1073 # HGPLAIN never set
1074 incoming.autobuild:run-with-plain = no
1074 incoming.autobuild:run-with-plain = no
1075 # HGPLAIN inherited from environment (default before Mercurial 5.7)
1075 # HGPLAIN inherited from environment (default before Mercurial 5.7)
1076 incoming.autobuild:run-with-plain = auto
1076 incoming.autobuild:run-with-plain = auto
1077
1077
1078 Most hooks are run with environment variables set that give useful
1078 Most hooks are run with environment variables set that give useful
1079 additional information. For each hook below, the environment variables
1079 additional information. For each hook below, the environment variables
1080 it is passed are listed with names in the form ``$HG_foo``. The
1080 it is passed are listed with names in the form ``$HG_foo``. The
1081 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
1081 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
1082 They contain the type of hook which triggered the run and the full name
1082 They contain the type of hook which triggered the run and the full name
1083 of the hook in the config, respectively. In the example above, this will
1083 of the hook in the config, respectively. In the example above, this will
1084 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
1084 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
1085
1085
1086 .. container:: windows
1086 .. container:: windows
1087
1087
1088 Some basic Unix syntax can be enabled for portability, including ``$VAR``
1088 Some basic Unix syntax can be enabled for portability, including ``$VAR``
1089 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
1089 and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will
1090 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
1090 be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion
1091 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
1091 on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back
1092 slash or inside of a strong quote. Strong quotes will be replaced by
1092 slash or inside of a strong quote. Strong quotes will be replaced by
1093 double quotes after processing.
1093 double quotes after processing.
1094
1094
1095 This feature is enabled by adding a prefix of ``tonative.`` to the hook
1095 This feature is enabled by adding a prefix of ``tonative.`` to the hook
1096 name on a new line, and setting it to ``True``. For example::
1096 name on a new line, and setting it to ``True``. For example::
1097
1097
1098 [hooks]
1098 [hooks]
1099 incoming.autobuild = /my/build/hook
1099 incoming.autobuild = /my/build/hook
1100 # enable translation to cmd.exe syntax for autobuild hook
1100 # enable translation to cmd.exe syntax for autobuild hook
1101 tonative.incoming.autobuild = True
1101 tonative.incoming.autobuild = True
1102
1102
1103 ``changegroup``
1103 ``changegroup``
1104 Run after a changegroup has been added via push, pull or unbundle. The ID of
1104 Run after a changegroup has been added via push, pull or unbundle. The ID of
1105 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
1105 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
1106 The URL from which changes came is in ``$HG_URL``.
1106 The URL from which changes came is in ``$HG_URL``.
1107
1107
1108 ``commit``
1108 ``commit``
1109 Run after a changeset has been created in the local repository. The ID
1109 Run after a changeset has been created in the local repository. The ID
1110 of the newly created changeset is in ``$HG_NODE``. Parent changeset
1110 of the newly created changeset is in ``$HG_NODE``. Parent changeset
1111 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1111 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1112
1112
1113 ``incoming``
1113 ``incoming``
1114 Run after a changeset has been pulled, pushed, or unbundled into
1114 Run after a changeset has been pulled, pushed, or unbundled into
1115 the local repository. The ID of the newly arrived changeset is in
1115 the local repository. The ID of the newly arrived changeset is in
1116 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1116 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
1117
1117
1118 ``outgoing``
1118 ``outgoing``
1119 Run after sending changes from the local repository to another. The ID of
1119 Run after sending changes from the local repository to another. The ID of
1120 first changeset sent is in ``$HG_NODE``. The source of operation is in
1120 first changeset sent is in ``$HG_NODE``. The source of operation is in
1121 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1121 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
1122
1122
1123 ``post-<command>``
1123 ``post-<command>``
1124 Run after successful invocations of the associated command. The
1124 Run after successful invocations of the associated command. The
1125 contents of the command line are passed as ``$HG_ARGS`` and the result
1125 contents of the command line are passed as ``$HG_ARGS`` and the result
1126 code in ``$HG_RESULT``. Parsed command line arguments are passed as
1126 code in ``$HG_RESULT``. Parsed command line arguments are passed as
1127 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1127 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
1128 the python data internally passed to <command>. ``$HG_OPTS`` is a
1128 the python data internally passed to <command>. ``$HG_OPTS`` is a
1129 dictionary of options (with unspecified options set to their defaults).
1129 dictionary of options (with unspecified options set to their defaults).
1130 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1130 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
1131
1131
1132 ``fail-<command>``
1132 ``fail-<command>``
1133 Run after a failed invocation of an associated command. The contents
1133 Run after a failed invocation of an associated command. The contents
1134 of the command line are passed as ``$HG_ARGS``. Parsed command line
1134 of the command line are passed as ``$HG_ARGS``. Parsed command line
1135 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1135 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
1136 string representations of the python data internally passed to
1136 string representations of the python data internally passed to
1137 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1137 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
1138 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1138 options set to their defaults). ``$HG_PATS`` is a list of arguments.
1139 Hook failure is ignored.
1139 Hook failure is ignored.
1140
1140
1141 ``pre-<command>``
1141 ``pre-<command>``
1142 Run before executing the associated command. The contents of the
1142 Run before executing the associated command. The contents of the
1143 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1143 command line are passed as ``$HG_ARGS``. Parsed command line arguments
1144 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1144 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
1145 representations of the data internally passed to <command>. ``$HG_OPTS``
1145 representations of the data internally passed to <command>. ``$HG_OPTS``
1146 is a dictionary of options (with unspecified options set to their
1146 is a dictionary of options (with unspecified options set to their
1147 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1147 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
1148 failure, the command doesn't execute and Mercurial returns the failure
1148 failure, the command doesn't execute and Mercurial returns the failure
1149 code.
1149 code.
1150
1150
1151 ``prechangegroup``
1151 ``prechangegroup``
1152 Run before a changegroup is added via push, pull or unbundle. Exit
1152 Run before a changegroup is added via push, pull or unbundle. Exit
1153 status 0 allows the changegroup to proceed. A non-zero status will
1153 status 0 allows the changegroup to proceed. A non-zero status will
1154 cause the push, pull or unbundle to fail. The URL from which changes
1154 cause the push, pull or unbundle to fail. The URL from which changes
1155 will come is in ``$HG_URL``.
1155 will come is in ``$HG_URL``.
1156
1156
1157 ``precommit``
1157 ``precommit``
1158 Run before starting a local commit. Exit status 0 allows the
1158 Run before starting a local commit. Exit status 0 allows the
1159 commit to proceed. A non-zero status will cause the commit to fail.
1159 commit to proceed. A non-zero status will cause the commit to fail.
1160 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1160 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1161
1161
1162 ``prelistkeys``
1162 ``prelistkeys``
1163 Run before listing pushkeys (like bookmarks) in the
1163 Run before listing pushkeys (like bookmarks) in the
1164 repository. A non-zero status will cause failure. The key namespace is
1164 repository. A non-zero status will cause failure. The key namespace is
1165 in ``$HG_NAMESPACE``.
1165 in ``$HG_NAMESPACE``.
1166
1166
1167 ``preoutgoing``
1167 ``preoutgoing``
1168 Run before collecting changes to send from the local repository to
1168 Run before collecting changes to send from the local repository to
1169 another. A non-zero status will cause failure. This lets you prevent
1169 another. A non-zero status will cause failure. This lets you prevent
1170 pull over HTTP or SSH. It can also prevent propagating commits (via
1170 pull over HTTP or SSH. It can also prevent propagating commits (via
1171 local pull, push (outbound) or bundle commands), but not completely,
1171 local pull, push (outbound) or bundle commands), but not completely,
1172 since you can just copy files instead. The source of operation is in
1172 since you can just copy files instead. The source of operation is in
1173 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1173 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
1174 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1174 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
1175 is happening on behalf of a repository on same system.
1175 is happening on behalf of a repository on same system.
1176
1176
1177 ``prepushkey``
1177 ``prepushkey``
1178 Run before a pushkey (like a bookmark) is added to the
1178 Run before a pushkey (like a bookmark) is added to the
1179 repository. A non-zero status will cause the key to be rejected. The
1179 repository. A non-zero status will cause the key to be rejected. The
1180 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1180 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
1181 the old value (if any) is in ``$HG_OLD``, and the new value is in
1181 the old value (if any) is in ``$HG_OLD``, and the new value is in
1182 ``$HG_NEW``.
1182 ``$HG_NEW``.
1183
1183
1184 ``pretag``
1184 ``pretag``
1185 Run before creating a tag. Exit status 0 allows the tag to be
1185 Run before creating a tag. Exit status 0 allows the tag to be
1186 created. A non-zero status will cause the tag to fail. The ID of the
1186 created. A non-zero status will cause the tag to fail. The ID of the
1187 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1187 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
1188 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1188 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
1189
1189
1190 ``pretxnopen``
1190 ``pretxnopen``
1191 Run before any new repository transaction is open. The reason for the
1191 Run before any new repository transaction is open. The reason for the
1192 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1192 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
1193 transaction will be in ``$HG_TXNID``. A non-zero status will prevent the
1193 transaction will be in ``$HG_TXNID``. A non-zero status will prevent the
1194 transaction from being opened.
1194 transaction from being opened.
1195
1195
1196 ``pretxnclose``
1196 ``pretxnclose``
1197 Run right before the transaction is actually finalized. Any repository change
1197 Run right before the transaction is actually finalized. Any repository change
1198 will be visible to the hook program. This lets you validate the transaction
1198 will be visible to the hook program. This lets you validate the transaction
1199 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1199 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1200 status will cause the transaction to be rolled back. The reason for the
1200 status will cause the transaction to be rolled back. The reason for the
1201 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1201 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
1202 the transaction will be in ``$HG_TXNID``. The rest of the available data will
1202 the transaction will be in ``$HG_TXNID``. The rest of the available data will
1203 vary according the transaction type. Changes unbundled to the repository will
1203 vary according the transaction type. Changes unbundled to the repository will
1204 add ``$HG_URL`` and ``$HG_SOURCE``. New changesets will add ``$HG_NODE`` (the
1204 add ``$HG_URL`` and ``$HG_SOURCE``. New changesets will add ``$HG_NODE`` (the
1205 ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last added
1205 ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last added
1206 changeset). Bookmark and phase changes will set ``$HG_BOOKMARK_MOVED`` and
1206 changeset). Bookmark and phase changes will set ``$HG_BOOKMARK_MOVED`` and
1207 ``$HG_PHASES_MOVED`` to ``1`` respectively. The number of new obsmarkers, if
1207 ``$HG_PHASES_MOVED`` to ``1`` respectively. The number of new obsmarkers, if
1208 any, will be in ``$HG_NEW_OBSMARKERS``, etc.
1208 any, will be in ``$HG_NEW_OBSMARKERS``, etc.
1209
1209
1210 ``pretxnclose-bookmark``
1210 ``pretxnclose-bookmark``
1211 Run right before a bookmark change is actually finalized. Any repository
1211 Run right before a bookmark change is actually finalized. Any repository
1212 change will be visible to the hook program. This lets you validate the
1212 change will be visible to the hook program. This lets you validate the
1213 transaction content or change it. Exit status 0 allows the commit to
1213 transaction content or change it. Exit status 0 allows the commit to
1214 proceed. A non-zero status will cause the transaction to be rolled back.
1214 proceed. A non-zero status will cause the transaction to be rolled back.
1215 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1215 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
1216 bookmark location will be available in ``$HG_NODE`` while the previous
1216 bookmark location will be available in ``$HG_NODE`` while the previous
1217 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1217 location will be available in ``$HG_OLDNODE``. In case of a bookmark
1218 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1218 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1219 will be empty.
1219 will be empty.
1220 In addition, the reason for the transaction opening will be in
1220 In addition, the reason for the transaction opening will be in
1221 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1221 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1222 ``$HG_TXNID``.
1222 ``$HG_TXNID``.
1223
1223
1224 ``pretxnclose-phase``
1224 ``pretxnclose-phase``
1225 Run right before a phase change is actually finalized. Any repository change
1225 Run right before a phase change is actually finalized. Any repository change
1226 will be visible to the hook program. This lets you validate the transaction
1226 will be visible to the hook program. This lets you validate the transaction
1227 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1227 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1228 status will cause the transaction to be rolled back. The hook is called
1228 status will cause the transaction to be rolled back. The hook is called
1229 multiple times, once for each revision affected by a phase change.
1229 multiple times, once for each revision affected by a phase change.
1230 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1230 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1231 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1231 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1232 will be empty. In addition, the reason for the transaction opening will be in
1232 will be empty. In addition, the reason for the transaction opening will be in
1233 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1233 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1234 ``$HG_TXNID``. The hook is also run for newly added revisions. In this case
1234 ``$HG_TXNID``. The hook is also run for newly added revisions. In this case
1235 the ``$HG_OLDPHASE`` entry will be empty.
1235 the ``$HG_OLDPHASE`` entry will be empty.
1236
1236
1237 ``txnclose``
1237 ``txnclose``
1238 Run after any repository transaction has been committed. At this
1238 Run after any repository transaction has been committed. At this
1239 point, the transaction can no longer be rolled back. The hook will run
1239 point, the transaction can no longer be rolled back. The hook will run
1240 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1240 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1241 details about available variables.
1241 details about available variables.
1242
1242
1243 ``txnclose-bookmark``
1243 ``txnclose-bookmark``
1244 Run after any bookmark change has been committed. At this point, the
1244 Run after any bookmark change has been committed. At this point, the
1245 transaction can no longer be rolled back. The hook will run after the lock
1245 transaction can no longer be rolled back. The hook will run after the lock
1246 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1246 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1247 about available variables.
1247 about available variables.
1248
1248
1249 ``txnclose-phase``
1249 ``txnclose-phase``
1250 Run after any phase change has been committed. At this point, the
1250 Run after any phase change has been committed. At this point, the
1251 transaction can no longer be rolled back. The hook will run after the lock
1251 transaction can no longer be rolled back. The hook will run after the lock
1252 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1252 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1253 available variables.
1253 available variables.
1254
1254
1255 ``txnabort``
1255 ``txnabort``
1256 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1256 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1257 for details about available variables.
1257 for details about available variables.
1258
1258
1259 ``pretxnchangegroup``
1259 ``pretxnchangegroup``
1260 Run after a changegroup has been added via push, pull or unbundle, but before
1260 Run after a changegroup has been added via push, pull or unbundle, but before
1261 the transaction has been committed. The changegroup is visible to the hook
1261 the transaction has been committed. The changegroup is visible to the hook
1262 program. This allows validation of incoming changes before accepting them.
1262 program. This allows validation of incoming changes before accepting them.
1263 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1263 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1264 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1264 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1265 status will cause the transaction to be rolled back, and the push, pull or
1265 status will cause the transaction to be rolled back, and the push, pull or
1266 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1266 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1267
1267
1268 ``pretxncommit``
1268 ``pretxncommit``
1269 Run after a changeset has been created, but before the transaction is
1269 Run after a changeset has been created, but before the transaction is
1270 committed. The changeset is visible to the hook program. This allows
1270 committed. The changeset is visible to the hook program. This allows
1271 validation of the commit message and changes. Exit status 0 allows the
1271 validation of the commit message and changes. Exit status 0 allows the
1272 commit to proceed. A non-zero status will cause the transaction to
1272 commit to proceed. A non-zero status will cause the transaction to
1273 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1273 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1274 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1274 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1275
1275
1276 ``preupdate``
1276 ``preupdate``
1277 Run before updating the working directory. Exit status 0 allows
1277 Run before updating the working directory. Exit status 0 allows
1278 the update to proceed. A non-zero status will prevent the update.
1278 the update to proceed. A non-zero status will prevent the update.
1279 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1279 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1280 merge, the ID of second new parent is in ``$HG_PARENT2``.
1280 merge, the ID of second new parent is in ``$HG_PARENT2``.
1281
1281
1282 ``listkeys``
1282 ``listkeys``
1283 Run after listing pushkeys (like bookmarks) in the repository. The
1283 Run after listing pushkeys (like bookmarks) in the repository. The
1284 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1284 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1285 dictionary containing the keys and values.
1285 dictionary containing the keys and values.
1286
1286
1287 ``pushkey``
1287 ``pushkey``
1288 Run after a pushkey (like a bookmark) is added to the
1288 Run after a pushkey (like a bookmark) is added to the
1289 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1289 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1290 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1290 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1291 value is in ``$HG_NEW``.
1291 value is in ``$HG_NEW``.
1292
1292
1293 ``tag``
1293 ``tag``
1294 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1294 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1295 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1295 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1296 the repository if ``$HG_LOCAL=0``.
1296 the repository if ``$HG_LOCAL=0``.
1297
1297
1298 ``update``
1298 ``update``
1299 Run after updating the working directory. The changeset ID of first
1299 Run after updating the working directory. The changeset ID of first
1300 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1300 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1301 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1301 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1302 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1302 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1303
1303
1304 .. note::
1304 .. note::
1305
1305
1306 It is generally better to use standard hooks rather than the
1306 It is generally better to use standard hooks rather than the
1307 generic pre- and post- command hooks, as they are guaranteed to be
1307 generic pre- and post- command hooks, as they are guaranteed to be
1308 called in the appropriate contexts for influencing transactions.
1308 called in the appropriate contexts for influencing transactions.
1309 Also, hooks like "commit" will be called in all contexts that
1309 Also, hooks like "commit" will be called in all contexts that
1310 generate a commit (e.g. tag) and not just the commit command.
1310 generate a commit (e.g. tag) and not just the commit command.
1311
1311
1312 .. note::
1312 .. note::
1313
1313
1314 Environment variables with empty values may not be passed to
1314 Environment variables with empty values may not be passed to
1315 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1315 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1316 will have an empty value under Unix-like platforms for non-merge
1316 will have an empty value under Unix-like platforms for non-merge
1317 changesets, while it will not be available at all under Windows.
1317 changesets, while it will not be available at all under Windows.
1318
1318
1319 The syntax for Python hooks is as follows::
1319 The syntax for Python hooks is as follows::
1320
1320
1321 hookname = python:modulename.submodule.callable
1321 hookname = python:modulename.submodule.callable
1322 hookname = python:/path/to/python/module.py:callable
1322 hookname = python:/path/to/python/module.py:callable
1323
1323
1324 Python hooks are run within the Mercurial process. Each hook is
1324 Python hooks are run within the Mercurial process. Each hook is
1325 called with at least three keyword arguments: a ui object (keyword
1325 called with at least three keyword arguments: a ui object (keyword
1326 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1326 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1327 keyword that tells what kind of hook is used. Arguments listed as
1327 keyword that tells what kind of hook is used. Arguments listed as
1328 environment variables above are passed as keyword arguments, with no
1328 environment variables above are passed as keyword arguments, with no
1329 ``HG_`` prefix, and names in lower case.
1329 ``HG_`` prefix, and names in lower case.
1330
1330
1331 If a Python hook returns a "true" value or raises an exception, this
1331 If a Python hook returns a "true" value or raises an exception, this
1332 is treated as a failure.
1332 is treated as a failure.
1333
1333
1334
1334
1335 ``hostfingerprints``
1335 ``hostfingerprints``
1336 --------------------
1336 --------------------
1337
1337
1338 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1338 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1339
1339
1340 Fingerprints of the certificates of known HTTPS servers.
1340 Fingerprints of the certificates of known HTTPS servers.
1341
1341
1342 A HTTPS connection to a server with a fingerprint configured here will
1342 A HTTPS connection to a server with a fingerprint configured here will
1343 only succeed if the servers certificate matches the fingerprint.
1343 only succeed if the servers certificate matches the fingerprint.
1344 This is very similar to how ssh known hosts works.
1344 This is very similar to how ssh known hosts works.
1345
1345
1346 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1346 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1347 Multiple values can be specified (separated by spaces or commas). This can
1347 Multiple values can be specified (separated by spaces or commas). This can
1348 be used to define both old and new fingerprints while a host transitions
1348 be used to define both old and new fingerprints while a host transitions
1349 to a new certificate.
1349 to a new certificate.
1350
1350
1351 The CA chain and web.cacerts is not used for servers with a fingerprint.
1351 The CA chain and web.cacerts is not used for servers with a fingerprint.
1352
1352
1353 For example::
1353 For example::
1354
1354
1355 [hostfingerprints]
1355 [hostfingerprints]
1356 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1356 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1357 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1357 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1358
1358
1359 ``hostsecurity``
1359 ``hostsecurity``
1360 ----------------
1360 ----------------
1361
1361
1362 Used to specify global and per-host security settings for connecting to
1362 Used to specify global and per-host security settings for connecting to
1363 other machines.
1363 other machines.
1364
1364
1365 The following options control default behavior for all hosts.
1365 The following options control default behavior for all hosts.
1366
1366
1367 ``ciphers``
1367 ``ciphers``
1368 Defines the cryptographic ciphers to use for connections.
1368 Defines the cryptographic ciphers to use for connections.
1369
1369
1370 Value must be a valid OpenSSL Cipher List Format as documented at
1370 Value must be a valid OpenSSL Cipher List Format as documented at
1371 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1371 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1372
1372
1373 This setting is for advanced users only. Setting to incorrect values
1373 This setting is for advanced users only. Setting to incorrect values
1374 can significantly lower connection security or decrease performance.
1374 can significantly lower connection security or decrease performance.
1375 You have been warned.
1375 You have been warned.
1376
1376
1377 This option requires Python 2.7.
1377 This option requires Python 2.7.
1378
1378
1379 ``minimumprotocol``
1379 ``minimumprotocol``
1380 Defines the minimum channel encryption protocol to use.
1380 Defines the minimum channel encryption protocol to use.
1381
1381
1382 By default, the highest version of TLS supported by both client and server
1382 By default, the highest version of TLS supported by both client and server
1383 is used.
1383 is used.
1384
1384
1385 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1385 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1386
1386
1387 When running on an old Python version, only ``tls1.0`` is allowed since
1387 When running on an old Python version, only ``tls1.0`` is allowed since
1388 old versions of Python only support up to TLS 1.0.
1388 old versions of Python only support up to TLS 1.0.
1389
1389
1390 When running a Python that supports modern TLS versions, the default is
1390 When running a Python that supports modern TLS versions, the default is
1391 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1391 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1392 weakens security and should only be used as a feature of last resort if
1392 weakens security and should only be used as a feature of last resort if
1393 a server does not support TLS 1.1+.
1393 a server does not support TLS 1.1+.
1394
1394
1395 Options in the ``[hostsecurity]`` section can have the form
1395 Options in the ``[hostsecurity]`` section can have the form
1396 ``hostname``:``setting``. This allows multiple settings to be defined on a
1396 ``hostname``:``setting``. This allows multiple settings to be defined on a
1397 per-host basis.
1397 per-host basis.
1398
1398
1399 The following per-host settings can be defined.
1399 The following per-host settings can be defined.
1400
1400
1401 ``ciphers``
1401 ``ciphers``
1402 This behaves like ``ciphers`` as described above except it only applies
1402 This behaves like ``ciphers`` as described above except it only applies
1403 to the host on which it is defined.
1403 to the host on which it is defined.
1404
1404
1405 ``fingerprints``
1405 ``fingerprints``
1406 A list of hashes of the DER encoded peer/remote certificate. Values have
1406 A list of hashes of the DER encoded peer/remote certificate. Values have
1407 the form ``algorithm``:``fingerprint``. e.g.
1407 the form ``algorithm``:``fingerprint``. e.g.
1408 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1408 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1409 In addition, colons (``:``) can appear in the fingerprint part.
1409 In addition, colons (``:``) can appear in the fingerprint part.
1410
1410
1411 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1411 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1412 ``sha512``.
1412 ``sha512``.
1413
1413
1414 Use of ``sha256`` or ``sha512`` is preferred.
1414 Use of ``sha256`` or ``sha512`` is preferred.
1415
1415
1416 If a fingerprint is specified, the CA chain is not validated for this
1416 If a fingerprint is specified, the CA chain is not validated for this
1417 host and Mercurial will require the remote certificate to match one
1417 host and Mercurial will require the remote certificate to match one
1418 of the fingerprints specified. This means if the server updates its
1418 of the fingerprints specified. This means if the server updates its
1419 certificate, Mercurial will abort until a new fingerprint is defined.
1419 certificate, Mercurial will abort until a new fingerprint is defined.
1420 This can provide stronger security than traditional CA-based validation
1420 This can provide stronger security than traditional CA-based validation
1421 at the expense of convenience.
1421 at the expense of convenience.
1422
1422
1423 This option takes precedence over ``verifycertsfile``.
1423 This option takes precedence over ``verifycertsfile``.
1424
1424
1425 ``minimumprotocol``
1425 ``minimumprotocol``
1426 This behaves like ``minimumprotocol`` as described above except it
1426 This behaves like ``minimumprotocol`` as described above except it
1427 only applies to the host on which it is defined.
1427 only applies to the host on which it is defined.
1428
1428
1429 ``verifycertsfile``
1429 ``verifycertsfile``
1430 Path to file a containing a list of PEM encoded certificates used to
1430 Path to file a containing a list of PEM encoded certificates used to
1431 verify the server certificate. Environment variables and ``~user``
1431 verify the server certificate. Environment variables and ``~user``
1432 constructs are expanded in the filename.
1432 constructs are expanded in the filename.
1433
1433
1434 The server certificate or the certificate's certificate authority (CA)
1434 The server certificate or the certificate's certificate authority (CA)
1435 must match a certificate from this file or certificate verification
1435 must match a certificate from this file or certificate verification
1436 will fail and connections to the server will be refused.
1436 will fail and connections to the server will be refused.
1437
1437
1438 If defined, only certificates provided by this file will be used:
1438 If defined, only certificates provided by this file will be used:
1439 ``web.cacerts`` and any system/default certificates will not be
1439 ``web.cacerts`` and any system/default certificates will not be
1440 used.
1440 used.
1441
1441
1442 This option has no effect if the per-host ``fingerprints`` option
1442 This option has no effect if the per-host ``fingerprints`` option
1443 is set.
1443 is set.
1444
1444
1445 The format of the file is as follows::
1445 The format of the file is as follows::
1446
1446
1447 -----BEGIN CERTIFICATE-----
1447 -----BEGIN CERTIFICATE-----
1448 ... (certificate in base64 PEM encoding) ...
1448 ... (certificate in base64 PEM encoding) ...
1449 -----END CERTIFICATE-----
1449 -----END CERTIFICATE-----
1450 -----BEGIN CERTIFICATE-----
1450 -----BEGIN CERTIFICATE-----
1451 ... (certificate in base64 PEM encoding) ...
1451 ... (certificate in base64 PEM encoding) ...
1452 -----END CERTIFICATE-----
1452 -----END CERTIFICATE-----
1453
1453
1454 For example::
1454 For example::
1455
1455
1456 [hostsecurity]
1456 [hostsecurity]
1457 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1457 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1458 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
1458 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
1459 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
1459 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
1460 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1460 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1461
1461
1462 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1462 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1463 when connecting to ``hg.example.com``::
1463 when connecting to ``hg.example.com``::
1464
1464
1465 [hostsecurity]
1465 [hostsecurity]
1466 minimumprotocol = tls1.2
1466 minimumprotocol = tls1.2
1467 hg.example.com:minimumprotocol = tls1.1
1467 hg.example.com:minimumprotocol = tls1.1
1468
1468
1469 ``http_proxy``
1469 ``http_proxy``
1470 --------------
1470 --------------
1471
1471
1472 Used to access web-based Mercurial repositories through a HTTP
1472 Used to access web-based Mercurial repositories through a HTTP
1473 proxy.
1473 proxy.
1474
1474
1475 ``host``
1475 ``host``
1476 Host name and (optional) port of the proxy server, for example
1476 Host name and (optional) port of the proxy server, for example
1477 "myproxy:8000".
1477 "myproxy:8000".
1478
1478
1479 ``no``
1479 ``no``
1480 Optional. Comma-separated list of host names that should bypass
1480 Optional. Comma-separated list of host names that should bypass
1481 the proxy.
1481 the proxy.
1482
1482
1483 ``passwd``
1483 ``passwd``
1484 Optional. Password to authenticate with at the proxy server.
1484 Optional. Password to authenticate with at the proxy server.
1485
1485
1486 ``user``
1486 ``user``
1487 Optional. User name to authenticate with at the proxy server.
1487 Optional. User name to authenticate with at the proxy server.
1488
1488
1489 ``always``
1489 ``always``
1490 Optional. Always use the proxy, even for localhost and any entries
1490 Optional. Always use the proxy, even for localhost and any entries
1491 in ``http_proxy.no``. (default: False)
1491 in ``http_proxy.no``. (default: False)
1492
1492
1493 ``http``
1493 ``http``
1494 ----------
1494 ----------
1495
1495
1496 Used to configure access to Mercurial repositories via HTTP.
1496 Used to configure access to Mercurial repositories via HTTP.
1497
1497
1498 ``timeout``
1498 ``timeout``
1499 If set, blocking operations will timeout after that many seconds.
1499 If set, blocking operations will timeout after that many seconds.
1500 (default: None)
1500 (default: None)
1501
1501
1502 ``merge``
1502 ``merge``
1503 ---------
1503 ---------
1504
1504
1505 This section specifies behavior during merges and updates.
1505 This section specifies behavior during merges and updates.
1506
1506
1507 ``checkignored``
1507 ``checkignored``
1508 Controls behavior when an ignored file on disk has the same name as a tracked
1508 Controls behavior when an ignored file on disk has the same name as a tracked
1509 file in the changeset being merged or updated to, and has different
1509 file in the changeset being merged or updated to, and has different
1510 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1510 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1511 abort on such files. With ``warn``, warn on such files and back them up as
1511 abort on such files. With ``warn``, warn on such files and back them up as
1512 ``.orig``. With ``ignore``, don't print a warning and back them up as
1512 ``.orig``. With ``ignore``, don't print a warning and back them up as
1513 ``.orig``. (default: ``abort``)
1513 ``.orig``. (default: ``abort``)
1514
1514
1515 ``checkunknown``
1515 ``checkunknown``
1516 Controls behavior when an unknown file that isn't ignored has the same name
1516 Controls behavior when an unknown file that isn't ignored has the same name
1517 as a tracked file in the changeset being merged or updated to, and has
1517 as a tracked file in the changeset being merged or updated to, and has
1518 different contents. Similar to ``merge.checkignored``, except for files that
1518 different contents. Similar to ``merge.checkignored``, except for files that
1519 are not ignored. (default: ``abort``)
1519 are not ignored. (default: ``abort``)
1520
1520
1521 ``on-failure``
1521 ``on-failure``
1522 When set to ``continue`` (the default), the merge process attempts to
1522 When set to ``continue`` (the default), the merge process attempts to
1523 merge all unresolved files using the merge chosen tool, regardless of
1523 merge all unresolved files using the merge chosen tool, regardless of
1524 whether previous file merge attempts during the process succeeded or not.
1524 whether previous file merge attempts during the process succeeded or not.
1525 Setting this to ``prompt`` will prompt after any merge failure continue
1525 Setting this to ``prompt`` will prompt after any merge failure continue
1526 or halt the merge process. Setting this to ``halt`` will automatically
1526 or halt the merge process. Setting this to ``halt`` will automatically
1527 halt the merge process on any merge tool failure. The merge process
1527 halt the merge process on any merge tool failure. The merge process
1528 can be restarted by using the ``resolve`` command. When a merge is
1528 can be restarted by using the ``resolve`` command. When a merge is
1529 halted, the repository is left in a normal ``unresolved`` merge state.
1529 halted, the repository is left in a normal ``unresolved`` merge state.
1530 (default: ``continue``)
1530 (default: ``continue``)
1531
1531
1532 ``strict-capability-check``
1532 ``strict-capability-check``
1533 Whether capabilities of internal merge tools are checked strictly
1533 Whether capabilities of internal merge tools are checked strictly
1534 or not, while examining rules to decide merge tool to be used.
1534 or not, while examining rules to decide merge tool to be used.
1535 (default: False)
1535 (default: False)
1536
1536
1537 ``merge-patterns``
1537 ``merge-patterns``
1538 ------------------
1538 ------------------
1539
1539
1540 This section specifies merge tools to associate with particular file
1540 This section specifies merge tools to associate with particular file
1541 patterns. Tools matched here will take precedence over the default
1541 patterns. Tools matched here will take precedence over the default
1542 merge tool. Patterns are globs by default, rooted at the repository
1542 merge tool. Patterns are globs by default, rooted at the repository
1543 root.
1543 root.
1544
1544
1545 Example::
1545 Example::
1546
1546
1547 [merge-patterns]
1547 [merge-patterns]
1548 **.c = kdiff3
1548 **.c = kdiff3
1549 **.jpg = myimgmerge
1549 **.jpg = myimgmerge
1550
1550
1551 ``merge-tools``
1551 ``merge-tools``
1552 ---------------
1552 ---------------
1553
1553
1554 This section configures external merge tools to use for file-level
1554 This section configures external merge tools to use for file-level
1555 merges. This section has likely been preconfigured at install time.
1555 merges. This section has likely been preconfigured at install time.
1556 Use :hg:`config merge-tools` to check the existing configuration.
1556 Use :hg:`config merge-tools` to check the existing configuration.
1557 Also see :hg:`help merge-tools` for more details.
1557 Also see :hg:`help merge-tools` for more details.
1558
1558
1559 Example ``~/.hgrc``::
1559 Example ``~/.hgrc``::
1560
1560
1561 [merge-tools]
1561 [merge-tools]
1562 # Override stock tool location
1562 # Override stock tool location
1563 kdiff3.executable = ~/bin/kdiff3
1563 kdiff3.executable = ~/bin/kdiff3
1564 # Specify command line
1564 # Specify command line
1565 kdiff3.args = $base $local $other -o $output
1565 kdiff3.args = $base $local $other -o $output
1566 # Give higher priority
1566 # Give higher priority
1567 kdiff3.priority = 1
1567 kdiff3.priority = 1
1568
1568
1569 # Changing the priority of preconfigured tool
1569 # Changing the priority of preconfigured tool
1570 meld.priority = 0
1570 meld.priority = 0
1571
1571
1572 # Disable a preconfigured tool
1572 # Disable a preconfigured tool
1573 vimdiff.disabled = yes
1573 vimdiff.disabled = yes
1574
1574
1575 # Define new tool
1575 # Define new tool
1576 myHtmlTool.args = -m $local $other $base $output
1576 myHtmlTool.args = -m $local $other $base $output
1577 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1577 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1578 myHtmlTool.priority = 1
1578 myHtmlTool.priority = 1
1579
1579
1580 Supported arguments:
1580 Supported arguments:
1581
1581
1582 ``priority``
1582 ``priority``
1583 The priority in which to evaluate this tool.
1583 The priority in which to evaluate this tool.
1584 (default: 0)
1584 (default: 0)
1585
1585
1586 ``executable``
1586 ``executable``
1587 Either just the name of the executable or its pathname.
1587 Either just the name of the executable or its pathname.
1588
1588
1589 .. container:: windows
1589 .. container:: windows
1590
1590
1591 On Windows, the path can use environment variables with ${ProgramFiles}
1591 On Windows, the path can use environment variables with ${ProgramFiles}
1592 syntax.
1592 syntax.
1593
1593
1594 (default: the tool name)
1594 (default: the tool name)
1595
1595
1596 ``args``
1596 ``args``
1597 The arguments to pass to the tool executable. You can refer to the
1597 The arguments to pass to the tool executable. You can refer to the
1598 files being merged as well as the output file through these
1598 files being merged as well as the output file through these
1599 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1599 variables: ``$base``, ``$local``, ``$other``, ``$output``.
1600
1600
1601 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1601 The meaning of ``$local`` and ``$other`` can vary depending on which action is
1602 being performed. During an update or merge, ``$local`` represents the original
1602 being performed. During an update or merge, ``$local`` represents the original
1603 state of the file, while ``$other`` represents the commit you are updating to or
1603 state of the file, while ``$other`` represents the commit you are updating to or
1604 the commit you are merging with. During a rebase, ``$local`` represents the
1604 the commit you are merging with. During a rebase, ``$local`` represents the
1605 destination of the rebase, and ``$other`` represents the commit being rebased.
1605 destination of the rebase, and ``$other`` represents the commit being rebased.
1606
1606
1607 Some operations define custom labels to assist with identifying the revisions,
1607 Some operations define custom labels to assist with identifying the revisions,
1608 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1608 accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom
1609 labels are not available, these will be ``local``, ``other``, and ``base``,
1609 labels are not available, these will be ``local``, ``other``, and ``base``,
1610 respectively.
1610 respectively.
1611 (default: ``$local $base $other``)
1611 (default: ``$local $base $other``)
1612
1612
1613 ``premerge``
1613 ``premerge``
1614 Attempt to run internal non-interactive 3-way merge tool before
1614 Attempt to run internal non-interactive 3-way merge tool before
1615 launching external tool. Options are ``true``, ``false``, ``keep``,
1615 launching external tool. Options are ``true``, ``false``, ``keep``,
1616 ``keep-merge3``, or ``keep-mergediff`` (experimental). The ``keep`` option
1616 ``keep-merge3``, or ``keep-mergediff`` (experimental). The ``keep`` option
1617 will leave markers in the file if the premerge fails. The ``keep-merge3``
1617 will leave markers in the file if the premerge fails. The ``keep-merge3``
1618 will do the same but include information about the base of the merge in the
1618 will do the same but include information about the base of the merge in the
1619 marker (see internal :merge3 in :hg:`help merge-tools`). The
1619 marker (see internal :merge3 in :hg:`help merge-tools`). The
1620 ``keep-mergediff`` option is similar but uses a different marker style
1620 ``keep-mergediff`` option is similar but uses a different marker style
1621 (see internal :merge3 in :hg:`help merge-tools`). (default: True)
1621 (see internal :merge3 in :hg:`help merge-tools`). (default: True)
1622
1622
1623 ``binary``
1623 ``binary``
1624 This tool can merge binary files. (default: False, unless tool
1624 This tool can merge binary files. (default: False, unless tool
1625 was selected by file pattern match)
1625 was selected by file pattern match)
1626
1626
1627 ``symlink``
1627 ``symlink``
1628 This tool can merge symlinks. (default: False)
1628 This tool can merge symlinks. (default: False)
1629
1629
1630 ``check``
1630 ``check``
1631 A list of merge success-checking options:
1631 A list of merge success-checking options:
1632
1632
1633 ``changed``
1633 ``changed``
1634 Ask whether merge was successful when the merged file shows no changes.
1634 Ask whether merge was successful when the merged file shows no changes.
1635 ``conflicts``
1635 ``conflicts``
1636 Check whether there are conflicts even though the tool reported success.
1636 Check whether there are conflicts even though the tool reported success.
1637 ``prompt``
1637 ``prompt``
1638 Always prompt for merge success, regardless of success reported by tool.
1638 Always prompt for merge success, regardless of success reported by tool.
1639
1639
1640 ``fixeol``
1640 ``fixeol``
1641 Attempt to fix up EOL changes caused by the merge tool.
1641 Attempt to fix up EOL changes caused by the merge tool.
1642 (default: False)
1642 (default: False)
1643
1643
1644 ``gui``
1644 ``gui``
1645 This tool requires a graphical interface to run. (default: False)
1645 This tool requires a graphical interface to run. (default: False)
1646
1646
1647 ``mergemarkers``
1647 ``mergemarkers``
1648 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1648 Controls whether the labels passed via ``$labellocal``, ``$labelother``, and
1649 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1649 ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or
1650 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1650 ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict
1651 markers generated during premerge will be ``detailed`` if either this option or
1651 markers generated during premerge will be ``detailed`` if either this option or
1652 the corresponding option in the ``[ui]`` section is ``detailed``.
1652 the corresponding option in the ``[ui]`` section is ``detailed``.
1653 (default: ``basic``)
1653 (default: ``basic``)
1654
1654
1655 ``mergemarkertemplate``
1655 ``mergemarkertemplate``
1656 This setting can be used to override ``mergemarker`` from the
1656 This setting can be used to override ``mergemarker`` from the
1657 ``[command-templates]`` section on a per-tool basis; this applies to the
1657 ``[command-templates]`` section on a per-tool basis; this applies to the
1658 ``$label``-prefixed variables and to the conflict markers that are generated
1658 ``$label``-prefixed variables and to the conflict markers that are generated
1659 if ``premerge`` is ``keep` or ``keep-merge3``. See the corresponding variable
1659 if ``premerge`` is ``keep` or ``keep-merge3``. See the corresponding variable
1660 in ``[ui]`` for more information.
1660 in ``[ui]`` for more information.
1661
1661
1662 .. container:: windows
1662 .. container:: windows
1663
1663
1664 ``regkey``
1664 ``regkey``
1665 Windows registry key which describes install location of this
1665 Windows registry key which describes install location of this
1666 tool. Mercurial will search for this key first under
1666 tool. Mercurial will search for this key first under
1667 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1667 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1668 (default: None)
1668 (default: None)
1669
1669
1670 ``regkeyalt``
1670 ``regkeyalt``
1671 An alternate Windows registry key to try if the first key is not
1671 An alternate Windows registry key to try if the first key is not
1672 found. The alternate key uses the same ``regname`` and ``regappend``
1672 found. The alternate key uses the same ``regname`` and ``regappend``
1673 semantics of the primary key. The most common use for this key
1673 semantics of the primary key. The most common use for this key
1674 is to search for 32bit applications on 64bit operating systems.
1674 is to search for 32bit applications on 64bit operating systems.
1675 (default: None)
1675 (default: None)
1676
1676
1677 ``regname``
1677 ``regname``
1678 Name of value to read from specified registry key.
1678 Name of value to read from specified registry key.
1679 (default: the unnamed (default) value)
1679 (default: the unnamed (default) value)
1680
1680
1681 ``regappend``
1681 ``regappend``
1682 String to append to the value read from the registry, typically
1682 String to append to the value read from the registry, typically
1683 the executable name of the tool.
1683 the executable name of the tool.
1684 (default: None)
1684 (default: None)
1685
1685
1686 ``pager``
1686 ``pager``
1687 ---------
1687 ---------
1688
1688
1689 Setting used to control when to paginate and with what external tool. See
1689 Setting used to control when to paginate and with what external tool. See
1690 :hg:`help pager` for details.
1690 :hg:`help pager` for details.
1691
1691
1692 ``pager``
1692 ``pager``
1693 Define the external tool used as pager.
1693 Define the external tool used as pager.
1694
1694
1695 If no pager is set, Mercurial uses the environment variable $PAGER.
1695 If no pager is set, Mercurial uses the environment variable $PAGER.
1696 If neither pager.pager, nor $PAGER is set, a default pager will be
1696 If neither pager.pager, nor $PAGER is set, a default pager will be
1697 used, typically `less` on Unix and `more` on Windows. Example::
1697 used, typically `less` on Unix and `more` on Windows. Example::
1698
1698
1699 [pager]
1699 [pager]
1700 pager = less -FRX
1700 pager = less -FRX
1701
1701
1702 ``ignore``
1702 ``ignore``
1703 List of commands to disable the pager for. Example::
1703 List of commands to disable the pager for. Example::
1704
1704
1705 [pager]
1705 [pager]
1706 ignore = version, help, update
1706 ignore = version, help, update
1707
1707
1708 ``patch``
1708 ``patch``
1709 ---------
1709 ---------
1710
1710
1711 Settings used when applying patches, for instance through the 'import'
1711 Settings used when applying patches, for instance through the 'import'
1712 command or with Mercurial Queues extension.
1712 command or with Mercurial Queues extension.
1713
1713
1714 ``eol``
1714 ``eol``
1715 When set to 'strict' patch content and patched files end of lines
1715 When set to 'strict' patch content and patched files end of lines
1716 are preserved. When set to ``lf`` or ``crlf``, both files end of
1716 are preserved. When set to ``lf`` or ``crlf``, both files end of
1717 lines are ignored when patching and the result line endings are
1717 lines are ignored when patching and the result line endings are
1718 normalized to either LF (Unix) or CRLF (Windows). When set to
1718 normalized to either LF (Unix) or CRLF (Windows). When set to
1719 ``auto``, end of lines are again ignored while patching but line
1719 ``auto``, end of lines are again ignored while patching but line
1720 endings in patched files are normalized to their original setting
1720 endings in patched files are normalized to their original setting
1721 on a per-file basis. If target file does not exist or has no end
1721 on a per-file basis. If target file does not exist or has no end
1722 of line, patch line endings are preserved.
1722 of line, patch line endings are preserved.
1723 (default: strict)
1723 (default: strict)
1724
1724
1725 ``fuzz``
1725 ``fuzz``
1726 The number of lines of 'fuzz' to allow when applying patches. This
1726 The number of lines of 'fuzz' to allow when applying patches. This
1727 controls how much context the patcher is allowed to ignore when
1727 controls how much context the patcher is allowed to ignore when
1728 trying to apply a patch.
1728 trying to apply a patch.
1729 (default: 2)
1729 (default: 2)
1730
1730
1731 ``paths``
1731 ``paths``
1732 ---------
1732 ---------
1733
1733
1734 Assigns symbolic names and behavior to repositories.
1734 Assigns symbolic names and behavior to repositories.
1735
1735
1736 Options are symbolic names defining the URL or directory that is the
1736 Options are symbolic names defining the URL or directory that is the
1737 location of the repository. Example::
1737 location of the repository. Example::
1738
1738
1739 [paths]
1739 [paths]
1740 my_server = https://example.com/my_repo
1740 my_server = https://example.com/my_repo
1741 local_path = /home/me/repo
1741 local_path = /home/me/repo
1742
1742
1743 These symbolic names can be used from the command line. To pull
1743 These symbolic names can be used from the command line. To pull
1744 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1744 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1745 :hg:`push local_path`. You can check :hg:`help urls` for details about
1745 :hg:`push local_path`. You can check :hg:`help urls` for details about
1746 valid URLs.
1746 valid URLs.
1747
1747
1748 Options containing colons (``:``) denote sub-options that can influence
1748 Options containing colons (``:``) denote sub-options that can influence
1749 behavior for that specific path. Example::
1749 behavior for that specific path. Example::
1750
1750
1751 [paths]
1751 [paths]
1752 my_server = https://example.com/my_path
1752 my_server = https://example.com/my_path
1753 my_server:pushurl = ssh://example.com/my_path
1753 my_server:pushurl = ssh://example.com/my_path
1754
1754
1755 Paths using the `path://otherpath` scheme will inherit the sub-options value from
1755 Paths using the `path://otherpath` scheme will inherit the sub-options value from
1756 the path they point to.
1756 the path they point to.
1757
1757
1758 The following sub-options can be defined:
1758 The following sub-options can be defined:
1759
1759
1760 ``multi-urls``
1760 ``multi-urls``
1761 A boolean option. When enabled the value of the `[paths]` entry will be
1761 A boolean option. When enabled the value of the `[paths]` entry will be
1762 parsed as a list and the alias will resolve to multiple destination. If some
1762 parsed as a list and the alias will resolve to multiple destination. If some
1763 of the list entry use the `path://` syntax, the suboption will be inherited
1763 of the list entry use the `path://` syntax, the suboption will be inherited
1764 individually.
1764 individually.
1765
1765
1766 ``pushurl``
1766 ``pushurl``
1767 The URL to use for push operations. If not defined, the location
1767 The URL to use for push operations. If not defined, the location
1768 defined by the path's main entry is used.
1768 defined by the path's main entry is used.
1769
1769
1770 ``pushrev``
1770 ``pushrev``
1771 A revset defining which revisions to push by default.
1771 A revset defining which revisions to push by default.
1772
1772
1773 When :hg:`push` is executed without a ``-r`` argument, the revset
1773 When :hg:`push` is executed without a ``-r`` argument, the revset
1774 defined by this sub-option is evaluated to determine what to push.
1774 defined by this sub-option is evaluated to determine what to push.
1775
1775
1776 For example, a value of ``.`` will push the working directory's
1776 For example, a value of ``.`` will push the working directory's
1777 revision by default.
1777 revision by default.
1778
1778
1779 Revsets specifying bookmarks will not result in the bookmark being
1779 Revsets specifying bookmarks will not result in the bookmark being
1780 pushed.
1780 pushed.
1781
1781
1782 ``bookmarks.mode``
1782 ``bookmarks.mode``
1783 How bookmark will be dealt during the exchange. It support the following value
1783 How bookmark will be dealt during the exchange. It support the following value
1784
1784
1785 - ``default``: the default behavior, local and remote bookmarks are "merged"
1785 - ``default``: the default behavior, local and remote bookmarks are "merged"
1786 on push/pull.
1786 on push/pull.
1787
1787
1788 - ``mirror``: when pulling, replace local bookmarks by remote bookmarks. This
1788 - ``mirror``: when pulling, replace local bookmarks by remote bookmarks. This
1789 is useful to replicate a repository, or as an optimization.
1789 is useful to replicate a repository, or as an optimization.
1790
1790
1791 - ``ignore``: ignore bookmarks during exchange.
1791 - ``ignore``: ignore bookmarks during exchange.
1792 (This currently only affect pulling)
1792 (This currently only affect pulling)
1793
1793
1794 The following special named paths exist:
1794 The following special named paths exist:
1795
1795
1796 ``default``
1796 ``default``
1797 The URL or directory to use when no source or remote is specified.
1797 The URL or directory to use when no source or remote is specified.
1798
1798
1799 :hg:`clone` will automatically define this path to the location the
1799 :hg:`clone` will automatically define this path to the location the
1800 repository was cloned from.
1800 repository was cloned from.
1801
1801
1802 ``default-push``
1802 ``default-push``
1803 (deprecated) The URL or directory for the default :hg:`push` location.
1803 (deprecated) The URL or directory for the default :hg:`push` location.
1804 ``default:pushurl`` should be used instead.
1804 ``default:pushurl`` should be used instead.
1805
1805
1806 ``phases``
1806 ``phases``
1807 ----------
1807 ----------
1808
1808
1809 Specifies default handling of phases. See :hg:`help phases` for more
1809 Specifies default handling of phases. See :hg:`help phases` for more
1810 information about working with phases.
1810 information about working with phases.
1811
1811
1812 ``publish``
1812 ``publish``
1813 Controls draft phase behavior when working as a server. When true,
1813 Controls draft phase behavior when working as a server. When true,
1814 pushed changesets are set to public in both client and server and
1814 pushed changesets are set to public in both client and server and
1815 pulled or cloned changesets are set to public in the client.
1815 pulled or cloned changesets are set to public in the client.
1816 (default: True)
1816 (default: True)
1817
1817
1818 ``new-commit``
1818 ``new-commit``
1819 Phase of newly-created commits.
1819 Phase of newly-created commits.
1820 (default: draft)
1820 (default: draft)
1821
1821
1822 ``checksubrepos``
1822 ``checksubrepos``
1823 Check the phase of the current revision of each subrepository. Allowed
1823 Check the phase of the current revision of each subrepository. Allowed
1824 values are "ignore", "follow" and "abort". For settings other than
1824 values are "ignore", "follow" and "abort". For settings other than
1825 "ignore", the phase of the current revision of each subrepository is
1825 "ignore", the phase of the current revision of each subrepository is
1826 checked before committing the parent repository. If any of those phases is
1826 checked before committing the parent repository. If any of those phases is
1827 greater than the phase of the parent repository (e.g. if a subrepo is in a
1827 greater than the phase of the parent repository (e.g. if a subrepo is in a
1828 "secret" phase while the parent repo is in "draft" phase), the commit is
1828 "secret" phase while the parent repo is in "draft" phase), the commit is
1829 either aborted (if checksubrepos is set to "abort") or the higher phase is
1829 either aborted (if checksubrepos is set to "abort") or the higher phase is
1830 used for the parent repository commit (if set to "follow").
1830 used for the parent repository commit (if set to "follow").
1831 (default: follow)
1831 (default: follow)
1832
1832
1833
1833
1834 ``profiling``
1834 ``profiling``
1835 -------------
1835 -------------
1836
1836
1837 Specifies profiling type, format, and file output. Two profilers are
1837 Specifies profiling type, format, and file output. Two profilers are
1838 supported: an instrumenting profiler (named ``ls``), and a sampling
1838 supported: an instrumenting profiler (named ``ls``), and a sampling
1839 profiler (named ``stat``).
1839 profiler (named ``stat``).
1840
1840
1841 In this section description, 'profiling data' stands for the raw data
1841 In this section description, 'profiling data' stands for the raw data
1842 collected during profiling, while 'profiling report' stands for a
1842 collected during profiling, while 'profiling report' stands for a
1843 statistical text report generated from the profiling data.
1843 statistical text report generated from the profiling data.
1844
1844
1845 ``enabled``
1845 ``enabled``
1846 Enable the profiler.
1846 Enable the profiler.
1847 (default: false)
1847 (default: false)
1848
1848
1849 This is equivalent to passing ``--profile`` on the command line.
1849 This is equivalent to passing ``--profile`` on the command line.
1850
1850
1851 ``type``
1851 ``type``
1852 The type of profiler to use.
1852 The type of profiler to use.
1853 (default: stat)
1853 (default: stat)
1854
1854
1855 ``ls``
1855 ``ls``
1856 Use Python's built-in instrumenting profiler. This profiler
1856 Use Python's built-in instrumenting profiler. This profiler
1857 works on all platforms, but each line number it reports is the
1857 works on all platforms, but each line number it reports is the
1858 first line of a function. This restriction makes it difficult to
1858 first line of a function. This restriction makes it difficult to
1859 identify the expensive parts of a non-trivial function.
1859 identify the expensive parts of a non-trivial function.
1860 ``stat``
1860 ``stat``
1861 Use a statistical profiler, statprof. This profiler is most
1861 Use a statistical profiler, statprof. This profiler is most
1862 useful for profiling commands that run for longer than about 0.1
1862 useful for profiling commands that run for longer than about 0.1
1863 seconds.
1863 seconds.
1864
1864
1865 ``format``
1865 ``format``
1866 Profiling format. Specific to the ``ls`` instrumenting profiler.
1866 Profiling format. Specific to the ``ls`` instrumenting profiler.
1867 (default: text)
1867 (default: text)
1868
1868
1869 ``text``
1869 ``text``
1870 Generate a profiling report. When saving to a file, it should be
1870 Generate a profiling report. When saving to a file, it should be
1871 noted that only the report is saved, and the profiling data is
1871 noted that only the report is saved, and the profiling data is
1872 not kept.
1872 not kept.
1873 ``kcachegrind``
1873 ``kcachegrind``
1874 Format profiling data for kcachegrind use: when saving to a
1874 Format profiling data for kcachegrind use: when saving to a
1875 file, the generated file can directly be loaded into
1875 file, the generated file can directly be loaded into
1876 kcachegrind.
1876 kcachegrind.
1877
1877
1878 ``statformat``
1878 ``statformat``
1879 Profiling format for the ``stat`` profiler.
1879 Profiling format for the ``stat`` profiler.
1880 (default: hotpath)
1880 (default: hotpath)
1881
1881
1882 ``hotpath``
1882 ``hotpath``
1883 Show a tree-based display containing the hot path of execution (where
1883 Show a tree-based display containing the hot path of execution (where
1884 most time was spent).
1884 most time was spent).
1885 ``bymethod``
1885 ``bymethod``
1886 Show a table of methods ordered by how frequently they are active.
1886 Show a table of methods ordered by how frequently they are active.
1887 ``byline``
1887 ``byline``
1888 Show a table of lines in files ordered by how frequently they are active.
1888 Show a table of lines in files ordered by how frequently they are active.
1889 ``json``
1889 ``json``
1890 Render profiling data as JSON.
1890 Render profiling data as JSON.
1891
1891
1892 ``freq``
1892 ``freq``
1893 Sampling frequency. Specific to the ``stat`` sampling profiler.
1893 Sampling frequency. Specific to the ``stat`` sampling profiler.
1894 (default: 1000)
1894 (default: 1000)
1895
1895
1896 ``output``
1896 ``output``
1897 File path where profiling data or report should be saved. If the
1897 File path where profiling data or report should be saved. If the
1898 file exists, it is replaced. (default: None, data is printed on
1898 file exists, it is replaced. (default: None, data is printed on
1899 stderr)
1899 stderr)
1900
1900
1901 ``sort``
1901 ``sort``
1902 Sort field. Specific to the ``ls`` instrumenting profiler.
1902 Sort field. Specific to the ``ls`` instrumenting profiler.
1903 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1903 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1904 ``inlinetime``.
1904 ``inlinetime``.
1905 (default: inlinetime)
1905 (default: inlinetime)
1906
1906
1907 ``time-track``
1907 ``time-track``
1908 Control if the stat profiler track ``cpu`` or ``real`` time.
1908 Control if the stat profiler track ``cpu`` or ``real`` time.
1909 (default: ``cpu`` on Windows, otherwise ``real``)
1909 (default: ``cpu`` on Windows, otherwise ``real``)
1910
1910
1911 ``limit``
1911 ``limit``
1912 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1912 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1913 (default: 30)
1913 (default: 30)
1914
1914
1915 ``nested``
1915 ``nested``
1916 Show at most this number of lines of drill-down info after each main entry.
1916 Show at most this number of lines of drill-down info after each main entry.
1917 This can help explain the difference between Total and Inline.
1917 This can help explain the difference between Total and Inline.
1918 Specific to the ``ls`` instrumenting profiler.
1918 Specific to the ``ls`` instrumenting profiler.
1919 (default: 0)
1919 (default: 0)
1920
1920
1921 ``showmin``
1921 ``showmin``
1922 Minimum fraction of samples an entry must have for it to be displayed.
1922 Minimum fraction of samples an entry must have for it to be displayed.
1923 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1923 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1924 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1924 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1925
1925
1926 Only used by the ``stat`` profiler.
1926 Only used by the ``stat`` profiler.
1927
1927
1928 For the ``hotpath`` format, default is ``0.05``.
1928 For the ``hotpath`` format, default is ``0.05``.
1929 For the ``chrome`` format, default is ``0.005``.
1929 For the ``chrome`` format, default is ``0.005``.
1930
1930
1931 The option is unused on other formats.
1931 The option is unused on other formats.
1932
1932
1933 ``showmax``
1933 ``showmax``
1934 Maximum fraction of samples an entry can have before it is ignored in
1934 Maximum fraction of samples an entry can have before it is ignored in
1935 display. Values format is the same as ``showmin``.
1935 display. Values format is the same as ``showmin``.
1936
1936
1937 Only used by the ``stat`` profiler.
1937 Only used by the ``stat`` profiler.
1938
1938
1939 For the ``chrome`` format, default is ``0.999``.
1939 For the ``chrome`` format, default is ``0.999``.
1940
1940
1941 The option is unused on other formats.
1941 The option is unused on other formats.
1942
1942
1943 ``showtime``
1943 ``showtime``
1944 Show time taken as absolute durations, in addition to percentages.
1944 Show time taken as absolute durations, in addition to percentages.
1945 Only used by the ``hotpath`` format.
1945 Only used by the ``hotpath`` format.
1946 (default: true)
1946 (default: true)
1947
1947
1948 ``progress``
1948 ``progress``
1949 ------------
1949 ------------
1950
1950
1951 Mercurial commands can draw progress bars that are as informative as
1951 Mercurial commands can draw progress bars that are as informative as
1952 possible. Some progress bars only offer indeterminate information, while others
1952 possible. Some progress bars only offer indeterminate information, while others
1953 have a definite end point.
1953 have a definite end point.
1954
1954
1955 ``debug``
1955 ``debug``
1956 Whether to print debug info when updating the progress bar. (default: False)
1956 Whether to print debug info when updating the progress bar. (default: False)
1957
1957
1958 ``delay``
1958 ``delay``
1959 Number of seconds (float) before showing the progress bar. (default: 3)
1959 Number of seconds (float) before showing the progress bar. (default: 3)
1960
1960
1961 ``changedelay``
1961 ``changedelay``
1962 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1962 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1963 that value will be used instead. (default: 1)
1963 that value will be used instead. (default: 1)
1964
1964
1965 ``estimateinterval``
1965 ``estimateinterval``
1966 Maximum sampling interval in seconds for speed and estimated time
1966 Maximum sampling interval in seconds for speed and estimated time
1967 calculation. (default: 60)
1967 calculation. (default: 60)
1968
1968
1969 ``refresh``
1969 ``refresh``
1970 Time in seconds between refreshes of the progress bar. (default: 0.1)
1970 Time in seconds between refreshes of the progress bar. (default: 0.1)
1971
1971
1972 ``format``
1972 ``format``
1973 Format of the progress bar.
1973 Format of the progress bar.
1974
1974
1975 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1975 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1976 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1976 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1977 last 20 characters of the item, but this can be changed by adding either
1977 last 20 characters of the item, but this can be changed by adding either
1978 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1978 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1979 first num characters.
1979 first num characters.
1980
1980
1981 (default: topic bar number estimate)
1981 (default: topic bar number estimate)
1982
1982
1983 ``width``
1983 ``width``
1984 If set, the maximum width of the progress information (that is, min(width,
1984 If set, the maximum width of the progress information (that is, min(width,
1985 term width) will be used).
1985 term width) will be used).
1986
1986
1987 ``clear-complete``
1987 ``clear-complete``
1988 Clear the progress bar after it's done. (default: True)
1988 Clear the progress bar after it's done. (default: True)
1989
1989
1990 ``disable``
1990 ``disable``
1991 If true, don't show a progress bar.
1991 If true, don't show a progress bar.
1992
1992
1993 ``assume-tty``
1993 ``assume-tty``
1994 If true, ALWAYS show a progress bar, unless disable is given.
1994 If true, ALWAYS show a progress bar, unless disable is given.
1995
1995
1996 ``rebase``
1996 ``rebase``
1997 ----------
1997 ----------
1998
1998
1999 ``evolution.allowdivergence``
1999 ``evolution.allowdivergence``
2000 Default to False, when True allow creating divergence when performing
2000 Default to False, when True allow creating divergence when performing
2001 rebase of obsolete changesets.
2001 rebase of obsolete changesets.
2002
2002
2003 ``revsetalias``
2003 ``revsetalias``
2004 ---------------
2004 ---------------
2005
2005
2006 Alias definitions for revsets. See :hg:`help revsets` for details.
2006 Alias definitions for revsets. See :hg:`help revsets` for details.
2007
2007
2008 ``rewrite``
2008 ``rewrite``
2009 -----------
2009 -----------
2010
2010
2011 ``backup-bundle``
2011 ``backup-bundle``
2012 Whether to save stripped changesets to a bundle file. (default: True)
2012 Whether to save stripped changesets to a bundle file. (default: True)
2013
2013
2014 ``update-timestamp``
2014 ``update-timestamp``
2015 If true, updates the date and time of the changeset to current. It is only
2015 If true, updates the date and time of the changeset to current. It is only
2016 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
2016 applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the
2017 current version.
2017 current version.
2018
2018
2019 ``empty-successor``
2019 ``empty-successor``
2020
2020
2021 Control what happens with empty successors that are the result of rewrite
2021 Control what happens with empty successors that are the result of rewrite
2022 operations. If set to ``skip``, the successor is not created. If set to
2022 operations. If set to ``skip``, the successor is not created. If set to
2023 ``keep``, the empty successor is created and kept.
2023 ``keep``, the empty successor is created and kept.
2024
2024
2025 Currently, only the rebase and absorb commands consider this configuration.
2025 Currently, only the rebase and absorb commands consider this configuration.
2026 (EXPERIMENTAL)
2026 (EXPERIMENTAL)
2027
2027
2028 ``share``
2028 ``share``
2029 ---------
2029 ---------
2030
2030
2031 ``safe-mismatch.source-safe``
2031 ``safe-mismatch.source-safe``
2032
2032
2033 Controls what happens when the shared repository does not use the
2033 Controls what happens when the shared repository does not use the
2034 share-safe mechanism but its source repository does.
2034 share-safe mechanism but its source repository does.
2035
2035
2036 Possible values are `abort` (default), `allow`, `upgrade-abort` and
2036 Possible values are `abort` (default), `allow`, `upgrade-abort` and
2037 `upgrade-abort`.
2037 `upgrade-abort`.
2038
2038
2039 ``abort``
2039 ``abort``
2040 Disallows running any command and aborts
2040 Disallows running any command and aborts
2041 ``allow``
2041 ``allow``
2042 Respects the feature presence in the share source
2042 Respects the feature presence in the share source
2043 ``upgrade-abort``
2043 ``upgrade-abort``
2044 tries to upgrade the share to use share-safe; if it fails, aborts
2044 tries to upgrade the share to use share-safe; if it fails, aborts
2045 ``upgrade-allow``
2045 ``upgrade-allow``
2046 tries to upgrade the share; if it fails, continue by
2046 tries to upgrade the share; if it fails, continue by
2047 respecting the share source setting
2047 respecting the share source setting
2048
2048
2049 Check :hg:`help config format.use-share-safe` for details about the
2049 Check :hg:`help config format.use-share-safe` for details about the
2050 share-safe feature.
2050 share-safe feature.
2051
2051
2052 ``safe-mismatch.source-safe.warn``
2052 ``safe-mismatch.source-safe.warn``
2053 Shows a warning on operations if the shared repository does not use
2053 Shows a warning on operations if the shared repository does not use
2054 share-safe, but the source repository does.
2054 share-safe, but the source repository does.
2055 (default: True)
2055 (default: True)
2056
2056
2057 ``safe-mismatch.source-not-safe``
2057 ``safe-mismatch.source-not-safe``
2058
2058
2059 Controls what happens when the shared repository uses the share-safe
2059 Controls what happens when the shared repository uses the share-safe
2060 mechanism but its source does not.
2060 mechanism but its source does not.
2061
2061
2062 Possible values are `abort` (default), `allow`, `downgrade-abort` and
2062 Possible values are `abort` (default), `allow`, `downgrade-abort` and
2063 `downgrade-abort`.
2063 `downgrade-abort`.
2064
2064
2065 ``abort``
2065 ``abort``
2066 Disallows running any command and aborts
2066 Disallows running any command and aborts
2067 ``allow``
2067 ``allow``
2068 Respects the feature presence in the share source
2068 Respects the feature presence in the share source
2069 ``downgrade-abort``
2069 ``downgrade-abort``
2070 tries to downgrade the share to not use share-safe; if it fails, aborts
2070 tries to downgrade the share to not use share-safe; if it fails, aborts
2071 ``downgrade-allow``
2071 ``downgrade-allow``
2072 tries to downgrade the share to not use share-safe;
2072 tries to downgrade the share to not use share-safe;
2073 if it fails, continue by respecting the shared source setting
2073 if it fails, continue by respecting the shared source setting
2074
2074
2075 Check :hg:`help config format.use-share-safe` for details about the
2075 Check :hg:`help config format.use-share-safe` for details about the
2076 share-safe feature.
2076 share-safe feature.
2077
2077
2078 ``safe-mismatch.source-not-safe.warn``
2078 ``safe-mismatch.source-not-safe.warn``
2079 Shows a warning on operations if the shared repository uses share-safe,
2079 Shows a warning on operations if the shared repository uses share-safe,
2080 but the source repository does not.
2080 but the source repository does not.
2081 (default: True)
2081 (default: True)
2082
2082
2083 ``storage``
2083 ``storage``
2084 -----------
2084 -----------
2085
2085
2086 Control the strategy Mercurial uses internally to store history. Options in this
2086 Control the strategy Mercurial uses internally to store history. Options in this
2087 category impact performance and repository size.
2087 category impact performance and repository size.
2088
2088
2089 ``revlog.issue6528.fix-incoming``
2089 ``revlog.issue6528.fix-incoming``
2090 Version 5.8 of Mercurial had a bug leading to altering the parent of file
2090 Version 5.8 of Mercurial had a bug leading to altering the parent of file
2091 revision with copy information (or any other metadata) on exchange. This
2091 revision with copy information (or any other metadata) on exchange. This
2092 leads to the copy metadata to be overlooked by various internal logic. The
2092 leads to the copy metadata to be overlooked by various internal logic. The
2093 issue was fixed in Mercurial 5.8.1.
2093 issue was fixed in Mercurial 5.8.1.
2094 (See https://bz.mercurial-scm.org/show_bug.cgi?id=6528 for details)
2094 (See https://bz.mercurial-scm.org/show_bug.cgi?id=6528 for details)
2095
2095
2096 As a result Mercurial is now checking and fixing incoming file revisions to
2096 As a result Mercurial is now checking and fixing incoming file revisions to
2097 make sure there parents are in the right order. This behavior can be
2097 make sure there parents are in the right order. This behavior can be
2098 disabled by setting this option to `no`. This apply to revisions added
2098 disabled by setting this option to `no`. This apply to revisions added
2099 through push, pull, clone and unbundle.
2099 through push, pull, clone and unbundle.
2100
2100
2101 To fix affected revisions that already exist within the repository, one can
2101 To fix affected revisions that already exist within the repository, one can
2102 use :hg:`debug-repair-issue-6528`.
2102 use :hg:`debug-repair-issue-6528`.
2103
2103
2104 ``revlog.optimize-delta-parent-choice``
2104 ``revlog.optimize-delta-parent-choice``
2105 When storing a merge revision, both parents will be equally considered as
2105 When storing a merge revision, both parents will be equally considered as
2106 a possible delta base. This results in better delta selection and improved
2106 a possible delta base. This results in better delta selection and improved
2107 revlog compression. This option is enabled by default.
2107 revlog compression. This option is enabled by default.
2108
2108
2109 Turning this option off can result in large increase of repository size for
2109 Turning this option off can result in large increase of repository size for
2110 repository with many merges.
2110 repository with many merges.
2111
2111
2112 ``revlog.persistent-nodemap.mmap``
2112 ``revlog.persistent-nodemap.mmap``
2113 Whether to use the Operating System "memory mapping" feature (when
2113 Whether to use the Operating System "memory mapping" feature (when
2114 possible) to access the persistent nodemap data. This improve performance
2114 possible) to access the persistent nodemap data. This improve performance
2115 and reduce memory pressure.
2115 and reduce memory pressure.
2116
2116
2117 Default to True.
2117 Default to True.
2118
2118
2119 For details on the "persistent-nodemap" feature, see:
2119 For details on the "persistent-nodemap" feature, see:
2120 :hg:`help config format.use-persistent-nodemap`.
2120 :hg:`help config format.use-persistent-nodemap`.
2121
2121
2122 ``revlog.persistent-nodemap.slow-path``
2122 ``revlog.persistent-nodemap.slow-path``
2123 Control the behavior of Merucrial when using a repository with "persistent"
2123 Control the behavior of Merucrial when using a repository with "persistent"
2124 nodemap with an installation of Mercurial without a fast implementation for
2124 nodemap with an installation of Mercurial without a fast implementation for
2125 the feature:
2125 the feature:
2126
2126
2127 ``allow``: Silently use the slower implementation to access the repository.
2127 ``allow``: Silently use the slower implementation to access the repository.
2128 ``warn``: Warn, but use the slower implementation to access the repository.
2128 ``warn``: Warn, but use the slower implementation to access the repository.
2129 ``abort``: Prevent access to such repositories. (This is the default)
2129 ``abort``: Prevent access to such repositories. (This is the default)
2130
2130
2131 For details on the "persistent-nodemap" feature, see:
2131 For details on the "persistent-nodemap" feature, see:
2132 :hg:`help config format.use-persistent-nodemap`.
2132 :hg:`help config format.use-persistent-nodemap`.
2133
2133
2134 ``revlog.reuse-external-delta-parent``
2134 ``revlog.reuse-external-delta-parent``
2135 Control the order in which delta parents are considered when adding new
2135 Control the order in which delta parents are considered when adding new
2136 revisions from an external source.
2136 revisions from an external source.
2137 (typically: apply bundle from `hg pull` or `hg push`).
2137 (typically: apply bundle from `hg pull` or `hg push`).
2138
2138
2139 New revisions are usually provided as a delta against other revisions. By
2139 New revisions are usually provided as a delta against other revisions. By
2140 default, Mercurial will try to reuse this delta first, therefore using the
2140 default, Mercurial will try to reuse this delta first, therefore using the
2141 same "delta parent" as the source. Directly using delta's from the source
2141 same "delta parent" as the source. Directly using delta's from the source
2142 reduces CPU usage and usually speeds up operation. However, in some case,
2142 reduces CPU usage and usually speeds up operation. However, in some case,
2143 the source might have sub-optimal delta bases and forcing their reevaluation
2143 the source might have sub-optimal delta bases and forcing their reevaluation
2144 is useful. For example, pushes from an old client could have sub-optimal
2144 is useful. For example, pushes from an old client could have sub-optimal
2145 delta's parent that the server want to optimize. (lack of general delta, bad
2145 delta's parent that the server want to optimize. (lack of general delta, bad
2146 parents, choice, lack of sparse-revlog, etc).
2146 parents, choice, lack of sparse-revlog, etc).
2147
2147
2148 This option is enabled by default. Turning it off will ensure bad delta
2148 This option is enabled by default. Turning it off will ensure bad delta
2149 parent choices from older client do not propagate to this repository, at
2149 parent choices from older client do not propagate to this repository, at
2150 the cost of a small increase in CPU consumption.
2150 the cost of a small increase in CPU consumption.
2151
2151
2152 Note: this option only control the order in which delta parents are
2152 Note: this option only control the order in which delta parents are
2153 considered. Even when disabled, the existing delta from the source will be
2153 considered. Even when disabled, the existing delta from the source will be
2154 reused if the same delta parent is selected.
2154 reused if the same delta parent is selected.
2155
2155
2156 ``revlog.reuse-external-delta``
2156 ``revlog.reuse-external-delta``
2157 Control the reuse of delta from external source.
2157 Control the reuse of delta from external source.
2158 (typically: apply bundle from `hg pull` or `hg push`).
2158 (typically: apply bundle from `hg pull` or `hg push`).
2159
2159
2160 New revisions are usually provided as a delta against another revision. By
2160 New revisions are usually provided as a delta against another revision. By
2161 default, Mercurial will not recompute the same delta again, trusting
2161 default, Mercurial will not recompute the same delta again, trusting
2162 externally provided deltas. There have been rare cases of small adjustment
2162 externally provided deltas. There have been rare cases of small adjustment
2163 to the diffing algorithm in the past. So in some rare case, recomputing
2163 to the diffing algorithm in the past. So in some rare case, recomputing
2164 delta provided by ancient clients can provides better results. Disabling
2164 delta provided by ancient clients can provides better results. Disabling
2165 this option means going through a full delta recomputation for all incoming
2165 this option means going through a full delta recomputation for all incoming
2166 revisions. It means a large increase in CPU usage and will slow operations
2166 revisions. It means a large increase in CPU usage and will slow operations
2167 down.
2167 down.
2168
2168
2169 This option is enabled by default. When disabled, it also disables the
2169 This option is enabled by default. When disabled, it also disables the
2170 related ``storage.revlog.reuse-external-delta-parent`` option.
2170 related ``storage.revlog.reuse-external-delta-parent`` option.
2171
2171
2172 ``revlog.zlib.level``
2172 ``revlog.zlib.level``
2173 Zlib compression level used when storing data into the repository. Accepted
2173 Zlib compression level used when storing data into the repository. Accepted
2174 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
2174 Value range from 1 (lowest compression) to 9 (highest compression). Zlib
2175 default value is 6.
2175 default value is 6.
2176
2176
2177
2177
2178 ``revlog.zstd.level``
2178 ``revlog.zstd.level``
2179 zstd compression level used when storing data into the repository. Accepted
2179 zstd compression level used when storing data into the repository. Accepted
2180 Value range from 1 (lowest compression) to 22 (highest compression).
2180 Value range from 1 (lowest compression) to 22 (highest compression).
2181 (default 3)
2181 (default 3)
2182
2182
2183 ``server``
2183 ``server``
2184 ----------
2184 ----------
2185
2185
2186 Controls generic server settings.
2186 Controls generic server settings.
2187
2187
2188 ``bookmarks-pushkey-compat``
2188 ``bookmarks-pushkey-compat``
2189 Trigger pushkey hook when being pushed bookmark updates. This config exist
2189 Trigger pushkey hook when being pushed bookmark updates. This config exist
2190 for compatibility purpose (default to True)
2190 for compatibility purpose (default to True)
2191
2191
2192 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
2192 If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark
2193 movement we recommend you migrate them to ``txnclose-bookmark`` and
2193 movement we recommend you migrate them to ``txnclose-bookmark`` and
2194 ``pretxnclose-bookmark``.
2194 ``pretxnclose-bookmark``.
2195
2195
2196 ``compressionengines``
2196 ``compressionengines``
2197 List of compression engines and their relative priority to advertise
2197 List of compression engines and their relative priority to advertise
2198 to clients.
2198 to clients.
2199
2199
2200 The order of compression engines determines their priority, the first
2200 The order of compression engines determines their priority, the first
2201 having the highest priority. If a compression engine is not listed
2201 having the highest priority. If a compression engine is not listed
2202 here, it won't be advertised to clients.
2202 here, it won't be advertised to clients.
2203
2203
2204 If not set (the default), built-in defaults are used. Run
2204 If not set (the default), built-in defaults are used. Run
2205 :hg:`debuginstall` to list available compression engines and their
2205 :hg:`debuginstall` to list available compression engines and their
2206 default wire protocol priority.
2206 default wire protocol priority.
2207
2207
2208 Older Mercurial clients only support zlib compression and this setting
2208 Older Mercurial clients only support zlib compression and this setting
2209 has no effect for legacy clients.
2209 has no effect for legacy clients.
2210
2210
2211 ``uncompressed``
2211 ``uncompressed``
2212 Whether to allow clients to clone a repository using the
2212 Whether to allow clients to clone a repository using the
2213 uncompressed streaming protocol. This transfers about 40% more
2213 uncompressed streaming protocol. This transfers about 40% more
2214 data than a regular clone, but uses less memory and CPU on both
2214 data than a regular clone, but uses less memory and CPU on both
2215 server and client. Over a LAN (100 Mbps or better) or a very fast
2215 server and client. Over a LAN (100 Mbps or better) or a very fast
2216 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
2216 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
2217 regular clone. Over most WAN connections (anything slower than
2217 regular clone. Over most WAN connections (anything slower than
2218 about 6 Mbps), uncompressed streaming is slower, because of the
2218 about 6 Mbps), uncompressed streaming is slower, because of the
2219 extra data transfer overhead. This mode will also temporarily hold
2219 extra data transfer overhead. This mode will also temporarily hold
2220 the write lock while determining what data to transfer.
2220 the write lock while determining what data to transfer.
2221 (default: True)
2221 (default: True)
2222
2222
2223 ``uncompressedallowsecret``
2223 ``uncompressedallowsecret``
2224 Whether to allow stream clones when the repository contains secret
2224 Whether to allow stream clones when the repository contains secret
2225 changesets. (default: False)
2225 changesets. (default: False)
2226
2226
2227 ``preferuncompressed``
2227 ``preferuncompressed``
2228 When set, clients will try to use the uncompressed streaming
2228 When set, clients will try to use the uncompressed streaming
2229 protocol. (default: False)
2229 protocol. (default: False)
2230
2230
2231 ``disablefullbundle``
2231 ``disablefullbundle``
2232 When set, servers will refuse attempts to do pull-based clones.
2232 When set, servers will refuse attempts to do pull-based clones.
2233 If this option is set, ``preferuncompressed`` and/or clone bundles
2233 If this option is set, ``preferuncompressed`` and/or clone bundles
2234 are highly recommended. Partial clones will still be allowed.
2234 are highly recommended. Partial clones will still be allowed.
2235 (default: False)
2235 (default: False)
2236
2236
2237 ``streamunbundle``
2237 ``streamunbundle``
2238 When set, servers will apply data sent from the client directly,
2238 When set, servers will apply data sent from the client directly,
2239 otherwise it will be written to a temporary file first. This option
2239 otherwise it will be written to a temporary file first. This option
2240 effectively prevents concurrent pushes.
2240 effectively prevents concurrent pushes.
2241
2241
2242 ``pullbundle``
2242 ``pullbundle``
2243 When set, the server will check pullbundle.manifest for bundles
2243 When set, the server will check pullbundle.manifest for bundles
2244 covering the requested heads and common nodes. The first matching
2244 covering the requested heads and common nodes. The first matching
2245 entry will be streamed to the client.
2245 entry will be streamed to the client.
2246
2246
2247 For HTTP transport, the stream will still use zlib compression
2247 For HTTP transport, the stream will still use zlib compression
2248 for older clients.
2248 for older clients.
2249
2249
2250 ``concurrent-push-mode``
2250 ``concurrent-push-mode``
2251 Level of allowed race condition between two pushing clients.
2251 Level of allowed race condition between two pushing clients.
2252
2252
2253 - 'strict': push is abort if another client touched the repository
2253 - 'strict': push is abort if another client touched the repository
2254 while the push was preparing.
2254 while the push was preparing.
2255 - 'check-related': push is only aborted if it affects head that got also
2255 - 'check-related': push is only aborted if it affects head that got also
2256 affected while the push was preparing. (default since 5.4)
2256 affected while the push was preparing. (default since 5.4)
2257
2257
2258 'check-related' only takes effect for compatible clients (version
2258 'check-related' only takes effect for compatible clients (version
2259 4.3 and later). Older clients will use 'strict'.
2259 4.3 and later). Older clients will use 'strict'.
2260
2260
2261 ``validate``
2261 ``validate``
2262 Whether to validate the completeness of pushed changesets by
2262 Whether to validate the completeness of pushed changesets by
2263 checking that all new file revisions specified in manifests are
2263 checking that all new file revisions specified in manifests are
2264 present. (default: False)
2264 present. (default: False)
2265
2265
2266 ``maxhttpheaderlen``
2266 ``maxhttpheaderlen``
2267 Instruct HTTP clients not to send request headers longer than this
2267 Instruct HTTP clients not to send request headers longer than this
2268 many bytes. (default: 1024)
2268 many bytes. (default: 1024)
2269
2269
2270 ``bundle1``
2270 ``bundle1``
2271 Whether to allow clients to push and pull using the legacy bundle1
2271 Whether to allow clients to push and pull using the legacy bundle1
2272 exchange format. (default: True)
2272 exchange format. (default: True)
2273
2273
2274 ``bundle1gd``
2274 ``bundle1gd``
2275 Like ``bundle1`` but only used if the repository is using the
2275 Like ``bundle1`` but only used if the repository is using the
2276 *generaldelta* storage format. (default: True)
2276 *generaldelta* storage format. (default: True)
2277
2277
2278 ``bundle1.push``
2278 ``bundle1.push``
2279 Whether to allow clients to push using the legacy bundle1 exchange
2279 Whether to allow clients to push using the legacy bundle1 exchange
2280 format. (default: True)
2280 format. (default: True)
2281
2281
2282 ``bundle1gd.push``
2282 ``bundle1gd.push``
2283 Like ``bundle1.push`` but only used if the repository is using the
2283 Like ``bundle1.push`` but only used if the repository is using the
2284 *generaldelta* storage format. (default: True)
2284 *generaldelta* storage format. (default: True)
2285
2285
2286 ``bundle1.pull``
2286 ``bundle1.pull``
2287 Whether to allow clients to pull using the legacy bundle1 exchange
2287 Whether to allow clients to pull using the legacy bundle1 exchange
2288 format. (default: True)
2288 format. (default: True)
2289
2289
2290 ``bundle1gd.pull``
2290 ``bundle1gd.pull``
2291 Like ``bundle1.pull`` but only used if the repository is using the
2291 Like ``bundle1.pull`` but only used if the repository is using the
2292 *generaldelta* storage format. (default: True)
2292 *generaldelta* storage format. (default: True)
2293
2293
2294 Large repositories using the *generaldelta* storage format should
2294 Large repositories using the *generaldelta* storage format should
2295 consider setting this option because converting *generaldelta*
2295 consider setting this option because converting *generaldelta*
2296 repositories to the exchange format required by the bundle1 data
2296 repositories to the exchange format required by the bundle1 data
2297 format can consume a lot of CPU.
2297 format can consume a lot of CPU.
2298
2298
2299 ``bundle2.stream``
2299 ``bundle2.stream``
2300 Whether to allow clients to pull using the bundle2 streaming protocol.
2300 Whether to allow clients to pull using the bundle2 streaming protocol.
2301 (default: True)
2301 (default: True)
2302
2302
2303 ``zliblevel``
2303 ``zliblevel``
2304 Integer between ``-1`` and ``9`` that controls the zlib compression level
2304 Integer between ``-1`` and ``9`` that controls the zlib compression level
2305 for wire protocol commands that send zlib compressed output (notably the
2305 for wire protocol commands that send zlib compressed output (notably the
2306 commands that send repository history data).
2306 commands that send repository history data).
2307
2307
2308 The default (``-1``) uses the default zlib compression level, which is
2308 The default (``-1``) uses the default zlib compression level, which is
2309 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2309 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
2310 maximum compression.
2310 maximum compression.
2311
2311
2312 Setting this option allows server operators to make trade-offs between
2312 Setting this option allows server operators to make trade-offs between
2313 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2313 bandwidth and CPU used. Lowering the compression lowers CPU utilization
2314 but sends more bytes to clients.
2314 but sends more bytes to clients.
2315
2315
2316 This option only impacts the HTTP server.
2316 This option only impacts the HTTP server.
2317
2317
2318 ``zstdlevel``
2318 ``zstdlevel``
2319 Integer between ``1`` and ``22`` that controls the zstd compression level
2319 Integer between ``1`` and ``22`` that controls the zstd compression level
2320 for wire protocol commands. ``1`` is the minimal amount of compression and
2320 for wire protocol commands. ``1`` is the minimal amount of compression and
2321 ``22`` is the highest amount of compression.
2321 ``22`` is the highest amount of compression.
2322
2322
2323 The default (``3``) should be significantly faster than zlib while likely
2323 The default (``3``) should be significantly faster than zlib while likely
2324 delivering better compression ratios.
2324 delivering better compression ratios.
2325
2325
2326 This option only impacts the HTTP server.
2326 This option only impacts the HTTP server.
2327
2327
2328 See also ``server.zliblevel``.
2328 See also ``server.zliblevel``.
2329
2329
2330 ``view``
2330 ``view``
2331 Repository filter used when exchanging revisions with the peer.
2331 Repository filter used when exchanging revisions with the peer.
2332
2332
2333 The default view (``served``) excludes secret and hidden changesets.
2333 The default view (``served``) excludes secret and hidden changesets.
2334 Another useful value is ``immutable`` (no draft, secret or hidden
2334 Another useful value is ``immutable`` (no draft, secret or hidden
2335 changesets). (EXPERIMENTAL)
2335 changesets). (EXPERIMENTAL)
2336
2336
2337 ``smtp``
2337 ``smtp``
2338 --------
2338 --------
2339
2339
2340 Configuration for extensions that need to send email messages.
2340 Configuration for extensions that need to send email messages.
2341
2341
2342 ``host``
2342 ``host``
2343 Host name of mail server, e.g. "mail.example.com".
2343 Host name of mail server, e.g. "mail.example.com".
2344
2344
2345 ``port``
2345 ``port``
2346 Optional. Port to connect to on mail server. (default: 465 if
2346 Optional. Port to connect to on mail server. (default: 465 if
2347 ``tls`` is smtps; 25 otherwise)
2347 ``tls`` is smtps; 25 otherwise)
2348
2348
2349 ``tls``
2349 ``tls``
2350 Optional. Method to enable TLS when connecting to mail server: starttls,
2350 Optional. Method to enable TLS when connecting to mail server: starttls,
2351 smtps or none. (default: none)
2351 smtps or none. (default: none)
2352
2352
2353 ``username``
2353 ``username``
2354 Optional. User name for authenticating with the SMTP server.
2354 Optional. User name for authenticating with the SMTP server.
2355 (default: None)
2355 (default: None)
2356
2356
2357 ``password``
2357 ``password``
2358 Optional. Password for authenticating with the SMTP server. If not
2358 Optional. Password for authenticating with the SMTP server. If not
2359 specified, interactive sessions will prompt the user for a
2359 specified, interactive sessions will prompt the user for a
2360 password; non-interactive sessions will fail. (default: None)
2360 password; non-interactive sessions will fail. (default: None)
2361
2361
2362 ``local_hostname``
2362 ``local_hostname``
2363 Optional. The hostname that the sender can use to identify
2363 Optional. The hostname that the sender can use to identify
2364 itself to the MTA.
2364 itself to the MTA.
2365
2365
2366
2366
2367 ``subpaths``
2367 ``subpaths``
2368 ------------
2368 ------------
2369
2369
2370 Subrepository source URLs can go stale if a remote server changes name
2370 Subrepository source URLs can go stale if a remote server changes name
2371 or becomes temporarily unavailable. This section lets you define
2371 or becomes temporarily unavailable. This section lets you define
2372 rewrite rules of the form::
2372 rewrite rules of the form::
2373
2373
2374 <pattern> = <replacement>
2374 <pattern> = <replacement>
2375
2375
2376 where ``pattern`` is a regular expression matching a subrepository
2376 where ``pattern`` is a regular expression matching a subrepository
2377 source URL and ``replacement`` is the replacement string used to
2377 source URL and ``replacement`` is the replacement string used to
2378 rewrite it. Groups can be matched in ``pattern`` and referenced in
2378 rewrite it. Groups can be matched in ``pattern`` and referenced in
2379 ``replacements``. For instance::
2379 ``replacements``. For instance::
2380
2380
2381 http://server/(.*)-hg/ = http://hg.server/\1/
2381 http://server/(.*)-hg/ = http://hg.server/\1/
2382
2382
2383 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2383 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
2384
2384
2385 Relative subrepository paths are first made absolute, and the
2385 Relative subrepository paths are first made absolute, and the
2386 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2386 rewrite rules are then applied on the full (absolute) path. If ``pattern``
2387 doesn't match the full path, an attempt is made to apply it on the
2387 doesn't match the full path, an attempt is made to apply it on the
2388 relative path alone. The rules are applied in definition order.
2388 relative path alone. The rules are applied in definition order.
2389
2389
2390 ``subrepos``
2390 ``subrepos``
2391 ------------
2391 ------------
2392
2392
2393 This section contains options that control the behavior of the
2393 This section contains options that control the behavior of the
2394 subrepositories feature. See also :hg:`help subrepos`.
2394 subrepositories feature. See also :hg:`help subrepos`.
2395
2395
2396 Security note: auditing in Mercurial is known to be insufficient to
2396 Security note: auditing in Mercurial is known to be insufficient to
2397 prevent clone-time code execution with carefully constructed Git
2397 prevent clone-time code execution with carefully constructed Git
2398 subrepos. It is unknown if a similar detect is present in Subversion
2398 subrepos. It is unknown if a similar detect is present in Subversion
2399 subrepos. Both Git and Subversion subrepos are disabled by default
2399 subrepos. Both Git and Subversion subrepos are disabled by default
2400 out of security concerns. These subrepo types can be enabled using
2400 out of security concerns. These subrepo types can be enabled using
2401 the respective options below.
2401 the respective options below.
2402
2402
2403 ``allowed``
2403 ``allowed``
2404 Whether subrepositories are allowed in the working directory.
2404 Whether subrepositories are allowed in the working directory.
2405
2405
2406 When false, commands involving subrepositories (like :hg:`update`)
2406 When false, commands involving subrepositories (like :hg:`update`)
2407 will fail for all subrepository types.
2407 will fail for all subrepository types.
2408 (default: true)
2408 (default: true)
2409
2409
2410 ``hg:allowed``
2410 ``hg:allowed``
2411 Whether Mercurial subrepositories are allowed in the working
2411 Whether Mercurial subrepositories are allowed in the working
2412 directory. This option only has an effect if ``subrepos.allowed``
2412 directory. This option only has an effect if ``subrepos.allowed``
2413 is true.
2413 is true.
2414 (default: true)
2414 (default: true)
2415
2415
2416 ``git:allowed``
2416 ``git:allowed``
2417 Whether Git subrepositories are allowed in the working directory.
2417 Whether Git subrepositories are allowed in the working directory.
2418 This option only has an effect if ``subrepos.allowed`` is true.
2418 This option only has an effect if ``subrepos.allowed`` is true.
2419
2419
2420 See the security note above before enabling Git subrepos.
2420 See the security note above before enabling Git subrepos.
2421 (default: false)
2421 (default: false)
2422
2422
2423 ``svn:allowed``
2423 ``svn:allowed``
2424 Whether Subversion subrepositories are allowed in the working
2424 Whether Subversion subrepositories are allowed in the working
2425 directory. This option only has an effect if ``subrepos.allowed``
2425 directory. This option only has an effect if ``subrepos.allowed``
2426 is true.
2426 is true.
2427
2427
2428 See the security note above before enabling Subversion subrepos.
2428 See the security note above before enabling Subversion subrepos.
2429 (default: false)
2429 (default: false)
2430
2430
2431 ``templatealias``
2431 ``templatealias``
2432 -----------------
2432 -----------------
2433
2433
2434 Alias definitions for templates. See :hg:`help templates` for details.
2434 Alias definitions for templates. See :hg:`help templates` for details.
2435
2435
2436 ``templates``
2436 ``templates``
2437 -------------
2437 -------------
2438
2438
2439 Use the ``[templates]`` section to define template strings.
2439 Use the ``[templates]`` section to define template strings.
2440 See :hg:`help templates` for details.
2440 See :hg:`help templates` for details.
2441
2441
2442 ``trusted``
2442 ``trusted``
2443 -----------
2443 -----------
2444
2444
2445 Mercurial will not use the settings in the
2445 Mercurial will not use the settings in the
2446 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2446 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
2447 user or to a trusted group, as various hgrc features allow arbitrary
2447 user or to a trusted group, as various hgrc features allow arbitrary
2448 commands to be run. This issue is often encountered when configuring
2448 commands to be run. This issue is often encountered when configuring
2449 hooks or extensions for shared repositories or servers. However,
2449 hooks or extensions for shared repositories or servers. However,
2450 the web interface will use some safe settings from the ``[web]``
2450 the web interface will use some safe settings from the ``[web]``
2451 section.
2451 section.
2452
2452
2453 This section specifies what users and groups are trusted. The
2453 This section specifies what users and groups are trusted. The
2454 current user is always trusted. To trust everybody, list a user or a
2454 current user is always trusted. To trust everybody, list a user or a
2455 group with name ``*``. These settings must be placed in an
2455 group with name ``*``. These settings must be placed in an
2456 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2456 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
2457 user or service running Mercurial.
2457 user or service running Mercurial.
2458
2458
2459 ``users``
2459 ``users``
2460 Comma-separated list of trusted users.
2460 Comma-separated list of trusted users.
2461
2461
2462 ``groups``
2462 ``groups``
2463 Comma-separated list of trusted groups.
2463 Comma-separated list of trusted groups.
2464
2464
2465
2465
2466 ``ui``
2466 ``ui``
2467 ------
2467 ------
2468
2468
2469 User interface controls.
2469 User interface controls.
2470
2470
2471 ``archivemeta``
2471 ``archivemeta``
2472 Whether to include the .hg_archival.txt file containing meta data
2472 Whether to include the .hg_archival.txt file containing meta data
2473 (hashes for the repository base and for tip) in archives created
2473 (hashes for the repository base and for tip) in archives created
2474 by the :hg:`archive` command or downloaded via hgweb.
2474 by the :hg:`archive` command or downloaded via hgweb.
2475 (default: True)
2475 (default: True)
2476
2476
2477 ``askusername``
2477 ``askusername``
2478 Whether to prompt for a username when committing. If True, and
2478 Whether to prompt for a username when committing. If True, and
2479 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2479 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
2480 be prompted to enter a username. If no username is entered, the
2480 be prompted to enter a username. If no username is entered, the
2481 default ``USER@HOST`` is used instead.
2481 default ``USER@HOST`` is used instead.
2482 (default: False)
2482 (default: False)
2483
2483
2484 ``clonebundles``
2484 ``clonebundles``
2485 Whether the "clone bundles" feature is enabled.
2485 Whether the "clone bundles" feature is enabled.
2486
2486
2487 When enabled, :hg:`clone` may download and apply a server-advertised
2487 When enabled, :hg:`clone` may download and apply a server-advertised
2488 bundle file from a URL instead of using the normal exchange mechanism.
2488 bundle file from a URL instead of using the normal exchange mechanism.
2489
2489
2490 This can likely result in faster and more reliable clones.
2490 This can likely result in faster and more reliable clones.
2491
2491
2492 (default: True)
2492 (default: True)
2493
2493
2494 ``clonebundlefallback``
2494 ``clonebundlefallback``
2495 Whether failure to apply an advertised "clone bundle" from a server
2495 Whether failure to apply an advertised "clone bundle" from a server
2496 should result in fallback to a regular clone.
2496 should result in fallback to a regular clone.
2497
2497
2498 This is disabled by default because servers advertising "clone
2498 This is disabled by default because servers advertising "clone
2499 bundles" often do so to reduce server load. If advertised bundles
2499 bundles" often do so to reduce server load. If advertised bundles
2500 start mass failing and clients automatically fall back to a regular
2500 start mass failing and clients automatically fall back to a regular
2501 clone, this would add significant and unexpected load to the server
2501 clone, this would add significant and unexpected load to the server
2502 since the server is expecting clone operations to be offloaded to
2502 since the server is expecting clone operations to be offloaded to
2503 pre-generated bundles. Failing fast (the default behavior) ensures
2503 pre-generated bundles. Failing fast (the default behavior) ensures
2504 clients don't overwhelm the server when "clone bundle" application
2504 clients don't overwhelm the server when "clone bundle" application
2505 fails.
2505 fails.
2506
2506
2507 (default: False)
2507 (default: False)
2508
2508
2509 ``clonebundleprefers``
2509 ``clonebundleprefers``
2510 Defines preferences for which "clone bundles" to use.
2510 Defines preferences for which "clone bundles" to use.
2511
2511
2512 Servers advertising "clone bundles" may advertise multiple available
2512 Servers advertising "clone bundles" may advertise multiple available
2513 bundles. Each bundle may have different attributes, such as the bundle
2513 bundles. Each bundle may have different attributes, such as the bundle
2514 type and compression format. This option is used to prefer a particular
2514 type and compression format. This option is used to prefer a particular
2515 bundle over another.
2515 bundle over another.
2516
2516
2517 The following keys are defined by Mercurial:
2517 The following keys are defined by Mercurial:
2518
2518
2519 BUNDLESPEC
2519 BUNDLESPEC
2520 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2520 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2521 e.g. ``gzip-v2`` or ``bzip2-v1``.
2521 e.g. ``gzip-v2`` or ``bzip2-v1``.
2522
2522
2523 COMPRESSION
2523 COMPRESSION
2524 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2524 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2525
2525
2526 Server operators may define custom keys.
2526 Server operators may define custom keys.
2527
2527
2528 Example values: ``COMPRESSION=bzip2``,
2528 Example values: ``COMPRESSION=bzip2``,
2529 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2529 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2530
2530
2531 By default, the first bundle advertised by the server is used.
2531 By default, the first bundle advertised by the server is used.
2532
2532
2533 ``color``
2533 ``color``
2534 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2534 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2535 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2535 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2536 seems possible. See :hg:`help color` for details.
2536 seems possible. See :hg:`help color` for details.
2537
2537
2538 ``commitsubrepos``
2538 ``commitsubrepos``
2539 Whether to commit modified subrepositories when committing the
2539 Whether to commit modified subrepositories when committing the
2540 parent repository. If False and one subrepository has uncommitted
2540 parent repository. If False and one subrepository has uncommitted
2541 changes, abort the commit.
2541 changes, abort the commit.
2542 (default: False)
2542 (default: False)
2543
2543
2544 ``debug``
2544 ``debug``
2545 Print debugging information. (default: False)
2545 Print debugging information. (default: False)
2546
2546
2547 ``editor``
2547 ``editor``
2548 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2548 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2549
2549
2550 ``fallbackencoding``
2550 ``fallbackencoding``
2551 Encoding to try if it's not possible to decode the changelog using
2551 Encoding to try if it's not possible to decode the changelog using
2552 UTF-8. (default: ISO-8859-1)
2552 UTF-8. (default: ISO-8859-1)
2553
2553
2554 ``graphnodetemplate``
2554 ``graphnodetemplate``
2555 (DEPRECATED) Use ``command-templates.graphnode`` instead.
2555 (DEPRECATED) Use ``command-templates.graphnode`` instead.
2556
2556
2557 ``ignore``
2557 ``ignore``
2558 A file to read per-user ignore patterns from. This file should be
2558 A file to read per-user ignore patterns from. This file should be
2559 in the same format as a repository-wide .hgignore file. Filenames
2559 in the same format as a repository-wide .hgignore file. Filenames
2560 are relative to the repository root. This option supports hook syntax,
2560 are relative to the repository root. This option supports hook syntax,
2561 so if you want to specify multiple ignore files, you can do so by
2561 so if you want to specify multiple ignore files, you can do so by
2562 setting something like ``ignore.other = ~/.hgignore2``. For details
2562 setting something like ``ignore.other = ~/.hgignore2``. For details
2563 of the ignore file format, see the ``hgignore(5)`` man page.
2563 of the ignore file format, see the ``hgignore(5)`` man page.
2564
2564
2565 ``interactive``
2565 ``interactive``
2566 Allow to prompt the user. (default: True)
2566 Allow to prompt the user. (default: True)
2567
2567
2568 ``interface``
2568 ``interface``
2569 Select the default interface for interactive features (default: text).
2569 Select the default interface for interactive features (default: text).
2570 Possible values are 'text' and 'curses'.
2570 Possible values are 'text' and 'curses'.
2571
2571
2572 ``interface.chunkselector``
2572 ``interface.chunkselector``
2573 Select the interface for change recording (e.g. :hg:`commit -i`).
2573 Select the interface for change recording (e.g. :hg:`commit -i`).
2574 Possible values are 'text' and 'curses'.
2574 Possible values are 'text' and 'curses'.
2575 This config overrides the interface specified by ui.interface.
2575 This config overrides the interface specified by ui.interface.
2576
2576
2577 ``large-file-limit``
2577 ``large-file-limit``
2578 Largest file size that gives no memory use warning.
2578 Largest file size that gives no memory use warning.
2579 Possible values are integers or 0 to disable the check.
2579 Possible values are integers or 0 to disable the check.
2580 (default: 10000000)
2580 (default: 10000000)
2581
2581
2582 ``logtemplate``
2582 ``logtemplate``
2583 (DEPRECATED) Use ``command-templates.log`` instead.
2583 (DEPRECATED) Use ``command-templates.log`` instead.
2584
2584
2585 ``merge``
2585 ``merge``
2586 The conflict resolution program to use during a manual merge.
2586 The conflict resolution program to use during a manual merge.
2587 For more information on merge tools see :hg:`help merge-tools`.
2587 For more information on merge tools see :hg:`help merge-tools`.
2588 For configuring merge tools see the ``[merge-tools]`` section.
2588 For configuring merge tools see the ``[merge-tools]`` section.
2589
2589
2590 ``mergemarkers``
2590 ``mergemarkers``
2591 Sets the merge conflict marker label styling. The ``detailed`` style
2591 Sets the merge conflict marker label styling. The ``detailed`` style
2592 uses the ``command-templates.mergemarker`` setting to style the labels.
2592 uses the ``command-templates.mergemarker`` setting to style the labels.
2593 The ``basic`` style just uses 'local' and 'other' as the marker label.
2593 The ``basic`` style just uses 'local' and 'other' as the marker label.
2594 One of ``basic`` or ``detailed``.
2594 One of ``basic`` or ``detailed``.
2595 (default: ``basic``)
2595 (default: ``basic``)
2596
2596
2597 ``mergemarkertemplate``
2597 ``mergemarkertemplate``
2598 (DEPRECATED) Use ``command-templates.mergemarker`` instead.
2598 (DEPRECATED) Use ``command-templates.mergemarker`` instead.
2599
2599
2600 ``message-output``
2600 ``message-output``
2601 Where to write status and error messages. (default: ``stdio``)
2601 Where to write status and error messages. (default: ``stdio``)
2602
2602
2603 ``channel``
2603 ``channel``
2604 Use separate channel for structured output. (Command-server only)
2604 Use separate channel for structured output. (Command-server only)
2605 ``stderr``
2605 ``stderr``
2606 Everything to stderr.
2606 Everything to stderr.
2607 ``stdio``
2607 ``stdio``
2608 Status to stdout, and error to stderr.
2608 Status to stdout, and error to stderr.
2609
2609
2610 ``origbackuppath``
2610 ``origbackuppath``
2611 The path to a directory used to store generated .orig files. If the path is
2611 The path to a directory used to store generated .orig files. If the path is
2612 not a directory, one will be created. If set, files stored in this
2612 not a directory, one will be created. If set, files stored in this
2613 directory have the same name as the original file and do not have a .orig
2613 directory have the same name as the original file and do not have a .orig
2614 suffix.
2614 suffix.
2615
2615
2616 ``paginate``
2616 ``paginate``
2617 Control the pagination of command output (default: True). See :hg:`help pager`
2617 Control the pagination of command output (default: True). See :hg:`help pager`
2618 for details.
2618 for details.
2619
2619
2620 ``patch``
2620 ``patch``
2621 An optional external tool that ``hg import`` and some extensions
2621 An optional external tool that ``hg import`` and some extensions
2622 will use for applying patches. By default Mercurial uses an
2622 will use for applying patches. By default Mercurial uses an
2623 internal patch utility. The external tool must work as the common
2623 internal patch utility. The external tool must work as the common
2624 Unix ``patch`` program. In particular, it must accept a ``-p``
2624 Unix ``patch`` program. In particular, it must accept a ``-p``
2625 argument to strip patch headers, a ``-d`` argument to specify the
2625 argument to strip patch headers, a ``-d`` argument to specify the
2626 current directory, a file name to patch, and a patch file to take
2626 current directory, a file name to patch, and a patch file to take
2627 from stdin.
2627 from stdin.
2628
2628
2629 It is possible to specify a patch tool together with extra
2629 It is possible to specify a patch tool together with extra
2630 arguments. For example, setting this option to ``patch --merge``
2630 arguments. For example, setting this option to ``patch --merge``
2631 will use the ``patch`` program with its 2-way merge option.
2631 will use the ``patch`` program with its 2-way merge option.
2632
2632
2633 ``portablefilenames``
2633 ``portablefilenames``
2634 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2634 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2635 (default: ``warn``)
2635 (default: ``warn``)
2636
2636
2637 ``warn``
2637 ``warn``
2638 Print a warning message on POSIX platforms, if a file with a non-portable
2638 Print a warning message on POSIX platforms, if a file with a non-portable
2639 filename is added (e.g. a file with a name that can't be created on
2639 filename is added (e.g. a file with a name that can't be created on
2640 Windows because it contains reserved parts like ``AUX``, reserved
2640 Windows because it contains reserved parts like ``AUX``, reserved
2641 characters like ``:``, or would cause a case collision with an existing
2641 characters like ``:``, or would cause a case collision with an existing
2642 file).
2642 file).
2643
2643
2644 ``ignore``
2644 ``ignore``
2645 Don't print a warning.
2645 Don't print a warning.
2646
2646
2647 ``abort``
2647 ``abort``
2648 The command is aborted.
2648 The command is aborted.
2649
2649
2650 ``true``
2650 ``true``
2651 Alias for ``warn``.
2651 Alias for ``warn``.
2652
2652
2653 ``false``
2653 ``false``
2654 Alias for ``ignore``.
2654 Alias for ``ignore``.
2655
2655
2656 .. container:: windows
2656 .. container:: windows
2657
2657
2658 On Windows, this configuration option is ignored and the command aborted.
2658 On Windows, this configuration option is ignored and the command aborted.
2659
2659
2660 ``pre-merge-tool-output-template``
2660 ``pre-merge-tool-output-template``
2661 (DEPRECATED) Use ``command-template.pre-merge-tool-output`` instead.
2661 (DEPRECATED) Use ``command-template.pre-merge-tool-output`` instead.
2662
2662
2663 ``quiet``
2663 ``quiet``
2664 Reduce the amount of output printed.
2664 Reduce the amount of output printed.
2665 (default: False)
2665 (default: False)
2666
2666
2667 ``relative-paths``
2667 ``relative-paths``
2668 Prefer relative paths in the UI.
2668 Prefer relative paths in the UI.
2669
2669
2670 ``remotecmd``
2670 ``remotecmd``
2671 Remote command to use for clone/push/pull operations.
2671 Remote command to use for clone/push/pull operations.
2672 (default: ``hg``)
2672 (default: ``hg``)
2673
2673
2674 ``report_untrusted``
2674 ``report_untrusted``
2675 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2675 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2676 trusted user or group.
2676 trusted user or group.
2677 (default: True)
2677 (default: True)
2678
2678
2679 ``slash``
2679 ``slash``
2680 (Deprecated. Use ``slashpath`` template filter instead.)
2680 (Deprecated. Use ``slashpath`` template filter instead.)
2681
2681
2682 Display paths using a slash (``/``) as the path separator. This
2682 Display paths using a slash (``/``) as the path separator. This
2683 only makes a difference on systems where the default path
2683 only makes a difference on systems where the default path
2684 separator is not the slash character (e.g. Windows uses the
2684 separator is not the slash character (e.g. Windows uses the
2685 backslash character (``\``)).
2685 backslash character (``\``)).
2686 (default: False)
2686 (default: False)
2687
2687
2688 ``statuscopies``
2688 ``statuscopies``
2689 Display copies in the status command.
2689 Display copies in the status command.
2690
2690
2691 ``ssh``
2691 ``ssh``
2692 Command to use for SSH connections. (default: ``ssh``)
2692 Command to use for SSH connections. (default: ``ssh``)
2693
2693
2694 ``ssherrorhint``
2694 ``ssherrorhint``
2695 A hint shown to the user in the case of SSH error (e.g.
2695 A hint shown to the user in the case of SSH error (e.g.
2696 ``Please see http://company/internalwiki/ssh.html``)
2696 ``Please see http://company/internalwiki/ssh.html``)
2697
2697
2698 ``strict``
2698 ``strict``
2699 Require exact command names, instead of allowing unambiguous
2699 Require exact command names, instead of allowing unambiguous
2700 abbreviations. (default: False)
2700 abbreviations. (default: False)
2701
2701
2702 ``style``
2702 ``style``
2703 Name of style to use for command output.
2703 Name of style to use for command output.
2704
2704
2705 ``supportcontact``
2705 ``supportcontact``
2706 A URL where users should report a Mercurial traceback. Use this if you are a
2706 A URL where users should report a Mercurial traceback. Use this if you are a
2707 large organisation with its own Mercurial deployment process and crash
2707 large organisation with its own Mercurial deployment process and crash
2708 reports should be addressed to your internal support.
2708 reports should be addressed to your internal support.
2709
2709
2710 ``textwidth``
2710 ``textwidth``
2711 Maximum width of help text. A longer line generated by ``hg help`` or
2711 Maximum width of help text. A longer line generated by ``hg help`` or
2712 ``hg subcommand --help`` will be broken after white space to get this
2712 ``hg subcommand --help`` will be broken after white space to get this
2713 width or the terminal width, whichever comes first.
2713 width or the terminal width, whichever comes first.
2714 A non-positive value will disable this and the terminal width will be
2714 A non-positive value will disable this and the terminal width will be
2715 used. (default: 78)
2715 used. (default: 78)
2716
2716
2717 ``timeout``
2717 ``timeout``
2718 The timeout used when a lock is held (in seconds), a negative value
2718 The timeout used when a lock is held (in seconds), a negative value
2719 means no timeout. (default: 600)
2719 means no timeout. (default: 600)
2720
2720
2721 ``timeout.warn``
2721 ``timeout.warn``
2722 Time (in seconds) before a warning is printed about held lock. A negative
2722 Time (in seconds) before a warning is printed about held lock. A negative
2723 value means no warning. (default: 0)
2723 value means no warning. (default: 0)
2724
2724
2725 ``traceback``
2725 ``traceback``
2726 Mercurial always prints a traceback when an unknown exception
2726 Mercurial always prints a traceback when an unknown exception
2727 occurs. Setting this to True will make Mercurial print a traceback
2727 occurs. Setting this to True will make Mercurial print a traceback
2728 on all exceptions, even those recognized by Mercurial (such as
2728 on all exceptions, even those recognized by Mercurial (such as
2729 IOError or MemoryError). (default: False)
2729 IOError or MemoryError). (default: False)
2730
2730
2731 ``tweakdefaults``
2731 ``tweakdefaults``
2732
2732
2733 By default Mercurial's behavior changes very little from release
2733 By default Mercurial's behavior changes very little from release
2734 to release, but over time the recommended config settings
2734 to release, but over time the recommended config settings
2735 shift. Enable this config to opt in to get automatic tweaks to
2735 shift. Enable this config to opt in to get automatic tweaks to
2736 Mercurial's behavior over time. This config setting will have no
2736 Mercurial's behavior over time. This config setting will have no
2737 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2737 effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does
2738 not include ``tweakdefaults``. (default: False)
2738 not include ``tweakdefaults``. (default: False)
2739
2739
2740 It currently means::
2740 It currently means::
2741
2741
2742 .. tweakdefaultsmarker
2742 .. tweakdefaultsmarker
2743
2743
2744 ``username``
2744 ``username``
2745 The committer of a changeset created when running "commit".
2745 The committer of a changeset created when running "commit".
2746 Typically a person's name and email address, e.g. ``Fred Widget
2746 Typically a person's name and email address, e.g. ``Fred Widget
2747 <fred@example.com>``. Environment variables in the
2747 <fred@example.com>``. Environment variables in the
2748 username are expanded.
2748 username are expanded.
2749
2749
2750 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2750 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2751 hgrc is empty, e.g. if the system admin set ``username =`` in the
2751 hgrc is empty, e.g. if the system admin set ``username =`` in the
2752 system hgrc, it has to be specified manually or in a different
2752 system hgrc, it has to be specified manually or in a different
2753 hgrc file)
2753 hgrc file)
2754
2754
2755 ``verbose``
2755 ``verbose``
2756 Increase the amount of output printed. (default: False)
2756 Increase the amount of output printed. (default: False)
2757
2757
2758
2758
2759 ``command-templates``
2759 ``command-templates``
2760 ---------------------
2760 ---------------------
2761
2761
2762 Templates used for customizing the output of commands.
2762 Templates used for customizing the output of commands.
2763
2763
2764 ``graphnode``
2764 ``graphnode``
2765 The template used to print changeset nodes in an ASCII revision graph.
2765 The template used to print changeset nodes in an ASCII revision graph.
2766 (default: ``{graphnode}``)
2766 (default: ``{graphnode}``)
2767
2767
2768 ``log``
2768 ``log``
2769 Template string for commands that print changesets.
2769 Template string for commands that print changesets.
2770
2770
2771 ``mergemarker``
2771 ``mergemarker``
2772 The template used to print the commit description next to each conflict
2772 The template used to print the commit description next to each conflict
2773 marker during merge conflicts. See :hg:`help templates` for the template
2773 marker during merge conflicts. See :hg:`help templates` for the template
2774 format.
2774 format.
2775
2775
2776 Defaults to showing the hash, tags, branches, bookmarks, author, and
2776 Defaults to showing the hash, tags, branches, bookmarks, author, and
2777 the first line of the commit description.
2777 the first line of the commit description.
2778
2778
2779 If you use non-ASCII characters in names for tags, branches, bookmarks,
2779 If you use non-ASCII characters in names for tags, branches, bookmarks,
2780 authors, and/or commit descriptions, you must pay attention to encodings of
2780 authors, and/or commit descriptions, you must pay attention to encodings of
2781 managed files. At template expansion, non-ASCII characters use the encoding
2781 managed files. At template expansion, non-ASCII characters use the encoding
2782 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2782 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2783 environment variables that govern your locale. If the encoding of the merge
2783 environment variables that govern your locale. If the encoding of the merge
2784 markers is different from the encoding of the merged files,
2784 markers is different from the encoding of the merged files,
2785 serious problems may occur.
2785 serious problems may occur.
2786
2786
2787 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2787 Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
2788
2788
2789 ``oneline-summary``
2789 ``oneline-summary``
2790 A template used by `hg rebase` and other commands for showing a one-line
2790 A template used by `hg rebase` and other commands for showing a one-line
2791 summary of a commit. If the template configured here is longer than one
2791 summary of a commit. If the template configured here is longer than one
2792 line, then only the first line is used.
2792 line, then only the first line is used.
2793
2793
2794 The template can be overridden per command by defining a template in
2794 The template can be overridden per command by defining a template in
2795 `oneline-summary.<command>`, where `<command>` can be e.g. "rebase".
2795 `oneline-summary.<command>`, where `<command>` can be e.g. "rebase".
2796
2796
2797 ``pre-merge-tool-output``
2797 ``pre-merge-tool-output``
2798 A template that is printed before executing an external merge tool. This can
2798 A template that is printed before executing an external merge tool. This can
2799 be used to print out additional context that might be useful to have during
2799 be used to print out additional context that might be useful to have during
2800 the conflict resolution, such as the description of the various commits
2800 the conflict resolution, such as the description of the various commits
2801 involved or bookmarks/tags.
2801 involved or bookmarks/tags.
2802
2802
2803 Additional information is available in the ``local`, ``base``, and ``other``
2803 Additional information is available in the ``local`, ``base``, and ``other``
2804 dicts. For example: ``{local.label}``, ``{base.name}``, or
2804 dicts. For example: ``{local.label}``, ``{base.name}``, or
2805 ``{other.islink}``.
2805 ``{other.islink}``.
2806
2806
2807
2807
2808 ``web``
2808 ``web``
2809 -------
2809 -------
2810
2810
2811 Web interface configuration. The settings in this section apply to
2811 Web interface configuration. The settings in this section apply to
2812 both the builtin webserver (started by :hg:`serve`) and the script you
2812 both the builtin webserver (started by :hg:`serve`) and the script you
2813 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2813 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2814 and WSGI).
2814 and WSGI).
2815
2815
2816 The Mercurial webserver does no authentication (it does not prompt for
2816 The Mercurial webserver does no authentication (it does not prompt for
2817 usernames and passwords to validate *who* users are), but it does do
2817 usernames and passwords to validate *who* users are), but it does do
2818 authorization (it grants or denies access for *authenticated users*
2818 authorization (it grants or denies access for *authenticated users*
2819 based on settings in this section). You must either configure your
2819 based on settings in this section). You must either configure your
2820 webserver to do authentication for you, or disable the authorization
2820 webserver to do authentication for you, or disable the authorization
2821 checks.
2821 checks.
2822
2822
2823 For a quick setup in a trusted environment, e.g., a private LAN, where
2823 For a quick setup in a trusted environment, e.g., a private LAN, where
2824 you want it to accept pushes from anybody, you can use the following
2824 you want it to accept pushes from anybody, you can use the following
2825 command line::
2825 command line::
2826
2826
2827 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2827 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2828
2828
2829 Note that this will allow anybody to push anything to the server and
2829 Note that this will allow anybody to push anything to the server and
2830 that this should not be used for public servers.
2830 that this should not be used for public servers.
2831
2831
2832 The full set of options is:
2832 The full set of options is:
2833
2833
2834 ``accesslog``
2834 ``accesslog``
2835 Where to output the access log. (default: stdout)
2835 Where to output the access log. (default: stdout)
2836
2836
2837 ``address``
2837 ``address``
2838 Interface address to bind to. (default: all)
2838 Interface address to bind to. (default: all)
2839
2839
2840 ``allow-archive``
2840 ``allow-archive``
2841 List of archive format (bz2, gz, zip) allowed for downloading.
2841 List of archive format (bz2, gz, zip) allowed for downloading.
2842 (default: empty)
2842 (default: empty)
2843
2843
2844 ``allowbz2``
2844 ``allowbz2``
2845 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2845 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2846 revisions.
2846 revisions.
2847 (default: False)
2847 (default: False)
2848
2848
2849 ``allowgz``
2849 ``allowgz``
2850 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2850 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2851 revisions.
2851 revisions.
2852 (default: False)
2852 (default: False)
2853
2853
2854 ``allow-pull``
2854 ``allow-pull``
2855 Whether to allow pulling from the repository. (default: True)
2855 Whether to allow pulling from the repository. (default: True)
2856
2856
2857 ``allow-push``
2857 ``allow-push``
2858 Whether to allow pushing to the repository. If empty or not set,
2858 Whether to allow pushing to the repository. If empty or not set,
2859 pushing is not allowed. If the special value ``*``, any remote
2859 pushing is not allowed. If the special value ``*``, any remote
2860 user can push, including unauthenticated users. Otherwise, the
2860 user can push, including unauthenticated users. Otherwise, the
2861 remote user must have been authenticated, and the authenticated
2861 remote user must have been authenticated, and the authenticated
2862 user name must be present in this list. The contents of the
2862 user name must be present in this list. The contents of the
2863 allow-push list are examined after the deny_push list.
2863 allow-push list are examined after the deny_push list.
2864
2864
2865 ``allow_read``
2865 ``allow_read``
2866 If the user has not already been denied repository access due to
2866 If the user has not already been denied repository access due to
2867 the contents of deny_read, this list determines whether to grant
2867 the contents of deny_read, this list determines whether to grant
2868 repository access to the user. If this list is not empty, and the
2868 repository access to the user. If this list is not empty, and the
2869 user is unauthenticated or not present in the list, then access is
2869 user is unauthenticated or not present in the list, then access is
2870 denied for the user. If the list is empty or not set, then access
2870 denied for the user. If the list is empty or not set, then access
2871 is permitted to all users by default. Setting allow_read to the
2871 is permitted to all users by default. Setting allow_read to the
2872 special value ``*`` is equivalent to it not being set (i.e. access
2872 special value ``*`` is equivalent to it not being set (i.e. access
2873 is permitted to all users). The contents of the allow_read list are
2873 is permitted to all users). The contents of the allow_read list are
2874 examined after the deny_read list.
2874 examined after the deny_read list.
2875
2875
2876 ``allowzip``
2876 ``allowzip``
2877 (DEPRECATED) Whether to allow .zip downloading of repository
2877 (DEPRECATED) Whether to allow .zip downloading of repository
2878 revisions. This feature creates temporary files.
2878 revisions. This feature creates temporary files.
2879 (default: False)
2879 (default: False)
2880
2880
2881 ``archivesubrepos``
2881 ``archivesubrepos``
2882 Whether to recurse into subrepositories when archiving.
2882 Whether to recurse into subrepositories when archiving.
2883 (default: False)
2883 (default: False)
2884
2884
2885 ``baseurl``
2885 ``baseurl``
2886 Base URL to use when publishing URLs in other locations, so
2886 Base URL to use when publishing URLs in other locations, so
2887 third-party tools like email notification hooks can construct
2887 third-party tools like email notification hooks can construct
2888 URLs. Example: ``http://hgserver/repos/``.
2888 URLs. Example: ``http://hgserver/repos/``.
2889
2889
2890 ``cacerts``
2890 ``cacerts``
2891 Path to file containing a list of PEM encoded certificate
2891 Path to file containing a list of PEM encoded certificate
2892 authority certificates. Environment variables and ``~user``
2892 authority certificates. Environment variables and ``~user``
2893 constructs are expanded in the filename. If specified on the
2893 constructs are expanded in the filename. If specified on the
2894 client, then it will verify the identity of remote HTTPS servers
2894 client, then it will verify the identity of remote HTTPS servers
2895 with these certificates.
2895 with these certificates.
2896
2896
2897 To disable SSL verification temporarily, specify ``--insecure`` from
2897 To disable SSL verification temporarily, specify ``--insecure`` from
2898 command line.
2898 command line.
2899
2899
2900 You can use OpenSSL's CA certificate file if your platform has
2900 You can use OpenSSL's CA certificate file if your platform has
2901 one. On most Linux systems this will be
2901 one. On most Linux systems this will be
2902 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2902 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2903 generate this file manually. The form must be as follows::
2903 generate this file manually. The form must be as follows::
2904
2904
2905 -----BEGIN CERTIFICATE-----
2905 -----BEGIN CERTIFICATE-----
2906 ... (certificate in base64 PEM encoding) ...
2906 ... (certificate in base64 PEM encoding) ...
2907 -----END CERTIFICATE-----
2907 -----END CERTIFICATE-----
2908 -----BEGIN CERTIFICATE-----
2908 -----BEGIN CERTIFICATE-----
2909 ... (certificate in base64 PEM encoding) ...
2909 ... (certificate in base64 PEM encoding) ...
2910 -----END CERTIFICATE-----
2910 -----END CERTIFICATE-----
2911
2911
2912 ``cache``
2912 ``cache``
2913 Whether to support caching in hgweb. (default: True)
2913 Whether to support caching in hgweb. (default: True)
2914
2914
2915 ``certificate``
2915 ``certificate``
2916 Certificate to use when running :hg:`serve`.
2916 Certificate to use when running :hg:`serve`.
2917
2917
2918 ``collapse``
2918 ``collapse``
2919 With ``descend`` enabled, repositories in subdirectories are shown at
2919 With ``descend`` enabled, repositories in subdirectories are shown at
2920 a single level alongside repositories in the current path. With
2920 a single level alongside repositories in the current path. With
2921 ``collapse`` also enabled, repositories residing at a deeper level than
2921 ``collapse`` also enabled, repositories residing at a deeper level than
2922 the current path are grouped behind navigable directory entries that
2922 the current path are grouped behind navigable directory entries that
2923 lead to the locations of these repositories. In effect, this setting
2923 lead to the locations of these repositories. In effect, this setting
2924 collapses each collection of repositories found within a subdirectory
2924 collapses each collection of repositories found within a subdirectory
2925 into a single entry for that subdirectory. (default: False)
2925 into a single entry for that subdirectory. (default: False)
2926
2926
2927 ``comparisoncontext``
2927 ``comparisoncontext``
2928 Number of lines of context to show in side-by-side file comparison. If
2928 Number of lines of context to show in side-by-side file comparison. If
2929 negative or the value ``full``, whole files are shown. (default: 5)
2929 negative or the value ``full``, whole files are shown. (default: 5)
2930
2930
2931 This setting can be overridden by a ``context`` request parameter to the
2931 This setting can be overridden by a ``context`` request parameter to the
2932 ``comparison`` command, taking the same values.
2932 ``comparison`` command, taking the same values.
2933
2933
2934 ``contact``
2934 ``contact``
2935 Name or email address of the person in charge of the repository.
2935 Name or email address of the person in charge of the repository.
2936 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2936 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2937
2937
2938 ``csp``
2938 ``csp``
2939 Send a ``Content-Security-Policy`` HTTP header with this value.
2939 Send a ``Content-Security-Policy`` HTTP header with this value.
2940
2940
2941 The value may contain a special string ``%nonce%``, which will be replaced
2941 The value may contain a special string ``%nonce%``, which will be replaced
2942 by a randomly-generated one-time use value. If the value contains
2942 by a randomly-generated one-time use value. If the value contains
2943 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2943 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2944 one-time property of the nonce. This nonce will also be inserted into
2944 one-time property of the nonce. This nonce will also be inserted into
2945 ``<script>`` elements containing inline JavaScript.
2945 ``<script>`` elements containing inline JavaScript.
2946
2946
2947 Note: lots of HTML content sent by the server is derived from repository
2947 Note: lots of HTML content sent by the server is derived from repository
2948 data. Please consider the potential for malicious repository data to
2948 data. Please consider the potential for malicious repository data to
2949 "inject" itself into generated HTML content as part of your security
2949 "inject" itself into generated HTML content as part of your security
2950 threat model.
2950 threat model.
2951
2951
2952 ``deny_push``
2952 ``deny_push``
2953 Whether to deny pushing to the repository. If empty or not set,
2953 Whether to deny pushing to the repository. If empty or not set,
2954 push is not denied. If the special value ``*``, all remote users are
2954 push is not denied. If the special value ``*``, all remote users are
2955 denied push. Otherwise, unauthenticated users are all denied, and
2955 denied push. Otherwise, unauthenticated users are all denied, and
2956 any authenticated user name present in this list is also denied. The
2956 any authenticated user name present in this list is also denied. The
2957 contents of the deny_push list are examined before the allow-push list.
2957 contents of the deny_push list are examined before the allow-push list.
2958
2958
2959 ``deny_read``
2959 ``deny_read``
2960 Whether to deny reading/viewing of the repository. If this list is
2960 Whether to deny reading/viewing of the repository. If this list is
2961 not empty, unauthenticated users are all denied, and any
2961 not empty, unauthenticated users are all denied, and any
2962 authenticated user name present in this list is also denied access to
2962 authenticated user name present in this list is also denied access to
2963 the repository. If set to the special value ``*``, all remote users
2963 the repository. If set to the special value ``*``, all remote users
2964 are denied access (rarely needed ;). If deny_read is empty or not set,
2964 are denied access (rarely needed ;). If deny_read is empty or not set,
2965 the determination of repository access depends on the presence and
2965 the determination of repository access depends on the presence and
2966 content of the allow_read list (see description). If both
2966 content of the allow_read list (see description). If both
2967 deny_read and allow_read are empty or not set, then access is
2967 deny_read and allow_read are empty or not set, then access is
2968 permitted to all users by default. If the repository is being
2968 permitted to all users by default. If the repository is being
2969 served via hgwebdir, denied users will not be able to see it in
2969 served via hgwebdir, denied users will not be able to see it in
2970 the list of repositories. The contents of the deny_read list have
2970 the list of repositories. The contents of the deny_read list have
2971 priority over (are examined before) the contents of the allow_read
2971 priority over (are examined before) the contents of the allow_read
2972 list.
2972 list.
2973
2973
2974 ``descend``
2974 ``descend``
2975 hgwebdir indexes will not descend into subdirectories. Only repositories
2975 hgwebdir indexes will not descend into subdirectories. Only repositories
2976 directly in the current path will be shown (other repositories are still
2976 directly in the current path will be shown (other repositories are still
2977 available from the index corresponding to their containing path).
2977 available from the index corresponding to their containing path).
2978
2978
2979 ``description``
2979 ``description``
2980 Textual description of the repository's purpose or contents.
2980 Textual description of the repository's purpose or contents.
2981 (default: "unknown")
2981 (default: "unknown")
2982
2982
2983 ``encoding``
2983 ``encoding``
2984 Character encoding name. (default: the current locale charset)
2984 Character encoding name. (default: the current locale charset)
2985 Example: "UTF-8".
2985 Example: "UTF-8".
2986
2986
2987 ``errorlog``
2987 ``errorlog``
2988 Where to output the error log. (default: stderr)
2988 Where to output the error log. (default: stderr)
2989
2989
2990 ``guessmime``
2990 ``guessmime``
2991 Control MIME types for raw download of file content.
2991 Control MIME types for raw download of file content.
2992 Set to True to let hgweb guess the content type from the file
2992 Set to True to let hgweb guess the content type from the file
2993 extension. This will serve HTML files as ``text/html`` and might
2993 extension. This will serve HTML files as ``text/html`` and might
2994 allow cross-site scripting attacks when serving untrusted
2994 allow cross-site scripting attacks when serving untrusted
2995 repositories. (default: False)
2995 repositories. (default: False)
2996
2996
2997 ``hidden``
2997 ``hidden``
2998 Whether to hide the repository in the hgwebdir index.
2998 Whether to hide the repository in the hgwebdir index.
2999 (default: False)
2999 (default: False)
3000
3000
3001 ``ipv6``
3001 ``ipv6``
3002 Whether to use IPv6. (default: False)
3002 Whether to use IPv6. (default: False)
3003
3003
3004 ``labels``
3004 ``labels``
3005 List of string *labels* associated with the repository.
3005 List of string *labels* associated with the repository.
3006
3006
3007 Labels are exposed as a template keyword and can be used to customize
3007 Labels are exposed as a template keyword and can be used to customize
3008 output. e.g. the ``index`` template can group or filter repositories
3008 output. e.g. the ``index`` template can group or filter repositories
3009 by labels and the ``summary`` template can display additional content
3009 by labels and the ``summary`` template can display additional content
3010 if a specific label is present.
3010 if a specific label is present.
3011
3011
3012 ``logoimg``
3012 ``logoimg``
3013 File name of the logo image that some templates display on each page.
3013 File name of the logo image that some templates display on each page.
3014 The file name is relative to ``staticurl``. That is, the full path to
3014 The file name is relative to ``staticurl``. That is, the full path to
3015 the logo image is "staticurl/logoimg".
3015 the logo image is "staticurl/logoimg".
3016 If unset, ``hglogo.png`` will be used.
3016 If unset, ``hglogo.png`` will be used.
3017
3017
3018 ``logourl``
3018 ``logourl``
3019 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
3019 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
3020 will be used.
3020 will be used.
3021
3021
3022 ``maxchanges``
3022 ``maxchanges``
3023 Maximum number of changes to list on the changelog. (default: 10)
3023 Maximum number of changes to list on the changelog. (default: 10)
3024
3024
3025 ``maxfiles``
3025 ``maxfiles``
3026 Maximum number of files to list per changeset. (default: 10)
3026 Maximum number of files to list per changeset. (default: 10)
3027
3027
3028 ``maxshortchanges``
3028 ``maxshortchanges``
3029 Maximum number of changes to list on the shortlog, graph or filelog
3029 Maximum number of changes to list on the shortlog, graph or filelog
3030 pages. (default: 60)
3030 pages. (default: 60)
3031
3031
3032 ``name``
3032 ``name``
3033 Repository name to use in the web interface.
3033 Repository name to use in the web interface.
3034 (default: current working directory)
3034 (default: current working directory)
3035
3035
3036 ``port``
3036 ``port``
3037 Port to listen on. (default: 8000)
3037 Port to listen on. (default: 8000)
3038
3038
3039 ``prefix``
3039 ``prefix``
3040 Prefix path to serve from. (default: '' (server root))
3040 Prefix path to serve from. (default: '' (server root))
3041
3041
3042 ``push_ssl``
3042 ``push_ssl``
3043 Whether to require that inbound pushes be transported over SSL to
3043 Whether to require that inbound pushes be transported over SSL to
3044 prevent password sniffing. (default: True)
3044 prevent password sniffing. (default: True)
3045
3045
3046 ``refreshinterval``
3046 ``refreshinterval``
3047 How frequently directory listings re-scan the filesystem for new
3047 How frequently directory listings re-scan the filesystem for new
3048 repositories, in seconds. This is relevant when wildcards are used
3048 repositories, in seconds. This is relevant when wildcards are used
3049 to define paths. Depending on how much filesystem traversal is
3049 to define paths. Depending on how much filesystem traversal is
3050 required, refreshing may negatively impact performance.
3050 required, refreshing may negatively impact performance.
3051
3051
3052 Values less than or equal to 0 always refresh.
3052 Values less than or equal to 0 always refresh.
3053 (default: 20)
3053 (default: 20)
3054
3054
3055 ``server-header``
3055 ``server-header``
3056 Value for HTTP ``Server`` response header.
3056 Value for HTTP ``Server`` response header.
3057
3057
3058 ``static``
3058 ``static``
3059 Directory where static files are served from.
3059 Directory where static files are served from.
3060
3060
3061 ``staticurl``
3061 ``staticurl``
3062 Base URL to use for static files. If unset, static files (e.g. the
3062 Base URL to use for static files. If unset, static files (e.g. the
3063 hgicon.png favicon) will be served by the CGI script itself. Use
3063 hgicon.png favicon) will be served by the CGI script itself. Use
3064 this setting to serve them directly with the HTTP server.
3064 this setting to serve them directly with the HTTP server.
3065 Example: ``http://hgserver/static/``.
3065 Example: ``http://hgserver/static/``.
3066
3066
3067 ``stripes``
3067 ``stripes``
3068 How many lines a "zebra stripe" should span in multi-line output.
3068 How many lines a "zebra stripe" should span in multi-line output.
3069 Set to 0 to disable. (default: 1)
3069 Set to 0 to disable. (default: 1)
3070
3070
3071 ``style``
3071 ``style``
3072 Which template map style to use. The available options are the names of
3072 Which template map style to use. The available options are the names of
3073 subdirectories in the HTML templates path. (default: ``paper``)
3073 subdirectories in the HTML templates path. (default: ``paper``)
3074 Example: ``monoblue``.
3074 Example: ``monoblue``.
3075
3075
3076 ``templates``
3076 ``templates``
3077 Where to find the HTML templates. The default path to the HTML templates
3077 Where to find the HTML templates. The default path to the HTML templates
3078 can be obtained from ``hg debuginstall``.
3078 can be obtained from ``hg debuginstall``.
3079
3079
3080 ``websub``
3080 ``websub``
3081 ----------
3081 ----------
3082
3082
3083 Web substitution filter definition. You can use this section to
3083 Web substitution filter definition. You can use this section to
3084 define a set of regular expression substitution patterns which
3084 define a set of regular expression substitution patterns which
3085 let you automatically modify the hgweb server output.
3085 let you automatically modify the hgweb server output.
3086
3086
3087 The default hgweb templates only apply these substitution patterns
3087 The default hgweb templates only apply these substitution patterns
3088 on the revision description fields. You can apply them anywhere
3088 on the revision description fields. You can apply them anywhere
3089 you want when you create your own templates by adding calls to the
3089 you want when you create your own templates by adding calls to the
3090 "websub" filter (usually after calling the "escape" filter).
3090 "websub" filter (usually after calling the "escape" filter).
3091
3091
3092 This can be used, for example, to convert issue references to links
3092 This can be used, for example, to convert issue references to links
3093 to your issue tracker, or to convert "markdown-like" syntax into
3093 to your issue tracker, or to convert "markdown-like" syntax into
3094 HTML (see the examples below).
3094 HTML (see the examples below).
3095
3095
3096 Each entry in this section names a substitution filter.
3096 Each entry in this section names a substitution filter.
3097 The value of each entry defines the substitution expression itself.
3097 The value of each entry defines the substitution expression itself.
3098 The websub expressions follow the old interhg extension syntax,
3098 The websub expressions follow the old interhg extension syntax,
3099 which in turn imitates the Unix sed replacement syntax::
3099 which in turn imitates the Unix sed replacement syntax::
3100
3100
3101 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
3101 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
3102
3102
3103 You can use any separator other than "/". The final "i" is optional
3103 You can use any separator other than "/". The final "i" is optional
3104 and indicates that the search must be case insensitive.
3104 and indicates that the search must be case insensitive.
3105
3105
3106 Examples::
3106 Examples::
3107
3107
3108 [websub]
3108 [websub]
3109 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
3109 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
3110 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
3110 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
3111 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
3111 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
3112
3112
3113 ``worker``
3113 ``worker``
3114 ----------
3114 ----------
3115
3115
3116 Parallel master/worker configuration. We currently perform working
3116 Parallel master/worker configuration. We currently perform working
3117 directory updates in parallel on Unix-like systems, which greatly
3117 directory updates in parallel on Unix-like systems, which greatly
3118 helps performance.
3118 helps performance.
3119
3119
3120 ``enabled``
3120 ``enabled``
3121 Whether to enable workers code to be used.
3121 Whether to enable workers code to be used.
3122 (default: true)
3122 (default: true)
3123
3123
3124 ``numcpus``
3124 ``numcpus``
3125 Number of CPUs to use for parallel operations. A zero or
3125 Number of CPUs to use for parallel operations. A zero or
3126 negative value is treated as ``use the default``.
3126 negative value is treated as ``use the default``.
3127 (default: 4 or the number of CPUs on the system, whichever is larger)
3127 (default: 4 or the number of CPUs on the system, whichever is larger)
3128
3128
3129 ``backgroundclose``
3129 ``backgroundclose``
3130 Whether to enable closing file handles on background threads during certain
3130 Whether to enable closing file handles on background threads during certain
3131 operations. Some platforms aren't very efficient at closing file
3131 operations. Some platforms aren't very efficient at closing file
3132 handles that have been written or appended to. By performing file closing
3132 handles that have been written or appended to. By performing file closing
3133 on background threads, file write rate can increase substantially.
3133 on background threads, file write rate can increase substantially.
3134 (default: true on Windows, false elsewhere)
3134 (default: true on Windows, false elsewhere)
3135
3135
3136 ``backgroundcloseminfilecount``
3136 ``backgroundcloseminfilecount``
3137 Minimum number of files required to trigger background file closing.
3137 Minimum number of files required to trigger background file closing.
3138 Operations not writing this many files won't start background close
3138 Operations not writing this many files won't start background close
3139 threads.
3139 threads.
3140 (default: 2048)
3140 (default: 2048)
3141
3141
3142 ``backgroundclosemaxqueue``
3142 ``backgroundclosemaxqueue``
3143 The maximum number of opened file handles waiting to be closed in the
3143 The maximum number of opened file handles waiting to be closed in the
3144 background. This option only has an effect if ``backgroundclose`` is
3144 background. This option only has an effect if ``backgroundclose`` is
3145 enabled.
3145 enabled.
3146 (default: 384)
3146 (default: 384)
3147
3147
3148 ``backgroundclosethreadcount``
3148 ``backgroundclosethreadcount``
3149 Number of threads to process background file closes. Only relevant if
3149 Number of threads to process background file closes. Only relevant if
3150 ``backgroundclose`` is enabled.
3150 ``backgroundclose`` is enabled.
3151 (default: 4)
3151 (default: 4)
@@ -1,616 +1,616 b''
1 The *dirstate* is what Mercurial uses internally to track
1 The *dirstate* is what Mercurial uses internally to track
2 the state of files in the working directory,
2 the state of files in the working directory,
3 such as set by commands like `hg add` and `hg rm`.
3 such as set by commands like `hg add` and `hg rm`.
4 It also contains some cached data that help make `hg status` faster.
4 It also contains some cached data that help make `hg status` faster.
5 The name refers both to `.hg/dirstate` on the filesystem
5 The name refers both to `.hg/dirstate` on the filesystem
6 and the corresponding data structure in memory while a Mercurial process
6 and the corresponding data structure in memory while a Mercurial process
7 is running.
7 is running.
8
8
9 The original file format, retroactively dubbed `dirstate-v1`,
9 The original file format, retroactively dubbed `dirstate-v1`,
10 is described at https://www.mercurial-scm.org/wiki/DirState.
10 is described at https://www.mercurial-scm.org/wiki/DirState.
11 It is made of a flat sequence of unordered variable-size entries,
11 It is made of a flat sequence of unordered variable-size entries,
12 so accessing any information in it requires parsing all of it.
12 so accessing any information in it requires parsing all of it.
13 Similarly, saving changes requires rewriting the entire file.
13 Similarly, saving changes requires rewriting the entire file.
14
14
15 The newer `dirstate-v2` file format is designed to fix these limitations
15 The newer `dirstate-v2` file format is designed to fix these limitations
16 and make `hg status` faster.
16 and make `hg status` faster.
17
17
18 User guide
18 User guide
19 ==========
19 ==========
20
20
21 Compatibility
21 Compatibility
22 -------------
22 -------------
23
23
24 The file format is experimental and may still change.
24 The file format is experimental and may still change.
25 Different versions of Mercurial may not be compatible with each other
25 Different versions of Mercurial may not be compatible with each other
26 when working on a local repository that uses this format.
26 when working on a local repository that uses this format.
27 When using an incompatible version with the experimental format,
27 When using an incompatible version with the experimental format,
28 anything can happen including data corruption.
28 anything can happen including data corruption.
29
29
30 Since the dirstate is entirely local and not relevant to the wire protocol,
30 Since the dirstate is entirely local and not relevant to the wire protocol,
31 `dirstate-v2` does not affect compatibility with remote Mercurial versions.
31 `dirstate-v2` does not affect compatibility with remote Mercurial versions.
32
32
33 When `share-safe` is enabled, different repositories sharing the same store
33 When `share-safe` is enabled, different repositories sharing the same store
34 can use different dirstate formats.
34 can use different dirstate formats.
35
35
36 Enabling `dirstate-v2` for new local repositories
36 Enabling `dirstate-v2` for new local repositories
37 ------------------------------------------------
37 ------------------------------------------------
38
38
39 When creating a new local repository such as with `hg init` or `hg clone`,
39 When creating a new local repository such as with `hg init` or `hg clone`,
40 the `exp-rc-dirstate-v2` boolean in the `format` configuration section
40 the `use-dirstate-v2` boolean in the `format` configuration section
41 controls whether to use this file format.
41 controls whether to use this file format.
42 This is disabled by default as of this writing.
42 This is disabled by default as of this writing.
43 To enable it for a single repository, run for example::
43 To enable it for a single repository, run for example::
44
44
45 $ hg init my-project --config format.exp-rc-dirstate-v2=1
45 $ hg init my-project --config format.use-dirstate-v2=1
46
46
47 Checking the format of an existing local repository
47 Checking the format of an existing local repository
48 --------------------------------------------------
48 --------------------------------------------------
49
49
50 The `debugformat` commands prints information about
50 The `debugformat` commands prints information about
51 which of multiple optional formats are used in the current repository,
51 which of multiple optional formats are used in the current repository,
52 including `dirstate-v2`::
52 including `dirstate-v2`::
53
53
54 $ hg debugformat
54 $ hg debugformat
55 format-variant repo
55 format-variant repo
56 fncache: yes
56 fncache: yes
57 dirstate-v2: yes
57 dirstate-v2: yes
58 […]
58 […]
59
59
60 Upgrading or downgrading an existing local repository
60 Upgrading or downgrading an existing local repository
61 -----------------------------------------------------
61 -----------------------------------------------------
62
62
63 The `debugupgrade` command does various upgrades or downgrades
63 The `debugupgrade` command does various upgrades or downgrades
64 on a local repository
64 on a local repository
65 based on the current Mercurial version and on configuration.
65 based on the current Mercurial version and on configuration.
66 The same `format.exp-rc-dirstate-v2` configuration is used again.
66 The same `format.use-dirstate-v2` configuration is used again.
67
67
68 Example to upgrade::
68 Example to upgrade::
69
69
70 $ hg debugupgrade --config format.exp-rc-dirstate-v2=1
70 $ hg debugupgrade --config format.use-dirstate-v2=1
71
71
72 Example to downgrade to `dirstate-v1`::
72 Example to downgrade to `dirstate-v1`::
73
73
74 $ hg debugupgrade --config format.exp-rc-dirstate-v2=0
74 $ hg debugupgrade --config format.use-dirstate-v2=0
75
75
76 Both of this commands do nothing but print a list of proposed changes,
76 Both of this commands do nothing but print a list of proposed changes,
77 which may include changes unrelated to the dirstate.
77 which may include changes unrelated to the dirstate.
78 Those other changes are controlled by their own configuration keys.
78 Those other changes are controlled by their own configuration keys.
79 Add `--run` to a command to actually apply the proposed changes.
79 Add `--run` to a command to actually apply the proposed changes.
80
80
81 Backups of `.hg/requires` and `.hg/dirstate` are created
81 Backups of `.hg/requires` and `.hg/dirstate` are created
82 in a `.hg/upgradebackup.*` directory.
82 in a `.hg/upgradebackup.*` directory.
83 If something goes wrong, restoring those files should undo the change.
83 If something goes wrong, restoring those files should undo the change.
84
84
85 Note that upgrading affects compatibility with older versions of Mercurial
85 Note that upgrading affects compatibility with older versions of Mercurial
86 as noted above.
86 as noted above.
87 This can be relevant when a repository’s files are on a USB drive
87 This can be relevant when a repository’s files are on a USB drive
88 or some other removable media, or shared over the network, etc.
88 or some other removable media, or shared over the network, etc.
89
89
90 Internal filesystem representation
90 Internal filesystem representation
91 ==================================
91 ==================================
92
92
93 Requirements file
93 Requirements file
94 -----------------
94 -----------------
95
95
96 The `.hg/requires` file indicates which of various optional file formats
96 The `.hg/requires` file indicates which of various optional file formats
97 are used by a given repository.
97 are used by a given repository.
98 Mercurial aborts when seeing a requirement it does not know about,
98 Mercurial aborts when seeing a requirement it does not know about,
99 which avoids older version accidentally messing up a repository
99 which avoids older version accidentally messing up a repository
100 that uses a format that was introduced later.
100 that uses a format that was introduced later.
101 For versions that do support a format, the presence or absence of
101 For versions that do support a format, the presence or absence of
102 the corresponding requirement indicates whether to use that format.
102 the corresponding requirement indicates whether to use that format.
103
103
104 When the file contains a `dirstate-v2` line,
104 When the file contains a `dirstate-v2` line,
105 the `dirstate-v2` format is used.
105 the `dirstate-v2` format is used.
106 With no such line `dirstate-v1` is used.
106 With no such line `dirstate-v1` is used.
107
107
108 High level description
108 High level description
109 ----------------------
109 ----------------------
110
110
111 Whereas `dirstate-v1` uses a single `.hg/dirstate` file,
111 Whereas `dirstate-v1` uses a single `.hg/dirstate` file,
112 in `dirstate-v2` that file is a "docket" file
112 in `dirstate-v2` that file is a "docket" file
113 that only contains some metadata
113 that only contains some metadata
114 and points to separate data file named `.hg/dirstate.{ID}`,
114 and points to separate data file named `.hg/dirstate.{ID}`,
115 where `{ID}` is a random identifier.
115 where `{ID}` is a random identifier.
116
116
117 This separation allows making data files append-only
117 This separation allows making data files append-only
118 and therefore safer to memory-map.
118 and therefore safer to memory-map.
119 Creating a new data file (occasionally to clean up unused data)
119 Creating a new data file (occasionally to clean up unused data)
120 can be done with a different ID
120 can be done with a different ID
121 without disrupting another Mercurial process
121 without disrupting another Mercurial process
122 that could still be using the previous data file.
122 that could still be using the previous data file.
123
123
124 Both files have a format designed to reduce the need for parsing,
124 Both files have a format designed to reduce the need for parsing,
125 by using fixed-size binary components as much as possible.
125 by using fixed-size binary components as much as possible.
126 For data that is not fixed-size,
126 For data that is not fixed-size,
127 references to other parts of a file can be made by storing "pseudo-pointers":
127 references to other parts of a file can be made by storing "pseudo-pointers":
128 integers counted in bytes from the start of a file.
128 integers counted in bytes from the start of a file.
129 For read-only access no data structure is needed,
129 For read-only access no data structure is needed,
130 only a bytes buffer (possibly memory-mapped directly from the filesystem)
130 only a bytes buffer (possibly memory-mapped directly from the filesystem)
131 with specific parts read on demand.
131 with specific parts read on demand.
132
132
133 The data file contains "nodes" organized in a tree.
133 The data file contains "nodes" organized in a tree.
134 Each node represents a file or directory inside the working directory
134 Each node represents a file or directory inside the working directory
135 or its parent changeset.
135 or its parent changeset.
136 This tree has the same structure as the filesystem,
136 This tree has the same structure as the filesystem,
137 so a node representing a directory has child nodes representing
137 so a node representing a directory has child nodes representing
138 the files and subdirectories contained directly in that directory.
138 the files and subdirectories contained directly in that directory.
139
139
140 The docket file format
140 The docket file format
141 ----------------------
141 ----------------------
142
142
143 This is implemented in `rust/hg-core/src/dirstate_tree/on_disk.rs`
143 This is implemented in `rust/hg-core/src/dirstate_tree/on_disk.rs`
144 and `mercurial/dirstateutils/docket.py`.
144 and `mercurial/dirstateutils/docket.py`.
145
145
146 Components of the docket file are found at fixed offsets,
146 Components of the docket file are found at fixed offsets,
147 counted in bytes from the start of the file:
147 counted in bytes from the start of the file:
148
148
149 * Offset 0:
149 * Offset 0:
150 The 12-bytes marker string "dirstate-v2\n" ending with a newline character.
150 The 12-bytes marker string "dirstate-v2\n" ending with a newline character.
151 This makes it easier to tell a dirstate-v2 file from a dirstate-v1 file,
151 This makes it easier to tell a dirstate-v2 file from a dirstate-v1 file,
152 although it is not strictly necessary
152 although it is not strictly necessary
153 since `.hg/requires` determines which format to use.
153 since `.hg/requires` determines which format to use.
154
154
155 * Offset 12:
155 * Offset 12:
156 The changeset node ID on the first parent of the working directory,
156 The changeset node ID on the first parent of the working directory,
157 as up to 32 binary bytes.
157 as up to 32 binary bytes.
158 If a node ID is shorter (20 bytes for SHA-1),
158 If a node ID is shorter (20 bytes for SHA-1),
159 it is start-aligned and the rest of the bytes are set to zero.
159 it is start-aligned and the rest of the bytes are set to zero.
160
160
161 * Offset 44:
161 * Offset 44:
162 The changeset node ID on the second parent of the working directory,
162 The changeset node ID on the second parent of the working directory,
163 or all zeros if there isn’t one.
163 or all zeros if there isn’t one.
164 Also 32 binary bytes.
164 Also 32 binary bytes.
165
165
166 * Offset 76:
166 * Offset 76:
167 Tree metadata on 44 bytes, described below.
167 Tree metadata on 44 bytes, described below.
168 Its separation in this documentation from the rest of the docket
168 Its separation in this documentation from the rest of the docket
169 reflects a detail of the current implementation.
169 reflects a detail of the current implementation.
170 Since tree metadata is also made of fields at fixed offsets, those could
170 Since tree metadata is also made of fields at fixed offsets, those could
171 be inlined here by adding 76 bytes to each offset.
171 be inlined here by adding 76 bytes to each offset.
172
172
173 * Offset 120:
173 * Offset 120:
174 The used size of the data file, as a 32-bit big-endian integer.
174 The used size of the data file, as a 32-bit big-endian integer.
175 The actual size of the data file may be larger
175 The actual size of the data file may be larger
176 (if another Mercurial process is appending to it
176 (if another Mercurial process is appending to it
177 but has not updated the docket yet).
177 but has not updated the docket yet).
178 That extra data must be ignored.
178 That extra data must be ignored.
179
179
180 * Offset 124:
180 * Offset 124:
181 The length of the data file identifier, as a 8-bit integer.
181 The length of the data file identifier, as a 8-bit integer.
182
182
183 * Offset 125:
183 * Offset 125:
184 The data file identifier.
184 The data file identifier.
185
185
186 * Any additional data is current ignored, and dropped when updating the file.
186 * Any additional data is current ignored, and dropped when updating the file.
187
187
188 Tree metadata in the docket file
188 Tree metadata in the docket file
189 --------------------------------
189 --------------------------------
190
190
191 Tree metadata is similarly made of components at fixed offsets.
191 Tree metadata is similarly made of components at fixed offsets.
192 These offsets are counted in bytes from the start of tree metadata,
192 These offsets are counted in bytes from the start of tree metadata,
193 which is 76 bytes after the start of the docket file.
193 which is 76 bytes after the start of the docket file.
194
194
195 This metadata can be thought of as the singular root of the tree
195 This metadata can be thought of as the singular root of the tree
196 formed by nodes in the data file.
196 formed by nodes in the data file.
197
197
198 * Offset 0:
198 * Offset 0:
199 Pseudo-pointer to the start of root nodes,
199 Pseudo-pointer to the start of root nodes,
200 counted in bytes from the start of the data file,
200 counted in bytes from the start of the data file,
201 as a 32-bit big-endian integer.
201 as a 32-bit big-endian integer.
202 These nodes describe files and directories found directly
202 These nodes describe files and directories found directly
203 at the root of the working directory.
203 at the root of the working directory.
204
204
205 * Offset 4:
205 * Offset 4:
206 Number of root nodes, as a 32-bit big-endian integer.
206 Number of root nodes, as a 32-bit big-endian integer.
207
207
208 * Offset 8:
208 * Offset 8:
209 Total number of nodes in the entire tree that "have a dirstate entry",
209 Total number of nodes in the entire tree that "have a dirstate entry",
210 as a 32-bit big-endian integer.
210 as a 32-bit big-endian integer.
211 Those nodes represent files that would be present at all in `dirstate-v1`.
211 Those nodes represent files that would be present at all in `dirstate-v1`.
212 This is typically less than the total number of nodes.
212 This is typically less than the total number of nodes.
213 This counter is used to implement `len(dirstatemap)`.
213 This counter is used to implement `len(dirstatemap)`.
214
214
215 * Offset 12:
215 * Offset 12:
216 Number of nodes in the entire tree that have a copy source,
216 Number of nodes in the entire tree that have a copy source,
217 as a 32-bit big-endian integer.
217 as a 32-bit big-endian integer.
218 At the next commit, these files are recorded
218 At the next commit, these files are recorded
219 as having been copied or moved/renamed from that source.
219 as having been copied or moved/renamed from that source.
220 (A move is recorded as a copy and separate removal of the source.)
220 (A move is recorded as a copy and separate removal of the source.)
221 This counter is used to implement `len(dirstatemap.copymap)`.
221 This counter is used to implement `len(dirstatemap.copymap)`.
222
222
223 * Offset 16:
223 * Offset 16:
224 An estimation of how many bytes of the data file
224 An estimation of how many bytes of the data file
225 (within its used size) are unused, as a 32-bit big-endian integer.
225 (within its used size) are unused, as a 32-bit big-endian integer.
226 When appending to an existing data file,
226 When appending to an existing data file,
227 some existing nodes or paths can be unreachable from the new root
227 some existing nodes or paths can be unreachable from the new root
228 but they still take up space.
228 but they still take up space.
229 This counter is used to decide when to write a new data file from scratch
229 This counter is used to decide when to write a new data file from scratch
230 instead of appending to an existing one,
230 instead of appending to an existing one,
231 in order to get rid of that unreachable data
231 in order to get rid of that unreachable data
232 and avoid unbounded file size growth.
232 and avoid unbounded file size growth.
233
233
234 * Offset 20:
234 * Offset 20:
235 These four bytes are currently ignored
235 These four bytes are currently ignored
236 and reset to zero when updating a docket file.
236 and reset to zero when updating a docket file.
237 This is an attempt at forward compatibility:
237 This is an attempt at forward compatibility:
238 future Mercurial versions could use this as a bit field
238 future Mercurial versions could use this as a bit field
239 to indicate that a dirstate has additional data or constraints.
239 to indicate that a dirstate has additional data or constraints.
240 Finding a dirstate file with the relevant bit unset indicates that
240 Finding a dirstate file with the relevant bit unset indicates that
241 it was written by a then-older version
241 it was written by a then-older version
242 which is not aware of that future change.
242 which is not aware of that future change.
243
243
244 * Offset 24:
244 * Offset 24:
245 Either 20 zero bytes, or a SHA-1 hash as 20 binary bytes.
245 Either 20 zero bytes, or a SHA-1 hash as 20 binary bytes.
246 When present, the hash is of ignore patterns
246 When present, the hash is of ignore patterns
247 that were used for some previous run of the `status` algorithm.
247 that were used for some previous run of the `status` algorithm.
248
248
249 * (Offset 44: end of tree metadata)
249 * (Offset 44: end of tree metadata)
250
250
251 Optional hash of ignore patterns
251 Optional hash of ignore patterns
252 --------------------------------
252 --------------------------------
253
253
254 The implementation of `status` at `rust/hg-core/src/dirstate_tree/status.rs`
254 The implementation of `status` at `rust/hg-core/src/dirstate_tree/status.rs`
255 has been optimized such that its run time is dominated by calls
255 has been optimized such that its run time is dominated by calls
256 to `stat` for reading the filesystem metadata of a file or directory,
256 to `stat` for reading the filesystem metadata of a file or directory,
257 and to `readdir` for listing the contents of a directory.
257 and to `readdir` for listing the contents of a directory.
258 In some cases the algorithm can skip calls to `readdir`
258 In some cases the algorithm can skip calls to `readdir`
259 (saving significant time)
259 (saving significant time)
260 because the dirstate already contains enough of the relevant information
260 because the dirstate already contains enough of the relevant information
261 to build the correct `status` results.
261 to build the correct `status` results.
262
262
263 The default configuration of `hg status` is to list unknown files
263 The default configuration of `hg status` is to list unknown files
264 but not ignored files.
264 but not ignored files.
265 In this case, it matters for the `readdir`-skipping optimization
265 In this case, it matters for the `readdir`-skipping optimization
266 if a given file used to be ignored but became unknown
266 if a given file used to be ignored but became unknown
267 because `.hgignore` changed.
267 because `.hgignore` changed.
268 To detect the possibility of such a change,
268 To detect the possibility of such a change,
269 the tree metadata contains an optional hash of all ignore patterns.
269 the tree metadata contains an optional hash of all ignore patterns.
270
270
271 We define:
271 We define:
272
272
273 * "Root" ignore files as:
273 * "Root" ignore files as:
274
274
275 - `.hgignore` at the root of the repository if it exists
275 - `.hgignore` at the root of the repository if it exists
276 - And all files from `ui.ignore.*` config.
276 - And all files from `ui.ignore.*` config.
277
277
278 This set of files is sorted by the string representation of their path.
278 This set of files is sorted by the string representation of their path.
279
279
280 * The "expanded contents" of an ignore files is the byte string made
280 * The "expanded contents" of an ignore files is the byte string made
281 by the concatenation of its contents followed by the "expanded contents"
281 by the concatenation of its contents followed by the "expanded contents"
282 of other files included with `include:` or `subinclude:` directives,
282 of other files included with `include:` or `subinclude:` directives,
283 in inclusion order. This definition is recursive, as included files can
283 in inclusion order. This definition is recursive, as included files can
284 themselves include more files.
284 themselves include more files.
285
285
286 This hash is defined as the SHA-1 of the concatenation (in sorted
286 This hash is defined as the SHA-1 of the concatenation (in sorted
287 order) of the "expanded contents" of each "root" ignore file.
287 order) of the "expanded contents" of each "root" ignore file.
288 (Note that computing this does not require actually concatenating
288 (Note that computing this does not require actually concatenating
289 into a single contiguous byte sequence.
289 into a single contiguous byte sequence.
290 Instead a SHA-1 hasher object can be created
290 Instead a SHA-1 hasher object can be created
291 and fed separate chunks one by one.)
291 and fed separate chunks one by one.)
292
292
293 The data file format
293 The data file format
294 --------------------
294 --------------------
295
295
296 This is implemented in `rust/hg-core/src/dirstate_tree/on_disk.rs`
296 This is implemented in `rust/hg-core/src/dirstate_tree/on_disk.rs`
297 and `mercurial/dirstateutils/v2.py`.
297 and `mercurial/dirstateutils/v2.py`.
298
298
299 The data file contains two types of data: paths and nodes.
299 The data file contains two types of data: paths and nodes.
300
300
301 Paths and nodes can be organized in any order in the file, except that sibling
301 Paths and nodes can be organized in any order in the file, except that sibling
302 nodes must be next to each other and sorted by their path.
302 nodes must be next to each other and sorted by their path.
303 Contiguity lets the parent refer to them all
303 Contiguity lets the parent refer to them all
304 by their count and a single pseudo-pointer,
304 by their count and a single pseudo-pointer,
305 instead of storing one pseudo-pointer per child node.
305 instead of storing one pseudo-pointer per child node.
306 Sorting allows using binary search to find a child node with a given name
306 Sorting allows using binary search to find a child node with a given name
307 in `O(log(n))` byte sequence comparisons.
307 in `O(log(n))` byte sequence comparisons.
308
308
309 The current implementation writes paths and child node before a given node
309 The current implementation writes paths and child node before a given node
310 for ease of figuring out the value of pseudo-pointers by the time the are to be
310 for ease of figuring out the value of pseudo-pointers by the time the are to be
311 written, but this is not an obligation and readers must not rely on it.
311 written, but this is not an obligation and readers must not rely on it.
312
312
313 A path is stored as a byte string anywhere in the file, without delimiter.
313 A path is stored as a byte string anywhere in the file, without delimiter.
314 It is referred to by one or more node by a pseudo-pointer to its start, and its
314 It is referred to by one or more node by a pseudo-pointer to its start, and its
315 length in bytes. Since there is no delimiter,
315 length in bytes. Since there is no delimiter,
316 when a path is a substring of another the same bytes could be reused,
316 when a path is a substring of another the same bytes could be reused,
317 although the implementation does not exploit this as of this writing.
317 although the implementation does not exploit this as of this writing.
318
318
319 A node is stored on 43 bytes with components at fixed offsets. Paths and
319 A node is stored on 43 bytes with components at fixed offsets. Paths and
320 child nodes relevant to a node are stored externally and referenced though
320 child nodes relevant to a node are stored externally and referenced though
321 pseudo-pointers.
321 pseudo-pointers.
322
322
323 All integers are stored in big-endian. All pseudo-pointers are 32-bit integers
323 All integers are stored in big-endian. All pseudo-pointers are 32-bit integers
324 counting bytes from the start of the data file. Path lengths and positions
324 counting bytes from the start of the data file. Path lengths and positions
325 are 16-bit integers, also counted in bytes.
325 are 16-bit integers, also counted in bytes.
326
326
327 Node components are:
327 Node components are:
328
328
329 * Offset 0:
329 * Offset 0:
330 Pseudo-pointer to the full path of this node,
330 Pseudo-pointer to the full path of this node,
331 from the working directory root.
331 from the working directory root.
332
332
333 * Offset 4:
333 * Offset 4:
334 Length of the full path.
334 Length of the full path.
335
335
336 * Offset 6:
336 * Offset 6:
337 Position of the last `/` path separator within the full path,
337 Position of the last `/` path separator within the full path,
338 in bytes from the start of the full path,
338 in bytes from the start of the full path,
339 or zero if there isn’t one.
339 or zero if there isn’t one.
340 The part of the full path after this position is the "base name".
340 The part of the full path after this position is the "base name".
341 Since sibling nodes have the same parent, only their base name vary
341 Since sibling nodes have the same parent, only their base name vary
342 and needs to be considered when doing binary search to find a given path.
342 and needs to be considered when doing binary search to find a given path.
343
343
344 * Offset 8:
344 * Offset 8:
345 Pseudo-pointer to the "copy source" path for this node,
345 Pseudo-pointer to the "copy source" path for this node,
346 or zero if there is no copy source.
346 or zero if there is no copy source.
347
347
348 * Offset 12:
348 * Offset 12:
349 Length of the copy source path, or zero if there isn’t one.
349 Length of the copy source path, or zero if there isn’t one.
350
350
351 * Offset 14:
351 * Offset 14:
352 Pseudo-pointer to the start of child nodes.
352 Pseudo-pointer to the start of child nodes.
353
353
354 * Offset 18:
354 * Offset 18:
355 Number of child nodes, as a 32-bit integer.
355 Number of child nodes, as a 32-bit integer.
356 They occupy 43 times this number of bytes
356 They occupy 43 times this number of bytes
357 (not counting space for paths, and further descendants).
357 (not counting space for paths, and further descendants).
358
358
359 * Offset 22:
359 * Offset 22:
360 Number as a 32-bit integer of descendant nodes in this subtree,
360 Number as a 32-bit integer of descendant nodes in this subtree,
361 not including this node itself,
361 not including this node itself,
362 that "have a dirstate entry".
362 that "have a dirstate entry".
363 Those nodes represent files that would be present at all in `dirstate-v1`.
363 Those nodes represent files that would be present at all in `dirstate-v1`.
364 This is typically less than the total number of descendants.
364 This is typically less than the total number of descendants.
365 This counter is used to implement `has_dir`.
365 This counter is used to implement `has_dir`.
366
366
367 * Offset 26:
367 * Offset 26:
368 Number as a 32-bit integer of descendant nodes in this subtree,
368 Number as a 32-bit integer of descendant nodes in this subtree,
369 not including this node itself,
369 not including this node itself,
370 that represent files tracked in the working directory.
370 that represent files tracked in the working directory.
371 (For example, `hg rm` makes a file untracked.)
371 (For example, `hg rm` makes a file untracked.)
372 This counter is used to implement `has_tracked_dir`.
372 This counter is used to implement `has_tracked_dir`.
373
373
374 * Offset 30:
374 * Offset 30:
375 A `flags` fields that packs some boolean values as bits of a 16-bit integer.
375 A `flags` fields that packs some boolean values as bits of a 16-bit integer.
376 Starting from least-significant, bit masks are::
376 Starting from least-significant, bit masks are::
377
377
378 WDIR_TRACKED = 1 << 0
378 WDIR_TRACKED = 1 << 0
379 P1_TRACKED = 1 << 1
379 P1_TRACKED = 1 << 1
380 P2_INFO = 1 << 2
380 P2_INFO = 1 << 2
381 MODE_EXEC_PERM = 1 << 3
381 MODE_EXEC_PERM = 1 << 3
382 MODE_IS_SYMLINK = 1 << 4
382 MODE_IS_SYMLINK = 1 << 4
383 HAS_FALLBACK_EXEC = 1 << 5
383 HAS_FALLBACK_EXEC = 1 << 5
384 FALLBACK_EXEC = 1 << 6
384 FALLBACK_EXEC = 1 << 6
385 HAS_FALLBACK_SYMLINK = 1 << 7
385 HAS_FALLBACK_SYMLINK = 1 << 7
386 FALLBACK_SYMLINK = 1 << 8
386 FALLBACK_SYMLINK = 1 << 8
387 EXPECTED_STATE_IS_MODIFIED = 1 << 9
387 EXPECTED_STATE_IS_MODIFIED = 1 << 9
388 HAS_MODE_AND_SIZE = 1 << 10
388 HAS_MODE_AND_SIZE = 1 << 10
389 HAS_MTIME = 1 << 11
389 HAS_MTIME = 1 << 11
390 MTIME_SECOND_AMBIGUOUS = 1 << 12
390 MTIME_SECOND_AMBIGUOUS = 1 << 12
391 DIRECTORY = 1 << 13
391 DIRECTORY = 1 << 13
392 ALL_UNKNOWN_RECORDED = 1 << 14
392 ALL_UNKNOWN_RECORDED = 1 << 14
393 ALL_IGNORED_RECORDED = 1 << 15
393 ALL_IGNORED_RECORDED = 1 << 15
394
394
395 The meaning of each bit is described below.
395 The meaning of each bit is described below.
396
396
397 Other bits are unset.
397 Other bits are unset.
398 They may be assigned meaning if the future,
398 They may be assigned meaning if the future,
399 with the limitation that Mercurial versions that pre-date such meaning
399 with the limitation that Mercurial versions that pre-date such meaning
400 will always reset those bits to unset when writing nodes.
400 will always reset those bits to unset when writing nodes.
401 (A new node is written for any mutation in its subtree,
401 (A new node is written for any mutation in its subtree,
402 leaving the bytes of the old node unreachable
402 leaving the bytes of the old node unreachable
403 until the data file is rewritten entirely.)
403 until the data file is rewritten entirely.)
404
404
405 * Offset 32:
405 * Offset 32:
406 A `size` field described below, as a 32-bit integer.
406 A `size` field described below, as a 32-bit integer.
407 Unlike in dirstate-v1, negative values are not used.
407 Unlike in dirstate-v1, negative values are not used.
408
408
409 * Offset 36:
409 * Offset 36:
410 The seconds component of an `mtime` field described below,
410 The seconds component of an `mtime` field described below,
411 as a 32-bit integer.
411 as a 32-bit integer.
412 Unlike in dirstate-v1, negative values are not used.
412 Unlike in dirstate-v1, negative values are not used.
413 When `mtime` is used, this is number of seconds since the Unix epoch
413 When `mtime` is used, this is number of seconds since the Unix epoch
414 truncated to its lower 31 bits.
414 truncated to its lower 31 bits.
415
415
416 * Offset 40:
416 * Offset 40:
417 The nanoseconds component of an `mtime` field described below,
417 The nanoseconds component of an `mtime` field described below,
418 as a 32-bit integer.
418 as a 32-bit integer.
419 When `mtime` is used,
419 When `mtime` is used,
420 this is the number of nanoseconds since `mtime.seconds`,
420 this is the number of nanoseconds since `mtime.seconds`,
421 always strictly less than one billion.
421 always strictly less than one billion.
422
422
423 This may be zero if more precision is not available.
423 This may be zero if more precision is not available.
424 (This can happen because of limitations in any of Mercurial, Python,
424 (This can happen because of limitations in any of Mercurial, Python,
425 libc, the operating system, …)
425 libc, the operating system, …)
426
426
427 When comparing two mtimes and either has this component set to zero,
427 When comparing two mtimes and either has this component set to zero,
428 the sub-second precision of both should be ignored.
428 the sub-second precision of both should be ignored.
429 False positives when checking mtime equality due to clock resolution
429 False positives when checking mtime equality due to clock resolution
430 are always possible and the status algorithm needs to deal with them,
430 are always possible and the status algorithm needs to deal with them,
431 but having too many false negatives could be harmful too.
431 but having too many false negatives could be harmful too.
432
432
433 * (Offset 44: end of this node)
433 * (Offset 44: end of this node)
434
434
435 The meaning of the boolean values packed in `flags` is:
435 The meaning of the boolean values packed in `flags` is:
436
436
437 `WDIR_TRACKED`
437 `WDIR_TRACKED`
438 Set if the working directory contains a tracked file at this node’s path.
438 Set if the working directory contains a tracked file at this node’s path.
439 This is typically set and unset by `hg add` and `hg rm`.
439 This is typically set and unset by `hg add` and `hg rm`.
440
440
441 `P1_TRACKED`
441 `P1_TRACKED`
442 Set if the working directory’s first parent changeset
442 Set if the working directory’s first parent changeset
443 (whose node identifier is found in tree metadata)
443 (whose node identifier is found in tree metadata)
444 contains a tracked file at this node’s path.
444 contains a tracked file at this node’s path.
445 This is a cache to reduce manifest lookups.
445 This is a cache to reduce manifest lookups.
446
446
447 `P2_INFO`
447 `P2_INFO`
448 Set if the file has been involved in some merge operation.
448 Set if the file has been involved in some merge operation.
449 Either because it was actually merged,
449 Either because it was actually merged,
450 or because the version in the second parent p2 version was ahead,
450 or because the version in the second parent p2 version was ahead,
451 or because some rename moved it there.
451 or because some rename moved it there.
452 In either case `hg status` will want it displayed as modified.
452 In either case `hg status` will want it displayed as modified.
453
453
454 Files that would be mentioned at all in the `dirstate-v1` file format
454 Files that would be mentioned at all in the `dirstate-v1` file format
455 have a node with at least one of the above three bits set in `dirstate-v2`.
455 have a node with at least one of the above three bits set in `dirstate-v2`.
456 Let’s call these files "tracked anywhere",
456 Let’s call these files "tracked anywhere",
457 and "untracked" the nodes with all three of these bits unset.
457 and "untracked" the nodes with all three of these bits unset.
458 Untracked nodes are typically for directories:
458 Untracked nodes are typically for directories:
459 they hold child nodes and form the tree structure.
459 they hold child nodes and form the tree structure.
460 Additional untracked nodes may also exist.
460 Additional untracked nodes may also exist.
461 Although implementations should strive to clean up nodes
461 Although implementations should strive to clean up nodes
462 that are entirely unused, other untracked nodes may also exist.
462 that are entirely unused, other untracked nodes may also exist.
463 For example, a future version of Mercurial might in some cases
463 For example, a future version of Mercurial might in some cases
464 add nodes for untracked files or/and ignored files in the working directory
464 add nodes for untracked files or/and ignored files in the working directory
465 in order to optimize `hg status`
465 in order to optimize `hg status`
466 by enabling it to skip `readdir` in more cases.
466 by enabling it to skip `readdir` in more cases.
467
467
468 `HAS_MODE_AND_SIZE`
468 `HAS_MODE_AND_SIZE`
469 Must be unset for untracked nodes.
469 Must be unset for untracked nodes.
470 For files tracked anywhere, if this is set:
470 For files tracked anywhere, if this is set:
471 - The `size` field is the expected file size,
471 - The `size` field is the expected file size,
472 in bytes truncated its lower to 31 bits.
472 in bytes truncated its lower to 31 bits.
473 - The expected execute permission for the file’s owner
473 - The expected execute permission for the file’s owner
474 is given by `MODE_EXEC_PERM`
474 is given by `MODE_EXEC_PERM`
475 - The expected file type is given by `MODE_IS_SIMLINK`:
475 - The expected file type is given by `MODE_IS_SIMLINK`:
476 a symbolic link if set, or a normal file if unset.
476 a symbolic link if set, or a normal file if unset.
477 If this is unset the expected size, permission, and file type are unknown.
477 If this is unset the expected size, permission, and file type are unknown.
478 The `size` field is unused (set to zero).
478 The `size` field is unused (set to zero).
479
479
480 `HAS_MTIME`
480 `HAS_MTIME`
481 The nodes contains a "valid" last modification time in the `mtime` field.
481 The nodes contains a "valid" last modification time in the `mtime` field.
482
482
483
483
484 It means the `mtime` was already strictly in the past when observed,
484 It means the `mtime` was already strictly in the past when observed,
485 meaning that later changes cannot happen in the same clock tick
485 meaning that later changes cannot happen in the same clock tick
486 and must cause a different modification time
486 and must cause a different modification time
487 (unless the system clock jumps back and we get unlucky,
487 (unless the system clock jumps back and we get unlucky,
488 which is not impossible but deemed unlikely enough).
488 which is not impossible but deemed unlikely enough).
489
489
490 This means that if `std::fs::symlink_metadata` later reports
490 This means that if `std::fs::symlink_metadata` later reports
491 the same modification time
491 the same modification time
492 and ignored patterns haven’t changed,
492 and ignored patterns haven’t changed,
493 we can assume the node to be unchanged on disk.
493 we can assume the node to be unchanged on disk.
494
494
495 The `mtime` field can then be used to skip more expensive lookup when
495 The `mtime` field can then be used to skip more expensive lookup when
496 checking the status of "tracked" nodes.
496 checking the status of "tracked" nodes.
497
497
498 It can also be set for node where `DIRECTORY` is set.
498 It can also be set for node where `DIRECTORY` is set.
499 See `DIRECTORY` documentation for details.
499 See `DIRECTORY` documentation for details.
500
500
501 `DIRECTORY`
501 `DIRECTORY`
502 When set, this entry will match a directory that exists or existed on the
502 When set, this entry will match a directory that exists or existed on the
503 file system.
503 file system.
504
504
505 * When `HAS_MTIME` is set a directory has been seen on the file system and
505 * When `HAS_MTIME` is set a directory has been seen on the file system and
506 `mtime` matches its last modification time. However, `HAS_MTIME` not
506 `mtime` matches its last modification time. However, `HAS_MTIME` not
507 being set does not indicate the lack of directory on the file system.
507 being set does not indicate the lack of directory on the file system.
508
508
509 * When not tracked anywhere, this node does not represent an ignored or
509 * When not tracked anywhere, this node does not represent an ignored or
510 unknown file on disk.
510 unknown file on disk.
511
511
512 If `HAS_MTIME` is set
512 If `HAS_MTIME` is set
513 and `mtime` matches the last modification time of the directory on disk,
513 and `mtime` matches the last modification time of the directory on disk,
514 the directory is unchanged
514 the directory is unchanged
515 and we can skip calling `std::fs::read_dir` again for this directory,
515 and we can skip calling `std::fs::read_dir` again for this directory,
516 and iterate child dirstate nodes instead.
516 and iterate child dirstate nodes instead.
517 (as long as `ALL_UNKNOWN_RECORDED` and `ALL_IGNORED_RECORDED` are taken
517 (as long as `ALL_UNKNOWN_RECORDED` and `ALL_IGNORED_RECORDED` are taken
518 into account)
518 into account)
519
519
520 `MODE_EXEC_PERM`
520 `MODE_EXEC_PERM`
521 Must be unset if `HAS_MODE_AND_SIZE` is unset.
521 Must be unset if `HAS_MODE_AND_SIZE` is unset.
522 If `HAS_MODE_AND_SIZE` is set,
522 If `HAS_MODE_AND_SIZE` is set,
523 this indicates whether the file’s own is expected
523 this indicates whether the file’s own is expected
524 to have execute permission.
524 to have execute permission.
525
525
526 Beware that on system without fs support for this information, the value
526 Beware that on system without fs support for this information, the value
527 stored in the dirstate might be wrong and should not be relied on.
527 stored in the dirstate might be wrong and should not be relied on.
528
528
529 `MODE_IS_SYMLINK`
529 `MODE_IS_SYMLINK`
530 Must be unset if `HAS_MODE_AND_SIZE` is unset.
530 Must be unset if `HAS_MODE_AND_SIZE` is unset.
531 If `HAS_MODE_AND_SIZE` is set,
531 If `HAS_MODE_AND_SIZE` is set,
532 this indicates whether the file is expected to be a symlink
532 this indicates whether the file is expected to be a symlink
533 as opposed to a normal file.
533 as opposed to a normal file.
534
534
535 Beware that on system without fs support for this information, the value
535 Beware that on system without fs support for this information, the value
536 stored in the dirstate might be wrong and should not be relied on.
536 stored in the dirstate might be wrong and should not be relied on.
537
537
538 `EXPECTED_STATE_IS_MODIFIED`
538 `EXPECTED_STATE_IS_MODIFIED`
539 Must be unset for untracked nodes.
539 Must be unset for untracked nodes.
540 For:
540 For:
541 - a file tracked anywhere
541 - a file tracked anywhere
542 - that has expected metadata (`HAS_MODE_AND_SIZE` and `HAS_MTIME`)
542 - that has expected metadata (`HAS_MODE_AND_SIZE` and `HAS_MTIME`)
543 - if that metadata matches
543 - if that metadata matches
544 metadata found in the working directory with `stat`
544 metadata found in the working directory with `stat`
545 This bit indicates the status of the file.
545 This bit indicates the status of the file.
546 If set, the status is modified. If unset, it is clean.
546 If set, the status is modified. If unset, it is clean.
547
547
548 In cases where `hg status` needs to read the contents of a file
548 In cases where `hg status` needs to read the contents of a file
549 because metadata is ambiguous, this bit lets it record the result
549 because metadata is ambiguous, this bit lets it record the result
550 if the result is modified so that a future run of `hg status`
550 if the result is modified so that a future run of `hg status`
551 does not need to do the same again.
551 does not need to do the same again.
552 It is valid to never set this bit,
552 It is valid to never set this bit,
553 and consider expected metadata ambiguous if it is set.
553 and consider expected metadata ambiguous if it is set.
554
554
555 `ALL_UNKNOWN_RECORDED`
555 `ALL_UNKNOWN_RECORDED`
556 If set, all "unknown" children existing on disk (at the time of the last
556 If set, all "unknown" children existing on disk (at the time of the last
557 status) have been recorded and the `mtime` associated with
557 status) have been recorded and the `mtime` associated with
558 `DIRECTORY` can be used for optimization even when "unknown" file
558 `DIRECTORY` can be used for optimization even when "unknown" file
559 are listed.
559 are listed.
560
560
561 Note that the amount recorded "unknown" children can still be zero if None
561 Note that the amount recorded "unknown" children can still be zero if None
562 where present.
562 where present.
563
563
564 Also note that having this flag unset does not imply that no "unknown"
564 Also note that having this flag unset does not imply that no "unknown"
565 children have been recorded. Some might be present, but there is
565 children have been recorded. Some might be present, but there is
566 no guarantee that is will be all of them.
566 no guarantee that is will be all of them.
567
567
568 `ALL_IGNORED_RECORDED`
568 `ALL_IGNORED_RECORDED`
569 If set, all "ignored" children existing on disk (at the time of the last
569 If set, all "ignored" children existing on disk (at the time of the last
570 status) have been recorded and the `mtime` associated with
570 status) have been recorded and the `mtime` associated with
571 `DIRECTORY` can be used for optimization even when "ignored" file
571 `DIRECTORY` can be used for optimization even when "ignored" file
572 are listed.
572 are listed.
573
573
574 Note that the amount recorded "ignored" children can still be zero if None
574 Note that the amount recorded "ignored" children can still be zero if None
575 where present.
575 where present.
576
576
577 Also note that having this flag unset does not imply that no "ignored"
577 Also note that having this flag unset does not imply that no "ignored"
578 children have been recorded. Some might be present, but there is
578 children have been recorded. Some might be present, but there is
579 no guarantee that is will be all of them.
579 no guarantee that is will be all of them.
580
580
581 `HAS_FALLBACK_EXEC`
581 `HAS_FALLBACK_EXEC`
582 If this flag is set, the entry carries "fallback" information for the
582 If this flag is set, the entry carries "fallback" information for the
583 executable bit in the `FALLBACK_EXEC` flag.
583 executable bit in the `FALLBACK_EXEC` flag.
584
584
585 Fallback information can be stored in the dirstate to keep track of
585 Fallback information can be stored in the dirstate to keep track of
586 filesystem attribute tracked by Mercurial when the underlying file
586 filesystem attribute tracked by Mercurial when the underlying file
587 system or operating system does not support that property, (e.g.
587 system or operating system does not support that property, (e.g.
588 Windows).
588 Windows).
589
589
590 `FALLBACK_EXEC`
590 `FALLBACK_EXEC`
591 Should be ignored if `HAS_FALLBACK_EXEC` is unset. If set the file for this
591 Should be ignored if `HAS_FALLBACK_EXEC` is unset. If set the file for this
592 entry should be considered executable if that information cannot be
592 entry should be considered executable if that information cannot be
593 extracted from the file system. If unset it should be considered
593 extracted from the file system. If unset it should be considered
594 non-executable instead.
594 non-executable instead.
595
595
596 `HAS_FALLBACK_SYMLINK`
596 `HAS_FALLBACK_SYMLINK`
597 If this flag is set, the entry carries "fallback" information for symbolic
597 If this flag is set, the entry carries "fallback" information for symbolic
598 link status in the `FALLBACK_SYMLINK` flag.
598 link status in the `FALLBACK_SYMLINK` flag.
599
599
600 Fallback information can be stored in the dirstate to keep track of
600 Fallback information can be stored in the dirstate to keep track of
601 filesystem attribute tracked by Mercurial when the underlying file
601 filesystem attribute tracked by Mercurial when the underlying file
602 system or operating system does not support that property, (e.g.
602 system or operating system does not support that property, (e.g.
603 Windows).
603 Windows).
604
604
605 `FALLBACK_SYMLINK`
605 `FALLBACK_SYMLINK`
606 Should be ignored if `HAS_FALLBACK_SYMLINK` is unset. If set the file for
606 Should be ignored if `HAS_FALLBACK_SYMLINK` is unset. If set the file for
607 this entry should be considered a symlink if that information cannot be
607 this entry should be considered a symlink if that information cannot be
608 extracted from the file system. If unset it should be considered a normal
608 extracted from the file system. If unset it should be considered a normal
609 file instead.
609 file instead.
610
610
611 `MTIME_SECOND_AMBIGUOUS`
611 `MTIME_SECOND_AMBIGUOUS`
612 This flag is relevant only when `HAS_FILE_MTIME` is set. When set, the
612 This flag is relevant only when `HAS_FILE_MTIME` is set. When set, the
613 `mtime` stored in the entry is only valid for comparison with timestamps
613 `mtime` stored in the entry is only valid for comparison with timestamps
614 that have nanosecond information. If available timestamp does not carries
614 that have nanosecond information. If available timestamp does not carries
615 nanosecond information, the `mtime` should be ignored and no optimization
615 nanosecond information, the `mtime` should be ignored and no optimization
616 can be applied.
616 can be applied.
@@ -1,95 +1,95 b''
1 Mercurial can be augmented with Rust extensions for speeding up certain
1 Mercurial can be augmented with Rust extensions for speeding up certain
2 operations.
2 operations.
3
3
4 Compatibility
4 Compatibility
5 =============
5 =============
6
6
7 Though the Rust extensions are only tested by the project under Linux, users of
7 Though the Rust extensions are only tested by the project under Linux, users of
8 MacOS, FreeBSD and other UNIX-likes have been using the Rust extensions. Your
8 MacOS, FreeBSD and other UNIX-likes have been using the Rust extensions. Your
9 mileage may vary, but by all means do give us feedback or signal your interest
9 mileage may vary, but by all means do give us feedback or signal your interest
10 for better support.
10 for better support.
11
11
12 No Rust extensions are available for Windows at this time.
12 No Rust extensions are available for Windows at this time.
13
13
14 Features
14 Features
15 ========
15 ========
16
16
17 The following operations are sped up when using Rust:
17 The following operations are sped up when using Rust:
18
18
19 - discovery of differences between repositories (pull/push)
19 - discovery of differences between repositories (pull/push)
20 - nodemap (see :hg:`help config.format.use-persistent-nodemap`)
20 - nodemap (see :hg:`help config.format.use-persistent-nodemap`)
21 - all commands using the dirstate (status, commit, diff, add, update, etc.)
21 - all commands using the dirstate (status, commit, diff, add, update, etc.)
22 - dirstate-v2 (see :hg:`help config.format.exp-rc-dirstate-v2`)
22 - dirstate-v2 (see :hg:`help config.format.use-dirstate-v2`)
23 - iteration over ancestors in a graph
23 - iteration over ancestors in a graph
24
24
25 More features are in the works, and improvements on the above listed are still
25 More features are in the works, and improvements on the above listed are still
26 in progress. For more experimental work see the "rhg" section.
26 in progress. For more experimental work see the "rhg" section.
27
27
28 Checking for Rust
28 Checking for Rust
29 =================
29 =================
30
30
31 You may already have the Rust extensions depending on how you install Mercurial.
31 You may already have the Rust extensions depending on how you install Mercurial.
32
32
33 $ hg debuginstall | grep -i rust
33 $ hg debuginstall | grep -i rust
34 checking Rust extensions (installed)
34 checking Rust extensions (installed)
35 checking module policy (rust+c-allow)
35 checking module policy (rust+c-allow)
36
36
37 If those lines don't even exist, you're using an old version of `hg` which does
37 If those lines don't even exist, you're using an old version of `hg` which does
38 not have any Rust extensions yet.
38 not have any Rust extensions yet.
39
39
40 Installing
40 Installing
41 ==========
41 ==========
42
42
43 You will need `cargo` to be in your `$PATH`. See the "MSRV" section for which
43 You will need `cargo` to be in your `$PATH`. See the "MSRV" section for which
44 version to use.
44 version to use.
45
45
46 Using pip
46 Using pip
47 ---------
47 ---------
48
48
49 Users of `pip` can install the Rust extensions with the following command:
49 Users of `pip` can install the Rust extensions with the following command:
50
50
51 $ pip install mercurial --global-option --rust --no-use-pep517
51 $ pip install mercurial --global-option --rust --no-use-pep517
52
52
53 `--no-use-pep517` is here to tell `pip` to preserve backwards compatibility with
53 `--no-use-pep517` is here to tell `pip` to preserve backwards compatibility with
54 the legacy `setup.py` system. Mercurial has not yet migrated its complex setup
54 the legacy `setup.py` system. Mercurial has not yet migrated its complex setup
55 to the new system, so we still need this to add compiled extensions.
55 to the new system, so we still need this to add compiled extensions.
56
56
57 This might take a couple of minutes because you're compiling everything.
57 This might take a couple of minutes because you're compiling everything.
58
58
59 See the "Checking for Rust" section to see if the install succeeded.
59 See the "Checking for Rust" section to see if the install succeeded.
60
60
61 From your distribution
61 From your distribution
62 ----------------------
62 ----------------------
63
63
64 Some distributions are shipping Mercurial with Rust extensions enabled and
64 Some distributions are shipping Mercurial with Rust extensions enabled and
65 pre-compiled (meaning you won't have to install `cargo`), or allow you to
65 pre-compiled (meaning you won't have to install `cargo`), or allow you to
66 specify an install flag. Check with your specific distribution for how to do
66 specify an install flag. Check with your specific distribution for how to do
67 that, or ask their team to add support for hg+Rust!
67 that, or ask their team to add support for hg+Rust!
68
68
69 From source
69 From source
70 -----------
70 -----------
71
71
72 Please refer to the `rust/README.rst` file in the Mercurial repository for
72 Please refer to the `rust/README.rst` file in the Mercurial repository for
73 instructions on how to install from source.
73 instructions on how to install from source.
74
74
75 MSRV
75 MSRV
76 ====
76 ====
77
77
78 The minimum supported Rust version is currently 1.48.0. The project's policy is
78 The minimum supported Rust version is currently 1.48.0. The project's policy is
79 to follow the version from Debian stable, to make the distributions' job easier.
79 to follow the version from Debian stable, to make the distributions' job easier.
80
80
81 rhg
81 rhg
82 ===
82 ===
83
83
84 There exists an experimental pure-Rust version of Mercurial called `rhg` with a
84 There exists an experimental pure-Rust version of Mercurial called `rhg` with a
85 fallback mechanism for unsupported invocations. It allows for much faster
85 fallback mechanism for unsupported invocations. It allows for much faster
86 execution of certain commands while adding no discernable overhead for the rest.
86 execution of certain commands while adding no discernable overhead for the rest.
87
87
88 The only way of trying it out is by building it from source. Please refer to
88 The only way of trying it out is by building it from source. Please refer to
89 `rust/README.rst` in the Mercurial repository.
89 `rust/README.rst` in the Mercurial repository.
90
90
91 Contributing
91 Contributing
92 ============
92 ============
93
93
94 If you would like to help the Rust endeavor, please refer to `rust/README.rst`
94 If you would like to help the Rust endeavor, please refer to `rust/README.rst`
95 in the Mercurial repository.
95 in the Mercurial repository.
@@ -1,3897 +1,3897 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 changelogcache(storecache):
147 class changelogcache(storecache):
148 """filecache for the changelog"""
148 """filecache for the changelog"""
149
149
150 def __init__(self):
150 def __init__(self):
151 super(changelogcache, self).__init__()
151 super(changelogcache, self).__init__()
152 _cachedfiles.add((b'00changelog.i', b''))
152 _cachedfiles.add((b'00changelog.i', b''))
153 _cachedfiles.add((b'00changelog.n', b''))
153 _cachedfiles.add((b'00changelog.n', b''))
154
154
155 def tracked_paths(self, obj):
155 def tracked_paths(self, obj):
156 paths = [self.join(obj, b'00changelog.i')]
156 paths = [self.join(obj, b'00changelog.i')]
157 if obj.store.opener.options.get(b'persistent-nodemap', False):
157 if obj.store.opener.options.get(b'persistent-nodemap', False):
158 paths.append(self.join(obj, b'00changelog.n'))
158 paths.append(self.join(obj, b'00changelog.n'))
159 return paths
159 return paths
160
160
161
161
162 class manifestlogcache(storecache):
162 class manifestlogcache(storecache):
163 """filecache for the manifestlog"""
163 """filecache for the manifestlog"""
164
164
165 def __init__(self):
165 def __init__(self):
166 super(manifestlogcache, self).__init__()
166 super(manifestlogcache, self).__init__()
167 _cachedfiles.add((b'00manifest.i', b''))
167 _cachedfiles.add((b'00manifest.i', b''))
168 _cachedfiles.add((b'00manifest.n', b''))
168 _cachedfiles.add((b'00manifest.n', b''))
169
169
170 def tracked_paths(self, obj):
170 def tracked_paths(self, obj):
171 paths = [self.join(obj, b'00manifest.i')]
171 paths = [self.join(obj, b'00manifest.i')]
172 if obj.store.opener.options.get(b'persistent-nodemap', False):
172 if obj.store.opener.options.get(b'persistent-nodemap', False):
173 paths.append(self.join(obj, b'00manifest.n'))
173 paths.append(self.join(obj, b'00manifest.n'))
174 return paths
174 return paths
175
175
176
176
177 class mixedrepostorecache(_basefilecache):
177 class mixedrepostorecache(_basefilecache):
178 """filecache for a mix files in .hg/store and outside"""
178 """filecache for a mix files in .hg/store and outside"""
179
179
180 def __init__(self, *pathsandlocations):
180 def __init__(self, *pathsandlocations):
181 # scmutil.filecache only uses the path for passing back into our
181 # scmutil.filecache only uses the path for passing back into our
182 # join(), so we can safely pass a list of paths and locations
182 # join(), so we can safely pass a list of paths and locations
183 super(mixedrepostorecache, self).__init__(*pathsandlocations)
183 super(mixedrepostorecache, self).__init__(*pathsandlocations)
184 _cachedfiles.update(pathsandlocations)
184 _cachedfiles.update(pathsandlocations)
185
185
186 def join(self, obj, fnameandlocation):
186 def join(self, obj, fnameandlocation):
187 fname, location = fnameandlocation
187 fname, location = fnameandlocation
188 if location == b'plain':
188 if location == b'plain':
189 return obj.vfs.join(fname)
189 return obj.vfs.join(fname)
190 else:
190 else:
191 if location != b'':
191 if location != b'':
192 raise error.ProgrammingError(
192 raise error.ProgrammingError(
193 b'unexpected location: %s' % location
193 b'unexpected location: %s' % location
194 )
194 )
195 return obj.sjoin(fname)
195 return obj.sjoin(fname)
196
196
197
197
198 def isfilecached(repo, name):
198 def isfilecached(repo, name):
199 """check if a repo has already cached "name" filecache-ed property
199 """check if a repo has already cached "name" filecache-ed property
200
200
201 This returns (cachedobj-or-None, iscached) tuple.
201 This returns (cachedobj-or-None, iscached) tuple.
202 """
202 """
203 cacheentry = repo.unfiltered()._filecache.get(name, None)
203 cacheentry = repo.unfiltered()._filecache.get(name, None)
204 if not cacheentry:
204 if not cacheentry:
205 return None, False
205 return None, False
206 return cacheentry.obj, True
206 return cacheentry.obj, True
207
207
208
208
209 class unfilteredpropertycache(util.propertycache):
209 class unfilteredpropertycache(util.propertycache):
210 """propertycache that apply to unfiltered repo only"""
210 """propertycache that apply to unfiltered repo only"""
211
211
212 def __get__(self, repo, type=None):
212 def __get__(self, repo, type=None):
213 unfi = repo.unfiltered()
213 unfi = repo.unfiltered()
214 if unfi is repo:
214 if unfi is repo:
215 return super(unfilteredpropertycache, self).__get__(unfi)
215 return super(unfilteredpropertycache, self).__get__(unfi)
216 return getattr(unfi, self.name)
216 return getattr(unfi, self.name)
217
217
218
218
219 class filteredpropertycache(util.propertycache):
219 class filteredpropertycache(util.propertycache):
220 """propertycache that must take filtering in account"""
220 """propertycache that must take filtering in account"""
221
221
222 def cachevalue(self, obj, value):
222 def cachevalue(self, obj, value):
223 object.__setattr__(obj, self.name, value)
223 object.__setattr__(obj, self.name, value)
224
224
225
225
226 def hasunfilteredcache(repo, name):
226 def hasunfilteredcache(repo, name):
227 """check if a repo has an unfilteredpropertycache value for <name>"""
227 """check if a repo has an unfilteredpropertycache value for <name>"""
228 return name in vars(repo.unfiltered())
228 return name in vars(repo.unfiltered())
229
229
230
230
231 def unfilteredmethod(orig):
231 def unfilteredmethod(orig):
232 """decorate method that always need to be run on unfiltered version"""
232 """decorate method that always need to be run on unfiltered version"""
233
233
234 @functools.wraps(orig)
234 @functools.wraps(orig)
235 def wrapper(repo, *args, **kwargs):
235 def wrapper(repo, *args, **kwargs):
236 return orig(repo.unfiltered(), *args, **kwargs)
236 return orig(repo.unfiltered(), *args, **kwargs)
237
237
238 return wrapper
238 return wrapper
239
239
240
240
241 moderncaps = {
241 moderncaps = {
242 b'lookup',
242 b'lookup',
243 b'branchmap',
243 b'branchmap',
244 b'pushkey',
244 b'pushkey',
245 b'known',
245 b'known',
246 b'getbundle',
246 b'getbundle',
247 b'unbundle',
247 b'unbundle',
248 }
248 }
249 legacycaps = moderncaps.union({b'changegroupsubset'})
249 legacycaps = moderncaps.union({b'changegroupsubset'})
250
250
251
251
252 @interfaceutil.implementer(repository.ipeercommandexecutor)
252 @interfaceutil.implementer(repository.ipeercommandexecutor)
253 class localcommandexecutor(object):
253 class localcommandexecutor(object):
254 def __init__(self, peer):
254 def __init__(self, peer):
255 self._peer = peer
255 self._peer = peer
256 self._sent = False
256 self._sent = False
257 self._closed = False
257 self._closed = False
258
258
259 def __enter__(self):
259 def __enter__(self):
260 return self
260 return self
261
261
262 def __exit__(self, exctype, excvalue, exctb):
262 def __exit__(self, exctype, excvalue, exctb):
263 self.close()
263 self.close()
264
264
265 def callcommand(self, command, args):
265 def callcommand(self, command, args):
266 if self._sent:
266 if self._sent:
267 raise error.ProgrammingError(
267 raise error.ProgrammingError(
268 b'callcommand() cannot be used after sendcommands()'
268 b'callcommand() cannot be used after sendcommands()'
269 )
269 )
270
270
271 if self._closed:
271 if self._closed:
272 raise error.ProgrammingError(
272 raise error.ProgrammingError(
273 b'callcommand() cannot be used after close()'
273 b'callcommand() cannot be used after close()'
274 )
274 )
275
275
276 # We don't need to support anything fancy. Just call the named
276 # We don't need to support anything fancy. Just call the named
277 # method on the peer and return a resolved future.
277 # method on the peer and return a resolved future.
278 fn = getattr(self._peer, pycompat.sysstr(command))
278 fn = getattr(self._peer, pycompat.sysstr(command))
279
279
280 f = pycompat.futures.Future()
280 f = pycompat.futures.Future()
281
281
282 try:
282 try:
283 result = fn(**pycompat.strkwargs(args))
283 result = fn(**pycompat.strkwargs(args))
284 except Exception:
284 except Exception:
285 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
285 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
286 else:
286 else:
287 f.set_result(result)
287 f.set_result(result)
288
288
289 return f
289 return f
290
290
291 def sendcommands(self):
291 def sendcommands(self):
292 self._sent = True
292 self._sent = True
293
293
294 def close(self):
294 def close(self):
295 self._closed = True
295 self._closed = True
296
296
297
297
298 @interfaceutil.implementer(repository.ipeercommands)
298 @interfaceutil.implementer(repository.ipeercommands)
299 class localpeer(repository.peer):
299 class localpeer(repository.peer):
300 '''peer for a local repo; reflects only the most recent API'''
300 '''peer for a local repo; reflects only the most recent API'''
301
301
302 def __init__(self, repo, caps=None):
302 def __init__(self, repo, caps=None):
303 super(localpeer, self).__init__()
303 super(localpeer, self).__init__()
304
304
305 if caps is None:
305 if caps is None:
306 caps = moderncaps.copy()
306 caps = moderncaps.copy()
307 self._repo = repo.filtered(b'served')
307 self._repo = repo.filtered(b'served')
308 self.ui = repo.ui
308 self.ui = repo.ui
309
309
310 if repo._wanted_sidedata:
310 if repo._wanted_sidedata:
311 formatted = bundle2.format_remote_wanted_sidedata(repo)
311 formatted = bundle2.format_remote_wanted_sidedata(repo)
312 caps.add(b'exp-wanted-sidedata=' + formatted)
312 caps.add(b'exp-wanted-sidedata=' + formatted)
313
313
314 self._caps = repo._restrictcapabilities(caps)
314 self._caps = repo._restrictcapabilities(caps)
315
315
316 # Begin of _basepeer interface.
316 # Begin of _basepeer interface.
317
317
318 def url(self):
318 def url(self):
319 return self._repo.url()
319 return self._repo.url()
320
320
321 def local(self):
321 def local(self):
322 return self._repo
322 return self._repo
323
323
324 def peer(self):
324 def peer(self):
325 return self
325 return self
326
326
327 def canpush(self):
327 def canpush(self):
328 return True
328 return True
329
329
330 def close(self):
330 def close(self):
331 self._repo.close()
331 self._repo.close()
332
332
333 # End of _basepeer interface.
333 # End of _basepeer interface.
334
334
335 # Begin of _basewirecommands interface.
335 # Begin of _basewirecommands interface.
336
336
337 def branchmap(self):
337 def branchmap(self):
338 return self._repo.branchmap()
338 return self._repo.branchmap()
339
339
340 def capabilities(self):
340 def capabilities(self):
341 return self._caps
341 return self._caps
342
342
343 def clonebundles(self):
343 def clonebundles(self):
344 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
344 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
345
345
346 def debugwireargs(self, one, two, three=None, four=None, five=None):
346 def debugwireargs(self, one, two, three=None, four=None, five=None):
347 """Used to test argument passing over the wire"""
347 """Used to test argument passing over the wire"""
348 return b"%s %s %s %s %s" % (
348 return b"%s %s %s %s %s" % (
349 one,
349 one,
350 two,
350 two,
351 pycompat.bytestr(three),
351 pycompat.bytestr(three),
352 pycompat.bytestr(four),
352 pycompat.bytestr(four),
353 pycompat.bytestr(five),
353 pycompat.bytestr(five),
354 )
354 )
355
355
356 def getbundle(
356 def getbundle(
357 self,
357 self,
358 source,
358 source,
359 heads=None,
359 heads=None,
360 common=None,
360 common=None,
361 bundlecaps=None,
361 bundlecaps=None,
362 remote_sidedata=None,
362 remote_sidedata=None,
363 **kwargs
363 **kwargs
364 ):
364 ):
365 chunks = exchange.getbundlechunks(
365 chunks = exchange.getbundlechunks(
366 self._repo,
366 self._repo,
367 source,
367 source,
368 heads=heads,
368 heads=heads,
369 common=common,
369 common=common,
370 bundlecaps=bundlecaps,
370 bundlecaps=bundlecaps,
371 remote_sidedata=remote_sidedata,
371 remote_sidedata=remote_sidedata,
372 **kwargs
372 **kwargs
373 )[1]
373 )[1]
374 cb = util.chunkbuffer(chunks)
374 cb = util.chunkbuffer(chunks)
375
375
376 if exchange.bundle2requested(bundlecaps):
376 if exchange.bundle2requested(bundlecaps):
377 # When requesting a bundle2, getbundle returns a stream to make the
377 # When requesting a bundle2, getbundle returns a stream to make the
378 # wire level function happier. We need to build a proper object
378 # wire level function happier. We need to build a proper object
379 # from it in local peer.
379 # from it in local peer.
380 return bundle2.getunbundler(self.ui, cb)
380 return bundle2.getunbundler(self.ui, cb)
381 else:
381 else:
382 return changegroup.getunbundler(b'01', cb, None)
382 return changegroup.getunbundler(b'01', cb, None)
383
383
384 def heads(self):
384 def heads(self):
385 return self._repo.heads()
385 return self._repo.heads()
386
386
387 def known(self, nodes):
387 def known(self, nodes):
388 return self._repo.known(nodes)
388 return self._repo.known(nodes)
389
389
390 def listkeys(self, namespace):
390 def listkeys(self, namespace):
391 return self._repo.listkeys(namespace)
391 return self._repo.listkeys(namespace)
392
392
393 def lookup(self, key):
393 def lookup(self, key):
394 return self._repo.lookup(key)
394 return self._repo.lookup(key)
395
395
396 def pushkey(self, namespace, key, old, new):
396 def pushkey(self, namespace, key, old, new):
397 return self._repo.pushkey(namespace, key, old, new)
397 return self._repo.pushkey(namespace, key, old, new)
398
398
399 def stream_out(self):
399 def stream_out(self):
400 raise error.Abort(_(b'cannot perform stream clone against local peer'))
400 raise error.Abort(_(b'cannot perform stream clone against local peer'))
401
401
402 def unbundle(self, bundle, heads, url):
402 def unbundle(self, bundle, heads, url):
403 """apply a bundle on a repo
403 """apply a bundle on a repo
404
404
405 This function handles the repo locking itself."""
405 This function handles the repo locking itself."""
406 try:
406 try:
407 try:
407 try:
408 bundle = exchange.readbundle(self.ui, bundle, None)
408 bundle = exchange.readbundle(self.ui, bundle, None)
409 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
409 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
410 if util.safehasattr(ret, b'getchunks'):
410 if util.safehasattr(ret, b'getchunks'):
411 # This is a bundle20 object, turn it into an unbundler.
411 # This is a bundle20 object, turn it into an unbundler.
412 # This little dance should be dropped eventually when the
412 # This little dance should be dropped eventually when the
413 # API is finally improved.
413 # API is finally improved.
414 stream = util.chunkbuffer(ret.getchunks())
414 stream = util.chunkbuffer(ret.getchunks())
415 ret = bundle2.getunbundler(self.ui, stream)
415 ret = bundle2.getunbundler(self.ui, stream)
416 return ret
416 return ret
417 except Exception as exc:
417 except Exception as exc:
418 # If the exception contains output salvaged from a bundle2
418 # If the exception contains output salvaged from a bundle2
419 # reply, we need to make sure it is printed before continuing
419 # reply, we need to make sure it is printed before continuing
420 # to fail. So we build a bundle2 with such output and consume
420 # to fail. So we build a bundle2 with such output and consume
421 # it directly.
421 # it directly.
422 #
422 #
423 # This is not very elegant but allows a "simple" solution for
423 # This is not very elegant but allows a "simple" solution for
424 # issue4594
424 # issue4594
425 output = getattr(exc, '_bundle2salvagedoutput', ())
425 output = getattr(exc, '_bundle2salvagedoutput', ())
426 if output:
426 if output:
427 bundler = bundle2.bundle20(self._repo.ui)
427 bundler = bundle2.bundle20(self._repo.ui)
428 for out in output:
428 for out in output:
429 bundler.addpart(out)
429 bundler.addpart(out)
430 stream = util.chunkbuffer(bundler.getchunks())
430 stream = util.chunkbuffer(bundler.getchunks())
431 b = bundle2.getunbundler(self.ui, stream)
431 b = bundle2.getunbundler(self.ui, stream)
432 bundle2.processbundle(self._repo, b)
432 bundle2.processbundle(self._repo, b)
433 raise
433 raise
434 except error.PushRaced as exc:
434 except error.PushRaced as exc:
435 raise error.ResponseError(
435 raise error.ResponseError(
436 _(b'push failed:'), stringutil.forcebytestr(exc)
436 _(b'push failed:'), stringutil.forcebytestr(exc)
437 )
437 )
438
438
439 # End of _basewirecommands interface.
439 # End of _basewirecommands interface.
440
440
441 # Begin of peer interface.
441 # Begin of peer interface.
442
442
443 def commandexecutor(self):
443 def commandexecutor(self):
444 return localcommandexecutor(self)
444 return localcommandexecutor(self)
445
445
446 # End of peer interface.
446 # End of peer interface.
447
447
448
448
449 @interfaceutil.implementer(repository.ipeerlegacycommands)
449 @interfaceutil.implementer(repository.ipeerlegacycommands)
450 class locallegacypeer(localpeer):
450 class locallegacypeer(localpeer):
451 """peer extension which implements legacy methods too; used for tests with
451 """peer extension which implements legacy methods too; used for tests with
452 restricted capabilities"""
452 restricted capabilities"""
453
453
454 def __init__(self, repo):
454 def __init__(self, repo):
455 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
455 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
456
456
457 # Begin of baselegacywirecommands interface.
457 # Begin of baselegacywirecommands interface.
458
458
459 def between(self, pairs):
459 def between(self, pairs):
460 return self._repo.between(pairs)
460 return self._repo.between(pairs)
461
461
462 def branches(self, nodes):
462 def branches(self, nodes):
463 return self._repo.branches(nodes)
463 return self._repo.branches(nodes)
464
464
465 def changegroup(self, nodes, source):
465 def changegroup(self, nodes, source):
466 outgoing = discovery.outgoing(
466 outgoing = discovery.outgoing(
467 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
467 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
468 )
468 )
469 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
469 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
470
470
471 def changegroupsubset(self, bases, heads, source):
471 def changegroupsubset(self, bases, heads, source):
472 outgoing = discovery.outgoing(
472 outgoing = discovery.outgoing(
473 self._repo, missingroots=bases, ancestorsof=heads
473 self._repo, missingroots=bases, ancestorsof=heads
474 )
474 )
475 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
475 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
476
476
477 # End of baselegacywirecommands interface.
477 # End of baselegacywirecommands interface.
478
478
479
479
480 # Functions receiving (ui, features) that extensions can register to impact
480 # Functions receiving (ui, features) that extensions can register to impact
481 # the ability to load repositories with custom requirements. Only
481 # the ability to load repositories with custom requirements. Only
482 # functions defined in loaded extensions are called.
482 # functions defined in loaded extensions are called.
483 #
483 #
484 # The function receives a set of requirement strings that the repository
484 # The function receives a set of requirement strings that the repository
485 # is capable of opening. Functions will typically add elements to the
485 # is capable of opening. Functions will typically add elements to the
486 # set to reflect that the extension knows how to handle that requirements.
486 # set to reflect that the extension knows how to handle that requirements.
487 featuresetupfuncs = set()
487 featuresetupfuncs = set()
488
488
489
489
490 def _getsharedvfs(hgvfs, requirements):
490 def _getsharedvfs(hgvfs, requirements):
491 """returns the vfs object pointing to root of shared source
491 """returns the vfs object pointing to root of shared source
492 repo for a shared repository
492 repo for a shared repository
493
493
494 hgvfs is vfs pointing at .hg/ of current repo (shared one)
494 hgvfs is vfs pointing at .hg/ of current repo (shared one)
495 requirements is a set of requirements of current repo (shared one)
495 requirements is a set of requirements of current repo (shared one)
496 """
496 """
497 # The ``shared`` or ``relshared`` requirements indicate the
497 # The ``shared`` or ``relshared`` requirements indicate the
498 # store lives in the path contained in the ``.hg/sharedpath`` file.
498 # store lives in the path contained in the ``.hg/sharedpath`` file.
499 # This is an absolute path for ``shared`` and relative to
499 # This is an absolute path for ``shared`` and relative to
500 # ``.hg/`` for ``relshared``.
500 # ``.hg/`` for ``relshared``.
501 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
501 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
502 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
502 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
503 sharedpath = util.normpath(hgvfs.join(sharedpath))
503 sharedpath = util.normpath(hgvfs.join(sharedpath))
504
504
505 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
505 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
506
506
507 if not sharedvfs.exists():
507 if not sharedvfs.exists():
508 raise error.RepoError(
508 raise error.RepoError(
509 _(b'.hg/sharedpath points to nonexistent directory %s')
509 _(b'.hg/sharedpath points to nonexistent directory %s')
510 % sharedvfs.base
510 % sharedvfs.base
511 )
511 )
512 return sharedvfs
512 return sharedvfs
513
513
514
514
515 def _readrequires(vfs, allowmissing):
515 def _readrequires(vfs, allowmissing):
516 """reads the require file present at root of this vfs
516 """reads the require file present at root of this vfs
517 and return a set of requirements
517 and return a set of requirements
518
518
519 If allowmissing is True, we suppress ENOENT if raised"""
519 If allowmissing is True, we suppress ENOENT if raised"""
520 # requires file contains a newline-delimited list of
520 # requires file contains a newline-delimited list of
521 # features/capabilities the opener (us) must have in order to use
521 # features/capabilities the opener (us) must have in order to use
522 # the repository. This file was introduced in Mercurial 0.9.2,
522 # the repository. This file was introduced in Mercurial 0.9.2,
523 # which means very old repositories may not have one. We assume
523 # which means very old repositories may not have one. We assume
524 # a missing file translates to no requirements.
524 # a missing file translates to no requirements.
525 try:
525 try:
526 requirements = set(vfs.read(b'requires').splitlines())
526 requirements = set(vfs.read(b'requires').splitlines())
527 except IOError as e:
527 except IOError as e:
528 if not (allowmissing and e.errno == errno.ENOENT):
528 if not (allowmissing and e.errno == errno.ENOENT):
529 raise
529 raise
530 requirements = set()
530 requirements = set()
531 return requirements
531 return requirements
532
532
533
533
534 def makelocalrepository(baseui, path, intents=None):
534 def makelocalrepository(baseui, path, intents=None):
535 """Create a local repository object.
535 """Create a local repository object.
536
536
537 Given arguments needed to construct a local repository, this function
537 Given arguments needed to construct a local repository, this function
538 performs various early repository loading functionality (such as
538 performs various early repository loading functionality (such as
539 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
539 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
540 the repository can be opened, derives a type suitable for representing
540 the repository can be opened, derives a type suitable for representing
541 that repository, and returns an instance of it.
541 that repository, and returns an instance of it.
542
542
543 The returned object conforms to the ``repository.completelocalrepository``
543 The returned object conforms to the ``repository.completelocalrepository``
544 interface.
544 interface.
545
545
546 The repository type is derived by calling a series of factory functions
546 The repository type is derived by calling a series of factory functions
547 for each aspect/interface of the final repository. These are defined by
547 for each aspect/interface of the final repository. These are defined by
548 ``REPO_INTERFACES``.
548 ``REPO_INTERFACES``.
549
549
550 Each factory function is called to produce a type implementing a specific
550 Each factory function is called to produce a type implementing a specific
551 interface. The cumulative list of returned types will be combined into a
551 interface. The cumulative list of returned types will be combined into a
552 new type and that type will be instantiated to represent the local
552 new type and that type will be instantiated to represent the local
553 repository.
553 repository.
554
554
555 The factory functions each receive various state that may be consulted
555 The factory functions each receive various state that may be consulted
556 as part of deriving a type.
556 as part of deriving a type.
557
557
558 Extensions should wrap these factory functions to customize repository type
558 Extensions should wrap these factory functions to customize repository type
559 creation. Note that an extension's wrapped function may be called even if
559 creation. Note that an extension's wrapped function may be called even if
560 that extension is not loaded for the repo being constructed. Extensions
560 that extension is not loaded for the repo being constructed. Extensions
561 should check if their ``__name__`` appears in the
561 should check if their ``__name__`` appears in the
562 ``extensionmodulenames`` set passed to the factory function and no-op if
562 ``extensionmodulenames`` set passed to the factory function and no-op if
563 not.
563 not.
564 """
564 """
565 ui = baseui.copy()
565 ui = baseui.copy()
566 # Prevent copying repo configuration.
566 # Prevent copying repo configuration.
567 ui.copy = baseui.copy
567 ui.copy = baseui.copy
568
568
569 # Working directory VFS rooted at repository root.
569 # Working directory VFS rooted at repository root.
570 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
570 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
571
571
572 # Main VFS for .hg/ directory.
572 # Main VFS for .hg/ directory.
573 hgpath = wdirvfs.join(b'.hg')
573 hgpath = wdirvfs.join(b'.hg')
574 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
574 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
575 # Whether this repository is shared one or not
575 # Whether this repository is shared one or not
576 shared = False
576 shared = False
577 # If this repository is shared, vfs pointing to shared repo
577 # If this repository is shared, vfs pointing to shared repo
578 sharedvfs = None
578 sharedvfs = None
579
579
580 # The .hg/ path should exist and should be a directory. All other
580 # The .hg/ path should exist and should be a directory. All other
581 # cases are errors.
581 # cases are errors.
582 if not hgvfs.isdir():
582 if not hgvfs.isdir():
583 try:
583 try:
584 hgvfs.stat()
584 hgvfs.stat()
585 except OSError as e:
585 except OSError as e:
586 if e.errno != errno.ENOENT:
586 if e.errno != errno.ENOENT:
587 raise
587 raise
588 except ValueError as e:
588 except ValueError as e:
589 # Can be raised on Python 3.8 when path is invalid.
589 # Can be raised on Python 3.8 when path is invalid.
590 raise error.Abort(
590 raise error.Abort(
591 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
591 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
592 )
592 )
593
593
594 raise error.RepoError(_(b'repository %s not found') % path)
594 raise error.RepoError(_(b'repository %s not found') % path)
595
595
596 requirements = _readrequires(hgvfs, True)
596 requirements = _readrequires(hgvfs, True)
597 shared = (
597 shared = (
598 requirementsmod.SHARED_REQUIREMENT in requirements
598 requirementsmod.SHARED_REQUIREMENT in requirements
599 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
599 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
600 )
600 )
601 storevfs = None
601 storevfs = None
602 if shared:
602 if shared:
603 # This is a shared repo
603 # This is a shared repo
604 sharedvfs = _getsharedvfs(hgvfs, requirements)
604 sharedvfs = _getsharedvfs(hgvfs, requirements)
605 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
605 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
606 else:
606 else:
607 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
607 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
608
608
609 # if .hg/requires contains the sharesafe requirement, it means
609 # if .hg/requires contains the sharesafe requirement, it means
610 # there exists a `.hg/store/requires` too and we should read it
610 # there exists a `.hg/store/requires` too and we should read it
611 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
611 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
612 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
612 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
613 # is not present, refer checkrequirementscompat() for that
613 # is not present, refer checkrequirementscompat() for that
614 #
614 #
615 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
615 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
616 # repository was shared the old way. We check the share source .hg/requires
616 # repository was shared the old way. We check the share source .hg/requires
617 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
617 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
618 # to be reshared
618 # to be reshared
619 hint = _(b"see `hg help config.format.use-share-safe` for more information")
619 hint = _(b"see `hg help config.format.use-share-safe` for more information")
620 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
620 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
621
621
622 if (
622 if (
623 shared
623 shared
624 and requirementsmod.SHARESAFE_REQUIREMENT
624 and requirementsmod.SHARESAFE_REQUIREMENT
625 not in _readrequires(sharedvfs, True)
625 not in _readrequires(sharedvfs, True)
626 ):
626 ):
627 mismatch_warn = ui.configbool(
627 mismatch_warn = ui.configbool(
628 b'share', b'safe-mismatch.source-not-safe.warn'
628 b'share', b'safe-mismatch.source-not-safe.warn'
629 )
629 )
630 mismatch_config = ui.config(
630 mismatch_config = ui.config(
631 b'share', b'safe-mismatch.source-not-safe'
631 b'share', b'safe-mismatch.source-not-safe'
632 )
632 )
633 if mismatch_config in (
633 if mismatch_config in (
634 b'downgrade-allow',
634 b'downgrade-allow',
635 b'allow',
635 b'allow',
636 b'downgrade-abort',
636 b'downgrade-abort',
637 ):
637 ):
638 # prevent cyclic import localrepo -> upgrade -> localrepo
638 # prevent cyclic import localrepo -> upgrade -> localrepo
639 from . import upgrade
639 from . import upgrade
640
640
641 upgrade.downgrade_share_to_non_safe(
641 upgrade.downgrade_share_to_non_safe(
642 ui,
642 ui,
643 hgvfs,
643 hgvfs,
644 sharedvfs,
644 sharedvfs,
645 requirements,
645 requirements,
646 mismatch_config,
646 mismatch_config,
647 mismatch_warn,
647 mismatch_warn,
648 )
648 )
649 elif mismatch_config == b'abort':
649 elif mismatch_config == b'abort':
650 raise error.Abort(
650 raise error.Abort(
651 _(b"share source does not support share-safe requirement"),
651 _(b"share source does not support share-safe requirement"),
652 hint=hint,
652 hint=hint,
653 )
653 )
654 else:
654 else:
655 raise error.Abort(
655 raise error.Abort(
656 _(
656 _(
657 b"share-safe mismatch with source.\nUnrecognized"
657 b"share-safe mismatch with source.\nUnrecognized"
658 b" value '%s' of `share.safe-mismatch.source-not-safe`"
658 b" value '%s' of `share.safe-mismatch.source-not-safe`"
659 b" set."
659 b" set."
660 )
660 )
661 % mismatch_config,
661 % mismatch_config,
662 hint=hint,
662 hint=hint,
663 )
663 )
664 else:
664 else:
665 requirements |= _readrequires(storevfs, False)
665 requirements |= _readrequires(storevfs, False)
666 elif shared:
666 elif shared:
667 sourcerequires = _readrequires(sharedvfs, False)
667 sourcerequires = _readrequires(sharedvfs, False)
668 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
668 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
669 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
669 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
670 mismatch_warn = ui.configbool(
670 mismatch_warn = ui.configbool(
671 b'share', b'safe-mismatch.source-safe.warn'
671 b'share', b'safe-mismatch.source-safe.warn'
672 )
672 )
673 if mismatch_config in (
673 if mismatch_config in (
674 b'upgrade-allow',
674 b'upgrade-allow',
675 b'allow',
675 b'allow',
676 b'upgrade-abort',
676 b'upgrade-abort',
677 ):
677 ):
678 # prevent cyclic import localrepo -> upgrade -> localrepo
678 # prevent cyclic import localrepo -> upgrade -> localrepo
679 from . import upgrade
679 from . import upgrade
680
680
681 upgrade.upgrade_share_to_safe(
681 upgrade.upgrade_share_to_safe(
682 ui,
682 ui,
683 hgvfs,
683 hgvfs,
684 storevfs,
684 storevfs,
685 requirements,
685 requirements,
686 mismatch_config,
686 mismatch_config,
687 mismatch_warn,
687 mismatch_warn,
688 )
688 )
689 elif mismatch_config == b'abort':
689 elif mismatch_config == b'abort':
690 raise error.Abort(
690 raise error.Abort(
691 _(
691 _(
692 b'version mismatch: source uses share-safe'
692 b'version mismatch: source uses share-safe'
693 b' functionality while the current share does not'
693 b' functionality while the current share does not'
694 ),
694 ),
695 hint=hint,
695 hint=hint,
696 )
696 )
697 else:
697 else:
698 raise error.Abort(
698 raise error.Abort(
699 _(
699 _(
700 b"share-safe mismatch with source.\nUnrecognized"
700 b"share-safe mismatch with source.\nUnrecognized"
701 b" value '%s' of `share.safe-mismatch.source-safe` set."
701 b" value '%s' of `share.safe-mismatch.source-safe` set."
702 )
702 )
703 % mismatch_config,
703 % mismatch_config,
704 hint=hint,
704 hint=hint,
705 )
705 )
706
706
707 # The .hg/hgrc file may load extensions or contain config options
707 # The .hg/hgrc file may load extensions or contain config options
708 # that influence repository construction. Attempt to load it and
708 # that influence repository construction. Attempt to load it and
709 # process any new extensions that it may have pulled in.
709 # process any new extensions that it may have pulled in.
710 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
710 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
711 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
711 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
712 extensions.loadall(ui)
712 extensions.loadall(ui)
713 extensions.populateui(ui)
713 extensions.populateui(ui)
714
714
715 # Set of module names of extensions loaded for this repository.
715 # Set of module names of extensions loaded for this repository.
716 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
716 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
717
717
718 supportedrequirements = gathersupportedrequirements(ui)
718 supportedrequirements = gathersupportedrequirements(ui)
719
719
720 # We first validate the requirements are known.
720 # We first validate the requirements are known.
721 ensurerequirementsrecognized(requirements, supportedrequirements)
721 ensurerequirementsrecognized(requirements, supportedrequirements)
722
722
723 # Then we validate that the known set is reasonable to use together.
723 # Then we validate that the known set is reasonable to use together.
724 ensurerequirementscompatible(ui, requirements)
724 ensurerequirementscompatible(ui, requirements)
725
725
726 # TODO there are unhandled edge cases related to opening repositories with
726 # TODO there are unhandled edge cases related to opening repositories with
727 # shared storage. If storage is shared, we should also test for requirements
727 # shared storage. If storage is shared, we should also test for requirements
728 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
728 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
729 # that repo, as that repo may load extensions needed to open it. This is a
729 # that repo, as that repo may load extensions needed to open it. This is a
730 # bit complicated because we don't want the other hgrc to overwrite settings
730 # bit complicated because we don't want the other hgrc to overwrite settings
731 # in this hgrc.
731 # in this hgrc.
732 #
732 #
733 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
733 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
734 # file when sharing repos. But if a requirement is added after the share is
734 # file when sharing repos. But if a requirement is added after the share is
735 # performed, thereby introducing a new requirement for the opener, we may
735 # performed, thereby introducing a new requirement for the opener, we may
736 # will not see that and could encounter a run-time error interacting with
736 # will not see that and could encounter a run-time error interacting with
737 # that shared store since it has an unknown-to-us requirement.
737 # that shared store since it has an unknown-to-us requirement.
738
738
739 # At this point, we know we should be capable of opening the repository.
739 # At this point, we know we should be capable of opening the repository.
740 # Now get on with doing that.
740 # Now get on with doing that.
741
741
742 features = set()
742 features = set()
743
743
744 # The "store" part of the repository holds versioned data. How it is
744 # The "store" part of the repository holds versioned data. How it is
745 # accessed is determined by various requirements. If `shared` or
745 # accessed is determined by various requirements. If `shared` or
746 # `relshared` requirements are present, this indicates current repository
746 # `relshared` requirements are present, this indicates current repository
747 # is a share and store exists in path mentioned in `.hg/sharedpath`
747 # is a share and store exists in path mentioned in `.hg/sharedpath`
748 if shared:
748 if shared:
749 storebasepath = sharedvfs.base
749 storebasepath = sharedvfs.base
750 cachepath = sharedvfs.join(b'cache')
750 cachepath = sharedvfs.join(b'cache')
751 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
751 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
752 else:
752 else:
753 storebasepath = hgvfs.base
753 storebasepath = hgvfs.base
754 cachepath = hgvfs.join(b'cache')
754 cachepath = hgvfs.join(b'cache')
755 wcachepath = hgvfs.join(b'wcache')
755 wcachepath = hgvfs.join(b'wcache')
756
756
757 # The store has changed over time and the exact layout is dictated by
757 # The store has changed over time and the exact layout is dictated by
758 # requirements. The store interface abstracts differences across all
758 # requirements. The store interface abstracts differences across all
759 # of them.
759 # of them.
760 store = makestore(
760 store = makestore(
761 requirements,
761 requirements,
762 storebasepath,
762 storebasepath,
763 lambda base: vfsmod.vfs(base, cacheaudited=True),
763 lambda base: vfsmod.vfs(base, cacheaudited=True),
764 )
764 )
765 hgvfs.createmode = store.createmode
765 hgvfs.createmode = store.createmode
766
766
767 storevfs = store.vfs
767 storevfs = store.vfs
768 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
768 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
769
769
770 if (
770 if (
771 requirementsmod.REVLOGV2_REQUIREMENT in requirements
771 requirementsmod.REVLOGV2_REQUIREMENT in requirements
772 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
772 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
773 ):
773 ):
774 features.add(repository.REPO_FEATURE_SIDE_DATA)
774 features.add(repository.REPO_FEATURE_SIDE_DATA)
775 # the revlogv2 docket introduced race condition that we need to fix
775 # the revlogv2 docket introduced race condition that we need to fix
776 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
776 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
777
777
778 # The cache vfs is used to manage cache files.
778 # The cache vfs is used to manage cache files.
779 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
779 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
780 cachevfs.createmode = store.createmode
780 cachevfs.createmode = store.createmode
781 # The cache vfs is used to manage cache files related to the working copy
781 # The cache vfs is used to manage cache files related to the working copy
782 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
782 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
783 wcachevfs.createmode = store.createmode
783 wcachevfs.createmode = store.createmode
784
784
785 # Now resolve the type for the repository object. We do this by repeatedly
785 # Now resolve the type for the repository object. We do this by repeatedly
786 # calling a factory function to produces types for specific aspects of the
786 # calling a factory function to produces types for specific aspects of the
787 # repo's operation. The aggregate returned types are used as base classes
787 # repo's operation. The aggregate returned types are used as base classes
788 # for a dynamically-derived type, which will represent our new repository.
788 # for a dynamically-derived type, which will represent our new repository.
789
789
790 bases = []
790 bases = []
791 extrastate = {}
791 extrastate = {}
792
792
793 for iface, fn in REPO_INTERFACES:
793 for iface, fn in REPO_INTERFACES:
794 # We pass all potentially useful state to give extensions tons of
794 # We pass all potentially useful state to give extensions tons of
795 # flexibility.
795 # flexibility.
796 typ = fn()(
796 typ = fn()(
797 ui=ui,
797 ui=ui,
798 intents=intents,
798 intents=intents,
799 requirements=requirements,
799 requirements=requirements,
800 features=features,
800 features=features,
801 wdirvfs=wdirvfs,
801 wdirvfs=wdirvfs,
802 hgvfs=hgvfs,
802 hgvfs=hgvfs,
803 store=store,
803 store=store,
804 storevfs=storevfs,
804 storevfs=storevfs,
805 storeoptions=storevfs.options,
805 storeoptions=storevfs.options,
806 cachevfs=cachevfs,
806 cachevfs=cachevfs,
807 wcachevfs=wcachevfs,
807 wcachevfs=wcachevfs,
808 extensionmodulenames=extensionmodulenames,
808 extensionmodulenames=extensionmodulenames,
809 extrastate=extrastate,
809 extrastate=extrastate,
810 baseclasses=bases,
810 baseclasses=bases,
811 )
811 )
812
812
813 if not isinstance(typ, type):
813 if not isinstance(typ, type):
814 raise error.ProgrammingError(
814 raise error.ProgrammingError(
815 b'unable to construct type for %s' % iface
815 b'unable to construct type for %s' % iface
816 )
816 )
817
817
818 bases.append(typ)
818 bases.append(typ)
819
819
820 # type() allows you to use characters in type names that wouldn't be
820 # type() allows you to use characters in type names that wouldn't be
821 # recognized as Python symbols in source code. We abuse that to add
821 # recognized as Python symbols in source code. We abuse that to add
822 # rich information about our constructed repo.
822 # rich information about our constructed repo.
823 name = pycompat.sysstr(
823 name = pycompat.sysstr(
824 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
824 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
825 )
825 )
826
826
827 cls = type(name, tuple(bases), {})
827 cls = type(name, tuple(bases), {})
828
828
829 return cls(
829 return cls(
830 baseui=baseui,
830 baseui=baseui,
831 ui=ui,
831 ui=ui,
832 origroot=path,
832 origroot=path,
833 wdirvfs=wdirvfs,
833 wdirvfs=wdirvfs,
834 hgvfs=hgvfs,
834 hgvfs=hgvfs,
835 requirements=requirements,
835 requirements=requirements,
836 supportedrequirements=supportedrequirements,
836 supportedrequirements=supportedrequirements,
837 sharedpath=storebasepath,
837 sharedpath=storebasepath,
838 store=store,
838 store=store,
839 cachevfs=cachevfs,
839 cachevfs=cachevfs,
840 wcachevfs=wcachevfs,
840 wcachevfs=wcachevfs,
841 features=features,
841 features=features,
842 intents=intents,
842 intents=intents,
843 )
843 )
844
844
845
845
846 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
846 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
847 """Load hgrc files/content into a ui instance.
847 """Load hgrc files/content into a ui instance.
848
848
849 This is called during repository opening to load any additional
849 This is called during repository opening to load any additional
850 config files or settings relevant to the current repository.
850 config files or settings relevant to the current repository.
851
851
852 Returns a bool indicating whether any additional configs were loaded.
852 Returns a bool indicating whether any additional configs were loaded.
853
853
854 Extensions should monkeypatch this function to modify how per-repo
854 Extensions should monkeypatch this function to modify how per-repo
855 configs are loaded. For example, an extension may wish to pull in
855 configs are loaded. For example, an extension may wish to pull in
856 configs from alternate files or sources.
856 configs from alternate files or sources.
857
857
858 sharedvfs is vfs object pointing to source repo if the current one is a
858 sharedvfs is vfs object pointing to source repo if the current one is a
859 shared one
859 shared one
860 """
860 """
861 if not rcutil.use_repo_hgrc():
861 if not rcutil.use_repo_hgrc():
862 return False
862 return False
863
863
864 ret = False
864 ret = False
865 # first load config from shared source if we has to
865 # first load config from shared source if we has to
866 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
866 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
867 try:
867 try:
868 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
868 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
869 ret = True
869 ret = True
870 except IOError:
870 except IOError:
871 pass
871 pass
872
872
873 try:
873 try:
874 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
874 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
875 ret = True
875 ret = True
876 except IOError:
876 except IOError:
877 pass
877 pass
878
878
879 try:
879 try:
880 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
880 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
881 ret = True
881 ret = True
882 except IOError:
882 except IOError:
883 pass
883 pass
884
884
885 return ret
885 return ret
886
886
887
887
888 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
888 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
889 """Perform additional actions after .hg/hgrc is loaded.
889 """Perform additional actions after .hg/hgrc is loaded.
890
890
891 This function is called during repository loading immediately after
891 This function is called during repository loading immediately after
892 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
892 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
893
893
894 The function can be used to validate configs, automatically add
894 The function can be used to validate configs, automatically add
895 options (including extensions) based on requirements, etc.
895 options (including extensions) based on requirements, etc.
896 """
896 """
897
897
898 # Map of requirements to list of extensions to load automatically when
898 # Map of requirements to list of extensions to load automatically when
899 # requirement is present.
899 # requirement is present.
900 autoextensions = {
900 autoextensions = {
901 b'git': [b'git'],
901 b'git': [b'git'],
902 b'largefiles': [b'largefiles'],
902 b'largefiles': [b'largefiles'],
903 b'lfs': [b'lfs'],
903 b'lfs': [b'lfs'],
904 }
904 }
905
905
906 for requirement, names in sorted(autoextensions.items()):
906 for requirement, names in sorted(autoextensions.items()):
907 if requirement not in requirements:
907 if requirement not in requirements:
908 continue
908 continue
909
909
910 for name in names:
910 for name in names:
911 if not ui.hasconfig(b'extensions', name):
911 if not ui.hasconfig(b'extensions', name):
912 ui.setconfig(b'extensions', name, b'', source=b'autoload')
912 ui.setconfig(b'extensions', name, b'', source=b'autoload')
913
913
914
914
915 def gathersupportedrequirements(ui):
915 def gathersupportedrequirements(ui):
916 """Determine the complete set of recognized requirements."""
916 """Determine the complete set of recognized requirements."""
917 # Start with all requirements supported by this file.
917 # Start with all requirements supported by this file.
918 supported = set(localrepository._basesupported)
918 supported = set(localrepository._basesupported)
919
919
920 # Execute ``featuresetupfuncs`` entries if they belong to an extension
920 # Execute ``featuresetupfuncs`` entries if they belong to an extension
921 # relevant to this ui instance.
921 # relevant to this ui instance.
922 modules = {m.__name__ for n, m in extensions.extensions(ui)}
922 modules = {m.__name__ for n, m in extensions.extensions(ui)}
923
923
924 for fn in featuresetupfuncs:
924 for fn in featuresetupfuncs:
925 if fn.__module__ in modules:
925 if fn.__module__ in modules:
926 fn(ui, supported)
926 fn(ui, supported)
927
927
928 # Add derived requirements from registered compression engines.
928 # Add derived requirements from registered compression engines.
929 for name in util.compengines:
929 for name in util.compengines:
930 engine = util.compengines[name]
930 engine = util.compengines[name]
931 if engine.available() and engine.revlogheader():
931 if engine.available() and engine.revlogheader():
932 supported.add(b'exp-compression-%s' % name)
932 supported.add(b'exp-compression-%s' % name)
933 if engine.name() == b'zstd':
933 if engine.name() == b'zstd':
934 supported.add(b'revlog-compression-zstd')
934 supported.add(b'revlog-compression-zstd')
935
935
936 return supported
936 return supported
937
937
938
938
939 def ensurerequirementsrecognized(requirements, supported):
939 def ensurerequirementsrecognized(requirements, supported):
940 """Validate that a set of local requirements is recognized.
940 """Validate that a set of local requirements is recognized.
941
941
942 Receives a set of requirements. Raises an ``error.RepoError`` if there
942 Receives a set of requirements. Raises an ``error.RepoError`` if there
943 exists any requirement in that set that currently loaded code doesn't
943 exists any requirement in that set that currently loaded code doesn't
944 recognize.
944 recognize.
945
945
946 Returns a set of supported requirements.
946 Returns a set of supported requirements.
947 """
947 """
948 missing = set()
948 missing = set()
949
949
950 for requirement in requirements:
950 for requirement in requirements:
951 if requirement in supported:
951 if requirement in supported:
952 continue
952 continue
953
953
954 if not requirement or not requirement[0:1].isalnum():
954 if not requirement or not requirement[0:1].isalnum():
955 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
955 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
956
956
957 missing.add(requirement)
957 missing.add(requirement)
958
958
959 if missing:
959 if missing:
960 raise error.RequirementError(
960 raise error.RequirementError(
961 _(b'repository requires features unknown to this Mercurial: %s')
961 _(b'repository requires features unknown to this Mercurial: %s')
962 % b' '.join(sorted(missing)),
962 % b' '.join(sorted(missing)),
963 hint=_(
963 hint=_(
964 b'see https://mercurial-scm.org/wiki/MissingRequirement '
964 b'see https://mercurial-scm.org/wiki/MissingRequirement '
965 b'for more information'
965 b'for more information'
966 ),
966 ),
967 )
967 )
968
968
969
969
970 def ensurerequirementscompatible(ui, requirements):
970 def ensurerequirementscompatible(ui, requirements):
971 """Validates that a set of recognized requirements is mutually compatible.
971 """Validates that a set of recognized requirements is mutually compatible.
972
972
973 Some requirements may not be compatible with others or require
973 Some requirements may not be compatible with others or require
974 config options that aren't enabled. This function is called during
974 config options that aren't enabled. This function is called during
975 repository opening to ensure that the set of requirements needed
975 repository opening to ensure that the set of requirements needed
976 to open a repository is sane and compatible with config options.
976 to open a repository is sane and compatible with config options.
977
977
978 Extensions can monkeypatch this function to perform additional
978 Extensions can monkeypatch this function to perform additional
979 checking.
979 checking.
980
980
981 ``error.RepoError`` should be raised on failure.
981 ``error.RepoError`` should be raised on failure.
982 """
982 """
983 if (
983 if (
984 requirementsmod.SPARSE_REQUIREMENT in requirements
984 requirementsmod.SPARSE_REQUIREMENT in requirements
985 and not sparse.enabled
985 and not sparse.enabled
986 ):
986 ):
987 raise error.RepoError(
987 raise error.RepoError(
988 _(
988 _(
989 b'repository is using sparse feature but '
989 b'repository is using sparse feature but '
990 b'sparse is not enabled; enable the '
990 b'sparse is not enabled; enable the '
991 b'"sparse" extensions to access'
991 b'"sparse" extensions to access'
992 )
992 )
993 )
993 )
994
994
995
995
996 def makestore(requirements, path, vfstype):
996 def makestore(requirements, path, vfstype):
997 """Construct a storage object for a repository."""
997 """Construct a storage object for a repository."""
998 if requirementsmod.STORE_REQUIREMENT in requirements:
998 if requirementsmod.STORE_REQUIREMENT in requirements:
999 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
999 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
1000 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
1000 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
1001 return storemod.fncachestore(path, vfstype, dotencode)
1001 return storemod.fncachestore(path, vfstype, dotencode)
1002
1002
1003 return storemod.encodedstore(path, vfstype)
1003 return storemod.encodedstore(path, vfstype)
1004
1004
1005 return storemod.basicstore(path, vfstype)
1005 return storemod.basicstore(path, vfstype)
1006
1006
1007
1007
1008 def resolvestorevfsoptions(ui, requirements, features):
1008 def resolvestorevfsoptions(ui, requirements, features):
1009 """Resolve the options to pass to the store vfs opener.
1009 """Resolve the options to pass to the store vfs opener.
1010
1010
1011 The returned dict is used to influence behavior of the storage layer.
1011 The returned dict is used to influence behavior of the storage layer.
1012 """
1012 """
1013 options = {}
1013 options = {}
1014
1014
1015 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
1015 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
1016 options[b'treemanifest'] = True
1016 options[b'treemanifest'] = True
1017
1017
1018 # experimental config: format.manifestcachesize
1018 # experimental config: format.manifestcachesize
1019 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
1019 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
1020 if manifestcachesize is not None:
1020 if manifestcachesize is not None:
1021 options[b'manifestcachesize'] = manifestcachesize
1021 options[b'manifestcachesize'] = manifestcachesize
1022
1022
1023 # In the absence of another requirement superseding a revlog-related
1023 # In the absence of another requirement superseding a revlog-related
1024 # requirement, we have to assume the repo is using revlog version 0.
1024 # requirement, we have to assume the repo is using revlog version 0.
1025 # This revlog format is super old and we don't bother trying to parse
1025 # This revlog format is super old and we don't bother trying to parse
1026 # opener options for it because those options wouldn't do anything
1026 # opener options for it because those options wouldn't do anything
1027 # meaningful on such old repos.
1027 # meaningful on such old repos.
1028 if (
1028 if (
1029 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1029 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1030 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1030 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1031 ):
1031 ):
1032 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1032 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1033 else: # explicitly mark repo as using revlogv0
1033 else: # explicitly mark repo as using revlogv0
1034 options[b'revlogv0'] = True
1034 options[b'revlogv0'] = True
1035
1035
1036 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1036 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1037 options[b'copies-storage'] = b'changeset-sidedata'
1037 options[b'copies-storage'] = b'changeset-sidedata'
1038 else:
1038 else:
1039 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1039 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1040 copiesextramode = (b'changeset-only', b'compatibility')
1040 copiesextramode = (b'changeset-only', b'compatibility')
1041 if writecopiesto in copiesextramode:
1041 if writecopiesto in copiesextramode:
1042 options[b'copies-storage'] = b'extra'
1042 options[b'copies-storage'] = b'extra'
1043
1043
1044 return options
1044 return options
1045
1045
1046
1046
1047 def resolverevlogstorevfsoptions(ui, requirements, features):
1047 def resolverevlogstorevfsoptions(ui, requirements, features):
1048 """Resolve opener options specific to revlogs."""
1048 """Resolve opener options specific to revlogs."""
1049
1049
1050 options = {}
1050 options = {}
1051 options[b'flagprocessors'] = {}
1051 options[b'flagprocessors'] = {}
1052
1052
1053 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1053 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1054 options[b'revlogv1'] = True
1054 options[b'revlogv1'] = True
1055 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1055 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1056 options[b'revlogv2'] = True
1056 options[b'revlogv2'] = True
1057 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1057 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1058 options[b'changelogv2'] = True
1058 options[b'changelogv2'] = True
1059
1059
1060 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1060 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1061 options[b'generaldelta'] = True
1061 options[b'generaldelta'] = True
1062
1062
1063 # experimental config: format.chunkcachesize
1063 # experimental config: format.chunkcachesize
1064 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1064 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1065 if chunkcachesize is not None:
1065 if chunkcachesize is not None:
1066 options[b'chunkcachesize'] = chunkcachesize
1066 options[b'chunkcachesize'] = chunkcachesize
1067
1067
1068 deltabothparents = ui.configbool(
1068 deltabothparents = ui.configbool(
1069 b'storage', b'revlog.optimize-delta-parent-choice'
1069 b'storage', b'revlog.optimize-delta-parent-choice'
1070 )
1070 )
1071 options[b'deltabothparents'] = deltabothparents
1071 options[b'deltabothparents'] = deltabothparents
1072
1072
1073 issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming')
1073 issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming')
1074 options[b'issue6528.fix-incoming'] = issue6528
1074 options[b'issue6528.fix-incoming'] = issue6528
1075
1075
1076 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1076 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1077 lazydeltabase = False
1077 lazydeltabase = False
1078 if lazydelta:
1078 if lazydelta:
1079 lazydeltabase = ui.configbool(
1079 lazydeltabase = ui.configbool(
1080 b'storage', b'revlog.reuse-external-delta-parent'
1080 b'storage', b'revlog.reuse-external-delta-parent'
1081 )
1081 )
1082 if lazydeltabase is None:
1082 if lazydeltabase is None:
1083 lazydeltabase = not scmutil.gddeltaconfig(ui)
1083 lazydeltabase = not scmutil.gddeltaconfig(ui)
1084 options[b'lazydelta'] = lazydelta
1084 options[b'lazydelta'] = lazydelta
1085 options[b'lazydeltabase'] = lazydeltabase
1085 options[b'lazydeltabase'] = lazydeltabase
1086
1086
1087 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1087 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1088 if 0 <= chainspan:
1088 if 0 <= chainspan:
1089 options[b'maxdeltachainspan'] = chainspan
1089 options[b'maxdeltachainspan'] = chainspan
1090
1090
1091 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1091 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1092 if mmapindexthreshold is not None:
1092 if mmapindexthreshold is not None:
1093 options[b'mmapindexthreshold'] = mmapindexthreshold
1093 options[b'mmapindexthreshold'] = mmapindexthreshold
1094
1094
1095 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1095 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1096 srdensitythres = float(
1096 srdensitythres = float(
1097 ui.config(b'experimental', b'sparse-read.density-threshold')
1097 ui.config(b'experimental', b'sparse-read.density-threshold')
1098 )
1098 )
1099 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1099 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1100 options[b'with-sparse-read'] = withsparseread
1100 options[b'with-sparse-read'] = withsparseread
1101 options[b'sparse-read-density-threshold'] = srdensitythres
1101 options[b'sparse-read-density-threshold'] = srdensitythres
1102 options[b'sparse-read-min-gap-size'] = srmingapsize
1102 options[b'sparse-read-min-gap-size'] = srmingapsize
1103
1103
1104 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1104 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1105 options[b'sparse-revlog'] = sparserevlog
1105 options[b'sparse-revlog'] = sparserevlog
1106 if sparserevlog:
1106 if sparserevlog:
1107 options[b'generaldelta'] = True
1107 options[b'generaldelta'] = True
1108
1108
1109 maxchainlen = None
1109 maxchainlen = None
1110 if sparserevlog:
1110 if sparserevlog:
1111 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1111 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1112 # experimental config: format.maxchainlen
1112 # experimental config: format.maxchainlen
1113 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1113 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1114 if maxchainlen is not None:
1114 if maxchainlen is not None:
1115 options[b'maxchainlen'] = maxchainlen
1115 options[b'maxchainlen'] = maxchainlen
1116
1116
1117 for r in requirements:
1117 for r in requirements:
1118 # we allow multiple compression engine requirement to co-exist because
1118 # we allow multiple compression engine requirement to co-exist because
1119 # strickly speaking, revlog seems to support mixed compression style.
1119 # strickly speaking, revlog seems to support mixed compression style.
1120 #
1120 #
1121 # The compression used for new entries will be "the last one"
1121 # The compression used for new entries will be "the last one"
1122 prefix = r.startswith
1122 prefix = r.startswith
1123 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1123 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1124 options[b'compengine'] = r.split(b'-', 2)[2]
1124 options[b'compengine'] = r.split(b'-', 2)[2]
1125
1125
1126 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1126 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1127 if options[b'zlib.level'] is not None:
1127 if options[b'zlib.level'] is not None:
1128 if not (0 <= options[b'zlib.level'] <= 9):
1128 if not (0 <= options[b'zlib.level'] <= 9):
1129 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1129 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1130 raise error.Abort(msg % options[b'zlib.level'])
1130 raise error.Abort(msg % options[b'zlib.level'])
1131 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1131 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1132 if options[b'zstd.level'] is not None:
1132 if options[b'zstd.level'] is not None:
1133 if not (0 <= options[b'zstd.level'] <= 22):
1133 if not (0 <= options[b'zstd.level'] <= 22):
1134 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1134 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1135 raise error.Abort(msg % options[b'zstd.level'])
1135 raise error.Abort(msg % options[b'zstd.level'])
1136
1136
1137 if requirementsmod.NARROW_REQUIREMENT in requirements:
1137 if requirementsmod.NARROW_REQUIREMENT in requirements:
1138 options[b'enableellipsis'] = True
1138 options[b'enableellipsis'] = True
1139
1139
1140 if ui.configbool(b'experimental', b'rust.index'):
1140 if ui.configbool(b'experimental', b'rust.index'):
1141 options[b'rust.index'] = True
1141 options[b'rust.index'] = True
1142 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1142 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1143 slow_path = ui.config(
1143 slow_path = ui.config(
1144 b'storage', b'revlog.persistent-nodemap.slow-path'
1144 b'storage', b'revlog.persistent-nodemap.slow-path'
1145 )
1145 )
1146 if slow_path not in (b'allow', b'warn', b'abort'):
1146 if slow_path not in (b'allow', b'warn', b'abort'):
1147 default = ui.config_default(
1147 default = ui.config_default(
1148 b'storage', b'revlog.persistent-nodemap.slow-path'
1148 b'storage', b'revlog.persistent-nodemap.slow-path'
1149 )
1149 )
1150 msg = _(
1150 msg = _(
1151 b'unknown value for config '
1151 b'unknown value for config '
1152 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1152 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1153 )
1153 )
1154 ui.warn(msg % slow_path)
1154 ui.warn(msg % slow_path)
1155 if not ui.quiet:
1155 if not ui.quiet:
1156 ui.warn(_(b'falling back to default value: %s\n') % default)
1156 ui.warn(_(b'falling back to default value: %s\n') % default)
1157 slow_path = default
1157 slow_path = default
1158
1158
1159 msg = _(
1159 msg = _(
1160 b"accessing `persistent-nodemap` repository without associated "
1160 b"accessing `persistent-nodemap` repository without associated "
1161 b"fast implementation."
1161 b"fast implementation."
1162 )
1162 )
1163 hint = _(
1163 hint = _(
1164 b"check `hg help config.format.use-persistent-nodemap` "
1164 b"check `hg help config.format.use-persistent-nodemap` "
1165 b"for details"
1165 b"for details"
1166 )
1166 )
1167 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1167 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1168 if slow_path == b'warn':
1168 if slow_path == b'warn':
1169 msg = b"warning: " + msg + b'\n'
1169 msg = b"warning: " + msg + b'\n'
1170 ui.warn(msg)
1170 ui.warn(msg)
1171 if not ui.quiet:
1171 if not ui.quiet:
1172 hint = b'(' + hint + b')\n'
1172 hint = b'(' + hint + b')\n'
1173 ui.warn(hint)
1173 ui.warn(hint)
1174 if slow_path == b'abort':
1174 if slow_path == b'abort':
1175 raise error.Abort(msg, hint=hint)
1175 raise error.Abort(msg, hint=hint)
1176 options[b'persistent-nodemap'] = True
1176 options[b'persistent-nodemap'] = True
1177 if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements:
1177 if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements:
1178 slow_path = ui.config(b'storage', b'dirstate-v2.slow-path')
1178 slow_path = ui.config(b'storage', b'dirstate-v2.slow-path')
1179 if slow_path not in (b'allow', b'warn', b'abort'):
1179 if slow_path not in (b'allow', b'warn', b'abort'):
1180 default = ui.config_default(b'storage', b'dirstate-v2.slow-path')
1180 default = ui.config_default(b'storage', b'dirstate-v2.slow-path')
1181 msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n')
1181 msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n')
1182 ui.warn(msg % slow_path)
1182 ui.warn(msg % slow_path)
1183 if not ui.quiet:
1183 if not ui.quiet:
1184 ui.warn(_(b'falling back to default value: %s\n') % default)
1184 ui.warn(_(b'falling back to default value: %s\n') % default)
1185 slow_path = default
1185 slow_path = default
1186
1186
1187 msg = _(
1187 msg = _(
1188 b"accessing `dirstate-v2` repository without associated "
1188 b"accessing `dirstate-v2` repository without associated "
1189 b"fast implementation."
1189 b"fast implementation."
1190 )
1190 )
1191 hint = _(
1191 hint = _(
1192 b"check `hg help config.format.exp-rc-dirstate-v2` " b"for details"
1192 b"check `hg help config.format.use-dirstate-v2` " b"for details"
1193 )
1193 )
1194 if not dirstate.HAS_FAST_DIRSTATE_V2:
1194 if not dirstate.HAS_FAST_DIRSTATE_V2:
1195 if slow_path == b'warn':
1195 if slow_path == b'warn':
1196 msg = b"warning: " + msg + b'\n'
1196 msg = b"warning: " + msg + b'\n'
1197 ui.warn(msg)
1197 ui.warn(msg)
1198 if not ui.quiet:
1198 if not ui.quiet:
1199 hint = b'(' + hint + b')\n'
1199 hint = b'(' + hint + b')\n'
1200 ui.warn(hint)
1200 ui.warn(hint)
1201 if slow_path == b'abort':
1201 if slow_path == b'abort':
1202 raise error.Abort(msg, hint=hint)
1202 raise error.Abort(msg, hint=hint)
1203 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1203 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1204 options[b'persistent-nodemap.mmap'] = True
1204 options[b'persistent-nodemap.mmap'] = True
1205 if ui.configbool(b'devel', b'persistent-nodemap'):
1205 if ui.configbool(b'devel', b'persistent-nodemap'):
1206 options[b'devel-force-nodemap'] = True
1206 options[b'devel-force-nodemap'] = True
1207
1207
1208 return options
1208 return options
1209
1209
1210
1210
1211 def makemain(**kwargs):
1211 def makemain(**kwargs):
1212 """Produce a type conforming to ``ilocalrepositorymain``."""
1212 """Produce a type conforming to ``ilocalrepositorymain``."""
1213 return localrepository
1213 return localrepository
1214
1214
1215
1215
1216 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1216 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1217 class revlogfilestorage(object):
1217 class revlogfilestorage(object):
1218 """File storage when using revlogs."""
1218 """File storage when using revlogs."""
1219
1219
1220 def file(self, path):
1220 def file(self, path):
1221 if path.startswith(b'/'):
1221 if path.startswith(b'/'):
1222 path = path[1:]
1222 path = path[1:]
1223
1223
1224 return filelog.filelog(self.svfs, path)
1224 return filelog.filelog(self.svfs, path)
1225
1225
1226
1226
1227 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1227 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1228 class revlognarrowfilestorage(object):
1228 class revlognarrowfilestorage(object):
1229 """File storage when using revlogs and narrow files."""
1229 """File storage when using revlogs and narrow files."""
1230
1230
1231 def file(self, path):
1231 def file(self, path):
1232 if path.startswith(b'/'):
1232 if path.startswith(b'/'):
1233 path = path[1:]
1233 path = path[1:]
1234
1234
1235 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1235 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1236
1236
1237
1237
1238 def makefilestorage(requirements, features, **kwargs):
1238 def makefilestorage(requirements, features, **kwargs):
1239 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1239 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1240 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1240 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1241 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1241 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1242
1242
1243 if requirementsmod.NARROW_REQUIREMENT in requirements:
1243 if requirementsmod.NARROW_REQUIREMENT in requirements:
1244 return revlognarrowfilestorage
1244 return revlognarrowfilestorage
1245 else:
1245 else:
1246 return revlogfilestorage
1246 return revlogfilestorage
1247
1247
1248
1248
1249 # List of repository interfaces and factory functions for them. Each
1249 # List of repository interfaces and factory functions for them. Each
1250 # will be called in order during ``makelocalrepository()`` to iteratively
1250 # will be called in order during ``makelocalrepository()`` to iteratively
1251 # derive the final type for a local repository instance. We capture the
1251 # derive the final type for a local repository instance. We capture the
1252 # function as a lambda so we don't hold a reference and the module-level
1252 # function as a lambda so we don't hold a reference and the module-level
1253 # functions can be wrapped.
1253 # functions can be wrapped.
1254 REPO_INTERFACES = [
1254 REPO_INTERFACES = [
1255 (repository.ilocalrepositorymain, lambda: makemain),
1255 (repository.ilocalrepositorymain, lambda: makemain),
1256 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1256 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1257 ]
1257 ]
1258
1258
1259
1259
1260 @interfaceutil.implementer(repository.ilocalrepositorymain)
1260 @interfaceutil.implementer(repository.ilocalrepositorymain)
1261 class localrepository(object):
1261 class localrepository(object):
1262 """Main class for representing local repositories.
1262 """Main class for representing local repositories.
1263
1263
1264 All local repositories are instances of this class.
1264 All local repositories are instances of this class.
1265
1265
1266 Constructed on its own, instances of this class are not usable as
1266 Constructed on its own, instances of this class are not usable as
1267 repository objects. To obtain a usable repository object, call
1267 repository objects. To obtain a usable repository object, call
1268 ``hg.repository()``, ``localrepo.instance()``, or
1268 ``hg.repository()``, ``localrepo.instance()``, or
1269 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1269 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1270 ``instance()`` adds support for creating new repositories.
1270 ``instance()`` adds support for creating new repositories.
1271 ``hg.repository()`` adds more extension integration, including calling
1271 ``hg.repository()`` adds more extension integration, including calling
1272 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1272 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1273 used.
1273 used.
1274 """
1274 """
1275
1275
1276 # obsolete experimental requirements:
1276 # obsolete experimental requirements:
1277 # - manifestv2: An experimental new manifest format that allowed
1277 # - manifestv2: An experimental new manifest format that allowed
1278 # for stem compression of long paths. Experiment ended up not
1278 # for stem compression of long paths. Experiment ended up not
1279 # being successful (repository sizes went up due to worse delta
1279 # being successful (repository sizes went up due to worse delta
1280 # chains), and the code was deleted in 4.6.
1280 # chains), and the code was deleted in 4.6.
1281 supportedformats = {
1281 supportedformats = {
1282 requirementsmod.REVLOGV1_REQUIREMENT,
1282 requirementsmod.REVLOGV1_REQUIREMENT,
1283 requirementsmod.GENERALDELTA_REQUIREMENT,
1283 requirementsmod.GENERALDELTA_REQUIREMENT,
1284 requirementsmod.TREEMANIFEST_REQUIREMENT,
1284 requirementsmod.TREEMANIFEST_REQUIREMENT,
1285 requirementsmod.COPIESSDC_REQUIREMENT,
1285 requirementsmod.COPIESSDC_REQUIREMENT,
1286 requirementsmod.REVLOGV2_REQUIREMENT,
1286 requirementsmod.REVLOGV2_REQUIREMENT,
1287 requirementsmod.CHANGELOGV2_REQUIREMENT,
1287 requirementsmod.CHANGELOGV2_REQUIREMENT,
1288 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1288 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1289 requirementsmod.NODEMAP_REQUIREMENT,
1289 requirementsmod.NODEMAP_REQUIREMENT,
1290 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1290 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1291 requirementsmod.SHARESAFE_REQUIREMENT,
1291 requirementsmod.SHARESAFE_REQUIREMENT,
1292 requirementsmod.DIRSTATE_V2_REQUIREMENT,
1292 requirementsmod.DIRSTATE_V2_REQUIREMENT,
1293 }
1293 }
1294 _basesupported = supportedformats | {
1294 _basesupported = supportedformats | {
1295 requirementsmod.STORE_REQUIREMENT,
1295 requirementsmod.STORE_REQUIREMENT,
1296 requirementsmod.FNCACHE_REQUIREMENT,
1296 requirementsmod.FNCACHE_REQUIREMENT,
1297 requirementsmod.SHARED_REQUIREMENT,
1297 requirementsmod.SHARED_REQUIREMENT,
1298 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1298 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1299 requirementsmod.DOTENCODE_REQUIREMENT,
1299 requirementsmod.DOTENCODE_REQUIREMENT,
1300 requirementsmod.SPARSE_REQUIREMENT,
1300 requirementsmod.SPARSE_REQUIREMENT,
1301 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1301 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1302 }
1302 }
1303
1303
1304 # list of prefix for file which can be written without 'wlock'
1304 # list of prefix for file which can be written without 'wlock'
1305 # Extensions should extend this list when needed
1305 # Extensions should extend this list when needed
1306 _wlockfreeprefix = {
1306 _wlockfreeprefix = {
1307 # We migh consider requiring 'wlock' for the next
1307 # We migh consider requiring 'wlock' for the next
1308 # two, but pretty much all the existing code assume
1308 # two, but pretty much all the existing code assume
1309 # wlock is not needed so we keep them excluded for
1309 # wlock is not needed so we keep them excluded for
1310 # now.
1310 # now.
1311 b'hgrc',
1311 b'hgrc',
1312 b'requires',
1312 b'requires',
1313 # XXX cache is a complicatged business someone
1313 # XXX cache is a complicatged business someone
1314 # should investigate this in depth at some point
1314 # should investigate this in depth at some point
1315 b'cache/',
1315 b'cache/',
1316 # XXX shouldn't be dirstate covered by the wlock?
1316 # XXX shouldn't be dirstate covered by the wlock?
1317 b'dirstate',
1317 b'dirstate',
1318 # XXX bisect was still a bit too messy at the time
1318 # XXX bisect was still a bit too messy at the time
1319 # this changeset was introduced. Someone should fix
1319 # this changeset was introduced. Someone should fix
1320 # the remainig bit and drop this line
1320 # the remainig bit and drop this line
1321 b'bisect.state',
1321 b'bisect.state',
1322 }
1322 }
1323
1323
1324 def __init__(
1324 def __init__(
1325 self,
1325 self,
1326 baseui,
1326 baseui,
1327 ui,
1327 ui,
1328 origroot,
1328 origroot,
1329 wdirvfs,
1329 wdirvfs,
1330 hgvfs,
1330 hgvfs,
1331 requirements,
1331 requirements,
1332 supportedrequirements,
1332 supportedrequirements,
1333 sharedpath,
1333 sharedpath,
1334 store,
1334 store,
1335 cachevfs,
1335 cachevfs,
1336 wcachevfs,
1336 wcachevfs,
1337 features,
1337 features,
1338 intents=None,
1338 intents=None,
1339 ):
1339 ):
1340 """Create a new local repository instance.
1340 """Create a new local repository instance.
1341
1341
1342 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1342 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1343 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1343 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1344 object.
1344 object.
1345
1345
1346 Arguments:
1346 Arguments:
1347
1347
1348 baseui
1348 baseui
1349 ``ui.ui`` instance that ``ui`` argument was based off of.
1349 ``ui.ui`` instance that ``ui`` argument was based off of.
1350
1350
1351 ui
1351 ui
1352 ``ui.ui`` instance for use by the repository.
1352 ``ui.ui`` instance for use by the repository.
1353
1353
1354 origroot
1354 origroot
1355 ``bytes`` path to working directory root of this repository.
1355 ``bytes`` path to working directory root of this repository.
1356
1356
1357 wdirvfs
1357 wdirvfs
1358 ``vfs.vfs`` rooted at the working directory.
1358 ``vfs.vfs`` rooted at the working directory.
1359
1359
1360 hgvfs
1360 hgvfs
1361 ``vfs.vfs`` rooted at .hg/
1361 ``vfs.vfs`` rooted at .hg/
1362
1362
1363 requirements
1363 requirements
1364 ``set`` of bytestrings representing repository opening requirements.
1364 ``set`` of bytestrings representing repository opening requirements.
1365
1365
1366 supportedrequirements
1366 supportedrequirements
1367 ``set`` of bytestrings representing repository requirements that we
1367 ``set`` of bytestrings representing repository requirements that we
1368 know how to open. May be a supetset of ``requirements``.
1368 know how to open. May be a supetset of ``requirements``.
1369
1369
1370 sharedpath
1370 sharedpath
1371 ``bytes`` Defining path to storage base directory. Points to a
1371 ``bytes`` Defining path to storage base directory. Points to a
1372 ``.hg/`` directory somewhere.
1372 ``.hg/`` directory somewhere.
1373
1373
1374 store
1374 store
1375 ``store.basicstore`` (or derived) instance providing access to
1375 ``store.basicstore`` (or derived) instance providing access to
1376 versioned storage.
1376 versioned storage.
1377
1377
1378 cachevfs
1378 cachevfs
1379 ``vfs.vfs`` used for cache files.
1379 ``vfs.vfs`` used for cache files.
1380
1380
1381 wcachevfs
1381 wcachevfs
1382 ``vfs.vfs`` used for cache files related to the working copy.
1382 ``vfs.vfs`` used for cache files related to the working copy.
1383
1383
1384 features
1384 features
1385 ``set`` of bytestrings defining features/capabilities of this
1385 ``set`` of bytestrings defining features/capabilities of this
1386 instance.
1386 instance.
1387
1387
1388 intents
1388 intents
1389 ``set`` of system strings indicating what this repo will be used
1389 ``set`` of system strings indicating what this repo will be used
1390 for.
1390 for.
1391 """
1391 """
1392 self.baseui = baseui
1392 self.baseui = baseui
1393 self.ui = ui
1393 self.ui = ui
1394 self.origroot = origroot
1394 self.origroot = origroot
1395 # vfs rooted at working directory.
1395 # vfs rooted at working directory.
1396 self.wvfs = wdirvfs
1396 self.wvfs = wdirvfs
1397 self.root = wdirvfs.base
1397 self.root = wdirvfs.base
1398 # vfs rooted at .hg/. Used to access most non-store paths.
1398 # vfs rooted at .hg/. Used to access most non-store paths.
1399 self.vfs = hgvfs
1399 self.vfs = hgvfs
1400 self.path = hgvfs.base
1400 self.path = hgvfs.base
1401 self.requirements = requirements
1401 self.requirements = requirements
1402 self.nodeconstants = sha1nodeconstants
1402 self.nodeconstants = sha1nodeconstants
1403 self.nullid = self.nodeconstants.nullid
1403 self.nullid = self.nodeconstants.nullid
1404 self.supported = supportedrequirements
1404 self.supported = supportedrequirements
1405 self.sharedpath = sharedpath
1405 self.sharedpath = sharedpath
1406 self.store = store
1406 self.store = store
1407 self.cachevfs = cachevfs
1407 self.cachevfs = cachevfs
1408 self.wcachevfs = wcachevfs
1408 self.wcachevfs = wcachevfs
1409 self.features = features
1409 self.features = features
1410
1410
1411 self.filtername = None
1411 self.filtername = None
1412
1412
1413 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1413 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1414 b'devel', b'check-locks'
1414 b'devel', b'check-locks'
1415 ):
1415 ):
1416 self.vfs.audit = self._getvfsward(self.vfs.audit)
1416 self.vfs.audit = self._getvfsward(self.vfs.audit)
1417 # A list of callback to shape the phase if no data were found.
1417 # A list of callback to shape the phase if no data were found.
1418 # Callback are in the form: func(repo, roots) --> processed root.
1418 # Callback are in the form: func(repo, roots) --> processed root.
1419 # This list it to be filled by extension during repo setup
1419 # This list it to be filled by extension during repo setup
1420 self._phasedefaults = []
1420 self._phasedefaults = []
1421
1421
1422 color.setup(self.ui)
1422 color.setup(self.ui)
1423
1423
1424 self.spath = self.store.path
1424 self.spath = self.store.path
1425 self.svfs = self.store.vfs
1425 self.svfs = self.store.vfs
1426 self.sjoin = self.store.join
1426 self.sjoin = self.store.join
1427 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1427 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1428 b'devel', b'check-locks'
1428 b'devel', b'check-locks'
1429 ):
1429 ):
1430 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1430 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1431 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1431 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1432 else: # standard vfs
1432 else: # standard vfs
1433 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1433 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1434
1434
1435 self._dirstatevalidatewarned = False
1435 self._dirstatevalidatewarned = False
1436
1436
1437 self._branchcaches = branchmap.BranchMapCache()
1437 self._branchcaches = branchmap.BranchMapCache()
1438 self._revbranchcache = None
1438 self._revbranchcache = None
1439 self._filterpats = {}
1439 self._filterpats = {}
1440 self._datafilters = {}
1440 self._datafilters = {}
1441 self._transref = self._lockref = self._wlockref = None
1441 self._transref = self._lockref = self._wlockref = None
1442
1442
1443 # A cache for various files under .hg/ that tracks file changes,
1443 # A cache for various files under .hg/ that tracks file changes,
1444 # (used by the filecache decorator)
1444 # (used by the filecache decorator)
1445 #
1445 #
1446 # Maps a property name to its util.filecacheentry
1446 # Maps a property name to its util.filecacheentry
1447 self._filecache = {}
1447 self._filecache = {}
1448
1448
1449 # hold sets of revision to be filtered
1449 # hold sets of revision to be filtered
1450 # should be cleared when something might have changed the filter value:
1450 # should be cleared when something might have changed the filter value:
1451 # - new changesets,
1451 # - new changesets,
1452 # - phase change,
1452 # - phase change,
1453 # - new obsolescence marker,
1453 # - new obsolescence marker,
1454 # - working directory parent change,
1454 # - working directory parent change,
1455 # - bookmark changes
1455 # - bookmark changes
1456 self.filteredrevcache = {}
1456 self.filteredrevcache = {}
1457
1457
1458 # post-dirstate-status hooks
1458 # post-dirstate-status hooks
1459 self._postdsstatus = []
1459 self._postdsstatus = []
1460
1460
1461 # generic mapping between names and nodes
1461 # generic mapping between names and nodes
1462 self.names = namespaces.namespaces()
1462 self.names = namespaces.namespaces()
1463
1463
1464 # Key to signature value.
1464 # Key to signature value.
1465 self._sparsesignaturecache = {}
1465 self._sparsesignaturecache = {}
1466 # Signature to cached matcher instance.
1466 # Signature to cached matcher instance.
1467 self._sparsematchercache = {}
1467 self._sparsematchercache = {}
1468
1468
1469 self._extrafilterid = repoview.extrafilter(ui)
1469 self._extrafilterid = repoview.extrafilter(ui)
1470
1470
1471 self.filecopiesmode = None
1471 self.filecopiesmode = None
1472 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1472 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1473 self.filecopiesmode = b'changeset-sidedata'
1473 self.filecopiesmode = b'changeset-sidedata'
1474
1474
1475 self._wanted_sidedata = set()
1475 self._wanted_sidedata = set()
1476 self._sidedata_computers = {}
1476 self._sidedata_computers = {}
1477 sidedatamod.set_sidedata_spec_for_repo(self)
1477 sidedatamod.set_sidedata_spec_for_repo(self)
1478
1478
1479 def _getvfsward(self, origfunc):
1479 def _getvfsward(self, origfunc):
1480 """build a ward for self.vfs"""
1480 """build a ward for self.vfs"""
1481 rref = weakref.ref(self)
1481 rref = weakref.ref(self)
1482
1482
1483 def checkvfs(path, mode=None):
1483 def checkvfs(path, mode=None):
1484 ret = origfunc(path, mode=mode)
1484 ret = origfunc(path, mode=mode)
1485 repo = rref()
1485 repo = rref()
1486 if (
1486 if (
1487 repo is None
1487 repo is None
1488 or not util.safehasattr(repo, b'_wlockref')
1488 or not util.safehasattr(repo, b'_wlockref')
1489 or not util.safehasattr(repo, b'_lockref')
1489 or not util.safehasattr(repo, b'_lockref')
1490 ):
1490 ):
1491 return
1491 return
1492 if mode in (None, b'r', b'rb'):
1492 if mode in (None, b'r', b'rb'):
1493 return
1493 return
1494 if path.startswith(repo.path):
1494 if path.startswith(repo.path):
1495 # truncate name relative to the repository (.hg)
1495 # truncate name relative to the repository (.hg)
1496 path = path[len(repo.path) + 1 :]
1496 path = path[len(repo.path) + 1 :]
1497 if path.startswith(b'cache/'):
1497 if path.startswith(b'cache/'):
1498 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1498 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1499 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1499 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1500 # path prefixes covered by 'lock'
1500 # path prefixes covered by 'lock'
1501 vfs_path_prefixes = (
1501 vfs_path_prefixes = (
1502 b'journal.',
1502 b'journal.',
1503 b'undo.',
1503 b'undo.',
1504 b'strip-backup/',
1504 b'strip-backup/',
1505 b'cache/',
1505 b'cache/',
1506 )
1506 )
1507 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1507 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1508 if repo._currentlock(repo._lockref) is None:
1508 if repo._currentlock(repo._lockref) is None:
1509 repo.ui.develwarn(
1509 repo.ui.develwarn(
1510 b'write with no lock: "%s"' % path,
1510 b'write with no lock: "%s"' % path,
1511 stacklevel=3,
1511 stacklevel=3,
1512 config=b'check-locks',
1512 config=b'check-locks',
1513 )
1513 )
1514 elif repo._currentlock(repo._wlockref) is None:
1514 elif repo._currentlock(repo._wlockref) is None:
1515 # rest of vfs files are covered by 'wlock'
1515 # rest of vfs files are covered by 'wlock'
1516 #
1516 #
1517 # exclude special files
1517 # exclude special files
1518 for prefix in self._wlockfreeprefix:
1518 for prefix in self._wlockfreeprefix:
1519 if path.startswith(prefix):
1519 if path.startswith(prefix):
1520 return
1520 return
1521 repo.ui.develwarn(
1521 repo.ui.develwarn(
1522 b'write with no wlock: "%s"' % path,
1522 b'write with no wlock: "%s"' % path,
1523 stacklevel=3,
1523 stacklevel=3,
1524 config=b'check-locks',
1524 config=b'check-locks',
1525 )
1525 )
1526 return ret
1526 return ret
1527
1527
1528 return checkvfs
1528 return checkvfs
1529
1529
1530 def _getsvfsward(self, origfunc):
1530 def _getsvfsward(self, origfunc):
1531 """build a ward for self.svfs"""
1531 """build a ward for self.svfs"""
1532 rref = weakref.ref(self)
1532 rref = weakref.ref(self)
1533
1533
1534 def checksvfs(path, mode=None):
1534 def checksvfs(path, mode=None):
1535 ret = origfunc(path, mode=mode)
1535 ret = origfunc(path, mode=mode)
1536 repo = rref()
1536 repo = rref()
1537 if repo is None or not util.safehasattr(repo, b'_lockref'):
1537 if repo is None or not util.safehasattr(repo, b'_lockref'):
1538 return
1538 return
1539 if mode in (None, b'r', b'rb'):
1539 if mode in (None, b'r', b'rb'):
1540 return
1540 return
1541 if path.startswith(repo.sharedpath):
1541 if path.startswith(repo.sharedpath):
1542 # truncate name relative to the repository (.hg)
1542 # truncate name relative to the repository (.hg)
1543 path = path[len(repo.sharedpath) + 1 :]
1543 path = path[len(repo.sharedpath) + 1 :]
1544 if repo._currentlock(repo._lockref) is None:
1544 if repo._currentlock(repo._lockref) is None:
1545 repo.ui.develwarn(
1545 repo.ui.develwarn(
1546 b'write with no lock: "%s"' % path, stacklevel=4
1546 b'write with no lock: "%s"' % path, stacklevel=4
1547 )
1547 )
1548 return ret
1548 return ret
1549
1549
1550 return checksvfs
1550 return checksvfs
1551
1551
1552 def close(self):
1552 def close(self):
1553 self._writecaches()
1553 self._writecaches()
1554
1554
1555 def _writecaches(self):
1555 def _writecaches(self):
1556 if self._revbranchcache:
1556 if self._revbranchcache:
1557 self._revbranchcache.write()
1557 self._revbranchcache.write()
1558
1558
1559 def _restrictcapabilities(self, caps):
1559 def _restrictcapabilities(self, caps):
1560 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1560 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1561 caps = set(caps)
1561 caps = set(caps)
1562 capsblob = bundle2.encodecaps(
1562 capsblob = bundle2.encodecaps(
1563 bundle2.getrepocaps(self, role=b'client')
1563 bundle2.getrepocaps(self, role=b'client')
1564 )
1564 )
1565 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1565 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1566 if self.ui.configbool(b'experimental', b'narrow'):
1566 if self.ui.configbool(b'experimental', b'narrow'):
1567 caps.add(wireprototypes.NARROWCAP)
1567 caps.add(wireprototypes.NARROWCAP)
1568 return caps
1568 return caps
1569
1569
1570 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1570 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1571 # self -> auditor -> self._checknested -> self
1571 # self -> auditor -> self._checknested -> self
1572
1572
1573 @property
1573 @property
1574 def auditor(self):
1574 def auditor(self):
1575 # This is only used by context.workingctx.match in order to
1575 # This is only used by context.workingctx.match in order to
1576 # detect files in subrepos.
1576 # detect files in subrepos.
1577 return pathutil.pathauditor(self.root, callback=self._checknested)
1577 return pathutil.pathauditor(self.root, callback=self._checknested)
1578
1578
1579 @property
1579 @property
1580 def nofsauditor(self):
1580 def nofsauditor(self):
1581 # This is only used by context.basectx.match in order to detect
1581 # This is only used by context.basectx.match in order to detect
1582 # files in subrepos.
1582 # files in subrepos.
1583 return pathutil.pathauditor(
1583 return pathutil.pathauditor(
1584 self.root, callback=self._checknested, realfs=False, cached=True
1584 self.root, callback=self._checknested, realfs=False, cached=True
1585 )
1585 )
1586
1586
1587 def _checknested(self, path):
1587 def _checknested(self, path):
1588 """Determine if path is a legal nested repository."""
1588 """Determine if path is a legal nested repository."""
1589 if not path.startswith(self.root):
1589 if not path.startswith(self.root):
1590 return False
1590 return False
1591 subpath = path[len(self.root) + 1 :]
1591 subpath = path[len(self.root) + 1 :]
1592 normsubpath = util.pconvert(subpath)
1592 normsubpath = util.pconvert(subpath)
1593
1593
1594 # XXX: Checking against the current working copy is wrong in
1594 # XXX: Checking against the current working copy is wrong in
1595 # the sense that it can reject things like
1595 # the sense that it can reject things like
1596 #
1596 #
1597 # $ hg cat -r 10 sub/x.txt
1597 # $ hg cat -r 10 sub/x.txt
1598 #
1598 #
1599 # if sub/ is no longer a subrepository in the working copy
1599 # if sub/ is no longer a subrepository in the working copy
1600 # parent revision.
1600 # parent revision.
1601 #
1601 #
1602 # However, it can of course also allow things that would have
1602 # However, it can of course also allow things that would have
1603 # been rejected before, such as the above cat command if sub/
1603 # been rejected before, such as the above cat command if sub/
1604 # is a subrepository now, but was a normal directory before.
1604 # is a subrepository now, but was a normal directory before.
1605 # The old path auditor would have rejected by mistake since it
1605 # The old path auditor would have rejected by mistake since it
1606 # panics when it sees sub/.hg/.
1606 # panics when it sees sub/.hg/.
1607 #
1607 #
1608 # All in all, checking against the working copy seems sensible
1608 # All in all, checking against the working copy seems sensible
1609 # since we want to prevent access to nested repositories on
1609 # since we want to prevent access to nested repositories on
1610 # the filesystem *now*.
1610 # the filesystem *now*.
1611 ctx = self[None]
1611 ctx = self[None]
1612 parts = util.splitpath(subpath)
1612 parts = util.splitpath(subpath)
1613 while parts:
1613 while parts:
1614 prefix = b'/'.join(parts)
1614 prefix = b'/'.join(parts)
1615 if prefix in ctx.substate:
1615 if prefix in ctx.substate:
1616 if prefix == normsubpath:
1616 if prefix == normsubpath:
1617 return True
1617 return True
1618 else:
1618 else:
1619 sub = ctx.sub(prefix)
1619 sub = ctx.sub(prefix)
1620 return sub.checknested(subpath[len(prefix) + 1 :])
1620 return sub.checknested(subpath[len(prefix) + 1 :])
1621 else:
1621 else:
1622 parts.pop()
1622 parts.pop()
1623 return False
1623 return False
1624
1624
1625 def peer(self):
1625 def peer(self):
1626 return localpeer(self) # not cached to avoid reference cycle
1626 return localpeer(self) # not cached to avoid reference cycle
1627
1627
1628 def unfiltered(self):
1628 def unfiltered(self):
1629 """Return unfiltered version of the repository
1629 """Return unfiltered version of the repository
1630
1630
1631 Intended to be overwritten by filtered repo."""
1631 Intended to be overwritten by filtered repo."""
1632 return self
1632 return self
1633
1633
1634 def filtered(self, name, visibilityexceptions=None):
1634 def filtered(self, name, visibilityexceptions=None):
1635 """Return a filtered version of a repository
1635 """Return a filtered version of a repository
1636
1636
1637 The `name` parameter is the identifier of the requested view. This
1637 The `name` parameter is the identifier of the requested view. This
1638 will return a repoview object set "exactly" to the specified view.
1638 will return a repoview object set "exactly" to the specified view.
1639
1639
1640 This function does not apply recursive filtering to a repository. For
1640 This function does not apply recursive filtering to a repository. For
1641 example calling `repo.filtered("served")` will return a repoview using
1641 example calling `repo.filtered("served")` will return a repoview using
1642 the "served" view, regardless of the initial view used by `repo`.
1642 the "served" view, regardless of the initial view used by `repo`.
1643
1643
1644 In other word, there is always only one level of `repoview` "filtering".
1644 In other word, there is always only one level of `repoview` "filtering".
1645 """
1645 """
1646 if self._extrafilterid is not None and b'%' not in name:
1646 if self._extrafilterid is not None and b'%' not in name:
1647 name = name + b'%' + self._extrafilterid
1647 name = name + b'%' + self._extrafilterid
1648
1648
1649 cls = repoview.newtype(self.unfiltered().__class__)
1649 cls = repoview.newtype(self.unfiltered().__class__)
1650 return cls(self, name, visibilityexceptions)
1650 return cls(self, name, visibilityexceptions)
1651
1651
1652 @mixedrepostorecache(
1652 @mixedrepostorecache(
1653 (b'bookmarks', b'plain'),
1653 (b'bookmarks', b'plain'),
1654 (b'bookmarks.current', b'plain'),
1654 (b'bookmarks.current', b'plain'),
1655 (b'bookmarks', b''),
1655 (b'bookmarks', b''),
1656 (b'00changelog.i', b''),
1656 (b'00changelog.i', b''),
1657 )
1657 )
1658 def _bookmarks(self):
1658 def _bookmarks(self):
1659 # Since the multiple files involved in the transaction cannot be
1659 # Since the multiple files involved in the transaction cannot be
1660 # written atomically (with current repository format), there is a race
1660 # written atomically (with current repository format), there is a race
1661 # condition here.
1661 # condition here.
1662 #
1662 #
1663 # 1) changelog content A is read
1663 # 1) changelog content A is read
1664 # 2) outside transaction update changelog to content B
1664 # 2) outside transaction update changelog to content B
1665 # 3) outside transaction update bookmark file referring to content B
1665 # 3) outside transaction update bookmark file referring to content B
1666 # 4) bookmarks file content is read and filtered against changelog-A
1666 # 4) bookmarks file content is read and filtered against changelog-A
1667 #
1667 #
1668 # When this happens, bookmarks against nodes missing from A are dropped.
1668 # When this happens, bookmarks against nodes missing from A are dropped.
1669 #
1669 #
1670 # Having this happening during read is not great, but it become worse
1670 # Having this happening during read is not great, but it become worse
1671 # when this happen during write because the bookmarks to the "unknown"
1671 # when this happen during write because the bookmarks to the "unknown"
1672 # nodes will be dropped for good. However, writes happen within locks.
1672 # nodes will be dropped for good. However, writes happen within locks.
1673 # This locking makes it possible to have a race free consistent read.
1673 # This locking makes it possible to have a race free consistent read.
1674 # For this purpose data read from disc before locking are
1674 # For this purpose data read from disc before locking are
1675 # "invalidated" right after the locks are taken. This invalidations are
1675 # "invalidated" right after the locks are taken. This invalidations are
1676 # "light", the `filecache` mechanism keep the data in memory and will
1676 # "light", the `filecache` mechanism keep the data in memory and will
1677 # reuse them if the underlying files did not changed. Not parsing the
1677 # reuse them if the underlying files did not changed. Not parsing the
1678 # same data multiple times helps performances.
1678 # same data multiple times helps performances.
1679 #
1679 #
1680 # Unfortunately in the case describe above, the files tracked by the
1680 # Unfortunately in the case describe above, the files tracked by the
1681 # bookmarks file cache might not have changed, but the in-memory
1681 # bookmarks file cache might not have changed, but the in-memory
1682 # content is still "wrong" because we used an older changelog content
1682 # content is still "wrong" because we used an older changelog content
1683 # to process the on-disk data. So after locking, the changelog would be
1683 # to process the on-disk data. So after locking, the changelog would be
1684 # refreshed but `_bookmarks` would be preserved.
1684 # refreshed but `_bookmarks` would be preserved.
1685 # Adding `00changelog.i` to the list of tracked file is not
1685 # Adding `00changelog.i` to the list of tracked file is not
1686 # enough, because at the time we build the content for `_bookmarks` in
1686 # enough, because at the time we build the content for `_bookmarks` in
1687 # (4), the changelog file has already diverged from the content used
1687 # (4), the changelog file has already diverged from the content used
1688 # for loading `changelog` in (1)
1688 # for loading `changelog` in (1)
1689 #
1689 #
1690 # To prevent the issue, we force the changelog to be explicitly
1690 # To prevent the issue, we force the changelog to be explicitly
1691 # reloaded while computing `_bookmarks`. The data race can still happen
1691 # reloaded while computing `_bookmarks`. The data race can still happen
1692 # without the lock (with a narrower window), but it would no longer go
1692 # without the lock (with a narrower window), but it would no longer go
1693 # undetected during the lock time refresh.
1693 # undetected during the lock time refresh.
1694 #
1694 #
1695 # The new schedule is as follow
1695 # The new schedule is as follow
1696 #
1696 #
1697 # 1) filecache logic detect that `_bookmarks` needs to be computed
1697 # 1) filecache logic detect that `_bookmarks` needs to be computed
1698 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1698 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1699 # 3) We force `changelog` filecache to be tested
1699 # 3) We force `changelog` filecache to be tested
1700 # 4) cachestat for `changelog` are captured (for changelog)
1700 # 4) cachestat for `changelog` are captured (for changelog)
1701 # 5) `_bookmarks` is computed and cached
1701 # 5) `_bookmarks` is computed and cached
1702 #
1702 #
1703 # The step in (3) ensure we have a changelog at least as recent as the
1703 # The step in (3) ensure we have a changelog at least as recent as the
1704 # cache stat computed in (1). As a result at locking time:
1704 # cache stat computed in (1). As a result at locking time:
1705 # * if the changelog did not changed since (1) -> we can reuse the data
1705 # * if the changelog did not changed since (1) -> we can reuse the data
1706 # * otherwise -> the bookmarks get refreshed.
1706 # * otherwise -> the bookmarks get refreshed.
1707 self._refreshchangelog()
1707 self._refreshchangelog()
1708 return bookmarks.bmstore(self)
1708 return bookmarks.bmstore(self)
1709
1709
1710 def _refreshchangelog(self):
1710 def _refreshchangelog(self):
1711 """make sure the in memory changelog match the on-disk one"""
1711 """make sure the in memory changelog match the on-disk one"""
1712 if 'changelog' in vars(self) and self.currenttransaction() is None:
1712 if 'changelog' in vars(self) and self.currenttransaction() is None:
1713 del self.changelog
1713 del self.changelog
1714
1714
1715 @property
1715 @property
1716 def _activebookmark(self):
1716 def _activebookmark(self):
1717 return self._bookmarks.active
1717 return self._bookmarks.active
1718
1718
1719 # _phasesets depend on changelog. what we need is to call
1719 # _phasesets depend on changelog. what we need is to call
1720 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1720 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1721 # can't be easily expressed in filecache mechanism.
1721 # can't be easily expressed in filecache mechanism.
1722 @storecache(b'phaseroots', b'00changelog.i')
1722 @storecache(b'phaseroots', b'00changelog.i')
1723 def _phasecache(self):
1723 def _phasecache(self):
1724 return phases.phasecache(self, self._phasedefaults)
1724 return phases.phasecache(self, self._phasedefaults)
1725
1725
1726 @storecache(b'obsstore')
1726 @storecache(b'obsstore')
1727 def obsstore(self):
1727 def obsstore(self):
1728 return obsolete.makestore(self.ui, self)
1728 return obsolete.makestore(self.ui, self)
1729
1729
1730 @changelogcache()
1730 @changelogcache()
1731 def changelog(repo):
1731 def changelog(repo):
1732 # load dirstate before changelog to avoid race see issue6303
1732 # load dirstate before changelog to avoid race see issue6303
1733 repo.dirstate.prefetch_parents()
1733 repo.dirstate.prefetch_parents()
1734 return repo.store.changelog(
1734 return repo.store.changelog(
1735 txnutil.mayhavepending(repo.root),
1735 txnutil.mayhavepending(repo.root),
1736 concurrencychecker=revlogchecker.get_checker(repo.ui, b'changelog'),
1736 concurrencychecker=revlogchecker.get_checker(repo.ui, b'changelog'),
1737 )
1737 )
1738
1738
1739 @manifestlogcache()
1739 @manifestlogcache()
1740 def manifestlog(self):
1740 def manifestlog(self):
1741 return self.store.manifestlog(self, self._storenarrowmatch)
1741 return self.store.manifestlog(self, self._storenarrowmatch)
1742
1742
1743 @repofilecache(b'dirstate')
1743 @repofilecache(b'dirstate')
1744 def dirstate(self):
1744 def dirstate(self):
1745 return self._makedirstate()
1745 return self._makedirstate()
1746
1746
1747 def _makedirstate(self):
1747 def _makedirstate(self):
1748 """Extension point for wrapping the dirstate per-repo."""
1748 """Extension point for wrapping the dirstate per-repo."""
1749 sparsematchfn = lambda: sparse.matcher(self)
1749 sparsematchfn = lambda: sparse.matcher(self)
1750 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1750 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1751 use_dirstate_v2 = v2_req in self.requirements
1751 use_dirstate_v2 = v2_req in self.requirements
1752
1752
1753 return dirstate.dirstate(
1753 return dirstate.dirstate(
1754 self.vfs,
1754 self.vfs,
1755 self.ui,
1755 self.ui,
1756 self.root,
1756 self.root,
1757 self._dirstatevalidate,
1757 self._dirstatevalidate,
1758 sparsematchfn,
1758 sparsematchfn,
1759 self.nodeconstants,
1759 self.nodeconstants,
1760 use_dirstate_v2,
1760 use_dirstate_v2,
1761 )
1761 )
1762
1762
1763 def _dirstatevalidate(self, node):
1763 def _dirstatevalidate(self, node):
1764 try:
1764 try:
1765 self.changelog.rev(node)
1765 self.changelog.rev(node)
1766 return node
1766 return node
1767 except error.LookupError:
1767 except error.LookupError:
1768 if not self._dirstatevalidatewarned:
1768 if not self._dirstatevalidatewarned:
1769 self._dirstatevalidatewarned = True
1769 self._dirstatevalidatewarned = True
1770 self.ui.warn(
1770 self.ui.warn(
1771 _(b"warning: ignoring unknown working parent %s!\n")
1771 _(b"warning: ignoring unknown working parent %s!\n")
1772 % short(node)
1772 % short(node)
1773 )
1773 )
1774 return self.nullid
1774 return self.nullid
1775
1775
1776 @storecache(narrowspec.FILENAME)
1776 @storecache(narrowspec.FILENAME)
1777 def narrowpats(self):
1777 def narrowpats(self):
1778 """matcher patterns for this repository's narrowspec
1778 """matcher patterns for this repository's narrowspec
1779
1779
1780 A tuple of (includes, excludes).
1780 A tuple of (includes, excludes).
1781 """
1781 """
1782 return narrowspec.load(self)
1782 return narrowspec.load(self)
1783
1783
1784 @storecache(narrowspec.FILENAME)
1784 @storecache(narrowspec.FILENAME)
1785 def _storenarrowmatch(self):
1785 def _storenarrowmatch(self):
1786 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1786 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1787 return matchmod.always()
1787 return matchmod.always()
1788 include, exclude = self.narrowpats
1788 include, exclude = self.narrowpats
1789 return narrowspec.match(self.root, include=include, exclude=exclude)
1789 return narrowspec.match(self.root, include=include, exclude=exclude)
1790
1790
1791 @storecache(narrowspec.FILENAME)
1791 @storecache(narrowspec.FILENAME)
1792 def _narrowmatch(self):
1792 def _narrowmatch(self):
1793 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1793 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1794 return matchmod.always()
1794 return matchmod.always()
1795 narrowspec.checkworkingcopynarrowspec(self)
1795 narrowspec.checkworkingcopynarrowspec(self)
1796 include, exclude = self.narrowpats
1796 include, exclude = self.narrowpats
1797 return narrowspec.match(self.root, include=include, exclude=exclude)
1797 return narrowspec.match(self.root, include=include, exclude=exclude)
1798
1798
1799 def narrowmatch(self, match=None, includeexact=False):
1799 def narrowmatch(self, match=None, includeexact=False):
1800 """matcher corresponding the the repo's narrowspec
1800 """matcher corresponding the the repo's narrowspec
1801
1801
1802 If `match` is given, then that will be intersected with the narrow
1802 If `match` is given, then that will be intersected with the narrow
1803 matcher.
1803 matcher.
1804
1804
1805 If `includeexact` is True, then any exact matches from `match` will
1805 If `includeexact` is True, then any exact matches from `match` will
1806 be included even if they're outside the narrowspec.
1806 be included even if they're outside the narrowspec.
1807 """
1807 """
1808 if match:
1808 if match:
1809 if includeexact and not self._narrowmatch.always():
1809 if includeexact and not self._narrowmatch.always():
1810 # do not exclude explicitly-specified paths so that they can
1810 # do not exclude explicitly-specified paths so that they can
1811 # be warned later on
1811 # be warned later on
1812 em = matchmod.exact(match.files())
1812 em = matchmod.exact(match.files())
1813 nm = matchmod.unionmatcher([self._narrowmatch, em])
1813 nm = matchmod.unionmatcher([self._narrowmatch, em])
1814 return matchmod.intersectmatchers(match, nm)
1814 return matchmod.intersectmatchers(match, nm)
1815 return matchmod.intersectmatchers(match, self._narrowmatch)
1815 return matchmod.intersectmatchers(match, self._narrowmatch)
1816 return self._narrowmatch
1816 return self._narrowmatch
1817
1817
1818 def setnarrowpats(self, newincludes, newexcludes):
1818 def setnarrowpats(self, newincludes, newexcludes):
1819 narrowspec.save(self, newincludes, newexcludes)
1819 narrowspec.save(self, newincludes, newexcludes)
1820 self.invalidate(clearfilecache=True)
1820 self.invalidate(clearfilecache=True)
1821
1821
1822 @unfilteredpropertycache
1822 @unfilteredpropertycache
1823 def _quick_access_changeid_null(self):
1823 def _quick_access_changeid_null(self):
1824 return {
1824 return {
1825 b'null': (nullrev, self.nodeconstants.nullid),
1825 b'null': (nullrev, self.nodeconstants.nullid),
1826 nullrev: (nullrev, self.nodeconstants.nullid),
1826 nullrev: (nullrev, self.nodeconstants.nullid),
1827 self.nullid: (nullrev, self.nullid),
1827 self.nullid: (nullrev, self.nullid),
1828 }
1828 }
1829
1829
1830 @unfilteredpropertycache
1830 @unfilteredpropertycache
1831 def _quick_access_changeid_wc(self):
1831 def _quick_access_changeid_wc(self):
1832 # also fast path access to the working copy parents
1832 # also fast path access to the working copy parents
1833 # however, only do it for filter that ensure wc is visible.
1833 # however, only do it for filter that ensure wc is visible.
1834 quick = self._quick_access_changeid_null.copy()
1834 quick = self._quick_access_changeid_null.copy()
1835 cl = self.unfiltered().changelog
1835 cl = self.unfiltered().changelog
1836 for node in self.dirstate.parents():
1836 for node in self.dirstate.parents():
1837 if node == self.nullid:
1837 if node == self.nullid:
1838 continue
1838 continue
1839 rev = cl.index.get_rev(node)
1839 rev = cl.index.get_rev(node)
1840 if rev is None:
1840 if rev is None:
1841 # unknown working copy parent case:
1841 # unknown working copy parent case:
1842 #
1842 #
1843 # skip the fast path and let higher code deal with it
1843 # skip the fast path and let higher code deal with it
1844 continue
1844 continue
1845 pair = (rev, node)
1845 pair = (rev, node)
1846 quick[rev] = pair
1846 quick[rev] = pair
1847 quick[node] = pair
1847 quick[node] = pair
1848 # also add the parents of the parents
1848 # also add the parents of the parents
1849 for r in cl.parentrevs(rev):
1849 for r in cl.parentrevs(rev):
1850 if r == nullrev:
1850 if r == nullrev:
1851 continue
1851 continue
1852 n = cl.node(r)
1852 n = cl.node(r)
1853 pair = (r, n)
1853 pair = (r, n)
1854 quick[r] = pair
1854 quick[r] = pair
1855 quick[n] = pair
1855 quick[n] = pair
1856 p1node = self.dirstate.p1()
1856 p1node = self.dirstate.p1()
1857 if p1node != self.nullid:
1857 if p1node != self.nullid:
1858 quick[b'.'] = quick[p1node]
1858 quick[b'.'] = quick[p1node]
1859 return quick
1859 return quick
1860
1860
1861 @unfilteredmethod
1861 @unfilteredmethod
1862 def _quick_access_changeid_invalidate(self):
1862 def _quick_access_changeid_invalidate(self):
1863 if '_quick_access_changeid_wc' in vars(self):
1863 if '_quick_access_changeid_wc' in vars(self):
1864 del self.__dict__['_quick_access_changeid_wc']
1864 del self.__dict__['_quick_access_changeid_wc']
1865
1865
1866 @property
1866 @property
1867 def _quick_access_changeid(self):
1867 def _quick_access_changeid(self):
1868 """an helper dictionnary for __getitem__ calls
1868 """an helper dictionnary for __getitem__ calls
1869
1869
1870 This contains a list of symbol we can recognise right away without
1870 This contains a list of symbol we can recognise right away without
1871 further processing.
1871 further processing.
1872 """
1872 """
1873 if self.filtername in repoview.filter_has_wc:
1873 if self.filtername in repoview.filter_has_wc:
1874 return self._quick_access_changeid_wc
1874 return self._quick_access_changeid_wc
1875 return self._quick_access_changeid_null
1875 return self._quick_access_changeid_null
1876
1876
1877 def __getitem__(self, changeid):
1877 def __getitem__(self, changeid):
1878 # dealing with special cases
1878 # dealing with special cases
1879 if changeid is None:
1879 if changeid is None:
1880 return context.workingctx(self)
1880 return context.workingctx(self)
1881 if isinstance(changeid, context.basectx):
1881 if isinstance(changeid, context.basectx):
1882 return changeid
1882 return changeid
1883
1883
1884 # dealing with multiple revisions
1884 # dealing with multiple revisions
1885 if isinstance(changeid, slice):
1885 if isinstance(changeid, slice):
1886 # wdirrev isn't contiguous so the slice shouldn't include it
1886 # wdirrev isn't contiguous so the slice shouldn't include it
1887 return [
1887 return [
1888 self[i]
1888 self[i]
1889 for i in pycompat.xrange(*changeid.indices(len(self)))
1889 for i in pycompat.xrange(*changeid.indices(len(self)))
1890 if i not in self.changelog.filteredrevs
1890 if i not in self.changelog.filteredrevs
1891 ]
1891 ]
1892
1892
1893 # dealing with some special values
1893 # dealing with some special values
1894 quick_access = self._quick_access_changeid.get(changeid)
1894 quick_access = self._quick_access_changeid.get(changeid)
1895 if quick_access is not None:
1895 if quick_access is not None:
1896 rev, node = quick_access
1896 rev, node = quick_access
1897 return context.changectx(self, rev, node, maybe_filtered=False)
1897 return context.changectx(self, rev, node, maybe_filtered=False)
1898 if changeid == b'tip':
1898 if changeid == b'tip':
1899 node = self.changelog.tip()
1899 node = self.changelog.tip()
1900 rev = self.changelog.rev(node)
1900 rev = self.changelog.rev(node)
1901 return context.changectx(self, rev, node)
1901 return context.changectx(self, rev, node)
1902
1902
1903 # dealing with arbitrary values
1903 # dealing with arbitrary values
1904 try:
1904 try:
1905 if isinstance(changeid, int):
1905 if isinstance(changeid, int):
1906 node = self.changelog.node(changeid)
1906 node = self.changelog.node(changeid)
1907 rev = changeid
1907 rev = changeid
1908 elif changeid == b'.':
1908 elif changeid == b'.':
1909 # this is a hack to delay/avoid loading obsmarkers
1909 # this is a hack to delay/avoid loading obsmarkers
1910 # when we know that '.' won't be hidden
1910 # when we know that '.' won't be hidden
1911 node = self.dirstate.p1()
1911 node = self.dirstate.p1()
1912 rev = self.unfiltered().changelog.rev(node)
1912 rev = self.unfiltered().changelog.rev(node)
1913 elif len(changeid) == self.nodeconstants.nodelen:
1913 elif len(changeid) == self.nodeconstants.nodelen:
1914 try:
1914 try:
1915 node = changeid
1915 node = changeid
1916 rev = self.changelog.rev(changeid)
1916 rev = self.changelog.rev(changeid)
1917 except error.FilteredLookupError:
1917 except error.FilteredLookupError:
1918 changeid = hex(changeid) # for the error message
1918 changeid = hex(changeid) # for the error message
1919 raise
1919 raise
1920 except LookupError:
1920 except LookupError:
1921 # check if it might have come from damaged dirstate
1921 # check if it might have come from damaged dirstate
1922 #
1922 #
1923 # XXX we could avoid the unfiltered if we had a recognizable
1923 # XXX we could avoid the unfiltered if we had a recognizable
1924 # exception for filtered changeset access
1924 # exception for filtered changeset access
1925 if (
1925 if (
1926 self.local()
1926 self.local()
1927 and changeid in self.unfiltered().dirstate.parents()
1927 and changeid in self.unfiltered().dirstate.parents()
1928 ):
1928 ):
1929 msg = _(b"working directory has unknown parent '%s'!")
1929 msg = _(b"working directory has unknown parent '%s'!")
1930 raise error.Abort(msg % short(changeid))
1930 raise error.Abort(msg % short(changeid))
1931 changeid = hex(changeid) # for the error message
1931 changeid = hex(changeid) # for the error message
1932 raise
1932 raise
1933
1933
1934 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1934 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1935 node = bin(changeid)
1935 node = bin(changeid)
1936 rev = self.changelog.rev(node)
1936 rev = self.changelog.rev(node)
1937 else:
1937 else:
1938 raise error.ProgrammingError(
1938 raise error.ProgrammingError(
1939 b"unsupported changeid '%s' of type %s"
1939 b"unsupported changeid '%s' of type %s"
1940 % (changeid, pycompat.bytestr(type(changeid)))
1940 % (changeid, pycompat.bytestr(type(changeid)))
1941 )
1941 )
1942
1942
1943 return context.changectx(self, rev, node)
1943 return context.changectx(self, rev, node)
1944
1944
1945 except (error.FilteredIndexError, error.FilteredLookupError):
1945 except (error.FilteredIndexError, error.FilteredLookupError):
1946 raise error.FilteredRepoLookupError(
1946 raise error.FilteredRepoLookupError(
1947 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1947 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1948 )
1948 )
1949 except (IndexError, LookupError):
1949 except (IndexError, LookupError):
1950 raise error.RepoLookupError(
1950 raise error.RepoLookupError(
1951 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1951 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1952 )
1952 )
1953 except error.WdirUnsupported:
1953 except error.WdirUnsupported:
1954 return context.workingctx(self)
1954 return context.workingctx(self)
1955
1955
1956 def __contains__(self, changeid):
1956 def __contains__(self, changeid):
1957 """True if the given changeid exists"""
1957 """True if the given changeid exists"""
1958 try:
1958 try:
1959 self[changeid]
1959 self[changeid]
1960 return True
1960 return True
1961 except error.RepoLookupError:
1961 except error.RepoLookupError:
1962 return False
1962 return False
1963
1963
1964 def __nonzero__(self):
1964 def __nonzero__(self):
1965 return True
1965 return True
1966
1966
1967 __bool__ = __nonzero__
1967 __bool__ = __nonzero__
1968
1968
1969 def __len__(self):
1969 def __len__(self):
1970 # no need to pay the cost of repoview.changelog
1970 # no need to pay the cost of repoview.changelog
1971 unfi = self.unfiltered()
1971 unfi = self.unfiltered()
1972 return len(unfi.changelog)
1972 return len(unfi.changelog)
1973
1973
1974 def __iter__(self):
1974 def __iter__(self):
1975 return iter(self.changelog)
1975 return iter(self.changelog)
1976
1976
1977 def revs(self, expr, *args):
1977 def revs(self, expr, *args):
1978 """Find revisions matching a revset.
1978 """Find revisions matching a revset.
1979
1979
1980 The revset is specified as a string ``expr`` that may contain
1980 The revset is specified as a string ``expr`` that may contain
1981 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1981 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1982
1982
1983 Revset aliases from the configuration are not expanded. To expand
1983 Revset aliases from the configuration are not expanded. To expand
1984 user aliases, consider calling ``scmutil.revrange()`` or
1984 user aliases, consider calling ``scmutil.revrange()`` or
1985 ``repo.anyrevs([expr], user=True)``.
1985 ``repo.anyrevs([expr], user=True)``.
1986
1986
1987 Returns a smartset.abstractsmartset, which is a list-like interface
1987 Returns a smartset.abstractsmartset, which is a list-like interface
1988 that contains integer revisions.
1988 that contains integer revisions.
1989 """
1989 """
1990 tree = revsetlang.spectree(expr, *args)
1990 tree = revsetlang.spectree(expr, *args)
1991 return revset.makematcher(tree)(self)
1991 return revset.makematcher(tree)(self)
1992
1992
1993 def set(self, expr, *args):
1993 def set(self, expr, *args):
1994 """Find revisions matching a revset and emit changectx instances.
1994 """Find revisions matching a revset and emit changectx instances.
1995
1995
1996 This is a convenience wrapper around ``revs()`` that iterates the
1996 This is a convenience wrapper around ``revs()`` that iterates the
1997 result and is a generator of changectx instances.
1997 result and is a generator of changectx instances.
1998
1998
1999 Revset aliases from the configuration are not expanded. To expand
1999 Revset aliases from the configuration are not expanded. To expand
2000 user aliases, consider calling ``scmutil.revrange()``.
2000 user aliases, consider calling ``scmutil.revrange()``.
2001 """
2001 """
2002 for r in self.revs(expr, *args):
2002 for r in self.revs(expr, *args):
2003 yield self[r]
2003 yield self[r]
2004
2004
2005 def anyrevs(self, specs, user=False, localalias=None):
2005 def anyrevs(self, specs, user=False, localalias=None):
2006 """Find revisions matching one of the given revsets.
2006 """Find revisions matching one of the given revsets.
2007
2007
2008 Revset aliases from the configuration are not expanded by default. To
2008 Revset aliases from the configuration are not expanded by default. To
2009 expand user aliases, specify ``user=True``. To provide some local
2009 expand user aliases, specify ``user=True``. To provide some local
2010 definitions overriding user aliases, set ``localalias`` to
2010 definitions overriding user aliases, set ``localalias`` to
2011 ``{name: definitionstring}``.
2011 ``{name: definitionstring}``.
2012 """
2012 """
2013 if specs == [b'null']:
2013 if specs == [b'null']:
2014 return revset.baseset([nullrev])
2014 return revset.baseset([nullrev])
2015 if specs == [b'.']:
2015 if specs == [b'.']:
2016 quick_data = self._quick_access_changeid.get(b'.')
2016 quick_data = self._quick_access_changeid.get(b'.')
2017 if quick_data is not None:
2017 if quick_data is not None:
2018 return revset.baseset([quick_data[0]])
2018 return revset.baseset([quick_data[0]])
2019 if user:
2019 if user:
2020 m = revset.matchany(
2020 m = revset.matchany(
2021 self.ui,
2021 self.ui,
2022 specs,
2022 specs,
2023 lookup=revset.lookupfn(self),
2023 lookup=revset.lookupfn(self),
2024 localalias=localalias,
2024 localalias=localalias,
2025 )
2025 )
2026 else:
2026 else:
2027 m = revset.matchany(None, specs, localalias=localalias)
2027 m = revset.matchany(None, specs, localalias=localalias)
2028 return m(self)
2028 return m(self)
2029
2029
2030 def url(self):
2030 def url(self):
2031 return b'file:' + self.root
2031 return b'file:' + self.root
2032
2032
2033 def hook(self, name, throw=False, **args):
2033 def hook(self, name, throw=False, **args):
2034 """Call a hook, passing this repo instance.
2034 """Call a hook, passing this repo instance.
2035
2035
2036 This a convenience method to aid invoking hooks. Extensions likely
2036 This a convenience method to aid invoking hooks. Extensions likely
2037 won't call this unless they have registered a custom hook or are
2037 won't call this unless they have registered a custom hook or are
2038 replacing code that is expected to call a hook.
2038 replacing code that is expected to call a hook.
2039 """
2039 """
2040 return hook.hook(self.ui, self, name, throw, **args)
2040 return hook.hook(self.ui, self, name, throw, **args)
2041
2041
2042 @filteredpropertycache
2042 @filteredpropertycache
2043 def _tagscache(self):
2043 def _tagscache(self):
2044 """Returns a tagscache object that contains various tags related
2044 """Returns a tagscache object that contains various tags related
2045 caches."""
2045 caches."""
2046
2046
2047 # This simplifies its cache management by having one decorated
2047 # This simplifies its cache management by having one decorated
2048 # function (this one) and the rest simply fetch things from it.
2048 # function (this one) and the rest simply fetch things from it.
2049 class tagscache(object):
2049 class tagscache(object):
2050 def __init__(self):
2050 def __init__(self):
2051 # These two define the set of tags for this repository. tags
2051 # These two define the set of tags for this repository. tags
2052 # maps tag name to node; tagtypes maps tag name to 'global' or
2052 # maps tag name to node; tagtypes maps tag name to 'global' or
2053 # 'local'. (Global tags are defined by .hgtags across all
2053 # 'local'. (Global tags are defined by .hgtags across all
2054 # heads, and local tags are defined in .hg/localtags.)
2054 # heads, and local tags are defined in .hg/localtags.)
2055 # They constitute the in-memory cache of tags.
2055 # They constitute the in-memory cache of tags.
2056 self.tags = self.tagtypes = None
2056 self.tags = self.tagtypes = None
2057
2057
2058 self.nodetagscache = self.tagslist = None
2058 self.nodetagscache = self.tagslist = None
2059
2059
2060 cache = tagscache()
2060 cache = tagscache()
2061 cache.tags, cache.tagtypes = self._findtags()
2061 cache.tags, cache.tagtypes = self._findtags()
2062
2062
2063 return cache
2063 return cache
2064
2064
2065 def tags(self):
2065 def tags(self):
2066 '''return a mapping of tag to node'''
2066 '''return a mapping of tag to node'''
2067 t = {}
2067 t = {}
2068 if self.changelog.filteredrevs:
2068 if self.changelog.filteredrevs:
2069 tags, tt = self._findtags()
2069 tags, tt = self._findtags()
2070 else:
2070 else:
2071 tags = self._tagscache.tags
2071 tags = self._tagscache.tags
2072 rev = self.changelog.rev
2072 rev = self.changelog.rev
2073 for k, v in pycompat.iteritems(tags):
2073 for k, v in pycompat.iteritems(tags):
2074 try:
2074 try:
2075 # ignore tags to unknown nodes
2075 # ignore tags to unknown nodes
2076 rev(v)
2076 rev(v)
2077 t[k] = v
2077 t[k] = v
2078 except (error.LookupError, ValueError):
2078 except (error.LookupError, ValueError):
2079 pass
2079 pass
2080 return t
2080 return t
2081
2081
2082 def _findtags(self):
2082 def _findtags(self):
2083 """Do the hard work of finding tags. Return a pair of dicts
2083 """Do the hard work of finding tags. Return a pair of dicts
2084 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2084 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2085 maps tag name to a string like \'global\' or \'local\'.
2085 maps tag name to a string like \'global\' or \'local\'.
2086 Subclasses or extensions are free to add their own tags, but
2086 Subclasses or extensions are free to add their own tags, but
2087 should be aware that the returned dicts will be retained for the
2087 should be aware that the returned dicts will be retained for the
2088 duration of the localrepo object."""
2088 duration of the localrepo object."""
2089
2089
2090 # XXX what tagtype should subclasses/extensions use? Currently
2090 # XXX what tagtype should subclasses/extensions use? Currently
2091 # mq and bookmarks add tags, but do not set the tagtype at all.
2091 # mq and bookmarks add tags, but do not set the tagtype at all.
2092 # Should each extension invent its own tag type? Should there
2092 # Should each extension invent its own tag type? Should there
2093 # be one tagtype for all such "virtual" tags? Or is the status
2093 # be one tagtype for all such "virtual" tags? Or is the status
2094 # quo fine?
2094 # quo fine?
2095
2095
2096 # map tag name to (node, hist)
2096 # map tag name to (node, hist)
2097 alltags = tagsmod.findglobaltags(self.ui, self)
2097 alltags = tagsmod.findglobaltags(self.ui, self)
2098 # map tag name to tag type
2098 # map tag name to tag type
2099 tagtypes = {tag: b'global' for tag in alltags}
2099 tagtypes = {tag: b'global' for tag in alltags}
2100
2100
2101 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2101 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2102
2102
2103 # Build the return dicts. Have to re-encode tag names because
2103 # Build the return dicts. Have to re-encode tag names because
2104 # the tags module always uses UTF-8 (in order not to lose info
2104 # the tags module always uses UTF-8 (in order not to lose info
2105 # writing to the cache), but the rest of Mercurial wants them in
2105 # writing to the cache), but the rest of Mercurial wants them in
2106 # local encoding.
2106 # local encoding.
2107 tags = {}
2107 tags = {}
2108 for (name, (node, hist)) in pycompat.iteritems(alltags):
2108 for (name, (node, hist)) in pycompat.iteritems(alltags):
2109 if node != self.nullid:
2109 if node != self.nullid:
2110 tags[encoding.tolocal(name)] = node
2110 tags[encoding.tolocal(name)] = node
2111 tags[b'tip'] = self.changelog.tip()
2111 tags[b'tip'] = self.changelog.tip()
2112 tagtypes = {
2112 tagtypes = {
2113 encoding.tolocal(name): value
2113 encoding.tolocal(name): value
2114 for (name, value) in pycompat.iteritems(tagtypes)
2114 for (name, value) in pycompat.iteritems(tagtypes)
2115 }
2115 }
2116 return (tags, tagtypes)
2116 return (tags, tagtypes)
2117
2117
2118 def tagtype(self, tagname):
2118 def tagtype(self, tagname):
2119 """
2119 """
2120 return the type of the given tag. result can be:
2120 return the type of the given tag. result can be:
2121
2121
2122 'local' : a local tag
2122 'local' : a local tag
2123 'global' : a global tag
2123 'global' : a global tag
2124 None : tag does not exist
2124 None : tag does not exist
2125 """
2125 """
2126
2126
2127 return self._tagscache.tagtypes.get(tagname)
2127 return self._tagscache.tagtypes.get(tagname)
2128
2128
2129 def tagslist(self):
2129 def tagslist(self):
2130 '''return a list of tags ordered by revision'''
2130 '''return a list of tags ordered by revision'''
2131 if not self._tagscache.tagslist:
2131 if not self._tagscache.tagslist:
2132 l = []
2132 l = []
2133 for t, n in pycompat.iteritems(self.tags()):
2133 for t, n in pycompat.iteritems(self.tags()):
2134 l.append((self.changelog.rev(n), t, n))
2134 l.append((self.changelog.rev(n), t, n))
2135 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2135 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2136
2136
2137 return self._tagscache.tagslist
2137 return self._tagscache.tagslist
2138
2138
2139 def nodetags(self, node):
2139 def nodetags(self, node):
2140 '''return the tags associated with a node'''
2140 '''return the tags associated with a node'''
2141 if not self._tagscache.nodetagscache:
2141 if not self._tagscache.nodetagscache:
2142 nodetagscache = {}
2142 nodetagscache = {}
2143 for t, n in pycompat.iteritems(self._tagscache.tags):
2143 for t, n in pycompat.iteritems(self._tagscache.tags):
2144 nodetagscache.setdefault(n, []).append(t)
2144 nodetagscache.setdefault(n, []).append(t)
2145 for tags in pycompat.itervalues(nodetagscache):
2145 for tags in pycompat.itervalues(nodetagscache):
2146 tags.sort()
2146 tags.sort()
2147 self._tagscache.nodetagscache = nodetagscache
2147 self._tagscache.nodetagscache = nodetagscache
2148 return self._tagscache.nodetagscache.get(node, [])
2148 return self._tagscache.nodetagscache.get(node, [])
2149
2149
2150 def nodebookmarks(self, node):
2150 def nodebookmarks(self, node):
2151 """return the list of bookmarks pointing to the specified node"""
2151 """return the list of bookmarks pointing to the specified node"""
2152 return self._bookmarks.names(node)
2152 return self._bookmarks.names(node)
2153
2153
2154 def branchmap(self):
2154 def branchmap(self):
2155 """returns a dictionary {branch: [branchheads]} with branchheads
2155 """returns a dictionary {branch: [branchheads]} with branchheads
2156 ordered by increasing revision number"""
2156 ordered by increasing revision number"""
2157 return self._branchcaches[self]
2157 return self._branchcaches[self]
2158
2158
2159 @unfilteredmethod
2159 @unfilteredmethod
2160 def revbranchcache(self):
2160 def revbranchcache(self):
2161 if not self._revbranchcache:
2161 if not self._revbranchcache:
2162 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2162 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2163 return self._revbranchcache
2163 return self._revbranchcache
2164
2164
2165 def register_changeset(self, rev, changelogrevision):
2165 def register_changeset(self, rev, changelogrevision):
2166 self.revbranchcache().setdata(rev, changelogrevision)
2166 self.revbranchcache().setdata(rev, changelogrevision)
2167
2167
2168 def branchtip(self, branch, ignoremissing=False):
2168 def branchtip(self, branch, ignoremissing=False):
2169 """return the tip node for a given branch
2169 """return the tip node for a given branch
2170
2170
2171 If ignoremissing is True, then this method will not raise an error.
2171 If ignoremissing is True, then this method will not raise an error.
2172 This is helpful for callers that only expect None for a missing branch
2172 This is helpful for callers that only expect None for a missing branch
2173 (e.g. namespace).
2173 (e.g. namespace).
2174
2174
2175 """
2175 """
2176 try:
2176 try:
2177 return self.branchmap().branchtip(branch)
2177 return self.branchmap().branchtip(branch)
2178 except KeyError:
2178 except KeyError:
2179 if not ignoremissing:
2179 if not ignoremissing:
2180 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2180 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2181 else:
2181 else:
2182 pass
2182 pass
2183
2183
2184 def lookup(self, key):
2184 def lookup(self, key):
2185 node = scmutil.revsymbol(self, key).node()
2185 node = scmutil.revsymbol(self, key).node()
2186 if node is None:
2186 if node is None:
2187 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2187 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2188 return node
2188 return node
2189
2189
2190 def lookupbranch(self, key):
2190 def lookupbranch(self, key):
2191 if self.branchmap().hasbranch(key):
2191 if self.branchmap().hasbranch(key):
2192 return key
2192 return key
2193
2193
2194 return scmutil.revsymbol(self, key).branch()
2194 return scmutil.revsymbol(self, key).branch()
2195
2195
2196 def known(self, nodes):
2196 def known(self, nodes):
2197 cl = self.changelog
2197 cl = self.changelog
2198 get_rev = cl.index.get_rev
2198 get_rev = cl.index.get_rev
2199 filtered = cl.filteredrevs
2199 filtered = cl.filteredrevs
2200 result = []
2200 result = []
2201 for n in nodes:
2201 for n in nodes:
2202 r = get_rev(n)
2202 r = get_rev(n)
2203 resp = not (r is None or r in filtered)
2203 resp = not (r is None or r in filtered)
2204 result.append(resp)
2204 result.append(resp)
2205 return result
2205 return result
2206
2206
2207 def local(self):
2207 def local(self):
2208 return self
2208 return self
2209
2209
2210 def publishing(self):
2210 def publishing(self):
2211 # it's safe (and desirable) to trust the publish flag unconditionally
2211 # it's safe (and desirable) to trust the publish flag unconditionally
2212 # so that we don't finalize changes shared between users via ssh or nfs
2212 # so that we don't finalize changes shared between users via ssh or nfs
2213 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2213 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2214
2214
2215 def cancopy(self):
2215 def cancopy(self):
2216 # so statichttprepo's override of local() works
2216 # so statichttprepo's override of local() works
2217 if not self.local():
2217 if not self.local():
2218 return False
2218 return False
2219 if not self.publishing():
2219 if not self.publishing():
2220 return True
2220 return True
2221 # if publishing we can't copy if there is filtered content
2221 # if publishing we can't copy if there is filtered content
2222 return not self.filtered(b'visible').changelog.filteredrevs
2222 return not self.filtered(b'visible').changelog.filteredrevs
2223
2223
2224 def shared(self):
2224 def shared(self):
2225 '''the type of shared repository (None if not shared)'''
2225 '''the type of shared repository (None if not shared)'''
2226 if self.sharedpath != self.path:
2226 if self.sharedpath != self.path:
2227 return b'store'
2227 return b'store'
2228 return None
2228 return None
2229
2229
2230 def wjoin(self, f, *insidef):
2230 def wjoin(self, f, *insidef):
2231 return self.vfs.reljoin(self.root, f, *insidef)
2231 return self.vfs.reljoin(self.root, f, *insidef)
2232
2232
2233 def setparents(self, p1, p2=None):
2233 def setparents(self, p1, p2=None):
2234 if p2 is None:
2234 if p2 is None:
2235 p2 = self.nullid
2235 p2 = self.nullid
2236 self[None].setparents(p1, p2)
2236 self[None].setparents(p1, p2)
2237 self._quick_access_changeid_invalidate()
2237 self._quick_access_changeid_invalidate()
2238
2238
2239 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2239 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2240 """changeid must be a changeset revision, if specified.
2240 """changeid must be a changeset revision, if specified.
2241 fileid can be a file revision or node."""
2241 fileid can be a file revision or node."""
2242 return context.filectx(
2242 return context.filectx(
2243 self, path, changeid, fileid, changectx=changectx
2243 self, path, changeid, fileid, changectx=changectx
2244 )
2244 )
2245
2245
2246 def getcwd(self):
2246 def getcwd(self):
2247 return self.dirstate.getcwd()
2247 return self.dirstate.getcwd()
2248
2248
2249 def pathto(self, f, cwd=None):
2249 def pathto(self, f, cwd=None):
2250 return self.dirstate.pathto(f, cwd)
2250 return self.dirstate.pathto(f, cwd)
2251
2251
2252 def _loadfilter(self, filter):
2252 def _loadfilter(self, filter):
2253 if filter not in self._filterpats:
2253 if filter not in self._filterpats:
2254 l = []
2254 l = []
2255 for pat, cmd in self.ui.configitems(filter):
2255 for pat, cmd in self.ui.configitems(filter):
2256 if cmd == b'!':
2256 if cmd == b'!':
2257 continue
2257 continue
2258 mf = matchmod.match(self.root, b'', [pat])
2258 mf = matchmod.match(self.root, b'', [pat])
2259 fn = None
2259 fn = None
2260 params = cmd
2260 params = cmd
2261 for name, filterfn in pycompat.iteritems(self._datafilters):
2261 for name, filterfn in pycompat.iteritems(self._datafilters):
2262 if cmd.startswith(name):
2262 if cmd.startswith(name):
2263 fn = filterfn
2263 fn = filterfn
2264 params = cmd[len(name) :].lstrip()
2264 params = cmd[len(name) :].lstrip()
2265 break
2265 break
2266 if not fn:
2266 if not fn:
2267 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2267 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2268 fn.__name__ = 'commandfilter'
2268 fn.__name__ = 'commandfilter'
2269 # Wrap old filters not supporting keyword arguments
2269 # Wrap old filters not supporting keyword arguments
2270 if not pycompat.getargspec(fn)[2]:
2270 if not pycompat.getargspec(fn)[2]:
2271 oldfn = fn
2271 oldfn = fn
2272 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2272 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2273 fn.__name__ = 'compat-' + oldfn.__name__
2273 fn.__name__ = 'compat-' + oldfn.__name__
2274 l.append((mf, fn, params))
2274 l.append((mf, fn, params))
2275 self._filterpats[filter] = l
2275 self._filterpats[filter] = l
2276 return self._filterpats[filter]
2276 return self._filterpats[filter]
2277
2277
2278 def _filter(self, filterpats, filename, data):
2278 def _filter(self, filterpats, filename, data):
2279 for mf, fn, cmd in filterpats:
2279 for mf, fn, cmd in filterpats:
2280 if mf(filename):
2280 if mf(filename):
2281 self.ui.debug(
2281 self.ui.debug(
2282 b"filtering %s through %s\n"
2282 b"filtering %s through %s\n"
2283 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2283 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2284 )
2284 )
2285 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2285 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2286 break
2286 break
2287
2287
2288 return data
2288 return data
2289
2289
2290 @unfilteredpropertycache
2290 @unfilteredpropertycache
2291 def _encodefilterpats(self):
2291 def _encodefilterpats(self):
2292 return self._loadfilter(b'encode')
2292 return self._loadfilter(b'encode')
2293
2293
2294 @unfilteredpropertycache
2294 @unfilteredpropertycache
2295 def _decodefilterpats(self):
2295 def _decodefilterpats(self):
2296 return self._loadfilter(b'decode')
2296 return self._loadfilter(b'decode')
2297
2297
2298 def adddatafilter(self, name, filter):
2298 def adddatafilter(self, name, filter):
2299 self._datafilters[name] = filter
2299 self._datafilters[name] = filter
2300
2300
2301 def wread(self, filename):
2301 def wread(self, filename):
2302 if self.wvfs.islink(filename):
2302 if self.wvfs.islink(filename):
2303 data = self.wvfs.readlink(filename)
2303 data = self.wvfs.readlink(filename)
2304 else:
2304 else:
2305 data = self.wvfs.read(filename)
2305 data = self.wvfs.read(filename)
2306 return self._filter(self._encodefilterpats, filename, data)
2306 return self._filter(self._encodefilterpats, filename, data)
2307
2307
2308 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2308 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2309 """write ``data`` into ``filename`` in the working directory
2309 """write ``data`` into ``filename`` in the working directory
2310
2310
2311 This returns length of written (maybe decoded) data.
2311 This returns length of written (maybe decoded) data.
2312 """
2312 """
2313 data = self._filter(self._decodefilterpats, filename, data)
2313 data = self._filter(self._decodefilterpats, filename, data)
2314 if b'l' in flags:
2314 if b'l' in flags:
2315 self.wvfs.symlink(data, filename)
2315 self.wvfs.symlink(data, filename)
2316 else:
2316 else:
2317 self.wvfs.write(
2317 self.wvfs.write(
2318 filename, data, backgroundclose=backgroundclose, **kwargs
2318 filename, data, backgroundclose=backgroundclose, **kwargs
2319 )
2319 )
2320 if b'x' in flags:
2320 if b'x' in flags:
2321 self.wvfs.setflags(filename, False, True)
2321 self.wvfs.setflags(filename, False, True)
2322 else:
2322 else:
2323 self.wvfs.setflags(filename, False, False)
2323 self.wvfs.setflags(filename, False, False)
2324 return len(data)
2324 return len(data)
2325
2325
2326 def wwritedata(self, filename, data):
2326 def wwritedata(self, filename, data):
2327 return self._filter(self._decodefilterpats, filename, data)
2327 return self._filter(self._decodefilterpats, filename, data)
2328
2328
2329 def currenttransaction(self):
2329 def currenttransaction(self):
2330 """return the current transaction or None if non exists"""
2330 """return the current transaction or None if non exists"""
2331 if self._transref:
2331 if self._transref:
2332 tr = self._transref()
2332 tr = self._transref()
2333 else:
2333 else:
2334 tr = None
2334 tr = None
2335
2335
2336 if tr and tr.running():
2336 if tr and tr.running():
2337 return tr
2337 return tr
2338 return None
2338 return None
2339
2339
2340 def transaction(self, desc, report=None):
2340 def transaction(self, desc, report=None):
2341 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2341 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2342 b'devel', b'check-locks'
2342 b'devel', b'check-locks'
2343 ):
2343 ):
2344 if self._currentlock(self._lockref) is None:
2344 if self._currentlock(self._lockref) is None:
2345 raise error.ProgrammingError(b'transaction requires locking')
2345 raise error.ProgrammingError(b'transaction requires locking')
2346 tr = self.currenttransaction()
2346 tr = self.currenttransaction()
2347 if tr is not None:
2347 if tr is not None:
2348 return tr.nest(name=desc)
2348 return tr.nest(name=desc)
2349
2349
2350 # abort here if the journal already exists
2350 # abort here if the journal already exists
2351 if self.svfs.exists(b"journal"):
2351 if self.svfs.exists(b"journal"):
2352 raise error.RepoError(
2352 raise error.RepoError(
2353 _(b"abandoned transaction found"),
2353 _(b"abandoned transaction found"),
2354 hint=_(b"run 'hg recover' to clean up transaction"),
2354 hint=_(b"run 'hg recover' to clean up transaction"),
2355 )
2355 )
2356
2356
2357 idbase = b"%.40f#%f" % (random.random(), time.time())
2357 idbase = b"%.40f#%f" % (random.random(), time.time())
2358 ha = hex(hashutil.sha1(idbase).digest())
2358 ha = hex(hashutil.sha1(idbase).digest())
2359 txnid = b'TXN:' + ha
2359 txnid = b'TXN:' + ha
2360 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2360 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2361
2361
2362 self._writejournal(desc)
2362 self._writejournal(desc)
2363 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2363 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2364 if report:
2364 if report:
2365 rp = report
2365 rp = report
2366 else:
2366 else:
2367 rp = self.ui.warn
2367 rp = self.ui.warn
2368 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2368 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2369 # we must avoid cyclic reference between repo and transaction.
2369 # we must avoid cyclic reference between repo and transaction.
2370 reporef = weakref.ref(self)
2370 reporef = weakref.ref(self)
2371 # Code to track tag movement
2371 # Code to track tag movement
2372 #
2372 #
2373 # Since tags are all handled as file content, it is actually quite hard
2373 # Since tags are all handled as file content, it is actually quite hard
2374 # to track these movement from a code perspective. So we fallback to a
2374 # to track these movement from a code perspective. So we fallback to a
2375 # tracking at the repository level. One could envision to track changes
2375 # tracking at the repository level. One could envision to track changes
2376 # to the '.hgtags' file through changegroup apply but that fails to
2376 # to the '.hgtags' file through changegroup apply but that fails to
2377 # cope with case where transaction expose new heads without changegroup
2377 # cope with case where transaction expose new heads without changegroup
2378 # being involved (eg: phase movement).
2378 # being involved (eg: phase movement).
2379 #
2379 #
2380 # For now, We gate the feature behind a flag since this likely comes
2380 # For now, We gate the feature behind a flag since this likely comes
2381 # with performance impacts. The current code run more often than needed
2381 # with performance impacts. The current code run more often than needed
2382 # and do not use caches as much as it could. The current focus is on
2382 # and do not use caches as much as it could. The current focus is on
2383 # the behavior of the feature so we disable it by default. The flag
2383 # the behavior of the feature so we disable it by default. The flag
2384 # will be removed when we are happy with the performance impact.
2384 # will be removed when we are happy with the performance impact.
2385 #
2385 #
2386 # Once this feature is no longer experimental move the following
2386 # Once this feature is no longer experimental move the following
2387 # documentation to the appropriate help section:
2387 # documentation to the appropriate help section:
2388 #
2388 #
2389 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2389 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2390 # tags (new or changed or deleted tags). In addition the details of
2390 # tags (new or changed or deleted tags). In addition the details of
2391 # these changes are made available in a file at:
2391 # these changes are made available in a file at:
2392 # ``REPOROOT/.hg/changes/tags.changes``.
2392 # ``REPOROOT/.hg/changes/tags.changes``.
2393 # Make sure you check for HG_TAG_MOVED before reading that file as it
2393 # Make sure you check for HG_TAG_MOVED before reading that file as it
2394 # might exist from a previous transaction even if no tag were touched
2394 # might exist from a previous transaction even if no tag were touched
2395 # in this one. Changes are recorded in a line base format::
2395 # in this one. Changes are recorded in a line base format::
2396 #
2396 #
2397 # <action> <hex-node> <tag-name>\n
2397 # <action> <hex-node> <tag-name>\n
2398 #
2398 #
2399 # Actions are defined as follow:
2399 # Actions are defined as follow:
2400 # "-R": tag is removed,
2400 # "-R": tag is removed,
2401 # "+A": tag is added,
2401 # "+A": tag is added,
2402 # "-M": tag is moved (old value),
2402 # "-M": tag is moved (old value),
2403 # "+M": tag is moved (new value),
2403 # "+M": tag is moved (new value),
2404 tracktags = lambda x: None
2404 tracktags = lambda x: None
2405 # experimental config: experimental.hook-track-tags
2405 # experimental config: experimental.hook-track-tags
2406 shouldtracktags = self.ui.configbool(
2406 shouldtracktags = self.ui.configbool(
2407 b'experimental', b'hook-track-tags'
2407 b'experimental', b'hook-track-tags'
2408 )
2408 )
2409 if desc != b'strip' and shouldtracktags:
2409 if desc != b'strip' and shouldtracktags:
2410 oldheads = self.changelog.headrevs()
2410 oldheads = self.changelog.headrevs()
2411
2411
2412 def tracktags(tr2):
2412 def tracktags(tr2):
2413 repo = reporef()
2413 repo = reporef()
2414 assert repo is not None # help pytype
2414 assert repo is not None # help pytype
2415 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2415 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2416 newheads = repo.changelog.headrevs()
2416 newheads = repo.changelog.headrevs()
2417 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2417 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2418 # notes: we compare lists here.
2418 # notes: we compare lists here.
2419 # As we do it only once buiding set would not be cheaper
2419 # As we do it only once buiding set would not be cheaper
2420 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2420 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2421 if changes:
2421 if changes:
2422 tr2.hookargs[b'tag_moved'] = b'1'
2422 tr2.hookargs[b'tag_moved'] = b'1'
2423 with repo.vfs(
2423 with repo.vfs(
2424 b'changes/tags.changes', b'w', atomictemp=True
2424 b'changes/tags.changes', b'w', atomictemp=True
2425 ) as changesfile:
2425 ) as changesfile:
2426 # note: we do not register the file to the transaction
2426 # note: we do not register the file to the transaction
2427 # because we needs it to still exist on the transaction
2427 # because we needs it to still exist on the transaction
2428 # is close (for txnclose hooks)
2428 # is close (for txnclose hooks)
2429 tagsmod.writediff(changesfile, changes)
2429 tagsmod.writediff(changesfile, changes)
2430
2430
2431 def validate(tr2):
2431 def validate(tr2):
2432 """will run pre-closing hooks"""
2432 """will run pre-closing hooks"""
2433 # XXX the transaction API is a bit lacking here so we take a hacky
2433 # XXX the transaction API is a bit lacking here so we take a hacky
2434 # path for now
2434 # path for now
2435 #
2435 #
2436 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2436 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2437 # dict is copied before these run. In addition we needs the data
2437 # dict is copied before these run. In addition we needs the data
2438 # available to in memory hooks too.
2438 # available to in memory hooks too.
2439 #
2439 #
2440 # Moreover, we also need to make sure this runs before txnclose
2440 # Moreover, we also need to make sure this runs before txnclose
2441 # hooks and there is no "pending" mechanism that would execute
2441 # hooks and there is no "pending" mechanism that would execute
2442 # logic only if hooks are about to run.
2442 # logic only if hooks are about to run.
2443 #
2443 #
2444 # Fixing this limitation of the transaction is also needed to track
2444 # Fixing this limitation of the transaction is also needed to track
2445 # other families of changes (bookmarks, phases, obsolescence).
2445 # other families of changes (bookmarks, phases, obsolescence).
2446 #
2446 #
2447 # This will have to be fixed before we remove the experimental
2447 # This will have to be fixed before we remove the experimental
2448 # gating.
2448 # gating.
2449 tracktags(tr2)
2449 tracktags(tr2)
2450 repo = reporef()
2450 repo = reporef()
2451 assert repo is not None # help pytype
2451 assert repo is not None # help pytype
2452
2452
2453 singleheadopt = (b'experimental', b'single-head-per-branch')
2453 singleheadopt = (b'experimental', b'single-head-per-branch')
2454 singlehead = repo.ui.configbool(*singleheadopt)
2454 singlehead = repo.ui.configbool(*singleheadopt)
2455 if singlehead:
2455 if singlehead:
2456 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2456 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2457 accountclosed = singleheadsub.get(
2457 accountclosed = singleheadsub.get(
2458 b"account-closed-heads", False
2458 b"account-closed-heads", False
2459 )
2459 )
2460 if singleheadsub.get(b"public-changes-only", False):
2460 if singleheadsub.get(b"public-changes-only", False):
2461 filtername = b"immutable"
2461 filtername = b"immutable"
2462 else:
2462 else:
2463 filtername = b"visible"
2463 filtername = b"visible"
2464 scmutil.enforcesinglehead(
2464 scmutil.enforcesinglehead(
2465 repo, tr2, desc, accountclosed, filtername
2465 repo, tr2, desc, accountclosed, filtername
2466 )
2466 )
2467 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2467 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2468 for name, (old, new) in sorted(
2468 for name, (old, new) in sorted(
2469 tr.changes[b'bookmarks'].items()
2469 tr.changes[b'bookmarks'].items()
2470 ):
2470 ):
2471 args = tr.hookargs.copy()
2471 args = tr.hookargs.copy()
2472 args.update(bookmarks.preparehookargs(name, old, new))
2472 args.update(bookmarks.preparehookargs(name, old, new))
2473 repo.hook(
2473 repo.hook(
2474 b'pretxnclose-bookmark',
2474 b'pretxnclose-bookmark',
2475 throw=True,
2475 throw=True,
2476 **pycompat.strkwargs(args)
2476 **pycompat.strkwargs(args)
2477 )
2477 )
2478 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2478 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2479 cl = repo.unfiltered().changelog
2479 cl = repo.unfiltered().changelog
2480 for revs, (old, new) in tr.changes[b'phases']:
2480 for revs, (old, new) in tr.changes[b'phases']:
2481 for rev in revs:
2481 for rev in revs:
2482 args = tr.hookargs.copy()
2482 args = tr.hookargs.copy()
2483 node = hex(cl.node(rev))
2483 node = hex(cl.node(rev))
2484 args.update(phases.preparehookargs(node, old, new))
2484 args.update(phases.preparehookargs(node, old, new))
2485 repo.hook(
2485 repo.hook(
2486 b'pretxnclose-phase',
2486 b'pretxnclose-phase',
2487 throw=True,
2487 throw=True,
2488 **pycompat.strkwargs(args)
2488 **pycompat.strkwargs(args)
2489 )
2489 )
2490
2490
2491 repo.hook(
2491 repo.hook(
2492 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2492 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2493 )
2493 )
2494
2494
2495 def releasefn(tr, success):
2495 def releasefn(tr, success):
2496 repo = reporef()
2496 repo = reporef()
2497 if repo is None:
2497 if repo is None:
2498 # If the repo has been GC'd (and this release function is being
2498 # If the repo has been GC'd (and this release function is being
2499 # called from transaction.__del__), there's not much we can do,
2499 # called from transaction.__del__), there's not much we can do,
2500 # so just leave the unfinished transaction there and let the
2500 # so just leave the unfinished transaction there and let the
2501 # user run `hg recover`.
2501 # user run `hg recover`.
2502 return
2502 return
2503 if success:
2503 if success:
2504 # this should be explicitly invoked here, because
2504 # this should be explicitly invoked here, because
2505 # in-memory changes aren't written out at closing
2505 # in-memory changes aren't written out at closing
2506 # transaction, if tr.addfilegenerator (via
2506 # transaction, if tr.addfilegenerator (via
2507 # dirstate.write or so) isn't invoked while
2507 # dirstate.write or so) isn't invoked while
2508 # transaction running
2508 # transaction running
2509 repo.dirstate.write(None)
2509 repo.dirstate.write(None)
2510 else:
2510 else:
2511 # discard all changes (including ones already written
2511 # discard all changes (including ones already written
2512 # out) in this transaction
2512 # out) in this transaction
2513 narrowspec.restorebackup(self, b'journal.narrowspec')
2513 narrowspec.restorebackup(self, b'journal.narrowspec')
2514 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2514 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2515 repo.dirstate.restorebackup(None, b'journal.dirstate')
2515 repo.dirstate.restorebackup(None, b'journal.dirstate')
2516
2516
2517 repo.invalidate(clearfilecache=True)
2517 repo.invalidate(clearfilecache=True)
2518
2518
2519 tr = transaction.transaction(
2519 tr = transaction.transaction(
2520 rp,
2520 rp,
2521 self.svfs,
2521 self.svfs,
2522 vfsmap,
2522 vfsmap,
2523 b"journal",
2523 b"journal",
2524 b"undo",
2524 b"undo",
2525 aftertrans(renames),
2525 aftertrans(renames),
2526 self.store.createmode,
2526 self.store.createmode,
2527 validator=validate,
2527 validator=validate,
2528 releasefn=releasefn,
2528 releasefn=releasefn,
2529 checkambigfiles=_cachedfiles,
2529 checkambigfiles=_cachedfiles,
2530 name=desc,
2530 name=desc,
2531 )
2531 )
2532 tr.changes[b'origrepolen'] = len(self)
2532 tr.changes[b'origrepolen'] = len(self)
2533 tr.changes[b'obsmarkers'] = set()
2533 tr.changes[b'obsmarkers'] = set()
2534 tr.changes[b'phases'] = []
2534 tr.changes[b'phases'] = []
2535 tr.changes[b'bookmarks'] = {}
2535 tr.changes[b'bookmarks'] = {}
2536
2536
2537 tr.hookargs[b'txnid'] = txnid
2537 tr.hookargs[b'txnid'] = txnid
2538 tr.hookargs[b'txnname'] = desc
2538 tr.hookargs[b'txnname'] = desc
2539 tr.hookargs[b'changes'] = tr.changes
2539 tr.hookargs[b'changes'] = tr.changes
2540 # note: writing the fncache only during finalize mean that the file is
2540 # note: writing the fncache only during finalize mean that the file is
2541 # outdated when running hooks. As fncache is used for streaming clone,
2541 # outdated when running hooks. As fncache is used for streaming clone,
2542 # this is not expected to break anything that happen during the hooks.
2542 # this is not expected to break anything that happen during the hooks.
2543 tr.addfinalize(b'flush-fncache', self.store.write)
2543 tr.addfinalize(b'flush-fncache', self.store.write)
2544
2544
2545 def txnclosehook(tr2):
2545 def txnclosehook(tr2):
2546 """To be run if transaction is successful, will schedule a hook run"""
2546 """To be run if transaction is successful, will schedule a hook run"""
2547 # Don't reference tr2 in hook() so we don't hold a reference.
2547 # Don't reference tr2 in hook() so we don't hold a reference.
2548 # This reduces memory consumption when there are multiple
2548 # This reduces memory consumption when there are multiple
2549 # transactions per lock. This can likely go away if issue5045
2549 # transactions per lock. This can likely go away if issue5045
2550 # fixes the function accumulation.
2550 # fixes the function accumulation.
2551 hookargs = tr2.hookargs
2551 hookargs = tr2.hookargs
2552
2552
2553 def hookfunc(unused_success):
2553 def hookfunc(unused_success):
2554 repo = reporef()
2554 repo = reporef()
2555 assert repo is not None # help pytype
2555 assert repo is not None # help pytype
2556
2556
2557 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2557 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2558 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2558 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2559 for name, (old, new) in bmchanges:
2559 for name, (old, new) in bmchanges:
2560 args = tr.hookargs.copy()
2560 args = tr.hookargs.copy()
2561 args.update(bookmarks.preparehookargs(name, old, new))
2561 args.update(bookmarks.preparehookargs(name, old, new))
2562 repo.hook(
2562 repo.hook(
2563 b'txnclose-bookmark',
2563 b'txnclose-bookmark',
2564 throw=False,
2564 throw=False,
2565 **pycompat.strkwargs(args)
2565 **pycompat.strkwargs(args)
2566 )
2566 )
2567
2567
2568 if hook.hashook(repo.ui, b'txnclose-phase'):
2568 if hook.hashook(repo.ui, b'txnclose-phase'):
2569 cl = repo.unfiltered().changelog
2569 cl = repo.unfiltered().changelog
2570 phasemv = sorted(
2570 phasemv = sorted(
2571 tr.changes[b'phases'], key=lambda r: r[0][0]
2571 tr.changes[b'phases'], key=lambda r: r[0][0]
2572 )
2572 )
2573 for revs, (old, new) in phasemv:
2573 for revs, (old, new) in phasemv:
2574 for rev in revs:
2574 for rev in revs:
2575 args = tr.hookargs.copy()
2575 args = tr.hookargs.copy()
2576 node = hex(cl.node(rev))
2576 node = hex(cl.node(rev))
2577 args.update(phases.preparehookargs(node, old, new))
2577 args.update(phases.preparehookargs(node, old, new))
2578 repo.hook(
2578 repo.hook(
2579 b'txnclose-phase',
2579 b'txnclose-phase',
2580 throw=False,
2580 throw=False,
2581 **pycompat.strkwargs(args)
2581 **pycompat.strkwargs(args)
2582 )
2582 )
2583
2583
2584 repo.hook(
2584 repo.hook(
2585 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2585 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2586 )
2586 )
2587
2587
2588 repo = reporef()
2588 repo = reporef()
2589 assert repo is not None # help pytype
2589 assert repo is not None # help pytype
2590 repo._afterlock(hookfunc)
2590 repo._afterlock(hookfunc)
2591
2591
2592 tr.addfinalize(b'txnclose-hook', txnclosehook)
2592 tr.addfinalize(b'txnclose-hook', txnclosehook)
2593 # Include a leading "-" to make it happen before the transaction summary
2593 # Include a leading "-" to make it happen before the transaction summary
2594 # reports registered via scmutil.registersummarycallback() whose names
2594 # reports registered via scmutil.registersummarycallback() whose names
2595 # are 00-txnreport etc. That way, the caches will be warm when the
2595 # are 00-txnreport etc. That way, the caches will be warm when the
2596 # callbacks run.
2596 # callbacks run.
2597 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2597 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2598
2598
2599 def txnaborthook(tr2):
2599 def txnaborthook(tr2):
2600 """To be run if transaction is aborted"""
2600 """To be run if transaction is aborted"""
2601 repo = reporef()
2601 repo = reporef()
2602 assert repo is not None # help pytype
2602 assert repo is not None # help pytype
2603 repo.hook(
2603 repo.hook(
2604 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2604 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2605 )
2605 )
2606
2606
2607 tr.addabort(b'txnabort-hook', txnaborthook)
2607 tr.addabort(b'txnabort-hook', txnaborthook)
2608 # avoid eager cache invalidation. in-memory data should be identical
2608 # avoid eager cache invalidation. in-memory data should be identical
2609 # to stored data if transaction has no error.
2609 # to stored data if transaction has no error.
2610 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2610 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2611 self._transref = weakref.ref(tr)
2611 self._transref = weakref.ref(tr)
2612 scmutil.registersummarycallback(self, tr, desc)
2612 scmutil.registersummarycallback(self, tr, desc)
2613 return tr
2613 return tr
2614
2614
2615 def _journalfiles(self):
2615 def _journalfiles(self):
2616 return (
2616 return (
2617 (self.svfs, b'journal'),
2617 (self.svfs, b'journal'),
2618 (self.svfs, b'journal.narrowspec'),
2618 (self.svfs, b'journal.narrowspec'),
2619 (self.vfs, b'journal.narrowspec.dirstate'),
2619 (self.vfs, b'journal.narrowspec.dirstate'),
2620 (self.vfs, b'journal.dirstate'),
2620 (self.vfs, b'journal.dirstate'),
2621 (self.vfs, b'journal.branch'),
2621 (self.vfs, b'journal.branch'),
2622 (self.vfs, b'journal.desc'),
2622 (self.vfs, b'journal.desc'),
2623 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2623 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2624 (self.svfs, b'journal.phaseroots'),
2624 (self.svfs, b'journal.phaseroots'),
2625 )
2625 )
2626
2626
2627 def undofiles(self):
2627 def undofiles(self):
2628 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2628 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2629
2629
2630 @unfilteredmethod
2630 @unfilteredmethod
2631 def _writejournal(self, desc):
2631 def _writejournal(self, desc):
2632 self.dirstate.savebackup(None, b'journal.dirstate')
2632 self.dirstate.savebackup(None, b'journal.dirstate')
2633 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2633 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2634 narrowspec.savebackup(self, b'journal.narrowspec')
2634 narrowspec.savebackup(self, b'journal.narrowspec')
2635 self.vfs.write(
2635 self.vfs.write(
2636 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2636 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2637 )
2637 )
2638 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2638 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2639 bookmarksvfs = bookmarks.bookmarksvfs(self)
2639 bookmarksvfs = bookmarks.bookmarksvfs(self)
2640 bookmarksvfs.write(
2640 bookmarksvfs.write(
2641 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2641 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2642 )
2642 )
2643 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2643 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2644
2644
2645 def recover(self):
2645 def recover(self):
2646 with self.lock():
2646 with self.lock():
2647 if self.svfs.exists(b"journal"):
2647 if self.svfs.exists(b"journal"):
2648 self.ui.status(_(b"rolling back interrupted transaction\n"))
2648 self.ui.status(_(b"rolling back interrupted transaction\n"))
2649 vfsmap = {
2649 vfsmap = {
2650 b'': self.svfs,
2650 b'': self.svfs,
2651 b'plain': self.vfs,
2651 b'plain': self.vfs,
2652 }
2652 }
2653 transaction.rollback(
2653 transaction.rollback(
2654 self.svfs,
2654 self.svfs,
2655 vfsmap,
2655 vfsmap,
2656 b"journal",
2656 b"journal",
2657 self.ui.warn,
2657 self.ui.warn,
2658 checkambigfiles=_cachedfiles,
2658 checkambigfiles=_cachedfiles,
2659 )
2659 )
2660 self.invalidate()
2660 self.invalidate()
2661 return True
2661 return True
2662 else:
2662 else:
2663 self.ui.warn(_(b"no interrupted transaction available\n"))
2663 self.ui.warn(_(b"no interrupted transaction available\n"))
2664 return False
2664 return False
2665
2665
2666 def rollback(self, dryrun=False, force=False):
2666 def rollback(self, dryrun=False, force=False):
2667 wlock = lock = dsguard = None
2667 wlock = lock = dsguard = None
2668 try:
2668 try:
2669 wlock = self.wlock()
2669 wlock = self.wlock()
2670 lock = self.lock()
2670 lock = self.lock()
2671 if self.svfs.exists(b"undo"):
2671 if self.svfs.exists(b"undo"):
2672 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2672 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2673
2673
2674 return self._rollback(dryrun, force, dsguard)
2674 return self._rollback(dryrun, force, dsguard)
2675 else:
2675 else:
2676 self.ui.warn(_(b"no rollback information available\n"))
2676 self.ui.warn(_(b"no rollback information available\n"))
2677 return 1
2677 return 1
2678 finally:
2678 finally:
2679 release(dsguard, lock, wlock)
2679 release(dsguard, lock, wlock)
2680
2680
2681 @unfilteredmethod # Until we get smarter cache management
2681 @unfilteredmethod # Until we get smarter cache management
2682 def _rollback(self, dryrun, force, dsguard):
2682 def _rollback(self, dryrun, force, dsguard):
2683 ui = self.ui
2683 ui = self.ui
2684 try:
2684 try:
2685 args = self.vfs.read(b'undo.desc').splitlines()
2685 args = self.vfs.read(b'undo.desc').splitlines()
2686 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2686 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2687 if len(args) >= 3:
2687 if len(args) >= 3:
2688 detail = args[2]
2688 detail = args[2]
2689 oldtip = oldlen - 1
2689 oldtip = oldlen - 1
2690
2690
2691 if detail and ui.verbose:
2691 if detail and ui.verbose:
2692 msg = _(
2692 msg = _(
2693 b'repository tip rolled back to revision %d'
2693 b'repository tip rolled back to revision %d'
2694 b' (undo %s: %s)\n'
2694 b' (undo %s: %s)\n'
2695 ) % (oldtip, desc, detail)
2695 ) % (oldtip, desc, detail)
2696 else:
2696 else:
2697 msg = _(
2697 msg = _(
2698 b'repository tip rolled back to revision %d (undo %s)\n'
2698 b'repository tip rolled back to revision %d (undo %s)\n'
2699 ) % (oldtip, desc)
2699 ) % (oldtip, desc)
2700 except IOError:
2700 except IOError:
2701 msg = _(b'rolling back unknown transaction\n')
2701 msg = _(b'rolling back unknown transaction\n')
2702 desc = None
2702 desc = None
2703
2703
2704 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2704 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2705 raise error.Abort(
2705 raise error.Abort(
2706 _(
2706 _(
2707 b'rollback of last commit while not checked out '
2707 b'rollback of last commit while not checked out '
2708 b'may lose data'
2708 b'may lose data'
2709 ),
2709 ),
2710 hint=_(b'use -f to force'),
2710 hint=_(b'use -f to force'),
2711 )
2711 )
2712
2712
2713 ui.status(msg)
2713 ui.status(msg)
2714 if dryrun:
2714 if dryrun:
2715 return 0
2715 return 0
2716
2716
2717 parents = self.dirstate.parents()
2717 parents = self.dirstate.parents()
2718 self.destroying()
2718 self.destroying()
2719 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2719 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2720 transaction.rollback(
2720 transaction.rollback(
2721 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2721 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2722 )
2722 )
2723 bookmarksvfs = bookmarks.bookmarksvfs(self)
2723 bookmarksvfs = bookmarks.bookmarksvfs(self)
2724 if bookmarksvfs.exists(b'undo.bookmarks'):
2724 if bookmarksvfs.exists(b'undo.bookmarks'):
2725 bookmarksvfs.rename(
2725 bookmarksvfs.rename(
2726 b'undo.bookmarks', b'bookmarks', checkambig=True
2726 b'undo.bookmarks', b'bookmarks', checkambig=True
2727 )
2727 )
2728 if self.svfs.exists(b'undo.phaseroots'):
2728 if self.svfs.exists(b'undo.phaseroots'):
2729 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2729 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2730 self.invalidate()
2730 self.invalidate()
2731
2731
2732 has_node = self.changelog.index.has_node
2732 has_node = self.changelog.index.has_node
2733 parentgone = any(not has_node(p) for p in parents)
2733 parentgone = any(not has_node(p) for p in parents)
2734 if parentgone:
2734 if parentgone:
2735 # prevent dirstateguard from overwriting already restored one
2735 # prevent dirstateguard from overwriting already restored one
2736 dsguard.close()
2736 dsguard.close()
2737
2737
2738 narrowspec.restorebackup(self, b'undo.narrowspec')
2738 narrowspec.restorebackup(self, b'undo.narrowspec')
2739 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2739 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2740 self.dirstate.restorebackup(None, b'undo.dirstate')
2740 self.dirstate.restorebackup(None, b'undo.dirstate')
2741 try:
2741 try:
2742 branch = self.vfs.read(b'undo.branch')
2742 branch = self.vfs.read(b'undo.branch')
2743 self.dirstate.setbranch(encoding.tolocal(branch))
2743 self.dirstate.setbranch(encoding.tolocal(branch))
2744 except IOError:
2744 except IOError:
2745 ui.warn(
2745 ui.warn(
2746 _(
2746 _(
2747 b'named branch could not be reset: '
2747 b'named branch could not be reset: '
2748 b'current branch is still \'%s\'\n'
2748 b'current branch is still \'%s\'\n'
2749 )
2749 )
2750 % self.dirstate.branch()
2750 % self.dirstate.branch()
2751 )
2751 )
2752
2752
2753 parents = tuple([p.rev() for p in self[None].parents()])
2753 parents = tuple([p.rev() for p in self[None].parents()])
2754 if len(parents) > 1:
2754 if len(parents) > 1:
2755 ui.status(
2755 ui.status(
2756 _(
2756 _(
2757 b'working directory now based on '
2757 b'working directory now based on '
2758 b'revisions %d and %d\n'
2758 b'revisions %d and %d\n'
2759 )
2759 )
2760 % parents
2760 % parents
2761 )
2761 )
2762 else:
2762 else:
2763 ui.status(
2763 ui.status(
2764 _(b'working directory now based on revision %d\n') % parents
2764 _(b'working directory now based on revision %d\n') % parents
2765 )
2765 )
2766 mergestatemod.mergestate.clean(self)
2766 mergestatemod.mergestate.clean(self)
2767
2767
2768 # TODO: if we know which new heads may result from this rollback, pass
2768 # TODO: if we know which new heads may result from this rollback, pass
2769 # them to destroy(), which will prevent the branchhead cache from being
2769 # them to destroy(), which will prevent the branchhead cache from being
2770 # invalidated.
2770 # invalidated.
2771 self.destroyed()
2771 self.destroyed()
2772 return 0
2772 return 0
2773
2773
2774 def _buildcacheupdater(self, newtransaction):
2774 def _buildcacheupdater(self, newtransaction):
2775 """called during transaction to build the callback updating cache
2775 """called during transaction to build the callback updating cache
2776
2776
2777 Lives on the repository to help extension who might want to augment
2777 Lives on the repository to help extension who might want to augment
2778 this logic. For this purpose, the created transaction is passed to the
2778 this logic. For this purpose, the created transaction is passed to the
2779 method.
2779 method.
2780 """
2780 """
2781 # we must avoid cyclic reference between repo and transaction.
2781 # we must avoid cyclic reference between repo and transaction.
2782 reporef = weakref.ref(self)
2782 reporef = weakref.ref(self)
2783
2783
2784 def updater(tr):
2784 def updater(tr):
2785 repo = reporef()
2785 repo = reporef()
2786 assert repo is not None # help pytype
2786 assert repo is not None # help pytype
2787 repo.updatecaches(tr)
2787 repo.updatecaches(tr)
2788
2788
2789 return updater
2789 return updater
2790
2790
2791 @unfilteredmethod
2791 @unfilteredmethod
2792 def updatecaches(self, tr=None, full=False, caches=None):
2792 def updatecaches(self, tr=None, full=False, caches=None):
2793 """warm appropriate caches
2793 """warm appropriate caches
2794
2794
2795 If this function is called after a transaction closed. The transaction
2795 If this function is called after a transaction closed. The transaction
2796 will be available in the 'tr' argument. This can be used to selectively
2796 will be available in the 'tr' argument. This can be used to selectively
2797 update caches relevant to the changes in that transaction.
2797 update caches relevant to the changes in that transaction.
2798
2798
2799 If 'full' is set, make sure all caches the function knows about have
2799 If 'full' is set, make sure all caches the function knows about have
2800 up-to-date data. Even the ones usually loaded more lazily.
2800 up-to-date data. Even the ones usually loaded more lazily.
2801
2801
2802 The `full` argument can take a special "post-clone" value. In this case
2802 The `full` argument can take a special "post-clone" value. In this case
2803 the cache warming is made after a clone and of the slower cache might
2803 the cache warming is made after a clone and of the slower cache might
2804 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2804 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2805 as we plan for a cleaner way to deal with this for 5.9.
2805 as we plan for a cleaner way to deal with this for 5.9.
2806 """
2806 """
2807 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2807 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2808 # During strip, many caches are invalid but
2808 # During strip, many caches are invalid but
2809 # later call to `destroyed` will refresh them.
2809 # later call to `destroyed` will refresh them.
2810 return
2810 return
2811
2811
2812 unfi = self.unfiltered()
2812 unfi = self.unfiltered()
2813
2813
2814 if full:
2814 if full:
2815 msg = (
2815 msg = (
2816 "`full` argument for `repo.updatecaches` is deprecated\n"
2816 "`full` argument for `repo.updatecaches` is deprecated\n"
2817 "(use `caches=repository.CACHE_ALL` instead)"
2817 "(use `caches=repository.CACHE_ALL` instead)"
2818 )
2818 )
2819 self.ui.deprecwarn(msg, b"5.9")
2819 self.ui.deprecwarn(msg, b"5.9")
2820 caches = repository.CACHES_ALL
2820 caches = repository.CACHES_ALL
2821 if full == b"post-clone":
2821 if full == b"post-clone":
2822 caches = repository.CACHES_POST_CLONE
2822 caches = repository.CACHES_POST_CLONE
2823 caches = repository.CACHES_ALL
2823 caches = repository.CACHES_ALL
2824 elif caches is None:
2824 elif caches is None:
2825 caches = repository.CACHES_DEFAULT
2825 caches = repository.CACHES_DEFAULT
2826
2826
2827 if repository.CACHE_BRANCHMAP_SERVED in caches:
2827 if repository.CACHE_BRANCHMAP_SERVED in caches:
2828 if tr is None or tr.changes[b'origrepolen'] < len(self):
2828 if tr is None or tr.changes[b'origrepolen'] < len(self):
2829 # accessing the 'served' branchmap should refresh all the others,
2829 # accessing the 'served' branchmap should refresh all the others,
2830 self.ui.debug(b'updating the branch cache\n')
2830 self.ui.debug(b'updating the branch cache\n')
2831 self.filtered(b'served').branchmap()
2831 self.filtered(b'served').branchmap()
2832 self.filtered(b'served.hidden').branchmap()
2832 self.filtered(b'served.hidden').branchmap()
2833
2833
2834 if repository.CACHE_CHANGELOG_CACHE in caches:
2834 if repository.CACHE_CHANGELOG_CACHE in caches:
2835 self.changelog.update_caches(transaction=tr)
2835 self.changelog.update_caches(transaction=tr)
2836
2836
2837 if repository.CACHE_MANIFESTLOG_CACHE in caches:
2837 if repository.CACHE_MANIFESTLOG_CACHE in caches:
2838 self.manifestlog.update_caches(transaction=tr)
2838 self.manifestlog.update_caches(transaction=tr)
2839
2839
2840 if repository.CACHE_REV_BRANCH in caches:
2840 if repository.CACHE_REV_BRANCH in caches:
2841 rbc = unfi.revbranchcache()
2841 rbc = unfi.revbranchcache()
2842 for r in unfi.changelog:
2842 for r in unfi.changelog:
2843 rbc.branchinfo(r)
2843 rbc.branchinfo(r)
2844 rbc.write()
2844 rbc.write()
2845
2845
2846 if repository.CACHE_FULL_MANIFEST in caches:
2846 if repository.CACHE_FULL_MANIFEST in caches:
2847 # ensure the working copy parents are in the manifestfulltextcache
2847 # ensure the working copy parents are in the manifestfulltextcache
2848 for ctx in self[b'.'].parents():
2848 for ctx in self[b'.'].parents():
2849 ctx.manifest() # accessing the manifest is enough
2849 ctx.manifest() # accessing the manifest is enough
2850
2850
2851 if repository.CACHE_FILE_NODE_TAGS in caches:
2851 if repository.CACHE_FILE_NODE_TAGS in caches:
2852 # accessing fnode cache warms the cache
2852 # accessing fnode cache warms the cache
2853 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2853 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2854
2854
2855 if repository.CACHE_TAGS_DEFAULT in caches:
2855 if repository.CACHE_TAGS_DEFAULT in caches:
2856 # accessing tags warm the cache
2856 # accessing tags warm the cache
2857 self.tags()
2857 self.tags()
2858 if repository.CACHE_TAGS_SERVED in caches:
2858 if repository.CACHE_TAGS_SERVED in caches:
2859 self.filtered(b'served').tags()
2859 self.filtered(b'served').tags()
2860
2860
2861 if repository.CACHE_BRANCHMAP_ALL in caches:
2861 if repository.CACHE_BRANCHMAP_ALL in caches:
2862 # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
2862 # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
2863 # so we're forcing a write to cause these caches to be warmed up
2863 # so we're forcing a write to cause these caches to be warmed up
2864 # even if they haven't explicitly been requested yet (if they've
2864 # even if they haven't explicitly been requested yet (if they've
2865 # never been used by hg, they won't ever have been written, even if
2865 # never been used by hg, they won't ever have been written, even if
2866 # they're a subset of another kind of cache that *has* been used).
2866 # they're a subset of another kind of cache that *has* been used).
2867 for filt in repoview.filtertable.keys():
2867 for filt in repoview.filtertable.keys():
2868 filtered = self.filtered(filt)
2868 filtered = self.filtered(filt)
2869 filtered.branchmap().write(filtered)
2869 filtered.branchmap().write(filtered)
2870
2870
2871 def invalidatecaches(self):
2871 def invalidatecaches(self):
2872
2872
2873 if '_tagscache' in vars(self):
2873 if '_tagscache' in vars(self):
2874 # can't use delattr on proxy
2874 # can't use delattr on proxy
2875 del self.__dict__['_tagscache']
2875 del self.__dict__['_tagscache']
2876
2876
2877 self._branchcaches.clear()
2877 self._branchcaches.clear()
2878 self.invalidatevolatilesets()
2878 self.invalidatevolatilesets()
2879 self._sparsesignaturecache.clear()
2879 self._sparsesignaturecache.clear()
2880
2880
2881 def invalidatevolatilesets(self):
2881 def invalidatevolatilesets(self):
2882 self.filteredrevcache.clear()
2882 self.filteredrevcache.clear()
2883 obsolete.clearobscaches(self)
2883 obsolete.clearobscaches(self)
2884 self._quick_access_changeid_invalidate()
2884 self._quick_access_changeid_invalidate()
2885
2885
2886 def invalidatedirstate(self):
2886 def invalidatedirstate(self):
2887 """Invalidates the dirstate, causing the next call to dirstate
2887 """Invalidates the dirstate, causing the next call to dirstate
2888 to check if it was modified since the last time it was read,
2888 to check if it was modified since the last time it was read,
2889 rereading it if it has.
2889 rereading it if it has.
2890
2890
2891 This is different to dirstate.invalidate() that it doesn't always
2891 This is different to dirstate.invalidate() that it doesn't always
2892 rereads the dirstate. Use dirstate.invalidate() if you want to
2892 rereads the dirstate. Use dirstate.invalidate() if you want to
2893 explicitly read the dirstate again (i.e. restoring it to a previous
2893 explicitly read the dirstate again (i.e. restoring it to a previous
2894 known good state)."""
2894 known good state)."""
2895 if hasunfilteredcache(self, 'dirstate'):
2895 if hasunfilteredcache(self, 'dirstate'):
2896 for k in self.dirstate._filecache:
2896 for k in self.dirstate._filecache:
2897 try:
2897 try:
2898 delattr(self.dirstate, k)
2898 delattr(self.dirstate, k)
2899 except AttributeError:
2899 except AttributeError:
2900 pass
2900 pass
2901 delattr(self.unfiltered(), 'dirstate')
2901 delattr(self.unfiltered(), 'dirstate')
2902
2902
2903 def invalidate(self, clearfilecache=False):
2903 def invalidate(self, clearfilecache=False):
2904 """Invalidates both store and non-store parts other than dirstate
2904 """Invalidates both store and non-store parts other than dirstate
2905
2905
2906 If a transaction is running, invalidation of store is omitted,
2906 If a transaction is running, invalidation of store is omitted,
2907 because discarding in-memory changes might cause inconsistency
2907 because discarding in-memory changes might cause inconsistency
2908 (e.g. incomplete fncache causes unintentional failure, but
2908 (e.g. incomplete fncache causes unintentional failure, but
2909 redundant one doesn't).
2909 redundant one doesn't).
2910 """
2910 """
2911 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2911 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2912 for k in list(self._filecache.keys()):
2912 for k in list(self._filecache.keys()):
2913 # dirstate is invalidated separately in invalidatedirstate()
2913 # dirstate is invalidated separately in invalidatedirstate()
2914 if k == b'dirstate':
2914 if k == b'dirstate':
2915 continue
2915 continue
2916 if (
2916 if (
2917 k == b'changelog'
2917 k == b'changelog'
2918 and self.currenttransaction()
2918 and self.currenttransaction()
2919 and self.changelog._delayed
2919 and self.changelog._delayed
2920 ):
2920 ):
2921 # The changelog object may store unwritten revisions. We don't
2921 # The changelog object may store unwritten revisions. We don't
2922 # want to lose them.
2922 # want to lose them.
2923 # TODO: Solve the problem instead of working around it.
2923 # TODO: Solve the problem instead of working around it.
2924 continue
2924 continue
2925
2925
2926 if clearfilecache:
2926 if clearfilecache:
2927 del self._filecache[k]
2927 del self._filecache[k]
2928 try:
2928 try:
2929 delattr(unfiltered, k)
2929 delattr(unfiltered, k)
2930 except AttributeError:
2930 except AttributeError:
2931 pass
2931 pass
2932 self.invalidatecaches()
2932 self.invalidatecaches()
2933 if not self.currenttransaction():
2933 if not self.currenttransaction():
2934 # TODO: Changing contents of store outside transaction
2934 # TODO: Changing contents of store outside transaction
2935 # causes inconsistency. We should make in-memory store
2935 # causes inconsistency. We should make in-memory store
2936 # changes detectable, and abort if changed.
2936 # changes detectable, and abort if changed.
2937 self.store.invalidatecaches()
2937 self.store.invalidatecaches()
2938
2938
2939 def invalidateall(self):
2939 def invalidateall(self):
2940 """Fully invalidates both store and non-store parts, causing the
2940 """Fully invalidates both store and non-store parts, causing the
2941 subsequent operation to reread any outside changes."""
2941 subsequent operation to reread any outside changes."""
2942 # extension should hook this to invalidate its caches
2942 # extension should hook this to invalidate its caches
2943 self.invalidate()
2943 self.invalidate()
2944 self.invalidatedirstate()
2944 self.invalidatedirstate()
2945
2945
2946 @unfilteredmethod
2946 @unfilteredmethod
2947 def _refreshfilecachestats(self, tr):
2947 def _refreshfilecachestats(self, tr):
2948 """Reload stats of cached files so that they are flagged as valid"""
2948 """Reload stats of cached files so that they are flagged as valid"""
2949 for k, ce in self._filecache.items():
2949 for k, ce in self._filecache.items():
2950 k = pycompat.sysstr(k)
2950 k = pycompat.sysstr(k)
2951 if k == 'dirstate' or k not in self.__dict__:
2951 if k == 'dirstate' or k not in self.__dict__:
2952 continue
2952 continue
2953 ce.refresh()
2953 ce.refresh()
2954
2954
2955 def _lock(
2955 def _lock(
2956 self,
2956 self,
2957 vfs,
2957 vfs,
2958 lockname,
2958 lockname,
2959 wait,
2959 wait,
2960 releasefn,
2960 releasefn,
2961 acquirefn,
2961 acquirefn,
2962 desc,
2962 desc,
2963 ):
2963 ):
2964 timeout = 0
2964 timeout = 0
2965 warntimeout = 0
2965 warntimeout = 0
2966 if wait:
2966 if wait:
2967 timeout = self.ui.configint(b"ui", b"timeout")
2967 timeout = self.ui.configint(b"ui", b"timeout")
2968 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2968 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2969 # internal config: ui.signal-safe-lock
2969 # internal config: ui.signal-safe-lock
2970 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2970 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2971
2971
2972 l = lockmod.trylock(
2972 l = lockmod.trylock(
2973 self.ui,
2973 self.ui,
2974 vfs,
2974 vfs,
2975 lockname,
2975 lockname,
2976 timeout,
2976 timeout,
2977 warntimeout,
2977 warntimeout,
2978 releasefn=releasefn,
2978 releasefn=releasefn,
2979 acquirefn=acquirefn,
2979 acquirefn=acquirefn,
2980 desc=desc,
2980 desc=desc,
2981 signalsafe=signalsafe,
2981 signalsafe=signalsafe,
2982 )
2982 )
2983 return l
2983 return l
2984
2984
2985 def _afterlock(self, callback):
2985 def _afterlock(self, callback):
2986 """add a callback to be run when the repository is fully unlocked
2986 """add a callback to be run when the repository is fully unlocked
2987
2987
2988 The callback will be executed when the outermost lock is released
2988 The callback will be executed when the outermost lock is released
2989 (with wlock being higher level than 'lock')."""
2989 (with wlock being higher level than 'lock')."""
2990 for ref in (self._wlockref, self._lockref):
2990 for ref in (self._wlockref, self._lockref):
2991 l = ref and ref()
2991 l = ref and ref()
2992 if l and l.held:
2992 if l and l.held:
2993 l.postrelease.append(callback)
2993 l.postrelease.append(callback)
2994 break
2994 break
2995 else: # no lock have been found.
2995 else: # no lock have been found.
2996 callback(True)
2996 callback(True)
2997
2997
2998 def lock(self, wait=True):
2998 def lock(self, wait=True):
2999 """Lock the repository store (.hg/store) and return a weak reference
2999 """Lock the repository store (.hg/store) and return a weak reference
3000 to the lock. Use this before modifying the store (e.g. committing or
3000 to the lock. Use this before modifying the store (e.g. committing or
3001 stripping). If you are opening a transaction, get a lock as well.)
3001 stripping). If you are opening a transaction, get a lock as well.)
3002
3002
3003 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
3003 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
3004 'wlock' first to avoid a dead-lock hazard."""
3004 'wlock' first to avoid a dead-lock hazard."""
3005 l = self._currentlock(self._lockref)
3005 l = self._currentlock(self._lockref)
3006 if l is not None:
3006 if l is not None:
3007 l.lock()
3007 l.lock()
3008 return l
3008 return l
3009
3009
3010 l = self._lock(
3010 l = self._lock(
3011 vfs=self.svfs,
3011 vfs=self.svfs,
3012 lockname=b"lock",
3012 lockname=b"lock",
3013 wait=wait,
3013 wait=wait,
3014 releasefn=None,
3014 releasefn=None,
3015 acquirefn=self.invalidate,
3015 acquirefn=self.invalidate,
3016 desc=_(b'repository %s') % self.origroot,
3016 desc=_(b'repository %s') % self.origroot,
3017 )
3017 )
3018 self._lockref = weakref.ref(l)
3018 self._lockref = weakref.ref(l)
3019 return l
3019 return l
3020
3020
3021 def wlock(self, wait=True):
3021 def wlock(self, wait=True):
3022 """Lock the non-store parts of the repository (everything under
3022 """Lock the non-store parts of the repository (everything under
3023 .hg except .hg/store) and return a weak reference to the lock.
3023 .hg except .hg/store) and return a weak reference to the lock.
3024
3024
3025 Use this before modifying files in .hg.
3025 Use this before modifying files in .hg.
3026
3026
3027 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
3027 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
3028 'wlock' first to avoid a dead-lock hazard."""
3028 'wlock' first to avoid a dead-lock hazard."""
3029 l = self._wlockref() if self._wlockref else None
3029 l = self._wlockref() if self._wlockref else None
3030 if l is not None and l.held:
3030 if l is not None and l.held:
3031 l.lock()
3031 l.lock()
3032 return l
3032 return l
3033
3033
3034 # We do not need to check for non-waiting lock acquisition. Such
3034 # We do not need to check for non-waiting lock acquisition. Such
3035 # acquisition would not cause dead-lock as they would just fail.
3035 # acquisition would not cause dead-lock as they would just fail.
3036 if wait and (
3036 if wait and (
3037 self.ui.configbool(b'devel', b'all-warnings')
3037 self.ui.configbool(b'devel', b'all-warnings')
3038 or self.ui.configbool(b'devel', b'check-locks')
3038 or self.ui.configbool(b'devel', b'check-locks')
3039 ):
3039 ):
3040 if self._currentlock(self._lockref) is not None:
3040 if self._currentlock(self._lockref) is not None:
3041 self.ui.develwarn(b'"wlock" acquired after "lock"')
3041 self.ui.develwarn(b'"wlock" acquired after "lock"')
3042
3042
3043 def unlock():
3043 def unlock():
3044 if self.dirstate.pendingparentchange():
3044 if self.dirstate.pendingparentchange():
3045 self.dirstate.invalidate()
3045 self.dirstate.invalidate()
3046 else:
3046 else:
3047 self.dirstate.write(None)
3047 self.dirstate.write(None)
3048
3048
3049 self._filecache[b'dirstate'].refresh()
3049 self._filecache[b'dirstate'].refresh()
3050
3050
3051 l = self._lock(
3051 l = self._lock(
3052 self.vfs,
3052 self.vfs,
3053 b"wlock",
3053 b"wlock",
3054 wait,
3054 wait,
3055 unlock,
3055 unlock,
3056 self.invalidatedirstate,
3056 self.invalidatedirstate,
3057 _(b'working directory of %s') % self.origroot,
3057 _(b'working directory of %s') % self.origroot,
3058 )
3058 )
3059 self._wlockref = weakref.ref(l)
3059 self._wlockref = weakref.ref(l)
3060 return l
3060 return l
3061
3061
3062 def _currentlock(self, lockref):
3062 def _currentlock(self, lockref):
3063 """Returns the lock if it's held, or None if it's not."""
3063 """Returns the lock if it's held, or None if it's not."""
3064 if lockref is None:
3064 if lockref is None:
3065 return None
3065 return None
3066 l = lockref()
3066 l = lockref()
3067 if l is None or not l.held:
3067 if l is None or not l.held:
3068 return None
3068 return None
3069 return l
3069 return l
3070
3070
3071 def currentwlock(self):
3071 def currentwlock(self):
3072 """Returns the wlock if it's held, or None if it's not."""
3072 """Returns the wlock if it's held, or None if it's not."""
3073 return self._currentlock(self._wlockref)
3073 return self._currentlock(self._wlockref)
3074
3074
3075 def checkcommitpatterns(self, wctx, match, status, fail):
3075 def checkcommitpatterns(self, wctx, match, status, fail):
3076 """check for commit arguments that aren't committable"""
3076 """check for commit arguments that aren't committable"""
3077 if match.isexact() or match.prefix():
3077 if match.isexact() or match.prefix():
3078 matched = set(status.modified + status.added + status.removed)
3078 matched = set(status.modified + status.added + status.removed)
3079
3079
3080 for f in match.files():
3080 for f in match.files():
3081 f = self.dirstate.normalize(f)
3081 f = self.dirstate.normalize(f)
3082 if f == b'.' or f in matched or f in wctx.substate:
3082 if f == b'.' or f in matched or f in wctx.substate:
3083 continue
3083 continue
3084 if f in status.deleted:
3084 if f in status.deleted:
3085 fail(f, _(b'file not found!'))
3085 fail(f, _(b'file not found!'))
3086 # Is it a directory that exists or used to exist?
3086 # Is it a directory that exists or used to exist?
3087 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3087 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3088 d = f + b'/'
3088 d = f + b'/'
3089 for mf in matched:
3089 for mf in matched:
3090 if mf.startswith(d):
3090 if mf.startswith(d):
3091 break
3091 break
3092 else:
3092 else:
3093 fail(f, _(b"no match under directory!"))
3093 fail(f, _(b"no match under directory!"))
3094 elif f not in self.dirstate:
3094 elif f not in self.dirstate:
3095 fail(f, _(b"file not tracked!"))
3095 fail(f, _(b"file not tracked!"))
3096
3096
3097 @unfilteredmethod
3097 @unfilteredmethod
3098 def commit(
3098 def commit(
3099 self,
3099 self,
3100 text=b"",
3100 text=b"",
3101 user=None,
3101 user=None,
3102 date=None,
3102 date=None,
3103 match=None,
3103 match=None,
3104 force=False,
3104 force=False,
3105 editor=None,
3105 editor=None,
3106 extra=None,
3106 extra=None,
3107 ):
3107 ):
3108 """Add a new revision to current repository.
3108 """Add a new revision to current repository.
3109
3109
3110 Revision information is gathered from the working directory,
3110 Revision information is gathered from the working directory,
3111 match can be used to filter the committed files. If editor is
3111 match can be used to filter the committed files. If editor is
3112 supplied, it is called to get a commit message.
3112 supplied, it is called to get a commit message.
3113 """
3113 """
3114 if extra is None:
3114 if extra is None:
3115 extra = {}
3115 extra = {}
3116
3116
3117 def fail(f, msg):
3117 def fail(f, msg):
3118 raise error.InputError(b'%s: %s' % (f, msg))
3118 raise error.InputError(b'%s: %s' % (f, msg))
3119
3119
3120 if not match:
3120 if not match:
3121 match = matchmod.always()
3121 match = matchmod.always()
3122
3122
3123 if not force:
3123 if not force:
3124 match.bad = fail
3124 match.bad = fail
3125
3125
3126 # lock() for recent changelog (see issue4368)
3126 # lock() for recent changelog (see issue4368)
3127 with self.wlock(), self.lock():
3127 with self.wlock(), self.lock():
3128 wctx = self[None]
3128 wctx = self[None]
3129 merge = len(wctx.parents()) > 1
3129 merge = len(wctx.parents()) > 1
3130
3130
3131 if not force and merge and not match.always():
3131 if not force and merge and not match.always():
3132 raise error.Abort(
3132 raise error.Abort(
3133 _(
3133 _(
3134 b'cannot partially commit a merge '
3134 b'cannot partially commit a merge '
3135 b'(do not specify files or patterns)'
3135 b'(do not specify files or patterns)'
3136 )
3136 )
3137 )
3137 )
3138
3138
3139 status = self.status(match=match, clean=force)
3139 status = self.status(match=match, clean=force)
3140 if force:
3140 if force:
3141 status.modified.extend(
3141 status.modified.extend(
3142 status.clean
3142 status.clean
3143 ) # mq may commit clean files
3143 ) # mq may commit clean files
3144
3144
3145 # check subrepos
3145 # check subrepos
3146 subs, commitsubs, newstate = subrepoutil.precommit(
3146 subs, commitsubs, newstate = subrepoutil.precommit(
3147 self.ui, wctx, status, match, force=force
3147 self.ui, wctx, status, match, force=force
3148 )
3148 )
3149
3149
3150 # make sure all explicit patterns are matched
3150 # make sure all explicit patterns are matched
3151 if not force:
3151 if not force:
3152 self.checkcommitpatterns(wctx, match, status, fail)
3152 self.checkcommitpatterns(wctx, match, status, fail)
3153
3153
3154 cctx = context.workingcommitctx(
3154 cctx = context.workingcommitctx(
3155 self, status, text, user, date, extra
3155 self, status, text, user, date, extra
3156 )
3156 )
3157
3157
3158 ms = mergestatemod.mergestate.read(self)
3158 ms = mergestatemod.mergestate.read(self)
3159 mergeutil.checkunresolved(ms)
3159 mergeutil.checkunresolved(ms)
3160
3160
3161 # internal config: ui.allowemptycommit
3161 # internal config: ui.allowemptycommit
3162 if cctx.isempty() and not self.ui.configbool(
3162 if cctx.isempty() and not self.ui.configbool(
3163 b'ui', b'allowemptycommit'
3163 b'ui', b'allowemptycommit'
3164 ):
3164 ):
3165 self.ui.debug(b'nothing to commit, clearing merge state\n')
3165 self.ui.debug(b'nothing to commit, clearing merge state\n')
3166 ms.reset()
3166 ms.reset()
3167 return None
3167 return None
3168
3168
3169 if merge and cctx.deleted():
3169 if merge and cctx.deleted():
3170 raise error.Abort(_(b"cannot commit merge with missing files"))
3170 raise error.Abort(_(b"cannot commit merge with missing files"))
3171
3171
3172 if editor:
3172 if editor:
3173 cctx._text = editor(self, cctx, subs)
3173 cctx._text = editor(self, cctx, subs)
3174 edited = text != cctx._text
3174 edited = text != cctx._text
3175
3175
3176 # Save commit message in case this transaction gets rolled back
3176 # Save commit message in case this transaction gets rolled back
3177 # (e.g. by a pretxncommit hook). Leave the content alone on
3177 # (e.g. by a pretxncommit hook). Leave the content alone on
3178 # the assumption that the user will use the same editor again.
3178 # the assumption that the user will use the same editor again.
3179 msgfn = self.savecommitmessage(cctx._text)
3179 msgfn = self.savecommitmessage(cctx._text)
3180
3180
3181 # commit subs and write new state
3181 # commit subs and write new state
3182 if subs:
3182 if subs:
3183 uipathfn = scmutil.getuipathfn(self)
3183 uipathfn = scmutil.getuipathfn(self)
3184 for s in sorted(commitsubs):
3184 for s in sorted(commitsubs):
3185 sub = wctx.sub(s)
3185 sub = wctx.sub(s)
3186 self.ui.status(
3186 self.ui.status(
3187 _(b'committing subrepository %s\n')
3187 _(b'committing subrepository %s\n')
3188 % uipathfn(subrepoutil.subrelpath(sub))
3188 % uipathfn(subrepoutil.subrelpath(sub))
3189 )
3189 )
3190 sr = sub.commit(cctx._text, user, date)
3190 sr = sub.commit(cctx._text, user, date)
3191 newstate[s] = (newstate[s][0], sr)
3191 newstate[s] = (newstate[s][0], sr)
3192 subrepoutil.writestate(self, newstate)
3192 subrepoutil.writestate(self, newstate)
3193
3193
3194 p1, p2 = self.dirstate.parents()
3194 p1, p2 = self.dirstate.parents()
3195 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3195 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3196 try:
3196 try:
3197 self.hook(
3197 self.hook(
3198 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3198 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3199 )
3199 )
3200 with self.transaction(b'commit'):
3200 with self.transaction(b'commit'):
3201 ret = self.commitctx(cctx, True)
3201 ret = self.commitctx(cctx, True)
3202 # update bookmarks, dirstate and mergestate
3202 # update bookmarks, dirstate and mergestate
3203 bookmarks.update(self, [p1, p2], ret)
3203 bookmarks.update(self, [p1, p2], ret)
3204 cctx.markcommitted(ret)
3204 cctx.markcommitted(ret)
3205 ms.reset()
3205 ms.reset()
3206 except: # re-raises
3206 except: # re-raises
3207 if edited:
3207 if edited:
3208 self.ui.write(
3208 self.ui.write(
3209 _(b'note: commit message saved in %s\n') % msgfn
3209 _(b'note: commit message saved in %s\n') % msgfn
3210 )
3210 )
3211 self.ui.write(
3211 self.ui.write(
3212 _(
3212 _(
3213 b"note: use 'hg commit --logfile "
3213 b"note: use 'hg commit --logfile "
3214 b".hg/last-message.txt --edit' to reuse it\n"
3214 b".hg/last-message.txt --edit' to reuse it\n"
3215 )
3215 )
3216 )
3216 )
3217 raise
3217 raise
3218
3218
3219 def commithook(unused_success):
3219 def commithook(unused_success):
3220 # hack for command that use a temporary commit (eg: histedit)
3220 # hack for command that use a temporary commit (eg: histedit)
3221 # temporary commit got stripped before hook release
3221 # temporary commit got stripped before hook release
3222 if self.changelog.hasnode(ret):
3222 if self.changelog.hasnode(ret):
3223 self.hook(
3223 self.hook(
3224 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3224 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3225 )
3225 )
3226
3226
3227 self._afterlock(commithook)
3227 self._afterlock(commithook)
3228 return ret
3228 return ret
3229
3229
3230 @unfilteredmethod
3230 @unfilteredmethod
3231 def commitctx(self, ctx, error=False, origctx=None):
3231 def commitctx(self, ctx, error=False, origctx=None):
3232 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3232 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3233
3233
3234 @unfilteredmethod
3234 @unfilteredmethod
3235 def destroying(self):
3235 def destroying(self):
3236 """Inform the repository that nodes are about to be destroyed.
3236 """Inform the repository that nodes are about to be destroyed.
3237 Intended for use by strip and rollback, so there's a common
3237 Intended for use by strip and rollback, so there's a common
3238 place for anything that has to be done before destroying history.
3238 place for anything that has to be done before destroying history.
3239
3239
3240 This is mostly useful for saving state that is in memory and waiting
3240 This is mostly useful for saving state that is in memory and waiting
3241 to be flushed when the current lock is released. Because a call to
3241 to be flushed when the current lock is released. Because a call to
3242 destroyed is imminent, the repo will be invalidated causing those
3242 destroyed is imminent, the repo will be invalidated causing those
3243 changes to stay in memory (waiting for the next unlock), or vanish
3243 changes to stay in memory (waiting for the next unlock), or vanish
3244 completely.
3244 completely.
3245 """
3245 """
3246 # When using the same lock to commit and strip, the phasecache is left
3246 # When using the same lock to commit and strip, the phasecache is left
3247 # dirty after committing. Then when we strip, the repo is invalidated,
3247 # dirty after committing. Then when we strip, the repo is invalidated,
3248 # causing those changes to disappear.
3248 # causing those changes to disappear.
3249 if '_phasecache' in vars(self):
3249 if '_phasecache' in vars(self):
3250 self._phasecache.write()
3250 self._phasecache.write()
3251
3251
3252 @unfilteredmethod
3252 @unfilteredmethod
3253 def destroyed(self):
3253 def destroyed(self):
3254 """Inform the repository that nodes have been destroyed.
3254 """Inform the repository that nodes have been destroyed.
3255 Intended for use by strip and rollback, so there's a common
3255 Intended for use by strip and rollback, so there's a common
3256 place for anything that has to be done after destroying history.
3256 place for anything that has to be done after destroying history.
3257 """
3257 """
3258 # When one tries to:
3258 # When one tries to:
3259 # 1) destroy nodes thus calling this method (e.g. strip)
3259 # 1) destroy nodes thus calling this method (e.g. strip)
3260 # 2) use phasecache somewhere (e.g. commit)
3260 # 2) use phasecache somewhere (e.g. commit)
3261 #
3261 #
3262 # then 2) will fail because the phasecache contains nodes that were
3262 # then 2) will fail because the phasecache contains nodes that were
3263 # removed. We can either remove phasecache from the filecache,
3263 # removed. We can either remove phasecache from the filecache,
3264 # causing it to reload next time it is accessed, or simply filter
3264 # causing it to reload next time it is accessed, or simply filter
3265 # the removed nodes now and write the updated cache.
3265 # the removed nodes now and write the updated cache.
3266 self._phasecache.filterunknown(self)
3266 self._phasecache.filterunknown(self)
3267 self._phasecache.write()
3267 self._phasecache.write()
3268
3268
3269 # refresh all repository caches
3269 # refresh all repository caches
3270 self.updatecaches()
3270 self.updatecaches()
3271
3271
3272 # Ensure the persistent tag cache is updated. Doing it now
3272 # Ensure the persistent tag cache is updated. Doing it now
3273 # means that the tag cache only has to worry about destroyed
3273 # means that the tag cache only has to worry about destroyed
3274 # heads immediately after a strip/rollback. That in turn
3274 # heads immediately after a strip/rollback. That in turn
3275 # guarantees that "cachetip == currenttip" (comparing both rev
3275 # guarantees that "cachetip == currenttip" (comparing both rev
3276 # and node) always means no nodes have been added or destroyed.
3276 # and node) always means no nodes have been added or destroyed.
3277
3277
3278 # XXX this is suboptimal when qrefresh'ing: we strip the current
3278 # XXX this is suboptimal when qrefresh'ing: we strip the current
3279 # head, refresh the tag cache, then immediately add a new head.
3279 # head, refresh the tag cache, then immediately add a new head.
3280 # But I think doing it this way is necessary for the "instant
3280 # But I think doing it this way is necessary for the "instant
3281 # tag cache retrieval" case to work.
3281 # tag cache retrieval" case to work.
3282 self.invalidate()
3282 self.invalidate()
3283
3283
3284 def status(
3284 def status(
3285 self,
3285 self,
3286 node1=b'.',
3286 node1=b'.',
3287 node2=None,
3287 node2=None,
3288 match=None,
3288 match=None,
3289 ignored=False,
3289 ignored=False,
3290 clean=False,
3290 clean=False,
3291 unknown=False,
3291 unknown=False,
3292 listsubrepos=False,
3292 listsubrepos=False,
3293 ):
3293 ):
3294 '''a convenience method that calls node1.status(node2)'''
3294 '''a convenience method that calls node1.status(node2)'''
3295 return self[node1].status(
3295 return self[node1].status(
3296 node2, match, ignored, clean, unknown, listsubrepos
3296 node2, match, ignored, clean, unknown, listsubrepos
3297 )
3297 )
3298
3298
3299 def addpostdsstatus(self, ps):
3299 def addpostdsstatus(self, ps):
3300 """Add a callback to run within the wlock, at the point at which status
3300 """Add a callback to run within the wlock, at the point at which status
3301 fixups happen.
3301 fixups happen.
3302
3302
3303 On status completion, callback(wctx, status) will be called with the
3303 On status completion, callback(wctx, status) will be called with the
3304 wlock held, unless the dirstate has changed from underneath or the wlock
3304 wlock held, unless the dirstate has changed from underneath or the wlock
3305 couldn't be grabbed.
3305 couldn't be grabbed.
3306
3306
3307 Callbacks should not capture and use a cached copy of the dirstate --
3307 Callbacks should not capture and use a cached copy of the dirstate --
3308 it might change in the meanwhile. Instead, they should access the
3308 it might change in the meanwhile. Instead, they should access the
3309 dirstate via wctx.repo().dirstate.
3309 dirstate via wctx.repo().dirstate.
3310
3310
3311 This list is emptied out after each status run -- extensions should
3311 This list is emptied out after each status run -- extensions should
3312 make sure it adds to this list each time dirstate.status is called.
3312 make sure it adds to this list each time dirstate.status is called.
3313 Extensions should also make sure they don't call this for statuses
3313 Extensions should also make sure they don't call this for statuses
3314 that don't involve the dirstate.
3314 that don't involve the dirstate.
3315 """
3315 """
3316
3316
3317 # The list is located here for uniqueness reasons -- it is actually
3317 # The list is located here for uniqueness reasons -- it is actually
3318 # managed by the workingctx, but that isn't unique per-repo.
3318 # managed by the workingctx, but that isn't unique per-repo.
3319 self._postdsstatus.append(ps)
3319 self._postdsstatus.append(ps)
3320
3320
3321 def postdsstatus(self):
3321 def postdsstatus(self):
3322 """Used by workingctx to get the list of post-dirstate-status hooks."""
3322 """Used by workingctx to get the list of post-dirstate-status hooks."""
3323 return self._postdsstatus
3323 return self._postdsstatus
3324
3324
3325 def clearpostdsstatus(self):
3325 def clearpostdsstatus(self):
3326 """Used by workingctx to clear post-dirstate-status hooks."""
3326 """Used by workingctx to clear post-dirstate-status hooks."""
3327 del self._postdsstatus[:]
3327 del self._postdsstatus[:]
3328
3328
3329 def heads(self, start=None):
3329 def heads(self, start=None):
3330 if start is None:
3330 if start is None:
3331 cl = self.changelog
3331 cl = self.changelog
3332 headrevs = reversed(cl.headrevs())
3332 headrevs = reversed(cl.headrevs())
3333 return [cl.node(rev) for rev in headrevs]
3333 return [cl.node(rev) for rev in headrevs]
3334
3334
3335 heads = self.changelog.heads(start)
3335 heads = self.changelog.heads(start)
3336 # sort the output in rev descending order
3336 # sort the output in rev descending order
3337 return sorted(heads, key=self.changelog.rev, reverse=True)
3337 return sorted(heads, key=self.changelog.rev, reverse=True)
3338
3338
3339 def branchheads(self, branch=None, start=None, closed=False):
3339 def branchheads(self, branch=None, start=None, closed=False):
3340 """return a (possibly filtered) list of heads for the given branch
3340 """return a (possibly filtered) list of heads for the given branch
3341
3341
3342 Heads are returned in topological order, from newest to oldest.
3342 Heads are returned in topological order, from newest to oldest.
3343 If branch is None, use the dirstate branch.
3343 If branch is None, use the dirstate branch.
3344 If start is not None, return only heads reachable from start.
3344 If start is not None, return only heads reachable from start.
3345 If closed is True, return heads that are marked as closed as well.
3345 If closed is True, return heads that are marked as closed as well.
3346 """
3346 """
3347 if branch is None:
3347 if branch is None:
3348 branch = self[None].branch()
3348 branch = self[None].branch()
3349 branches = self.branchmap()
3349 branches = self.branchmap()
3350 if not branches.hasbranch(branch):
3350 if not branches.hasbranch(branch):
3351 return []
3351 return []
3352 # the cache returns heads ordered lowest to highest
3352 # the cache returns heads ordered lowest to highest
3353 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3353 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3354 if start is not None:
3354 if start is not None:
3355 # filter out the heads that cannot be reached from startrev
3355 # filter out the heads that cannot be reached from startrev
3356 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3356 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3357 bheads = [h for h in bheads if h in fbheads]
3357 bheads = [h for h in bheads if h in fbheads]
3358 return bheads
3358 return bheads
3359
3359
3360 def branches(self, nodes):
3360 def branches(self, nodes):
3361 if not nodes:
3361 if not nodes:
3362 nodes = [self.changelog.tip()]
3362 nodes = [self.changelog.tip()]
3363 b = []
3363 b = []
3364 for n in nodes:
3364 for n in nodes:
3365 t = n
3365 t = n
3366 while True:
3366 while True:
3367 p = self.changelog.parents(n)
3367 p = self.changelog.parents(n)
3368 if p[1] != self.nullid or p[0] == self.nullid:
3368 if p[1] != self.nullid or p[0] == self.nullid:
3369 b.append((t, n, p[0], p[1]))
3369 b.append((t, n, p[0], p[1]))
3370 break
3370 break
3371 n = p[0]
3371 n = p[0]
3372 return b
3372 return b
3373
3373
3374 def between(self, pairs):
3374 def between(self, pairs):
3375 r = []
3375 r = []
3376
3376
3377 for top, bottom in pairs:
3377 for top, bottom in pairs:
3378 n, l, i = top, [], 0
3378 n, l, i = top, [], 0
3379 f = 1
3379 f = 1
3380
3380
3381 while n != bottom and n != self.nullid:
3381 while n != bottom and n != self.nullid:
3382 p = self.changelog.parents(n)[0]
3382 p = self.changelog.parents(n)[0]
3383 if i == f:
3383 if i == f:
3384 l.append(n)
3384 l.append(n)
3385 f = f * 2
3385 f = f * 2
3386 n = p
3386 n = p
3387 i += 1
3387 i += 1
3388
3388
3389 r.append(l)
3389 r.append(l)
3390
3390
3391 return r
3391 return r
3392
3392
3393 def checkpush(self, pushop):
3393 def checkpush(self, pushop):
3394 """Extensions can override this function if additional checks have
3394 """Extensions can override this function if additional checks have
3395 to be performed before pushing, or call it if they override push
3395 to be performed before pushing, or call it if they override push
3396 command.
3396 command.
3397 """
3397 """
3398
3398
3399 @unfilteredpropertycache
3399 @unfilteredpropertycache
3400 def prepushoutgoinghooks(self):
3400 def prepushoutgoinghooks(self):
3401 """Return util.hooks consists of a pushop with repo, remote, outgoing
3401 """Return util.hooks consists of a pushop with repo, remote, outgoing
3402 methods, which are called before pushing changesets.
3402 methods, which are called before pushing changesets.
3403 """
3403 """
3404 return util.hooks()
3404 return util.hooks()
3405
3405
3406 def pushkey(self, namespace, key, old, new):
3406 def pushkey(self, namespace, key, old, new):
3407 try:
3407 try:
3408 tr = self.currenttransaction()
3408 tr = self.currenttransaction()
3409 hookargs = {}
3409 hookargs = {}
3410 if tr is not None:
3410 if tr is not None:
3411 hookargs.update(tr.hookargs)
3411 hookargs.update(tr.hookargs)
3412 hookargs = pycompat.strkwargs(hookargs)
3412 hookargs = pycompat.strkwargs(hookargs)
3413 hookargs['namespace'] = namespace
3413 hookargs['namespace'] = namespace
3414 hookargs['key'] = key
3414 hookargs['key'] = key
3415 hookargs['old'] = old
3415 hookargs['old'] = old
3416 hookargs['new'] = new
3416 hookargs['new'] = new
3417 self.hook(b'prepushkey', throw=True, **hookargs)
3417 self.hook(b'prepushkey', throw=True, **hookargs)
3418 except error.HookAbort as exc:
3418 except error.HookAbort as exc:
3419 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3419 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3420 if exc.hint:
3420 if exc.hint:
3421 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3421 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3422 return False
3422 return False
3423 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3423 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3424 ret = pushkey.push(self, namespace, key, old, new)
3424 ret = pushkey.push(self, namespace, key, old, new)
3425
3425
3426 def runhook(unused_success):
3426 def runhook(unused_success):
3427 self.hook(
3427 self.hook(
3428 b'pushkey',
3428 b'pushkey',
3429 namespace=namespace,
3429 namespace=namespace,
3430 key=key,
3430 key=key,
3431 old=old,
3431 old=old,
3432 new=new,
3432 new=new,
3433 ret=ret,
3433 ret=ret,
3434 )
3434 )
3435
3435
3436 self._afterlock(runhook)
3436 self._afterlock(runhook)
3437 return ret
3437 return ret
3438
3438
3439 def listkeys(self, namespace):
3439 def listkeys(self, namespace):
3440 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3440 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3441 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3441 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3442 values = pushkey.list(self, namespace)
3442 values = pushkey.list(self, namespace)
3443 self.hook(b'listkeys', namespace=namespace, values=values)
3443 self.hook(b'listkeys', namespace=namespace, values=values)
3444 return values
3444 return values
3445
3445
3446 def debugwireargs(self, one, two, three=None, four=None, five=None):
3446 def debugwireargs(self, one, two, three=None, four=None, five=None):
3447 '''used to test argument passing over the wire'''
3447 '''used to test argument passing over the wire'''
3448 return b"%s %s %s %s %s" % (
3448 return b"%s %s %s %s %s" % (
3449 one,
3449 one,
3450 two,
3450 two,
3451 pycompat.bytestr(three),
3451 pycompat.bytestr(three),
3452 pycompat.bytestr(four),
3452 pycompat.bytestr(four),
3453 pycompat.bytestr(five),
3453 pycompat.bytestr(five),
3454 )
3454 )
3455
3455
3456 def savecommitmessage(self, text):
3456 def savecommitmessage(self, text):
3457 fp = self.vfs(b'last-message.txt', b'wb')
3457 fp = self.vfs(b'last-message.txt', b'wb')
3458 try:
3458 try:
3459 fp.write(text)
3459 fp.write(text)
3460 finally:
3460 finally:
3461 fp.close()
3461 fp.close()
3462 return self.pathto(fp.name[len(self.root) + 1 :])
3462 return self.pathto(fp.name[len(self.root) + 1 :])
3463
3463
3464 def register_wanted_sidedata(self, category):
3464 def register_wanted_sidedata(self, category):
3465 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3465 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3466 # Only revlogv2 repos can want sidedata.
3466 # Only revlogv2 repos can want sidedata.
3467 return
3467 return
3468 self._wanted_sidedata.add(pycompat.bytestr(category))
3468 self._wanted_sidedata.add(pycompat.bytestr(category))
3469
3469
3470 def register_sidedata_computer(
3470 def register_sidedata_computer(
3471 self, kind, category, keys, computer, flags, replace=False
3471 self, kind, category, keys, computer, flags, replace=False
3472 ):
3472 ):
3473 if kind not in revlogconst.ALL_KINDS:
3473 if kind not in revlogconst.ALL_KINDS:
3474 msg = _(b"unexpected revlog kind '%s'.")
3474 msg = _(b"unexpected revlog kind '%s'.")
3475 raise error.ProgrammingError(msg % kind)
3475 raise error.ProgrammingError(msg % kind)
3476 category = pycompat.bytestr(category)
3476 category = pycompat.bytestr(category)
3477 already_registered = category in self._sidedata_computers.get(kind, [])
3477 already_registered = category in self._sidedata_computers.get(kind, [])
3478 if already_registered and not replace:
3478 if already_registered and not replace:
3479 msg = _(
3479 msg = _(
3480 b"cannot register a sidedata computer twice for category '%s'."
3480 b"cannot register a sidedata computer twice for category '%s'."
3481 )
3481 )
3482 raise error.ProgrammingError(msg % category)
3482 raise error.ProgrammingError(msg % category)
3483 if replace and not already_registered:
3483 if replace and not already_registered:
3484 msg = _(
3484 msg = _(
3485 b"cannot replace a sidedata computer that isn't registered "
3485 b"cannot replace a sidedata computer that isn't registered "
3486 b"for category '%s'."
3486 b"for category '%s'."
3487 )
3487 )
3488 raise error.ProgrammingError(msg % category)
3488 raise error.ProgrammingError(msg % category)
3489 self._sidedata_computers.setdefault(kind, {})
3489 self._sidedata_computers.setdefault(kind, {})
3490 self._sidedata_computers[kind][category] = (keys, computer, flags)
3490 self._sidedata_computers[kind][category] = (keys, computer, flags)
3491
3491
3492
3492
3493 # used to avoid circular references so destructors work
3493 # used to avoid circular references so destructors work
3494 def aftertrans(files):
3494 def aftertrans(files):
3495 renamefiles = [tuple(t) for t in files]
3495 renamefiles = [tuple(t) for t in files]
3496
3496
3497 def a():
3497 def a():
3498 for vfs, src, dest in renamefiles:
3498 for vfs, src, dest in renamefiles:
3499 # if src and dest refer to a same file, vfs.rename is a no-op,
3499 # if src and dest refer to a same file, vfs.rename is a no-op,
3500 # leaving both src and dest on disk. delete dest to make sure
3500 # leaving both src and dest on disk. delete dest to make sure
3501 # the rename couldn't be such a no-op.
3501 # the rename couldn't be such a no-op.
3502 vfs.tryunlink(dest)
3502 vfs.tryunlink(dest)
3503 try:
3503 try:
3504 vfs.rename(src, dest)
3504 vfs.rename(src, dest)
3505 except OSError as exc: # journal file does not yet exist
3505 except OSError as exc: # journal file does not yet exist
3506 if exc.errno != errno.ENOENT:
3506 if exc.errno != errno.ENOENT:
3507 raise
3507 raise
3508
3508
3509 return a
3509 return a
3510
3510
3511
3511
3512 def undoname(fn):
3512 def undoname(fn):
3513 base, name = os.path.split(fn)
3513 base, name = os.path.split(fn)
3514 assert name.startswith(b'journal')
3514 assert name.startswith(b'journal')
3515 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3515 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3516
3516
3517
3517
3518 def instance(ui, path, create, intents=None, createopts=None):
3518 def instance(ui, path, create, intents=None, createopts=None):
3519 localpath = urlutil.urllocalpath(path)
3519 localpath = urlutil.urllocalpath(path)
3520 if create:
3520 if create:
3521 createrepository(ui, localpath, createopts=createopts)
3521 createrepository(ui, localpath, createopts=createopts)
3522
3522
3523 return makelocalrepository(ui, localpath, intents=intents)
3523 return makelocalrepository(ui, localpath, intents=intents)
3524
3524
3525
3525
3526 def islocal(path):
3526 def islocal(path):
3527 return True
3527 return True
3528
3528
3529
3529
3530 def defaultcreateopts(ui, createopts=None):
3530 def defaultcreateopts(ui, createopts=None):
3531 """Populate the default creation options for a repository.
3531 """Populate the default creation options for a repository.
3532
3532
3533 A dictionary of explicitly requested creation options can be passed
3533 A dictionary of explicitly requested creation options can be passed
3534 in. Missing keys will be populated.
3534 in. Missing keys will be populated.
3535 """
3535 """
3536 createopts = dict(createopts or {})
3536 createopts = dict(createopts or {})
3537
3537
3538 if b'backend' not in createopts:
3538 if b'backend' not in createopts:
3539 # experimental config: storage.new-repo-backend
3539 # experimental config: storage.new-repo-backend
3540 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3540 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3541
3541
3542 return createopts
3542 return createopts
3543
3543
3544
3544
3545 def clone_requirements(ui, createopts, srcrepo):
3545 def clone_requirements(ui, createopts, srcrepo):
3546 """clone the requirements of a local repo for a local clone
3546 """clone the requirements of a local repo for a local clone
3547
3547
3548 The store requirements are unchanged while the working copy requirements
3548 The store requirements are unchanged while the working copy requirements
3549 depends on the configuration
3549 depends on the configuration
3550 """
3550 """
3551 target_requirements = set()
3551 target_requirements = set()
3552 createopts = defaultcreateopts(ui, createopts=createopts)
3552 createopts = defaultcreateopts(ui, createopts=createopts)
3553 for r in newreporequirements(ui, createopts):
3553 for r in newreporequirements(ui, createopts):
3554 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
3554 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
3555 target_requirements.add(r)
3555 target_requirements.add(r)
3556
3556
3557 for r in srcrepo.requirements:
3557 for r in srcrepo.requirements:
3558 if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
3558 if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
3559 target_requirements.add(r)
3559 target_requirements.add(r)
3560 return target_requirements
3560 return target_requirements
3561
3561
3562
3562
3563 def newreporequirements(ui, createopts):
3563 def newreporequirements(ui, createopts):
3564 """Determine the set of requirements for a new local repository.
3564 """Determine the set of requirements for a new local repository.
3565
3565
3566 Extensions can wrap this function to specify custom requirements for
3566 Extensions can wrap this function to specify custom requirements for
3567 new repositories.
3567 new repositories.
3568 """
3568 """
3569 # If the repo is being created from a shared repository, we copy
3569 # If the repo is being created from a shared repository, we copy
3570 # its requirements.
3570 # its requirements.
3571 if b'sharedrepo' in createopts:
3571 if b'sharedrepo' in createopts:
3572 requirements = set(createopts[b'sharedrepo'].requirements)
3572 requirements = set(createopts[b'sharedrepo'].requirements)
3573 if createopts.get(b'sharedrelative'):
3573 if createopts.get(b'sharedrelative'):
3574 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3574 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3575 else:
3575 else:
3576 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3576 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3577
3577
3578 return requirements
3578 return requirements
3579
3579
3580 if b'backend' not in createopts:
3580 if b'backend' not in createopts:
3581 raise error.ProgrammingError(
3581 raise error.ProgrammingError(
3582 b'backend key not present in createopts; '
3582 b'backend key not present in createopts; '
3583 b'was defaultcreateopts() called?'
3583 b'was defaultcreateopts() called?'
3584 )
3584 )
3585
3585
3586 if createopts[b'backend'] != b'revlogv1':
3586 if createopts[b'backend'] != b'revlogv1':
3587 raise error.Abort(
3587 raise error.Abort(
3588 _(
3588 _(
3589 b'unable to determine repository requirements for '
3589 b'unable to determine repository requirements for '
3590 b'storage backend: %s'
3590 b'storage backend: %s'
3591 )
3591 )
3592 % createopts[b'backend']
3592 % createopts[b'backend']
3593 )
3593 )
3594
3594
3595 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3595 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3596 if ui.configbool(b'format', b'usestore'):
3596 if ui.configbool(b'format', b'usestore'):
3597 requirements.add(requirementsmod.STORE_REQUIREMENT)
3597 requirements.add(requirementsmod.STORE_REQUIREMENT)
3598 if ui.configbool(b'format', b'usefncache'):
3598 if ui.configbool(b'format', b'usefncache'):
3599 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3599 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3600 if ui.configbool(b'format', b'dotencode'):
3600 if ui.configbool(b'format', b'dotencode'):
3601 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3601 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3602
3602
3603 compengines = ui.configlist(b'format', b'revlog-compression')
3603 compengines = ui.configlist(b'format', b'revlog-compression')
3604 for compengine in compengines:
3604 for compengine in compengines:
3605 if compengine in util.compengines:
3605 if compengine in util.compengines:
3606 engine = util.compengines[compengine]
3606 engine = util.compengines[compengine]
3607 if engine.available() and engine.revlogheader():
3607 if engine.available() and engine.revlogheader():
3608 break
3608 break
3609 else:
3609 else:
3610 raise error.Abort(
3610 raise error.Abort(
3611 _(
3611 _(
3612 b'compression engines %s defined by '
3612 b'compression engines %s defined by '
3613 b'format.revlog-compression not available'
3613 b'format.revlog-compression not available'
3614 )
3614 )
3615 % b', '.join(b'"%s"' % e for e in compengines),
3615 % b', '.join(b'"%s"' % e for e in compengines),
3616 hint=_(
3616 hint=_(
3617 b'run "hg debuginstall" to list available '
3617 b'run "hg debuginstall" to list available '
3618 b'compression engines'
3618 b'compression engines'
3619 ),
3619 ),
3620 )
3620 )
3621
3621
3622 # zlib is the historical default and doesn't need an explicit requirement.
3622 # zlib is the historical default and doesn't need an explicit requirement.
3623 if compengine == b'zstd':
3623 if compengine == b'zstd':
3624 requirements.add(b'revlog-compression-zstd')
3624 requirements.add(b'revlog-compression-zstd')
3625 elif compengine != b'zlib':
3625 elif compengine != b'zlib':
3626 requirements.add(b'exp-compression-%s' % compengine)
3626 requirements.add(b'exp-compression-%s' % compengine)
3627
3627
3628 if scmutil.gdinitconfig(ui):
3628 if scmutil.gdinitconfig(ui):
3629 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3629 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3630 if ui.configbool(b'format', b'sparse-revlog'):
3630 if ui.configbool(b'format', b'sparse-revlog'):
3631 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3631 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3632
3632
3633 # experimental config: format.exp-rc-dirstate-v2
3633 # experimental config: format.use-dirstate-v2
3634 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3634 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3635 if ui.configbool(b'format', b'exp-rc-dirstate-v2'):
3635 if ui.configbool(b'format', b'use-dirstate-v2'):
3636 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3636 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3637
3637
3638 # experimental config: format.exp-use-copies-side-data-changeset
3638 # experimental config: format.exp-use-copies-side-data-changeset
3639 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3639 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3640 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3640 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3641 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3641 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3642 if ui.configbool(b'experimental', b'treemanifest'):
3642 if ui.configbool(b'experimental', b'treemanifest'):
3643 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3643 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3644
3644
3645 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3645 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3646 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3646 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3647 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3647 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3648
3648
3649 revlogv2 = ui.config(b'experimental', b'revlogv2')
3649 revlogv2 = ui.config(b'experimental', b'revlogv2')
3650 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3650 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3651 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3651 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3652 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3652 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3653 # experimental config: format.internal-phase
3653 # experimental config: format.internal-phase
3654 if ui.configbool(b'format', b'internal-phase'):
3654 if ui.configbool(b'format', b'internal-phase'):
3655 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3655 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3656
3656
3657 if createopts.get(b'narrowfiles'):
3657 if createopts.get(b'narrowfiles'):
3658 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3658 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3659
3659
3660 if createopts.get(b'lfs'):
3660 if createopts.get(b'lfs'):
3661 requirements.add(b'lfs')
3661 requirements.add(b'lfs')
3662
3662
3663 if ui.configbool(b'format', b'bookmarks-in-store'):
3663 if ui.configbool(b'format', b'bookmarks-in-store'):
3664 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3664 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3665
3665
3666 if ui.configbool(b'format', b'use-persistent-nodemap'):
3666 if ui.configbool(b'format', b'use-persistent-nodemap'):
3667 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3667 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3668
3668
3669 # if share-safe is enabled, let's create the new repository with the new
3669 # if share-safe is enabled, let's create the new repository with the new
3670 # requirement
3670 # requirement
3671 if ui.configbool(b'format', b'use-share-safe'):
3671 if ui.configbool(b'format', b'use-share-safe'):
3672 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3672 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3673
3673
3674 return requirements
3674 return requirements
3675
3675
3676
3676
3677 def checkrequirementscompat(ui, requirements):
3677 def checkrequirementscompat(ui, requirements):
3678 """Checks compatibility of repository requirements enabled and disabled.
3678 """Checks compatibility of repository requirements enabled and disabled.
3679
3679
3680 Returns a set of requirements which needs to be dropped because dependend
3680 Returns a set of requirements which needs to be dropped because dependend
3681 requirements are not enabled. Also warns users about it"""
3681 requirements are not enabled. Also warns users about it"""
3682
3682
3683 dropped = set()
3683 dropped = set()
3684
3684
3685 if requirementsmod.STORE_REQUIREMENT not in requirements:
3685 if requirementsmod.STORE_REQUIREMENT not in requirements:
3686 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3686 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3687 ui.warn(
3687 ui.warn(
3688 _(
3688 _(
3689 b'ignoring enabled \'format.bookmarks-in-store\' config '
3689 b'ignoring enabled \'format.bookmarks-in-store\' config '
3690 b'beacuse it is incompatible with disabled '
3690 b'beacuse it is incompatible with disabled '
3691 b'\'format.usestore\' config\n'
3691 b'\'format.usestore\' config\n'
3692 )
3692 )
3693 )
3693 )
3694 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3694 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3695
3695
3696 if (
3696 if (
3697 requirementsmod.SHARED_REQUIREMENT in requirements
3697 requirementsmod.SHARED_REQUIREMENT in requirements
3698 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3698 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3699 ):
3699 ):
3700 raise error.Abort(
3700 raise error.Abort(
3701 _(
3701 _(
3702 b"cannot create shared repository as source was created"
3702 b"cannot create shared repository as source was created"
3703 b" with 'format.usestore' config disabled"
3703 b" with 'format.usestore' config disabled"
3704 )
3704 )
3705 )
3705 )
3706
3706
3707 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3707 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3708 ui.warn(
3708 ui.warn(
3709 _(
3709 _(
3710 b"ignoring enabled 'format.use-share-safe' config because "
3710 b"ignoring enabled 'format.use-share-safe' config because "
3711 b"it is incompatible with disabled 'format.usestore'"
3711 b"it is incompatible with disabled 'format.usestore'"
3712 b" config\n"
3712 b" config\n"
3713 )
3713 )
3714 )
3714 )
3715 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3715 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3716
3716
3717 return dropped
3717 return dropped
3718
3718
3719
3719
3720 def filterknowncreateopts(ui, createopts):
3720 def filterknowncreateopts(ui, createopts):
3721 """Filters a dict of repo creation options against options that are known.
3721 """Filters a dict of repo creation options against options that are known.
3722
3722
3723 Receives a dict of repo creation options and returns a dict of those
3723 Receives a dict of repo creation options and returns a dict of those
3724 options that we don't know how to handle.
3724 options that we don't know how to handle.
3725
3725
3726 This function is called as part of repository creation. If the
3726 This function is called as part of repository creation. If the
3727 returned dict contains any items, repository creation will not
3727 returned dict contains any items, repository creation will not
3728 be allowed, as it means there was a request to create a repository
3728 be allowed, as it means there was a request to create a repository
3729 with options not recognized by loaded code.
3729 with options not recognized by loaded code.
3730
3730
3731 Extensions can wrap this function to filter out creation options
3731 Extensions can wrap this function to filter out creation options
3732 they know how to handle.
3732 they know how to handle.
3733 """
3733 """
3734 known = {
3734 known = {
3735 b'backend',
3735 b'backend',
3736 b'lfs',
3736 b'lfs',
3737 b'narrowfiles',
3737 b'narrowfiles',
3738 b'sharedrepo',
3738 b'sharedrepo',
3739 b'sharedrelative',
3739 b'sharedrelative',
3740 b'shareditems',
3740 b'shareditems',
3741 b'shallowfilestore',
3741 b'shallowfilestore',
3742 }
3742 }
3743
3743
3744 return {k: v for k, v in createopts.items() if k not in known}
3744 return {k: v for k, v in createopts.items() if k not in known}
3745
3745
3746
3746
3747 def createrepository(ui, path, createopts=None, requirements=None):
3747 def createrepository(ui, path, createopts=None, requirements=None):
3748 """Create a new repository in a vfs.
3748 """Create a new repository in a vfs.
3749
3749
3750 ``path`` path to the new repo's working directory.
3750 ``path`` path to the new repo's working directory.
3751 ``createopts`` options for the new repository.
3751 ``createopts`` options for the new repository.
3752 ``requirement`` predefined set of requirements.
3752 ``requirement`` predefined set of requirements.
3753 (incompatible with ``createopts``)
3753 (incompatible with ``createopts``)
3754
3754
3755 The following keys for ``createopts`` are recognized:
3755 The following keys for ``createopts`` are recognized:
3756
3756
3757 backend
3757 backend
3758 The storage backend to use.
3758 The storage backend to use.
3759 lfs
3759 lfs
3760 Repository will be created with ``lfs`` requirement. The lfs extension
3760 Repository will be created with ``lfs`` requirement. The lfs extension
3761 will automatically be loaded when the repository is accessed.
3761 will automatically be loaded when the repository is accessed.
3762 narrowfiles
3762 narrowfiles
3763 Set up repository to support narrow file storage.
3763 Set up repository to support narrow file storage.
3764 sharedrepo
3764 sharedrepo
3765 Repository object from which storage should be shared.
3765 Repository object from which storage should be shared.
3766 sharedrelative
3766 sharedrelative
3767 Boolean indicating if the path to the shared repo should be
3767 Boolean indicating if the path to the shared repo should be
3768 stored as relative. By default, the pointer to the "parent" repo
3768 stored as relative. By default, the pointer to the "parent" repo
3769 is stored as an absolute path.
3769 is stored as an absolute path.
3770 shareditems
3770 shareditems
3771 Set of items to share to the new repository (in addition to storage).
3771 Set of items to share to the new repository (in addition to storage).
3772 shallowfilestore
3772 shallowfilestore
3773 Indicates that storage for files should be shallow (not all ancestor
3773 Indicates that storage for files should be shallow (not all ancestor
3774 revisions are known).
3774 revisions are known).
3775 """
3775 """
3776
3776
3777 if requirements is not None:
3777 if requirements is not None:
3778 if createopts is not None:
3778 if createopts is not None:
3779 msg = b'cannot specify both createopts and requirements'
3779 msg = b'cannot specify both createopts and requirements'
3780 raise error.ProgrammingError(msg)
3780 raise error.ProgrammingError(msg)
3781 createopts = {}
3781 createopts = {}
3782 else:
3782 else:
3783 createopts = defaultcreateopts(ui, createopts=createopts)
3783 createopts = defaultcreateopts(ui, createopts=createopts)
3784
3784
3785 unknownopts = filterknowncreateopts(ui, createopts)
3785 unknownopts = filterknowncreateopts(ui, createopts)
3786
3786
3787 if not isinstance(unknownopts, dict):
3787 if not isinstance(unknownopts, dict):
3788 raise error.ProgrammingError(
3788 raise error.ProgrammingError(
3789 b'filterknowncreateopts() did not return a dict'
3789 b'filterknowncreateopts() did not return a dict'
3790 )
3790 )
3791
3791
3792 if unknownopts:
3792 if unknownopts:
3793 raise error.Abort(
3793 raise error.Abort(
3794 _(
3794 _(
3795 b'unable to create repository because of unknown '
3795 b'unable to create repository because of unknown '
3796 b'creation option: %s'
3796 b'creation option: %s'
3797 )
3797 )
3798 % b', '.join(sorted(unknownopts)),
3798 % b', '.join(sorted(unknownopts)),
3799 hint=_(b'is a required extension not loaded?'),
3799 hint=_(b'is a required extension not loaded?'),
3800 )
3800 )
3801
3801
3802 requirements = newreporequirements(ui, createopts=createopts)
3802 requirements = newreporequirements(ui, createopts=createopts)
3803 requirements -= checkrequirementscompat(ui, requirements)
3803 requirements -= checkrequirementscompat(ui, requirements)
3804
3804
3805 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3805 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3806
3806
3807 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3807 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3808 if hgvfs.exists():
3808 if hgvfs.exists():
3809 raise error.RepoError(_(b'repository %s already exists') % path)
3809 raise error.RepoError(_(b'repository %s already exists') % path)
3810
3810
3811 if b'sharedrepo' in createopts:
3811 if b'sharedrepo' in createopts:
3812 sharedpath = createopts[b'sharedrepo'].sharedpath
3812 sharedpath = createopts[b'sharedrepo'].sharedpath
3813
3813
3814 if createopts.get(b'sharedrelative'):
3814 if createopts.get(b'sharedrelative'):
3815 try:
3815 try:
3816 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3816 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3817 sharedpath = util.pconvert(sharedpath)
3817 sharedpath = util.pconvert(sharedpath)
3818 except (IOError, ValueError) as e:
3818 except (IOError, ValueError) as e:
3819 # ValueError is raised on Windows if the drive letters differ
3819 # ValueError is raised on Windows if the drive letters differ
3820 # on each path.
3820 # on each path.
3821 raise error.Abort(
3821 raise error.Abort(
3822 _(b'cannot calculate relative path'),
3822 _(b'cannot calculate relative path'),
3823 hint=stringutil.forcebytestr(e),
3823 hint=stringutil.forcebytestr(e),
3824 )
3824 )
3825
3825
3826 if not wdirvfs.exists():
3826 if not wdirvfs.exists():
3827 wdirvfs.makedirs()
3827 wdirvfs.makedirs()
3828
3828
3829 hgvfs.makedir(notindexed=True)
3829 hgvfs.makedir(notindexed=True)
3830 if b'sharedrepo' not in createopts:
3830 if b'sharedrepo' not in createopts:
3831 hgvfs.mkdir(b'cache')
3831 hgvfs.mkdir(b'cache')
3832 hgvfs.mkdir(b'wcache')
3832 hgvfs.mkdir(b'wcache')
3833
3833
3834 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3834 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3835 if has_store and b'sharedrepo' not in createopts:
3835 if has_store and b'sharedrepo' not in createopts:
3836 hgvfs.mkdir(b'store')
3836 hgvfs.mkdir(b'store')
3837
3837
3838 # We create an invalid changelog outside the store so very old
3838 # We create an invalid changelog outside the store so very old
3839 # Mercurial versions (which didn't know about the requirements
3839 # Mercurial versions (which didn't know about the requirements
3840 # file) encounter an error on reading the changelog. This
3840 # file) encounter an error on reading the changelog. This
3841 # effectively locks out old clients and prevents them from
3841 # effectively locks out old clients and prevents them from
3842 # mucking with a repo in an unknown format.
3842 # mucking with a repo in an unknown format.
3843 #
3843 #
3844 # The revlog header has version 65535, which won't be recognized by
3844 # The revlog header has version 65535, which won't be recognized by
3845 # such old clients.
3845 # such old clients.
3846 hgvfs.append(
3846 hgvfs.append(
3847 b'00changelog.i',
3847 b'00changelog.i',
3848 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3848 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3849 b'layout',
3849 b'layout',
3850 )
3850 )
3851
3851
3852 # Filter the requirements into working copy and store ones
3852 # Filter the requirements into working copy and store ones
3853 wcreq, storereq = scmutil.filterrequirements(requirements)
3853 wcreq, storereq = scmutil.filterrequirements(requirements)
3854 # write working copy ones
3854 # write working copy ones
3855 scmutil.writerequires(hgvfs, wcreq)
3855 scmutil.writerequires(hgvfs, wcreq)
3856 # If there are store requirements and the current repository
3856 # If there are store requirements and the current repository
3857 # is not a shared one, write stored requirements
3857 # is not a shared one, write stored requirements
3858 # For new shared repository, we don't need to write the store
3858 # For new shared repository, we don't need to write the store
3859 # requirements as they are already present in store requires
3859 # requirements as they are already present in store requires
3860 if storereq and b'sharedrepo' not in createopts:
3860 if storereq and b'sharedrepo' not in createopts:
3861 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3861 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3862 scmutil.writerequires(storevfs, storereq)
3862 scmutil.writerequires(storevfs, storereq)
3863
3863
3864 # Write out file telling readers where to find the shared store.
3864 # Write out file telling readers where to find the shared store.
3865 if b'sharedrepo' in createopts:
3865 if b'sharedrepo' in createopts:
3866 hgvfs.write(b'sharedpath', sharedpath)
3866 hgvfs.write(b'sharedpath', sharedpath)
3867
3867
3868 if createopts.get(b'shareditems'):
3868 if createopts.get(b'shareditems'):
3869 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3869 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3870 hgvfs.write(b'shared', shared)
3870 hgvfs.write(b'shared', shared)
3871
3871
3872
3872
3873 def poisonrepository(repo):
3873 def poisonrepository(repo):
3874 """Poison a repository instance so it can no longer be used."""
3874 """Poison a repository instance so it can no longer be used."""
3875 # Perform any cleanup on the instance.
3875 # Perform any cleanup on the instance.
3876 repo.close()
3876 repo.close()
3877
3877
3878 # Our strategy is to replace the type of the object with one that
3878 # Our strategy is to replace the type of the object with one that
3879 # has all attribute lookups result in error.
3879 # has all attribute lookups result in error.
3880 #
3880 #
3881 # But we have to allow the close() method because some constructors
3881 # But we have to allow the close() method because some constructors
3882 # of repos call close() on repo references.
3882 # of repos call close() on repo references.
3883 class poisonedrepository(object):
3883 class poisonedrepository(object):
3884 def __getattribute__(self, item):
3884 def __getattribute__(self, item):
3885 if item == 'close':
3885 if item == 'close':
3886 return object.__getattribute__(self, item)
3886 return object.__getattribute__(self, item)
3887
3887
3888 raise error.ProgrammingError(
3888 raise error.ProgrammingError(
3889 b'repo instances should not be used after unshare'
3889 b'repo instances should not be used after unshare'
3890 )
3890 )
3891
3891
3892 def close(self):
3892 def close(self):
3893 pass
3893 pass
3894
3894
3895 # We may have a repoview, which intercepts __setattr__. So be sure
3895 # We may have a repoview, which intercepts __setattr__. So be sure
3896 # we operate at the lowest level possible.
3896 # we operate at the lowest level possible.
3897 object.__setattr__(repo, '__class__', poisonedrepository)
3897 object.__setattr__(repo, '__class__', poisonedrepository)
@@ -1,258 +1,258 b''
1 Create a repository:
1 Create a repository:
2
2
3 #if no-extraextensions
3 #if no-extraextensions
4 $ hg config
4 $ hg config
5 chgserver.idletimeout=60
5 chgserver.idletimeout=60
6 devel.all-warnings=true
6 devel.all-warnings=true
7 devel.default-date=0 0
7 devel.default-date=0 0
8 extensions.fsmonitor= (fsmonitor !)
8 extensions.fsmonitor= (fsmonitor !)
9 format.exp-rc-dirstate-v2=1 (dirstate-v2 !)
9 format.use-dirstate-v2=1 (dirstate-v2 !)
10 largefiles.usercache=$TESTTMP/.cache/largefiles
10 largefiles.usercache=$TESTTMP/.cache/largefiles
11 lfs.usercache=$TESTTMP/.cache/lfs
11 lfs.usercache=$TESTTMP/.cache/lfs
12 ui.slash=True
12 ui.slash=True
13 ui.interactive=False
13 ui.interactive=False
14 ui.detailed-exit-code=True
14 ui.detailed-exit-code=True
15 ui.merge=internal:merge
15 ui.merge=internal:merge
16 ui.mergemarkers=detailed
16 ui.mergemarkers=detailed
17 ui.promptecho=True
17 ui.promptecho=True
18 ui.ssh=* (glob)
18 ui.ssh=* (glob)
19 ui.timeout.warn=15
19 ui.timeout.warn=15
20 web.address=localhost
20 web.address=localhost
21 web\.ipv6=(?:True|False) (re)
21 web\.ipv6=(?:True|False) (re)
22 web.server-header=testing stub value
22 web.server-header=testing stub value
23 #endif
23 #endif
24
24
25 $ hg init t
25 $ hg init t
26 $ cd t
26 $ cd t
27
27
28 Prepare a changeset:
28 Prepare a changeset:
29
29
30 $ echo a > a
30 $ echo a > a
31 $ hg add a
31 $ hg add a
32
32
33 $ hg status
33 $ hg status
34 A a
34 A a
35
35
36 Writes to stdio succeed and fail appropriately
36 Writes to stdio succeed and fail appropriately
37
37
38 #if devfull
38 #if devfull
39 $ hg status 2>/dev/full
39 $ hg status 2>/dev/full
40 A a
40 A a
41
41
42 $ hg status >/dev/full
42 $ hg status >/dev/full
43 abort: No space left on device
43 abort: No space left on device
44 [255]
44 [255]
45 #endif
45 #endif
46
46
47 #if devfull
47 #if devfull
48 $ hg status >/dev/full 2>&1
48 $ hg status >/dev/full 2>&1
49 [255]
49 [255]
50
50
51 $ hg status ENOENT 2>/dev/full
51 $ hg status ENOENT 2>/dev/full
52 [255]
52 [255]
53 #endif
53 #endif
54
54
55 On Python 3, stdio may be None:
55 On Python 3, stdio may be None:
56
56
57 $ hg debuguiprompt --config ui.interactive=true 0<&-
57 $ hg debuguiprompt --config ui.interactive=true 0<&-
58 abort: Bad file descriptor (no-rhg !)
58 abort: Bad file descriptor (no-rhg !)
59 abort: response expected (rhg !)
59 abort: response expected (rhg !)
60 [255]
60 [255]
61 $ hg version -q 0<&-
61 $ hg version -q 0<&-
62 Mercurial Distributed SCM * (glob)
62 Mercurial Distributed SCM * (glob)
63
63
64 #if py3 no-rhg
64 #if py3 no-rhg
65 $ hg version -q 1>&-
65 $ hg version -q 1>&-
66 abort: Bad file descriptor
66 abort: Bad file descriptor
67 [255]
67 [255]
68 #else
68 #else
69 $ hg version -q 1>&-
69 $ hg version -q 1>&-
70 #endif
70 #endif
71 $ hg unknown -q 1>&-
71 $ hg unknown -q 1>&-
72 hg: unknown command 'unknown'
72 hg: unknown command 'unknown'
73 (did you mean debugknown?)
73 (did you mean debugknown?)
74 [10]
74 [10]
75
75
76 $ hg version -q 2>&-
76 $ hg version -q 2>&-
77 Mercurial Distributed SCM * (glob)
77 Mercurial Distributed SCM * (glob)
78 $ hg unknown -q 2>&-
78 $ hg unknown -q 2>&-
79 [10]
79 [10]
80
80
81 $ hg commit -m test
81 $ hg commit -m test
82
82
83 This command is ancient:
83 This command is ancient:
84
84
85 $ hg history
85 $ hg history
86 changeset: 0:acb14030fe0a
86 changeset: 0:acb14030fe0a
87 tag: tip
87 tag: tip
88 user: test
88 user: test
89 date: Thu Jan 01 00:00:00 1970 +0000
89 date: Thu Jan 01 00:00:00 1970 +0000
90 summary: test
90 summary: test
91
91
92
92
93 Verify that updating to revision 0 via commands.update() works properly
93 Verify that updating to revision 0 via commands.update() works properly
94
94
95 $ cat <<EOF > update_to_rev0.py
95 $ cat <<EOF > update_to_rev0.py
96 > from mercurial import commands, hg, ui as uimod
96 > from mercurial import commands, hg, ui as uimod
97 > myui = uimod.ui.load()
97 > myui = uimod.ui.load()
98 > repo = hg.repository(myui, path=b'.')
98 > repo = hg.repository(myui, path=b'.')
99 > commands.update(myui, repo, rev=b"0")
99 > commands.update(myui, repo, rev=b"0")
100 > EOF
100 > EOF
101 $ hg up null
101 $ hg up null
102 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
102 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
103 $ "$PYTHON" ./update_to_rev0.py
103 $ "$PYTHON" ./update_to_rev0.py
104 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
104 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
105 $ hg identify -n
105 $ hg identify -n
106 0
106 0
107
107
108
108
109 Poke around at hashes:
109 Poke around at hashes:
110
110
111 $ hg manifest --debug
111 $ hg manifest --debug
112 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
112 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
113
113
114 $ hg cat a
114 $ hg cat a
115 a
115 a
116
116
117 Verify should succeed:
117 Verify should succeed:
118
118
119 $ hg verify
119 $ hg verify
120 checking changesets
120 checking changesets
121 checking manifests
121 checking manifests
122 crosschecking files in changesets and manifests
122 crosschecking files in changesets and manifests
123 checking files
123 checking files
124 checked 1 changesets with 1 changes to 1 files
124 checked 1 changesets with 1 changes to 1 files
125
125
126 Repository root:
126 Repository root:
127
127
128 $ hg root
128 $ hg root
129 $TESTTMP/t
129 $TESTTMP/t
130 $ hg log -l1 -T '{reporoot}\n'
130 $ hg log -l1 -T '{reporoot}\n'
131 $TESTTMP/t
131 $TESTTMP/t
132 $ hg root -Tjson | sed 's|\\\\|\\|g'
132 $ hg root -Tjson | sed 's|\\\\|\\|g'
133 [
133 [
134 {
134 {
135 "hgpath": "$TESTTMP/t/.hg",
135 "hgpath": "$TESTTMP/t/.hg",
136 "reporoot": "$TESTTMP/t",
136 "reporoot": "$TESTTMP/t",
137 "storepath": "$TESTTMP/t/.hg/store"
137 "storepath": "$TESTTMP/t/.hg/store"
138 }
138 }
139 ]
139 ]
140
140
141 At the end...
141 At the end...
142
142
143 $ cd ..
143 $ cd ..
144
144
145 Status message redirection:
145 Status message redirection:
146
146
147 $ hg init empty
147 $ hg init empty
148
148
149 status messages are sent to stdout by default:
149 status messages are sent to stdout by default:
150
150
151 $ hg outgoing -R t empty -Tjson 2>/dev/null
151 $ hg outgoing -R t empty -Tjson 2>/dev/null
152 comparing with empty
152 comparing with empty
153 searching for changes
153 searching for changes
154 [
154 [
155 {
155 {
156 "bookmarks": [],
156 "bookmarks": [],
157 "branch": "default",
157 "branch": "default",
158 "date": [0, 0],
158 "date": [0, 0],
159 "desc": "test",
159 "desc": "test",
160 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
160 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
161 "parents": ["0000000000000000000000000000000000000000"],
161 "parents": ["0000000000000000000000000000000000000000"],
162 "phase": "draft",
162 "phase": "draft",
163 "rev": 0,
163 "rev": 0,
164 "tags": ["tip"],
164 "tags": ["tip"],
165 "user": "test"
165 "user": "test"
166 }
166 }
167 ]
167 ]
168
168
169 which can be configured to send to stderr, so the output wouldn't be
169 which can be configured to send to stderr, so the output wouldn't be
170 interleaved:
170 interleaved:
171
171
172 $ cat <<'EOF' >> "$HGRCPATH"
172 $ cat <<'EOF' >> "$HGRCPATH"
173 > [ui]
173 > [ui]
174 > message-output = stderr
174 > message-output = stderr
175 > EOF
175 > EOF
176 $ hg outgoing -R t empty -Tjson 2>/dev/null
176 $ hg outgoing -R t empty -Tjson 2>/dev/null
177 [
177 [
178 {
178 {
179 "bookmarks": [],
179 "bookmarks": [],
180 "branch": "default",
180 "branch": "default",
181 "date": [0, 0],
181 "date": [0, 0],
182 "desc": "test",
182 "desc": "test",
183 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
183 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
184 "parents": ["0000000000000000000000000000000000000000"],
184 "parents": ["0000000000000000000000000000000000000000"],
185 "phase": "draft",
185 "phase": "draft",
186 "rev": 0,
186 "rev": 0,
187 "tags": ["tip"],
187 "tags": ["tip"],
188 "user": "test"
188 "user": "test"
189 }
189 }
190 ]
190 ]
191 $ hg outgoing -R t empty -Tjson >/dev/null
191 $ hg outgoing -R t empty -Tjson >/dev/null
192 comparing with empty
192 comparing with empty
193 searching for changes
193 searching for changes
194
194
195 this option should be turned off by HGPLAIN= since it may break scripting use:
195 this option should be turned off by HGPLAIN= since it may break scripting use:
196
196
197 $ HGPLAIN= hg outgoing -R t empty -Tjson 2>/dev/null
197 $ HGPLAIN= hg outgoing -R t empty -Tjson 2>/dev/null
198 comparing with empty
198 comparing with empty
199 searching for changes
199 searching for changes
200 [
200 [
201 {
201 {
202 "bookmarks": [],
202 "bookmarks": [],
203 "branch": "default",
203 "branch": "default",
204 "date": [0, 0],
204 "date": [0, 0],
205 "desc": "test",
205 "desc": "test",
206 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
206 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
207 "parents": ["0000000000000000000000000000000000000000"],
207 "parents": ["0000000000000000000000000000000000000000"],
208 "phase": "draft",
208 "phase": "draft",
209 "rev": 0,
209 "rev": 0,
210 "tags": ["tip"],
210 "tags": ["tip"],
211 "user": "test"
211 "user": "test"
212 }
212 }
213 ]
213 ]
214
214
215 but still overridden by --config:
215 but still overridden by --config:
216
216
217 $ HGPLAIN= hg outgoing -R t empty -Tjson --config ui.message-output=stderr \
217 $ HGPLAIN= hg outgoing -R t empty -Tjson --config ui.message-output=stderr \
218 > 2>/dev/null
218 > 2>/dev/null
219 [
219 [
220 {
220 {
221 "bookmarks": [],
221 "bookmarks": [],
222 "branch": "default",
222 "branch": "default",
223 "date": [0, 0],
223 "date": [0, 0],
224 "desc": "test",
224 "desc": "test",
225 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
225 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
226 "parents": ["0000000000000000000000000000000000000000"],
226 "parents": ["0000000000000000000000000000000000000000"],
227 "phase": "draft",
227 "phase": "draft",
228 "rev": 0,
228 "rev": 0,
229 "tags": ["tip"],
229 "tags": ["tip"],
230 "user": "test"
230 "user": "test"
231 }
231 }
232 ]
232 ]
233
233
234 Invalid ui.message-output option:
234 Invalid ui.message-output option:
235
235
236 $ hg log -R t --config ui.message-output=bad
236 $ hg log -R t --config ui.message-output=bad
237 abort: invalid ui.message-output destination: bad
237 abort: invalid ui.message-output destination: bad
238 [255]
238 [255]
239
239
240 Underlying message streams should be updated when ui.fout/ferr are set:
240 Underlying message streams should be updated when ui.fout/ferr are set:
241
241
242 $ cat <<'EOF' > capui.py
242 $ cat <<'EOF' > capui.py
243 > from mercurial import pycompat, registrar
243 > from mercurial import pycompat, registrar
244 > cmdtable = {}
244 > cmdtable = {}
245 > command = registrar.command(cmdtable)
245 > command = registrar.command(cmdtable)
246 > @command(b'capui', norepo=True)
246 > @command(b'capui', norepo=True)
247 > def capui(ui):
247 > def capui(ui):
248 > out = ui.fout
248 > out = ui.fout
249 > ui.fout = pycompat.bytesio()
249 > ui.fout = pycompat.bytesio()
250 > ui.status(b'status\n')
250 > ui.status(b'status\n')
251 > ui.ferr = pycompat.bytesio()
251 > ui.ferr = pycompat.bytesio()
252 > ui.warn(b'warn\n')
252 > ui.warn(b'warn\n')
253 > out.write(b'stdout: %s' % ui.fout.getvalue())
253 > out.write(b'stdout: %s' % ui.fout.getvalue())
254 > out.write(b'stderr: %s' % ui.ferr.getvalue())
254 > out.write(b'stderr: %s' % ui.ferr.getvalue())
255 > EOF
255 > EOF
256 $ hg --config extensions.capui=capui.py --config ui.message-output=stdio capui
256 $ hg --config extensions.capui=capui.py --config ui.message-output=stdio capui
257 stdout: status
257 stdout: status
258 stderr: warn
258 stderr: warn
@@ -1,1174 +1,1174 b''
1 #require no-rhg no-chg
1 #require no-rhg no-chg
2
2
3 XXX-RHG this test hangs if `hg` is really `rhg`. This was hidden by the use of
3 XXX-RHG this test hangs if `hg` is really `rhg`. This was hidden by the use of
4 `alias hg=rhg` by run-tests.py. With such alias removed, this test is revealed
4 `alias hg=rhg` by run-tests.py. With such alias removed, this test is revealed
5 buggy. This need to be resolved sooner than later.
5 buggy. This need to be resolved sooner than later.
6
6
7 XXX-CHG this test hangs if `hg` is really `chg`. This was hidden by the use of
7 XXX-CHG this test hangs if `hg` is really `chg`. This was hidden by the use of
8 `alias hg=chg` by run-tests.py. With such alias removed, this test is revealed
8 `alias hg=chg` by run-tests.py. With such alias removed, this test is revealed
9 buggy. This need to be resolved sooner than later.
9 buggy. This need to be resolved sooner than later.
10
10
11 #if windows
11 #if windows
12 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
12 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
13 #else
13 #else
14 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
14 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
15 #endif
15 #endif
16 $ export PYTHONPATH
16 $ export PYTHONPATH
17
17
18 typical client does not want echo-back messages, so test without it:
18 typical client does not want echo-back messages, so test without it:
19
19
20 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
20 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
21 $ mv $HGRCPATH.new $HGRCPATH
21 $ mv $HGRCPATH.new $HGRCPATH
22
22
23 $ hg init repo
23 $ hg init repo
24 $ cd repo
24 $ cd repo
25
25
26 >>> from __future__ import absolute_import
26 >>> from __future__ import absolute_import
27 >>> import os
27 >>> import os
28 >>> import sys
28 >>> import sys
29 >>> from hgclient import bprint, check, readchannel, runcommand
29 >>> from hgclient import bprint, check, readchannel, runcommand
30 >>> @check
30 >>> @check
31 ... def hellomessage(server):
31 ... def hellomessage(server):
32 ... ch, data = readchannel(server)
32 ... ch, data = readchannel(server)
33 ... bprint(b'%c, %r' % (ch, data))
33 ... bprint(b'%c, %r' % (ch, data))
34 ... # run an arbitrary command to make sure the next thing the server
34 ... # run an arbitrary command to make sure the next thing the server
35 ... # sends isn't part of the hello message
35 ... # sends isn't part of the hello message
36 ... runcommand(server, [b'id'])
36 ... runcommand(server, [b'id'])
37 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
37 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
38 *** runcommand id
38 *** runcommand id
39 000000000000 tip
39 000000000000 tip
40
40
41 >>> from hgclient import check
41 >>> from hgclient import check
42 >>> @check
42 >>> @check
43 ... def unknowncommand(server):
43 ... def unknowncommand(server):
44 ... server.stdin.write(b'unknowncommand\n')
44 ... server.stdin.write(b'unknowncommand\n')
45 abort: unknown command unknowncommand
45 abort: unknown command unknowncommand
46
46
47 >>> from hgclient import check, readchannel, runcommand
47 >>> from hgclient import check, readchannel, runcommand
48 >>> @check
48 >>> @check
49 ... def checkruncommand(server):
49 ... def checkruncommand(server):
50 ... # hello block
50 ... # hello block
51 ... readchannel(server)
51 ... readchannel(server)
52 ...
52 ...
53 ... # no args
53 ... # no args
54 ... runcommand(server, [])
54 ... runcommand(server, [])
55 ...
55 ...
56 ... # global options
56 ... # global options
57 ... runcommand(server, [b'id', b'--quiet'])
57 ... runcommand(server, [b'id', b'--quiet'])
58 ...
58 ...
59 ... # make sure global options don't stick through requests
59 ... # make sure global options don't stick through requests
60 ... runcommand(server, [b'id'])
60 ... runcommand(server, [b'id'])
61 ...
61 ...
62 ... # --config
62 ... # --config
63 ... runcommand(server, [b'id', b'--config', b'ui.quiet=True'])
63 ... runcommand(server, [b'id', b'--config', b'ui.quiet=True'])
64 ...
64 ...
65 ... # make sure --config doesn't stick
65 ... # make sure --config doesn't stick
66 ... runcommand(server, [b'id'])
66 ... runcommand(server, [b'id'])
67 ...
67 ...
68 ... # negative return code should be masked
68 ... # negative return code should be masked
69 ... runcommand(server, [b'id', b'-runknown'])
69 ... runcommand(server, [b'id', b'-runknown'])
70 *** runcommand
70 *** runcommand
71 Mercurial Distributed SCM
71 Mercurial Distributed SCM
72
72
73 basic commands:
73 basic commands:
74
74
75 add add the specified files on the next commit
75 add add the specified files on the next commit
76 annotate show changeset information by line for each file
76 annotate show changeset information by line for each file
77 clone make a copy of an existing repository
77 clone make a copy of an existing repository
78 commit commit the specified files or all outstanding changes
78 commit commit the specified files or all outstanding changes
79 diff diff repository (or selected files)
79 diff diff repository (or selected files)
80 export dump the header and diffs for one or more changesets
80 export dump the header and diffs for one or more changesets
81 forget forget the specified files on the next commit
81 forget forget the specified files on the next commit
82 init create a new repository in the given directory
82 init create a new repository in the given directory
83 log show revision history of entire repository or files
83 log show revision history of entire repository or files
84 merge merge another revision into working directory
84 merge merge another revision into working directory
85 pull pull changes from the specified source
85 pull pull changes from the specified source
86 push push changes to the specified destination
86 push push changes to the specified destination
87 remove remove the specified files on the next commit
87 remove remove the specified files on the next commit
88 serve start stand-alone webserver
88 serve start stand-alone webserver
89 status show changed files in the working directory
89 status show changed files in the working directory
90 summary summarize working directory state
90 summary summarize working directory state
91 update update working directory (or switch revisions)
91 update update working directory (or switch revisions)
92
92
93 (use 'hg help' for the full list of commands or 'hg -v' for details)
93 (use 'hg help' for the full list of commands or 'hg -v' for details)
94 *** runcommand id --quiet
94 *** runcommand id --quiet
95 000000000000
95 000000000000
96 *** runcommand id
96 *** runcommand id
97 000000000000 tip
97 000000000000 tip
98 *** runcommand id --config ui.quiet=True
98 *** runcommand id --config ui.quiet=True
99 000000000000
99 000000000000
100 *** runcommand id
100 *** runcommand id
101 000000000000 tip
101 000000000000 tip
102 *** runcommand id -runknown
102 *** runcommand id -runknown
103 abort: unknown revision 'unknown'
103 abort: unknown revision 'unknown'
104 [10]
104 [10]
105
105
106 >>> from hgclient import bprint, check, readchannel
106 >>> from hgclient import bprint, check, readchannel
107 >>> @check
107 >>> @check
108 ... def inputeof(server):
108 ... def inputeof(server):
109 ... readchannel(server)
109 ... readchannel(server)
110 ... server.stdin.write(b'runcommand\n')
110 ... server.stdin.write(b'runcommand\n')
111 ... # close stdin while server is waiting for input
111 ... # close stdin while server is waiting for input
112 ... server.stdin.close()
112 ... server.stdin.close()
113 ...
113 ...
114 ... # server exits with 1 if the pipe closed while reading the command
114 ... # server exits with 1 if the pipe closed while reading the command
115 ... bprint(b'server exit code =', b'%d' % server.wait())
115 ... bprint(b'server exit code =', b'%d' % server.wait())
116 server exit code = 1
116 server exit code = 1
117
117
118 >>> from hgclient import check, readchannel, runcommand, stringio
118 >>> from hgclient import check, readchannel, runcommand, stringio
119 >>> @check
119 >>> @check
120 ... def serverinput(server):
120 ... def serverinput(server):
121 ... readchannel(server)
121 ... readchannel(server)
122 ...
122 ...
123 ... patch = b"""
123 ... patch = b"""
124 ... # HG changeset patch
124 ... # HG changeset patch
125 ... # User test
125 ... # User test
126 ... # Date 0 0
126 ... # Date 0 0
127 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
127 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
128 ... # Parent 0000000000000000000000000000000000000000
128 ... # Parent 0000000000000000000000000000000000000000
129 ... 1
129 ... 1
130 ...
130 ...
131 ... diff -r 000000000000 -r c103a3dec114 a
131 ... diff -r 000000000000 -r c103a3dec114 a
132 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
132 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
133 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
133 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
134 ... @@ -0,0 +1,1 @@
134 ... @@ -0,0 +1,1 @@
135 ... +1
135 ... +1
136 ... """
136 ... """
137 ...
137 ...
138 ... runcommand(server, [b'import', b'-'], input=stringio(patch))
138 ... runcommand(server, [b'import', b'-'], input=stringio(patch))
139 ... runcommand(server, [b'log'])
139 ... runcommand(server, [b'log'])
140 *** runcommand import -
140 *** runcommand import -
141 applying patch from stdin
141 applying patch from stdin
142 *** runcommand log
142 *** runcommand log
143 changeset: 0:eff892de26ec
143 changeset: 0:eff892de26ec
144 tag: tip
144 tag: tip
145 user: test
145 user: test
146 date: Thu Jan 01 00:00:00 1970 +0000
146 date: Thu Jan 01 00:00:00 1970 +0000
147 summary: 1
147 summary: 1
148
148
149
149
150 check strict parsing of early options:
150 check strict parsing of early options:
151
151
152 >>> import os
152 >>> import os
153 >>> from hgclient import check, readchannel, runcommand
153 >>> from hgclient import check, readchannel, runcommand
154 >>> os.environ['HGPLAIN'] = '+strictflags'
154 >>> os.environ['HGPLAIN'] = '+strictflags'
155 >>> @check
155 >>> @check
156 ... def cwd(server):
156 ... def cwd(server):
157 ... readchannel(server)
157 ... readchannel(server)
158 ... runcommand(server, [b'log', b'-b', b'--config=alias.log=!echo pwned',
158 ... runcommand(server, [b'log', b'-b', b'--config=alias.log=!echo pwned',
159 ... b'default'])
159 ... b'default'])
160 *** runcommand log -b --config=alias.log=!echo pwned default
160 *** runcommand log -b --config=alias.log=!echo pwned default
161 abort: unknown revision '--config=alias.log=!echo pwned'
161 abort: unknown revision '--config=alias.log=!echo pwned'
162 [255]
162 [255]
163
163
164 check that "histedit --commands=-" can read rules from the input channel:
164 check that "histedit --commands=-" can read rules from the input channel:
165
165
166 >>> from hgclient import check, readchannel, runcommand, stringio
166 >>> from hgclient import check, readchannel, runcommand, stringio
167 >>> @check
167 >>> @check
168 ... def serverinput(server):
168 ... def serverinput(server):
169 ... readchannel(server)
169 ... readchannel(server)
170 ... rules = b'pick eff892de26ec\n'
170 ... rules = b'pick eff892de26ec\n'
171 ... runcommand(server, [b'histedit', b'0', b'--commands=-',
171 ... runcommand(server, [b'histedit', b'0', b'--commands=-',
172 ... b'--config', b'extensions.histedit='],
172 ... b'--config', b'extensions.histedit='],
173 ... input=stringio(rules))
173 ... input=stringio(rules))
174 *** runcommand histedit 0 --commands=- --config extensions.histedit=
174 *** runcommand histedit 0 --commands=- --config extensions.histedit=
175
175
176 check that --cwd doesn't persist between requests:
176 check that --cwd doesn't persist between requests:
177
177
178 $ mkdir foo
178 $ mkdir foo
179 $ touch foo/bar
179 $ touch foo/bar
180 >>> from hgclient import check, readchannel, runcommand
180 >>> from hgclient import check, readchannel, runcommand
181 >>> @check
181 >>> @check
182 ... def cwd(server):
182 ... def cwd(server):
183 ... readchannel(server)
183 ... readchannel(server)
184 ... runcommand(server, [b'--cwd', b'foo', b'st', b'bar'])
184 ... runcommand(server, [b'--cwd', b'foo', b'st', b'bar'])
185 ... runcommand(server, [b'st', b'foo/bar'])
185 ... runcommand(server, [b'st', b'foo/bar'])
186 *** runcommand --cwd foo st bar
186 *** runcommand --cwd foo st bar
187 ? bar
187 ? bar
188 *** runcommand st foo/bar
188 *** runcommand st foo/bar
189 ? foo/bar
189 ? foo/bar
190
190
191 $ rm foo/bar
191 $ rm foo/bar
192
192
193
193
194 check that local configs for the cached repo aren't inherited when -R is used:
194 check that local configs for the cached repo aren't inherited when -R is used:
195
195
196 $ cat <<EOF >> .hg/hgrc
196 $ cat <<EOF >> .hg/hgrc
197 > [ui]
197 > [ui]
198 > foo = bar
198 > foo = bar
199 > EOF
199 > EOF
200
200
201 #if no-extraextensions
201 #if no-extraextensions
202
202
203 >>> from hgclient import check, readchannel, runcommand, sep
203 >>> from hgclient import check, readchannel, runcommand, sep
204 >>> @check
204 >>> @check
205 ... def localhgrc(server):
205 ... def localhgrc(server):
206 ... readchannel(server)
206 ... readchannel(server)
207 ...
207 ...
208 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
208 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
209 ... # show it
209 ... # show it
210 ... runcommand(server, [b'showconfig'], outfilter=sep)
210 ... runcommand(server, [b'showconfig'], outfilter=sep)
211 ...
211 ...
212 ... # but not for this repo
212 ... # but not for this repo
213 ... runcommand(server, [b'init', b'foo'])
213 ... runcommand(server, [b'init', b'foo'])
214 ... runcommand(server, [b'-R', b'foo', b'showconfig', b'ui', b'defaults'])
214 ... runcommand(server, [b'-R', b'foo', b'showconfig', b'ui', b'defaults'])
215 *** runcommand showconfig
215 *** runcommand showconfig
216 bundle.mainreporoot=$TESTTMP/repo
216 bundle.mainreporoot=$TESTTMP/repo
217 chgserver.idletimeout=60
217 chgserver.idletimeout=60
218 devel.all-warnings=true
218 devel.all-warnings=true
219 devel.default-date=0 0
219 devel.default-date=0 0
220 extensions.fsmonitor= (fsmonitor !)
220 extensions.fsmonitor= (fsmonitor !)
221 format.exp-rc-dirstate-v2=1 (dirstate-v2 !)
221 format.use-dirstate-v2=1 (dirstate-v2 !)
222 largefiles.usercache=$TESTTMP/.cache/largefiles
222 largefiles.usercache=$TESTTMP/.cache/largefiles
223 lfs.usercache=$TESTTMP/.cache/lfs
223 lfs.usercache=$TESTTMP/.cache/lfs
224 ui.slash=True
224 ui.slash=True
225 ui.interactive=False
225 ui.interactive=False
226 ui.detailed-exit-code=True
226 ui.detailed-exit-code=True
227 ui.merge=internal:merge
227 ui.merge=internal:merge
228 ui.mergemarkers=detailed
228 ui.mergemarkers=detailed
229 ui.ssh=* (glob)
229 ui.ssh=* (glob)
230 ui.timeout.warn=15
230 ui.timeout.warn=15
231 ui.foo=bar
231 ui.foo=bar
232 ui.nontty=true
232 ui.nontty=true
233 web.address=localhost
233 web.address=localhost
234 web\.ipv6=(?:True|False) (re)
234 web\.ipv6=(?:True|False) (re)
235 web.server-header=testing stub value
235 web.server-header=testing stub value
236 *** runcommand init foo
236 *** runcommand init foo
237 *** runcommand -R foo showconfig ui defaults
237 *** runcommand -R foo showconfig ui defaults
238 ui.slash=True
238 ui.slash=True
239 ui.interactive=False
239 ui.interactive=False
240 ui.detailed-exit-code=True
240 ui.detailed-exit-code=True
241 ui.merge=internal:merge
241 ui.merge=internal:merge
242 ui.mergemarkers=detailed
242 ui.mergemarkers=detailed
243 ui.ssh=* (glob)
243 ui.ssh=* (glob)
244 ui.timeout.warn=15
244 ui.timeout.warn=15
245 ui.nontty=true
245 ui.nontty=true
246 #endif
246 #endif
247
247
248 $ rm -R foo
248 $ rm -R foo
249
249
250 #if windows
250 #if windows
251 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
251 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
252 #else
252 #else
253 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
253 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
254 #endif
254 #endif
255
255
256 $ cat <<EOF > hook.py
256 $ cat <<EOF > hook.py
257 > import sys
257 > import sys
258 > from hgclient import bprint
258 > from hgclient import bprint
259 > def hook(**args):
259 > def hook(**args):
260 > bprint(b'hook talking')
260 > bprint(b'hook talking')
261 > bprint(b'now try to read something: %r' % sys.stdin.read())
261 > bprint(b'now try to read something: %r' % sys.stdin.read())
262 > EOF
262 > EOF
263
263
264 >>> from hgclient import check, readchannel, runcommand, stringio
264 >>> from hgclient import check, readchannel, runcommand, stringio
265 >>> @check
265 >>> @check
266 ... def hookoutput(server):
266 ... def hookoutput(server):
267 ... readchannel(server)
267 ... readchannel(server)
268 ... runcommand(server, [b'--config',
268 ... runcommand(server, [b'--config',
269 ... b'hooks.pre-identify=python:hook.hook',
269 ... b'hooks.pre-identify=python:hook.hook',
270 ... b'id'],
270 ... b'id'],
271 ... input=stringio(b'some input'))
271 ... input=stringio(b'some input'))
272 *** runcommand --config hooks.pre-identify=python:hook.hook id
272 *** runcommand --config hooks.pre-identify=python:hook.hook id
273 eff892de26ec tip
273 eff892de26ec tip
274 hook talking
274 hook talking
275 now try to read something: ''
275 now try to read something: ''
276
276
277 Clean hook cached version
277 Clean hook cached version
278 $ rm hook.py*
278 $ rm hook.py*
279 $ rm -Rf __pycache__
279 $ rm -Rf __pycache__
280
280
281 $ echo a >> a
281 $ echo a >> a
282 >>> import os
282 >>> import os
283 >>> from hgclient import check, readchannel, runcommand
283 >>> from hgclient import check, readchannel, runcommand
284 >>> @check
284 >>> @check
285 ... def outsidechanges(server):
285 ... def outsidechanges(server):
286 ... readchannel(server)
286 ... readchannel(server)
287 ... runcommand(server, [b'status'])
287 ... runcommand(server, [b'status'])
288 ... os.system('hg ci -Am2')
288 ... os.system('hg ci -Am2')
289 ... runcommand(server, [b'tip'])
289 ... runcommand(server, [b'tip'])
290 ... runcommand(server, [b'status'])
290 ... runcommand(server, [b'status'])
291 *** runcommand status
291 *** runcommand status
292 M a
292 M a
293 *** runcommand tip
293 *** runcommand tip
294 changeset: 1:d3a0a68be6de
294 changeset: 1:d3a0a68be6de
295 tag: tip
295 tag: tip
296 user: test
296 user: test
297 date: Thu Jan 01 00:00:00 1970 +0000
297 date: Thu Jan 01 00:00:00 1970 +0000
298 summary: 2
298 summary: 2
299
299
300 *** runcommand status
300 *** runcommand status
301
301
302 >>> import os
302 >>> import os
303 >>> from hgclient import bprint, check, readchannel, runcommand
303 >>> from hgclient import bprint, check, readchannel, runcommand
304 >>> @check
304 >>> @check
305 ... def bookmarks(server):
305 ... def bookmarks(server):
306 ... readchannel(server)
306 ... readchannel(server)
307 ... runcommand(server, [b'bookmarks'])
307 ... runcommand(server, [b'bookmarks'])
308 ...
308 ...
309 ... # changes .hg/bookmarks
309 ... # changes .hg/bookmarks
310 ... os.system('hg bookmark -i bm1')
310 ... os.system('hg bookmark -i bm1')
311 ... os.system('hg bookmark -i bm2')
311 ... os.system('hg bookmark -i bm2')
312 ... runcommand(server, [b'bookmarks'])
312 ... runcommand(server, [b'bookmarks'])
313 ...
313 ...
314 ... # changes .hg/bookmarks.current
314 ... # changes .hg/bookmarks.current
315 ... os.system('hg upd bm1 -q')
315 ... os.system('hg upd bm1 -q')
316 ... runcommand(server, [b'bookmarks'])
316 ... runcommand(server, [b'bookmarks'])
317 ...
317 ...
318 ... runcommand(server, [b'bookmarks', b'bm3'])
318 ... runcommand(server, [b'bookmarks', b'bm3'])
319 ... f = open('a', 'ab')
319 ... f = open('a', 'ab')
320 ... f.write(b'a\n') and None
320 ... f.write(b'a\n') and None
321 ... f.close()
321 ... f.close()
322 ... runcommand(server, [b'commit', b'-Amm'])
322 ... runcommand(server, [b'commit', b'-Amm'])
323 ... runcommand(server, [b'bookmarks'])
323 ... runcommand(server, [b'bookmarks'])
324 ... bprint(b'')
324 ... bprint(b'')
325 *** runcommand bookmarks
325 *** runcommand bookmarks
326 no bookmarks set
326 no bookmarks set
327 *** runcommand bookmarks
327 *** runcommand bookmarks
328 bm1 1:d3a0a68be6de
328 bm1 1:d3a0a68be6de
329 bm2 1:d3a0a68be6de
329 bm2 1:d3a0a68be6de
330 *** runcommand bookmarks
330 *** runcommand bookmarks
331 * bm1 1:d3a0a68be6de
331 * bm1 1:d3a0a68be6de
332 bm2 1:d3a0a68be6de
332 bm2 1:d3a0a68be6de
333 *** runcommand bookmarks bm3
333 *** runcommand bookmarks bm3
334 *** runcommand commit -Amm
334 *** runcommand commit -Amm
335 *** runcommand bookmarks
335 *** runcommand bookmarks
336 bm1 1:d3a0a68be6de
336 bm1 1:d3a0a68be6de
337 bm2 1:d3a0a68be6de
337 bm2 1:d3a0a68be6de
338 * bm3 2:aef17e88f5f0
338 * bm3 2:aef17e88f5f0
339
339
340
340
341 >>> import os
341 >>> import os
342 >>> from hgclient import check, readchannel, runcommand
342 >>> from hgclient import check, readchannel, runcommand
343 >>> @check
343 >>> @check
344 ... def tagscache(server):
344 ... def tagscache(server):
345 ... readchannel(server)
345 ... readchannel(server)
346 ... runcommand(server, [b'id', b'-t', b'-r', b'0'])
346 ... runcommand(server, [b'id', b'-t', b'-r', b'0'])
347 ... os.system('hg tag -r 0 foo')
347 ... os.system('hg tag -r 0 foo')
348 ... runcommand(server, [b'id', b'-t', b'-r', b'0'])
348 ... runcommand(server, [b'id', b'-t', b'-r', b'0'])
349 *** runcommand id -t -r 0
349 *** runcommand id -t -r 0
350
350
351 *** runcommand id -t -r 0
351 *** runcommand id -t -r 0
352 foo
352 foo
353
353
354 >>> import os
354 >>> import os
355 >>> from hgclient import check, readchannel, runcommand
355 >>> from hgclient import check, readchannel, runcommand
356 >>> @check
356 >>> @check
357 ... def setphase(server):
357 ... def setphase(server):
358 ... readchannel(server)
358 ... readchannel(server)
359 ... runcommand(server, [b'phase', b'-r', b'.'])
359 ... runcommand(server, [b'phase', b'-r', b'.'])
360 ... os.system('hg phase -r . -p')
360 ... os.system('hg phase -r . -p')
361 ... runcommand(server, [b'phase', b'-r', b'.'])
361 ... runcommand(server, [b'phase', b'-r', b'.'])
362 *** runcommand phase -r .
362 *** runcommand phase -r .
363 3: draft
363 3: draft
364 *** runcommand phase -r .
364 *** runcommand phase -r .
365 3: public
365 3: public
366
366
367 $ echo a >> a
367 $ echo a >> a
368 >>> from hgclient import bprint, check, readchannel, runcommand
368 >>> from hgclient import bprint, check, readchannel, runcommand
369 >>> @check
369 >>> @check
370 ... def rollback(server):
370 ... def rollback(server):
371 ... readchannel(server)
371 ... readchannel(server)
372 ... runcommand(server, [b'phase', b'-r', b'.', b'-p'])
372 ... runcommand(server, [b'phase', b'-r', b'.', b'-p'])
373 ... runcommand(server, [b'commit', b'-Am.'])
373 ... runcommand(server, [b'commit', b'-Am.'])
374 ... runcommand(server, [b'rollback'])
374 ... runcommand(server, [b'rollback'])
375 ... runcommand(server, [b'phase', b'-r', b'.'])
375 ... runcommand(server, [b'phase', b'-r', b'.'])
376 ... bprint(b'')
376 ... bprint(b'')
377 *** runcommand phase -r . -p
377 *** runcommand phase -r . -p
378 no phases changed
378 no phases changed
379 *** runcommand commit -Am.
379 *** runcommand commit -Am.
380 *** runcommand rollback
380 *** runcommand rollback
381 repository tip rolled back to revision 3 (undo commit)
381 repository tip rolled back to revision 3 (undo commit)
382 working directory now based on revision 3
382 working directory now based on revision 3
383 *** runcommand phase -r .
383 *** runcommand phase -r .
384 3: public
384 3: public
385
385
386
386
387 >>> import os
387 >>> import os
388 >>> from hgclient import check, readchannel, runcommand
388 >>> from hgclient import check, readchannel, runcommand
389 >>> @check
389 >>> @check
390 ... def branch(server):
390 ... def branch(server):
391 ... readchannel(server)
391 ... readchannel(server)
392 ... runcommand(server, [b'branch'])
392 ... runcommand(server, [b'branch'])
393 ... os.system('hg branch foo')
393 ... os.system('hg branch foo')
394 ... runcommand(server, [b'branch'])
394 ... runcommand(server, [b'branch'])
395 ... os.system('hg branch default')
395 ... os.system('hg branch default')
396 *** runcommand branch
396 *** runcommand branch
397 default
397 default
398 marked working directory as branch foo
398 marked working directory as branch foo
399 (branches are permanent and global, did you want a bookmark?)
399 (branches are permanent and global, did you want a bookmark?)
400 *** runcommand branch
400 *** runcommand branch
401 foo
401 foo
402 marked working directory as branch default
402 marked working directory as branch default
403 (branches are permanent and global, did you want a bookmark?)
403 (branches are permanent and global, did you want a bookmark?)
404
404
405 $ touch .hgignore
405 $ touch .hgignore
406 >>> import os
406 >>> import os
407 >>> from hgclient import bprint, check, readchannel, runcommand
407 >>> from hgclient import bprint, check, readchannel, runcommand
408 >>> @check
408 >>> @check
409 ... def hgignore(server):
409 ... def hgignore(server):
410 ... readchannel(server)
410 ... readchannel(server)
411 ... runcommand(server, [b'commit', b'-Am.'])
411 ... runcommand(server, [b'commit', b'-Am.'])
412 ... f = open('ignored-file', 'ab')
412 ... f = open('ignored-file', 'ab')
413 ... f.write(b'') and None
413 ... f.write(b'') and None
414 ... f.close()
414 ... f.close()
415 ... f = open('.hgignore', 'ab')
415 ... f = open('.hgignore', 'ab')
416 ... f.write(b'ignored-file')
416 ... f.write(b'ignored-file')
417 ... f.close()
417 ... f.close()
418 ... runcommand(server, [b'status', b'-i', b'-u'])
418 ... runcommand(server, [b'status', b'-i', b'-u'])
419 ... bprint(b'')
419 ... bprint(b'')
420 *** runcommand commit -Am.
420 *** runcommand commit -Am.
421 adding .hgignore
421 adding .hgignore
422 *** runcommand status -i -u
422 *** runcommand status -i -u
423 I ignored-file
423 I ignored-file
424
424
425
425
426 cache of non-public revisions should be invalidated on repository change
426 cache of non-public revisions should be invalidated on repository change
427 (issue4855):
427 (issue4855):
428
428
429 >>> import os
429 >>> import os
430 >>> from hgclient import bprint, check, readchannel, runcommand
430 >>> from hgclient import bprint, check, readchannel, runcommand
431 >>> @check
431 >>> @check
432 ... def phasesetscacheaftercommit(server):
432 ... def phasesetscacheaftercommit(server):
433 ... readchannel(server)
433 ... readchannel(server)
434 ... # load _phasecache._phaserevs and _phasesets
434 ... # load _phasecache._phaserevs and _phasesets
435 ... runcommand(server, [b'log', b'-qr', b'draft()'])
435 ... runcommand(server, [b'log', b'-qr', b'draft()'])
436 ... # create draft commits by another process
436 ... # create draft commits by another process
437 ... for i in range(5, 7):
437 ... for i in range(5, 7):
438 ... f = open('a', 'ab')
438 ... f = open('a', 'ab')
439 ... f.seek(0, os.SEEK_END)
439 ... f.seek(0, os.SEEK_END)
440 ... f.write(b'a\n') and None
440 ... f.write(b'a\n') and None
441 ... f.close()
441 ... f.close()
442 ... os.system('hg commit -Aqm%d' % i)
442 ... os.system('hg commit -Aqm%d' % i)
443 ... # new commits should be listed as draft revisions
443 ... # new commits should be listed as draft revisions
444 ... runcommand(server, [b'log', b'-qr', b'draft()'])
444 ... runcommand(server, [b'log', b'-qr', b'draft()'])
445 ... bprint(b'')
445 ... bprint(b'')
446 *** runcommand log -qr draft()
446 *** runcommand log -qr draft()
447 4:7966c8e3734d
447 4:7966c8e3734d
448 *** runcommand log -qr draft()
448 *** runcommand log -qr draft()
449 4:7966c8e3734d
449 4:7966c8e3734d
450 5:41f6602d1c4f
450 5:41f6602d1c4f
451 6:10501e202c35
451 6:10501e202c35
452
452
453
453
454 >>> import os
454 >>> import os
455 >>> from hgclient import bprint, check, readchannel, runcommand
455 >>> from hgclient import bprint, check, readchannel, runcommand
456 >>> @check
456 >>> @check
457 ... def phasesetscacheafterstrip(server):
457 ... def phasesetscacheafterstrip(server):
458 ... readchannel(server)
458 ... readchannel(server)
459 ... # load _phasecache._phaserevs and _phasesets
459 ... # load _phasecache._phaserevs and _phasesets
460 ... runcommand(server, [b'log', b'-qr', b'draft()'])
460 ... runcommand(server, [b'log', b'-qr', b'draft()'])
461 ... # strip cached revisions by another process
461 ... # strip cached revisions by another process
462 ... os.system('hg --config extensions.strip= strip -q 5')
462 ... os.system('hg --config extensions.strip= strip -q 5')
463 ... # shouldn't abort by "unknown revision '6'"
463 ... # shouldn't abort by "unknown revision '6'"
464 ... runcommand(server, [b'log', b'-qr', b'draft()'])
464 ... runcommand(server, [b'log', b'-qr', b'draft()'])
465 ... bprint(b'')
465 ... bprint(b'')
466 *** runcommand log -qr draft()
466 *** runcommand log -qr draft()
467 4:7966c8e3734d
467 4:7966c8e3734d
468 5:41f6602d1c4f
468 5:41f6602d1c4f
469 6:10501e202c35
469 6:10501e202c35
470 *** runcommand log -qr draft()
470 *** runcommand log -qr draft()
471 4:7966c8e3734d
471 4:7966c8e3734d
472
472
473
473
474 cache of phase roots should be invalidated on strip (issue3827):
474 cache of phase roots should be invalidated on strip (issue3827):
475
475
476 >>> import os
476 >>> import os
477 >>> from hgclient import check, readchannel, runcommand, sep
477 >>> from hgclient import check, readchannel, runcommand, sep
478 >>> @check
478 >>> @check
479 ... def phasecacheafterstrip(server):
479 ... def phasecacheafterstrip(server):
480 ... readchannel(server)
480 ... readchannel(server)
481 ...
481 ...
482 ... # create new head, 5:731265503d86
482 ... # create new head, 5:731265503d86
483 ... runcommand(server, [b'update', b'-C', b'0'])
483 ... runcommand(server, [b'update', b'-C', b'0'])
484 ... f = open('a', 'ab')
484 ... f = open('a', 'ab')
485 ... f.write(b'a\n') and None
485 ... f.write(b'a\n') and None
486 ... f.close()
486 ... f.close()
487 ... runcommand(server, [b'commit', b'-Am.', b'a'])
487 ... runcommand(server, [b'commit', b'-Am.', b'a'])
488 ... runcommand(server, [b'log', b'-Gq'])
488 ... runcommand(server, [b'log', b'-Gq'])
489 ...
489 ...
490 ... # make it public; draft marker moves to 4:7966c8e3734d
490 ... # make it public; draft marker moves to 4:7966c8e3734d
491 ... runcommand(server, [b'phase', b'-p', b'.'])
491 ... runcommand(server, [b'phase', b'-p', b'.'])
492 ... # load _phasecache.phaseroots
492 ... # load _phasecache.phaseroots
493 ... runcommand(server, [b'phase', b'.'], outfilter=sep)
493 ... runcommand(server, [b'phase', b'.'], outfilter=sep)
494 ...
494 ...
495 ... # strip 1::4 outside server
495 ... # strip 1::4 outside server
496 ... os.system('hg -q --config extensions.mq= strip 1')
496 ... os.system('hg -q --config extensions.mq= strip 1')
497 ...
497 ...
498 ... # shouldn't raise "7966c8e3734d: no node!"
498 ... # shouldn't raise "7966c8e3734d: no node!"
499 ... runcommand(server, [b'branches'])
499 ... runcommand(server, [b'branches'])
500 *** runcommand update -C 0
500 *** runcommand update -C 0
501 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
501 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
502 (leaving bookmark bm3)
502 (leaving bookmark bm3)
503 *** runcommand commit -Am. a
503 *** runcommand commit -Am. a
504 created new head
504 created new head
505 *** runcommand log -Gq
505 *** runcommand log -Gq
506 @ 5:731265503d86
506 @ 5:731265503d86
507 |
507 |
508 | o 4:7966c8e3734d
508 | o 4:7966c8e3734d
509 | |
509 | |
510 | o 3:b9b85890c400
510 | o 3:b9b85890c400
511 | |
511 | |
512 | o 2:aef17e88f5f0
512 | o 2:aef17e88f5f0
513 | |
513 | |
514 | o 1:d3a0a68be6de
514 | o 1:d3a0a68be6de
515 |/
515 |/
516 o 0:eff892de26ec
516 o 0:eff892de26ec
517
517
518 *** runcommand phase -p .
518 *** runcommand phase -p .
519 *** runcommand phase .
519 *** runcommand phase .
520 5: public
520 5: public
521 *** runcommand branches
521 *** runcommand branches
522 default 1:731265503d86
522 default 1:731265503d86
523
523
524 in-memory cache must be reloaded if transaction is aborted. otherwise
524 in-memory cache must be reloaded if transaction is aborted. otherwise
525 changelog and manifest would have invalid node:
525 changelog and manifest would have invalid node:
526
526
527 $ echo a >> a
527 $ echo a >> a
528 >>> from hgclient import check, readchannel, runcommand
528 >>> from hgclient import check, readchannel, runcommand
529 >>> @check
529 >>> @check
530 ... def txabort(server):
530 ... def txabort(server):
531 ... readchannel(server)
531 ... readchannel(server)
532 ... runcommand(server, [b'commit', b'--config', b'hooks.pretxncommit=false',
532 ... runcommand(server, [b'commit', b'--config', b'hooks.pretxncommit=false',
533 ... b'-mfoo'])
533 ... b'-mfoo'])
534 ... runcommand(server, [b'verify'])
534 ... runcommand(server, [b'verify'])
535 *** runcommand commit --config hooks.pretxncommit=false -mfoo
535 *** runcommand commit --config hooks.pretxncommit=false -mfoo
536 transaction abort!
536 transaction abort!
537 rollback completed
537 rollback completed
538 abort: pretxncommit hook exited with status 1
538 abort: pretxncommit hook exited with status 1
539 [40]
539 [40]
540 *** runcommand verify
540 *** runcommand verify
541 checking changesets
541 checking changesets
542 checking manifests
542 checking manifests
543 crosschecking files in changesets and manifests
543 crosschecking files in changesets and manifests
544 checking files
544 checking files
545 checked 2 changesets with 2 changes to 1 files
545 checked 2 changesets with 2 changes to 1 files
546 $ hg revert --no-backup -aq
546 $ hg revert --no-backup -aq
547
547
548 $ cat >> .hg/hgrc << EOF
548 $ cat >> .hg/hgrc << EOF
549 > [experimental]
549 > [experimental]
550 > evolution.createmarkers=True
550 > evolution.createmarkers=True
551 > EOF
551 > EOF
552
552
553 >>> import os
553 >>> import os
554 >>> from hgclient import check, readchannel, runcommand
554 >>> from hgclient import check, readchannel, runcommand
555 >>> @check
555 >>> @check
556 ... def obsolete(server):
556 ... def obsolete(server):
557 ... readchannel(server)
557 ... readchannel(server)
558 ...
558 ...
559 ... runcommand(server, [b'up', b'null'])
559 ... runcommand(server, [b'up', b'null'])
560 ... runcommand(server, [b'phase', b'-df', b'tip'])
560 ... runcommand(server, [b'phase', b'-df', b'tip'])
561 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
561 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
562 ... if os.name == 'nt':
562 ... if os.name == 'nt':
563 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
563 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
564 ... os.system(cmd)
564 ... os.system(cmd)
565 ... runcommand(server, [b'log', b'--hidden'])
565 ... runcommand(server, [b'log', b'--hidden'])
566 ... runcommand(server, [b'log'])
566 ... runcommand(server, [b'log'])
567 *** runcommand up null
567 *** runcommand up null
568 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
568 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
569 *** runcommand phase -df tip
569 *** runcommand phase -df tip
570 1 new obsolescence markers
570 1 new obsolescence markers
571 obsoleted 1 changesets
571 obsoleted 1 changesets
572 *** runcommand log --hidden
572 *** runcommand log --hidden
573 changeset: 1:731265503d86
573 changeset: 1:731265503d86
574 tag: tip
574 tag: tip
575 user: test
575 user: test
576 date: Thu Jan 01 00:00:00 1970 +0000
576 date: Thu Jan 01 00:00:00 1970 +0000
577 obsolete: pruned
577 obsolete: pruned
578 summary: .
578 summary: .
579
579
580 changeset: 0:eff892de26ec
580 changeset: 0:eff892de26ec
581 bookmark: bm1
581 bookmark: bm1
582 bookmark: bm2
582 bookmark: bm2
583 bookmark: bm3
583 bookmark: bm3
584 user: test
584 user: test
585 date: Thu Jan 01 00:00:00 1970 +0000
585 date: Thu Jan 01 00:00:00 1970 +0000
586 summary: 1
586 summary: 1
587
587
588 *** runcommand log
588 *** runcommand log
589 changeset: 0:eff892de26ec
589 changeset: 0:eff892de26ec
590 bookmark: bm1
590 bookmark: bm1
591 bookmark: bm2
591 bookmark: bm2
592 bookmark: bm3
592 bookmark: bm3
593 tag: tip
593 tag: tip
594 user: test
594 user: test
595 date: Thu Jan 01 00:00:00 1970 +0000
595 date: Thu Jan 01 00:00:00 1970 +0000
596 summary: 1
596 summary: 1
597
597
598
598
599 $ cat <<EOF >> .hg/hgrc
599 $ cat <<EOF >> .hg/hgrc
600 > [extensions]
600 > [extensions]
601 > mq =
601 > mq =
602 > EOF
602 > EOF
603
603
604 >>> import os
604 >>> import os
605 >>> from hgclient import check, readchannel, runcommand
605 >>> from hgclient import check, readchannel, runcommand
606 >>> @check
606 >>> @check
607 ... def mqoutsidechanges(server):
607 ... def mqoutsidechanges(server):
608 ... readchannel(server)
608 ... readchannel(server)
609 ...
609 ...
610 ... # load repo.mq
610 ... # load repo.mq
611 ... runcommand(server, [b'qapplied'])
611 ... runcommand(server, [b'qapplied'])
612 ... os.system('hg qnew 0.diff')
612 ... os.system('hg qnew 0.diff')
613 ... # repo.mq should be invalidated
613 ... # repo.mq should be invalidated
614 ... runcommand(server, [b'qapplied'])
614 ... runcommand(server, [b'qapplied'])
615 ...
615 ...
616 ... runcommand(server, [b'qpop', b'--all'])
616 ... runcommand(server, [b'qpop', b'--all'])
617 ... os.system('hg qqueue --create foo')
617 ... os.system('hg qqueue --create foo')
618 ... # repo.mq should be recreated to point to new queue
618 ... # repo.mq should be recreated to point to new queue
619 ... runcommand(server, [b'qqueue', b'--active'])
619 ... runcommand(server, [b'qqueue', b'--active'])
620 *** runcommand qapplied
620 *** runcommand qapplied
621 *** runcommand qapplied
621 *** runcommand qapplied
622 0.diff
622 0.diff
623 *** runcommand qpop --all
623 *** runcommand qpop --all
624 popping 0.diff
624 popping 0.diff
625 patch queue now empty
625 patch queue now empty
626 *** runcommand qqueue --active
626 *** runcommand qqueue --active
627 foo
627 foo
628
628
629 $ cat <<'EOF' > ../dbgui.py
629 $ cat <<'EOF' > ../dbgui.py
630 > import os
630 > import os
631 > import sys
631 > import sys
632 > from mercurial import commands, registrar
632 > from mercurial import commands, registrar
633 > cmdtable = {}
633 > cmdtable = {}
634 > command = registrar.command(cmdtable)
634 > command = registrar.command(cmdtable)
635 > @command(b"debuggetpass", norepo=True)
635 > @command(b"debuggetpass", norepo=True)
636 > def debuggetpass(ui):
636 > def debuggetpass(ui):
637 > ui.write(b"%s\n" % ui.getpass())
637 > ui.write(b"%s\n" % ui.getpass())
638 > @command(b"debugprompt", norepo=True)
638 > @command(b"debugprompt", norepo=True)
639 > def debugprompt(ui):
639 > def debugprompt(ui):
640 > ui.write(b"%s\n" % ui.prompt(b"prompt:"))
640 > ui.write(b"%s\n" % ui.prompt(b"prompt:"))
641 > @command(b"debugpromptchoice", norepo=True)
641 > @command(b"debugpromptchoice", norepo=True)
642 > def debugpromptchoice(ui):
642 > def debugpromptchoice(ui):
643 > msg = b"promptchoice (y/n)? $$ &Yes $$ &No"
643 > msg = b"promptchoice (y/n)? $$ &Yes $$ &No"
644 > ui.write(b"%d\n" % ui.promptchoice(msg))
644 > ui.write(b"%d\n" % ui.promptchoice(msg))
645 > @command(b"debugreadstdin", norepo=True)
645 > @command(b"debugreadstdin", norepo=True)
646 > def debugreadstdin(ui):
646 > def debugreadstdin(ui):
647 > ui.write(b"read: %r\n" % sys.stdin.read(1))
647 > ui.write(b"read: %r\n" % sys.stdin.read(1))
648 > @command(b"debugwritestdout", norepo=True)
648 > @command(b"debugwritestdout", norepo=True)
649 > def debugwritestdout(ui):
649 > def debugwritestdout(ui):
650 > os.write(1, b"low-level stdout fd and\n")
650 > os.write(1, b"low-level stdout fd and\n")
651 > sys.stdout.write("stdout should be redirected to stderr\n")
651 > sys.stdout.write("stdout should be redirected to stderr\n")
652 > sys.stdout.flush()
652 > sys.stdout.flush()
653 > EOF
653 > EOF
654 $ cat <<EOF >> .hg/hgrc
654 $ cat <<EOF >> .hg/hgrc
655 > [extensions]
655 > [extensions]
656 > dbgui = ../dbgui.py
656 > dbgui = ../dbgui.py
657 > EOF
657 > EOF
658
658
659 >>> from hgclient import check, readchannel, runcommand, stringio
659 >>> from hgclient import check, readchannel, runcommand, stringio
660 >>> @check
660 >>> @check
661 ... def getpass(server):
661 ... def getpass(server):
662 ... readchannel(server)
662 ... readchannel(server)
663 ... runcommand(server, [b'debuggetpass', b'--config',
663 ... runcommand(server, [b'debuggetpass', b'--config',
664 ... b'ui.interactive=True'],
664 ... b'ui.interactive=True'],
665 ... input=stringio(b'1234\n'))
665 ... input=stringio(b'1234\n'))
666 ... runcommand(server, [b'debuggetpass', b'--config',
666 ... runcommand(server, [b'debuggetpass', b'--config',
667 ... b'ui.interactive=True'],
667 ... b'ui.interactive=True'],
668 ... input=stringio(b'\n'))
668 ... input=stringio(b'\n'))
669 ... runcommand(server, [b'debuggetpass', b'--config',
669 ... runcommand(server, [b'debuggetpass', b'--config',
670 ... b'ui.interactive=True'],
670 ... b'ui.interactive=True'],
671 ... input=stringio(b''))
671 ... input=stringio(b''))
672 ... runcommand(server, [b'debugprompt', b'--config',
672 ... runcommand(server, [b'debugprompt', b'--config',
673 ... b'ui.interactive=True'],
673 ... b'ui.interactive=True'],
674 ... input=stringio(b'5678\n'))
674 ... input=stringio(b'5678\n'))
675 ... runcommand(server, [b'debugprompt', b'--config',
675 ... runcommand(server, [b'debugprompt', b'--config',
676 ... b'ui.interactive=True'],
676 ... b'ui.interactive=True'],
677 ... input=stringio(b'\nremainder\nshould\nnot\nbe\nread\n'))
677 ... input=stringio(b'\nremainder\nshould\nnot\nbe\nread\n'))
678 ... runcommand(server, [b'debugreadstdin'])
678 ... runcommand(server, [b'debugreadstdin'])
679 ... runcommand(server, [b'debugwritestdout'])
679 ... runcommand(server, [b'debugwritestdout'])
680 *** runcommand debuggetpass --config ui.interactive=True
680 *** runcommand debuggetpass --config ui.interactive=True
681 password: 1234
681 password: 1234
682 *** runcommand debuggetpass --config ui.interactive=True
682 *** runcommand debuggetpass --config ui.interactive=True
683 password:
683 password:
684 *** runcommand debuggetpass --config ui.interactive=True
684 *** runcommand debuggetpass --config ui.interactive=True
685 password: abort: response expected
685 password: abort: response expected
686 [255]
686 [255]
687 *** runcommand debugprompt --config ui.interactive=True
687 *** runcommand debugprompt --config ui.interactive=True
688 prompt: 5678
688 prompt: 5678
689 *** runcommand debugprompt --config ui.interactive=True
689 *** runcommand debugprompt --config ui.interactive=True
690 prompt: y
690 prompt: y
691 *** runcommand debugreadstdin
691 *** runcommand debugreadstdin
692 read: ''
692 read: ''
693 *** runcommand debugwritestdout
693 *** runcommand debugwritestdout
694 low-level stdout fd and
694 low-level stdout fd and
695 stdout should be redirected to stderr
695 stdout should be redirected to stderr
696
696
697
697
698 run commandserver in commandserver, which is silly but should work:
698 run commandserver in commandserver, which is silly but should work:
699
699
700 >>> from hgclient import bprint, check, readchannel, runcommand, stringio
700 >>> from hgclient import bprint, check, readchannel, runcommand, stringio
701 >>> @check
701 >>> @check
702 ... def nested(server):
702 ... def nested(server):
703 ... bprint(b'%c, %r' % readchannel(server))
703 ... bprint(b'%c, %r' % readchannel(server))
704 ... class nestedserver(object):
704 ... class nestedserver(object):
705 ... stdin = stringio(b'getencoding\n')
705 ... stdin = stringio(b'getencoding\n')
706 ... stdout = stringio()
706 ... stdout = stringio()
707 ... runcommand(server, [b'serve', b'--cmdserver', b'pipe'],
707 ... runcommand(server, [b'serve', b'--cmdserver', b'pipe'],
708 ... output=nestedserver.stdout, input=nestedserver.stdin)
708 ... output=nestedserver.stdout, input=nestedserver.stdin)
709 ... nestedserver.stdout.seek(0)
709 ... nestedserver.stdout.seek(0)
710 ... bprint(b'%c, %r' % readchannel(nestedserver)) # hello
710 ... bprint(b'%c, %r' % readchannel(nestedserver)) # hello
711 ... bprint(b'%c, %r' % readchannel(nestedserver)) # getencoding
711 ... bprint(b'%c, %r' % readchannel(nestedserver)) # getencoding
712 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
712 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
713 *** runcommand serve --cmdserver pipe
713 *** runcommand serve --cmdserver pipe
714 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
714 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
715 r, '*' (glob)
715 r, '*' (glob)
716
716
717
717
718 start without repository:
718 start without repository:
719
719
720 $ cd ..
720 $ cd ..
721
721
722 >>> from hgclient import bprint, check, readchannel, runcommand
722 >>> from hgclient import bprint, check, readchannel, runcommand
723 >>> @check
723 >>> @check
724 ... def hellomessage(server):
724 ... def hellomessage(server):
725 ... ch, data = readchannel(server)
725 ... ch, data = readchannel(server)
726 ... bprint(b'%c, %r' % (ch, data))
726 ... bprint(b'%c, %r' % (ch, data))
727 ... # run an arbitrary command to make sure the next thing the server
727 ... # run an arbitrary command to make sure the next thing the server
728 ... # sends isn't part of the hello message
728 ... # sends isn't part of the hello message
729 ... runcommand(server, [b'id'])
729 ... runcommand(server, [b'id'])
730 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
730 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
731 *** runcommand id
731 *** runcommand id
732 abort: there is no Mercurial repository here (.hg not found)
732 abort: there is no Mercurial repository here (.hg not found)
733 [10]
733 [10]
734
734
735 >>> from hgclient import check, readchannel, runcommand
735 >>> from hgclient import check, readchannel, runcommand
736 >>> @check
736 >>> @check
737 ... def startwithoutrepo(server):
737 ... def startwithoutrepo(server):
738 ... readchannel(server)
738 ... readchannel(server)
739 ... runcommand(server, [b'init', b'repo2'])
739 ... runcommand(server, [b'init', b'repo2'])
740 ... runcommand(server, [b'id', b'-R', b'repo2'])
740 ... runcommand(server, [b'id', b'-R', b'repo2'])
741 *** runcommand init repo2
741 *** runcommand init repo2
742 *** runcommand id -R repo2
742 *** runcommand id -R repo2
743 000000000000 tip
743 000000000000 tip
744
744
745
745
746 don't fall back to cwd if invalid -R path is specified (issue4805):
746 don't fall back to cwd if invalid -R path is specified (issue4805):
747
747
748 $ cd repo
748 $ cd repo
749 $ hg serve --cmdserver pipe -R ../nonexistent
749 $ hg serve --cmdserver pipe -R ../nonexistent
750 abort: repository ../nonexistent not found
750 abort: repository ../nonexistent not found
751 [255]
751 [255]
752 $ cd ..
752 $ cd ..
753
753
754
754
755 #if no-windows
755 #if no-windows
756
756
757 option to not shutdown on SIGINT:
757 option to not shutdown on SIGINT:
758
758
759 $ cat <<'EOF' > dbgint.py
759 $ cat <<'EOF' > dbgint.py
760 > import os
760 > import os
761 > import signal
761 > import signal
762 > import time
762 > import time
763 > from mercurial import commands, registrar
763 > from mercurial import commands, registrar
764 > cmdtable = {}
764 > cmdtable = {}
765 > command = registrar.command(cmdtable)
765 > command = registrar.command(cmdtable)
766 > @command(b"debugsleep", norepo=True)
766 > @command(b"debugsleep", norepo=True)
767 > def debugsleep(ui):
767 > def debugsleep(ui):
768 > time.sleep(1)
768 > time.sleep(1)
769 > @command(b"debugsuicide", norepo=True)
769 > @command(b"debugsuicide", norepo=True)
770 > def debugsuicide(ui):
770 > def debugsuicide(ui):
771 > os.kill(os.getpid(), signal.SIGINT)
771 > os.kill(os.getpid(), signal.SIGINT)
772 > time.sleep(1)
772 > time.sleep(1)
773 > EOF
773 > EOF
774
774
775 >>> import signal
775 >>> import signal
776 >>> import time
776 >>> import time
777 >>> from hgclient import checkwith, readchannel, runcommand
777 >>> from hgclient import checkwith, readchannel, runcommand
778 >>> @checkwith(extraargs=[b'--config', b'cmdserver.shutdown-on-interrupt=False',
778 >>> @checkwith(extraargs=[b'--config', b'cmdserver.shutdown-on-interrupt=False',
779 ... b'--config', b'extensions.dbgint=dbgint.py'])
779 ... b'--config', b'extensions.dbgint=dbgint.py'])
780 ... def nointr(server):
780 ... def nointr(server):
781 ... readchannel(server)
781 ... readchannel(server)
782 ... server.send_signal(signal.SIGINT) # server won't be terminated
782 ... server.send_signal(signal.SIGINT) # server won't be terminated
783 ... time.sleep(1)
783 ... time.sleep(1)
784 ... runcommand(server, [b'debugsleep'])
784 ... runcommand(server, [b'debugsleep'])
785 ... server.send_signal(signal.SIGINT) # server won't be terminated
785 ... server.send_signal(signal.SIGINT) # server won't be terminated
786 ... runcommand(server, [b'debugsleep'])
786 ... runcommand(server, [b'debugsleep'])
787 ... runcommand(server, [b'debugsuicide']) # command can be interrupted
787 ... runcommand(server, [b'debugsuicide']) # command can be interrupted
788 ... server.send_signal(signal.SIGTERM) # server will be terminated
788 ... server.send_signal(signal.SIGTERM) # server will be terminated
789 ... time.sleep(1)
789 ... time.sleep(1)
790 *** runcommand debugsleep
790 *** runcommand debugsleep
791 *** runcommand debugsleep
791 *** runcommand debugsleep
792 *** runcommand debugsuicide
792 *** runcommand debugsuicide
793 interrupted!
793 interrupted!
794 killed!
794 killed!
795 [255]
795 [255]
796
796
797 #endif
797 #endif
798
798
799
799
800 structured message channel:
800 structured message channel:
801
801
802 $ cat <<'EOF' >> repo2/.hg/hgrc
802 $ cat <<'EOF' >> repo2/.hg/hgrc
803 > [ui]
803 > [ui]
804 > # server --config should precede repository option
804 > # server --config should precede repository option
805 > message-output = stdio
805 > message-output = stdio
806 > EOF
806 > EOF
807
807
808 >>> from hgclient import bprint, checkwith, readchannel, runcommand
808 >>> from hgclient import bprint, checkwith, readchannel, runcommand
809 >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel',
809 >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel',
810 ... b'--config', b'cmdserver.message-encodings=foo cbor'])
810 ... b'--config', b'cmdserver.message-encodings=foo cbor'])
811 ... def verify(server):
811 ... def verify(server):
812 ... _ch, data = readchannel(server)
812 ... _ch, data = readchannel(server)
813 ... bprint(data)
813 ... bprint(data)
814 ... runcommand(server, [b'-R', b'repo2', b'verify'])
814 ... runcommand(server, [b'-R', b'repo2', b'verify'])
815 capabilities: getencoding runcommand
815 capabilities: getencoding runcommand
816 encoding: ascii
816 encoding: ascii
817 message-encoding: cbor
817 message-encoding: cbor
818 pid: * (glob)
818 pid: * (glob)
819 pgid: * (glob) (no-windows !)
819 pgid: * (glob) (no-windows !)
820 *** runcommand -R repo2 verify
820 *** runcommand -R repo2 verify
821 message: '\xa2DdataTchecking changesets\nDtypeFstatus'
821 message: '\xa2DdataTchecking changesets\nDtypeFstatus'
822 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
822 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
823 message: '\xa2DdataSchecking manifests\nDtypeFstatus'
823 message: '\xa2DdataSchecking manifests\nDtypeFstatus'
824 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
824 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
825 message: '\xa2DdataX0crosschecking files in changesets and manifests\nDtypeFstatus'
825 message: '\xa2DdataX0crosschecking files in changesets and manifests\nDtypeFstatus'
826 message: '\xa6Ditem@Cpos\xf6EtopicMcrosscheckingEtotal\xf6DtypeHprogressDunit@'
826 message: '\xa6Ditem@Cpos\xf6EtopicMcrosscheckingEtotal\xf6DtypeHprogressDunit@'
827 message: '\xa2DdataOchecking files\nDtypeFstatus'
827 message: '\xa2DdataOchecking files\nDtypeFstatus'
828 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
828 message: '\xa6Ditem@Cpos\xf6EtopicHcheckingEtotal\xf6DtypeHprogressDunit@'
829 message: '\xa2DdataX/checked 0 changesets with 0 changes to 0 files\nDtypeFstatus'
829 message: '\xa2DdataX/checked 0 changesets with 0 changes to 0 files\nDtypeFstatus'
830
830
831 >>> from hgclient import checkwith, readchannel, runcommand, stringio
831 >>> from hgclient import checkwith, readchannel, runcommand, stringio
832 >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel',
832 >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel',
833 ... b'--config', b'cmdserver.message-encodings=cbor',
833 ... b'--config', b'cmdserver.message-encodings=cbor',
834 ... b'--config', b'extensions.dbgui=dbgui.py'])
834 ... b'--config', b'extensions.dbgui=dbgui.py'])
835 ... def prompt(server):
835 ... def prompt(server):
836 ... readchannel(server)
836 ... readchannel(server)
837 ... interactive = [b'--config', b'ui.interactive=True']
837 ... interactive = [b'--config', b'ui.interactive=True']
838 ... runcommand(server, [b'debuggetpass'] + interactive,
838 ... runcommand(server, [b'debuggetpass'] + interactive,
839 ... input=stringio(b'1234\n'))
839 ... input=stringio(b'1234\n'))
840 ... runcommand(server, [b'debugprompt'] + interactive,
840 ... runcommand(server, [b'debugprompt'] + interactive,
841 ... input=stringio(b'5678\n'))
841 ... input=stringio(b'5678\n'))
842 ... runcommand(server, [b'debugpromptchoice'] + interactive,
842 ... runcommand(server, [b'debugpromptchoice'] + interactive,
843 ... input=stringio(b'n\n'))
843 ... input=stringio(b'n\n'))
844 *** runcommand debuggetpass --config ui.interactive=True
844 *** runcommand debuggetpass --config ui.interactive=True
845 message: '\xa3DdataJpassword: Hpassword\xf5DtypeFprompt'
845 message: '\xa3DdataJpassword: Hpassword\xf5DtypeFprompt'
846 1234
846 1234
847 *** runcommand debugprompt --config ui.interactive=True
847 *** runcommand debugprompt --config ui.interactive=True
848 message: '\xa3DdataGprompt:GdefaultAyDtypeFprompt'
848 message: '\xa3DdataGprompt:GdefaultAyDtypeFprompt'
849 5678
849 5678
850 *** runcommand debugpromptchoice --config ui.interactive=True
850 *** runcommand debugpromptchoice --config ui.interactive=True
851 message: '\xa4Gchoices\x82\x82AyCYes\x82AnBNoDdataTpromptchoice (y/n)? GdefaultAyDtypeFprompt'
851 message: '\xa4Gchoices\x82\x82AyCYes\x82AnBNoDdataTpromptchoice (y/n)? GdefaultAyDtypeFprompt'
852 1
852 1
853
853
854 bad message encoding:
854 bad message encoding:
855
855
856 $ hg serve --cmdserver pipe --config ui.message-output=channel
856 $ hg serve --cmdserver pipe --config ui.message-output=channel
857 abort: no supported message encodings:
857 abort: no supported message encodings:
858 [255]
858 [255]
859 $ hg serve --cmdserver pipe --config ui.message-output=channel \
859 $ hg serve --cmdserver pipe --config ui.message-output=channel \
860 > --config cmdserver.message-encodings='foo bar'
860 > --config cmdserver.message-encodings='foo bar'
861 abort: no supported message encodings: foo bar
861 abort: no supported message encodings: foo bar
862 [255]
862 [255]
863
863
864 unix domain socket:
864 unix domain socket:
865
865
866 $ cd repo
866 $ cd repo
867 $ hg update -q
867 $ hg update -q
868
868
869 #if unix-socket unix-permissions
869 #if unix-socket unix-permissions
870
870
871 >>> from hgclient import bprint, check, readchannel, runcommand, stringio, unixserver
871 >>> from hgclient import bprint, check, readchannel, runcommand, stringio, unixserver
872 >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log')
872 >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log')
873 >>> def hellomessage(conn):
873 >>> def hellomessage(conn):
874 ... ch, data = readchannel(conn)
874 ... ch, data = readchannel(conn)
875 ... bprint(b'%c, %r' % (ch, data))
875 ... bprint(b'%c, %r' % (ch, data))
876 ... runcommand(conn, [b'id'])
876 ... runcommand(conn, [b'id'])
877 >>> check(hellomessage, server.connect)
877 >>> check(hellomessage, server.connect)
878 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
878 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
879 *** runcommand id
879 *** runcommand id
880 eff892de26ec tip bm1/bm2/bm3
880 eff892de26ec tip bm1/bm2/bm3
881 >>> def unknowncommand(conn):
881 >>> def unknowncommand(conn):
882 ... readchannel(conn)
882 ... readchannel(conn)
883 ... conn.stdin.write(b'unknowncommand\n')
883 ... conn.stdin.write(b'unknowncommand\n')
884 >>> check(unknowncommand, server.connect) # error sent to server.log
884 >>> check(unknowncommand, server.connect) # error sent to server.log
885 >>> def serverinput(conn):
885 >>> def serverinput(conn):
886 ... readchannel(conn)
886 ... readchannel(conn)
887 ... patch = b"""
887 ... patch = b"""
888 ... # HG changeset patch
888 ... # HG changeset patch
889 ... # User test
889 ... # User test
890 ... # Date 0 0
890 ... # Date 0 0
891 ... 2
891 ... 2
892 ...
892 ...
893 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
893 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
894 ... --- a/a
894 ... --- a/a
895 ... +++ b/a
895 ... +++ b/a
896 ... @@ -1,1 +1,2 @@
896 ... @@ -1,1 +1,2 @@
897 ... 1
897 ... 1
898 ... +2
898 ... +2
899 ... """
899 ... """
900 ... runcommand(conn, [b'import', b'-'], input=stringio(patch))
900 ... runcommand(conn, [b'import', b'-'], input=stringio(patch))
901 ... runcommand(conn, [b'log', b'-rtip', b'-q'])
901 ... runcommand(conn, [b'log', b'-rtip', b'-q'])
902 >>> check(serverinput, server.connect)
902 >>> check(serverinput, server.connect)
903 *** runcommand import -
903 *** runcommand import -
904 applying patch from stdin
904 applying patch from stdin
905 *** runcommand log -rtip -q
905 *** runcommand log -rtip -q
906 2:1ed24be7e7a0
906 2:1ed24be7e7a0
907 >>> server.shutdown()
907 >>> server.shutdown()
908
908
909 $ cat .hg/server.log
909 $ cat .hg/server.log
910 listening at .hg/server.sock
910 listening at .hg/server.sock
911 abort: unknown command unknowncommand
911 abort: unknown command unknowncommand
912 killed!
912 killed!
913 $ rm .hg/server.log
913 $ rm .hg/server.log
914
914
915 if server crashed before hello, traceback will be sent to 'e' channel as
915 if server crashed before hello, traceback will be sent to 'e' channel as
916 last ditch:
916 last ditch:
917
917
918 $ cat <<'EOF' > ../earlycrasher.py
918 $ cat <<'EOF' > ../earlycrasher.py
919 > from mercurial import commandserver, extensions
919 > from mercurial import commandserver, extensions
920 > def _serverequest(orig, ui, repo, conn, createcmdserver, prereposetups):
920 > def _serverequest(orig, ui, repo, conn, createcmdserver, prereposetups):
921 > def createcmdserver(*args, **kwargs):
921 > def createcmdserver(*args, **kwargs):
922 > raise Exception('crash')
922 > raise Exception('crash')
923 > return orig(ui, repo, conn, createcmdserver, prereposetups)
923 > return orig(ui, repo, conn, createcmdserver, prereposetups)
924 > def extsetup(ui):
924 > def extsetup(ui):
925 > extensions.wrapfunction(commandserver, b'_serverequest', _serverequest)
925 > extensions.wrapfunction(commandserver, b'_serverequest', _serverequest)
926 > EOF
926 > EOF
927 $ cat <<EOF >> .hg/hgrc
927 $ cat <<EOF >> .hg/hgrc
928 > [extensions]
928 > [extensions]
929 > earlycrasher = ../earlycrasher.py
929 > earlycrasher = ../earlycrasher.py
930 > EOF
930 > EOF
931 >>> from hgclient import bprint, check, readchannel, unixserver
931 >>> from hgclient import bprint, check, readchannel, unixserver
932 >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log')
932 >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log')
933 >>> def earlycrash(conn):
933 >>> def earlycrash(conn):
934 ... while True:
934 ... while True:
935 ... try:
935 ... try:
936 ... ch, data = readchannel(conn)
936 ... ch, data = readchannel(conn)
937 ... for l in data.splitlines(True):
937 ... for l in data.splitlines(True):
938 ... if not l.startswith(b' '):
938 ... if not l.startswith(b' '):
939 ... bprint(b'%c, %r' % (ch, l))
939 ... bprint(b'%c, %r' % (ch, l))
940 ... except EOFError:
940 ... except EOFError:
941 ... break
941 ... break
942 >>> check(earlycrash, server.connect)
942 >>> check(earlycrash, server.connect)
943 e, 'Traceback (most recent call last):\n'
943 e, 'Traceback (most recent call last):\n'
944 e, 'Exception: crash\n'
944 e, 'Exception: crash\n'
945 >>> server.shutdown()
945 >>> server.shutdown()
946
946
947 $ cat .hg/server.log | grep -v '^ '
947 $ cat .hg/server.log | grep -v '^ '
948 listening at .hg/server.sock
948 listening at .hg/server.sock
949 Traceback (most recent call last):
949 Traceback (most recent call last):
950 Exception: crash
950 Exception: crash
951 killed!
951 killed!
952 #endif
952 #endif
953 #if no-unix-socket
953 #if no-unix-socket
954
954
955 $ hg serve --cmdserver unix -a .hg/server.sock
955 $ hg serve --cmdserver unix -a .hg/server.sock
956 abort: unsupported platform
956 abort: unsupported platform
957 [255]
957 [255]
958
958
959 #endif
959 #endif
960
960
961 $ cd ..
961 $ cd ..
962
962
963 Test that accessing to invalid changelog cache is avoided at
963 Test that accessing to invalid changelog cache is avoided at
964 subsequent operations even if repo object is reused even after failure
964 subsequent operations even if repo object is reused even after failure
965 of transaction (see 0a7610758c42 also)
965 of transaction (see 0a7610758c42 also)
966
966
967 "hg log" after failure of transaction is needed to detect invalid
967 "hg log" after failure of transaction is needed to detect invalid
968 cache in repoview: this can't detect by "hg verify" only.
968 cache in repoview: this can't detect by "hg verify" only.
969
969
970 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
970 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
971 4) are tested, because '00changelog.i' are differently changed in each
971 4) are tested, because '00changelog.i' are differently changed in each
972 cases.
972 cases.
973
973
974 $ cat > $TESTTMP/failafterfinalize.py <<EOF
974 $ cat > $TESTTMP/failafterfinalize.py <<EOF
975 > # extension to abort transaction after finalization forcibly
975 > # extension to abort transaction after finalization forcibly
976 > from mercurial import commands, error, extensions, lock as lockmod
976 > from mercurial import commands, error, extensions, lock as lockmod
977 > from mercurial import registrar
977 > from mercurial import registrar
978 > cmdtable = {}
978 > cmdtable = {}
979 > command = registrar.command(cmdtable)
979 > command = registrar.command(cmdtable)
980 > configtable = {}
980 > configtable = {}
981 > configitem = registrar.configitem(configtable)
981 > configitem = registrar.configitem(configtable)
982 > configitem(b'failafterfinalize', b'fail',
982 > configitem(b'failafterfinalize', b'fail',
983 > default=None,
983 > default=None,
984 > )
984 > )
985 > def fail(tr):
985 > def fail(tr):
986 > raise error.Abort(b'fail after finalization')
986 > raise error.Abort(b'fail after finalization')
987 > def reposetup(ui, repo):
987 > def reposetup(ui, repo):
988 > class failrepo(repo.__class__):
988 > class failrepo(repo.__class__):
989 > def commitctx(self, ctx, error=False, origctx=None):
989 > def commitctx(self, ctx, error=False, origctx=None):
990 > if self.ui.configbool(b'failafterfinalize', b'fail'):
990 > if self.ui.configbool(b'failafterfinalize', b'fail'):
991 > # 'sorted()' by ASCII code on category names causes
991 > # 'sorted()' by ASCII code on category names causes
992 > # invoking 'fail' after finalization of changelog
992 > # invoking 'fail' after finalization of changelog
993 > # using "'cl-%i' % id(self)" as category name
993 > # using "'cl-%i' % id(self)" as category name
994 > self.currenttransaction().addfinalize(b'zzzzzzzz', fail)
994 > self.currenttransaction().addfinalize(b'zzzzzzzz', fail)
995 > return super(failrepo, self).commitctx(ctx, error, origctx)
995 > return super(failrepo, self).commitctx(ctx, error, origctx)
996 > repo.__class__ = failrepo
996 > repo.__class__ = failrepo
997 > EOF
997 > EOF
998
998
999 $ hg init repo3
999 $ hg init repo3
1000 $ cd repo3
1000 $ cd repo3
1001
1001
1002 $ cat <<EOF >> $HGRCPATH
1002 $ cat <<EOF >> $HGRCPATH
1003 > [command-templates]
1003 > [command-templates]
1004 > log = {rev} {desc|firstline} ({files})\n
1004 > log = {rev} {desc|firstline} ({files})\n
1005 >
1005 >
1006 > [extensions]
1006 > [extensions]
1007 > failafterfinalize = $TESTTMP/failafterfinalize.py
1007 > failafterfinalize = $TESTTMP/failafterfinalize.py
1008 > EOF
1008 > EOF
1009
1009
1010 - test failure with "empty changelog"
1010 - test failure with "empty changelog"
1011
1011
1012 $ echo foo > foo
1012 $ echo foo > foo
1013 $ hg add foo
1013 $ hg add foo
1014
1014
1015 (failure before finalization)
1015 (failure before finalization)
1016
1016
1017 >>> from hgclient import check, readchannel, runcommand
1017 >>> from hgclient import check, readchannel, runcommand
1018 >>> @check
1018 >>> @check
1019 ... def abort(server):
1019 ... def abort(server):
1020 ... readchannel(server)
1020 ... readchannel(server)
1021 ... runcommand(server, [b'commit',
1021 ... runcommand(server, [b'commit',
1022 ... b'--config', b'hooks.pretxncommit=false',
1022 ... b'--config', b'hooks.pretxncommit=false',
1023 ... b'-mfoo'])
1023 ... b'-mfoo'])
1024 ... runcommand(server, [b'log'])
1024 ... runcommand(server, [b'log'])
1025 ... runcommand(server, [b'verify', b'-q'])
1025 ... runcommand(server, [b'verify', b'-q'])
1026 *** runcommand commit --config hooks.pretxncommit=false -mfoo
1026 *** runcommand commit --config hooks.pretxncommit=false -mfoo
1027 transaction abort!
1027 transaction abort!
1028 rollback completed
1028 rollback completed
1029 abort: pretxncommit hook exited with status 1
1029 abort: pretxncommit hook exited with status 1
1030 [40]
1030 [40]
1031 *** runcommand log
1031 *** runcommand log
1032 *** runcommand verify -q
1032 *** runcommand verify -q
1033
1033
1034 (failure after finalization)
1034 (failure after finalization)
1035
1035
1036 >>> from hgclient import check, readchannel, runcommand
1036 >>> from hgclient import check, readchannel, runcommand
1037 >>> @check
1037 >>> @check
1038 ... def abort(server):
1038 ... def abort(server):
1039 ... readchannel(server)
1039 ... readchannel(server)
1040 ... runcommand(server, [b'commit',
1040 ... runcommand(server, [b'commit',
1041 ... b'--config', b'failafterfinalize.fail=true',
1041 ... b'--config', b'failafterfinalize.fail=true',
1042 ... b'-mfoo'])
1042 ... b'-mfoo'])
1043 ... runcommand(server, [b'log'])
1043 ... runcommand(server, [b'log'])
1044 ... runcommand(server, [b'verify', b'-q'])
1044 ... runcommand(server, [b'verify', b'-q'])
1045 *** runcommand commit --config failafterfinalize.fail=true -mfoo
1045 *** runcommand commit --config failafterfinalize.fail=true -mfoo
1046 transaction abort!
1046 transaction abort!
1047 rollback completed
1047 rollback completed
1048 abort: fail after finalization
1048 abort: fail after finalization
1049 [255]
1049 [255]
1050 *** runcommand log
1050 *** runcommand log
1051 *** runcommand verify -q
1051 *** runcommand verify -q
1052
1052
1053 - test failure with "not-empty changelog"
1053 - test failure with "not-empty changelog"
1054
1054
1055 $ echo bar > bar
1055 $ echo bar > bar
1056 $ hg add bar
1056 $ hg add bar
1057 $ hg commit -mbar bar
1057 $ hg commit -mbar bar
1058
1058
1059 (failure before finalization)
1059 (failure before finalization)
1060
1060
1061 >>> from hgclient import check, readchannel, runcommand
1061 >>> from hgclient import check, readchannel, runcommand
1062 >>> @check
1062 >>> @check
1063 ... def abort(server):
1063 ... def abort(server):
1064 ... readchannel(server)
1064 ... readchannel(server)
1065 ... runcommand(server, [b'commit',
1065 ... runcommand(server, [b'commit',
1066 ... b'--config', b'hooks.pretxncommit=false',
1066 ... b'--config', b'hooks.pretxncommit=false',
1067 ... b'-mfoo', b'foo'])
1067 ... b'-mfoo', b'foo'])
1068 ... runcommand(server, [b'log'])
1068 ... runcommand(server, [b'log'])
1069 ... runcommand(server, [b'verify', b'-q'])
1069 ... runcommand(server, [b'verify', b'-q'])
1070 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
1070 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
1071 transaction abort!
1071 transaction abort!
1072 rollback completed
1072 rollback completed
1073 abort: pretxncommit hook exited with status 1
1073 abort: pretxncommit hook exited with status 1
1074 [40]
1074 [40]
1075 *** runcommand log
1075 *** runcommand log
1076 0 bar (bar)
1076 0 bar (bar)
1077 *** runcommand verify -q
1077 *** runcommand verify -q
1078
1078
1079 (failure after finalization)
1079 (failure after finalization)
1080
1080
1081 >>> from hgclient import check, readchannel, runcommand
1081 >>> from hgclient import check, readchannel, runcommand
1082 >>> @check
1082 >>> @check
1083 ... def abort(server):
1083 ... def abort(server):
1084 ... readchannel(server)
1084 ... readchannel(server)
1085 ... runcommand(server, [b'commit',
1085 ... runcommand(server, [b'commit',
1086 ... b'--config', b'failafterfinalize.fail=true',
1086 ... b'--config', b'failafterfinalize.fail=true',
1087 ... b'-mfoo', b'foo'])
1087 ... b'-mfoo', b'foo'])
1088 ... runcommand(server, [b'log'])
1088 ... runcommand(server, [b'log'])
1089 ... runcommand(server, [b'verify', b'-q'])
1089 ... runcommand(server, [b'verify', b'-q'])
1090 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
1090 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
1091 transaction abort!
1091 transaction abort!
1092 rollback completed
1092 rollback completed
1093 abort: fail after finalization
1093 abort: fail after finalization
1094 [255]
1094 [255]
1095 *** runcommand log
1095 *** runcommand log
1096 0 bar (bar)
1096 0 bar (bar)
1097 *** runcommand verify -q
1097 *** runcommand verify -q
1098
1098
1099 $ cd ..
1099 $ cd ..
1100
1100
1101 Test symlink traversal over cached audited paths:
1101 Test symlink traversal over cached audited paths:
1102 -------------------------------------------------
1102 -------------------------------------------------
1103
1103
1104 #if symlink
1104 #if symlink
1105
1105
1106 set up symlink hell
1106 set up symlink hell
1107
1107
1108 $ mkdir merge-symlink-out
1108 $ mkdir merge-symlink-out
1109 $ hg init merge-symlink
1109 $ hg init merge-symlink
1110 $ cd merge-symlink
1110 $ cd merge-symlink
1111 $ touch base
1111 $ touch base
1112 $ hg commit -qAm base
1112 $ hg commit -qAm base
1113 $ ln -s ../merge-symlink-out a
1113 $ ln -s ../merge-symlink-out a
1114 $ hg commit -qAm 'symlink a -> ../merge-symlink-out'
1114 $ hg commit -qAm 'symlink a -> ../merge-symlink-out'
1115 $ hg up -q 0
1115 $ hg up -q 0
1116 $ mkdir a
1116 $ mkdir a
1117 $ touch a/poisoned
1117 $ touch a/poisoned
1118 $ hg commit -qAm 'file a/poisoned'
1118 $ hg commit -qAm 'file a/poisoned'
1119 $ hg log -G -T '{rev}: {desc}\n'
1119 $ hg log -G -T '{rev}: {desc}\n'
1120 @ 2: file a/poisoned
1120 @ 2: file a/poisoned
1121 |
1121 |
1122 | o 1: symlink a -> ../merge-symlink-out
1122 | o 1: symlink a -> ../merge-symlink-out
1123 |/
1123 |/
1124 o 0: base
1124 o 0: base
1125
1125
1126
1126
1127 try trivial merge after update: cache of audited paths should be discarded,
1127 try trivial merge after update: cache of audited paths should be discarded,
1128 and the merge should fail (issue5628)
1128 and the merge should fail (issue5628)
1129
1129
1130 $ hg up -q null
1130 $ hg up -q null
1131 >>> from hgclient import check, readchannel, runcommand
1131 >>> from hgclient import check, readchannel, runcommand
1132 >>> @check
1132 >>> @check
1133 ... def merge(server):
1133 ... def merge(server):
1134 ... readchannel(server)
1134 ... readchannel(server)
1135 ... # audit a/poisoned as a good path
1135 ... # audit a/poisoned as a good path
1136 ... runcommand(server, [b'up', b'-qC', b'2'])
1136 ... runcommand(server, [b'up', b'-qC', b'2'])
1137 ... runcommand(server, [b'up', b'-qC', b'1'])
1137 ... runcommand(server, [b'up', b'-qC', b'1'])
1138 ... # here a is a symlink, so a/poisoned is bad
1138 ... # here a is a symlink, so a/poisoned is bad
1139 ... runcommand(server, [b'merge', b'2'])
1139 ... runcommand(server, [b'merge', b'2'])
1140 *** runcommand up -qC 2
1140 *** runcommand up -qC 2
1141 *** runcommand up -qC 1
1141 *** runcommand up -qC 1
1142 *** runcommand merge 2
1142 *** runcommand merge 2
1143 abort: path 'a/poisoned' traverses symbolic link 'a'
1143 abort: path 'a/poisoned' traverses symbolic link 'a'
1144 [255]
1144 [255]
1145 $ ls ../merge-symlink-out
1145 $ ls ../merge-symlink-out
1146
1146
1147 cache of repo.auditor should be discarded, so matcher would never traverse
1147 cache of repo.auditor should be discarded, so matcher would never traverse
1148 symlinks:
1148 symlinks:
1149
1149
1150 $ hg up -qC 0
1150 $ hg up -qC 0
1151 $ touch ../merge-symlink-out/poisoned
1151 $ touch ../merge-symlink-out/poisoned
1152 >>> from hgclient import check, readchannel, runcommand
1152 >>> from hgclient import check, readchannel, runcommand
1153 >>> @check
1153 >>> @check
1154 ... def files(server):
1154 ... def files(server):
1155 ... readchannel(server)
1155 ... readchannel(server)
1156 ... runcommand(server, [b'up', b'-qC', b'2'])
1156 ... runcommand(server, [b'up', b'-qC', b'2'])
1157 ... # audit a/poisoned as a good path
1157 ... # audit a/poisoned as a good path
1158 ... runcommand(server, [b'files', b'a/poisoned'])
1158 ... runcommand(server, [b'files', b'a/poisoned'])
1159 ... runcommand(server, [b'up', b'-qC', b'0'])
1159 ... runcommand(server, [b'up', b'-qC', b'0'])
1160 ... runcommand(server, [b'up', b'-qC', b'1'])
1160 ... runcommand(server, [b'up', b'-qC', b'1'])
1161 ... # here 'a' is a symlink, so a/poisoned should be warned
1161 ... # here 'a' is a symlink, so a/poisoned should be warned
1162 ... runcommand(server, [b'files', b'a/poisoned'])
1162 ... runcommand(server, [b'files', b'a/poisoned'])
1163 *** runcommand up -qC 2
1163 *** runcommand up -qC 2
1164 *** runcommand files a/poisoned
1164 *** runcommand files a/poisoned
1165 a/poisoned
1165 a/poisoned
1166 *** runcommand up -qC 0
1166 *** runcommand up -qC 0
1167 *** runcommand up -qC 1
1167 *** runcommand up -qC 1
1168 *** runcommand files a/poisoned
1168 *** runcommand files a/poisoned
1169 abort: path 'a/poisoned' traverses symbolic link 'a'
1169 abort: path 'a/poisoned' traverses symbolic link 'a'
1170 [255]
1170 [255]
1171
1171
1172 $ cd ..
1172 $ cd ..
1173
1173
1174 #endif
1174 #endif
@@ -1,247 +1,247 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 $ cat >> $HGRCPATH << EOF
4 $ cat >> $HGRCPATH << EOF
5 > [format]
5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 > [storage]
7 > [storage]
8 > dirstate-v2.slow-path=allow
8 > dirstate-v2.slow-path=allow
9 > EOF
9 > EOF
10 #endif
10 #endif
11
11
12 $ hg init repo
12 $ hg init repo
13 $ cd repo
13 $ cd repo
14 $ echo a > a
14 $ echo a > a
15 $ hg add a
15 $ hg add a
16 $ hg commit -m test
16 $ hg commit -m test
17
17
18 Do we ever miss a sub-second change?:
18 Do we ever miss a sub-second change?:
19
19
20 $ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
20 $ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
21 > hg co -qC 0
21 > hg co -qC 0
22 > echo b > a
22 > echo b > a
23 > hg st
23 > hg st
24 > done
24 > done
25 M a
25 M a
26 M a
26 M a
27 M a
27 M a
28 M a
28 M a
29 M a
29 M a
30 M a
30 M a
31 M a
31 M a
32 M a
32 M a
33 M a
33 M a
34 M a
34 M a
35 M a
35 M a
36 M a
36 M a
37 M a
37 M a
38 M a
38 M a
39 M a
39 M a
40 M a
40 M a
41 M a
41 M a
42 M a
42 M a
43 M a
43 M a
44 M a
44 M a
45
45
46 $ echo test > b
46 $ echo test > b
47 $ mkdir dir1
47 $ mkdir dir1
48 $ echo test > dir1/c
48 $ echo test > dir1/c
49 $ echo test > d
49 $ echo test > d
50
50
51 $ echo test > e
51 $ echo test > e
52 #if execbit
52 #if execbit
53 A directory will typically have the execute bit -- make sure it doesn't get
53 A directory will typically have the execute bit -- make sure it doesn't get
54 confused with a file with the exec bit set
54 confused with a file with the exec bit set
55 $ chmod +x e
55 $ chmod +x e
56 #endif
56 #endif
57
57
58 $ hg add b dir1 d e
58 $ hg add b dir1 d e
59 adding dir1/c
59 adding dir1/c
60 $ hg commit -m test2
60 $ hg commit -m test2
61
61
62 $ cat >> $TESTTMP/dirstaterace.py << EOF
62 $ cat >> $TESTTMP/dirstaterace.py << EOF
63 > from mercurial import (
63 > from mercurial import (
64 > context,
64 > context,
65 > extensions,
65 > extensions,
66 > )
66 > )
67 > def extsetup(ui):
67 > def extsetup(ui):
68 > extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
68 > extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
69 > def overridechecklookup(orig, self, files):
69 > def overridechecklookup(orig, self, files):
70 > # make an update that changes the dirstate from underneath
70 > # make an update that changes the dirstate from underneath
71 > self._repo.ui.system(br"sh '$TESTTMP/dirstaterace.sh'",
71 > self._repo.ui.system(br"sh '$TESTTMP/dirstaterace.sh'",
72 > cwd=self._repo.root)
72 > cwd=self._repo.root)
73 > return orig(self, files)
73 > return orig(self, files)
74 > EOF
74 > EOF
75
75
76 $ hg debugrebuilddirstate
76 $ hg debugrebuilddirstate
77 $ hg debugdirstate
77 $ hg debugdirstate
78 n 0 -1 unset a
78 n 0 -1 unset a
79 n 0 -1 unset b
79 n 0 -1 unset b
80 n 0 -1 unset d
80 n 0 -1 unset d
81 n 0 -1 unset dir1/c
81 n 0 -1 unset dir1/c
82 n 0 -1 unset e
82 n 0 -1 unset e
83
83
84 XXX Note that this returns M for files that got replaced by directories. This is
84 XXX Note that this returns M for files that got replaced by directories. This is
85 definitely a bug, but the fix for that is hard and the next status run is fine
85 definitely a bug, but the fix for that is hard and the next status run is fine
86 anyway.
86 anyway.
87
87
88 $ cat > $TESTTMP/dirstaterace.sh <<EOF
88 $ cat > $TESTTMP/dirstaterace.sh <<EOF
89 > rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e
89 > rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e
90 > EOF
90 > EOF
91
91
92 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py
92 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py
93 M d
93 M d
94 M e
94 M e
95 ! b
95 ! b
96 ! dir1/c
96 ! dir1/c
97 $ hg debugdirstate
97 $ hg debugdirstate
98 n 644 2 * a (glob)
98 n 644 2 * a (glob)
99 n 0 -1 unset b
99 n 0 -1 unset b
100 n 0 -1 unset d
100 n 0 -1 unset d
101 n 0 -1 unset dir1/c
101 n 0 -1 unset dir1/c
102 n 0 -1 unset e
102 n 0 -1 unset e
103
103
104 $ hg status
104 $ hg status
105 ! b
105 ! b
106 ! d
106 ! d
107 ! dir1/c
107 ! dir1/c
108 ! e
108 ! e
109
109
110 $ rmdir d e
110 $ rmdir d e
111 $ hg update -C -q .
111 $ hg update -C -q .
112
112
113 Test that dirstate changes aren't written out at the end of "hg
113 Test that dirstate changes aren't written out at the end of "hg
114 status", if .hg/dirstate is already changed simultaneously before
114 status", if .hg/dirstate is already changed simultaneously before
115 acquisition of wlock in workingctx._poststatusfixup().
115 acquisition of wlock in workingctx._poststatusfixup().
116
116
117 This avoidance is important to keep consistency of dirstate in race
117 This avoidance is important to keep consistency of dirstate in race
118 condition (see issue5584 for detail).
118 condition (see issue5584 for detail).
119
119
120 $ hg parents -q
120 $ hg parents -q
121 1:* (glob)
121 1:* (glob)
122
122
123 $ hg debugrebuilddirstate
123 $ hg debugrebuilddirstate
124 $ hg debugdirstate
124 $ hg debugdirstate
125 n 0 -1 unset a
125 n 0 -1 unset a
126 n 0 -1 unset b
126 n 0 -1 unset b
127 n 0 -1 unset d
127 n 0 -1 unset d
128 n 0 -1 unset dir1/c
128 n 0 -1 unset dir1/c
129 n 0 -1 unset e
129 n 0 -1 unset e
130
130
131 $ cat > $TESTTMP/dirstaterace.sh <<EOF
131 $ cat > $TESTTMP/dirstaterace.sh <<EOF
132 > # This script assumes timetable of typical issue5584 case below:
132 > # This script assumes timetable of typical issue5584 case below:
133 > #
133 > #
134 > # 1. "hg status" loads .hg/dirstate
134 > # 1. "hg status" loads .hg/dirstate
135 > # 2. "hg status" confirms clean-ness of FILE
135 > # 2. "hg status" confirms clean-ness of FILE
136 > # 3. "hg update -C 0" updates the working directory simultaneously
136 > # 3. "hg update -C 0" updates the working directory simultaneously
137 > # (FILE is removed, and FILE is dropped from .hg/dirstate)
137 > # (FILE is removed, and FILE is dropped from .hg/dirstate)
138 > # 4. "hg status" acquires wlock
138 > # 4. "hg status" acquires wlock
139 > # (.hg/dirstate is re-loaded = no FILE entry in dirstate)
139 > # (.hg/dirstate is re-loaded = no FILE entry in dirstate)
140 > # 5. "hg status" marks FILE in dirstate as clean
140 > # 5. "hg status" marks FILE in dirstate as clean
141 > # (FILE entry is added to in-memory dirstate)
141 > # (FILE entry is added to in-memory dirstate)
142 > # 6. "hg status" writes dirstate changes into .hg/dirstate
142 > # 6. "hg status" writes dirstate changes into .hg/dirstate
143 > # (FILE entry is written into .hg/dirstate)
143 > # (FILE entry is written into .hg/dirstate)
144 > #
144 > #
145 > # To reproduce similar situation easily and certainly, #2 and #3
145 > # To reproduce similar situation easily and certainly, #2 and #3
146 > # are swapped. "hg cat" below ensures #2 on "hg status" side.
146 > # are swapped. "hg cat" below ensures #2 on "hg status" side.
147 >
147 >
148 > hg update -q -C 0
148 > hg update -q -C 0
149 > hg cat -r 1 b > b
149 > hg cat -r 1 b > b
150 > EOF
150 > EOF
151
151
152 "hg status" below should excludes "e", of which exec flag is set, for
152 "hg status" below should excludes "e", of which exec flag is set, for
153 portability of test scenario, because unsure but missing "e" is
153 portability of test scenario, because unsure but missing "e" is
154 treated differently in _checklookup() according to runtime platform.
154 treated differently in _checklookup() according to runtime platform.
155
155
156 - "missing(!)" on POSIX, "pctx[f].cmp(self[f])" raises ENOENT
156 - "missing(!)" on POSIX, "pctx[f].cmp(self[f])" raises ENOENT
157 - "modified(M)" on Windows, "self.flags(f) != pctx.flags(f)" is True
157 - "modified(M)" on Windows, "self.flags(f) != pctx.flags(f)" is True
158
158
159 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug -X path:e
159 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug -X path:e
160 skip updating dirstate: identity mismatch
160 skip updating dirstate: identity mismatch
161 M a
161 M a
162 ! d
162 ! d
163 ! dir1/c
163 ! dir1/c
164
164
165 $ hg parents -q
165 $ hg parents -q
166 0:* (glob)
166 0:* (glob)
167 $ hg files
167 $ hg files
168 a
168 a
169 $ hg debugdirstate
169 $ hg debugdirstate
170 n * * * a (glob)
170 n * * * a (glob)
171
171
172 $ rm b
172 $ rm b
173
173
174 #if fsmonitor
174 #if fsmonitor
175
175
176 Create fsmonitor state.
176 Create fsmonitor state.
177
177
178 $ hg status
178 $ hg status
179 $ f --type .hg/fsmonitor.state
179 $ f --type .hg/fsmonitor.state
180 .hg/fsmonitor.state: file
180 .hg/fsmonitor.state: file
181
181
182 Test that invalidating fsmonitor state in the middle (which doesn't require the
182 Test that invalidating fsmonitor state in the middle (which doesn't require the
183 wlock) causes the fsmonitor update to be skipped.
183 wlock) causes the fsmonitor update to be skipped.
184 hg debugrebuilddirstate ensures that the dirstaterace hook will be called, but
184 hg debugrebuilddirstate ensures that the dirstaterace hook will be called, but
185 it also invalidates the fsmonitor state. So back it up and restore it.
185 it also invalidates the fsmonitor state. So back it up and restore it.
186
186
187 $ mv .hg/fsmonitor.state .hg/fsmonitor.state.tmp
187 $ mv .hg/fsmonitor.state .hg/fsmonitor.state.tmp
188 $ hg debugrebuilddirstate
188 $ hg debugrebuilddirstate
189 $ mv .hg/fsmonitor.state.tmp .hg/fsmonitor.state
189 $ mv .hg/fsmonitor.state.tmp .hg/fsmonitor.state
190
190
191 $ cat > $TESTTMP/dirstaterace.sh <<EOF
191 $ cat > $TESTTMP/dirstaterace.sh <<EOF
192 > rm .hg/fsmonitor.state
192 > rm .hg/fsmonitor.state
193 > EOF
193 > EOF
194
194
195 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug
195 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug
196 skip updating fsmonitor.state: identity mismatch
196 skip updating fsmonitor.state: identity mismatch
197 $ f .hg/fsmonitor.state
197 $ f .hg/fsmonitor.state
198 .hg/fsmonitor.state: file not found
198 .hg/fsmonitor.state: file not found
199
199
200 #endif
200 #endif
201
201
202 Set up a rebase situation for issue5581.
202 Set up a rebase situation for issue5581.
203
203
204 $ echo c2 > a
204 $ echo c2 > a
205 $ echo c2 > b
205 $ echo c2 > b
206 $ hg add b
206 $ hg add b
207 $ hg commit -m c2
207 $ hg commit -m c2
208 created new head
208 created new head
209 $ echo c3 >> a
209 $ echo c3 >> a
210 $ hg commit -m c3
210 $ hg commit -m c3
211 $ hg update 2
211 $ hg update 2
212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 $ echo c4 >> a
213 $ echo c4 >> a
214 $ echo c4 >> b
214 $ echo c4 >> b
215 $ hg commit -m c4
215 $ hg commit -m c4
216 created new head
216 created new head
217
217
218 Configure a merge tool that runs status in the middle of the rebase. The goal of
218 Configure a merge tool that runs status in the middle of the rebase. The goal of
219 the status call is to trigger a potential bug if fsmonitor's state is written
219 the status call is to trigger a potential bug if fsmonitor's state is written
220 even though the wlock is held by another process. The output of 'hg status' in
220 even though the wlock is held by another process. The output of 'hg status' in
221 the merge tool goes to /dev/null because we're more interested in the results of
221 the merge tool goes to /dev/null because we're more interested in the results of
222 'hg status' run after the rebase.
222 'hg status' run after the rebase.
223
223
224 $ cat >> $TESTTMP/mergetool-race.sh << EOF
224 $ cat >> $TESTTMP/mergetool-race.sh << EOF
225 > echo "custom merge tool"
225 > echo "custom merge tool"
226 > printf "c2\nc3\nc4\n" > \$1
226 > printf "c2\nc3\nc4\n" > \$1
227 > hg --cwd "$TESTTMP/repo" status > /dev/null
227 > hg --cwd "$TESTTMP/repo" status > /dev/null
228 > echo "custom merge tool end"
228 > echo "custom merge tool end"
229 > EOF
229 > EOF
230 $ cat >> $HGRCPATH << EOF
230 $ cat >> $HGRCPATH << EOF
231 > [extensions]
231 > [extensions]
232 > rebase =
232 > rebase =
233 > [merge-tools]
233 > [merge-tools]
234 > test.executable=sh
234 > test.executable=sh
235 > test.args=$TESTTMP/mergetool-race.sh \$output
235 > test.args=$TESTTMP/mergetool-race.sh \$output
236 > EOF
236 > EOF
237
237
238 $ hg rebase -s . -d 3 --tool test
238 $ hg rebase -s . -d 3 --tool test
239 rebasing 4:b08445fd6b2a tip "c4"
239 rebasing 4:b08445fd6b2a tip "c4"
240 merging a
240 merging a
241 custom merge tool
241 custom merge tool
242 custom merge tool end
242 custom merge tool end
243 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/* (glob)
243 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/* (glob)
244
244
245 This hg status should be empty, whether or not fsmonitor is enabled (issue5581).
245 This hg status should be empty, whether or not fsmonitor is enabled (issue5581).
246
246
247 $ hg status
247 $ hg status
@@ -1,48 +1,48 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 $ cat >> $HGRCPATH << EOF
4 $ cat >> $HGRCPATH << EOF
5 > [format]
5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 > [storage]
7 > [storage]
8 > dirstate-v2.slow-path=allow
8 > dirstate-v2.slow-path=allow
9 > EOF
9 > EOF
10 #endif
10 #endif
11
11
12 Checking the size/permissions/file-type of files stored in the
12 Checking the size/permissions/file-type of files stored in the
13 dirstate after an update where the files are changed concurrently
13 dirstate after an update where the files are changed concurrently
14 outside of hg's control.
14 outside of hg's control.
15
15
16 $ hg init repo
16 $ hg init repo
17 $ cd repo
17 $ cd repo
18 $ echo a > a
18 $ echo a > a
19 $ hg commit -qAm _
19 $ hg commit -qAm _
20 $ echo aa > a
20 $ echo aa > a
21 $ hg commit -m _
21 $ hg commit -m _
22
22
23 $ hg debugdirstate --no-dates
23 $ hg debugdirstate --no-dates
24 n 644 3 (set |unset) a (re)
24 n 644 3 (set |unset) a (re)
25
25
26 $ cat >> $TESTTMP/dirstaterace.py << EOF
26 $ cat >> $TESTTMP/dirstaterace.py << EOF
27 > from mercurial import (
27 > from mercurial import (
28 > extensions,
28 > extensions,
29 > merge,
29 > merge,
30 > )
30 > )
31 > def extsetup(ui):
31 > def extsetup(ui):
32 > extensions.wrapfunction(merge, 'applyupdates', wrap)
32 > extensions.wrapfunction(merge, 'applyupdates', wrap)
33 > def wrap(orig, *args, **kwargs):
33 > def wrap(orig, *args, **kwargs):
34 > res = orig(*args, **kwargs)
34 > res = orig(*args, **kwargs)
35 > with open("a", "w"):
35 > with open("a", "w"):
36 > pass # just truncate the file
36 > pass # just truncate the file
37 > return res
37 > return res
38 > EOF
38 > EOF
39
39
40 Do an update where file 'a' is changed between hg writing it to disk
40 Do an update where file 'a' is changed between hg writing it to disk
41 and hg writing the dirstate. The dirstate is correct nonetheless, and
41 and hg writing the dirstate. The dirstate is correct nonetheless, and
42 so hg status correctly shows a as clean.
42 so hg status correctly shows a as clean.
43
43
44 $ hg up -r 0 --config extensions.race=$TESTTMP/dirstaterace.py
44 $ hg up -r 0 --config extensions.race=$TESTTMP/dirstaterace.py
45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 $ hg debugdirstate --no-dates
46 $ hg debugdirstate --no-dates
47 n 644 2 (set |unset) a (re)
47 n 644 2 (set |unset) a (re)
48 $ echo a > a; hg status; hg diff
48 $ echo a > a; hg status; hg diff
@@ -1,105 +1,105 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 $ cat >> $HGRCPATH << EOF
4 $ cat >> $HGRCPATH << EOF
5 > [format]
5 > [format]
6 > exp-rc-dirstate-v2=1
6 > use-dirstate-v2=1
7 > [storage]
7 > [storage]
8 > dirstate-v2.slow-path=allow
8 > dirstate-v2.slow-path=allow
9 > EOF
9 > EOF
10 #endif
10 #endif
11
11
12 ------ Test dirstate._dirs refcounting
12 ------ Test dirstate._dirs refcounting
13
13
14 $ hg init t
14 $ hg init t
15 $ cd t
15 $ cd t
16 $ mkdir -p a/b/c/d
16 $ mkdir -p a/b/c/d
17 $ touch a/b/c/d/x
17 $ touch a/b/c/d/x
18 $ touch a/b/c/d/y
18 $ touch a/b/c/d/y
19 $ touch a/b/c/d/z
19 $ touch a/b/c/d/z
20 $ hg ci -Am m
20 $ hg ci -Am m
21 adding a/b/c/d/x
21 adding a/b/c/d/x
22 adding a/b/c/d/y
22 adding a/b/c/d/y
23 adding a/b/c/d/z
23 adding a/b/c/d/z
24 $ hg mv a z
24 $ hg mv a z
25 moving a/b/c/d/x to z/b/c/d/x
25 moving a/b/c/d/x to z/b/c/d/x
26 moving a/b/c/d/y to z/b/c/d/y
26 moving a/b/c/d/y to z/b/c/d/y
27 moving a/b/c/d/z to z/b/c/d/z
27 moving a/b/c/d/z to z/b/c/d/z
28
28
29 Test name collisions
29 Test name collisions
30
30
31 $ rm z/b/c/d/x
31 $ rm z/b/c/d/x
32 $ mkdir z/b/c/d/x
32 $ mkdir z/b/c/d/x
33 $ touch z/b/c/d/x/y
33 $ touch z/b/c/d/x/y
34 $ hg add z/b/c/d/x/y
34 $ hg add z/b/c/d/x/y
35 abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y'
35 abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y'
36 [255]
36 [255]
37 $ rm -rf z/b/c/d
37 $ rm -rf z/b/c/d
38 $ touch z/b/c/d
38 $ touch z/b/c/d
39 $ hg add z/b/c/d
39 $ hg add z/b/c/d
40 abort: directory 'z/b/c/d' already in dirstate
40 abort: directory 'z/b/c/d' already in dirstate
41 [255]
41 [255]
42
42
43 $ cd ..
43 $ cd ..
44
44
45 Issue1790: dirstate entry locked into unset if file mtime is set into
45 Issue1790: dirstate entry locked into unset if file mtime is set into
46 the future
46 the future
47
47
48 Prepare test repo:
48 Prepare test repo:
49
49
50 $ hg init u
50 $ hg init u
51 $ cd u
51 $ cd u
52 $ echo a > a
52 $ echo a > a
53 $ hg add
53 $ hg add
54 adding a
54 adding a
55 $ hg ci -m1
55 $ hg ci -m1
56
56
57 Set mtime of a into the future:
57 Set mtime of a into the future:
58
58
59 $ touch -t 203101011200 a
59 $ touch -t 203101011200 a
60
60
61 Status must not set a's entry to unset (issue1790):
61 Status must not set a's entry to unset (issue1790):
62
62
63 $ hg status
63 $ hg status
64 $ hg debugstate
64 $ hg debugstate
65 n 644 2 2031-01-01 12:00:00 a
65 n 644 2 2031-01-01 12:00:00 a
66
66
67 Test modulo storage/comparison of absurd dates:
67 Test modulo storage/comparison of absurd dates:
68
68
69 #if no-aix
69 #if no-aix
70 $ touch -t 195001011200 a
70 $ touch -t 195001011200 a
71 $ hg st
71 $ hg st
72 $ hg debugstate
72 $ hg debugstate
73 n 644 2 2018-01-19 15:14:08 a
73 n 644 2 2018-01-19 15:14:08 a
74 #endif
74 #endif
75
75
76 Verify that exceptions during a dirstate change leave the dirstate
76 Verify that exceptions during a dirstate change leave the dirstate
77 coherent (issue4353)
77 coherent (issue4353)
78
78
79 $ cat > ../dirstateexception.py <<EOF
79 $ cat > ../dirstateexception.py <<EOF
80 > from __future__ import absolute_import
80 > from __future__ import absolute_import
81 > from mercurial import (
81 > from mercurial import (
82 > error,
82 > error,
83 > extensions,
83 > extensions,
84 > mergestate as mergestatemod,
84 > mergestate as mergestatemod,
85 > )
85 > )
86 >
86 >
87 > def wraprecordupdates(*args):
87 > def wraprecordupdates(*args):
88 > raise error.Abort(b"simulated error while recording dirstateupdates")
88 > raise error.Abort(b"simulated error while recording dirstateupdates")
89 >
89 >
90 > def reposetup(ui, repo):
90 > def reposetup(ui, repo):
91 > extensions.wrapfunction(mergestatemod, 'recordupdates',
91 > extensions.wrapfunction(mergestatemod, 'recordupdates',
92 > wraprecordupdates)
92 > wraprecordupdates)
93 > EOF
93 > EOF
94
94
95 $ hg rm a
95 $ hg rm a
96 $ hg commit -m 'rm a'
96 $ hg commit -m 'rm a'
97 $ echo "[extensions]" >> .hg/hgrc
97 $ echo "[extensions]" >> .hg/hgrc
98 $ echo "dirstateex=../dirstateexception.py" >> .hg/hgrc
98 $ echo "dirstateex=../dirstateexception.py" >> .hg/hgrc
99 $ hg up 0
99 $ hg up 0
100 abort: simulated error while recording dirstateupdates
100 abort: simulated error while recording dirstateupdates
101 [255]
101 [255]
102 $ hg log -r . -T '{rev}\n'
102 $ hg log -r . -T '{rev}\n'
103 1
103 1
104 $ hg status
104 $ hg status
105 ? a
105 ? a
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now