##// END OF EJS Templates
lock: allow to configure when the lock messages are displayed...
Boris Feld -
r35210:9153871d default
parent child Browse files
Show More
@@ -1,1262 +1,1265 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 def loadconfigtable(ui, extname, configtable):
18 def loadconfigtable(ui, extname, configtable):
19 """update config item known to the ui with the extension ones"""
19 """update config item known to the ui with the extension ones"""
20 for section, items in configtable.items():
20 for section, items in configtable.items():
21 knownitems = ui._knownconfig.setdefault(section, itemregister())
21 knownitems = ui._knownconfig.setdefault(section, itemregister())
22 knownkeys = set(knownitems)
22 knownkeys = set(knownitems)
23 newkeys = set(items)
23 newkeys = set(items)
24 for key in sorted(knownkeys & newkeys):
24 for key in sorted(knownkeys & newkeys):
25 msg = "extension '%s' overwrite config item '%s.%s'"
25 msg = "extension '%s' overwrite config item '%s.%s'"
26 msg %= (extname, section, key)
26 msg %= (extname, section, key)
27 ui.develwarn(msg, config='warn-config')
27 ui.develwarn(msg, config='warn-config')
28
28
29 knownitems.update(items)
29 knownitems.update(items)
30
30
31 class configitem(object):
31 class configitem(object):
32 """represent a known config item
32 """represent a known config item
33
33
34 :section: the official config section where to find this item,
34 :section: the official config section where to find this item,
35 :name: the official name within the section,
35 :name: the official name within the section,
36 :default: default value for this item,
36 :default: default value for this item,
37 :alias: optional list of tuples as alternatives,
37 :alias: optional list of tuples as alternatives,
38 :generic: this is a generic definition, match name using regular expression.
38 :generic: this is a generic definition, match name using regular expression.
39 """
39 """
40
40
41 def __init__(self, section, name, default=None, alias=(),
41 def __init__(self, section, name, default=None, alias=(),
42 generic=False, priority=0):
42 generic=False, priority=0):
43 self.section = section
43 self.section = section
44 self.name = name
44 self.name = name
45 self.default = default
45 self.default = default
46 self.alias = list(alias)
46 self.alias = list(alias)
47 self.generic = generic
47 self.generic = generic
48 self.priority = priority
48 self.priority = priority
49 self._re = None
49 self._re = None
50 if generic:
50 if generic:
51 self._re = re.compile(self.name)
51 self._re = re.compile(self.name)
52
52
53 class itemregister(dict):
53 class itemregister(dict):
54 """A specialized dictionary that can handle wild-card selection"""
54 """A specialized dictionary that can handle wild-card selection"""
55
55
56 def __init__(self):
56 def __init__(self):
57 super(itemregister, self).__init__()
57 super(itemregister, self).__init__()
58 self._generics = set()
58 self._generics = set()
59
59
60 def update(self, other):
60 def update(self, other):
61 super(itemregister, self).update(other)
61 super(itemregister, self).update(other)
62 self._generics.update(other._generics)
62 self._generics.update(other._generics)
63
63
64 def __setitem__(self, key, item):
64 def __setitem__(self, key, item):
65 super(itemregister, self).__setitem__(key, item)
65 super(itemregister, self).__setitem__(key, item)
66 if item.generic:
66 if item.generic:
67 self._generics.add(item)
67 self._generics.add(item)
68
68
69 def get(self, key):
69 def get(self, key):
70 baseitem = super(itemregister, self).get(key)
70 baseitem = super(itemregister, self).get(key)
71 if baseitem is not None and not baseitem.generic:
71 if baseitem is not None and not baseitem.generic:
72 return baseitem
72 return baseitem
73
73
74 # search for a matching generic item
74 # search for a matching generic item
75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
76 for item in generics:
76 for item in generics:
77 # we use 'match' instead of 'search' to make the matching simpler
77 # we use 'match' instead of 'search' to make the matching simpler
78 # for people unfamiliar with regular expression. Having the match
78 # for people unfamiliar with regular expression. Having the match
79 # rooted to the start of the string will produce less surprising
79 # rooted to the start of the string will produce less surprising
80 # result for user writing simple regex for sub-attribute.
80 # result for user writing simple regex for sub-attribute.
81 #
81 #
82 # For example using "color\..*" match produces an unsurprising
82 # For example using "color\..*" match produces an unsurprising
83 # result, while using search could suddenly match apparently
83 # result, while using search could suddenly match apparently
84 # unrelated configuration that happens to contains "color."
84 # unrelated configuration that happens to contains "color."
85 # anywhere. This is a tradeoff where we favor requiring ".*" on
85 # anywhere. This is a tradeoff where we favor requiring ".*" on
86 # some match to avoid the need to prefix most pattern with "^".
86 # some match to avoid the need to prefix most pattern with "^".
87 # The "^" seems more error prone.
87 # The "^" seems more error prone.
88 if item._re.match(key):
88 if item._re.match(key):
89 return item
89 return item
90
90
91 return None
91 return None
92
92
93 coreitems = {}
93 coreitems = {}
94
94
95 def _register(configtable, *args, **kwargs):
95 def _register(configtable, *args, **kwargs):
96 item = configitem(*args, **kwargs)
96 item = configitem(*args, **kwargs)
97 section = configtable.setdefault(item.section, itemregister())
97 section = configtable.setdefault(item.section, itemregister())
98 if item.name in section:
98 if item.name in section:
99 msg = "duplicated config item registration for '%s.%s'"
99 msg = "duplicated config item registration for '%s.%s'"
100 raise error.ProgrammingError(msg % (item.section, item.name))
100 raise error.ProgrammingError(msg % (item.section, item.name))
101 section[item.name] = item
101 section[item.name] = item
102
102
103 # special value for case where the default is derived from other values
103 # special value for case where the default is derived from other values
104 dynamicdefault = object()
104 dynamicdefault = object()
105
105
106 # Registering actual config items
106 # Registering actual config items
107
107
108 def getitemregister(configtable):
108 def getitemregister(configtable):
109 f = functools.partial(_register, configtable)
109 f = functools.partial(_register, configtable)
110 # export pseudo enum as configitem.*
110 # export pseudo enum as configitem.*
111 f.dynamicdefault = dynamicdefault
111 f.dynamicdefault = dynamicdefault
112 return f
112 return f
113
113
114 coreconfigitem = getitemregister(coreitems)
114 coreconfigitem = getitemregister(coreitems)
115
115
116 coreconfigitem('alias', '.*',
116 coreconfigitem('alias', '.*',
117 default=None,
117 default=None,
118 generic=True,
118 generic=True,
119 )
119 )
120 coreconfigitem('annotate', 'nodates',
120 coreconfigitem('annotate', 'nodates',
121 default=False,
121 default=False,
122 )
122 )
123 coreconfigitem('annotate', 'showfunc',
123 coreconfigitem('annotate', 'showfunc',
124 default=False,
124 default=False,
125 )
125 )
126 coreconfigitem('annotate', 'unified',
126 coreconfigitem('annotate', 'unified',
127 default=None,
127 default=None,
128 )
128 )
129 coreconfigitem('annotate', 'git',
129 coreconfigitem('annotate', 'git',
130 default=False,
130 default=False,
131 )
131 )
132 coreconfigitem('annotate', 'ignorews',
132 coreconfigitem('annotate', 'ignorews',
133 default=False,
133 default=False,
134 )
134 )
135 coreconfigitem('annotate', 'ignorewsamount',
135 coreconfigitem('annotate', 'ignorewsamount',
136 default=False,
136 default=False,
137 )
137 )
138 coreconfigitem('annotate', 'ignoreblanklines',
138 coreconfigitem('annotate', 'ignoreblanklines',
139 default=False,
139 default=False,
140 )
140 )
141 coreconfigitem('annotate', 'ignorewseol',
141 coreconfigitem('annotate', 'ignorewseol',
142 default=False,
142 default=False,
143 )
143 )
144 coreconfigitem('annotate', 'nobinary',
144 coreconfigitem('annotate', 'nobinary',
145 default=False,
145 default=False,
146 )
146 )
147 coreconfigitem('annotate', 'noprefix',
147 coreconfigitem('annotate', 'noprefix',
148 default=False,
148 default=False,
149 )
149 )
150 coreconfigitem('auth', 'cookiefile',
150 coreconfigitem('auth', 'cookiefile',
151 default=None,
151 default=None,
152 )
152 )
153 # bookmarks.pushing: internal hack for discovery
153 # bookmarks.pushing: internal hack for discovery
154 coreconfigitem('bookmarks', 'pushing',
154 coreconfigitem('bookmarks', 'pushing',
155 default=list,
155 default=list,
156 )
156 )
157 # bundle.mainreporoot: internal hack for bundlerepo
157 # bundle.mainreporoot: internal hack for bundlerepo
158 coreconfigitem('bundle', 'mainreporoot',
158 coreconfigitem('bundle', 'mainreporoot',
159 default='',
159 default='',
160 )
160 )
161 # bundle.reorder: experimental config
161 # bundle.reorder: experimental config
162 coreconfigitem('bundle', 'reorder',
162 coreconfigitem('bundle', 'reorder',
163 default='auto',
163 default='auto',
164 )
164 )
165 coreconfigitem('censor', 'policy',
165 coreconfigitem('censor', 'policy',
166 default='abort',
166 default='abort',
167 )
167 )
168 coreconfigitem('chgserver', 'idletimeout',
168 coreconfigitem('chgserver', 'idletimeout',
169 default=3600,
169 default=3600,
170 )
170 )
171 coreconfigitem('chgserver', 'skiphash',
171 coreconfigitem('chgserver', 'skiphash',
172 default=False,
172 default=False,
173 )
173 )
174 coreconfigitem('cmdserver', 'log',
174 coreconfigitem('cmdserver', 'log',
175 default=None,
175 default=None,
176 )
176 )
177 coreconfigitem('color', '.*',
177 coreconfigitem('color', '.*',
178 default=None,
178 default=None,
179 generic=True,
179 generic=True,
180 )
180 )
181 coreconfigitem('color', 'mode',
181 coreconfigitem('color', 'mode',
182 default='auto',
182 default='auto',
183 )
183 )
184 coreconfigitem('color', 'pagermode',
184 coreconfigitem('color', 'pagermode',
185 default=dynamicdefault,
185 default=dynamicdefault,
186 )
186 )
187 coreconfigitem('commands', 'show.aliasprefix',
187 coreconfigitem('commands', 'show.aliasprefix',
188 default=list,
188 default=list,
189 )
189 )
190 coreconfigitem('commands', 'status.relative',
190 coreconfigitem('commands', 'status.relative',
191 default=False,
191 default=False,
192 )
192 )
193 coreconfigitem('commands', 'status.skipstates',
193 coreconfigitem('commands', 'status.skipstates',
194 default=[],
194 default=[],
195 )
195 )
196 coreconfigitem('commands', 'status.verbose',
196 coreconfigitem('commands', 'status.verbose',
197 default=False,
197 default=False,
198 )
198 )
199 coreconfigitem('commands', 'update.check',
199 coreconfigitem('commands', 'update.check',
200 default=None,
200 default=None,
201 # Deprecated, remove after 4.4 release
201 # Deprecated, remove after 4.4 release
202 alias=[('experimental', 'updatecheck')]
202 alias=[('experimental', 'updatecheck')]
203 )
203 )
204 coreconfigitem('commands', 'update.requiredest',
204 coreconfigitem('commands', 'update.requiredest',
205 default=False,
205 default=False,
206 )
206 )
207 coreconfigitem('committemplate', '.*',
207 coreconfigitem('committemplate', '.*',
208 default=None,
208 default=None,
209 generic=True,
209 generic=True,
210 )
210 )
211 coreconfigitem('convert', 'cvsps.cache',
211 coreconfigitem('convert', 'cvsps.cache',
212 default=True,
212 default=True,
213 )
213 )
214 coreconfigitem('convert', 'cvsps.fuzz',
214 coreconfigitem('convert', 'cvsps.fuzz',
215 default=60,
215 default=60,
216 )
216 )
217 coreconfigitem('convert', 'cvsps.logencoding',
217 coreconfigitem('convert', 'cvsps.logencoding',
218 default=None,
218 default=None,
219 )
219 )
220 coreconfigitem('convert', 'cvsps.mergefrom',
220 coreconfigitem('convert', 'cvsps.mergefrom',
221 default=None,
221 default=None,
222 )
222 )
223 coreconfigitem('convert', 'cvsps.mergeto',
223 coreconfigitem('convert', 'cvsps.mergeto',
224 default=None,
224 default=None,
225 )
225 )
226 coreconfigitem('convert', 'git.committeractions',
226 coreconfigitem('convert', 'git.committeractions',
227 default=lambda: ['messagedifferent'],
227 default=lambda: ['messagedifferent'],
228 )
228 )
229 coreconfigitem('convert', 'git.extrakeys',
229 coreconfigitem('convert', 'git.extrakeys',
230 default=list,
230 default=list,
231 )
231 )
232 coreconfigitem('convert', 'git.findcopiesharder',
232 coreconfigitem('convert', 'git.findcopiesharder',
233 default=False,
233 default=False,
234 )
234 )
235 coreconfigitem('convert', 'git.remoteprefix',
235 coreconfigitem('convert', 'git.remoteprefix',
236 default='remote',
236 default='remote',
237 )
237 )
238 coreconfigitem('convert', 'git.renamelimit',
238 coreconfigitem('convert', 'git.renamelimit',
239 default=400,
239 default=400,
240 )
240 )
241 coreconfigitem('convert', 'git.saverev',
241 coreconfigitem('convert', 'git.saverev',
242 default=True,
242 default=True,
243 )
243 )
244 coreconfigitem('convert', 'git.similarity',
244 coreconfigitem('convert', 'git.similarity',
245 default=50,
245 default=50,
246 )
246 )
247 coreconfigitem('convert', 'git.skipsubmodules',
247 coreconfigitem('convert', 'git.skipsubmodules',
248 default=False,
248 default=False,
249 )
249 )
250 coreconfigitem('convert', 'hg.clonebranches',
250 coreconfigitem('convert', 'hg.clonebranches',
251 default=False,
251 default=False,
252 )
252 )
253 coreconfigitem('convert', 'hg.ignoreerrors',
253 coreconfigitem('convert', 'hg.ignoreerrors',
254 default=False,
254 default=False,
255 )
255 )
256 coreconfigitem('convert', 'hg.revs',
256 coreconfigitem('convert', 'hg.revs',
257 default=None,
257 default=None,
258 )
258 )
259 coreconfigitem('convert', 'hg.saverev',
259 coreconfigitem('convert', 'hg.saverev',
260 default=False,
260 default=False,
261 )
261 )
262 coreconfigitem('convert', 'hg.sourcename',
262 coreconfigitem('convert', 'hg.sourcename',
263 default=None,
263 default=None,
264 )
264 )
265 coreconfigitem('convert', 'hg.startrev',
265 coreconfigitem('convert', 'hg.startrev',
266 default=None,
266 default=None,
267 )
267 )
268 coreconfigitem('convert', 'hg.tagsbranch',
268 coreconfigitem('convert', 'hg.tagsbranch',
269 default='default',
269 default='default',
270 )
270 )
271 coreconfigitem('convert', 'hg.usebranchnames',
271 coreconfigitem('convert', 'hg.usebranchnames',
272 default=True,
272 default=True,
273 )
273 )
274 coreconfigitem('convert', 'ignoreancestorcheck',
274 coreconfigitem('convert', 'ignoreancestorcheck',
275 default=False,
275 default=False,
276 )
276 )
277 coreconfigitem('convert', 'localtimezone',
277 coreconfigitem('convert', 'localtimezone',
278 default=False,
278 default=False,
279 )
279 )
280 coreconfigitem('convert', 'p4.encoding',
280 coreconfigitem('convert', 'p4.encoding',
281 default=dynamicdefault,
281 default=dynamicdefault,
282 )
282 )
283 coreconfigitem('convert', 'p4.startrev',
283 coreconfigitem('convert', 'p4.startrev',
284 default=0,
284 default=0,
285 )
285 )
286 coreconfigitem('convert', 'skiptags',
286 coreconfigitem('convert', 'skiptags',
287 default=False,
287 default=False,
288 )
288 )
289 coreconfigitem('convert', 'svn.debugsvnlog',
289 coreconfigitem('convert', 'svn.debugsvnlog',
290 default=True,
290 default=True,
291 )
291 )
292 coreconfigitem('convert', 'svn.trunk',
292 coreconfigitem('convert', 'svn.trunk',
293 default=None,
293 default=None,
294 )
294 )
295 coreconfigitem('convert', 'svn.tags',
295 coreconfigitem('convert', 'svn.tags',
296 default=None,
296 default=None,
297 )
297 )
298 coreconfigitem('convert', 'svn.branches',
298 coreconfigitem('convert', 'svn.branches',
299 default=None,
299 default=None,
300 )
300 )
301 coreconfigitem('convert', 'svn.startrev',
301 coreconfigitem('convert', 'svn.startrev',
302 default=0,
302 default=0,
303 )
303 )
304 coreconfigitem('debug', 'dirstate.delaywrite',
304 coreconfigitem('debug', 'dirstate.delaywrite',
305 default=0,
305 default=0,
306 )
306 )
307 coreconfigitem('defaults', '.*',
307 coreconfigitem('defaults', '.*',
308 default=None,
308 default=None,
309 generic=True,
309 generic=True,
310 )
310 )
311 coreconfigitem('devel', 'all-warnings',
311 coreconfigitem('devel', 'all-warnings',
312 default=False,
312 default=False,
313 )
313 )
314 coreconfigitem('devel', 'bundle2.debug',
314 coreconfigitem('devel', 'bundle2.debug',
315 default=False,
315 default=False,
316 )
316 )
317 coreconfigitem('devel', 'cache-vfs',
317 coreconfigitem('devel', 'cache-vfs',
318 default=None,
318 default=None,
319 )
319 )
320 coreconfigitem('devel', 'check-locks',
320 coreconfigitem('devel', 'check-locks',
321 default=False,
321 default=False,
322 )
322 )
323 coreconfigitem('devel', 'check-relroot',
323 coreconfigitem('devel', 'check-relroot',
324 default=False,
324 default=False,
325 )
325 )
326 coreconfigitem('devel', 'default-date',
326 coreconfigitem('devel', 'default-date',
327 default=None,
327 default=None,
328 )
328 )
329 coreconfigitem('devel', 'deprec-warn',
329 coreconfigitem('devel', 'deprec-warn',
330 default=False,
330 default=False,
331 )
331 )
332 coreconfigitem('devel', 'disableloaddefaultcerts',
332 coreconfigitem('devel', 'disableloaddefaultcerts',
333 default=False,
333 default=False,
334 )
334 )
335 coreconfigitem('devel', 'warn-empty-changegroup',
335 coreconfigitem('devel', 'warn-empty-changegroup',
336 default=False,
336 default=False,
337 )
337 )
338 coreconfigitem('devel', 'legacy.exchange',
338 coreconfigitem('devel', 'legacy.exchange',
339 default=list,
339 default=list,
340 )
340 )
341 coreconfigitem('devel', 'servercafile',
341 coreconfigitem('devel', 'servercafile',
342 default='',
342 default='',
343 )
343 )
344 coreconfigitem('devel', 'serverexactprotocol',
344 coreconfigitem('devel', 'serverexactprotocol',
345 default='',
345 default='',
346 )
346 )
347 coreconfigitem('devel', 'serverrequirecert',
347 coreconfigitem('devel', 'serverrequirecert',
348 default=False,
348 default=False,
349 )
349 )
350 coreconfigitem('devel', 'strip-obsmarkers',
350 coreconfigitem('devel', 'strip-obsmarkers',
351 default=True,
351 default=True,
352 )
352 )
353 coreconfigitem('devel', 'warn-config',
353 coreconfigitem('devel', 'warn-config',
354 default=None,
354 default=None,
355 )
355 )
356 coreconfigitem('devel', 'warn-config-default',
356 coreconfigitem('devel', 'warn-config-default',
357 default=None,
357 default=None,
358 )
358 )
359 coreconfigitem('devel', 'user.obsmarker',
359 coreconfigitem('devel', 'user.obsmarker',
360 default=None,
360 default=None,
361 )
361 )
362 coreconfigitem('devel', 'warn-config-unknown',
362 coreconfigitem('devel', 'warn-config-unknown',
363 default=None,
363 default=None,
364 )
364 )
365 coreconfigitem('diff', 'nodates',
365 coreconfigitem('diff', 'nodates',
366 default=False,
366 default=False,
367 )
367 )
368 coreconfigitem('diff', 'showfunc',
368 coreconfigitem('diff', 'showfunc',
369 default=False,
369 default=False,
370 )
370 )
371 coreconfigitem('diff', 'unified',
371 coreconfigitem('diff', 'unified',
372 default=None,
372 default=None,
373 )
373 )
374 coreconfigitem('diff', 'git',
374 coreconfigitem('diff', 'git',
375 default=False,
375 default=False,
376 )
376 )
377 coreconfigitem('diff', 'ignorews',
377 coreconfigitem('diff', 'ignorews',
378 default=False,
378 default=False,
379 )
379 )
380 coreconfigitem('diff', 'ignorewsamount',
380 coreconfigitem('diff', 'ignorewsamount',
381 default=False,
381 default=False,
382 )
382 )
383 coreconfigitem('diff', 'ignoreblanklines',
383 coreconfigitem('diff', 'ignoreblanklines',
384 default=False,
384 default=False,
385 )
385 )
386 coreconfigitem('diff', 'ignorewseol',
386 coreconfigitem('diff', 'ignorewseol',
387 default=False,
387 default=False,
388 )
388 )
389 coreconfigitem('diff', 'nobinary',
389 coreconfigitem('diff', 'nobinary',
390 default=False,
390 default=False,
391 )
391 )
392 coreconfigitem('diff', 'noprefix',
392 coreconfigitem('diff', 'noprefix',
393 default=False,
393 default=False,
394 )
394 )
395 coreconfigitem('email', 'bcc',
395 coreconfigitem('email', 'bcc',
396 default=None,
396 default=None,
397 )
397 )
398 coreconfigitem('email', 'cc',
398 coreconfigitem('email', 'cc',
399 default=None,
399 default=None,
400 )
400 )
401 coreconfigitem('email', 'charsets',
401 coreconfigitem('email', 'charsets',
402 default=list,
402 default=list,
403 )
403 )
404 coreconfigitem('email', 'from',
404 coreconfigitem('email', 'from',
405 default=None,
405 default=None,
406 )
406 )
407 coreconfigitem('email', 'method',
407 coreconfigitem('email', 'method',
408 default='smtp',
408 default='smtp',
409 )
409 )
410 coreconfigitem('email', 'reply-to',
410 coreconfigitem('email', 'reply-to',
411 default=None,
411 default=None,
412 )
412 )
413 coreconfigitem('email', 'to',
413 coreconfigitem('email', 'to',
414 default=None,
414 default=None,
415 )
415 )
416 coreconfigitem('experimental', 'archivemetatemplate',
416 coreconfigitem('experimental', 'archivemetatemplate',
417 default=dynamicdefault,
417 default=dynamicdefault,
418 )
418 )
419 coreconfigitem('experimental', 'bundle-phases',
419 coreconfigitem('experimental', 'bundle-phases',
420 default=False,
420 default=False,
421 )
421 )
422 coreconfigitem('experimental', 'bundle2-advertise',
422 coreconfigitem('experimental', 'bundle2-advertise',
423 default=True,
423 default=True,
424 )
424 )
425 coreconfigitem('experimental', 'bundle2-output-capture',
425 coreconfigitem('experimental', 'bundle2-output-capture',
426 default=False,
426 default=False,
427 )
427 )
428 coreconfigitem('experimental', 'bundle2.pushback',
428 coreconfigitem('experimental', 'bundle2.pushback',
429 default=False,
429 default=False,
430 )
430 )
431 coreconfigitem('experimental', 'bundle2lazylocking',
431 coreconfigitem('experimental', 'bundle2lazylocking',
432 default=False,
432 default=False,
433 )
433 )
434 coreconfigitem('experimental', 'bundlecomplevel',
434 coreconfigitem('experimental', 'bundlecomplevel',
435 default=None,
435 default=None,
436 )
436 )
437 coreconfigitem('experimental', 'changegroup3',
437 coreconfigitem('experimental', 'changegroup3',
438 default=False,
438 default=False,
439 )
439 )
440 coreconfigitem('experimental', 'clientcompressionengines',
440 coreconfigitem('experimental', 'clientcompressionengines',
441 default=list,
441 default=list,
442 )
442 )
443 coreconfigitem('experimental', 'copytrace',
443 coreconfigitem('experimental', 'copytrace',
444 default='on',
444 default='on',
445 )
445 )
446 coreconfigitem('experimental', 'copytrace.movecandidateslimit',
446 coreconfigitem('experimental', 'copytrace.movecandidateslimit',
447 default=100,
447 default=100,
448 )
448 )
449 coreconfigitem('experimental', 'copytrace.sourcecommitlimit',
449 coreconfigitem('experimental', 'copytrace.sourcecommitlimit',
450 default=100,
450 default=100,
451 )
451 )
452 coreconfigitem('experimental', 'crecordtest',
452 coreconfigitem('experimental', 'crecordtest',
453 default=None,
453 default=None,
454 )
454 )
455 coreconfigitem('experimental', 'editortmpinhg',
455 coreconfigitem('experimental', 'editortmpinhg',
456 default=False,
456 default=False,
457 )
457 )
458 coreconfigitem('experimental', 'evolution',
458 coreconfigitem('experimental', 'evolution',
459 default=list,
459 default=list,
460 )
460 )
461 coreconfigitem('experimental', 'evolution.allowdivergence',
461 coreconfigitem('experimental', 'evolution.allowdivergence',
462 default=False,
462 default=False,
463 alias=[('experimental', 'allowdivergence')]
463 alias=[('experimental', 'allowdivergence')]
464 )
464 )
465 coreconfigitem('experimental', 'evolution.allowunstable',
465 coreconfigitem('experimental', 'evolution.allowunstable',
466 default=None,
466 default=None,
467 )
467 )
468 coreconfigitem('experimental', 'evolution.createmarkers',
468 coreconfigitem('experimental', 'evolution.createmarkers',
469 default=None,
469 default=None,
470 )
470 )
471 coreconfigitem('experimental', 'evolution.effect-flags',
471 coreconfigitem('experimental', 'evolution.effect-flags',
472 default=True,
472 default=True,
473 alias=[('experimental', 'effect-flags')]
473 alias=[('experimental', 'effect-flags')]
474 )
474 )
475 coreconfigitem('experimental', 'evolution.exchange',
475 coreconfigitem('experimental', 'evolution.exchange',
476 default=None,
476 default=None,
477 )
477 )
478 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
478 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
479 default=False,
479 default=False,
480 )
480 )
481 coreconfigitem('experimental', 'evolution.track-operation',
481 coreconfigitem('experimental', 'evolution.track-operation',
482 default=True,
482 default=True,
483 )
483 )
484 coreconfigitem('experimental', 'maxdeltachainspan',
484 coreconfigitem('experimental', 'maxdeltachainspan',
485 default=-1,
485 default=-1,
486 )
486 )
487 coreconfigitem('experimental', 'mmapindexthreshold',
487 coreconfigitem('experimental', 'mmapindexthreshold',
488 default=None,
488 default=None,
489 )
489 )
490 coreconfigitem('experimental', 'nonnormalparanoidcheck',
490 coreconfigitem('experimental', 'nonnormalparanoidcheck',
491 default=False,
491 default=False,
492 )
492 )
493 coreconfigitem('experimental', 'exportableenviron',
493 coreconfigitem('experimental', 'exportableenviron',
494 default=list,
494 default=list,
495 )
495 )
496 coreconfigitem('experimental', 'extendedheader.index',
496 coreconfigitem('experimental', 'extendedheader.index',
497 default=None,
497 default=None,
498 )
498 )
499 coreconfigitem('experimental', 'extendedheader.similarity',
499 coreconfigitem('experimental', 'extendedheader.similarity',
500 default=False,
500 default=False,
501 )
501 )
502 coreconfigitem('experimental', 'format.compression',
502 coreconfigitem('experimental', 'format.compression',
503 default='zlib',
503 default='zlib',
504 )
504 )
505 coreconfigitem('experimental', 'graphshorten',
505 coreconfigitem('experimental', 'graphshorten',
506 default=False,
506 default=False,
507 )
507 )
508 coreconfigitem('experimental', 'graphstyle.parent',
508 coreconfigitem('experimental', 'graphstyle.parent',
509 default=dynamicdefault,
509 default=dynamicdefault,
510 )
510 )
511 coreconfigitem('experimental', 'graphstyle.missing',
511 coreconfigitem('experimental', 'graphstyle.missing',
512 default=dynamicdefault,
512 default=dynamicdefault,
513 )
513 )
514 coreconfigitem('experimental', 'graphstyle.grandparent',
514 coreconfigitem('experimental', 'graphstyle.grandparent',
515 default=dynamicdefault,
515 default=dynamicdefault,
516 )
516 )
517 coreconfigitem('experimental', 'hook-track-tags',
517 coreconfigitem('experimental', 'hook-track-tags',
518 default=False,
518 default=False,
519 )
519 )
520 coreconfigitem('experimental', 'httppostargs',
520 coreconfigitem('experimental', 'httppostargs',
521 default=False,
521 default=False,
522 )
522 )
523 coreconfigitem('experimental', 'manifestv2',
523 coreconfigitem('experimental', 'manifestv2',
524 default=False,
524 default=False,
525 )
525 )
526 coreconfigitem('experimental', 'mergedriver',
526 coreconfigitem('experimental', 'mergedriver',
527 default=None,
527 default=None,
528 )
528 )
529 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
529 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
530 default=False,
530 default=False,
531 )
531 )
532 coreconfigitem('experimental', 'rebase.multidest',
532 coreconfigitem('experimental', 'rebase.multidest',
533 default=False,
533 default=False,
534 )
534 )
535 coreconfigitem('experimental', 'revlogv2',
535 coreconfigitem('experimental', 'revlogv2',
536 default=None,
536 default=None,
537 )
537 )
538 coreconfigitem('experimental', 'single-head-per-branch',
538 coreconfigitem('experimental', 'single-head-per-branch',
539 default=False,
539 default=False,
540 )
540 )
541 coreconfigitem('experimental', 'spacemovesdown',
541 coreconfigitem('experimental', 'spacemovesdown',
542 default=False,
542 default=False,
543 )
543 )
544 coreconfigitem('experimental', 'sparse-read',
544 coreconfigitem('experimental', 'sparse-read',
545 default=False,
545 default=False,
546 )
546 )
547 coreconfigitem('experimental', 'sparse-read.density-threshold',
547 coreconfigitem('experimental', 'sparse-read.density-threshold',
548 default=0.25,
548 default=0.25,
549 )
549 )
550 coreconfigitem('experimental', 'sparse-read.min-gap-size',
550 coreconfigitem('experimental', 'sparse-read.min-gap-size',
551 default='256K',
551 default='256K',
552 )
552 )
553 coreconfigitem('experimental', 'treemanifest',
553 coreconfigitem('experimental', 'treemanifest',
554 default=False,
554 default=False,
555 )
555 )
556 coreconfigitem('extensions', '.*',
556 coreconfigitem('extensions', '.*',
557 default=None,
557 default=None,
558 generic=True,
558 generic=True,
559 )
559 )
560 coreconfigitem('extdata', '.*',
560 coreconfigitem('extdata', '.*',
561 default=None,
561 default=None,
562 generic=True,
562 generic=True,
563 )
563 )
564 coreconfigitem('format', 'aggressivemergedeltas',
564 coreconfigitem('format', 'aggressivemergedeltas',
565 default=False,
565 default=False,
566 )
566 )
567 coreconfigitem('format', 'chunkcachesize',
567 coreconfigitem('format', 'chunkcachesize',
568 default=None,
568 default=None,
569 )
569 )
570 coreconfigitem('format', 'dotencode',
570 coreconfigitem('format', 'dotencode',
571 default=True,
571 default=True,
572 )
572 )
573 coreconfigitem('format', 'generaldelta',
573 coreconfigitem('format', 'generaldelta',
574 default=False,
574 default=False,
575 )
575 )
576 coreconfigitem('format', 'manifestcachesize',
576 coreconfigitem('format', 'manifestcachesize',
577 default=None,
577 default=None,
578 )
578 )
579 coreconfigitem('format', 'maxchainlen',
579 coreconfigitem('format', 'maxchainlen',
580 default=None,
580 default=None,
581 )
581 )
582 coreconfigitem('format', 'obsstore-version',
582 coreconfigitem('format', 'obsstore-version',
583 default=None,
583 default=None,
584 )
584 )
585 coreconfigitem('format', 'usefncache',
585 coreconfigitem('format', 'usefncache',
586 default=True,
586 default=True,
587 )
587 )
588 coreconfigitem('format', 'usegeneraldelta',
588 coreconfigitem('format', 'usegeneraldelta',
589 default=True,
589 default=True,
590 )
590 )
591 coreconfigitem('format', 'usestore',
591 coreconfigitem('format', 'usestore',
592 default=True,
592 default=True,
593 )
593 )
594 coreconfigitem('fsmonitor', 'warn_when_unused',
594 coreconfigitem('fsmonitor', 'warn_when_unused',
595 default=True,
595 default=True,
596 )
596 )
597 coreconfigitem('fsmonitor', 'warn_update_file_count',
597 coreconfigitem('fsmonitor', 'warn_update_file_count',
598 default=50000,
598 default=50000,
599 )
599 )
600 coreconfigitem('hooks', '.*',
600 coreconfigitem('hooks', '.*',
601 default=dynamicdefault,
601 default=dynamicdefault,
602 generic=True,
602 generic=True,
603 )
603 )
604 coreconfigitem('hgweb-paths', '.*',
604 coreconfigitem('hgweb-paths', '.*',
605 default=list,
605 default=list,
606 generic=True,
606 generic=True,
607 )
607 )
608 coreconfigitem('hostfingerprints', '.*',
608 coreconfigitem('hostfingerprints', '.*',
609 default=list,
609 default=list,
610 generic=True,
610 generic=True,
611 )
611 )
612 coreconfigitem('hostsecurity', 'ciphers',
612 coreconfigitem('hostsecurity', 'ciphers',
613 default=None,
613 default=None,
614 )
614 )
615 coreconfigitem('hostsecurity', 'disabletls10warning',
615 coreconfigitem('hostsecurity', 'disabletls10warning',
616 default=False,
616 default=False,
617 )
617 )
618 coreconfigitem('hostsecurity', 'minimumprotocol',
618 coreconfigitem('hostsecurity', 'minimumprotocol',
619 default=dynamicdefault,
619 default=dynamicdefault,
620 )
620 )
621 coreconfigitem('hostsecurity', '.*:minimumprotocol$',
621 coreconfigitem('hostsecurity', '.*:minimumprotocol$',
622 default=dynamicdefault,
622 default=dynamicdefault,
623 generic=True,
623 generic=True,
624 )
624 )
625 coreconfigitem('hostsecurity', '.*:ciphers$',
625 coreconfigitem('hostsecurity', '.*:ciphers$',
626 default=dynamicdefault,
626 default=dynamicdefault,
627 generic=True,
627 generic=True,
628 )
628 )
629 coreconfigitem('hostsecurity', '.*:fingerprints$',
629 coreconfigitem('hostsecurity', '.*:fingerprints$',
630 default=list,
630 default=list,
631 generic=True,
631 generic=True,
632 )
632 )
633 coreconfigitem('hostsecurity', '.*:verifycertsfile$',
633 coreconfigitem('hostsecurity', '.*:verifycertsfile$',
634 default=None,
634 default=None,
635 generic=True,
635 generic=True,
636 )
636 )
637
637
638 coreconfigitem('http_proxy', 'always',
638 coreconfigitem('http_proxy', 'always',
639 default=False,
639 default=False,
640 )
640 )
641 coreconfigitem('http_proxy', 'host',
641 coreconfigitem('http_proxy', 'host',
642 default=None,
642 default=None,
643 )
643 )
644 coreconfigitem('http_proxy', 'no',
644 coreconfigitem('http_proxy', 'no',
645 default=list,
645 default=list,
646 )
646 )
647 coreconfigitem('http_proxy', 'passwd',
647 coreconfigitem('http_proxy', 'passwd',
648 default=None,
648 default=None,
649 )
649 )
650 coreconfigitem('http_proxy', 'user',
650 coreconfigitem('http_proxy', 'user',
651 default=None,
651 default=None,
652 )
652 )
653 coreconfigitem('logtoprocess', 'commandexception',
653 coreconfigitem('logtoprocess', 'commandexception',
654 default=None,
654 default=None,
655 )
655 )
656 coreconfigitem('logtoprocess', 'commandfinish',
656 coreconfigitem('logtoprocess', 'commandfinish',
657 default=None,
657 default=None,
658 )
658 )
659 coreconfigitem('logtoprocess', 'command',
659 coreconfigitem('logtoprocess', 'command',
660 default=None,
660 default=None,
661 )
661 )
662 coreconfigitem('logtoprocess', 'develwarn',
662 coreconfigitem('logtoprocess', 'develwarn',
663 default=None,
663 default=None,
664 )
664 )
665 coreconfigitem('logtoprocess', 'uiblocked',
665 coreconfigitem('logtoprocess', 'uiblocked',
666 default=None,
666 default=None,
667 )
667 )
668 coreconfigitem('merge', 'checkunknown',
668 coreconfigitem('merge', 'checkunknown',
669 default='abort',
669 default='abort',
670 )
670 )
671 coreconfigitem('merge', 'checkignored',
671 coreconfigitem('merge', 'checkignored',
672 default='abort',
672 default='abort',
673 )
673 )
674 coreconfigitem('experimental', 'merge.checkpathconflicts',
674 coreconfigitem('experimental', 'merge.checkpathconflicts',
675 default=False,
675 default=False,
676 )
676 )
677 coreconfigitem('merge', 'followcopies',
677 coreconfigitem('merge', 'followcopies',
678 default=True,
678 default=True,
679 )
679 )
680 coreconfigitem('merge', 'on-failure',
680 coreconfigitem('merge', 'on-failure',
681 default='continue',
681 default='continue',
682 )
682 )
683 coreconfigitem('merge', 'preferancestor',
683 coreconfigitem('merge', 'preferancestor',
684 default=lambda: ['*'],
684 default=lambda: ['*'],
685 )
685 )
686 coreconfigitem('merge-tools', '.*',
686 coreconfigitem('merge-tools', '.*',
687 default=None,
687 default=None,
688 generic=True,
688 generic=True,
689 )
689 )
690 coreconfigitem('merge-tools', br'.*\.args$',
690 coreconfigitem('merge-tools', br'.*\.args$',
691 default="$local $base $other",
691 default="$local $base $other",
692 generic=True,
692 generic=True,
693 priority=-1,
693 priority=-1,
694 )
694 )
695 coreconfigitem('merge-tools', br'.*\.binary$',
695 coreconfigitem('merge-tools', br'.*\.binary$',
696 default=False,
696 default=False,
697 generic=True,
697 generic=True,
698 priority=-1,
698 priority=-1,
699 )
699 )
700 coreconfigitem('merge-tools', br'.*\.check$',
700 coreconfigitem('merge-tools', br'.*\.check$',
701 default=list,
701 default=list,
702 generic=True,
702 generic=True,
703 priority=-1,
703 priority=-1,
704 )
704 )
705 coreconfigitem('merge-tools', br'.*\.checkchanged$',
705 coreconfigitem('merge-tools', br'.*\.checkchanged$',
706 default=False,
706 default=False,
707 generic=True,
707 generic=True,
708 priority=-1,
708 priority=-1,
709 )
709 )
710 coreconfigitem('merge-tools', br'.*\.executable$',
710 coreconfigitem('merge-tools', br'.*\.executable$',
711 default=dynamicdefault,
711 default=dynamicdefault,
712 generic=True,
712 generic=True,
713 priority=-1,
713 priority=-1,
714 )
714 )
715 coreconfigitem('merge-tools', br'.*\.fixeol$',
715 coreconfigitem('merge-tools', br'.*\.fixeol$',
716 default=False,
716 default=False,
717 generic=True,
717 generic=True,
718 priority=-1,
718 priority=-1,
719 )
719 )
720 coreconfigitem('merge-tools', br'.*\.gui$',
720 coreconfigitem('merge-tools', br'.*\.gui$',
721 default=False,
721 default=False,
722 generic=True,
722 generic=True,
723 priority=-1,
723 priority=-1,
724 )
724 )
725 coreconfigitem('merge-tools', br'.*\.priority$',
725 coreconfigitem('merge-tools', br'.*\.priority$',
726 default=0,
726 default=0,
727 generic=True,
727 generic=True,
728 priority=-1,
728 priority=-1,
729 )
729 )
730 coreconfigitem('merge-tools', br'.*\.premerge$',
730 coreconfigitem('merge-tools', br'.*\.premerge$',
731 default=dynamicdefault,
731 default=dynamicdefault,
732 generic=True,
732 generic=True,
733 priority=-1,
733 priority=-1,
734 )
734 )
735 coreconfigitem('merge-tools', br'.*\.symlink$',
735 coreconfigitem('merge-tools', br'.*\.symlink$',
736 default=False,
736 default=False,
737 generic=True,
737 generic=True,
738 priority=-1,
738 priority=-1,
739 )
739 )
740 coreconfigitem('pager', 'attend-.*',
740 coreconfigitem('pager', 'attend-.*',
741 default=dynamicdefault,
741 default=dynamicdefault,
742 generic=True,
742 generic=True,
743 )
743 )
744 coreconfigitem('pager', 'ignore',
744 coreconfigitem('pager', 'ignore',
745 default=list,
745 default=list,
746 )
746 )
747 coreconfigitem('pager', 'pager',
747 coreconfigitem('pager', 'pager',
748 default=dynamicdefault,
748 default=dynamicdefault,
749 )
749 )
750 coreconfigitem('patch', 'eol',
750 coreconfigitem('patch', 'eol',
751 default='strict',
751 default='strict',
752 )
752 )
753 coreconfigitem('patch', 'fuzz',
753 coreconfigitem('patch', 'fuzz',
754 default=2,
754 default=2,
755 )
755 )
756 coreconfigitem('paths', 'default',
756 coreconfigitem('paths', 'default',
757 default=None,
757 default=None,
758 )
758 )
759 coreconfigitem('paths', 'default-push',
759 coreconfigitem('paths', 'default-push',
760 default=None,
760 default=None,
761 )
761 )
762 coreconfigitem('paths', '.*',
762 coreconfigitem('paths', '.*',
763 default=None,
763 default=None,
764 generic=True,
764 generic=True,
765 )
765 )
766 coreconfigitem('phases', 'checksubrepos',
766 coreconfigitem('phases', 'checksubrepos',
767 default='follow',
767 default='follow',
768 )
768 )
769 coreconfigitem('phases', 'new-commit',
769 coreconfigitem('phases', 'new-commit',
770 default='draft',
770 default='draft',
771 )
771 )
772 coreconfigitem('phases', 'publish',
772 coreconfigitem('phases', 'publish',
773 default=True,
773 default=True,
774 )
774 )
775 coreconfigitem('profiling', 'enabled',
775 coreconfigitem('profiling', 'enabled',
776 default=False,
776 default=False,
777 )
777 )
778 coreconfigitem('profiling', 'format',
778 coreconfigitem('profiling', 'format',
779 default='text',
779 default='text',
780 )
780 )
781 coreconfigitem('profiling', 'freq',
781 coreconfigitem('profiling', 'freq',
782 default=1000,
782 default=1000,
783 )
783 )
784 coreconfigitem('profiling', 'limit',
784 coreconfigitem('profiling', 'limit',
785 default=30,
785 default=30,
786 )
786 )
787 coreconfigitem('profiling', 'nested',
787 coreconfigitem('profiling', 'nested',
788 default=0,
788 default=0,
789 )
789 )
790 coreconfigitem('profiling', 'output',
790 coreconfigitem('profiling', 'output',
791 default=None,
791 default=None,
792 )
792 )
793 coreconfigitem('profiling', 'showmax',
793 coreconfigitem('profiling', 'showmax',
794 default=0.999,
794 default=0.999,
795 )
795 )
796 coreconfigitem('profiling', 'showmin',
796 coreconfigitem('profiling', 'showmin',
797 default=dynamicdefault,
797 default=dynamicdefault,
798 )
798 )
799 coreconfigitem('profiling', 'sort',
799 coreconfigitem('profiling', 'sort',
800 default='inlinetime',
800 default='inlinetime',
801 )
801 )
802 coreconfigitem('profiling', 'statformat',
802 coreconfigitem('profiling', 'statformat',
803 default='hotpath',
803 default='hotpath',
804 )
804 )
805 coreconfigitem('profiling', 'type',
805 coreconfigitem('profiling', 'type',
806 default='stat',
806 default='stat',
807 )
807 )
808 coreconfigitem('progress', 'assume-tty',
808 coreconfigitem('progress', 'assume-tty',
809 default=False,
809 default=False,
810 )
810 )
811 coreconfigitem('progress', 'changedelay',
811 coreconfigitem('progress', 'changedelay',
812 default=1,
812 default=1,
813 )
813 )
814 coreconfigitem('progress', 'clear-complete',
814 coreconfigitem('progress', 'clear-complete',
815 default=True,
815 default=True,
816 )
816 )
817 coreconfigitem('progress', 'debug',
817 coreconfigitem('progress', 'debug',
818 default=False,
818 default=False,
819 )
819 )
820 coreconfigitem('progress', 'delay',
820 coreconfigitem('progress', 'delay',
821 default=3,
821 default=3,
822 )
822 )
823 coreconfigitem('progress', 'disable',
823 coreconfigitem('progress', 'disable',
824 default=False,
824 default=False,
825 )
825 )
826 coreconfigitem('progress', 'estimateinterval',
826 coreconfigitem('progress', 'estimateinterval',
827 default=60.0,
827 default=60.0,
828 )
828 )
829 coreconfigitem('progress', 'format',
829 coreconfigitem('progress', 'format',
830 default=lambda: ['topic', 'bar', 'number', 'estimate'],
830 default=lambda: ['topic', 'bar', 'number', 'estimate'],
831 )
831 )
832 coreconfigitem('progress', 'refresh',
832 coreconfigitem('progress', 'refresh',
833 default=0.1,
833 default=0.1,
834 )
834 )
835 coreconfigitem('progress', 'width',
835 coreconfigitem('progress', 'width',
836 default=dynamicdefault,
836 default=dynamicdefault,
837 )
837 )
838 coreconfigitem('push', 'pushvars.server',
838 coreconfigitem('push', 'pushvars.server',
839 default=False,
839 default=False,
840 )
840 )
841 coreconfigitem('server', 'bundle1',
841 coreconfigitem('server', 'bundle1',
842 default=True,
842 default=True,
843 )
843 )
844 coreconfigitem('server', 'bundle1gd',
844 coreconfigitem('server', 'bundle1gd',
845 default=None,
845 default=None,
846 )
846 )
847 coreconfigitem('server', 'bundle1.pull',
847 coreconfigitem('server', 'bundle1.pull',
848 default=None,
848 default=None,
849 )
849 )
850 coreconfigitem('server', 'bundle1gd.pull',
850 coreconfigitem('server', 'bundle1gd.pull',
851 default=None,
851 default=None,
852 )
852 )
853 coreconfigitem('server', 'bundle1.push',
853 coreconfigitem('server', 'bundle1.push',
854 default=None,
854 default=None,
855 )
855 )
856 coreconfigitem('server', 'bundle1gd.push',
856 coreconfigitem('server', 'bundle1gd.push',
857 default=None,
857 default=None,
858 )
858 )
859 coreconfigitem('server', 'compressionengines',
859 coreconfigitem('server', 'compressionengines',
860 default=list,
860 default=list,
861 )
861 )
862 coreconfigitem('server', 'concurrent-push-mode',
862 coreconfigitem('server', 'concurrent-push-mode',
863 default='strict',
863 default='strict',
864 )
864 )
865 coreconfigitem('server', 'disablefullbundle',
865 coreconfigitem('server', 'disablefullbundle',
866 default=False,
866 default=False,
867 )
867 )
868 coreconfigitem('server', 'maxhttpheaderlen',
868 coreconfigitem('server', 'maxhttpheaderlen',
869 default=1024,
869 default=1024,
870 )
870 )
871 coreconfigitem('server', 'preferuncompressed',
871 coreconfigitem('server', 'preferuncompressed',
872 default=False,
872 default=False,
873 )
873 )
874 coreconfigitem('server', 'uncompressed',
874 coreconfigitem('server', 'uncompressed',
875 default=True,
875 default=True,
876 )
876 )
877 coreconfigitem('server', 'uncompressedallowsecret',
877 coreconfigitem('server', 'uncompressedallowsecret',
878 default=False,
878 default=False,
879 )
879 )
880 coreconfigitem('server', 'validate',
880 coreconfigitem('server', 'validate',
881 default=False,
881 default=False,
882 )
882 )
883 coreconfigitem('server', 'zliblevel',
883 coreconfigitem('server', 'zliblevel',
884 default=-1,
884 default=-1,
885 )
885 )
886 coreconfigitem('share', 'pool',
886 coreconfigitem('share', 'pool',
887 default=None,
887 default=None,
888 )
888 )
889 coreconfigitem('share', 'poolnaming',
889 coreconfigitem('share', 'poolnaming',
890 default='identity',
890 default='identity',
891 )
891 )
892 coreconfigitem('smtp', 'host',
892 coreconfigitem('smtp', 'host',
893 default=None,
893 default=None,
894 )
894 )
895 coreconfigitem('smtp', 'local_hostname',
895 coreconfigitem('smtp', 'local_hostname',
896 default=None,
896 default=None,
897 )
897 )
898 coreconfigitem('smtp', 'password',
898 coreconfigitem('smtp', 'password',
899 default=None,
899 default=None,
900 )
900 )
901 coreconfigitem('smtp', 'port',
901 coreconfigitem('smtp', 'port',
902 default=dynamicdefault,
902 default=dynamicdefault,
903 )
903 )
904 coreconfigitem('smtp', 'tls',
904 coreconfigitem('smtp', 'tls',
905 default='none',
905 default='none',
906 )
906 )
907 coreconfigitem('smtp', 'username',
907 coreconfigitem('smtp', 'username',
908 default=None,
908 default=None,
909 )
909 )
910 coreconfigitem('sparse', 'missingwarning',
910 coreconfigitem('sparse', 'missingwarning',
911 default=True,
911 default=True,
912 )
912 )
913 coreconfigitem('subrepos', 'allowed',
913 coreconfigitem('subrepos', 'allowed',
914 default=dynamicdefault, # to make backporting simpler
914 default=dynamicdefault, # to make backporting simpler
915 )
915 )
916 coreconfigitem('subrepos', 'hg:allowed',
916 coreconfigitem('subrepos', 'hg:allowed',
917 default=dynamicdefault,
917 default=dynamicdefault,
918 )
918 )
919 coreconfigitem('subrepos', 'git:allowed',
919 coreconfigitem('subrepos', 'git:allowed',
920 default=dynamicdefault,
920 default=dynamicdefault,
921 )
921 )
922 coreconfigitem('subrepos', 'svn:allowed',
922 coreconfigitem('subrepos', 'svn:allowed',
923 default=dynamicdefault,
923 default=dynamicdefault,
924 )
924 )
925 coreconfigitem('templates', '.*',
925 coreconfigitem('templates', '.*',
926 default=None,
926 default=None,
927 generic=True,
927 generic=True,
928 )
928 )
929 coreconfigitem('trusted', 'groups',
929 coreconfigitem('trusted', 'groups',
930 default=list,
930 default=list,
931 )
931 )
932 coreconfigitem('trusted', 'users',
932 coreconfigitem('trusted', 'users',
933 default=list,
933 default=list,
934 )
934 )
935 coreconfigitem('ui', '_usedassubrepo',
935 coreconfigitem('ui', '_usedassubrepo',
936 default=False,
936 default=False,
937 )
937 )
938 coreconfigitem('ui', 'allowemptycommit',
938 coreconfigitem('ui', 'allowemptycommit',
939 default=False,
939 default=False,
940 )
940 )
941 coreconfigitem('ui', 'archivemeta',
941 coreconfigitem('ui', 'archivemeta',
942 default=True,
942 default=True,
943 )
943 )
944 coreconfigitem('ui', 'askusername',
944 coreconfigitem('ui', 'askusername',
945 default=False,
945 default=False,
946 )
946 )
947 coreconfigitem('ui', 'clonebundlefallback',
947 coreconfigitem('ui', 'clonebundlefallback',
948 default=False,
948 default=False,
949 )
949 )
950 coreconfigitem('ui', 'clonebundleprefers',
950 coreconfigitem('ui', 'clonebundleprefers',
951 default=list,
951 default=list,
952 )
952 )
953 coreconfigitem('ui', 'clonebundles',
953 coreconfigitem('ui', 'clonebundles',
954 default=True,
954 default=True,
955 )
955 )
956 coreconfigitem('ui', 'color',
956 coreconfigitem('ui', 'color',
957 default='auto',
957 default='auto',
958 )
958 )
959 coreconfigitem('ui', 'commitsubrepos',
959 coreconfigitem('ui', 'commitsubrepos',
960 default=False,
960 default=False,
961 )
961 )
962 coreconfigitem('ui', 'debug',
962 coreconfigitem('ui', 'debug',
963 default=False,
963 default=False,
964 )
964 )
965 coreconfigitem('ui', 'debugger',
965 coreconfigitem('ui', 'debugger',
966 default=None,
966 default=None,
967 )
967 )
968 coreconfigitem('ui', 'editor',
968 coreconfigitem('ui', 'editor',
969 default=dynamicdefault,
969 default=dynamicdefault,
970 )
970 )
971 coreconfigitem('ui', 'fallbackencoding',
971 coreconfigitem('ui', 'fallbackencoding',
972 default=None,
972 default=None,
973 )
973 )
974 coreconfigitem('ui', 'forcecwd',
974 coreconfigitem('ui', 'forcecwd',
975 default=None,
975 default=None,
976 )
976 )
977 coreconfigitem('ui', 'forcemerge',
977 coreconfigitem('ui', 'forcemerge',
978 default=None,
978 default=None,
979 )
979 )
980 coreconfigitem('ui', 'formatdebug',
980 coreconfigitem('ui', 'formatdebug',
981 default=False,
981 default=False,
982 )
982 )
983 coreconfigitem('ui', 'formatjson',
983 coreconfigitem('ui', 'formatjson',
984 default=False,
984 default=False,
985 )
985 )
986 coreconfigitem('ui', 'formatted',
986 coreconfigitem('ui', 'formatted',
987 default=None,
987 default=None,
988 )
988 )
989 coreconfigitem('ui', 'graphnodetemplate',
989 coreconfigitem('ui', 'graphnodetemplate',
990 default=None,
990 default=None,
991 )
991 )
992 coreconfigitem('ui', 'http2debuglevel',
992 coreconfigitem('ui', 'http2debuglevel',
993 default=None,
993 default=None,
994 )
994 )
995 coreconfigitem('ui', 'interactive',
995 coreconfigitem('ui', 'interactive',
996 default=None,
996 default=None,
997 )
997 )
998 coreconfigitem('ui', 'interface',
998 coreconfigitem('ui', 'interface',
999 default=None,
999 default=None,
1000 )
1000 )
1001 coreconfigitem('ui', 'interface.chunkselector',
1001 coreconfigitem('ui', 'interface.chunkselector',
1002 default=None,
1002 default=None,
1003 )
1003 )
1004 coreconfigitem('ui', 'logblockedtimes',
1004 coreconfigitem('ui', 'logblockedtimes',
1005 default=False,
1005 default=False,
1006 )
1006 )
1007 coreconfigitem('ui', 'logtemplate',
1007 coreconfigitem('ui', 'logtemplate',
1008 default=None,
1008 default=None,
1009 )
1009 )
1010 coreconfigitem('ui', 'merge',
1010 coreconfigitem('ui', 'merge',
1011 default=None,
1011 default=None,
1012 )
1012 )
1013 coreconfigitem('ui', 'mergemarkers',
1013 coreconfigitem('ui', 'mergemarkers',
1014 default='basic',
1014 default='basic',
1015 )
1015 )
1016 coreconfigitem('ui', 'mergemarkertemplate',
1016 coreconfigitem('ui', 'mergemarkertemplate',
1017 default=('{node|short} '
1017 default=('{node|short} '
1018 '{ifeq(tags, "tip", "", '
1018 '{ifeq(tags, "tip", "", '
1019 'ifeq(tags, "", "", "{tags} "))}'
1019 'ifeq(tags, "", "", "{tags} "))}'
1020 '{if(bookmarks, "{bookmarks} ")}'
1020 '{if(bookmarks, "{bookmarks} ")}'
1021 '{ifeq(branch, "default", "", "{branch} ")}'
1021 '{ifeq(branch, "default", "", "{branch} ")}'
1022 '- {author|user}: {desc|firstline}')
1022 '- {author|user}: {desc|firstline}')
1023 )
1023 )
1024 coreconfigitem('ui', 'nontty',
1024 coreconfigitem('ui', 'nontty',
1025 default=False,
1025 default=False,
1026 )
1026 )
1027 coreconfigitem('ui', 'origbackuppath',
1027 coreconfigitem('ui', 'origbackuppath',
1028 default=None,
1028 default=None,
1029 )
1029 )
1030 coreconfigitem('ui', 'paginate',
1030 coreconfigitem('ui', 'paginate',
1031 default=True,
1031 default=True,
1032 )
1032 )
1033 coreconfigitem('ui', 'patch',
1033 coreconfigitem('ui', 'patch',
1034 default=None,
1034 default=None,
1035 )
1035 )
1036 coreconfigitem('ui', 'portablefilenames',
1036 coreconfigitem('ui', 'portablefilenames',
1037 default='warn',
1037 default='warn',
1038 )
1038 )
1039 coreconfigitem('ui', 'promptecho',
1039 coreconfigitem('ui', 'promptecho',
1040 default=False,
1040 default=False,
1041 )
1041 )
1042 coreconfigitem('ui', 'quiet',
1042 coreconfigitem('ui', 'quiet',
1043 default=False,
1043 default=False,
1044 )
1044 )
1045 coreconfigitem('ui', 'quietbookmarkmove',
1045 coreconfigitem('ui', 'quietbookmarkmove',
1046 default=False,
1046 default=False,
1047 )
1047 )
1048 coreconfigitem('ui', 'remotecmd',
1048 coreconfigitem('ui', 'remotecmd',
1049 default='hg',
1049 default='hg',
1050 )
1050 )
1051 coreconfigitem('ui', 'report_untrusted',
1051 coreconfigitem('ui', 'report_untrusted',
1052 default=True,
1052 default=True,
1053 )
1053 )
1054 coreconfigitem('ui', 'rollback',
1054 coreconfigitem('ui', 'rollback',
1055 default=True,
1055 default=True,
1056 )
1056 )
1057 coreconfigitem('ui', 'slash',
1057 coreconfigitem('ui', 'slash',
1058 default=False,
1058 default=False,
1059 )
1059 )
1060 coreconfigitem('ui', 'ssh',
1060 coreconfigitem('ui', 'ssh',
1061 default='ssh',
1061 default='ssh',
1062 )
1062 )
1063 coreconfigitem('ui', 'ssherrorhint',
1063 coreconfigitem('ui', 'ssherrorhint',
1064 default=None,
1064 default=None,
1065 )
1065 )
1066 coreconfigitem('ui', 'statuscopies',
1066 coreconfigitem('ui', 'statuscopies',
1067 default=False,
1067 default=False,
1068 )
1068 )
1069 coreconfigitem('ui', 'strict',
1069 coreconfigitem('ui', 'strict',
1070 default=False,
1070 default=False,
1071 )
1071 )
1072 coreconfigitem('ui', 'style',
1072 coreconfigitem('ui', 'style',
1073 default='',
1073 default='',
1074 )
1074 )
1075 coreconfigitem('ui', 'supportcontact',
1075 coreconfigitem('ui', 'supportcontact',
1076 default=None,
1076 default=None,
1077 )
1077 )
1078 coreconfigitem('ui', 'textwidth',
1078 coreconfigitem('ui', 'textwidth',
1079 default=78,
1079 default=78,
1080 )
1080 )
1081 coreconfigitem('ui', 'timeout',
1081 coreconfigitem('ui', 'timeout',
1082 default='600',
1082 default='600',
1083 )
1083 )
1084 coreconfigitem('ui', 'timeout.warn',
1085 default=0,
1086 )
1084 coreconfigitem('ui', 'traceback',
1087 coreconfigitem('ui', 'traceback',
1085 default=False,
1088 default=False,
1086 )
1089 )
1087 coreconfigitem('ui', 'tweakdefaults',
1090 coreconfigitem('ui', 'tweakdefaults',
1088 default=False,
1091 default=False,
1089 )
1092 )
1090 coreconfigitem('ui', 'usehttp2',
1093 coreconfigitem('ui', 'usehttp2',
1091 default=False,
1094 default=False,
1092 )
1095 )
1093 coreconfigitem('ui', 'username',
1096 coreconfigitem('ui', 'username',
1094 alias=[('ui', 'user')]
1097 alias=[('ui', 'user')]
1095 )
1098 )
1096 coreconfigitem('ui', 'verbose',
1099 coreconfigitem('ui', 'verbose',
1097 default=False,
1100 default=False,
1098 )
1101 )
1099 coreconfigitem('verify', 'skipflags',
1102 coreconfigitem('verify', 'skipflags',
1100 default=None,
1103 default=None,
1101 )
1104 )
1102 coreconfigitem('web', 'allowbz2',
1105 coreconfigitem('web', 'allowbz2',
1103 default=False,
1106 default=False,
1104 )
1107 )
1105 coreconfigitem('web', 'allowgz',
1108 coreconfigitem('web', 'allowgz',
1106 default=False,
1109 default=False,
1107 )
1110 )
1108 coreconfigitem('web', 'allow-pull',
1111 coreconfigitem('web', 'allow-pull',
1109 alias=[('web', 'allowpull')],
1112 alias=[('web', 'allowpull')],
1110 default=True,
1113 default=True,
1111 )
1114 )
1112 coreconfigitem('web', 'allow-push',
1115 coreconfigitem('web', 'allow-push',
1113 alias=[('web', 'allow_push')],
1116 alias=[('web', 'allow_push')],
1114 default=list,
1117 default=list,
1115 )
1118 )
1116 coreconfigitem('web', 'allowzip',
1119 coreconfigitem('web', 'allowzip',
1117 default=False,
1120 default=False,
1118 )
1121 )
1119 coreconfigitem('web', 'archivesubrepos',
1122 coreconfigitem('web', 'archivesubrepos',
1120 default=False,
1123 default=False,
1121 )
1124 )
1122 coreconfigitem('web', 'cache',
1125 coreconfigitem('web', 'cache',
1123 default=True,
1126 default=True,
1124 )
1127 )
1125 coreconfigitem('web', 'contact',
1128 coreconfigitem('web', 'contact',
1126 default=None,
1129 default=None,
1127 )
1130 )
1128 coreconfigitem('web', 'deny_push',
1131 coreconfigitem('web', 'deny_push',
1129 default=list,
1132 default=list,
1130 )
1133 )
1131 coreconfigitem('web', 'guessmime',
1134 coreconfigitem('web', 'guessmime',
1132 default=False,
1135 default=False,
1133 )
1136 )
1134 coreconfigitem('web', 'hidden',
1137 coreconfigitem('web', 'hidden',
1135 default=False,
1138 default=False,
1136 )
1139 )
1137 coreconfigitem('web', 'labels',
1140 coreconfigitem('web', 'labels',
1138 default=list,
1141 default=list,
1139 )
1142 )
1140 coreconfigitem('web', 'logoimg',
1143 coreconfigitem('web', 'logoimg',
1141 default='hglogo.png',
1144 default='hglogo.png',
1142 )
1145 )
1143 coreconfigitem('web', 'logourl',
1146 coreconfigitem('web', 'logourl',
1144 default='https://mercurial-scm.org/',
1147 default='https://mercurial-scm.org/',
1145 )
1148 )
1146 coreconfigitem('web', 'accesslog',
1149 coreconfigitem('web', 'accesslog',
1147 default='-',
1150 default='-',
1148 )
1151 )
1149 coreconfigitem('web', 'address',
1152 coreconfigitem('web', 'address',
1150 default='',
1153 default='',
1151 )
1154 )
1152 coreconfigitem('web', 'allow_archive',
1155 coreconfigitem('web', 'allow_archive',
1153 default=list,
1156 default=list,
1154 )
1157 )
1155 coreconfigitem('web', 'allow_read',
1158 coreconfigitem('web', 'allow_read',
1156 default=list,
1159 default=list,
1157 )
1160 )
1158 coreconfigitem('web', 'baseurl',
1161 coreconfigitem('web', 'baseurl',
1159 default=None,
1162 default=None,
1160 )
1163 )
1161 coreconfigitem('web', 'cacerts',
1164 coreconfigitem('web', 'cacerts',
1162 default=None,
1165 default=None,
1163 )
1166 )
1164 coreconfigitem('web', 'certificate',
1167 coreconfigitem('web', 'certificate',
1165 default=None,
1168 default=None,
1166 )
1169 )
1167 coreconfigitem('web', 'collapse',
1170 coreconfigitem('web', 'collapse',
1168 default=False,
1171 default=False,
1169 )
1172 )
1170 coreconfigitem('web', 'csp',
1173 coreconfigitem('web', 'csp',
1171 default=None,
1174 default=None,
1172 )
1175 )
1173 coreconfigitem('web', 'deny_read',
1176 coreconfigitem('web', 'deny_read',
1174 default=list,
1177 default=list,
1175 )
1178 )
1176 coreconfigitem('web', 'descend',
1179 coreconfigitem('web', 'descend',
1177 default=True,
1180 default=True,
1178 )
1181 )
1179 coreconfigitem('web', 'description',
1182 coreconfigitem('web', 'description',
1180 default="",
1183 default="",
1181 )
1184 )
1182 coreconfigitem('web', 'encoding',
1185 coreconfigitem('web', 'encoding',
1183 default=lambda: encoding.encoding,
1186 default=lambda: encoding.encoding,
1184 )
1187 )
1185 coreconfigitem('web', 'errorlog',
1188 coreconfigitem('web', 'errorlog',
1186 default='-',
1189 default='-',
1187 )
1190 )
1188 coreconfigitem('web', 'ipv6',
1191 coreconfigitem('web', 'ipv6',
1189 default=False,
1192 default=False,
1190 )
1193 )
1191 coreconfigitem('web', 'maxchanges',
1194 coreconfigitem('web', 'maxchanges',
1192 default=10,
1195 default=10,
1193 )
1196 )
1194 coreconfigitem('web', 'maxfiles',
1197 coreconfigitem('web', 'maxfiles',
1195 default=10,
1198 default=10,
1196 )
1199 )
1197 coreconfigitem('web', 'maxshortchanges',
1200 coreconfigitem('web', 'maxshortchanges',
1198 default=60,
1201 default=60,
1199 )
1202 )
1200 coreconfigitem('web', 'motd',
1203 coreconfigitem('web', 'motd',
1201 default='',
1204 default='',
1202 )
1205 )
1203 coreconfigitem('web', 'name',
1206 coreconfigitem('web', 'name',
1204 default=dynamicdefault,
1207 default=dynamicdefault,
1205 )
1208 )
1206 coreconfigitem('web', 'port',
1209 coreconfigitem('web', 'port',
1207 default=8000,
1210 default=8000,
1208 )
1211 )
1209 coreconfigitem('web', 'prefix',
1212 coreconfigitem('web', 'prefix',
1210 default='',
1213 default='',
1211 )
1214 )
1212 coreconfigitem('web', 'push_ssl',
1215 coreconfigitem('web', 'push_ssl',
1213 default=True,
1216 default=True,
1214 )
1217 )
1215 coreconfigitem('web', 'refreshinterval',
1218 coreconfigitem('web', 'refreshinterval',
1216 default=20,
1219 default=20,
1217 )
1220 )
1218 coreconfigitem('web', 'staticurl',
1221 coreconfigitem('web', 'staticurl',
1219 default=None,
1222 default=None,
1220 )
1223 )
1221 coreconfigitem('web', 'stripes',
1224 coreconfigitem('web', 'stripes',
1222 default=1,
1225 default=1,
1223 )
1226 )
1224 coreconfigitem('web', 'style',
1227 coreconfigitem('web', 'style',
1225 default='paper',
1228 default='paper',
1226 )
1229 )
1227 coreconfigitem('web', 'templates',
1230 coreconfigitem('web', 'templates',
1228 default=None,
1231 default=None,
1229 )
1232 )
1230 coreconfigitem('web', 'view',
1233 coreconfigitem('web', 'view',
1231 default='served',
1234 default='served',
1232 )
1235 )
1233 coreconfigitem('worker', 'backgroundclose',
1236 coreconfigitem('worker', 'backgroundclose',
1234 default=dynamicdefault,
1237 default=dynamicdefault,
1235 )
1238 )
1236 # Windows defaults to a limit of 512 open files. A buffer of 128
1239 # Windows defaults to a limit of 512 open files. A buffer of 128
1237 # should give us enough headway.
1240 # should give us enough headway.
1238 coreconfigitem('worker', 'backgroundclosemaxqueue',
1241 coreconfigitem('worker', 'backgroundclosemaxqueue',
1239 default=384,
1242 default=384,
1240 )
1243 )
1241 coreconfigitem('worker', 'backgroundcloseminfilecount',
1244 coreconfigitem('worker', 'backgroundcloseminfilecount',
1242 default=2048,
1245 default=2048,
1243 )
1246 )
1244 coreconfigitem('worker', 'backgroundclosethreadcount',
1247 coreconfigitem('worker', 'backgroundclosethreadcount',
1245 default=4,
1248 default=4,
1246 )
1249 )
1247 coreconfigitem('worker', 'numcpus',
1250 coreconfigitem('worker', 'numcpus',
1248 default=None,
1251 default=None,
1249 )
1252 )
1250
1253
1251 # Rebase related configuration moved to core because other extension are doing
1254 # Rebase related configuration moved to core because other extension are doing
1252 # strange things. For example, shelve import the extensions to reuse some bit
1255 # strange things. For example, shelve import the extensions to reuse some bit
1253 # without formally loading it.
1256 # without formally loading it.
1254 coreconfigitem('commands', 'rebase.requiredest',
1257 coreconfigitem('commands', 'rebase.requiredest',
1255 default=False,
1258 default=False,
1256 )
1259 )
1257 coreconfigitem('experimental', 'rebaseskipobsolete',
1260 coreconfigitem('experimental', 'rebaseskipobsolete',
1258 default=True,
1261 default=True,
1259 )
1262 )
1260 coreconfigitem('rebase', 'singletransaction',
1263 coreconfigitem('rebase', 'singletransaction',
1261 default=False,
1264 default=False,
1262 )
1265 )
@@ -1,2581 +1,2585 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 --debug` can help you understand what is introducing
8 :hg:`config --debug` 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`` (per-repository)
57 - ``<repo>/.hg/hgrc`` (per-repository)
58 - ``$HOME/.hgrc`` (per-user)
58 - ``$HOME/.hgrc`` (per-user)
59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
59 - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user)
60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
60 - ``<install-root>/etc/mercurial/hgrc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
61 - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation)
62 - ``/etc/mercurial/hgrc`` (per-system)
62 - ``/etc/mercurial/hgrc`` (per-system)
63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
63 - ``/etc/mercurial/hgrc.d/*.rc`` (per-system)
64 - ``<internal>/default.d/*.rc`` (defaults)
64 - ``<internal>/default.d/*.rc`` (defaults)
65
65
66 .. container:: verbose.windows
66 .. container:: verbose.windows
67
67
68 On Windows, the following files are consulted:
68 On Windows, the following files are consulted:
69
69
70 - ``<repo>/.hg/hgrc`` (per-repository)
70 - ``<repo>/.hg/hgrc`` (per-repository)
71 - ``%USERPROFILE%\.hgrc`` (per-user)
71 - ``%USERPROFILE%\.hgrc`` (per-user)
72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
72 - ``%USERPROFILE%\Mercurial.ini`` (per-user)
73 - ``%HOME%\.hgrc`` (per-user)
73 - ``%HOME%\.hgrc`` (per-user)
74 - ``%HOME%\Mercurial.ini`` (per-user)
74 - ``%HOME%\Mercurial.ini`` (per-user)
75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
75 - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-installation)
76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
76 - ``<install-dir>\hgrc.d\*.rc`` (per-installation)
77 - ``<install-dir>\Mercurial.ini`` (per-installation)
77 - ``<install-dir>\Mercurial.ini`` (per-installation)
78 - ``<internal>/default.d/*.rc`` (defaults)
78 - ``<internal>/default.d/*.rc`` (defaults)
79
79
80 .. note::
80 .. note::
81
81
82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
82 The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial``
83 is used when running 32-bit Python on 64-bit Windows.
83 is used when running 32-bit Python on 64-bit Windows.
84
84
85 .. container:: windows
85 .. container:: windows
86
86
87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
87 On Windows 9x, ``%HOME%`` is replaced by ``%APPDATA%``.
88
88
89 .. container:: verbose.plan9
89 .. container:: verbose.plan9
90
90
91 On Plan9, the following files are consulted:
91 On Plan9, the following files are consulted:
92
92
93 - ``<repo>/.hg/hgrc`` (per-repository)
93 - ``<repo>/.hg/hgrc`` (per-repository)
94 - ``$home/lib/hgrc`` (per-user)
94 - ``$home/lib/hgrc`` (per-user)
95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
95 - ``<install-root>/lib/mercurial/hgrc`` (per-installation)
96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
96 - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation)
97 - ``/lib/mercurial/hgrc`` (per-system)
97 - ``/lib/mercurial/hgrc`` (per-system)
98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
98 - ``/lib/mercurial/hgrc.d/*.rc`` (per-system)
99 - ``<internal>/default.d/*.rc`` (defaults)
99 - ``<internal>/default.d/*.rc`` (defaults)
100
100
101 Per-repository configuration options only apply in a
101 Per-repository configuration options only apply in a
102 particular repository. This file is not version-controlled, and
102 particular repository. This file is not version-controlled, and
103 will not get transferred during a "clone" operation. Options in
103 will not get transferred during a "clone" operation. Options in
104 this file override options in all other configuration files.
104 this file override options in all other configuration files.
105
105
106 .. container:: unix.plan9
106 .. container:: unix.plan9
107
107
108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
108 On Plan 9 and Unix, most of this file will be ignored if it doesn't
109 belong to a trusted user or to a trusted group. See
109 belong to a trusted user or to a trusted group. See
110 :hg:`help config.trusted` for more details.
110 :hg:`help config.trusted` for more details.
111
111
112 Per-user configuration file(s) are for the user running Mercurial. Options
112 Per-user configuration file(s) are for the user running Mercurial. Options
113 in these files apply to all Mercurial commands executed by this user in any
113 in these files apply to all Mercurial commands executed by this user in any
114 directory. Options in these files override per-system and per-installation
114 directory. Options in these files override per-system and per-installation
115 options.
115 options.
116
116
117 Per-installation configuration files are searched for in the
117 Per-installation configuration files are searched for in the
118 directory where Mercurial is installed. ``<install-root>`` is the
118 directory where Mercurial is installed. ``<install-root>`` is the
119 parent directory of the **hg** executable (or symlink) being run.
119 parent directory of the **hg** executable (or symlink) being run.
120
120
121 .. container:: unix.plan9
121 .. container:: unix.plan9
122
122
123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
123 For example, if installed in ``/shared/tools/bin/hg``, Mercurial
124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
124 will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these
125 files apply to all Mercurial commands executed by any user in any
125 files apply to all Mercurial commands executed by any user in any
126 directory.
126 directory.
127
127
128 Per-installation configuration files are for the system on
128 Per-installation configuration files are for the system on
129 which Mercurial is running. Options in these files apply to all
129 which Mercurial is running. Options in these files apply to all
130 Mercurial commands executed by any user in any directory. Registry
130 Mercurial commands executed by any user in any directory. Registry
131 keys contain PATH-like strings, every part of which must reference
131 keys contain PATH-like strings, every part of which must reference
132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
132 a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will
133 be read. Mercurial checks each of these locations in the specified
133 be read. Mercurial checks each of these locations in the specified
134 order until one or more configuration files are detected.
134 order until one or more configuration files are detected.
135
135
136 Per-system configuration files are for the system on which Mercurial
136 Per-system configuration files are for the system on which Mercurial
137 is running. Options in these files apply to all Mercurial commands
137 is running. Options in these files apply to all Mercurial commands
138 executed by any user in any directory. Options in these files
138 executed by any user in any directory. Options in these files
139 override per-installation options.
139 override per-installation options.
140
140
141 Mercurial comes with some default configuration. The default configuration
141 Mercurial comes with some default configuration. The default configuration
142 files are installed with Mercurial and will be overwritten on upgrades. Default
142 files are installed with Mercurial and will be overwritten on upgrades. Default
143 configuration files should never be edited by users or administrators but can
143 configuration files should never be edited by users or administrators but can
144 be overridden in other configuration files. So far the directory only contains
144 be overridden in other configuration files. So far the directory only contains
145 merge tool configuration but packagers can also put other default configuration
145 merge tool configuration but packagers can also put other default configuration
146 there.
146 there.
147
147
148 Syntax
148 Syntax
149 ======
149 ======
150
150
151 A configuration file consists of sections, led by a ``[section]`` header
151 A configuration file consists of sections, led by a ``[section]`` header
152 and followed by ``name = value`` entries (sometimes called
152 and followed by ``name = value`` entries (sometimes called
153 ``configuration keys``)::
153 ``configuration keys``)::
154
154
155 [spam]
155 [spam]
156 eggs=ham
156 eggs=ham
157 green=
157 green=
158 eggs
158 eggs
159
159
160 Each line contains one entry. If the lines that follow are indented,
160 Each line contains one entry. If the lines that follow are indented,
161 they are treated as continuations of that entry. Leading whitespace is
161 they are treated as continuations of that entry. Leading whitespace is
162 removed from values. Empty lines are skipped. Lines beginning with
162 removed from values. Empty lines are skipped. Lines beginning with
163 ``#`` or ``;`` are ignored and may be used to provide comments.
163 ``#`` or ``;`` are ignored and may be used to provide comments.
164
164
165 Configuration keys can be set multiple times, in which case Mercurial
165 Configuration keys can be set multiple times, in which case Mercurial
166 will use the value that was configured last. As an example::
166 will use the value that was configured last. As an example::
167
167
168 [spam]
168 [spam]
169 eggs=large
169 eggs=large
170 ham=serrano
170 ham=serrano
171 eggs=small
171 eggs=small
172
172
173 This would set the configuration key named ``eggs`` to ``small``.
173 This would set the configuration key named ``eggs`` to ``small``.
174
174
175 It is also possible to define a section multiple times. A section can
175 It is also possible to define a section multiple times. A section can
176 be redefined on the same and/or on different configuration files. For
176 be redefined on the same and/or on different configuration files. For
177 example::
177 example::
178
178
179 [foo]
179 [foo]
180 eggs=large
180 eggs=large
181 ham=serrano
181 ham=serrano
182 eggs=small
182 eggs=small
183
183
184 [bar]
184 [bar]
185 eggs=ham
185 eggs=ham
186 green=
186 green=
187 eggs
187 eggs
188
188
189 [foo]
189 [foo]
190 ham=prosciutto
190 ham=prosciutto
191 eggs=medium
191 eggs=medium
192 bread=toasted
192 bread=toasted
193
193
194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
194 This would set the ``eggs``, ``ham``, and ``bread`` configuration keys
195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
195 of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``,
196 respectively. As you can see there only thing that matters is the last
196 respectively. As you can see there only thing that matters is the last
197 value that was set for each of the configuration keys.
197 value that was set for each of the configuration keys.
198
198
199 If a configuration key is set multiple times in different
199 If a configuration key is set multiple times in different
200 configuration files the final value will depend on the order in which
200 configuration files the final value will depend on the order in which
201 the different configuration files are read, with settings from earlier
201 the different configuration files are read, with settings from earlier
202 paths overriding later ones as described on the ``Files`` section
202 paths overriding later ones as described on the ``Files`` section
203 above.
203 above.
204
204
205 A line of the form ``%include file`` will include ``file`` into the
205 A line of the form ``%include file`` will include ``file`` into the
206 current configuration file. The inclusion is recursive, which means
206 current configuration file. The inclusion is recursive, which means
207 that included files can include other files. Filenames are relative to
207 that included files can include other files. Filenames are relative to
208 the configuration file in which the ``%include`` directive is found.
208 the configuration file in which the ``%include`` directive is found.
209 Environment variables and ``~user`` constructs are expanded in
209 Environment variables and ``~user`` constructs are expanded in
210 ``file``. This lets you do something like::
210 ``file``. This lets you do something like::
211
211
212 %include ~/.hgrc.d/$HOST.rc
212 %include ~/.hgrc.d/$HOST.rc
213
213
214 to include a different configuration file on each computer you use.
214 to include a different configuration file on each computer you use.
215
215
216 A line with ``%unset name`` will remove ``name`` from the current
216 A line with ``%unset name`` will remove ``name`` from the current
217 section, if it has been set previously.
217 section, if it has been set previously.
218
218
219 The values are either free-form text strings, lists of text strings,
219 The values are either free-form text strings, lists of text strings,
220 or Boolean values. Boolean values can be set to true using any of "1",
220 or Boolean values. Boolean values can be set to true using any of "1",
221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
221 "yes", "true", or "on" and to false using "0", "no", "false", or "off"
222 (all case insensitive).
222 (all case insensitive).
223
223
224 List values are separated by whitespace or comma, except when values are
224 List values are separated by whitespace or comma, except when values are
225 placed in double quotation marks::
225 placed in double quotation marks::
226
226
227 allow_read = "John Doe, PhD", brian, betty
227 allow_read = "John Doe, PhD", brian, betty
228
228
229 Quotation marks can be escaped by prefixing them with a backslash. Only
229 Quotation marks can be escaped by prefixing them with a backslash. Only
230 quotation marks at the beginning of a word is counted as a quotation
230 quotation marks at the beginning of a word is counted as a quotation
231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
231 (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``).
232
232
233 Sections
233 Sections
234 ========
234 ========
235
235
236 This section describes the different sections that may appear in a
236 This section describes the different sections that may appear in a
237 Mercurial configuration file, the purpose of each section, its possible
237 Mercurial configuration file, the purpose of each section, its possible
238 keys, and their possible values.
238 keys, and their possible values.
239
239
240 ``alias``
240 ``alias``
241 ---------
241 ---------
242
242
243 Defines command aliases.
243 Defines command aliases.
244
244
245 Aliases allow you to define your own commands in terms of other
245 Aliases allow you to define your own commands in terms of other
246 commands (or aliases), optionally including arguments. Positional
246 commands (or aliases), optionally including arguments. Positional
247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
247 arguments in the form of ``$1``, ``$2``, etc. in the alias definition
248 are expanded by Mercurial before execution. Positional arguments not
248 are expanded by Mercurial before execution. Positional arguments not
249 already used by ``$N`` in the definition are put at the end of the
249 already used by ``$N`` in the definition are put at the end of the
250 command to be executed.
250 command to be executed.
251
251
252 Alias definitions consist of lines of the form::
252 Alias definitions consist of lines of the form::
253
253
254 <alias> = <command> [<argument>]...
254 <alias> = <command> [<argument>]...
255
255
256 For example, this definition::
256 For example, this definition::
257
257
258 latest = log --limit 5
258 latest = log --limit 5
259
259
260 creates a new command ``latest`` that shows only the five most recent
260 creates a new command ``latest`` that shows only the five most recent
261 changesets. You can define subsequent aliases using earlier ones::
261 changesets. You can define subsequent aliases using earlier ones::
262
262
263 stable5 = latest -b stable
263 stable5 = latest -b stable
264
264
265 .. note::
265 .. note::
266
266
267 It is possible to create aliases with the same names as
267 It is possible to create aliases with the same names as
268 existing commands, which will then override the original
268 existing commands, which will then override the original
269 definitions. This is almost always a bad idea!
269 definitions. This is almost always a bad idea!
270
270
271 An alias can start with an exclamation point (``!``) to make it a
271 An alias can start with an exclamation point (``!``) to make it a
272 shell alias. A shell alias is executed with the shell and will let you
272 shell alias. A shell alias is executed with the shell and will let you
273 run arbitrary commands. As an example, ::
273 run arbitrary commands. As an example, ::
274
274
275 echo = !echo $@
275 echo = !echo $@
276
276
277 will let you do ``hg echo foo`` to have ``foo`` printed in your
277 will let you do ``hg echo foo`` to have ``foo`` printed in your
278 terminal. A better example might be::
278 terminal. A better example might be::
279
279
280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
280 purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f
281
281
282 which will make ``hg purge`` delete all unknown files in the
282 which will make ``hg purge`` delete all unknown files in the
283 repository in the same manner as the purge extension.
283 repository in the same manner as the purge extension.
284
284
285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
285 Positional arguments like ``$1``, ``$2``, etc. in the alias definition
286 expand to the command arguments. Unmatched arguments are
286 expand to the command arguments. Unmatched arguments are
287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
287 removed. ``$0`` expands to the alias name and ``$@`` expands to all
288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
288 arguments separated by a space. ``"$@"`` (with quotes) expands to all
289 arguments quoted individually and separated by a space. These expansions
289 arguments quoted individually and separated by a space. These expansions
290 happen before the command is passed to the shell.
290 happen before the command is passed to the shell.
291
291
292 Shell aliases are executed in an environment where ``$HG`` expands to
292 Shell aliases are executed in an environment where ``$HG`` expands to
293 the path of the Mercurial that was used to execute the alias. This is
293 the path of the Mercurial that was used to execute the alias. This is
294 useful when you want to call further Mercurial commands in a shell
294 useful when you want to call further Mercurial commands in a shell
295 alias, as was done above for the purge alias. In addition,
295 alias, as was done above for the purge alias. In addition,
296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
296 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg
297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
297 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
298
298
299 .. note::
299 .. note::
300
300
301 Some global configuration options such as ``-R`` are
301 Some global configuration options such as ``-R`` are
302 processed before shell aliases and will thus not be passed to
302 processed before shell aliases and will thus not be passed to
303 aliases.
303 aliases.
304
304
305
305
306 ``annotate``
306 ``annotate``
307 ------------
307 ------------
308
308
309 Settings used when displaying file annotations. All values are
309 Settings used when displaying file annotations. All values are
310 Booleans and default to False. See :hg:`help config.diff` for
310 Booleans and default to False. See :hg:`help config.diff` for
311 related options for the diff command.
311 related options for the diff command.
312
312
313 ``ignorews``
313 ``ignorews``
314 Ignore white space when comparing lines.
314 Ignore white space when comparing lines.
315
315
316 ``ignorewseol``
316 ``ignorewseol``
317 Ignore white space at the end of a line when comparing lines.
317 Ignore white space at the end of a line when comparing lines.
318
318
319 ``ignorewsamount``
319 ``ignorewsamount``
320 Ignore changes in the amount of white space.
320 Ignore changes in the amount of white space.
321
321
322 ``ignoreblanklines``
322 ``ignoreblanklines``
323 Ignore changes whose lines are all blank.
323 Ignore changes whose lines are all blank.
324
324
325
325
326 ``auth``
326 ``auth``
327 --------
327 --------
328
328
329 Authentication credentials and other authentication-like configuration
329 Authentication credentials and other authentication-like configuration
330 for HTTP connections. This section allows you to store usernames and
330 for HTTP connections. This section allows you to store usernames and
331 passwords for use when logging *into* HTTP servers. See
331 passwords for use when logging *into* HTTP servers. See
332 :hg:`help config.web` if you want to configure *who* can login to
332 :hg:`help config.web` if you want to configure *who* can login to
333 your HTTP server.
333 your HTTP server.
334
334
335 The following options apply to all hosts.
335 The following options apply to all hosts.
336
336
337 ``cookiefile``
337 ``cookiefile``
338 Path to a file containing HTTP cookie lines. Cookies matching a
338 Path to a file containing HTTP cookie lines. Cookies matching a
339 host will be sent automatically.
339 host will be sent automatically.
340
340
341 The file format uses the Mozilla cookies.txt format, which defines cookies
341 The file format uses the Mozilla cookies.txt format, which defines cookies
342 on their own lines. Each line contains 7 fields delimited by the tab
342 on their own lines. Each line contains 7 fields delimited by the tab
343 character (domain, is_domain_cookie, path, is_secure, expires, name,
343 character (domain, is_domain_cookie, path, is_secure, expires, name,
344 value). For more info, do an Internet search for "Netscape cookies.txt
344 value). For more info, do an Internet search for "Netscape cookies.txt
345 format."
345 format."
346
346
347 Note: the cookies parser does not handle port numbers on domains. You
347 Note: the cookies parser does not handle port numbers on domains. You
348 will need to remove ports from the domain for the cookie to be recognized.
348 will need to remove ports from the domain for the cookie to be recognized.
349 This could result in a cookie being disclosed to an unwanted server.
349 This could result in a cookie being disclosed to an unwanted server.
350
350
351 The cookies file is read-only.
351 The cookies file is read-only.
352
352
353 Other options in this section are grouped by name and have the following
353 Other options in this section are grouped by name and have the following
354 format::
354 format::
355
355
356 <name>.<argument> = <value>
356 <name>.<argument> = <value>
357
357
358 where ``<name>`` is used to group arguments into authentication
358 where ``<name>`` is used to group arguments into authentication
359 entries. Example::
359 entries. Example::
360
360
361 foo.prefix = hg.intevation.de/mercurial
361 foo.prefix = hg.intevation.de/mercurial
362 foo.username = foo
362 foo.username = foo
363 foo.password = bar
363 foo.password = bar
364 foo.schemes = http https
364 foo.schemes = http https
365
365
366 bar.prefix = secure.example.org
366 bar.prefix = secure.example.org
367 bar.key = path/to/file.key
367 bar.key = path/to/file.key
368 bar.cert = path/to/file.cert
368 bar.cert = path/to/file.cert
369 bar.schemes = https
369 bar.schemes = https
370
370
371 Supported arguments:
371 Supported arguments:
372
372
373 ``prefix``
373 ``prefix``
374 Either ``*`` or a URI prefix with or without the scheme part.
374 Either ``*`` or a URI prefix with or without the scheme part.
375 The authentication entry with the longest matching prefix is used
375 The authentication entry with the longest matching prefix is used
376 (where ``*`` matches everything and counts as a match of length
376 (where ``*`` matches everything and counts as a match of length
377 1). If the prefix doesn't include a scheme, the match is performed
377 1). If the prefix doesn't include a scheme, the match is performed
378 against the URI with its scheme stripped as well, and the schemes
378 against the URI with its scheme stripped as well, and the schemes
379 argument, q.v., is then subsequently consulted.
379 argument, q.v., is then subsequently consulted.
380
380
381 ``username``
381 ``username``
382 Optional. Username to authenticate with. If not given, and the
382 Optional. Username to authenticate with. If not given, and the
383 remote site requires basic or digest authentication, the user will
383 remote site requires basic or digest authentication, the user will
384 be prompted for it. Environment variables are expanded in the
384 be prompted for it. Environment variables are expanded in the
385 username letting you do ``foo.username = $USER``. If the URI
385 username letting you do ``foo.username = $USER``. If the URI
386 includes a username, only ``[auth]`` entries with a matching
386 includes a username, only ``[auth]`` entries with a matching
387 username or without a username will be considered.
387 username or without a username will be considered.
388
388
389 ``password``
389 ``password``
390 Optional. Password to authenticate with. If not given, and the
390 Optional. Password to authenticate with. If not given, and the
391 remote site requires basic or digest authentication, the user
391 remote site requires basic or digest authentication, the user
392 will be prompted for it.
392 will be prompted for it.
393
393
394 ``key``
394 ``key``
395 Optional. PEM encoded client certificate key file. Environment
395 Optional. PEM encoded client certificate key file. Environment
396 variables are expanded in the filename.
396 variables are expanded in the filename.
397
397
398 ``cert``
398 ``cert``
399 Optional. PEM encoded client certificate chain file. Environment
399 Optional. PEM encoded client certificate chain file. Environment
400 variables are expanded in the filename.
400 variables are expanded in the filename.
401
401
402 ``schemes``
402 ``schemes``
403 Optional. Space separated list of URI schemes to use this
403 Optional. Space separated list of URI schemes to use this
404 authentication entry with. Only used if the prefix doesn't include
404 authentication entry with. Only used if the prefix doesn't include
405 a scheme. Supported schemes are http and https. They will match
405 a scheme. Supported schemes are http and https. They will match
406 static-http and static-https respectively, as well.
406 static-http and static-https respectively, as well.
407 (default: https)
407 (default: https)
408
408
409 If no suitable authentication entry is found, the user is prompted
409 If no suitable authentication entry is found, the user is prompted
410 for credentials as usual if required by the remote.
410 for credentials as usual if required by the remote.
411
411
412 ``color``
412 ``color``
413 ---------
413 ---------
414
414
415 Configure the Mercurial color mode. For details about how to define your custom
415 Configure the Mercurial color mode. For details about how to define your custom
416 effect and style see :hg:`help color`.
416 effect and style see :hg:`help color`.
417
417
418 ``mode``
418 ``mode``
419 String: control the method used to output color. One of ``auto``, ``ansi``,
419 String: control the method used to output color. One of ``auto``, ``ansi``,
420 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
420 ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
421 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
421 use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
422 terminal. Any invalid value will disable color.
422 terminal. Any invalid value will disable color.
423
423
424 ``pagermode``
424 ``pagermode``
425 String: optional override of ``color.mode`` used with pager.
425 String: optional override of ``color.mode`` used with pager.
426
426
427 On some systems, terminfo mode may cause problems when using
427 On some systems, terminfo mode may cause problems when using
428 color with ``less -R`` as a pager program. less with the -R option
428 color with ``less -R`` as a pager program. less with the -R option
429 will only display ECMA-48 color codes, and terminfo mode may sometimes
429 will only display ECMA-48 color codes, and terminfo mode may sometimes
430 emit codes that less doesn't understand. You can work around this by
430 emit codes that less doesn't understand. You can work around this by
431 either using ansi mode (or auto mode), or by using less -r (which will
431 either using ansi mode (or auto mode), or by using less -r (which will
432 pass through all terminal control codes, not just color control
432 pass through all terminal control codes, not just color control
433 codes).
433 codes).
434
434
435 On some systems (such as MSYS in Windows), the terminal may support
435 On some systems (such as MSYS in Windows), the terminal may support
436 a different color mode than the pager program.
436 a different color mode than the pager program.
437
437
438 ``commands``
438 ``commands``
439 ------------
439 ------------
440
440
441 ``status.relative``
441 ``status.relative``
442 Make paths in :hg:`status` output relative to the current directory.
442 Make paths in :hg:`status` output relative to the current directory.
443 (default: False)
443 (default: False)
444
444
445 ``update.check``
445 ``update.check``
446 Determines what level of checking :hg:`update` will perform before moving
446 Determines what level of checking :hg:`update` will perform before moving
447 to a destination revision. Valid values are ``abort``, ``none``,
447 to a destination revision. Valid values are ``abort``, ``none``,
448 ``linear``, and ``noconflict``. ``abort`` always fails if the working
448 ``linear``, and ``noconflict``. ``abort`` always fails if the working
449 directory has uncommitted changes. ``none`` performs no checking, and may
449 directory has uncommitted changes. ``none`` performs no checking, and may
450 result in a merge with uncommitted changes. ``linear`` allows any update
450 result in a merge with uncommitted changes. ``linear`` allows any update
451 as long as it follows a straight line in the revision history, and may
451 as long as it follows a straight line in the revision history, and may
452 trigger a merge with uncommitted changes. ``noconflict`` will allow any
452 trigger a merge with uncommitted changes. ``noconflict`` will allow any
453 update which would not trigger a merge with uncommitted changes, if any
453 update which would not trigger a merge with uncommitted changes, if any
454 are present.
454 are present.
455 (default: ``linear``)
455 (default: ``linear``)
456
456
457 ``update.requiredest``
457 ``update.requiredest``
458 Require that the user pass a destination when running :hg:`update`.
458 Require that the user pass a destination when running :hg:`update`.
459 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
459 For example, :hg:`update .::` will be allowed, but a plain :hg:`update`
460 will be disallowed.
460 will be disallowed.
461 (default: False)
461 (default: False)
462
462
463 ``committemplate``
463 ``committemplate``
464 ------------------
464 ------------------
465
465
466 ``changeset``
466 ``changeset``
467 String: configuration in this section is used as the template to
467 String: configuration in this section is used as the template to
468 customize the text shown in the editor when committing.
468 customize the text shown in the editor when committing.
469
469
470 In addition to pre-defined template keywords, commit log specific one
470 In addition to pre-defined template keywords, commit log specific one
471 below can be used for customization:
471 below can be used for customization:
472
472
473 ``extramsg``
473 ``extramsg``
474 String: Extra message (typically 'Leave message empty to abort
474 String: Extra message (typically 'Leave message empty to abort
475 commit.'). This may be changed by some commands or extensions.
475 commit.'). This may be changed by some commands or extensions.
476
476
477 For example, the template configuration below shows as same text as
477 For example, the template configuration below shows as same text as
478 one shown by default::
478 one shown by default::
479
479
480 [committemplate]
480 [committemplate]
481 changeset = {desc}\n\n
481 changeset = {desc}\n\n
482 HG: Enter commit message. Lines beginning with 'HG:' are removed.
482 HG: Enter commit message. Lines beginning with 'HG:' are removed.
483 HG: {extramsg}
483 HG: {extramsg}
484 HG: --
484 HG: --
485 HG: user: {author}\n{ifeq(p2rev, "-1", "",
485 HG: user: {author}\n{ifeq(p2rev, "-1", "",
486 "HG: branch merge\n")
486 "HG: branch merge\n")
487 }HG: branch '{branch}'\n{if(activebookmark,
487 }HG: branch '{branch}'\n{if(activebookmark,
488 "HG: bookmark '{activebookmark}'\n") }{subrepos %
488 "HG: bookmark '{activebookmark}'\n") }{subrepos %
489 "HG: subrepo {subrepo}\n" }{file_adds %
489 "HG: subrepo {subrepo}\n" }{file_adds %
490 "HG: added {file}\n" }{file_mods %
490 "HG: added {file}\n" }{file_mods %
491 "HG: changed {file}\n" }{file_dels %
491 "HG: changed {file}\n" }{file_dels %
492 "HG: removed {file}\n" }{if(files, "",
492 "HG: removed {file}\n" }{if(files, "",
493 "HG: no files changed\n")}
493 "HG: no files changed\n")}
494
494
495 ``diff()``
495 ``diff()``
496 String: show the diff (see :hg:`help templates` for detail)
496 String: show the diff (see :hg:`help templates` for detail)
497
497
498 Sometimes it is helpful to show the diff of the changeset in the editor without
498 Sometimes it is helpful to show the diff of the changeset in the editor without
499 having to prefix 'HG: ' to each line so that highlighting works correctly. For
499 having to prefix 'HG: ' to each line so that highlighting works correctly. For
500 this, Mercurial provides a special string which will ignore everything below
500 this, Mercurial provides a special string which will ignore everything below
501 it::
501 it::
502
502
503 HG: ------------------------ >8 ------------------------
503 HG: ------------------------ >8 ------------------------
504
504
505 For example, the template configuration below will show the diff below the
505 For example, the template configuration below will show the diff below the
506 extra message::
506 extra message::
507
507
508 [committemplate]
508 [committemplate]
509 changeset = {desc}\n\n
509 changeset = {desc}\n\n
510 HG: Enter commit message. Lines beginning with 'HG:' are removed.
510 HG: Enter commit message. Lines beginning with 'HG:' are removed.
511 HG: {extramsg}
511 HG: {extramsg}
512 HG: ------------------------ >8 ------------------------
512 HG: ------------------------ >8 ------------------------
513 HG: Do not touch the line above.
513 HG: Do not touch the line above.
514 HG: Everything below will be removed.
514 HG: Everything below will be removed.
515 {diff()}
515 {diff()}
516
516
517 .. note::
517 .. note::
518
518
519 For some problematic encodings (see :hg:`help win32mbcs` for
519 For some problematic encodings (see :hg:`help win32mbcs` for
520 detail), this customization should be configured carefully, to
520 detail), this customization should be configured carefully, to
521 avoid showing broken characters.
521 avoid showing broken characters.
522
522
523 For example, if a multibyte character ending with backslash (0x5c) is
523 For example, if a multibyte character ending with backslash (0x5c) is
524 followed by the ASCII character 'n' in the customized template,
524 followed by the ASCII character 'n' in the customized template,
525 the sequence of backslash and 'n' is treated as line-feed unexpectedly
525 the sequence of backslash and 'n' is treated as line-feed unexpectedly
526 (and the multibyte character is broken, too).
526 (and the multibyte character is broken, too).
527
527
528 Customized template is used for commands below (``--edit`` may be
528 Customized template is used for commands below (``--edit`` may be
529 required):
529 required):
530
530
531 - :hg:`backout`
531 - :hg:`backout`
532 - :hg:`commit`
532 - :hg:`commit`
533 - :hg:`fetch` (for merge commit only)
533 - :hg:`fetch` (for merge commit only)
534 - :hg:`graft`
534 - :hg:`graft`
535 - :hg:`histedit`
535 - :hg:`histedit`
536 - :hg:`import`
536 - :hg:`import`
537 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
537 - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh`
538 - :hg:`rebase`
538 - :hg:`rebase`
539 - :hg:`shelve`
539 - :hg:`shelve`
540 - :hg:`sign`
540 - :hg:`sign`
541 - :hg:`tag`
541 - :hg:`tag`
542 - :hg:`transplant`
542 - :hg:`transplant`
543
543
544 Configuring items below instead of ``changeset`` allows showing
544 Configuring items below instead of ``changeset`` allows showing
545 customized message only for specific actions, or showing different
545 customized message only for specific actions, or showing different
546 messages for each action.
546 messages for each action.
547
547
548 - ``changeset.backout`` for :hg:`backout`
548 - ``changeset.backout`` for :hg:`backout`
549 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
549 - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges
550 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
550 - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other
551 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
551 - ``changeset.commit.normal.merge`` for :hg:`commit` on merges
552 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
552 - ``changeset.commit.normal.normal`` for :hg:`commit` on other
553 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
553 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
554 - ``changeset.gpg.sign`` for :hg:`sign`
554 - ``changeset.gpg.sign`` for :hg:`sign`
555 - ``changeset.graft`` for :hg:`graft`
555 - ``changeset.graft`` for :hg:`graft`
556 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
556 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
557 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
557 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
558 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
558 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
559 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
559 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
560 - ``changeset.import.bypass`` for :hg:`import --bypass`
560 - ``changeset.import.bypass`` for :hg:`import --bypass`
561 - ``changeset.import.normal.merge`` for :hg:`import` on merges
561 - ``changeset.import.normal.merge`` for :hg:`import` on merges
562 - ``changeset.import.normal.normal`` for :hg:`import` on other
562 - ``changeset.import.normal.normal`` for :hg:`import` on other
563 - ``changeset.mq.qnew`` for :hg:`qnew`
563 - ``changeset.mq.qnew`` for :hg:`qnew`
564 - ``changeset.mq.qfold`` for :hg:`qfold`
564 - ``changeset.mq.qfold`` for :hg:`qfold`
565 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
565 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
566 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
566 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
567 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
567 - ``changeset.rebase.merge`` for :hg:`rebase` on merges
568 - ``changeset.rebase.normal`` for :hg:`rebase` on other
568 - ``changeset.rebase.normal`` for :hg:`rebase` on other
569 - ``changeset.shelve.shelve`` for :hg:`shelve`
569 - ``changeset.shelve.shelve`` for :hg:`shelve`
570 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
570 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
571 - ``changeset.tag.remove`` for :hg:`tag --remove`
571 - ``changeset.tag.remove`` for :hg:`tag --remove`
572 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
572 - ``changeset.transplant.merge`` for :hg:`transplant` on merges
573 - ``changeset.transplant.normal`` for :hg:`transplant` on other
573 - ``changeset.transplant.normal`` for :hg:`transplant` on other
574
574
575 These dot-separated lists of names are treated as hierarchical ones.
575 These dot-separated lists of names are treated as hierarchical ones.
576 For example, ``changeset.tag.remove`` customizes the commit message
576 For example, ``changeset.tag.remove`` customizes the commit message
577 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
577 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
578 commit message for :hg:`tag` regardless of ``--remove`` option.
578 commit message for :hg:`tag` regardless of ``--remove`` option.
579
579
580 When the external editor is invoked for a commit, the corresponding
580 When the external editor is invoked for a commit, the corresponding
581 dot-separated list of names without the ``changeset.`` prefix
581 dot-separated list of names without the ``changeset.`` prefix
582 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
582 (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment
583 variable.
583 variable.
584
584
585 In this section, items other than ``changeset`` can be referred from
585 In this section, items other than ``changeset`` can be referred from
586 others. For example, the configuration to list committed files up
586 others. For example, the configuration to list committed files up
587 below can be referred as ``{listupfiles}``::
587 below can be referred as ``{listupfiles}``::
588
588
589 [committemplate]
589 [committemplate]
590 listupfiles = {file_adds %
590 listupfiles = {file_adds %
591 "HG: added {file}\n" }{file_mods %
591 "HG: added {file}\n" }{file_mods %
592 "HG: changed {file}\n" }{file_dels %
592 "HG: changed {file}\n" }{file_dels %
593 "HG: removed {file}\n" }{if(files, "",
593 "HG: removed {file}\n" }{if(files, "",
594 "HG: no files changed\n")}
594 "HG: no files changed\n")}
595
595
596 ``decode/encode``
596 ``decode/encode``
597 -----------------
597 -----------------
598
598
599 Filters for transforming files on checkout/checkin. This would
599 Filters for transforming files on checkout/checkin. This would
600 typically be used for newline processing or other
600 typically be used for newline processing or other
601 localization/canonicalization of files.
601 localization/canonicalization of files.
602
602
603 Filters consist of a filter pattern followed by a filter command.
603 Filters consist of a filter pattern followed by a filter command.
604 Filter patterns are globs by default, rooted at the repository root.
604 Filter patterns are globs by default, rooted at the repository root.
605 For example, to match any file ending in ``.txt`` in the root
605 For example, to match any file ending in ``.txt`` in the root
606 directory only, use the pattern ``*.txt``. To match any file ending
606 directory only, use the pattern ``*.txt``. To match any file ending
607 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
607 in ``.c`` anywhere in the repository, use the pattern ``**.c``.
608 For each file only the first matching filter applies.
608 For each file only the first matching filter applies.
609
609
610 The filter command can start with a specifier, either ``pipe:`` or
610 The filter command can start with a specifier, either ``pipe:`` or
611 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
611 ``tempfile:``. If no specifier is given, ``pipe:`` is used by default.
612
612
613 A ``pipe:`` command must accept data on stdin and return the transformed
613 A ``pipe:`` command must accept data on stdin and return the transformed
614 data on stdout.
614 data on stdout.
615
615
616 Pipe example::
616 Pipe example::
617
617
618 [encode]
618 [encode]
619 # uncompress gzip files on checkin to improve delta compression
619 # uncompress gzip files on checkin to improve delta compression
620 # note: not necessarily a good idea, just an example
620 # note: not necessarily a good idea, just an example
621 *.gz = pipe: gunzip
621 *.gz = pipe: gunzip
622
622
623 [decode]
623 [decode]
624 # recompress gzip files when writing them to the working dir (we
624 # recompress gzip files when writing them to the working dir (we
625 # can safely omit "pipe:", because it's the default)
625 # can safely omit "pipe:", because it's the default)
626 *.gz = gzip
626 *.gz = gzip
627
627
628 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
628 A ``tempfile:`` command is a template. The string ``INFILE`` is replaced
629 with the name of a temporary file that contains the data to be
629 with the name of a temporary file that contains the data to be
630 filtered by the command. The string ``OUTFILE`` is replaced with the name
630 filtered by the command. The string ``OUTFILE`` is replaced with the name
631 of an empty temporary file, where the filtered data must be written by
631 of an empty temporary file, where the filtered data must be written by
632 the command.
632 the command.
633
633
634 .. container:: windows
634 .. container:: windows
635
635
636 .. note::
636 .. note::
637
637
638 The tempfile mechanism is recommended for Windows systems,
638 The tempfile mechanism is recommended for Windows systems,
639 where the standard shell I/O redirection operators often have
639 where the standard shell I/O redirection operators often have
640 strange effects and may corrupt the contents of your files.
640 strange effects and may corrupt the contents of your files.
641
641
642 This filter mechanism is used internally by the ``eol`` extension to
642 This filter mechanism is used internally by the ``eol`` extension to
643 translate line ending characters between Windows (CRLF) and Unix (LF)
643 translate line ending characters between Windows (CRLF) and Unix (LF)
644 format. We suggest you use the ``eol`` extension for convenience.
644 format. We suggest you use the ``eol`` extension for convenience.
645
645
646
646
647 ``defaults``
647 ``defaults``
648 ------------
648 ------------
649
649
650 (defaults are deprecated. Don't use them. Use aliases instead.)
650 (defaults are deprecated. Don't use them. Use aliases instead.)
651
651
652 Use the ``[defaults]`` section to define command defaults, i.e. the
652 Use the ``[defaults]`` section to define command defaults, i.e. the
653 default options/arguments to pass to the specified commands.
653 default options/arguments to pass to the specified commands.
654
654
655 The following example makes :hg:`log` run in verbose mode, and
655 The following example makes :hg:`log` run in verbose mode, and
656 :hg:`status` show only the modified files, by default::
656 :hg:`status` show only the modified files, by default::
657
657
658 [defaults]
658 [defaults]
659 log = -v
659 log = -v
660 status = -m
660 status = -m
661
661
662 The actual commands, instead of their aliases, must be used when
662 The actual commands, instead of their aliases, must be used when
663 defining command defaults. The command defaults will also be applied
663 defining command defaults. The command defaults will also be applied
664 to the aliases of the commands defined.
664 to the aliases of the commands defined.
665
665
666
666
667 ``diff``
667 ``diff``
668 --------
668 --------
669
669
670 Settings used when displaying diffs. Everything except for ``unified``
670 Settings used when displaying diffs. Everything except for ``unified``
671 is a Boolean and defaults to False. See :hg:`help config.annotate`
671 is a Boolean and defaults to False. See :hg:`help config.annotate`
672 for related options for the annotate command.
672 for related options for the annotate command.
673
673
674 ``git``
674 ``git``
675 Use git extended diff format.
675 Use git extended diff format.
676
676
677 ``nobinary``
677 ``nobinary``
678 Omit git binary patches.
678 Omit git binary patches.
679
679
680 ``nodates``
680 ``nodates``
681 Don't include dates in diff headers.
681 Don't include dates in diff headers.
682
682
683 ``noprefix``
683 ``noprefix``
684 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
684 Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
685
685
686 ``showfunc``
686 ``showfunc``
687 Show which function each change is in.
687 Show which function each change is in.
688
688
689 ``ignorews``
689 ``ignorews``
690 Ignore white space when comparing lines.
690 Ignore white space when comparing lines.
691
691
692 ``ignorewsamount``
692 ``ignorewsamount``
693 Ignore changes in the amount of white space.
693 Ignore changes in the amount of white space.
694
694
695 ``ignoreblanklines``
695 ``ignoreblanklines``
696 Ignore changes whose lines are all blank.
696 Ignore changes whose lines are all blank.
697
697
698 ``unified``
698 ``unified``
699 Number of lines of context to show.
699 Number of lines of context to show.
700
700
701 ``email``
701 ``email``
702 ---------
702 ---------
703
703
704 Settings for extensions that send email messages.
704 Settings for extensions that send email messages.
705
705
706 ``from``
706 ``from``
707 Optional. Email address to use in "From" header and SMTP envelope
707 Optional. Email address to use in "From" header and SMTP envelope
708 of outgoing messages.
708 of outgoing messages.
709
709
710 ``to``
710 ``to``
711 Optional. Comma-separated list of recipients' email addresses.
711 Optional. Comma-separated list of recipients' email addresses.
712
712
713 ``cc``
713 ``cc``
714 Optional. Comma-separated list of carbon copy recipients'
714 Optional. Comma-separated list of carbon copy recipients'
715 email addresses.
715 email addresses.
716
716
717 ``bcc``
717 ``bcc``
718 Optional. Comma-separated list of blind carbon copy recipients'
718 Optional. Comma-separated list of blind carbon copy recipients'
719 email addresses.
719 email addresses.
720
720
721 ``method``
721 ``method``
722 Optional. Method to use to send email messages. If value is ``smtp``
722 Optional. Method to use to send email messages. If value is ``smtp``
723 (default), use SMTP (see the ``[smtp]`` section for configuration).
723 (default), use SMTP (see the ``[smtp]`` section for configuration).
724 Otherwise, use as name of program to run that acts like sendmail
724 Otherwise, use as name of program to run that acts like sendmail
725 (takes ``-f`` option for sender, list of recipients on command line,
725 (takes ``-f`` option for sender, list of recipients on command line,
726 message on stdin). Normally, setting this to ``sendmail`` or
726 message on stdin). Normally, setting this to ``sendmail`` or
727 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
727 ``/usr/sbin/sendmail`` is enough to use sendmail to send messages.
728
728
729 ``charsets``
729 ``charsets``
730 Optional. Comma-separated list of character sets considered
730 Optional. Comma-separated list of character sets considered
731 convenient for recipients. Addresses, headers, and parts not
731 convenient for recipients. Addresses, headers, and parts not
732 containing patches of outgoing messages will be encoded in the
732 containing patches of outgoing messages will be encoded in the
733 first character set to which conversion from local encoding
733 first character set to which conversion from local encoding
734 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
734 (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct
735 conversion fails, the text in question is sent as is.
735 conversion fails, the text in question is sent as is.
736 (default: '')
736 (default: '')
737
737
738 Order of outgoing email character sets:
738 Order of outgoing email character sets:
739
739
740 1. ``us-ascii``: always first, regardless of settings
740 1. ``us-ascii``: always first, regardless of settings
741 2. ``email.charsets``: in order given by user
741 2. ``email.charsets``: in order given by user
742 3. ``ui.fallbackencoding``: if not in email.charsets
742 3. ``ui.fallbackencoding``: if not in email.charsets
743 4. ``$HGENCODING``: if not in email.charsets
743 4. ``$HGENCODING``: if not in email.charsets
744 5. ``utf-8``: always last, regardless of settings
744 5. ``utf-8``: always last, regardless of settings
745
745
746 Email example::
746 Email example::
747
747
748 [email]
748 [email]
749 from = Joseph User <joe.user@example.com>
749 from = Joseph User <joe.user@example.com>
750 method = /usr/sbin/sendmail
750 method = /usr/sbin/sendmail
751 # charsets for western Europeans
751 # charsets for western Europeans
752 # us-ascii, utf-8 omitted, as they are tried first and last
752 # us-ascii, utf-8 omitted, as they are tried first and last
753 charsets = iso-8859-1, iso-8859-15, windows-1252
753 charsets = iso-8859-1, iso-8859-15, windows-1252
754
754
755
755
756 ``extensions``
756 ``extensions``
757 --------------
757 --------------
758
758
759 Mercurial has an extension mechanism for adding new features. To
759 Mercurial has an extension mechanism for adding new features. To
760 enable an extension, create an entry for it in this section.
760 enable an extension, create an entry for it in this section.
761
761
762 If you know that the extension is already in Python's search path,
762 If you know that the extension is already in Python's search path,
763 you can give the name of the module, followed by ``=``, with nothing
763 you can give the name of the module, followed by ``=``, with nothing
764 after the ``=``.
764 after the ``=``.
765
765
766 Otherwise, give a name that you choose, followed by ``=``, followed by
766 Otherwise, give a name that you choose, followed by ``=``, followed by
767 the path to the ``.py`` file (including the file name extension) that
767 the path to the ``.py`` file (including the file name extension) that
768 defines the extension.
768 defines the extension.
769
769
770 To explicitly disable an extension that is enabled in an hgrc of
770 To explicitly disable an extension that is enabled in an hgrc of
771 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
771 broader scope, prepend its path with ``!``, as in ``foo = !/ext/path``
772 or ``foo = !`` when path is not supplied.
772 or ``foo = !`` when path is not supplied.
773
773
774 Example for ``~/.hgrc``::
774 Example for ``~/.hgrc``::
775
775
776 [extensions]
776 [extensions]
777 # (the churn extension will get loaded from Mercurial's path)
777 # (the churn extension will get loaded from Mercurial's path)
778 churn =
778 churn =
779 # (this extension will get loaded from the file specified)
779 # (this extension will get loaded from the file specified)
780 myfeature = ~/.hgext/myfeature.py
780 myfeature = ~/.hgext/myfeature.py
781
781
782
782
783 ``format``
783 ``format``
784 ----------
784 ----------
785
785
786 ``usegeneraldelta``
786 ``usegeneraldelta``
787 Enable or disable the "generaldelta" repository format which improves
787 Enable or disable the "generaldelta" repository format which improves
788 repository compression by allowing "revlog" to store delta against arbitrary
788 repository compression by allowing "revlog" to store delta against arbitrary
789 revision instead of the previous stored one. This provides significant
789 revision instead of the previous stored one. This provides significant
790 improvement for repositories with branches.
790 improvement for repositories with branches.
791
791
792 Repositories with this on-disk format require Mercurial version 1.9.
792 Repositories with this on-disk format require Mercurial version 1.9.
793
793
794 Enabled by default.
794 Enabled by default.
795
795
796 ``dotencode``
796 ``dotencode``
797 Enable or disable the "dotencode" repository format which enhances
797 Enable or disable the "dotencode" repository format which enhances
798 the "fncache" repository format (which has to be enabled to use
798 the "fncache" repository format (which has to be enabled to use
799 dotencode) to avoid issues with filenames starting with ._ on
799 dotencode) to avoid issues with filenames starting with ._ on
800 Mac OS X and spaces on Windows.
800 Mac OS X and spaces on Windows.
801
801
802 Repositories with this on-disk format require Mercurial version 1.7.
802 Repositories with this on-disk format require Mercurial version 1.7.
803
803
804 Enabled by default.
804 Enabled by default.
805
805
806 ``usefncache``
806 ``usefncache``
807 Enable or disable the "fncache" repository format which enhances
807 Enable or disable the "fncache" repository format which enhances
808 the "store" repository format (which has to be enabled to use
808 the "store" repository format (which has to be enabled to use
809 fncache) to allow longer filenames and avoids using Windows
809 fncache) to allow longer filenames and avoids using Windows
810 reserved names, e.g. "nul".
810 reserved names, e.g. "nul".
811
811
812 Repositories with this on-disk format require Mercurial version 1.1.
812 Repositories with this on-disk format require Mercurial version 1.1.
813
813
814 Enabled by default.
814 Enabled by default.
815
815
816 ``usestore``
816 ``usestore``
817 Enable or disable the "store" repository format which improves
817 Enable or disable the "store" repository format which improves
818 compatibility with systems that fold case or otherwise mangle
818 compatibility with systems that fold case or otherwise mangle
819 filenames. Disabling this option will allow you to store longer filenames
819 filenames. Disabling this option will allow you to store longer filenames
820 in some situations at the expense of compatibility.
820 in some situations at the expense of compatibility.
821
821
822 Repositories with this on-disk format require Mercurial version 0.9.4.
822 Repositories with this on-disk format require Mercurial version 0.9.4.
823
823
824 Enabled by default.
824 Enabled by default.
825
825
826 ``graph``
826 ``graph``
827 ---------
827 ---------
828
828
829 Web graph view configuration. This section let you change graph
829 Web graph view configuration. This section let you change graph
830 elements display properties by branches, for instance to make the
830 elements display properties by branches, for instance to make the
831 ``default`` branch stand out.
831 ``default`` branch stand out.
832
832
833 Each line has the following format::
833 Each line has the following format::
834
834
835 <branch>.<argument> = <value>
835 <branch>.<argument> = <value>
836
836
837 where ``<branch>`` is the name of the branch being
837 where ``<branch>`` is the name of the branch being
838 customized. Example::
838 customized. Example::
839
839
840 [graph]
840 [graph]
841 # 2px width
841 # 2px width
842 default.width = 2
842 default.width = 2
843 # red color
843 # red color
844 default.color = FF0000
844 default.color = FF0000
845
845
846 Supported arguments:
846 Supported arguments:
847
847
848 ``width``
848 ``width``
849 Set branch edges width in pixels.
849 Set branch edges width in pixels.
850
850
851 ``color``
851 ``color``
852 Set branch edges color in hexadecimal RGB notation.
852 Set branch edges color in hexadecimal RGB notation.
853
853
854 ``hooks``
854 ``hooks``
855 ---------
855 ---------
856
856
857 Commands or Python functions that get automatically executed by
857 Commands or Python functions that get automatically executed by
858 various actions such as starting or finishing a commit. Multiple
858 various actions such as starting or finishing a commit. Multiple
859 hooks can be run for the same action by appending a suffix to the
859 hooks can be run for the same action by appending a suffix to the
860 action. Overriding a site-wide hook can be done by changing its
860 action. Overriding a site-wide hook can be done by changing its
861 value or setting it to an empty string. Hooks can be prioritized
861 value or setting it to an empty string. Hooks can be prioritized
862 by adding a prefix of ``priority.`` to the hook name on a new line
862 by adding a prefix of ``priority.`` to the hook name on a new line
863 and setting the priority. The default priority is 0.
863 and setting the priority. The default priority is 0.
864
864
865 Example ``.hg/hgrc``::
865 Example ``.hg/hgrc``::
866
866
867 [hooks]
867 [hooks]
868 # update working directory after adding changesets
868 # update working directory after adding changesets
869 changegroup.update = hg update
869 changegroup.update = hg update
870 # do not use the site-wide hook
870 # do not use the site-wide hook
871 incoming =
871 incoming =
872 incoming.email = /my/email/hook
872 incoming.email = /my/email/hook
873 incoming.autobuild = /my/build/hook
873 incoming.autobuild = /my/build/hook
874 # force autobuild hook to run before other incoming hooks
874 # force autobuild hook to run before other incoming hooks
875 priority.incoming.autobuild = 1
875 priority.incoming.autobuild = 1
876
876
877 Most hooks are run with environment variables set that give useful
877 Most hooks are run with environment variables set that give useful
878 additional information. For each hook below, the environment variables
878 additional information. For each hook below, the environment variables
879 it is passed are listed with names in the form ``$HG_foo``. The
879 it is passed are listed with names in the form ``$HG_foo``. The
880 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
880 ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks.
881 They contain the type of hook which triggered the run and the full name
881 They contain the type of hook which triggered the run and the full name
882 of the hook in the config, respectively. In the example above, this will
882 of the hook in the config, respectively. In the example above, this will
883 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
883 be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``.
884
884
885 ``changegroup``
885 ``changegroup``
886 Run after a changegroup has been added via push, pull or unbundle. The ID of
886 Run after a changegroup has been added via push, pull or unbundle. The ID of
887 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
887 the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``.
888 The URL from which changes came is in ``$HG_URL``.
888 The URL from which changes came is in ``$HG_URL``.
889
889
890 ``commit``
890 ``commit``
891 Run after a changeset has been created in the local repository. The ID
891 Run after a changeset has been created in the local repository. The ID
892 of the newly created changeset is in ``$HG_NODE``. Parent changeset
892 of the newly created changeset is in ``$HG_NODE``. Parent changeset
893 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
893 IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
894
894
895 ``incoming``
895 ``incoming``
896 Run after a changeset has been pulled, pushed, or unbundled into
896 Run after a changeset has been pulled, pushed, or unbundled into
897 the local repository. The ID of the newly arrived changeset is in
897 the local repository. The ID of the newly arrived changeset is in
898 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
898 ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``.
899
899
900 ``outgoing``
900 ``outgoing``
901 Run after sending changes from the local repository to another. The ID of
901 Run after sending changes from the local repository to another. The ID of
902 first changeset sent is in ``$HG_NODE``. The source of operation is in
902 first changeset sent is in ``$HG_NODE``. The source of operation is in
903 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
903 ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`.
904
904
905 ``post-<command>``
905 ``post-<command>``
906 Run after successful invocations of the associated command. The
906 Run after successful invocations of the associated command. The
907 contents of the command line are passed as ``$HG_ARGS`` and the result
907 contents of the command line are passed as ``$HG_ARGS`` and the result
908 code in ``$HG_RESULT``. Parsed command line arguments are passed as
908 code in ``$HG_RESULT``. Parsed command line arguments are passed as
909 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
909 ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of
910 the python data internally passed to <command>. ``$HG_OPTS`` is a
910 the python data internally passed to <command>. ``$HG_OPTS`` is a
911 dictionary of options (with unspecified options set to their defaults).
911 dictionary of options (with unspecified options set to their defaults).
912 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
912 ``$HG_PATS`` is a list of arguments. Hook failure is ignored.
913
913
914 ``fail-<command>``
914 ``fail-<command>``
915 Run after a failed invocation of an associated command. The contents
915 Run after a failed invocation of an associated command. The contents
916 of the command line are passed as ``$HG_ARGS``. Parsed command line
916 of the command line are passed as ``$HG_ARGS``. Parsed command line
917 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
917 arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain
918 string representations of the python data internally passed to
918 string representations of the python data internally passed to
919 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
919 <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified
920 options set to their defaults). ``$HG_PATS`` is a list of arguments.
920 options set to their defaults). ``$HG_PATS`` is a list of arguments.
921 Hook failure is ignored.
921 Hook failure is ignored.
922
922
923 ``pre-<command>``
923 ``pre-<command>``
924 Run before executing the associated command. The contents of the
924 Run before executing the associated command. The contents of the
925 command line are passed as ``$HG_ARGS``. Parsed command line arguments
925 command line are passed as ``$HG_ARGS``. Parsed command line arguments
926 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
926 are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string
927 representations of the data internally passed to <command>. ``$HG_OPTS``
927 representations of the data internally passed to <command>. ``$HG_OPTS``
928 is a dictionary of options (with unspecified options set to their
928 is a dictionary of options (with unspecified options set to their
929 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
929 defaults). ``$HG_PATS`` is a list of arguments. If the hook returns
930 failure, the command doesn't execute and Mercurial returns the failure
930 failure, the command doesn't execute and Mercurial returns the failure
931 code.
931 code.
932
932
933 ``prechangegroup``
933 ``prechangegroup``
934 Run before a changegroup is added via push, pull or unbundle. Exit
934 Run before a changegroup is added via push, pull or unbundle. Exit
935 status 0 allows the changegroup to proceed. A non-zero status will
935 status 0 allows the changegroup to proceed. A non-zero status will
936 cause the push, pull or unbundle to fail. The URL from which changes
936 cause the push, pull or unbundle to fail. The URL from which changes
937 will come is in ``$HG_URL``.
937 will come is in ``$HG_URL``.
938
938
939 ``precommit``
939 ``precommit``
940 Run before starting a local commit. Exit status 0 allows the
940 Run before starting a local commit. Exit status 0 allows the
941 commit to proceed. A non-zero status will cause the commit to fail.
941 commit to proceed. A non-zero status will cause the commit to fail.
942 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
942 Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
943
943
944 ``prelistkeys``
944 ``prelistkeys``
945 Run before listing pushkeys (like bookmarks) in the
945 Run before listing pushkeys (like bookmarks) in the
946 repository. A non-zero status will cause failure. The key namespace is
946 repository. A non-zero status will cause failure. The key namespace is
947 in ``$HG_NAMESPACE``.
947 in ``$HG_NAMESPACE``.
948
948
949 ``preoutgoing``
949 ``preoutgoing``
950 Run before collecting changes to send from the local repository to
950 Run before collecting changes to send from the local repository to
951 another. A non-zero status will cause failure. This lets you prevent
951 another. A non-zero status will cause failure. This lets you prevent
952 pull over HTTP or SSH. It can also prevent propagating commits (via
952 pull over HTTP or SSH. It can also prevent propagating commits (via
953 local pull, push (outbound) or bundle commands), but not completely,
953 local pull, push (outbound) or bundle commands), but not completely,
954 since you can just copy files instead. The source of operation is in
954 since you can just copy files instead. The source of operation is in
955 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
955 ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote
956 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
956 SSH or HTTP repository. If "push", "pull" or "bundle", the operation
957 is happening on behalf of a repository on same system.
957 is happening on behalf of a repository on same system.
958
958
959 ``prepushkey``
959 ``prepushkey``
960 Run before a pushkey (like a bookmark) is added to the
960 Run before a pushkey (like a bookmark) is added to the
961 repository. A non-zero status will cause the key to be rejected. The
961 repository. A non-zero status will cause the key to be rejected. The
962 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
962 key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``,
963 the old value (if any) is in ``$HG_OLD``, and the new value is in
963 the old value (if any) is in ``$HG_OLD``, and the new value is in
964 ``$HG_NEW``.
964 ``$HG_NEW``.
965
965
966 ``pretag``
966 ``pretag``
967 Run before creating a tag. Exit status 0 allows the tag to be
967 Run before creating a tag. Exit status 0 allows the tag to be
968 created. A non-zero status will cause the tag to fail. The ID of the
968 created. A non-zero status will cause the tag to fail. The ID of the
969 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
969 changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The
970 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
970 tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``.
971
971
972 ``pretxnopen``
972 ``pretxnopen``
973 Run before any new repository transaction is open. The reason for the
973 Run before any new repository transaction is open. The reason for the
974 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
974 transaction will be in ``$HG_TXNNAME``, and a unique identifier for the
975 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
975 transaction will be in ``HG_TXNID``. A non-zero status will prevent the
976 transaction from being opened.
976 transaction from being opened.
977
977
978 ``pretxnclose``
978 ``pretxnclose``
979 Run right before the transaction is actually finalized. Any repository change
979 Run right before the transaction is actually finalized. Any repository change
980 will be visible to the hook program. This lets you validate the transaction
980 will be visible to the hook program. This lets you validate the transaction
981 content or change it. Exit status 0 allows the commit to proceed. A non-zero
981 content or change it. Exit status 0 allows the commit to proceed. A non-zero
982 status will cause the transaction to be rolled back. The reason for the
982 status will cause the transaction to be rolled back. The reason for the
983 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
983 transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for
984 the transaction will be in ``HG_TXNID``. The rest of the available data will
984 the transaction will be in ``HG_TXNID``. The rest of the available data will
985 vary according the transaction type. New changesets will add ``$HG_NODE``
985 vary according the transaction type. New changesets will add ``$HG_NODE``
986 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
986 (the ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last
987 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
987 added changeset), ``$HG_URL`` and ``$HG_SOURCE`` variables. Bookmark and
988 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
988 phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
989 respectively, etc.
989 respectively, etc.
990
990
991 ``pretxnclose-bookmark``
991 ``pretxnclose-bookmark``
992 Run right before a bookmark change is actually finalized. Any repository
992 Run right before a bookmark change is actually finalized. Any repository
993 change will be visible to the hook program. This lets you validate the
993 change will be visible to the hook program. This lets you validate the
994 transaction content or change it. Exit status 0 allows the commit to
994 transaction content or change it. Exit status 0 allows the commit to
995 proceed. A non-zero status will cause the transaction to be rolled back.
995 proceed. A non-zero status will cause the transaction to be rolled back.
996 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
996 The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
997 bookmark location will be available in ``$HG_NODE`` while the previous
997 bookmark location will be available in ``$HG_NODE`` while the previous
998 location will be available in ``$HG_OLDNODE``. In case of a bookmark
998 location will be available in ``$HG_OLDNODE``. In case of a bookmark
999 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
999 creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
1000 will be empty.
1000 will be empty.
1001 In addition, the reason for the transaction opening will be in
1001 In addition, the reason for the transaction opening will be in
1002 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1002 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1003 ``HG_TXNID``.
1003 ``HG_TXNID``.
1004
1004
1005 ``pretxnclose-phase``
1005 ``pretxnclose-phase``
1006 Run right before a phase change is actually finalized. Any repository change
1006 Run right before a phase change is actually finalized. Any repository change
1007 will be visible to the hook program. This lets you validate the transaction
1007 will be visible to the hook program. This lets you validate the transaction
1008 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1008 content or change it. Exit status 0 allows the commit to proceed. A non-zero
1009 status will cause the transaction to be rolled back. The hook is called
1009 status will cause the transaction to be rolled back. The hook is called
1010 multiple times, once for each revision affected by a phase change.
1010 multiple times, once for each revision affected by a phase change.
1011 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1011 The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
1012 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1012 while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
1013 will be empty. In addition, the reason for the transaction opening will be in
1013 will be empty. In addition, the reason for the transaction opening will be in
1014 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1014 ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
1015 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1015 ``HG_TXNID``. The hook is also run for newly added revisions. In this case
1016 the ``$HG_OLDPHASE`` entry will be empty.
1016 the ``$HG_OLDPHASE`` entry will be empty.
1017
1017
1018 ``txnclose``
1018 ``txnclose``
1019 Run after any repository transaction has been committed. At this
1019 Run after any repository transaction has been committed. At this
1020 point, the transaction can no longer be rolled back. The hook will run
1020 point, the transaction can no longer be rolled back. The hook will run
1021 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1021 after the lock is released. See :hg:`help config.hooks.pretxnclose` for
1022 details about available variables.
1022 details about available variables.
1023
1023
1024 ``txnclose-bookmark``
1024 ``txnclose-bookmark``
1025 Run after any bookmark change has been committed. At this point, the
1025 Run after any bookmark change has been committed. At this point, the
1026 transaction can no longer be rolled back. The hook will run after the lock
1026 transaction can no longer be rolled back. The hook will run after the lock
1027 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1027 is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
1028 about available variables.
1028 about available variables.
1029
1029
1030 ``txnclose-phase``
1030 ``txnclose-phase``
1031 Run after any phase change has been committed. At this point, the
1031 Run after any phase change has been committed. At this point, the
1032 transaction can no longer be rolled back. The hook will run after the lock
1032 transaction can no longer be rolled back. The hook will run after the lock
1033 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1033 is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
1034 available variables.
1034 available variables.
1035
1035
1036 ``txnabort``
1036 ``txnabort``
1037 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1037 Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
1038 for details about available variables.
1038 for details about available variables.
1039
1039
1040 ``pretxnchangegroup``
1040 ``pretxnchangegroup``
1041 Run after a changegroup has been added via push, pull or unbundle, but before
1041 Run after a changegroup has been added via push, pull or unbundle, but before
1042 the transaction has been committed. The changegroup is visible to the hook
1042 the transaction has been committed. The changegroup is visible to the hook
1043 program. This allows validation of incoming changes before accepting them.
1043 program. This allows validation of incoming changes before accepting them.
1044 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1044 The ID of the first new changeset is in ``$HG_NODE`` and last is in
1045 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1045 ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero
1046 status will cause the transaction to be rolled back, and the push, pull or
1046 status will cause the transaction to be rolled back, and the push, pull or
1047 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1047 unbundle will fail. The URL that was the source of changes is in ``$HG_URL``.
1048
1048
1049 ``pretxncommit``
1049 ``pretxncommit``
1050 Run after a changeset has been created, but before the transaction is
1050 Run after a changeset has been created, but before the transaction is
1051 committed. The changeset is visible to the hook program. This allows
1051 committed. The changeset is visible to the hook program. This allows
1052 validation of the commit message and changes. Exit status 0 allows the
1052 validation of the commit message and changes. Exit status 0 allows the
1053 commit to proceed. A non-zero status will cause the transaction to
1053 commit to proceed. A non-zero status will cause the transaction to
1054 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1054 be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent
1055 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1055 changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``.
1056
1056
1057 ``preupdate``
1057 ``preupdate``
1058 Run before updating the working directory. Exit status 0 allows
1058 Run before updating the working directory. Exit status 0 allows
1059 the update to proceed. A non-zero status will prevent the update.
1059 the update to proceed. A non-zero status will prevent the update.
1060 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1060 The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a
1061 merge, the ID of second new parent is in ``$HG_PARENT2``.
1061 merge, the ID of second new parent is in ``$HG_PARENT2``.
1062
1062
1063 ``listkeys``
1063 ``listkeys``
1064 Run after listing pushkeys (like bookmarks) in the repository. The
1064 Run after listing pushkeys (like bookmarks) in the repository. The
1065 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1065 key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a
1066 dictionary containing the keys and values.
1066 dictionary containing the keys and values.
1067
1067
1068 ``pushkey``
1068 ``pushkey``
1069 Run after a pushkey (like a bookmark) is added to the
1069 Run after a pushkey (like a bookmark) is added to the
1070 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1070 repository. The key namespace is in ``$HG_NAMESPACE``, the key is in
1071 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1071 ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new
1072 value is in ``$HG_NEW``.
1072 value is in ``$HG_NEW``.
1073
1073
1074 ``tag``
1074 ``tag``
1075 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1075 Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``.
1076 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1076 The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in
1077 the repository if ``$HG_LOCAL=0``.
1077 the repository if ``$HG_LOCAL=0``.
1078
1078
1079 ``update``
1079 ``update``
1080 Run after updating the working directory. The changeset ID of first
1080 Run after updating the working directory. The changeset ID of first
1081 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1081 new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new
1082 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1082 parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the
1083 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1083 update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``.
1084
1084
1085 .. note::
1085 .. note::
1086
1086
1087 It is generally better to use standard hooks rather than the
1087 It is generally better to use standard hooks rather than the
1088 generic pre- and post- command hooks, as they are guaranteed to be
1088 generic pre- and post- command hooks, as they are guaranteed to be
1089 called in the appropriate contexts for influencing transactions.
1089 called in the appropriate contexts for influencing transactions.
1090 Also, hooks like "commit" will be called in all contexts that
1090 Also, hooks like "commit" will be called in all contexts that
1091 generate a commit (e.g. tag) and not just the commit command.
1091 generate a commit (e.g. tag) and not just the commit command.
1092
1092
1093 .. note::
1093 .. note::
1094
1094
1095 Environment variables with empty values may not be passed to
1095 Environment variables with empty values may not be passed to
1096 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1096 hooks on platforms such as Windows. As an example, ``$HG_PARENT2``
1097 will have an empty value under Unix-like platforms for non-merge
1097 will have an empty value under Unix-like platforms for non-merge
1098 changesets, while it will not be available at all under Windows.
1098 changesets, while it will not be available at all under Windows.
1099
1099
1100 The syntax for Python hooks is as follows::
1100 The syntax for Python hooks is as follows::
1101
1101
1102 hookname = python:modulename.submodule.callable
1102 hookname = python:modulename.submodule.callable
1103 hookname = python:/path/to/python/module.py:callable
1103 hookname = python:/path/to/python/module.py:callable
1104
1104
1105 Python hooks are run within the Mercurial process. Each hook is
1105 Python hooks are run within the Mercurial process. Each hook is
1106 called with at least three keyword arguments: a ui object (keyword
1106 called with at least three keyword arguments: a ui object (keyword
1107 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1107 ``ui``), a repository object (keyword ``repo``), and a ``hooktype``
1108 keyword that tells what kind of hook is used. Arguments listed as
1108 keyword that tells what kind of hook is used. Arguments listed as
1109 environment variables above are passed as keyword arguments, with no
1109 environment variables above are passed as keyword arguments, with no
1110 ``HG_`` prefix, and names in lower case.
1110 ``HG_`` prefix, and names in lower case.
1111
1111
1112 If a Python hook returns a "true" value or raises an exception, this
1112 If a Python hook returns a "true" value or raises an exception, this
1113 is treated as a failure.
1113 is treated as a failure.
1114
1114
1115
1115
1116 ``hostfingerprints``
1116 ``hostfingerprints``
1117 --------------------
1117 --------------------
1118
1118
1119 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1119 (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.)
1120
1120
1121 Fingerprints of the certificates of known HTTPS servers.
1121 Fingerprints of the certificates of known HTTPS servers.
1122
1122
1123 A HTTPS connection to a server with a fingerprint configured here will
1123 A HTTPS connection to a server with a fingerprint configured here will
1124 only succeed if the servers certificate matches the fingerprint.
1124 only succeed if the servers certificate matches the fingerprint.
1125 This is very similar to how ssh known hosts works.
1125 This is very similar to how ssh known hosts works.
1126
1126
1127 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1127 The fingerprint is the SHA-1 hash value of the DER encoded certificate.
1128 Multiple values can be specified (separated by spaces or commas). This can
1128 Multiple values can be specified (separated by spaces or commas). This can
1129 be used to define both old and new fingerprints while a host transitions
1129 be used to define both old and new fingerprints while a host transitions
1130 to a new certificate.
1130 to a new certificate.
1131
1131
1132 The CA chain and web.cacerts is not used for servers with a fingerprint.
1132 The CA chain and web.cacerts is not used for servers with a fingerprint.
1133
1133
1134 For example::
1134 For example::
1135
1135
1136 [hostfingerprints]
1136 [hostfingerprints]
1137 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1137 hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1138 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1138 hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33
1139
1139
1140 ``hostsecurity``
1140 ``hostsecurity``
1141 ----------------
1141 ----------------
1142
1142
1143 Used to specify global and per-host security settings for connecting to
1143 Used to specify global and per-host security settings for connecting to
1144 other machines.
1144 other machines.
1145
1145
1146 The following options control default behavior for all hosts.
1146 The following options control default behavior for all hosts.
1147
1147
1148 ``ciphers``
1148 ``ciphers``
1149 Defines the cryptographic ciphers to use for connections.
1149 Defines the cryptographic ciphers to use for connections.
1150
1150
1151 Value must be a valid OpenSSL Cipher List Format as documented at
1151 Value must be a valid OpenSSL Cipher List Format as documented at
1152 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1152 https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT.
1153
1153
1154 This setting is for advanced users only. Setting to incorrect values
1154 This setting is for advanced users only. Setting to incorrect values
1155 can significantly lower connection security or decrease performance.
1155 can significantly lower connection security or decrease performance.
1156 You have been warned.
1156 You have been warned.
1157
1157
1158 This option requires Python 2.7.
1158 This option requires Python 2.7.
1159
1159
1160 ``minimumprotocol``
1160 ``minimumprotocol``
1161 Defines the minimum channel encryption protocol to use.
1161 Defines the minimum channel encryption protocol to use.
1162
1162
1163 By default, the highest version of TLS supported by both client and server
1163 By default, the highest version of TLS supported by both client and server
1164 is used.
1164 is used.
1165
1165
1166 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1166 Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``.
1167
1167
1168 When running on an old Python version, only ``tls1.0`` is allowed since
1168 When running on an old Python version, only ``tls1.0`` is allowed since
1169 old versions of Python only support up to TLS 1.0.
1169 old versions of Python only support up to TLS 1.0.
1170
1170
1171 When running a Python that supports modern TLS versions, the default is
1171 When running a Python that supports modern TLS versions, the default is
1172 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1172 ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this
1173 weakens security and should only be used as a feature of last resort if
1173 weakens security and should only be used as a feature of last resort if
1174 a server does not support TLS 1.1+.
1174 a server does not support TLS 1.1+.
1175
1175
1176 Options in the ``[hostsecurity]`` section can have the form
1176 Options in the ``[hostsecurity]`` section can have the form
1177 ``hostname``:``setting``. This allows multiple settings to be defined on a
1177 ``hostname``:``setting``. This allows multiple settings to be defined on a
1178 per-host basis.
1178 per-host basis.
1179
1179
1180 The following per-host settings can be defined.
1180 The following per-host settings can be defined.
1181
1181
1182 ``ciphers``
1182 ``ciphers``
1183 This behaves like ``ciphers`` as described above except it only applies
1183 This behaves like ``ciphers`` as described above except it only applies
1184 to the host on which it is defined.
1184 to the host on which it is defined.
1185
1185
1186 ``fingerprints``
1186 ``fingerprints``
1187 A list of hashes of the DER encoded peer/remote certificate. Values have
1187 A list of hashes of the DER encoded peer/remote certificate. Values have
1188 the form ``algorithm``:``fingerprint``. e.g.
1188 the form ``algorithm``:``fingerprint``. e.g.
1189 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1189 ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``.
1190 In addition, colons (``:``) can appear in the fingerprint part.
1190 In addition, colons (``:``) can appear in the fingerprint part.
1191
1191
1192 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1192 The following algorithms/prefixes are supported: ``sha1``, ``sha256``,
1193 ``sha512``.
1193 ``sha512``.
1194
1194
1195 Use of ``sha256`` or ``sha512`` is preferred.
1195 Use of ``sha256`` or ``sha512`` is preferred.
1196
1196
1197 If a fingerprint is specified, the CA chain is not validated for this
1197 If a fingerprint is specified, the CA chain is not validated for this
1198 host and Mercurial will require the remote certificate to match one
1198 host and Mercurial will require the remote certificate to match one
1199 of the fingerprints specified. This means if the server updates its
1199 of the fingerprints specified. This means if the server updates its
1200 certificate, Mercurial will abort until a new fingerprint is defined.
1200 certificate, Mercurial will abort until a new fingerprint is defined.
1201 This can provide stronger security than traditional CA-based validation
1201 This can provide stronger security than traditional CA-based validation
1202 at the expense of convenience.
1202 at the expense of convenience.
1203
1203
1204 This option takes precedence over ``verifycertsfile``.
1204 This option takes precedence over ``verifycertsfile``.
1205
1205
1206 ``minimumprotocol``
1206 ``minimumprotocol``
1207 This behaves like ``minimumprotocol`` as described above except it
1207 This behaves like ``minimumprotocol`` as described above except it
1208 only applies to the host on which it is defined.
1208 only applies to the host on which it is defined.
1209
1209
1210 ``verifycertsfile``
1210 ``verifycertsfile``
1211 Path to file a containing a list of PEM encoded certificates used to
1211 Path to file a containing a list of PEM encoded certificates used to
1212 verify the server certificate. Environment variables and ``~user``
1212 verify the server certificate. Environment variables and ``~user``
1213 constructs are expanded in the filename.
1213 constructs are expanded in the filename.
1214
1214
1215 The server certificate or the certificate's certificate authority (CA)
1215 The server certificate or the certificate's certificate authority (CA)
1216 must match a certificate from this file or certificate verification
1216 must match a certificate from this file or certificate verification
1217 will fail and connections to the server will be refused.
1217 will fail and connections to the server will be refused.
1218
1218
1219 If defined, only certificates provided by this file will be used:
1219 If defined, only certificates provided by this file will be used:
1220 ``web.cacerts`` and any system/default certificates will not be
1220 ``web.cacerts`` and any system/default certificates will not be
1221 used.
1221 used.
1222
1222
1223 This option has no effect if the per-host ``fingerprints`` option
1223 This option has no effect if the per-host ``fingerprints`` option
1224 is set.
1224 is set.
1225
1225
1226 The format of the file is as follows::
1226 The format of the file is as follows::
1227
1227
1228 -----BEGIN CERTIFICATE-----
1228 -----BEGIN CERTIFICATE-----
1229 ... (certificate in base64 PEM encoding) ...
1229 ... (certificate in base64 PEM encoding) ...
1230 -----END CERTIFICATE-----
1230 -----END CERTIFICATE-----
1231 -----BEGIN CERTIFICATE-----
1231 -----BEGIN CERTIFICATE-----
1232 ... (certificate in base64 PEM encoding) ...
1232 ... (certificate in base64 PEM encoding) ...
1233 -----END CERTIFICATE-----
1233 -----END CERTIFICATE-----
1234
1234
1235 For example::
1235 For example::
1236
1236
1237 [hostsecurity]
1237 [hostsecurity]
1238 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1238 hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2
1239 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
1239 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
1240 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
1240 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
1241 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1241 foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem
1242
1242
1243 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1243 To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1
1244 when connecting to ``hg.example.com``::
1244 when connecting to ``hg.example.com``::
1245
1245
1246 [hostsecurity]
1246 [hostsecurity]
1247 minimumprotocol = tls1.2
1247 minimumprotocol = tls1.2
1248 hg.example.com:minimumprotocol = tls1.1
1248 hg.example.com:minimumprotocol = tls1.1
1249
1249
1250 ``http_proxy``
1250 ``http_proxy``
1251 --------------
1251 --------------
1252
1252
1253 Used to access web-based Mercurial repositories through a HTTP
1253 Used to access web-based Mercurial repositories through a HTTP
1254 proxy.
1254 proxy.
1255
1255
1256 ``host``
1256 ``host``
1257 Host name and (optional) port of the proxy server, for example
1257 Host name and (optional) port of the proxy server, for example
1258 "myproxy:8000".
1258 "myproxy:8000".
1259
1259
1260 ``no``
1260 ``no``
1261 Optional. Comma-separated list of host names that should bypass
1261 Optional. Comma-separated list of host names that should bypass
1262 the proxy.
1262 the proxy.
1263
1263
1264 ``passwd``
1264 ``passwd``
1265 Optional. Password to authenticate with at the proxy server.
1265 Optional. Password to authenticate with at the proxy server.
1266
1266
1267 ``user``
1267 ``user``
1268 Optional. User name to authenticate with at the proxy server.
1268 Optional. User name to authenticate with at the proxy server.
1269
1269
1270 ``always``
1270 ``always``
1271 Optional. Always use the proxy, even for localhost and any entries
1271 Optional. Always use the proxy, even for localhost and any entries
1272 in ``http_proxy.no``. (default: False)
1272 in ``http_proxy.no``. (default: False)
1273
1273
1274 ``merge``
1274 ``merge``
1275 ---------
1275 ---------
1276
1276
1277 This section specifies behavior during merges and updates.
1277 This section specifies behavior during merges and updates.
1278
1278
1279 ``checkignored``
1279 ``checkignored``
1280 Controls behavior when an ignored file on disk has the same name as a tracked
1280 Controls behavior when an ignored file on disk has the same name as a tracked
1281 file in the changeset being merged or updated to, and has different
1281 file in the changeset being merged or updated to, and has different
1282 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1282 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
1283 abort on such files. With ``warn``, warn on such files and back them up as
1283 abort on such files. With ``warn``, warn on such files and back them up as
1284 ``.orig``. With ``ignore``, don't print a warning and back them up as
1284 ``.orig``. With ``ignore``, don't print a warning and back them up as
1285 ``.orig``. (default: ``abort``)
1285 ``.orig``. (default: ``abort``)
1286
1286
1287 ``checkunknown``
1287 ``checkunknown``
1288 Controls behavior when an unknown file that isn't ignored has the same name
1288 Controls behavior when an unknown file that isn't ignored has the same name
1289 as a tracked file in the changeset being merged or updated to, and has
1289 as a tracked file in the changeset being merged or updated to, and has
1290 different contents. Similar to ``merge.checkignored``, except for files that
1290 different contents. Similar to ``merge.checkignored``, except for files that
1291 are not ignored. (default: ``abort``)
1291 are not ignored. (default: ``abort``)
1292
1292
1293 ``on-failure``
1293 ``on-failure``
1294 When set to ``continue`` (the default), the merge process attempts to
1294 When set to ``continue`` (the default), the merge process attempts to
1295 merge all unresolved files using the merge chosen tool, regardless of
1295 merge all unresolved files using the merge chosen tool, regardless of
1296 whether previous file merge attempts during the process succeeded or not.
1296 whether previous file merge attempts during the process succeeded or not.
1297 Setting this to ``prompt`` will prompt after any merge failure continue
1297 Setting this to ``prompt`` will prompt after any merge failure continue
1298 or halt the merge process. Setting this to ``halt`` will automatically
1298 or halt the merge process. Setting this to ``halt`` will automatically
1299 halt the merge process on any merge tool failure. The merge process
1299 halt the merge process on any merge tool failure. The merge process
1300 can be restarted by using the ``resolve`` command. When a merge is
1300 can be restarted by using the ``resolve`` command. When a merge is
1301 halted, the repository is left in a normal ``unresolved`` merge state.
1301 halted, the repository is left in a normal ``unresolved`` merge state.
1302 (default: ``continue``)
1302 (default: ``continue``)
1303
1303
1304 ``merge-patterns``
1304 ``merge-patterns``
1305 ------------------
1305 ------------------
1306
1306
1307 This section specifies merge tools to associate with particular file
1307 This section specifies merge tools to associate with particular file
1308 patterns. Tools matched here will take precedence over the default
1308 patterns. Tools matched here will take precedence over the default
1309 merge tool. Patterns are globs by default, rooted at the repository
1309 merge tool. Patterns are globs by default, rooted at the repository
1310 root.
1310 root.
1311
1311
1312 Example::
1312 Example::
1313
1313
1314 [merge-patterns]
1314 [merge-patterns]
1315 **.c = kdiff3
1315 **.c = kdiff3
1316 **.jpg = myimgmerge
1316 **.jpg = myimgmerge
1317
1317
1318 ``merge-tools``
1318 ``merge-tools``
1319 ---------------
1319 ---------------
1320
1320
1321 This section configures external merge tools to use for file-level
1321 This section configures external merge tools to use for file-level
1322 merges. This section has likely been preconfigured at install time.
1322 merges. This section has likely been preconfigured at install time.
1323 Use :hg:`config merge-tools` to check the existing configuration.
1323 Use :hg:`config merge-tools` to check the existing configuration.
1324 Also see :hg:`help merge-tools` for more details.
1324 Also see :hg:`help merge-tools` for more details.
1325
1325
1326 Example ``~/.hgrc``::
1326 Example ``~/.hgrc``::
1327
1327
1328 [merge-tools]
1328 [merge-tools]
1329 # Override stock tool location
1329 # Override stock tool location
1330 kdiff3.executable = ~/bin/kdiff3
1330 kdiff3.executable = ~/bin/kdiff3
1331 # Specify command line
1331 # Specify command line
1332 kdiff3.args = $base $local $other -o $output
1332 kdiff3.args = $base $local $other -o $output
1333 # Give higher priority
1333 # Give higher priority
1334 kdiff3.priority = 1
1334 kdiff3.priority = 1
1335
1335
1336 # Changing the priority of preconfigured tool
1336 # Changing the priority of preconfigured tool
1337 meld.priority = 0
1337 meld.priority = 0
1338
1338
1339 # Disable a preconfigured tool
1339 # Disable a preconfigured tool
1340 vimdiff.disabled = yes
1340 vimdiff.disabled = yes
1341
1341
1342 # Define new tool
1342 # Define new tool
1343 myHtmlTool.args = -m $local $other $base $output
1343 myHtmlTool.args = -m $local $other $base $output
1344 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1344 myHtmlTool.regkey = Software\FooSoftware\HtmlMerge
1345 myHtmlTool.priority = 1
1345 myHtmlTool.priority = 1
1346
1346
1347 Supported arguments:
1347 Supported arguments:
1348
1348
1349 ``priority``
1349 ``priority``
1350 The priority in which to evaluate this tool.
1350 The priority in which to evaluate this tool.
1351 (default: 0)
1351 (default: 0)
1352
1352
1353 ``executable``
1353 ``executable``
1354 Either just the name of the executable or its pathname.
1354 Either just the name of the executable or its pathname.
1355
1355
1356 .. container:: windows
1356 .. container:: windows
1357
1357
1358 On Windows, the path can use environment variables with ${ProgramFiles}
1358 On Windows, the path can use environment variables with ${ProgramFiles}
1359 syntax.
1359 syntax.
1360
1360
1361 (default: the tool name)
1361 (default: the tool name)
1362
1362
1363 ``args``
1363 ``args``
1364 The arguments to pass to the tool executable. You can refer to the
1364 The arguments to pass to the tool executable. You can refer to the
1365 files being merged as well as the output file through these
1365 files being merged as well as the output file through these
1366 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
1366 variables: ``$base``, ``$local``, ``$other``, ``$output``. The meaning
1367 of ``$local`` and ``$other`` can vary depending on which action is being
1367 of ``$local`` and ``$other`` can vary depending on which action is being
1368 performed. During and update or merge, ``$local`` represents the original
1368 performed. During and update or merge, ``$local`` represents the original
1369 state of the file, while ``$other`` represents the commit you are updating
1369 state of the file, while ``$other`` represents the commit you are updating
1370 to or the commit you are merging with. During a rebase ``$local``
1370 to or the commit you are merging with. During a rebase ``$local``
1371 represents the destination of the rebase, and ``$other`` represents the
1371 represents the destination of the rebase, and ``$other`` represents the
1372 commit being rebased.
1372 commit being rebased.
1373 (default: ``$local $base $other``)
1373 (default: ``$local $base $other``)
1374
1374
1375 ``premerge``
1375 ``premerge``
1376 Attempt to run internal non-interactive 3-way merge tool before
1376 Attempt to run internal non-interactive 3-way merge tool before
1377 launching external tool. Options are ``true``, ``false``, ``keep`` or
1377 launching external tool. Options are ``true``, ``false``, ``keep`` or
1378 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1378 ``keep-merge3``. The ``keep`` option will leave markers in the file if the
1379 premerge fails. The ``keep-merge3`` will do the same but include information
1379 premerge fails. The ``keep-merge3`` will do the same but include information
1380 about the base of the merge in the marker (see internal :merge3 in
1380 about the base of the merge in the marker (see internal :merge3 in
1381 :hg:`help merge-tools`).
1381 :hg:`help merge-tools`).
1382 (default: True)
1382 (default: True)
1383
1383
1384 ``binary``
1384 ``binary``
1385 This tool can merge binary files. (default: False, unless tool
1385 This tool can merge binary files. (default: False, unless tool
1386 was selected by file pattern match)
1386 was selected by file pattern match)
1387
1387
1388 ``symlink``
1388 ``symlink``
1389 This tool can merge symlinks. (default: False)
1389 This tool can merge symlinks. (default: False)
1390
1390
1391 ``check``
1391 ``check``
1392 A list of merge success-checking options:
1392 A list of merge success-checking options:
1393
1393
1394 ``changed``
1394 ``changed``
1395 Ask whether merge was successful when the merged file shows no changes.
1395 Ask whether merge was successful when the merged file shows no changes.
1396 ``conflicts``
1396 ``conflicts``
1397 Check whether there are conflicts even though the tool reported success.
1397 Check whether there are conflicts even though the tool reported success.
1398 ``prompt``
1398 ``prompt``
1399 Always prompt for merge success, regardless of success reported by tool.
1399 Always prompt for merge success, regardless of success reported by tool.
1400
1400
1401 ``fixeol``
1401 ``fixeol``
1402 Attempt to fix up EOL changes caused by the merge tool.
1402 Attempt to fix up EOL changes caused by the merge tool.
1403 (default: False)
1403 (default: False)
1404
1404
1405 ``gui``
1405 ``gui``
1406 This tool requires a graphical interface to run. (default: False)
1406 This tool requires a graphical interface to run. (default: False)
1407
1407
1408 .. container:: windows
1408 .. container:: windows
1409
1409
1410 ``regkey``
1410 ``regkey``
1411 Windows registry key which describes install location of this
1411 Windows registry key which describes install location of this
1412 tool. Mercurial will search for this key first under
1412 tool. Mercurial will search for this key first under
1413 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1413 ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``.
1414 (default: None)
1414 (default: None)
1415
1415
1416 ``regkeyalt``
1416 ``regkeyalt``
1417 An alternate Windows registry key to try if the first key is not
1417 An alternate Windows registry key to try if the first key is not
1418 found. The alternate key uses the same ``regname`` and ``regappend``
1418 found. The alternate key uses the same ``regname`` and ``regappend``
1419 semantics of the primary key. The most common use for this key
1419 semantics of the primary key. The most common use for this key
1420 is to search for 32bit applications on 64bit operating systems.
1420 is to search for 32bit applications on 64bit operating systems.
1421 (default: None)
1421 (default: None)
1422
1422
1423 ``regname``
1423 ``regname``
1424 Name of value to read from specified registry key.
1424 Name of value to read from specified registry key.
1425 (default: the unnamed (default) value)
1425 (default: the unnamed (default) value)
1426
1426
1427 ``regappend``
1427 ``regappend``
1428 String to append to the value read from the registry, typically
1428 String to append to the value read from the registry, typically
1429 the executable name of the tool.
1429 the executable name of the tool.
1430 (default: None)
1430 (default: None)
1431
1431
1432 ``pager``
1432 ``pager``
1433 ---------
1433 ---------
1434
1434
1435 Setting used to control when to paginate and with what external tool. See
1435 Setting used to control when to paginate and with what external tool. See
1436 :hg:`help pager` for details.
1436 :hg:`help pager` for details.
1437
1437
1438 ``pager``
1438 ``pager``
1439 Define the external tool used as pager.
1439 Define the external tool used as pager.
1440
1440
1441 If no pager is set, Mercurial uses the environment variable $PAGER.
1441 If no pager is set, Mercurial uses the environment variable $PAGER.
1442 If neither pager.pager, nor $PAGER is set, a default pager will be
1442 If neither pager.pager, nor $PAGER is set, a default pager will be
1443 used, typically `less` on Unix and `more` on Windows. Example::
1443 used, typically `less` on Unix and `more` on Windows. Example::
1444
1444
1445 [pager]
1445 [pager]
1446 pager = less -FRX
1446 pager = less -FRX
1447
1447
1448 ``ignore``
1448 ``ignore``
1449 List of commands to disable the pager for. Example::
1449 List of commands to disable the pager for. Example::
1450
1450
1451 [pager]
1451 [pager]
1452 ignore = version, help, update
1452 ignore = version, help, update
1453
1453
1454 ``patch``
1454 ``patch``
1455 ---------
1455 ---------
1456
1456
1457 Settings used when applying patches, for instance through the 'import'
1457 Settings used when applying patches, for instance through the 'import'
1458 command or with Mercurial Queues extension.
1458 command or with Mercurial Queues extension.
1459
1459
1460 ``eol``
1460 ``eol``
1461 When set to 'strict' patch content and patched files end of lines
1461 When set to 'strict' patch content and patched files end of lines
1462 are preserved. When set to ``lf`` or ``crlf``, both files end of
1462 are preserved. When set to ``lf`` or ``crlf``, both files end of
1463 lines are ignored when patching and the result line endings are
1463 lines are ignored when patching and the result line endings are
1464 normalized to either LF (Unix) or CRLF (Windows). When set to
1464 normalized to either LF (Unix) or CRLF (Windows). When set to
1465 ``auto``, end of lines are again ignored while patching but line
1465 ``auto``, end of lines are again ignored while patching but line
1466 endings in patched files are normalized to their original setting
1466 endings in patched files are normalized to their original setting
1467 on a per-file basis. If target file does not exist or has no end
1467 on a per-file basis. If target file does not exist or has no end
1468 of line, patch line endings are preserved.
1468 of line, patch line endings are preserved.
1469 (default: strict)
1469 (default: strict)
1470
1470
1471 ``fuzz``
1471 ``fuzz``
1472 The number of lines of 'fuzz' to allow when applying patches. This
1472 The number of lines of 'fuzz' to allow when applying patches. This
1473 controls how much context the patcher is allowed to ignore when
1473 controls how much context the patcher is allowed to ignore when
1474 trying to apply a patch.
1474 trying to apply a patch.
1475 (default: 2)
1475 (default: 2)
1476
1476
1477 ``paths``
1477 ``paths``
1478 ---------
1478 ---------
1479
1479
1480 Assigns symbolic names and behavior to repositories.
1480 Assigns symbolic names and behavior to repositories.
1481
1481
1482 Options are symbolic names defining the URL or directory that is the
1482 Options are symbolic names defining the URL or directory that is the
1483 location of the repository. Example::
1483 location of the repository. Example::
1484
1484
1485 [paths]
1485 [paths]
1486 my_server = https://example.com/my_repo
1486 my_server = https://example.com/my_repo
1487 local_path = /home/me/repo
1487 local_path = /home/me/repo
1488
1488
1489 These symbolic names can be used from the command line. To pull
1489 These symbolic names can be used from the command line. To pull
1490 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1490 from ``my_server``: :hg:`pull my_server`. To push to ``local_path``:
1491 :hg:`push local_path`.
1491 :hg:`push local_path`.
1492
1492
1493 Options containing colons (``:``) denote sub-options that can influence
1493 Options containing colons (``:``) denote sub-options that can influence
1494 behavior for that specific path. Example::
1494 behavior for that specific path. Example::
1495
1495
1496 [paths]
1496 [paths]
1497 my_server = https://example.com/my_path
1497 my_server = https://example.com/my_path
1498 my_server:pushurl = ssh://example.com/my_path
1498 my_server:pushurl = ssh://example.com/my_path
1499
1499
1500 The following sub-options can be defined:
1500 The following sub-options can be defined:
1501
1501
1502 ``pushurl``
1502 ``pushurl``
1503 The URL to use for push operations. If not defined, the location
1503 The URL to use for push operations. If not defined, the location
1504 defined by the path's main entry is used.
1504 defined by the path's main entry is used.
1505
1505
1506 ``pushrev``
1506 ``pushrev``
1507 A revset defining which revisions to push by default.
1507 A revset defining which revisions to push by default.
1508
1508
1509 When :hg:`push` is executed without a ``-r`` argument, the revset
1509 When :hg:`push` is executed without a ``-r`` argument, the revset
1510 defined by this sub-option is evaluated to determine what to push.
1510 defined by this sub-option is evaluated to determine what to push.
1511
1511
1512 For example, a value of ``.`` will push the working directory's
1512 For example, a value of ``.`` will push the working directory's
1513 revision by default.
1513 revision by default.
1514
1514
1515 Revsets specifying bookmarks will not result in the bookmark being
1515 Revsets specifying bookmarks will not result in the bookmark being
1516 pushed.
1516 pushed.
1517
1517
1518 The following special named paths exist:
1518 The following special named paths exist:
1519
1519
1520 ``default``
1520 ``default``
1521 The URL or directory to use when no source or remote is specified.
1521 The URL or directory to use when no source or remote is specified.
1522
1522
1523 :hg:`clone` will automatically define this path to the location the
1523 :hg:`clone` will automatically define this path to the location the
1524 repository was cloned from.
1524 repository was cloned from.
1525
1525
1526 ``default-push``
1526 ``default-push``
1527 (deprecated) The URL or directory for the default :hg:`push` location.
1527 (deprecated) The URL or directory for the default :hg:`push` location.
1528 ``default:pushurl`` should be used instead.
1528 ``default:pushurl`` should be used instead.
1529
1529
1530 ``phases``
1530 ``phases``
1531 ----------
1531 ----------
1532
1532
1533 Specifies default handling of phases. See :hg:`help phases` for more
1533 Specifies default handling of phases. See :hg:`help phases` for more
1534 information about working with phases.
1534 information about working with phases.
1535
1535
1536 ``publish``
1536 ``publish``
1537 Controls draft phase behavior when working as a server. When true,
1537 Controls draft phase behavior when working as a server. When true,
1538 pushed changesets are set to public in both client and server and
1538 pushed changesets are set to public in both client and server and
1539 pulled or cloned changesets are set to public in the client.
1539 pulled or cloned changesets are set to public in the client.
1540 (default: True)
1540 (default: True)
1541
1541
1542 ``new-commit``
1542 ``new-commit``
1543 Phase of newly-created commits.
1543 Phase of newly-created commits.
1544 (default: draft)
1544 (default: draft)
1545
1545
1546 ``checksubrepos``
1546 ``checksubrepos``
1547 Check the phase of the current revision of each subrepository. Allowed
1547 Check the phase of the current revision of each subrepository. Allowed
1548 values are "ignore", "follow" and "abort". For settings other than
1548 values are "ignore", "follow" and "abort". For settings other than
1549 "ignore", the phase of the current revision of each subrepository is
1549 "ignore", the phase of the current revision of each subrepository is
1550 checked before committing the parent repository. If any of those phases is
1550 checked before committing the parent repository. If any of those phases is
1551 greater than the phase of the parent repository (e.g. if a subrepo is in a
1551 greater than the phase of the parent repository (e.g. if a subrepo is in a
1552 "secret" phase while the parent repo is in "draft" phase), the commit is
1552 "secret" phase while the parent repo is in "draft" phase), the commit is
1553 either aborted (if checksubrepos is set to "abort") or the higher phase is
1553 either aborted (if checksubrepos is set to "abort") or the higher phase is
1554 used for the parent repository commit (if set to "follow").
1554 used for the parent repository commit (if set to "follow").
1555 (default: follow)
1555 (default: follow)
1556
1556
1557
1557
1558 ``profiling``
1558 ``profiling``
1559 -------------
1559 -------------
1560
1560
1561 Specifies profiling type, format, and file output. Two profilers are
1561 Specifies profiling type, format, and file output. Two profilers are
1562 supported: an instrumenting profiler (named ``ls``), and a sampling
1562 supported: an instrumenting profiler (named ``ls``), and a sampling
1563 profiler (named ``stat``).
1563 profiler (named ``stat``).
1564
1564
1565 In this section description, 'profiling data' stands for the raw data
1565 In this section description, 'profiling data' stands for the raw data
1566 collected during profiling, while 'profiling report' stands for a
1566 collected during profiling, while 'profiling report' stands for a
1567 statistical text report generated from the profiling data. The
1567 statistical text report generated from the profiling data. The
1568 profiling is done using lsprof.
1568 profiling is done using lsprof.
1569
1569
1570 ``enabled``
1570 ``enabled``
1571 Enable the profiler.
1571 Enable the profiler.
1572 (default: false)
1572 (default: false)
1573
1573
1574 This is equivalent to passing ``--profile`` on the command line.
1574 This is equivalent to passing ``--profile`` on the command line.
1575
1575
1576 ``type``
1576 ``type``
1577 The type of profiler to use.
1577 The type of profiler to use.
1578 (default: stat)
1578 (default: stat)
1579
1579
1580 ``ls``
1580 ``ls``
1581 Use Python's built-in instrumenting profiler. This profiler
1581 Use Python's built-in instrumenting profiler. This profiler
1582 works on all platforms, but each line number it reports is the
1582 works on all platforms, but each line number it reports is the
1583 first line of a function. This restriction makes it difficult to
1583 first line of a function. This restriction makes it difficult to
1584 identify the expensive parts of a non-trivial function.
1584 identify the expensive parts of a non-trivial function.
1585 ``stat``
1585 ``stat``
1586 Use a statistical profiler, statprof. This profiler is most
1586 Use a statistical profiler, statprof. This profiler is most
1587 useful for profiling commands that run for longer than about 0.1
1587 useful for profiling commands that run for longer than about 0.1
1588 seconds.
1588 seconds.
1589
1589
1590 ``format``
1590 ``format``
1591 Profiling format. Specific to the ``ls`` instrumenting profiler.
1591 Profiling format. Specific to the ``ls`` instrumenting profiler.
1592 (default: text)
1592 (default: text)
1593
1593
1594 ``text``
1594 ``text``
1595 Generate a profiling report. When saving to a file, it should be
1595 Generate a profiling report. When saving to a file, it should be
1596 noted that only the report is saved, and the profiling data is
1596 noted that only the report is saved, and the profiling data is
1597 not kept.
1597 not kept.
1598 ``kcachegrind``
1598 ``kcachegrind``
1599 Format profiling data for kcachegrind use: when saving to a
1599 Format profiling data for kcachegrind use: when saving to a
1600 file, the generated file can directly be loaded into
1600 file, the generated file can directly be loaded into
1601 kcachegrind.
1601 kcachegrind.
1602
1602
1603 ``statformat``
1603 ``statformat``
1604 Profiling format for the ``stat`` profiler.
1604 Profiling format for the ``stat`` profiler.
1605 (default: hotpath)
1605 (default: hotpath)
1606
1606
1607 ``hotpath``
1607 ``hotpath``
1608 Show a tree-based display containing the hot path of execution (where
1608 Show a tree-based display containing the hot path of execution (where
1609 most time was spent).
1609 most time was spent).
1610 ``bymethod``
1610 ``bymethod``
1611 Show a table of methods ordered by how frequently they are active.
1611 Show a table of methods ordered by how frequently they are active.
1612 ``byline``
1612 ``byline``
1613 Show a table of lines in files ordered by how frequently they are active.
1613 Show a table of lines in files ordered by how frequently they are active.
1614 ``json``
1614 ``json``
1615 Render profiling data as JSON.
1615 Render profiling data as JSON.
1616
1616
1617 ``frequency``
1617 ``frequency``
1618 Sampling frequency. Specific to the ``stat`` sampling profiler.
1618 Sampling frequency. Specific to the ``stat`` sampling profiler.
1619 (default: 1000)
1619 (default: 1000)
1620
1620
1621 ``output``
1621 ``output``
1622 File path where profiling data or report should be saved. If the
1622 File path where profiling data or report should be saved. If the
1623 file exists, it is replaced. (default: None, data is printed on
1623 file exists, it is replaced. (default: None, data is printed on
1624 stderr)
1624 stderr)
1625
1625
1626 ``sort``
1626 ``sort``
1627 Sort field. Specific to the ``ls`` instrumenting profiler.
1627 Sort field. Specific to the ``ls`` instrumenting profiler.
1628 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1628 One of ``callcount``, ``reccallcount``, ``totaltime`` and
1629 ``inlinetime``.
1629 ``inlinetime``.
1630 (default: inlinetime)
1630 (default: inlinetime)
1631
1631
1632 ``limit``
1632 ``limit``
1633 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1633 Number of lines to show. Specific to the ``ls`` instrumenting profiler.
1634 (default: 30)
1634 (default: 30)
1635
1635
1636 ``nested``
1636 ``nested``
1637 Show at most this number of lines of drill-down info after each main entry.
1637 Show at most this number of lines of drill-down info after each main entry.
1638 This can help explain the difference between Total and Inline.
1638 This can help explain the difference between Total and Inline.
1639 Specific to the ``ls`` instrumenting profiler.
1639 Specific to the ``ls`` instrumenting profiler.
1640 (default: 5)
1640 (default: 5)
1641
1641
1642 ``showmin``
1642 ``showmin``
1643 Minimum fraction of samples an entry must have for it to be displayed.
1643 Minimum fraction of samples an entry must have for it to be displayed.
1644 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1644 Can be specified as a float between ``0.0`` and ``1.0`` or can have a
1645 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1645 ``%`` afterwards to allow values up to ``100``. e.g. ``5%``.
1646
1646
1647 Only used by the ``stat`` profiler.
1647 Only used by the ``stat`` profiler.
1648
1648
1649 For the ``hotpath`` format, default is ``0.05``.
1649 For the ``hotpath`` format, default is ``0.05``.
1650 For the ``chrome`` format, default is ``0.005``.
1650 For the ``chrome`` format, default is ``0.005``.
1651
1651
1652 The option is unused on other formats.
1652 The option is unused on other formats.
1653
1653
1654 ``showmax``
1654 ``showmax``
1655 Maximum fraction of samples an entry can have before it is ignored in
1655 Maximum fraction of samples an entry can have before it is ignored in
1656 display. Values format is the same as ``showmin``.
1656 display. Values format is the same as ``showmin``.
1657
1657
1658 Only used by the ``stat`` profiler.
1658 Only used by the ``stat`` profiler.
1659
1659
1660 For the ``chrome`` format, default is ``0.999``.
1660 For the ``chrome`` format, default is ``0.999``.
1661
1661
1662 The option is unused on other formats.
1662 The option is unused on other formats.
1663
1663
1664 ``progress``
1664 ``progress``
1665 ------------
1665 ------------
1666
1666
1667 Mercurial commands can draw progress bars that are as informative as
1667 Mercurial commands can draw progress bars that are as informative as
1668 possible. Some progress bars only offer indeterminate information, while others
1668 possible. Some progress bars only offer indeterminate information, while others
1669 have a definite end point.
1669 have a definite end point.
1670
1670
1671 ``delay``
1671 ``delay``
1672 Number of seconds (float) before showing the progress bar. (default: 3)
1672 Number of seconds (float) before showing the progress bar. (default: 3)
1673
1673
1674 ``changedelay``
1674 ``changedelay``
1675 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1675 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1676 that value will be used instead. (default: 1)
1676 that value will be used instead. (default: 1)
1677
1677
1678 ``estimateinterval``
1678 ``estimateinterval``
1679 Maximum sampling interval in seconds for speed and estimated time
1679 Maximum sampling interval in seconds for speed and estimated time
1680 calculation. (default: 60)
1680 calculation. (default: 60)
1681
1681
1682 ``refresh``
1682 ``refresh``
1683 Time in seconds between refreshes of the progress bar. (default: 0.1)
1683 Time in seconds between refreshes of the progress bar. (default: 0.1)
1684
1684
1685 ``format``
1685 ``format``
1686 Format of the progress bar.
1686 Format of the progress bar.
1687
1687
1688 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1688 Valid entries for the format field are ``topic``, ``bar``, ``number``,
1689 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1689 ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the
1690 last 20 characters of the item, but this can be changed by adding either
1690 last 20 characters of the item, but this can be changed by adding either
1691 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1691 ``-<num>`` which would take the last num characters, or ``+<num>`` for the
1692 first num characters.
1692 first num characters.
1693
1693
1694 (default: topic bar number estimate)
1694 (default: topic bar number estimate)
1695
1695
1696 ``width``
1696 ``width``
1697 If set, the maximum width of the progress information (that is, min(width,
1697 If set, the maximum width of the progress information (that is, min(width,
1698 term width) will be used).
1698 term width) will be used).
1699
1699
1700 ``clear-complete``
1700 ``clear-complete``
1701 Clear the progress bar after it's done. (default: True)
1701 Clear the progress bar after it's done. (default: True)
1702
1702
1703 ``disable``
1703 ``disable``
1704 If true, don't show a progress bar.
1704 If true, don't show a progress bar.
1705
1705
1706 ``assume-tty``
1706 ``assume-tty``
1707 If true, ALWAYS show a progress bar, unless disable is given.
1707 If true, ALWAYS show a progress bar, unless disable is given.
1708
1708
1709 ``rebase``
1709 ``rebase``
1710 ----------
1710 ----------
1711
1711
1712 ``evolution.allowdivergence``
1712 ``evolution.allowdivergence``
1713 Default to False, when True allow creating divergence when performing
1713 Default to False, when True allow creating divergence when performing
1714 rebase of obsolete changesets.
1714 rebase of obsolete changesets.
1715
1715
1716 ``revsetalias``
1716 ``revsetalias``
1717 ---------------
1717 ---------------
1718
1718
1719 Alias definitions for revsets. See :hg:`help revsets` for details.
1719 Alias definitions for revsets. See :hg:`help revsets` for details.
1720
1720
1721 ``server``
1721 ``server``
1722 ----------
1722 ----------
1723
1723
1724 Controls generic server settings.
1724 Controls generic server settings.
1725
1725
1726 ``compressionengines``
1726 ``compressionengines``
1727 List of compression engines and their relative priority to advertise
1727 List of compression engines and their relative priority to advertise
1728 to clients.
1728 to clients.
1729
1729
1730 The order of compression engines determines their priority, the first
1730 The order of compression engines determines their priority, the first
1731 having the highest priority. If a compression engine is not listed
1731 having the highest priority. If a compression engine is not listed
1732 here, it won't be advertised to clients.
1732 here, it won't be advertised to clients.
1733
1733
1734 If not set (the default), built-in defaults are used. Run
1734 If not set (the default), built-in defaults are used. Run
1735 :hg:`debuginstall` to list available compression engines and their
1735 :hg:`debuginstall` to list available compression engines and their
1736 default wire protocol priority.
1736 default wire protocol priority.
1737
1737
1738 Older Mercurial clients only support zlib compression and this setting
1738 Older Mercurial clients only support zlib compression and this setting
1739 has no effect for legacy clients.
1739 has no effect for legacy clients.
1740
1740
1741 ``uncompressed``
1741 ``uncompressed``
1742 Whether to allow clients to clone a repository using the
1742 Whether to allow clients to clone a repository using the
1743 uncompressed streaming protocol. This transfers about 40% more
1743 uncompressed streaming protocol. This transfers about 40% more
1744 data than a regular clone, but uses less memory and CPU on both
1744 data than a regular clone, but uses less memory and CPU on both
1745 server and client. Over a LAN (100 Mbps or better) or a very fast
1745 server and client. Over a LAN (100 Mbps or better) or a very fast
1746 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1746 WAN, an uncompressed streaming clone is a lot faster (~10x) than a
1747 regular clone. Over most WAN connections (anything slower than
1747 regular clone. Over most WAN connections (anything slower than
1748 about 6 Mbps), uncompressed streaming is slower, because of the
1748 about 6 Mbps), uncompressed streaming is slower, because of the
1749 extra data transfer overhead. This mode will also temporarily hold
1749 extra data transfer overhead. This mode will also temporarily hold
1750 the write lock while determining what data to transfer.
1750 the write lock while determining what data to transfer.
1751 (default: True)
1751 (default: True)
1752
1752
1753 ``uncompressedallowsecret``
1753 ``uncompressedallowsecret``
1754 Whether to allow stream clones when the repository contains secret
1754 Whether to allow stream clones when the repository contains secret
1755 changesets. (default: False)
1755 changesets. (default: False)
1756
1756
1757 ``preferuncompressed``
1757 ``preferuncompressed``
1758 When set, clients will try to use the uncompressed streaming
1758 When set, clients will try to use the uncompressed streaming
1759 protocol. (default: False)
1759 protocol. (default: False)
1760
1760
1761 ``disablefullbundle``
1761 ``disablefullbundle``
1762 When set, servers will refuse attempts to do pull-based clones.
1762 When set, servers will refuse attempts to do pull-based clones.
1763 If this option is set, ``preferuncompressed`` and/or clone bundles
1763 If this option is set, ``preferuncompressed`` and/or clone bundles
1764 are highly recommended. Partial clones will still be allowed.
1764 are highly recommended. Partial clones will still be allowed.
1765 (default: False)
1765 (default: False)
1766
1766
1767 ``concurrent-push-mode``
1767 ``concurrent-push-mode``
1768 Level of allowed race condition between two pushing clients.
1768 Level of allowed race condition between two pushing clients.
1769
1769
1770 - 'strict': push is abort if another client touched the repository
1770 - 'strict': push is abort if another client touched the repository
1771 while the push was preparing. (default)
1771 while the push was preparing. (default)
1772 - 'check-related': push is only aborted if it affects head that got also
1772 - 'check-related': push is only aborted if it affects head that got also
1773 affected while the push was preparing.
1773 affected while the push was preparing.
1774
1774
1775 This requires compatible client (version 4.3 and later). Old client will
1775 This requires compatible client (version 4.3 and later). Old client will
1776 use 'strict'.
1776 use 'strict'.
1777
1777
1778 ``validate``
1778 ``validate``
1779 Whether to validate the completeness of pushed changesets by
1779 Whether to validate the completeness of pushed changesets by
1780 checking that all new file revisions specified in manifests are
1780 checking that all new file revisions specified in manifests are
1781 present. (default: False)
1781 present. (default: False)
1782
1782
1783 ``maxhttpheaderlen``
1783 ``maxhttpheaderlen``
1784 Instruct HTTP clients not to send request headers longer than this
1784 Instruct HTTP clients not to send request headers longer than this
1785 many bytes. (default: 1024)
1785 many bytes. (default: 1024)
1786
1786
1787 ``bundle1``
1787 ``bundle1``
1788 Whether to allow clients to push and pull using the legacy bundle1
1788 Whether to allow clients to push and pull using the legacy bundle1
1789 exchange format. (default: True)
1789 exchange format. (default: True)
1790
1790
1791 ``bundle1gd``
1791 ``bundle1gd``
1792 Like ``bundle1`` but only used if the repository is using the
1792 Like ``bundle1`` but only used if the repository is using the
1793 *generaldelta* storage format. (default: True)
1793 *generaldelta* storage format. (default: True)
1794
1794
1795 ``bundle1.push``
1795 ``bundle1.push``
1796 Whether to allow clients to push using the legacy bundle1 exchange
1796 Whether to allow clients to push using the legacy bundle1 exchange
1797 format. (default: True)
1797 format. (default: True)
1798
1798
1799 ``bundle1gd.push``
1799 ``bundle1gd.push``
1800 Like ``bundle1.push`` but only used if the repository is using the
1800 Like ``bundle1.push`` but only used if the repository is using the
1801 *generaldelta* storage format. (default: True)
1801 *generaldelta* storage format. (default: True)
1802
1802
1803 ``bundle1.pull``
1803 ``bundle1.pull``
1804 Whether to allow clients to pull using the legacy bundle1 exchange
1804 Whether to allow clients to pull using the legacy bundle1 exchange
1805 format. (default: True)
1805 format. (default: True)
1806
1806
1807 ``bundle1gd.pull``
1807 ``bundle1gd.pull``
1808 Like ``bundle1.pull`` but only used if the repository is using the
1808 Like ``bundle1.pull`` but only used if the repository is using the
1809 *generaldelta* storage format. (default: True)
1809 *generaldelta* storage format. (default: True)
1810
1810
1811 Large repositories using the *generaldelta* storage format should
1811 Large repositories using the *generaldelta* storage format should
1812 consider setting this option because converting *generaldelta*
1812 consider setting this option because converting *generaldelta*
1813 repositories to the exchange format required by the bundle1 data
1813 repositories to the exchange format required by the bundle1 data
1814 format can consume a lot of CPU.
1814 format can consume a lot of CPU.
1815
1815
1816 ``zliblevel``
1816 ``zliblevel``
1817 Integer between ``-1`` and ``9`` that controls the zlib compression level
1817 Integer between ``-1`` and ``9`` that controls the zlib compression level
1818 for wire protocol commands that send zlib compressed output (notably the
1818 for wire protocol commands that send zlib compressed output (notably the
1819 commands that send repository history data).
1819 commands that send repository history data).
1820
1820
1821 The default (``-1``) uses the default zlib compression level, which is
1821 The default (``-1``) uses the default zlib compression level, which is
1822 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1822 likely equivalent to ``6``. ``0`` means no compression. ``9`` means
1823 maximum compression.
1823 maximum compression.
1824
1824
1825 Setting this option allows server operators to make trade-offs between
1825 Setting this option allows server operators to make trade-offs between
1826 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1826 bandwidth and CPU used. Lowering the compression lowers CPU utilization
1827 but sends more bytes to clients.
1827 but sends more bytes to clients.
1828
1828
1829 This option only impacts the HTTP server.
1829 This option only impacts the HTTP server.
1830
1830
1831 ``zstdlevel``
1831 ``zstdlevel``
1832 Integer between ``1`` and ``22`` that controls the zstd compression level
1832 Integer between ``1`` and ``22`` that controls the zstd compression level
1833 for wire protocol commands. ``1`` is the minimal amount of compression and
1833 for wire protocol commands. ``1`` is the minimal amount of compression and
1834 ``22`` is the highest amount of compression.
1834 ``22`` is the highest amount of compression.
1835
1835
1836 The default (``3``) should be significantly faster than zlib while likely
1836 The default (``3``) should be significantly faster than zlib while likely
1837 delivering better compression ratios.
1837 delivering better compression ratios.
1838
1838
1839 This option only impacts the HTTP server.
1839 This option only impacts the HTTP server.
1840
1840
1841 See also ``server.zliblevel``.
1841 See also ``server.zliblevel``.
1842
1842
1843 ``smtp``
1843 ``smtp``
1844 --------
1844 --------
1845
1845
1846 Configuration for extensions that need to send email messages.
1846 Configuration for extensions that need to send email messages.
1847
1847
1848 ``host``
1848 ``host``
1849 Host name of mail server, e.g. "mail.example.com".
1849 Host name of mail server, e.g. "mail.example.com".
1850
1850
1851 ``port``
1851 ``port``
1852 Optional. Port to connect to on mail server. (default: 465 if
1852 Optional. Port to connect to on mail server. (default: 465 if
1853 ``tls`` is smtps; 25 otherwise)
1853 ``tls`` is smtps; 25 otherwise)
1854
1854
1855 ``tls``
1855 ``tls``
1856 Optional. Method to enable TLS when connecting to mail server: starttls,
1856 Optional. Method to enable TLS when connecting to mail server: starttls,
1857 smtps or none. (default: none)
1857 smtps or none. (default: none)
1858
1858
1859 ``username``
1859 ``username``
1860 Optional. User name for authenticating with the SMTP server.
1860 Optional. User name for authenticating with the SMTP server.
1861 (default: None)
1861 (default: None)
1862
1862
1863 ``password``
1863 ``password``
1864 Optional. Password for authenticating with the SMTP server. If not
1864 Optional. Password for authenticating with the SMTP server. If not
1865 specified, interactive sessions will prompt the user for a
1865 specified, interactive sessions will prompt the user for a
1866 password; non-interactive sessions will fail. (default: None)
1866 password; non-interactive sessions will fail. (default: None)
1867
1867
1868 ``local_hostname``
1868 ``local_hostname``
1869 Optional. The hostname that the sender can use to identify
1869 Optional. The hostname that the sender can use to identify
1870 itself to the MTA.
1870 itself to the MTA.
1871
1871
1872
1872
1873 ``subpaths``
1873 ``subpaths``
1874 ------------
1874 ------------
1875
1875
1876 Subrepository source URLs can go stale if a remote server changes name
1876 Subrepository source URLs can go stale if a remote server changes name
1877 or becomes temporarily unavailable. This section lets you define
1877 or becomes temporarily unavailable. This section lets you define
1878 rewrite rules of the form::
1878 rewrite rules of the form::
1879
1879
1880 <pattern> = <replacement>
1880 <pattern> = <replacement>
1881
1881
1882 where ``pattern`` is a regular expression matching a subrepository
1882 where ``pattern`` is a regular expression matching a subrepository
1883 source URL and ``replacement`` is the replacement string used to
1883 source URL and ``replacement`` is the replacement string used to
1884 rewrite it. Groups can be matched in ``pattern`` and referenced in
1884 rewrite it. Groups can be matched in ``pattern`` and referenced in
1885 ``replacements``. For instance::
1885 ``replacements``. For instance::
1886
1886
1887 http://server/(.*)-hg/ = http://hg.server/\1/
1887 http://server/(.*)-hg/ = http://hg.server/\1/
1888
1888
1889 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1889 rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``.
1890
1890
1891 Relative subrepository paths are first made absolute, and the
1891 Relative subrepository paths are first made absolute, and the
1892 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1892 rewrite rules are then applied on the full (absolute) path. If ``pattern``
1893 doesn't match the full path, an attempt is made to apply it on the
1893 doesn't match the full path, an attempt is made to apply it on the
1894 relative path alone. The rules are applied in definition order.
1894 relative path alone. The rules are applied in definition order.
1895
1895
1896 ``subrepos``
1896 ``subrepos``
1897 ------------
1897 ------------
1898
1898
1899 This section contains options that control the behavior of the
1899 This section contains options that control the behavior of the
1900 subrepositories feature. See also :hg:`help subrepos`.
1900 subrepositories feature. See also :hg:`help subrepos`.
1901
1901
1902 Security note: auditing in Mercurial is known to be insufficient to
1902 Security note: auditing in Mercurial is known to be insufficient to
1903 prevent clone-time code execution with carefully constructed Git
1903 prevent clone-time code execution with carefully constructed Git
1904 subrepos. It is unknown if a similar detect is present in Subversion
1904 subrepos. It is unknown if a similar detect is present in Subversion
1905 subrepos. Both Git and Subversion subrepos are disabled by default
1905 subrepos. Both Git and Subversion subrepos are disabled by default
1906 out of security concerns. These subrepo types can be enabled using
1906 out of security concerns. These subrepo types can be enabled using
1907 the respective options below.
1907 the respective options below.
1908
1908
1909 ``allowed``
1909 ``allowed``
1910 Whether subrepositories are allowed in the working directory.
1910 Whether subrepositories are allowed in the working directory.
1911
1911
1912 When false, commands involving subrepositories (like :hg:`update`)
1912 When false, commands involving subrepositories (like :hg:`update`)
1913 will fail for all subrepository types.
1913 will fail for all subrepository types.
1914 (default: true)
1914 (default: true)
1915
1915
1916 ``hg:allowed``
1916 ``hg:allowed``
1917 Whether Mercurial subrepositories are allowed in the working
1917 Whether Mercurial subrepositories are allowed in the working
1918 directory. This option only has an effect if ``subrepos.allowed``
1918 directory. This option only has an effect if ``subrepos.allowed``
1919 is true.
1919 is true.
1920 (default: true)
1920 (default: true)
1921
1921
1922 ``git:allowed``
1922 ``git:allowed``
1923 Whether Git subrepositories are allowed in the working directory.
1923 Whether Git subrepositories are allowed in the working directory.
1924 This option only has an effect if ``subrepos.allowed`` is true.
1924 This option only has an effect if ``subrepos.allowed`` is true.
1925
1925
1926 See the security note above before enabling Git subrepos.
1926 See the security note above before enabling Git subrepos.
1927 (default: false)
1927 (default: false)
1928
1928
1929 ``svn:allowed``
1929 ``svn:allowed``
1930 Whether Subversion subrepositories are allowed in the working
1930 Whether Subversion subrepositories are allowed in the working
1931 directory. This option only has an effect if ``subrepos.allowed``
1931 directory. This option only has an effect if ``subrepos.allowed``
1932 is true.
1932 is true.
1933
1933
1934 See the security note above before enabling Subversion subrepos.
1934 See the security note above before enabling Subversion subrepos.
1935 (default: false)
1935 (default: false)
1936
1936
1937 ``templatealias``
1937 ``templatealias``
1938 -----------------
1938 -----------------
1939
1939
1940 Alias definitions for templates. See :hg:`help templates` for details.
1940 Alias definitions for templates. See :hg:`help templates` for details.
1941
1941
1942 ``templates``
1942 ``templates``
1943 -------------
1943 -------------
1944
1944
1945 Use the ``[templates]`` section to define template strings.
1945 Use the ``[templates]`` section to define template strings.
1946 See :hg:`help templates` for details.
1946 See :hg:`help templates` for details.
1947
1947
1948 ``trusted``
1948 ``trusted``
1949 -----------
1949 -----------
1950
1950
1951 Mercurial will not use the settings in the
1951 Mercurial will not use the settings in the
1952 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1952 ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted
1953 user or to a trusted group, as various hgrc features allow arbitrary
1953 user or to a trusted group, as various hgrc features allow arbitrary
1954 commands to be run. This issue is often encountered when configuring
1954 commands to be run. This issue is often encountered when configuring
1955 hooks or extensions for shared repositories or servers. However,
1955 hooks or extensions for shared repositories or servers. However,
1956 the web interface will use some safe settings from the ``[web]``
1956 the web interface will use some safe settings from the ``[web]``
1957 section.
1957 section.
1958
1958
1959 This section specifies what users and groups are trusted. The
1959 This section specifies what users and groups are trusted. The
1960 current user is always trusted. To trust everybody, list a user or a
1960 current user is always trusted. To trust everybody, list a user or a
1961 group with name ``*``. These settings must be placed in an
1961 group with name ``*``. These settings must be placed in an
1962 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1962 *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the
1963 user or service running Mercurial.
1963 user or service running Mercurial.
1964
1964
1965 ``users``
1965 ``users``
1966 Comma-separated list of trusted users.
1966 Comma-separated list of trusted users.
1967
1967
1968 ``groups``
1968 ``groups``
1969 Comma-separated list of trusted groups.
1969 Comma-separated list of trusted groups.
1970
1970
1971
1971
1972 ``ui``
1972 ``ui``
1973 ------
1973 ------
1974
1974
1975 User interface controls.
1975 User interface controls.
1976
1976
1977 ``archivemeta``
1977 ``archivemeta``
1978 Whether to include the .hg_archival.txt file containing meta data
1978 Whether to include the .hg_archival.txt file containing meta data
1979 (hashes for the repository base and for tip) in archives created
1979 (hashes for the repository base and for tip) in archives created
1980 by the :hg:`archive` command or downloaded via hgweb.
1980 by the :hg:`archive` command or downloaded via hgweb.
1981 (default: True)
1981 (default: True)
1982
1982
1983 ``askusername``
1983 ``askusername``
1984 Whether to prompt for a username when committing. If True, and
1984 Whether to prompt for a username when committing. If True, and
1985 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1985 neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will
1986 be prompted to enter a username. If no username is entered, the
1986 be prompted to enter a username. If no username is entered, the
1987 default ``USER@HOST`` is used instead.
1987 default ``USER@HOST`` is used instead.
1988 (default: False)
1988 (default: False)
1989
1989
1990 ``clonebundles``
1990 ``clonebundles``
1991 Whether the "clone bundles" feature is enabled.
1991 Whether the "clone bundles" feature is enabled.
1992
1992
1993 When enabled, :hg:`clone` may download and apply a server-advertised
1993 When enabled, :hg:`clone` may download and apply a server-advertised
1994 bundle file from a URL instead of using the normal exchange mechanism.
1994 bundle file from a URL instead of using the normal exchange mechanism.
1995
1995
1996 This can likely result in faster and more reliable clones.
1996 This can likely result in faster and more reliable clones.
1997
1997
1998 (default: True)
1998 (default: True)
1999
1999
2000 ``clonebundlefallback``
2000 ``clonebundlefallback``
2001 Whether failure to apply an advertised "clone bundle" from a server
2001 Whether failure to apply an advertised "clone bundle" from a server
2002 should result in fallback to a regular clone.
2002 should result in fallback to a regular clone.
2003
2003
2004 This is disabled by default because servers advertising "clone
2004 This is disabled by default because servers advertising "clone
2005 bundles" often do so to reduce server load. If advertised bundles
2005 bundles" often do so to reduce server load. If advertised bundles
2006 start mass failing and clients automatically fall back to a regular
2006 start mass failing and clients automatically fall back to a regular
2007 clone, this would add significant and unexpected load to the server
2007 clone, this would add significant and unexpected load to the server
2008 since the server is expecting clone operations to be offloaded to
2008 since the server is expecting clone operations to be offloaded to
2009 pre-generated bundles. Failing fast (the default behavior) ensures
2009 pre-generated bundles. Failing fast (the default behavior) ensures
2010 clients don't overwhelm the server when "clone bundle" application
2010 clients don't overwhelm the server when "clone bundle" application
2011 fails.
2011 fails.
2012
2012
2013 (default: False)
2013 (default: False)
2014
2014
2015 ``clonebundleprefers``
2015 ``clonebundleprefers``
2016 Defines preferences for which "clone bundles" to use.
2016 Defines preferences for which "clone bundles" to use.
2017
2017
2018 Servers advertising "clone bundles" may advertise multiple available
2018 Servers advertising "clone bundles" may advertise multiple available
2019 bundles. Each bundle may have different attributes, such as the bundle
2019 bundles. Each bundle may have different attributes, such as the bundle
2020 type and compression format. This option is used to prefer a particular
2020 type and compression format. This option is used to prefer a particular
2021 bundle over another.
2021 bundle over another.
2022
2022
2023 The following keys are defined by Mercurial:
2023 The following keys are defined by Mercurial:
2024
2024
2025 BUNDLESPEC
2025 BUNDLESPEC
2026 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2026 A bundle type specifier. These are strings passed to :hg:`bundle -t`.
2027 e.g. ``gzip-v2`` or ``bzip2-v1``.
2027 e.g. ``gzip-v2`` or ``bzip2-v1``.
2028
2028
2029 COMPRESSION
2029 COMPRESSION
2030 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2030 The compression format of the bundle. e.g. ``gzip`` and ``bzip2``.
2031
2031
2032 Server operators may define custom keys.
2032 Server operators may define custom keys.
2033
2033
2034 Example values: ``COMPRESSION=bzip2``,
2034 Example values: ``COMPRESSION=bzip2``,
2035 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2035 ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``.
2036
2036
2037 By default, the first bundle advertised by the server is used.
2037 By default, the first bundle advertised by the server is used.
2038
2038
2039 ``color``
2039 ``color``
2040 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2040 When to colorize output. Possible value are Boolean ("yes" or "no"), or
2041 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2041 "debug", or "always". (default: "yes"). "yes" will use color whenever it
2042 seems possible. See :hg:`help color` for details.
2042 seems possible. See :hg:`help color` for details.
2043
2043
2044 ``commitsubrepos``
2044 ``commitsubrepos``
2045 Whether to commit modified subrepositories when committing the
2045 Whether to commit modified subrepositories when committing the
2046 parent repository. If False and one subrepository has uncommitted
2046 parent repository. If False and one subrepository has uncommitted
2047 changes, abort the commit.
2047 changes, abort the commit.
2048 (default: False)
2048 (default: False)
2049
2049
2050 ``debug``
2050 ``debug``
2051 Print debugging information. (default: False)
2051 Print debugging information. (default: False)
2052
2052
2053 ``editor``
2053 ``editor``
2054 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2054 The editor to use during a commit. (default: ``$EDITOR`` or ``vi``)
2055
2055
2056 ``fallbackencoding``
2056 ``fallbackencoding``
2057 Encoding to try if it's not possible to decode the changelog using
2057 Encoding to try if it's not possible to decode the changelog using
2058 UTF-8. (default: ISO-8859-1)
2058 UTF-8. (default: ISO-8859-1)
2059
2059
2060 ``graphnodetemplate``
2060 ``graphnodetemplate``
2061 The template used to print changeset nodes in an ASCII revision graph.
2061 The template used to print changeset nodes in an ASCII revision graph.
2062 (default: ``{graphnode}``)
2062 (default: ``{graphnode}``)
2063
2063
2064 ``ignore``
2064 ``ignore``
2065 A file to read per-user ignore patterns from. This file should be
2065 A file to read per-user ignore patterns from. This file should be
2066 in the same format as a repository-wide .hgignore file. Filenames
2066 in the same format as a repository-wide .hgignore file. Filenames
2067 are relative to the repository root. This option supports hook syntax,
2067 are relative to the repository root. This option supports hook syntax,
2068 so if you want to specify multiple ignore files, you can do so by
2068 so if you want to specify multiple ignore files, you can do so by
2069 setting something like ``ignore.other = ~/.hgignore2``. For details
2069 setting something like ``ignore.other = ~/.hgignore2``. For details
2070 of the ignore file format, see the ``hgignore(5)`` man page.
2070 of the ignore file format, see the ``hgignore(5)`` man page.
2071
2071
2072 ``interactive``
2072 ``interactive``
2073 Allow to prompt the user. (default: True)
2073 Allow to prompt the user. (default: True)
2074
2074
2075 ``interface``
2075 ``interface``
2076 Select the default interface for interactive features (default: text).
2076 Select the default interface for interactive features (default: text).
2077 Possible values are 'text' and 'curses'.
2077 Possible values are 'text' and 'curses'.
2078
2078
2079 ``interface.chunkselector``
2079 ``interface.chunkselector``
2080 Select the interface for change recording (e.g. :hg:`commit -i`).
2080 Select the interface for change recording (e.g. :hg:`commit -i`).
2081 Possible values are 'text' and 'curses'.
2081 Possible values are 'text' and 'curses'.
2082 This config overrides the interface specified by ui.interface.
2082 This config overrides the interface specified by ui.interface.
2083
2083
2084 ``logtemplate``
2084 ``logtemplate``
2085 Template string for commands that print changesets.
2085 Template string for commands that print changesets.
2086
2086
2087 ``merge``
2087 ``merge``
2088 The conflict resolution program to use during a manual merge.
2088 The conflict resolution program to use during a manual merge.
2089 For more information on merge tools see :hg:`help merge-tools`.
2089 For more information on merge tools see :hg:`help merge-tools`.
2090 For configuring merge tools see the ``[merge-tools]`` section.
2090 For configuring merge tools see the ``[merge-tools]`` section.
2091
2091
2092 ``mergemarkers``
2092 ``mergemarkers``
2093 Sets the merge conflict marker label styling. The ``detailed``
2093 Sets the merge conflict marker label styling. The ``detailed``
2094 style uses the ``mergemarkertemplate`` setting to style the labels.
2094 style uses the ``mergemarkertemplate`` setting to style the labels.
2095 The ``basic`` style just uses 'local' and 'other' as the marker label.
2095 The ``basic`` style just uses 'local' and 'other' as the marker label.
2096 One of ``basic`` or ``detailed``.
2096 One of ``basic`` or ``detailed``.
2097 (default: ``basic``)
2097 (default: ``basic``)
2098
2098
2099 ``mergemarkertemplate``
2099 ``mergemarkertemplate``
2100 The template used to print the commit description next to each conflict
2100 The template used to print the commit description next to each conflict
2101 marker during merge conflicts. See :hg:`help templates` for the template
2101 marker during merge conflicts. See :hg:`help templates` for the template
2102 format.
2102 format.
2103
2103
2104 Defaults to showing the hash, tags, branches, bookmarks, author, and
2104 Defaults to showing the hash, tags, branches, bookmarks, author, and
2105 the first line of the commit description.
2105 the first line of the commit description.
2106
2106
2107 If you use non-ASCII characters in names for tags, branches, bookmarks,
2107 If you use non-ASCII characters in names for tags, branches, bookmarks,
2108 authors, and/or commit descriptions, you must pay attention to encodings of
2108 authors, and/or commit descriptions, you must pay attention to encodings of
2109 managed files. At template expansion, non-ASCII characters use the encoding
2109 managed files. At template expansion, non-ASCII characters use the encoding
2110 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2110 specified by the ``--encoding`` global option, ``HGENCODING`` or other
2111 environment variables that govern your locale. If the encoding of the merge
2111 environment variables that govern your locale. If the encoding of the merge
2112 markers is different from the encoding of the merged files,
2112 markers is different from the encoding of the merged files,
2113 serious problems may occur.
2113 serious problems may occur.
2114
2114
2115 ``origbackuppath``
2115 ``origbackuppath``
2116 The path to a directory used to store generated .orig files. If the path is
2116 The path to a directory used to store generated .orig files. If the path is
2117 not a directory, one will be created. If set, files stored in this
2117 not a directory, one will be created. If set, files stored in this
2118 directory have the same name as the original file and do not have a .orig
2118 directory have the same name as the original file and do not have a .orig
2119 suffix.
2119 suffix.
2120
2120
2121 ``paginate``
2121 ``paginate``
2122 Control the pagination of command output (default: True). See :hg:`help pager`
2122 Control the pagination of command output (default: True). See :hg:`help pager`
2123 for details.
2123 for details.
2124
2124
2125 ``patch``
2125 ``patch``
2126 An optional external tool that ``hg import`` and some extensions
2126 An optional external tool that ``hg import`` and some extensions
2127 will use for applying patches. By default Mercurial uses an
2127 will use for applying patches. By default Mercurial uses an
2128 internal patch utility. The external tool must work as the common
2128 internal patch utility. The external tool must work as the common
2129 Unix ``patch`` program. In particular, it must accept a ``-p``
2129 Unix ``patch`` program. In particular, it must accept a ``-p``
2130 argument to strip patch headers, a ``-d`` argument to specify the
2130 argument to strip patch headers, a ``-d`` argument to specify the
2131 current directory, a file name to patch, and a patch file to take
2131 current directory, a file name to patch, and a patch file to take
2132 from stdin.
2132 from stdin.
2133
2133
2134 It is possible to specify a patch tool together with extra
2134 It is possible to specify a patch tool together with extra
2135 arguments. For example, setting this option to ``patch --merge``
2135 arguments. For example, setting this option to ``patch --merge``
2136 will use the ``patch`` program with its 2-way merge option.
2136 will use the ``patch`` program with its 2-way merge option.
2137
2137
2138 ``portablefilenames``
2138 ``portablefilenames``
2139 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2139 Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
2140 (default: ``warn``)
2140 (default: ``warn``)
2141
2141
2142 ``warn``
2142 ``warn``
2143 Print a warning message on POSIX platforms, if a file with a non-portable
2143 Print a warning message on POSIX platforms, if a file with a non-portable
2144 filename is added (e.g. a file with a name that can't be created on
2144 filename is added (e.g. a file with a name that can't be created on
2145 Windows because it contains reserved parts like ``AUX``, reserved
2145 Windows because it contains reserved parts like ``AUX``, reserved
2146 characters like ``:``, or would cause a case collision with an existing
2146 characters like ``:``, or would cause a case collision with an existing
2147 file).
2147 file).
2148
2148
2149 ``ignore``
2149 ``ignore``
2150 Don't print a warning.
2150 Don't print a warning.
2151
2151
2152 ``abort``
2152 ``abort``
2153 The command is aborted.
2153 The command is aborted.
2154
2154
2155 ``true``
2155 ``true``
2156 Alias for ``warn``.
2156 Alias for ``warn``.
2157
2157
2158 ``false``
2158 ``false``
2159 Alias for ``ignore``.
2159 Alias for ``ignore``.
2160
2160
2161 .. container:: windows
2161 .. container:: windows
2162
2162
2163 On Windows, this configuration option is ignored and the command aborted.
2163 On Windows, this configuration option is ignored and the command aborted.
2164
2164
2165 ``quiet``
2165 ``quiet``
2166 Reduce the amount of output printed.
2166 Reduce the amount of output printed.
2167 (default: False)
2167 (default: False)
2168
2168
2169 ``remotecmd``
2169 ``remotecmd``
2170 Remote command to use for clone/push/pull operations.
2170 Remote command to use for clone/push/pull operations.
2171 (default: ``hg``)
2171 (default: ``hg``)
2172
2172
2173 ``report_untrusted``
2173 ``report_untrusted``
2174 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2174 Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a
2175 trusted user or group.
2175 trusted user or group.
2176 (default: True)
2176 (default: True)
2177
2177
2178 ``slash``
2178 ``slash``
2179 Display paths using a slash (``/``) as the path separator. This
2179 Display paths using a slash (``/``) as the path separator. This
2180 only makes a difference on systems where the default path
2180 only makes a difference on systems where the default path
2181 separator is not the slash character (e.g. Windows uses the
2181 separator is not the slash character (e.g. Windows uses the
2182 backslash character (``\``)).
2182 backslash character (``\``)).
2183 (default: False)
2183 (default: False)
2184
2184
2185 ``statuscopies``
2185 ``statuscopies``
2186 Display copies in the status command.
2186 Display copies in the status command.
2187
2187
2188 ``ssh``
2188 ``ssh``
2189 Command to use for SSH connections. (default: ``ssh``)
2189 Command to use for SSH connections. (default: ``ssh``)
2190
2190
2191 ``ssherrorhint``
2191 ``ssherrorhint``
2192 A hint shown to the user in the case of SSH error (e.g.
2192 A hint shown to the user in the case of SSH error (e.g.
2193 ``Please see http://company/internalwiki/ssh.html``)
2193 ``Please see http://company/internalwiki/ssh.html``)
2194
2194
2195 ``strict``
2195 ``strict``
2196 Require exact command names, instead of allowing unambiguous
2196 Require exact command names, instead of allowing unambiguous
2197 abbreviations. (default: False)
2197 abbreviations. (default: False)
2198
2198
2199 ``style``
2199 ``style``
2200 Name of style to use for command output.
2200 Name of style to use for command output.
2201
2201
2202 ``supportcontact``
2202 ``supportcontact``
2203 A URL where users should report a Mercurial traceback. Use this if you are a
2203 A URL where users should report a Mercurial traceback. Use this if you are a
2204 large organisation with its own Mercurial deployment process and crash
2204 large organisation with its own Mercurial deployment process and crash
2205 reports should be addressed to your internal support.
2205 reports should be addressed to your internal support.
2206
2206
2207 ``textwidth``
2207 ``textwidth``
2208 Maximum width of help text. A longer line generated by ``hg help`` or
2208 Maximum width of help text. A longer line generated by ``hg help`` or
2209 ``hg subcommand --help`` will be broken after white space to get this
2209 ``hg subcommand --help`` will be broken after white space to get this
2210 width or the terminal width, whichever comes first.
2210 width or the terminal width, whichever comes first.
2211 A non-positive value will disable this and the terminal width will be
2211 A non-positive value will disable this and the terminal width will be
2212 used. (default: 78)
2212 used. (default: 78)
2213
2213
2214 ``timeout``
2214 ``timeout``
2215 The timeout used when a lock is held (in seconds), a negative value
2215 The timeout used when a lock is held (in seconds), a negative value
2216 means no timeout. (default: 600)
2216 means no timeout. (default: 600)
2217
2217
2218 ``timeout.warn``
2219 Time (in seconds) before a warning is printed about held lock. A negative
2220 value means no warning. (default: 0)
2221
2218 ``traceback``
2222 ``traceback``
2219 Mercurial always prints a traceback when an unknown exception
2223 Mercurial always prints a traceback when an unknown exception
2220 occurs. Setting this to True will make Mercurial print a traceback
2224 occurs. Setting this to True will make Mercurial print a traceback
2221 on all exceptions, even those recognized by Mercurial (such as
2225 on all exceptions, even those recognized by Mercurial (such as
2222 IOError or MemoryError). (default: False)
2226 IOError or MemoryError). (default: False)
2223
2227
2224 ``tweakdefaults``
2228 ``tweakdefaults``
2225
2229
2226 By default Mercurial's behavior changes very little from release
2230 By default Mercurial's behavior changes very little from release
2227 to release, but over time the recommended config settings
2231 to release, but over time the recommended config settings
2228 shift. Enable this config to opt in to get automatic tweaks to
2232 shift. Enable this config to opt in to get automatic tweaks to
2229 Mercurial's behavior over time. This config setting will have no
2233 Mercurial's behavior over time. This config setting will have no
2230 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2234 effet if ``HGPLAIN` is set or ``HGPLAINEXCEPT`` is set and does
2231 not include ``tweakdefaults``. (default: False)
2235 not include ``tweakdefaults``. (default: False)
2232
2236
2233 ``username``
2237 ``username``
2234 The committer of a changeset created when running "commit".
2238 The committer of a changeset created when running "commit".
2235 Typically a person's name and email address, e.g. ``Fred Widget
2239 Typically a person's name and email address, e.g. ``Fred Widget
2236 <fred@example.com>``. Environment variables in the
2240 <fred@example.com>``. Environment variables in the
2237 username are expanded.
2241 username are expanded.
2238
2242
2239 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2243 (default: ``$EMAIL`` or ``username@hostname``. If the username in
2240 hgrc is empty, e.g. if the system admin set ``username =`` in the
2244 hgrc is empty, e.g. if the system admin set ``username =`` in the
2241 system hgrc, it has to be specified manually or in a different
2245 system hgrc, it has to be specified manually or in a different
2242 hgrc file)
2246 hgrc file)
2243
2247
2244 ``verbose``
2248 ``verbose``
2245 Increase the amount of output printed. (default: False)
2249 Increase the amount of output printed. (default: False)
2246
2250
2247
2251
2248 ``web``
2252 ``web``
2249 -------
2253 -------
2250
2254
2251 Web interface configuration. The settings in this section apply to
2255 Web interface configuration. The settings in this section apply to
2252 both the builtin webserver (started by :hg:`serve`) and the script you
2256 both the builtin webserver (started by :hg:`serve`) and the script you
2253 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2257 run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI
2254 and WSGI).
2258 and WSGI).
2255
2259
2256 The Mercurial webserver does no authentication (it does not prompt for
2260 The Mercurial webserver does no authentication (it does not prompt for
2257 usernames and passwords to validate *who* users are), but it does do
2261 usernames and passwords to validate *who* users are), but it does do
2258 authorization (it grants or denies access for *authenticated users*
2262 authorization (it grants or denies access for *authenticated users*
2259 based on settings in this section). You must either configure your
2263 based on settings in this section). You must either configure your
2260 webserver to do authentication for you, or disable the authorization
2264 webserver to do authentication for you, or disable the authorization
2261 checks.
2265 checks.
2262
2266
2263 For a quick setup in a trusted environment, e.g., a private LAN, where
2267 For a quick setup in a trusted environment, e.g., a private LAN, where
2264 you want it to accept pushes from anybody, you can use the following
2268 you want it to accept pushes from anybody, you can use the following
2265 command line::
2269 command line::
2266
2270
2267 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2271 $ hg --config web.allow-push=* --config web.push_ssl=False serve
2268
2272
2269 Note that this will allow anybody to push anything to the server and
2273 Note that this will allow anybody to push anything to the server and
2270 that this should not be used for public servers.
2274 that this should not be used for public servers.
2271
2275
2272 The full set of options is:
2276 The full set of options is:
2273
2277
2274 ``accesslog``
2278 ``accesslog``
2275 Where to output the access log. (default: stdout)
2279 Where to output the access log. (default: stdout)
2276
2280
2277 ``address``
2281 ``address``
2278 Interface address to bind to. (default: all)
2282 Interface address to bind to. (default: all)
2279
2283
2280 ``allow_archive``
2284 ``allow_archive``
2281 List of archive format (bz2, gz, zip) allowed for downloading.
2285 List of archive format (bz2, gz, zip) allowed for downloading.
2282 (default: empty)
2286 (default: empty)
2283
2287
2284 ``allowbz2``
2288 ``allowbz2``
2285 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2289 (DEPRECATED) Whether to allow .tar.bz2 downloading of repository
2286 revisions.
2290 revisions.
2287 (default: False)
2291 (default: False)
2288
2292
2289 ``allowgz``
2293 ``allowgz``
2290 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2294 (DEPRECATED) Whether to allow .tar.gz downloading of repository
2291 revisions.
2295 revisions.
2292 (default: False)
2296 (default: False)
2293
2297
2294 ``allow-pull``
2298 ``allow-pull``
2295 Whether to allow pulling from the repository. (default: True)
2299 Whether to allow pulling from the repository. (default: True)
2296
2300
2297 ``allow-push``
2301 ``allow-push``
2298 Whether to allow pushing to the repository. If empty or not set,
2302 Whether to allow pushing to the repository. If empty or not set,
2299 pushing is not allowed. If the special value ``*``, any remote
2303 pushing is not allowed. If the special value ``*``, any remote
2300 user can push, including unauthenticated users. Otherwise, the
2304 user can push, including unauthenticated users. Otherwise, the
2301 remote user must have been authenticated, and the authenticated
2305 remote user must have been authenticated, and the authenticated
2302 user name must be present in this list. The contents of the
2306 user name must be present in this list. The contents of the
2303 allow-push list are examined after the deny_push list.
2307 allow-push list are examined after the deny_push list.
2304
2308
2305 ``allow_read``
2309 ``allow_read``
2306 If the user has not already been denied repository access due to
2310 If the user has not already been denied repository access due to
2307 the contents of deny_read, this list determines whether to grant
2311 the contents of deny_read, this list determines whether to grant
2308 repository access to the user. If this list is not empty, and the
2312 repository access to the user. If this list is not empty, and the
2309 user is unauthenticated or not present in the list, then access is
2313 user is unauthenticated or not present in the list, then access is
2310 denied for the user. If the list is empty or not set, then access
2314 denied for the user. If the list is empty or not set, then access
2311 is permitted to all users by default. Setting allow_read to the
2315 is permitted to all users by default. Setting allow_read to the
2312 special value ``*`` is equivalent to it not being set (i.e. access
2316 special value ``*`` is equivalent to it not being set (i.e. access
2313 is permitted to all users). The contents of the allow_read list are
2317 is permitted to all users). The contents of the allow_read list are
2314 examined after the deny_read list.
2318 examined after the deny_read list.
2315
2319
2316 ``allowzip``
2320 ``allowzip``
2317 (DEPRECATED) Whether to allow .zip downloading of repository
2321 (DEPRECATED) Whether to allow .zip downloading of repository
2318 revisions. This feature creates temporary files.
2322 revisions. This feature creates temporary files.
2319 (default: False)
2323 (default: False)
2320
2324
2321 ``archivesubrepos``
2325 ``archivesubrepos``
2322 Whether to recurse into subrepositories when archiving.
2326 Whether to recurse into subrepositories when archiving.
2323 (default: False)
2327 (default: False)
2324
2328
2325 ``baseurl``
2329 ``baseurl``
2326 Base URL to use when publishing URLs in other locations, so
2330 Base URL to use when publishing URLs in other locations, so
2327 third-party tools like email notification hooks can construct
2331 third-party tools like email notification hooks can construct
2328 URLs. Example: ``http://hgserver/repos/``.
2332 URLs. Example: ``http://hgserver/repos/``.
2329
2333
2330 ``cacerts``
2334 ``cacerts``
2331 Path to file containing a list of PEM encoded certificate
2335 Path to file containing a list of PEM encoded certificate
2332 authority certificates. Environment variables and ``~user``
2336 authority certificates. Environment variables and ``~user``
2333 constructs are expanded in the filename. If specified on the
2337 constructs are expanded in the filename. If specified on the
2334 client, then it will verify the identity of remote HTTPS servers
2338 client, then it will verify the identity of remote HTTPS servers
2335 with these certificates.
2339 with these certificates.
2336
2340
2337 To disable SSL verification temporarily, specify ``--insecure`` from
2341 To disable SSL verification temporarily, specify ``--insecure`` from
2338 command line.
2342 command line.
2339
2343
2340 You can use OpenSSL's CA certificate file if your platform has
2344 You can use OpenSSL's CA certificate file if your platform has
2341 one. On most Linux systems this will be
2345 one. On most Linux systems this will be
2342 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2346 ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to
2343 generate this file manually. The form must be as follows::
2347 generate this file manually. The form must be as follows::
2344
2348
2345 -----BEGIN CERTIFICATE-----
2349 -----BEGIN CERTIFICATE-----
2346 ... (certificate in base64 PEM encoding) ...
2350 ... (certificate in base64 PEM encoding) ...
2347 -----END CERTIFICATE-----
2351 -----END CERTIFICATE-----
2348 -----BEGIN CERTIFICATE-----
2352 -----BEGIN CERTIFICATE-----
2349 ... (certificate in base64 PEM encoding) ...
2353 ... (certificate in base64 PEM encoding) ...
2350 -----END CERTIFICATE-----
2354 -----END CERTIFICATE-----
2351
2355
2352 ``cache``
2356 ``cache``
2353 Whether to support caching in hgweb. (default: True)
2357 Whether to support caching in hgweb. (default: True)
2354
2358
2355 ``certificate``
2359 ``certificate``
2356 Certificate to use when running :hg:`serve`.
2360 Certificate to use when running :hg:`serve`.
2357
2361
2358 ``collapse``
2362 ``collapse``
2359 With ``descend`` enabled, repositories in subdirectories are shown at
2363 With ``descend`` enabled, repositories in subdirectories are shown at
2360 a single level alongside repositories in the current path. With
2364 a single level alongside repositories in the current path. With
2361 ``collapse`` also enabled, repositories residing at a deeper level than
2365 ``collapse`` also enabled, repositories residing at a deeper level than
2362 the current path are grouped behind navigable directory entries that
2366 the current path are grouped behind navigable directory entries that
2363 lead to the locations of these repositories. In effect, this setting
2367 lead to the locations of these repositories. In effect, this setting
2364 collapses each collection of repositories found within a subdirectory
2368 collapses each collection of repositories found within a subdirectory
2365 into a single entry for that subdirectory. (default: False)
2369 into a single entry for that subdirectory. (default: False)
2366
2370
2367 ``comparisoncontext``
2371 ``comparisoncontext``
2368 Number of lines of context to show in side-by-side file comparison. If
2372 Number of lines of context to show in side-by-side file comparison. If
2369 negative or the value ``full``, whole files are shown. (default: 5)
2373 negative or the value ``full``, whole files are shown. (default: 5)
2370
2374
2371 This setting can be overridden by a ``context`` request parameter to the
2375 This setting can be overridden by a ``context`` request parameter to the
2372 ``comparison`` command, taking the same values.
2376 ``comparison`` command, taking the same values.
2373
2377
2374 ``contact``
2378 ``contact``
2375 Name or email address of the person in charge of the repository.
2379 Name or email address of the person in charge of the repository.
2376 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2380 (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty)
2377
2381
2378 ``csp``
2382 ``csp``
2379 Send a ``Content-Security-Policy`` HTTP header with this value.
2383 Send a ``Content-Security-Policy`` HTTP header with this value.
2380
2384
2381 The value may contain a special string ``%nonce%``, which will be replaced
2385 The value may contain a special string ``%nonce%``, which will be replaced
2382 by a randomly-generated one-time use value. If the value contains
2386 by a randomly-generated one-time use value. If the value contains
2383 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2387 ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the
2384 one-time property of the nonce. This nonce will also be inserted into
2388 one-time property of the nonce. This nonce will also be inserted into
2385 ``<script>`` elements containing inline JavaScript.
2389 ``<script>`` elements containing inline JavaScript.
2386
2390
2387 Note: lots of HTML content sent by the server is derived from repository
2391 Note: lots of HTML content sent by the server is derived from repository
2388 data. Please consider the potential for malicious repository data to
2392 data. Please consider the potential for malicious repository data to
2389 "inject" itself into generated HTML content as part of your security
2393 "inject" itself into generated HTML content as part of your security
2390 threat model.
2394 threat model.
2391
2395
2392 ``deny_push``
2396 ``deny_push``
2393 Whether to deny pushing to the repository. If empty or not set,
2397 Whether to deny pushing to the repository. If empty or not set,
2394 push is not denied. If the special value ``*``, all remote users are
2398 push is not denied. If the special value ``*``, all remote users are
2395 denied push. Otherwise, unauthenticated users are all denied, and
2399 denied push. Otherwise, unauthenticated users are all denied, and
2396 any authenticated user name present in this list is also denied. The
2400 any authenticated user name present in this list is also denied. The
2397 contents of the deny_push list are examined before the allow-push list.
2401 contents of the deny_push list are examined before the allow-push list.
2398
2402
2399 ``deny_read``
2403 ``deny_read``
2400 Whether to deny reading/viewing of the repository. If this list is
2404 Whether to deny reading/viewing of the repository. If this list is
2401 not empty, unauthenticated users are all denied, and any
2405 not empty, unauthenticated users are all denied, and any
2402 authenticated user name present in this list is also denied access to
2406 authenticated user name present in this list is also denied access to
2403 the repository. If set to the special value ``*``, all remote users
2407 the repository. If set to the special value ``*``, all remote users
2404 are denied access (rarely needed ;). If deny_read is empty or not set,
2408 are denied access (rarely needed ;). If deny_read is empty or not set,
2405 the determination of repository access depends on the presence and
2409 the determination of repository access depends on the presence and
2406 content of the allow_read list (see description). If both
2410 content of the allow_read list (see description). If both
2407 deny_read and allow_read are empty or not set, then access is
2411 deny_read and allow_read are empty or not set, then access is
2408 permitted to all users by default. If the repository is being
2412 permitted to all users by default. If the repository is being
2409 served via hgwebdir, denied users will not be able to see it in
2413 served via hgwebdir, denied users will not be able to see it in
2410 the list of repositories. The contents of the deny_read list have
2414 the list of repositories. The contents of the deny_read list have
2411 priority over (are examined before) the contents of the allow_read
2415 priority over (are examined before) the contents of the allow_read
2412 list.
2416 list.
2413
2417
2414 ``descend``
2418 ``descend``
2415 hgwebdir indexes will not descend into subdirectories. Only repositories
2419 hgwebdir indexes will not descend into subdirectories. Only repositories
2416 directly in the current path will be shown (other repositories are still
2420 directly in the current path will be shown (other repositories are still
2417 available from the index corresponding to their containing path).
2421 available from the index corresponding to their containing path).
2418
2422
2419 ``description``
2423 ``description``
2420 Textual description of the repository's purpose or contents.
2424 Textual description of the repository's purpose or contents.
2421 (default: "unknown")
2425 (default: "unknown")
2422
2426
2423 ``encoding``
2427 ``encoding``
2424 Character encoding name. (default: the current locale charset)
2428 Character encoding name. (default: the current locale charset)
2425 Example: "UTF-8".
2429 Example: "UTF-8".
2426
2430
2427 ``errorlog``
2431 ``errorlog``
2428 Where to output the error log. (default: stderr)
2432 Where to output the error log. (default: stderr)
2429
2433
2430 ``guessmime``
2434 ``guessmime``
2431 Control MIME types for raw download of file content.
2435 Control MIME types for raw download of file content.
2432 Set to True to let hgweb guess the content type from the file
2436 Set to True to let hgweb guess the content type from the file
2433 extension. This will serve HTML files as ``text/html`` and might
2437 extension. This will serve HTML files as ``text/html`` and might
2434 allow cross-site scripting attacks when serving untrusted
2438 allow cross-site scripting attacks when serving untrusted
2435 repositories. (default: False)
2439 repositories. (default: False)
2436
2440
2437 ``hidden``
2441 ``hidden``
2438 Whether to hide the repository in the hgwebdir index.
2442 Whether to hide the repository in the hgwebdir index.
2439 (default: False)
2443 (default: False)
2440
2444
2441 ``ipv6``
2445 ``ipv6``
2442 Whether to use IPv6. (default: False)
2446 Whether to use IPv6. (default: False)
2443
2447
2444 ``labels``
2448 ``labels``
2445 List of string *labels* associated with the repository.
2449 List of string *labels* associated with the repository.
2446
2450
2447 Labels are exposed as a template keyword and can be used to customize
2451 Labels are exposed as a template keyword and can be used to customize
2448 output. e.g. the ``index`` template can group or filter repositories
2452 output. e.g. the ``index`` template can group or filter repositories
2449 by labels and the ``summary`` template can display additional content
2453 by labels and the ``summary`` template can display additional content
2450 if a specific label is present.
2454 if a specific label is present.
2451
2455
2452 ``logoimg``
2456 ``logoimg``
2453 File name of the logo image that some templates display on each page.
2457 File name of the logo image that some templates display on each page.
2454 The file name is relative to ``staticurl``. That is, the full path to
2458 The file name is relative to ``staticurl``. That is, the full path to
2455 the logo image is "staticurl/logoimg".
2459 the logo image is "staticurl/logoimg".
2456 If unset, ``hglogo.png`` will be used.
2460 If unset, ``hglogo.png`` will be used.
2457
2461
2458 ``logourl``
2462 ``logourl``
2459 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2463 Base URL to use for logos. If unset, ``https://mercurial-scm.org/``
2460 will be used.
2464 will be used.
2461
2465
2462 ``maxchanges``
2466 ``maxchanges``
2463 Maximum number of changes to list on the changelog. (default: 10)
2467 Maximum number of changes to list on the changelog. (default: 10)
2464
2468
2465 ``maxfiles``
2469 ``maxfiles``
2466 Maximum number of files to list per changeset. (default: 10)
2470 Maximum number of files to list per changeset. (default: 10)
2467
2471
2468 ``maxshortchanges``
2472 ``maxshortchanges``
2469 Maximum number of changes to list on the shortlog, graph or filelog
2473 Maximum number of changes to list on the shortlog, graph or filelog
2470 pages. (default: 60)
2474 pages. (default: 60)
2471
2475
2472 ``name``
2476 ``name``
2473 Repository name to use in the web interface.
2477 Repository name to use in the web interface.
2474 (default: current working directory)
2478 (default: current working directory)
2475
2479
2476 ``port``
2480 ``port``
2477 Port to listen on. (default: 8000)
2481 Port to listen on. (default: 8000)
2478
2482
2479 ``prefix``
2483 ``prefix``
2480 Prefix path to serve from. (default: '' (server root))
2484 Prefix path to serve from. (default: '' (server root))
2481
2485
2482 ``push_ssl``
2486 ``push_ssl``
2483 Whether to require that inbound pushes be transported over SSL to
2487 Whether to require that inbound pushes be transported over SSL to
2484 prevent password sniffing. (default: True)
2488 prevent password sniffing. (default: True)
2485
2489
2486 ``refreshinterval``
2490 ``refreshinterval``
2487 How frequently directory listings re-scan the filesystem for new
2491 How frequently directory listings re-scan the filesystem for new
2488 repositories, in seconds. This is relevant when wildcards are used
2492 repositories, in seconds. This is relevant when wildcards are used
2489 to define paths. Depending on how much filesystem traversal is
2493 to define paths. Depending on how much filesystem traversal is
2490 required, refreshing may negatively impact performance.
2494 required, refreshing may negatively impact performance.
2491
2495
2492 Values less than or equal to 0 always refresh.
2496 Values less than or equal to 0 always refresh.
2493 (default: 20)
2497 (default: 20)
2494
2498
2495 ``staticurl``
2499 ``staticurl``
2496 Base URL to use for static files. If unset, static files (e.g. the
2500 Base URL to use for static files. If unset, static files (e.g. the
2497 hgicon.png favicon) will be served by the CGI script itself. Use
2501 hgicon.png favicon) will be served by the CGI script itself. Use
2498 this setting to serve them directly with the HTTP server.
2502 this setting to serve them directly with the HTTP server.
2499 Example: ``http://hgserver/static/``.
2503 Example: ``http://hgserver/static/``.
2500
2504
2501 ``stripes``
2505 ``stripes``
2502 How many lines a "zebra stripe" should span in multi-line output.
2506 How many lines a "zebra stripe" should span in multi-line output.
2503 Set to 0 to disable. (default: 1)
2507 Set to 0 to disable. (default: 1)
2504
2508
2505 ``style``
2509 ``style``
2506 Which template map style to use. The available options are the names of
2510 Which template map style to use. The available options are the names of
2507 subdirectories in the HTML templates path. (default: ``paper``)
2511 subdirectories in the HTML templates path. (default: ``paper``)
2508 Example: ``monoblue``.
2512 Example: ``monoblue``.
2509
2513
2510 ``templates``
2514 ``templates``
2511 Where to find the HTML templates. The default path to the HTML templates
2515 Where to find the HTML templates. The default path to the HTML templates
2512 can be obtained from ``hg debuginstall``.
2516 can be obtained from ``hg debuginstall``.
2513
2517
2514 ``websub``
2518 ``websub``
2515 ----------
2519 ----------
2516
2520
2517 Web substitution filter definition. You can use this section to
2521 Web substitution filter definition. You can use this section to
2518 define a set of regular expression substitution patterns which
2522 define a set of regular expression substitution patterns which
2519 let you automatically modify the hgweb server output.
2523 let you automatically modify the hgweb server output.
2520
2524
2521 The default hgweb templates only apply these substitution patterns
2525 The default hgweb templates only apply these substitution patterns
2522 on the revision description fields. You can apply them anywhere
2526 on the revision description fields. You can apply them anywhere
2523 you want when you create your own templates by adding calls to the
2527 you want when you create your own templates by adding calls to the
2524 "websub" filter (usually after calling the "escape" filter).
2528 "websub" filter (usually after calling the "escape" filter).
2525
2529
2526 This can be used, for example, to convert issue references to links
2530 This can be used, for example, to convert issue references to links
2527 to your issue tracker, or to convert "markdown-like" syntax into
2531 to your issue tracker, or to convert "markdown-like" syntax into
2528 HTML (see the examples below).
2532 HTML (see the examples below).
2529
2533
2530 Each entry in this section names a substitution filter.
2534 Each entry in this section names a substitution filter.
2531 The value of each entry defines the substitution expression itself.
2535 The value of each entry defines the substitution expression itself.
2532 The websub expressions follow the old interhg extension syntax,
2536 The websub expressions follow the old interhg extension syntax,
2533 which in turn imitates the Unix sed replacement syntax::
2537 which in turn imitates the Unix sed replacement syntax::
2534
2538
2535 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2539 patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i]
2536
2540
2537 You can use any separator other than "/". The final "i" is optional
2541 You can use any separator other than "/". The final "i" is optional
2538 and indicates that the search must be case insensitive.
2542 and indicates that the search must be case insensitive.
2539
2543
2540 Examples::
2544 Examples::
2541
2545
2542 [websub]
2546 [websub]
2543 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2547 issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
2544 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2548 italic = s/\b_(\S+)_\b/<i>\1<\/i>/
2545 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2549 bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
2546
2550
2547 ``worker``
2551 ``worker``
2548 ----------
2552 ----------
2549
2553
2550 Parallel master/worker configuration. We currently perform working
2554 Parallel master/worker configuration. We currently perform working
2551 directory updates in parallel on Unix-like systems, which greatly
2555 directory updates in parallel on Unix-like systems, which greatly
2552 helps performance.
2556 helps performance.
2553
2557
2554 ``numcpus``
2558 ``numcpus``
2555 Number of CPUs to use for parallel operations. A zero or
2559 Number of CPUs to use for parallel operations. A zero or
2556 negative value is treated as ``use the default``.
2560 negative value is treated as ``use the default``.
2557 (default: 4 or the number of CPUs on the system, whichever is larger)
2561 (default: 4 or the number of CPUs on the system, whichever is larger)
2558
2562
2559 ``backgroundclose``
2563 ``backgroundclose``
2560 Whether to enable closing file handles on background threads during certain
2564 Whether to enable closing file handles on background threads during certain
2561 operations. Some platforms aren't very efficient at closing file
2565 operations. Some platforms aren't very efficient at closing file
2562 handles that have been written or appended to. By performing file closing
2566 handles that have been written or appended to. By performing file closing
2563 on background threads, file write rate can increase substantially.
2567 on background threads, file write rate can increase substantially.
2564 (default: true on Windows, false elsewhere)
2568 (default: true on Windows, false elsewhere)
2565
2569
2566 ``backgroundcloseminfilecount``
2570 ``backgroundcloseminfilecount``
2567 Minimum number of files required to trigger background file closing.
2571 Minimum number of files required to trigger background file closing.
2568 Operations not writing this many files won't start background close
2572 Operations not writing this many files won't start background close
2569 threads.
2573 threads.
2570 (default: 2048)
2574 (default: 2048)
2571
2575
2572 ``backgroundclosemaxqueue``
2576 ``backgroundclosemaxqueue``
2573 The maximum number of opened file handles waiting to be closed in the
2577 The maximum number of opened file handles waiting to be closed in the
2574 background. This option only has an effect if ``backgroundclose`` is
2578 background. This option only has an effect if ``backgroundclose`` is
2575 enabled.
2579 enabled.
2576 (default: 384)
2580 (default: 384)
2577
2581
2578 ``backgroundclosethreadcount``
2582 ``backgroundclosethreadcount``
2579 Number of threads to process background file closes. Only relevant if
2583 Number of threads to process background file closes. Only relevant if
2580 ``backgroundclose`` is enabled.
2584 ``backgroundclose`` is enabled.
2581 (default: 4)
2585 (default: 4)
@@ -1,2288 +1,2290 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 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@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 hashlib
11 import hashlib
12 import inspect
12 import inspect
13 import os
13 import os
14 import random
14 import random
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 hex,
20 hex,
21 nullid,
21 nullid,
22 short,
22 short,
23 )
23 )
24 from . import (
24 from . import (
25 bookmarks,
25 bookmarks,
26 branchmap,
26 branchmap,
27 bundle2,
27 bundle2,
28 changegroup,
28 changegroup,
29 changelog,
29 changelog,
30 color,
30 color,
31 context,
31 context,
32 dirstate,
32 dirstate,
33 dirstateguard,
33 dirstateguard,
34 discovery,
34 discovery,
35 encoding,
35 encoding,
36 error,
36 error,
37 exchange,
37 exchange,
38 extensions,
38 extensions,
39 filelog,
39 filelog,
40 hook,
40 hook,
41 lock as lockmod,
41 lock as lockmod,
42 manifest,
42 manifest,
43 match as matchmod,
43 match as matchmod,
44 merge as mergemod,
44 merge as mergemod,
45 mergeutil,
45 mergeutil,
46 namespaces,
46 namespaces,
47 obsolete,
47 obsolete,
48 pathutil,
48 pathutil,
49 peer,
49 peer,
50 phases,
50 phases,
51 pushkey,
51 pushkey,
52 pycompat,
52 pycompat,
53 repository,
53 repository,
54 repoview,
54 repoview,
55 revset,
55 revset,
56 revsetlang,
56 revsetlang,
57 scmutil,
57 scmutil,
58 sparse,
58 sparse,
59 store,
59 store,
60 subrepo,
60 subrepo,
61 tags as tagsmod,
61 tags as tagsmod,
62 transaction,
62 transaction,
63 txnutil,
63 txnutil,
64 util,
64 util,
65 vfs as vfsmod,
65 vfs as vfsmod,
66 )
66 )
67
67
68 release = lockmod.release
68 release = lockmod.release
69 urlerr = util.urlerr
69 urlerr = util.urlerr
70 urlreq = util.urlreq
70 urlreq = util.urlreq
71
71
72 # set of (path, vfs-location) tuples. vfs-location is:
72 # set of (path, vfs-location) tuples. vfs-location is:
73 # - 'plain for vfs relative paths
73 # - 'plain for vfs relative paths
74 # - '' for svfs relative paths
74 # - '' for svfs relative paths
75 _cachedfiles = set()
75 _cachedfiles = set()
76
76
77 class _basefilecache(scmutil.filecache):
77 class _basefilecache(scmutil.filecache):
78 """All filecache usage on repo are done for logic that should be unfiltered
78 """All filecache usage on repo are done for logic that should be unfiltered
79 """
79 """
80 def __get__(self, repo, type=None):
80 def __get__(self, repo, type=None):
81 if repo is None:
81 if repo is None:
82 return self
82 return self
83 return super(_basefilecache, self).__get__(repo.unfiltered(), type)
83 return super(_basefilecache, self).__get__(repo.unfiltered(), type)
84 def __set__(self, repo, value):
84 def __set__(self, repo, value):
85 return super(_basefilecache, self).__set__(repo.unfiltered(), value)
85 return super(_basefilecache, self).__set__(repo.unfiltered(), value)
86 def __delete__(self, repo):
86 def __delete__(self, repo):
87 return super(_basefilecache, self).__delete__(repo.unfiltered())
87 return super(_basefilecache, self).__delete__(repo.unfiltered())
88
88
89 class repofilecache(_basefilecache):
89 class repofilecache(_basefilecache):
90 """filecache for files in .hg but outside of .hg/store"""
90 """filecache for files in .hg but outside of .hg/store"""
91 def __init__(self, *paths):
91 def __init__(self, *paths):
92 super(repofilecache, self).__init__(*paths)
92 super(repofilecache, self).__init__(*paths)
93 for path in paths:
93 for path in paths:
94 _cachedfiles.add((path, 'plain'))
94 _cachedfiles.add((path, 'plain'))
95
95
96 def join(self, obj, fname):
96 def join(self, obj, fname):
97 return obj.vfs.join(fname)
97 return obj.vfs.join(fname)
98
98
99 class storecache(_basefilecache):
99 class storecache(_basefilecache):
100 """filecache for files in the store"""
100 """filecache for files in the store"""
101 def __init__(self, *paths):
101 def __init__(self, *paths):
102 super(storecache, self).__init__(*paths)
102 super(storecache, self).__init__(*paths)
103 for path in paths:
103 for path in paths:
104 _cachedfiles.add((path, ''))
104 _cachedfiles.add((path, ''))
105
105
106 def join(self, obj, fname):
106 def join(self, obj, fname):
107 return obj.sjoin(fname)
107 return obj.sjoin(fname)
108
108
109 def isfilecached(repo, name):
109 def isfilecached(repo, name):
110 """check if a repo has already cached "name" filecache-ed property
110 """check if a repo has already cached "name" filecache-ed property
111
111
112 This returns (cachedobj-or-None, iscached) tuple.
112 This returns (cachedobj-or-None, iscached) tuple.
113 """
113 """
114 cacheentry = repo.unfiltered()._filecache.get(name, None)
114 cacheentry = repo.unfiltered()._filecache.get(name, None)
115 if not cacheentry:
115 if not cacheentry:
116 return None, False
116 return None, False
117 return cacheentry.obj, True
117 return cacheentry.obj, True
118
118
119 class unfilteredpropertycache(util.propertycache):
119 class unfilteredpropertycache(util.propertycache):
120 """propertycache that apply to unfiltered repo only"""
120 """propertycache that apply to unfiltered repo only"""
121
121
122 def __get__(self, repo, type=None):
122 def __get__(self, repo, type=None):
123 unfi = repo.unfiltered()
123 unfi = repo.unfiltered()
124 if unfi is repo:
124 if unfi is repo:
125 return super(unfilteredpropertycache, self).__get__(unfi)
125 return super(unfilteredpropertycache, self).__get__(unfi)
126 return getattr(unfi, self.name)
126 return getattr(unfi, self.name)
127
127
128 class filteredpropertycache(util.propertycache):
128 class filteredpropertycache(util.propertycache):
129 """propertycache that must take filtering in account"""
129 """propertycache that must take filtering in account"""
130
130
131 def cachevalue(self, obj, value):
131 def cachevalue(self, obj, value):
132 object.__setattr__(obj, self.name, value)
132 object.__setattr__(obj, self.name, value)
133
133
134
134
135 def hasunfilteredcache(repo, name):
135 def hasunfilteredcache(repo, name):
136 """check if a repo has an unfilteredpropertycache value for <name>"""
136 """check if a repo has an unfilteredpropertycache value for <name>"""
137 return name in vars(repo.unfiltered())
137 return name in vars(repo.unfiltered())
138
138
139 def unfilteredmethod(orig):
139 def unfilteredmethod(orig):
140 """decorate method that always need to be run on unfiltered version"""
140 """decorate method that always need to be run on unfiltered version"""
141 def wrapper(repo, *args, **kwargs):
141 def wrapper(repo, *args, **kwargs):
142 return orig(repo.unfiltered(), *args, **kwargs)
142 return orig(repo.unfiltered(), *args, **kwargs)
143 return wrapper
143 return wrapper
144
144
145 moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
145 moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
146 'unbundle'}
146 'unbundle'}
147 legacycaps = moderncaps.union({'changegroupsubset'})
147 legacycaps = moderncaps.union({'changegroupsubset'})
148
148
149 class localpeer(repository.peer):
149 class localpeer(repository.peer):
150 '''peer for a local repo; reflects only the most recent API'''
150 '''peer for a local repo; reflects only the most recent API'''
151
151
152 def __init__(self, repo, caps=None):
152 def __init__(self, repo, caps=None):
153 super(localpeer, self).__init__()
153 super(localpeer, self).__init__()
154
154
155 if caps is None:
155 if caps is None:
156 caps = moderncaps.copy()
156 caps = moderncaps.copy()
157 self._repo = repo.filtered('served')
157 self._repo = repo.filtered('served')
158 self._ui = repo.ui
158 self._ui = repo.ui
159 self._caps = repo._restrictcapabilities(caps)
159 self._caps = repo._restrictcapabilities(caps)
160
160
161 # Begin of _basepeer interface.
161 # Begin of _basepeer interface.
162
162
163 @util.propertycache
163 @util.propertycache
164 def ui(self):
164 def ui(self):
165 return self._ui
165 return self._ui
166
166
167 def url(self):
167 def url(self):
168 return self._repo.url()
168 return self._repo.url()
169
169
170 def local(self):
170 def local(self):
171 return self._repo
171 return self._repo
172
172
173 def peer(self):
173 def peer(self):
174 return self
174 return self
175
175
176 def canpush(self):
176 def canpush(self):
177 return True
177 return True
178
178
179 def close(self):
179 def close(self):
180 self._repo.close()
180 self._repo.close()
181
181
182 # End of _basepeer interface.
182 # End of _basepeer interface.
183
183
184 # Begin of _basewirecommands interface.
184 # Begin of _basewirecommands interface.
185
185
186 def branchmap(self):
186 def branchmap(self):
187 return self._repo.branchmap()
187 return self._repo.branchmap()
188
188
189 def capabilities(self):
189 def capabilities(self):
190 return self._caps
190 return self._caps
191
191
192 def debugwireargs(self, one, two, three=None, four=None, five=None):
192 def debugwireargs(self, one, two, three=None, four=None, five=None):
193 """Used to test argument passing over the wire"""
193 """Used to test argument passing over the wire"""
194 return "%s %s %s %s %s" % (one, two, three, four, five)
194 return "%s %s %s %s %s" % (one, two, three, four, five)
195
195
196 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
196 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
197 **kwargs):
197 **kwargs):
198 chunks = exchange.getbundlechunks(self._repo, source, heads=heads,
198 chunks = exchange.getbundlechunks(self._repo, source, heads=heads,
199 common=common, bundlecaps=bundlecaps,
199 common=common, bundlecaps=bundlecaps,
200 **kwargs)
200 **kwargs)
201 cb = util.chunkbuffer(chunks)
201 cb = util.chunkbuffer(chunks)
202
202
203 if exchange.bundle2requested(bundlecaps):
203 if exchange.bundle2requested(bundlecaps):
204 # When requesting a bundle2, getbundle returns a stream to make the
204 # When requesting a bundle2, getbundle returns a stream to make the
205 # wire level function happier. We need to build a proper object
205 # wire level function happier. We need to build a proper object
206 # from it in local peer.
206 # from it in local peer.
207 return bundle2.getunbundler(self.ui, cb)
207 return bundle2.getunbundler(self.ui, cb)
208 else:
208 else:
209 return changegroup.getunbundler('01', cb, None)
209 return changegroup.getunbundler('01', cb, None)
210
210
211 def heads(self):
211 def heads(self):
212 return self._repo.heads()
212 return self._repo.heads()
213
213
214 def known(self, nodes):
214 def known(self, nodes):
215 return self._repo.known(nodes)
215 return self._repo.known(nodes)
216
216
217 def listkeys(self, namespace):
217 def listkeys(self, namespace):
218 return self._repo.listkeys(namespace)
218 return self._repo.listkeys(namespace)
219
219
220 def lookup(self, key):
220 def lookup(self, key):
221 return self._repo.lookup(key)
221 return self._repo.lookup(key)
222
222
223 def pushkey(self, namespace, key, old, new):
223 def pushkey(self, namespace, key, old, new):
224 return self._repo.pushkey(namespace, key, old, new)
224 return self._repo.pushkey(namespace, key, old, new)
225
225
226 def stream_out(self):
226 def stream_out(self):
227 raise error.Abort(_('cannot perform stream clone against local '
227 raise error.Abort(_('cannot perform stream clone against local '
228 'peer'))
228 'peer'))
229
229
230 def unbundle(self, cg, heads, url):
230 def unbundle(self, cg, heads, url):
231 """apply a bundle on a repo
231 """apply a bundle on a repo
232
232
233 This function handles the repo locking itself."""
233 This function handles the repo locking itself."""
234 try:
234 try:
235 try:
235 try:
236 cg = exchange.readbundle(self.ui, cg, None)
236 cg = exchange.readbundle(self.ui, cg, None)
237 ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
237 ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
238 if util.safehasattr(ret, 'getchunks'):
238 if util.safehasattr(ret, 'getchunks'):
239 # This is a bundle20 object, turn it into an unbundler.
239 # This is a bundle20 object, turn it into an unbundler.
240 # This little dance should be dropped eventually when the
240 # This little dance should be dropped eventually when the
241 # API is finally improved.
241 # API is finally improved.
242 stream = util.chunkbuffer(ret.getchunks())
242 stream = util.chunkbuffer(ret.getchunks())
243 ret = bundle2.getunbundler(self.ui, stream)
243 ret = bundle2.getunbundler(self.ui, stream)
244 return ret
244 return ret
245 except Exception as exc:
245 except Exception as exc:
246 # If the exception contains output salvaged from a bundle2
246 # If the exception contains output salvaged from a bundle2
247 # reply, we need to make sure it is printed before continuing
247 # reply, we need to make sure it is printed before continuing
248 # to fail. So we build a bundle2 with such output and consume
248 # to fail. So we build a bundle2 with such output and consume
249 # it directly.
249 # it directly.
250 #
250 #
251 # This is not very elegant but allows a "simple" solution for
251 # This is not very elegant but allows a "simple" solution for
252 # issue4594
252 # issue4594
253 output = getattr(exc, '_bundle2salvagedoutput', ())
253 output = getattr(exc, '_bundle2salvagedoutput', ())
254 if output:
254 if output:
255 bundler = bundle2.bundle20(self._repo.ui)
255 bundler = bundle2.bundle20(self._repo.ui)
256 for out in output:
256 for out in output:
257 bundler.addpart(out)
257 bundler.addpart(out)
258 stream = util.chunkbuffer(bundler.getchunks())
258 stream = util.chunkbuffer(bundler.getchunks())
259 b = bundle2.getunbundler(self.ui, stream)
259 b = bundle2.getunbundler(self.ui, stream)
260 bundle2.processbundle(self._repo, b)
260 bundle2.processbundle(self._repo, b)
261 raise
261 raise
262 except error.PushRaced as exc:
262 except error.PushRaced as exc:
263 raise error.ResponseError(_('push failed:'), str(exc))
263 raise error.ResponseError(_('push failed:'), str(exc))
264
264
265 # End of _basewirecommands interface.
265 # End of _basewirecommands interface.
266
266
267 # Begin of peer interface.
267 # Begin of peer interface.
268
268
269 def iterbatch(self):
269 def iterbatch(self):
270 return peer.localiterbatcher(self)
270 return peer.localiterbatcher(self)
271
271
272 # End of peer interface.
272 # End of peer interface.
273
273
274 class locallegacypeer(repository.legacypeer, localpeer):
274 class locallegacypeer(repository.legacypeer, localpeer):
275 '''peer extension which implements legacy methods too; used for tests with
275 '''peer extension which implements legacy methods too; used for tests with
276 restricted capabilities'''
276 restricted capabilities'''
277
277
278 def __init__(self, repo):
278 def __init__(self, repo):
279 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
279 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
280
280
281 # Begin of baselegacywirecommands interface.
281 # Begin of baselegacywirecommands interface.
282
282
283 def between(self, pairs):
283 def between(self, pairs):
284 return self._repo.between(pairs)
284 return self._repo.between(pairs)
285
285
286 def branches(self, nodes):
286 def branches(self, nodes):
287 return self._repo.branches(nodes)
287 return self._repo.branches(nodes)
288
288
289 def changegroup(self, basenodes, source):
289 def changegroup(self, basenodes, source):
290 outgoing = discovery.outgoing(self._repo, missingroots=basenodes,
290 outgoing = discovery.outgoing(self._repo, missingroots=basenodes,
291 missingheads=self._repo.heads())
291 missingheads=self._repo.heads())
292 return changegroup.makechangegroup(self._repo, outgoing, '01', source)
292 return changegroup.makechangegroup(self._repo, outgoing, '01', source)
293
293
294 def changegroupsubset(self, bases, heads, source):
294 def changegroupsubset(self, bases, heads, source):
295 outgoing = discovery.outgoing(self._repo, missingroots=bases,
295 outgoing = discovery.outgoing(self._repo, missingroots=bases,
296 missingheads=heads)
296 missingheads=heads)
297 return changegroup.makechangegroup(self._repo, outgoing, '01', source)
297 return changegroup.makechangegroup(self._repo, outgoing, '01', source)
298
298
299 # End of baselegacywirecommands interface.
299 # End of baselegacywirecommands interface.
300
300
301 # Increment the sub-version when the revlog v2 format changes to lock out old
301 # Increment the sub-version when the revlog v2 format changes to lock out old
302 # clients.
302 # clients.
303 REVLOGV2_REQUIREMENT = 'exp-revlogv2.0'
303 REVLOGV2_REQUIREMENT = 'exp-revlogv2.0'
304
304
305 class localrepository(object):
305 class localrepository(object):
306
306
307 supportedformats = {
307 supportedformats = {
308 'revlogv1',
308 'revlogv1',
309 'generaldelta',
309 'generaldelta',
310 'treemanifest',
310 'treemanifest',
311 'manifestv2',
311 'manifestv2',
312 REVLOGV2_REQUIREMENT,
312 REVLOGV2_REQUIREMENT,
313 }
313 }
314 _basesupported = supportedformats | {
314 _basesupported = supportedformats | {
315 'store',
315 'store',
316 'fncache',
316 'fncache',
317 'shared',
317 'shared',
318 'relshared',
318 'relshared',
319 'dotencode',
319 'dotencode',
320 'exp-sparse',
320 'exp-sparse',
321 }
321 }
322 openerreqs = {
322 openerreqs = {
323 'revlogv1',
323 'revlogv1',
324 'generaldelta',
324 'generaldelta',
325 'treemanifest',
325 'treemanifest',
326 'manifestv2',
326 'manifestv2',
327 }
327 }
328
328
329 # a list of (ui, featureset) functions.
329 # a list of (ui, featureset) functions.
330 # only functions defined in module of enabled extensions are invoked
330 # only functions defined in module of enabled extensions are invoked
331 featuresetupfuncs = set()
331 featuresetupfuncs = set()
332
332
333 # list of prefix for file which can be written without 'wlock'
333 # list of prefix for file which can be written without 'wlock'
334 # Extensions should extend this list when needed
334 # Extensions should extend this list when needed
335 _wlockfreeprefix = {
335 _wlockfreeprefix = {
336 # We migh consider requiring 'wlock' for the next
336 # We migh consider requiring 'wlock' for the next
337 # two, but pretty much all the existing code assume
337 # two, but pretty much all the existing code assume
338 # wlock is not needed so we keep them excluded for
338 # wlock is not needed so we keep them excluded for
339 # now.
339 # now.
340 'hgrc',
340 'hgrc',
341 'requires',
341 'requires',
342 # XXX cache is a complicatged business someone
342 # XXX cache is a complicatged business someone
343 # should investigate this in depth at some point
343 # should investigate this in depth at some point
344 'cache/',
344 'cache/',
345 # XXX shouldn't be dirstate covered by the wlock?
345 # XXX shouldn't be dirstate covered by the wlock?
346 'dirstate',
346 'dirstate',
347 # XXX bisect was still a bit too messy at the time
347 # XXX bisect was still a bit too messy at the time
348 # this changeset was introduced. Someone should fix
348 # this changeset was introduced. Someone should fix
349 # the remainig bit and drop this line
349 # the remainig bit and drop this line
350 'bisect.state',
350 'bisect.state',
351 }
351 }
352
352
353 def __init__(self, baseui, path, create=False):
353 def __init__(self, baseui, path, create=False):
354 self.requirements = set()
354 self.requirements = set()
355 self.filtername = None
355 self.filtername = None
356 # wvfs: rooted at the repository root, used to access the working copy
356 # wvfs: rooted at the repository root, used to access the working copy
357 self.wvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
357 self.wvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
358 # vfs: rooted at .hg, used to access repo files outside of .hg/store
358 # vfs: rooted at .hg, used to access repo files outside of .hg/store
359 self.vfs = None
359 self.vfs = None
360 # svfs: usually rooted at .hg/store, used to access repository history
360 # svfs: usually rooted at .hg/store, used to access repository history
361 # If this is a shared repository, this vfs may point to another
361 # If this is a shared repository, this vfs may point to another
362 # repository's .hg/store directory.
362 # repository's .hg/store directory.
363 self.svfs = None
363 self.svfs = None
364 self.root = self.wvfs.base
364 self.root = self.wvfs.base
365 self.path = self.wvfs.join(".hg")
365 self.path = self.wvfs.join(".hg")
366 self.origroot = path
366 self.origroot = path
367 # This is only used by context.workingctx.match in order to
367 # This is only used by context.workingctx.match in order to
368 # detect files in subrepos.
368 # detect files in subrepos.
369 self.auditor = pathutil.pathauditor(
369 self.auditor = pathutil.pathauditor(
370 self.root, callback=self._checknested)
370 self.root, callback=self._checknested)
371 # This is only used by context.basectx.match in order to detect
371 # This is only used by context.basectx.match in order to detect
372 # files in subrepos.
372 # files in subrepos.
373 self.nofsauditor = pathutil.pathauditor(
373 self.nofsauditor = pathutil.pathauditor(
374 self.root, callback=self._checknested, realfs=False, cached=True)
374 self.root, callback=self._checknested, realfs=False, cached=True)
375 self.baseui = baseui
375 self.baseui = baseui
376 self.ui = baseui.copy()
376 self.ui = baseui.copy()
377 self.ui.copy = baseui.copy # prevent copying repo configuration
377 self.ui.copy = baseui.copy # prevent copying repo configuration
378 self.vfs = vfsmod.vfs(self.path, cacheaudited=True)
378 self.vfs = vfsmod.vfs(self.path, cacheaudited=True)
379 if (self.ui.configbool('devel', 'all-warnings') or
379 if (self.ui.configbool('devel', 'all-warnings') or
380 self.ui.configbool('devel', 'check-locks')):
380 self.ui.configbool('devel', 'check-locks')):
381 self.vfs.audit = self._getvfsward(self.vfs.audit)
381 self.vfs.audit = self._getvfsward(self.vfs.audit)
382 # A list of callback to shape the phase if no data were found.
382 # A list of callback to shape the phase if no data were found.
383 # Callback are in the form: func(repo, roots) --> processed root.
383 # Callback are in the form: func(repo, roots) --> processed root.
384 # This list it to be filled by extension during repo setup
384 # This list it to be filled by extension during repo setup
385 self._phasedefaults = []
385 self._phasedefaults = []
386 try:
386 try:
387 self.ui.readconfig(self.vfs.join("hgrc"), self.root)
387 self.ui.readconfig(self.vfs.join("hgrc"), self.root)
388 self._loadextensions()
388 self._loadextensions()
389 except IOError:
389 except IOError:
390 pass
390 pass
391
391
392 if self.featuresetupfuncs:
392 if self.featuresetupfuncs:
393 self.supported = set(self._basesupported) # use private copy
393 self.supported = set(self._basesupported) # use private copy
394 extmods = set(m.__name__ for n, m
394 extmods = set(m.__name__ for n, m
395 in extensions.extensions(self.ui))
395 in extensions.extensions(self.ui))
396 for setupfunc in self.featuresetupfuncs:
396 for setupfunc in self.featuresetupfuncs:
397 if setupfunc.__module__ in extmods:
397 if setupfunc.__module__ in extmods:
398 setupfunc(self.ui, self.supported)
398 setupfunc(self.ui, self.supported)
399 else:
399 else:
400 self.supported = self._basesupported
400 self.supported = self._basesupported
401 color.setup(self.ui)
401 color.setup(self.ui)
402
402
403 # Add compression engines.
403 # Add compression engines.
404 for name in util.compengines:
404 for name in util.compengines:
405 engine = util.compengines[name]
405 engine = util.compengines[name]
406 if engine.revlogheader():
406 if engine.revlogheader():
407 self.supported.add('exp-compression-%s' % name)
407 self.supported.add('exp-compression-%s' % name)
408
408
409 if not self.vfs.isdir():
409 if not self.vfs.isdir():
410 if create:
410 if create:
411 self.requirements = newreporequirements(self)
411 self.requirements = newreporequirements(self)
412
412
413 if not self.wvfs.exists():
413 if not self.wvfs.exists():
414 self.wvfs.makedirs()
414 self.wvfs.makedirs()
415 self.vfs.makedir(notindexed=True)
415 self.vfs.makedir(notindexed=True)
416
416
417 if 'store' in self.requirements:
417 if 'store' in self.requirements:
418 self.vfs.mkdir("store")
418 self.vfs.mkdir("store")
419
419
420 # create an invalid changelog
420 # create an invalid changelog
421 self.vfs.append(
421 self.vfs.append(
422 "00changelog.i",
422 "00changelog.i",
423 '\0\0\0\2' # represents revlogv2
423 '\0\0\0\2' # represents revlogv2
424 ' dummy changelog to prevent using the old repo layout'
424 ' dummy changelog to prevent using the old repo layout'
425 )
425 )
426 else:
426 else:
427 raise error.RepoError(_("repository %s not found") % path)
427 raise error.RepoError(_("repository %s not found") % path)
428 elif create:
428 elif create:
429 raise error.RepoError(_("repository %s already exists") % path)
429 raise error.RepoError(_("repository %s already exists") % path)
430 else:
430 else:
431 try:
431 try:
432 self.requirements = scmutil.readrequires(
432 self.requirements = scmutil.readrequires(
433 self.vfs, self.supported)
433 self.vfs, self.supported)
434 except IOError as inst:
434 except IOError as inst:
435 if inst.errno != errno.ENOENT:
435 if inst.errno != errno.ENOENT:
436 raise
436 raise
437
437
438 cachepath = self.vfs.join('cache')
438 cachepath = self.vfs.join('cache')
439 self.sharedpath = self.path
439 self.sharedpath = self.path
440 try:
440 try:
441 sharedpath = self.vfs.read("sharedpath").rstrip('\n')
441 sharedpath = self.vfs.read("sharedpath").rstrip('\n')
442 if 'relshared' in self.requirements:
442 if 'relshared' in self.requirements:
443 sharedpath = self.vfs.join(sharedpath)
443 sharedpath = self.vfs.join(sharedpath)
444 vfs = vfsmod.vfs(sharedpath, realpath=True)
444 vfs = vfsmod.vfs(sharedpath, realpath=True)
445 cachepath = vfs.join('cache')
445 cachepath = vfs.join('cache')
446 s = vfs.base
446 s = vfs.base
447 if not vfs.exists():
447 if not vfs.exists():
448 raise error.RepoError(
448 raise error.RepoError(
449 _('.hg/sharedpath points to nonexistent directory %s') % s)
449 _('.hg/sharedpath points to nonexistent directory %s') % s)
450 self.sharedpath = s
450 self.sharedpath = s
451 except IOError as inst:
451 except IOError as inst:
452 if inst.errno != errno.ENOENT:
452 if inst.errno != errno.ENOENT:
453 raise
453 raise
454
454
455 if 'exp-sparse' in self.requirements and not sparse.enabled:
455 if 'exp-sparse' in self.requirements and not sparse.enabled:
456 raise error.RepoError(_('repository is using sparse feature but '
456 raise error.RepoError(_('repository is using sparse feature but '
457 'sparse is not enabled; enable the '
457 'sparse is not enabled; enable the '
458 '"sparse" extensions to access'))
458 '"sparse" extensions to access'))
459
459
460 self.store = store.store(
460 self.store = store.store(
461 self.requirements, self.sharedpath,
461 self.requirements, self.sharedpath,
462 lambda base: vfsmod.vfs(base, cacheaudited=True))
462 lambda base: vfsmod.vfs(base, cacheaudited=True))
463 self.spath = self.store.path
463 self.spath = self.store.path
464 self.svfs = self.store.vfs
464 self.svfs = self.store.vfs
465 self.sjoin = self.store.join
465 self.sjoin = self.store.join
466 self.vfs.createmode = self.store.createmode
466 self.vfs.createmode = self.store.createmode
467 self.cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
467 self.cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
468 self.cachevfs.createmode = self.store.createmode
468 self.cachevfs.createmode = self.store.createmode
469 if (self.ui.configbool('devel', 'all-warnings') or
469 if (self.ui.configbool('devel', 'all-warnings') or
470 self.ui.configbool('devel', 'check-locks')):
470 self.ui.configbool('devel', 'check-locks')):
471 if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs
471 if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs
472 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
472 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
473 else: # standard vfs
473 else: # standard vfs
474 self.svfs.audit = self._getsvfsward(self.svfs.audit)
474 self.svfs.audit = self._getsvfsward(self.svfs.audit)
475 self._applyopenerreqs()
475 self._applyopenerreqs()
476 if create:
476 if create:
477 self._writerequirements()
477 self._writerequirements()
478
478
479 self._dirstatevalidatewarned = False
479 self._dirstatevalidatewarned = False
480
480
481 self._branchcaches = {}
481 self._branchcaches = {}
482 self._revbranchcache = None
482 self._revbranchcache = None
483 self.filterpats = {}
483 self.filterpats = {}
484 self._datafilters = {}
484 self._datafilters = {}
485 self._transref = self._lockref = self._wlockref = None
485 self._transref = self._lockref = self._wlockref = None
486
486
487 # A cache for various files under .hg/ that tracks file changes,
487 # A cache for various files under .hg/ that tracks file changes,
488 # (used by the filecache decorator)
488 # (used by the filecache decorator)
489 #
489 #
490 # Maps a property name to its util.filecacheentry
490 # Maps a property name to its util.filecacheentry
491 self._filecache = {}
491 self._filecache = {}
492
492
493 # hold sets of revision to be filtered
493 # hold sets of revision to be filtered
494 # should be cleared when something might have changed the filter value:
494 # should be cleared when something might have changed the filter value:
495 # - new changesets,
495 # - new changesets,
496 # - phase change,
496 # - phase change,
497 # - new obsolescence marker,
497 # - new obsolescence marker,
498 # - working directory parent change,
498 # - working directory parent change,
499 # - bookmark changes
499 # - bookmark changes
500 self.filteredrevcache = {}
500 self.filteredrevcache = {}
501
501
502 # post-dirstate-status hooks
502 # post-dirstate-status hooks
503 self._postdsstatus = []
503 self._postdsstatus = []
504
504
505 # Cache of types representing filtered repos.
505 # Cache of types representing filtered repos.
506 self._filteredrepotypes = weakref.WeakKeyDictionary()
506 self._filteredrepotypes = weakref.WeakKeyDictionary()
507
507
508 # generic mapping between names and nodes
508 # generic mapping between names and nodes
509 self.names = namespaces.namespaces()
509 self.names = namespaces.namespaces()
510
510
511 # Key to signature value.
511 # Key to signature value.
512 self._sparsesignaturecache = {}
512 self._sparsesignaturecache = {}
513 # Signature to cached matcher instance.
513 # Signature to cached matcher instance.
514 self._sparsematchercache = {}
514 self._sparsematchercache = {}
515
515
516 def _getvfsward(self, origfunc):
516 def _getvfsward(self, origfunc):
517 """build a ward for self.vfs"""
517 """build a ward for self.vfs"""
518 rref = weakref.ref(self)
518 rref = weakref.ref(self)
519 def checkvfs(path, mode=None):
519 def checkvfs(path, mode=None):
520 ret = origfunc(path, mode=mode)
520 ret = origfunc(path, mode=mode)
521 repo = rref()
521 repo = rref()
522 if (repo is None
522 if (repo is None
523 or not util.safehasattr(repo, '_wlockref')
523 or not util.safehasattr(repo, '_wlockref')
524 or not util.safehasattr(repo, '_lockref')):
524 or not util.safehasattr(repo, '_lockref')):
525 return
525 return
526 if mode in (None, 'r', 'rb'):
526 if mode in (None, 'r', 'rb'):
527 return
527 return
528 if path.startswith(repo.path):
528 if path.startswith(repo.path):
529 # truncate name relative to the repository (.hg)
529 # truncate name relative to the repository (.hg)
530 path = path[len(repo.path) + 1:]
530 path = path[len(repo.path) + 1:]
531 if path.startswith('cache/'):
531 if path.startswith('cache/'):
532 msg = 'accessing cache with vfs instead of cachevfs: "%s"'
532 msg = 'accessing cache with vfs instead of cachevfs: "%s"'
533 repo.ui.develwarn(msg % path, stacklevel=2, config="cache-vfs")
533 repo.ui.develwarn(msg % path, stacklevel=2, config="cache-vfs")
534 if path.startswith('journal.'):
534 if path.startswith('journal.'):
535 # journal is covered by 'lock'
535 # journal is covered by 'lock'
536 if repo._currentlock(repo._lockref) is None:
536 if repo._currentlock(repo._lockref) is None:
537 repo.ui.develwarn('write with no lock: "%s"' % path,
537 repo.ui.develwarn('write with no lock: "%s"' % path,
538 stacklevel=2, config='check-locks')
538 stacklevel=2, config='check-locks')
539 elif repo._currentlock(repo._wlockref) is None:
539 elif repo._currentlock(repo._wlockref) is None:
540 # rest of vfs files are covered by 'wlock'
540 # rest of vfs files are covered by 'wlock'
541 #
541 #
542 # exclude special files
542 # exclude special files
543 for prefix in self._wlockfreeprefix:
543 for prefix in self._wlockfreeprefix:
544 if path.startswith(prefix):
544 if path.startswith(prefix):
545 return
545 return
546 repo.ui.develwarn('write with no wlock: "%s"' % path,
546 repo.ui.develwarn('write with no wlock: "%s"' % path,
547 stacklevel=2, config='check-locks')
547 stacklevel=2, config='check-locks')
548 return ret
548 return ret
549 return checkvfs
549 return checkvfs
550
550
551 def _getsvfsward(self, origfunc):
551 def _getsvfsward(self, origfunc):
552 """build a ward for self.svfs"""
552 """build a ward for self.svfs"""
553 rref = weakref.ref(self)
553 rref = weakref.ref(self)
554 def checksvfs(path, mode=None):
554 def checksvfs(path, mode=None):
555 ret = origfunc(path, mode=mode)
555 ret = origfunc(path, mode=mode)
556 repo = rref()
556 repo = rref()
557 if repo is None or not util.safehasattr(repo, '_lockref'):
557 if repo is None or not util.safehasattr(repo, '_lockref'):
558 return
558 return
559 if mode in (None, 'r', 'rb'):
559 if mode in (None, 'r', 'rb'):
560 return
560 return
561 if path.startswith(repo.sharedpath):
561 if path.startswith(repo.sharedpath):
562 # truncate name relative to the repository (.hg)
562 # truncate name relative to the repository (.hg)
563 path = path[len(repo.sharedpath) + 1:]
563 path = path[len(repo.sharedpath) + 1:]
564 if repo._currentlock(repo._lockref) is None:
564 if repo._currentlock(repo._lockref) is None:
565 repo.ui.develwarn('write with no lock: "%s"' % path,
565 repo.ui.develwarn('write with no lock: "%s"' % path,
566 stacklevel=3)
566 stacklevel=3)
567 return ret
567 return ret
568 return checksvfs
568 return checksvfs
569
569
570 def close(self):
570 def close(self):
571 self._writecaches()
571 self._writecaches()
572
572
573 def _loadextensions(self):
573 def _loadextensions(self):
574 extensions.loadall(self.ui)
574 extensions.loadall(self.ui)
575
575
576 def _writecaches(self):
576 def _writecaches(self):
577 if self._revbranchcache:
577 if self._revbranchcache:
578 self._revbranchcache.write()
578 self._revbranchcache.write()
579
579
580 def _restrictcapabilities(self, caps):
580 def _restrictcapabilities(self, caps):
581 if self.ui.configbool('experimental', 'bundle2-advertise'):
581 if self.ui.configbool('experimental', 'bundle2-advertise'):
582 caps = set(caps)
582 caps = set(caps)
583 capsblob = bundle2.encodecaps(bundle2.getrepocaps(self))
583 capsblob = bundle2.encodecaps(bundle2.getrepocaps(self))
584 caps.add('bundle2=' + urlreq.quote(capsblob))
584 caps.add('bundle2=' + urlreq.quote(capsblob))
585 return caps
585 return caps
586
586
587 def _applyopenerreqs(self):
587 def _applyopenerreqs(self):
588 self.svfs.options = dict((r, 1) for r in self.requirements
588 self.svfs.options = dict((r, 1) for r in self.requirements
589 if r in self.openerreqs)
589 if r in self.openerreqs)
590 # experimental config: format.chunkcachesize
590 # experimental config: format.chunkcachesize
591 chunkcachesize = self.ui.configint('format', 'chunkcachesize')
591 chunkcachesize = self.ui.configint('format', 'chunkcachesize')
592 if chunkcachesize is not None:
592 if chunkcachesize is not None:
593 self.svfs.options['chunkcachesize'] = chunkcachesize
593 self.svfs.options['chunkcachesize'] = chunkcachesize
594 # experimental config: format.maxchainlen
594 # experimental config: format.maxchainlen
595 maxchainlen = self.ui.configint('format', 'maxchainlen')
595 maxchainlen = self.ui.configint('format', 'maxchainlen')
596 if maxchainlen is not None:
596 if maxchainlen is not None:
597 self.svfs.options['maxchainlen'] = maxchainlen
597 self.svfs.options['maxchainlen'] = maxchainlen
598 # experimental config: format.manifestcachesize
598 # experimental config: format.manifestcachesize
599 manifestcachesize = self.ui.configint('format', 'manifestcachesize')
599 manifestcachesize = self.ui.configint('format', 'manifestcachesize')
600 if manifestcachesize is not None:
600 if manifestcachesize is not None:
601 self.svfs.options['manifestcachesize'] = manifestcachesize
601 self.svfs.options['manifestcachesize'] = manifestcachesize
602 # experimental config: format.aggressivemergedeltas
602 # experimental config: format.aggressivemergedeltas
603 aggressivemergedeltas = self.ui.configbool('format',
603 aggressivemergedeltas = self.ui.configbool('format',
604 'aggressivemergedeltas')
604 'aggressivemergedeltas')
605 self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas
605 self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas
606 self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui)
606 self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui)
607 chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan')
607 chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan')
608 if 0 <= chainspan:
608 if 0 <= chainspan:
609 self.svfs.options['maxdeltachainspan'] = chainspan
609 self.svfs.options['maxdeltachainspan'] = chainspan
610 mmapindexthreshold = self.ui.configbytes('experimental',
610 mmapindexthreshold = self.ui.configbytes('experimental',
611 'mmapindexthreshold')
611 'mmapindexthreshold')
612 if mmapindexthreshold is not None:
612 if mmapindexthreshold is not None:
613 self.svfs.options['mmapindexthreshold'] = mmapindexthreshold
613 self.svfs.options['mmapindexthreshold'] = mmapindexthreshold
614 withsparseread = self.ui.configbool('experimental', 'sparse-read')
614 withsparseread = self.ui.configbool('experimental', 'sparse-read')
615 srdensitythres = float(self.ui.config('experimental',
615 srdensitythres = float(self.ui.config('experimental',
616 'sparse-read.density-threshold'))
616 'sparse-read.density-threshold'))
617 srmingapsize = self.ui.configbytes('experimental',
617 srmingapsize = self.ui.configbytes('experimental',
618 'sparse-read.min-gap-size')
618 'sparse-read.min-gap-size')
619 self.svfs.options['with-sparse-read'] = withsparseread
619 self.svfs.options['with-sparse-read'] = withsparseread
620 self.svfs.options['sparse-read-density-threshold'] = srdensitythres
620 self.svfs.options['sparse-read-density-threshold'] = srdensitythres
621 self.svfs.options['sparse-read-min-gap-size'] = srmingapsize
621 self.svfs.options['sparse-read-min-gap-size'] = srmingapsize
622
622
623 for r in self.requirements:
623 for r in self.requirements:
624 if r.startswith('exp-compression-'):
624 if r.startswith('exp-compression-'):
625 self.svfs.options['compengine'] = r[len('exp-compression-'):]
625 self.svfs.options['compengine'] = r[len('exp-compression-'):]
626
626
627 # TODO move "revlogv2" to openerreqs once finalized.
627 # TODO move "revlogv2" to openerreqs once finalized.
628 if REVLOGV2_REQUIREMENT in self.requirements:
628 if REVLOGV2_REQUIREMENT in self.requirements:
629 self.svfs.options['revlogv2'] = True
629 self.svfs.options['revlogv2'] = True
630
630
631 def _writerequirements(self):
631 def _writerequirements(self):
632 scmutil.writerequires(self.vfs, self.requirements)
632 scmutil.writerequires(self.vfs, self.requirements)
633
633
634 def _checknested(self, path):
634 def _checknested(self, path):
635 """Determine if path is a legal nested repository."""
635 """Determine if path is a legal nested repository."""
636 if not path.startswith(self.root):
636 if not path.startswith(self.root):
637 return False
637 return False
638 subpath = path[len(self.root) + 1:]
638 subpath = path[len(self.root) + 1:]
639 normsubpath = util.pconvert(subpath)
639 normsubpath = util.pconvert(subpath)
640
640
641 # XXX: Checking against the current working copy is wrong in
641 # XXX: Checking against the current working copy is wrong in
642 # the sense that it can reject things like
642 # the sense that it can reject things like
643 #
643 #
644 # $ hg cat -r 10 sub/x.txt
644 # $ hg cat -r 10 sub/x.txt
645 #
645 #
646 # if sub/ is no longer a subrepository in the working copy
646 # if sub/ is no longer a subrepository in the working copy
647 # parent revision.
647 # parent revision.
648 #
648 #
649 # However, it can of course also allow things that would have
649 # However, it can of course also allow things that would have
650 # been rejected before, such as the above cat command if sub/
650 # been rejected before, such as the above cat command if sub/
651 # is a subrepository now, but was a normal directory before.
651 # is a subrepository now, but was a normal directory before.
652 # The old path auditor would have rejected by mistake since it
652 # The old path auditor would have rejected by mistake since it
653 # panics when it sees sub/.hg/.
653 # panics when it sees sub/.hg/.
654 #
654 #
655 # All in all, checking against the working copy seems sensible
655 # All in all, checking against the working copy seems sensible
656 # since we want to prevent access to nested repositories on
656 # since we want to prevent access to nested repositories on
657 # the filesystem *now*.
657 # the filesystem *now*.
658 ctx = self[None]
658 ctx = self[None]
659 parts = util.splitpath(subpath)
659 parts = util.splitpath(subpath)
660 while parts:
660 while parts:
661 prefix = '/'.join(parts)
661 prefix = '/'.join(parts)
662 if prefix in ctx.substate:
662 if prefix in ctx.substate:
663 if prefix == normsubpath:
663 if prefix == normsubpath:
664 return True
664 return True
665 else:
665 else:
666 sub = ctx.sub(prefix)
666 sub = ctx.sub(prefix)
667 return sub.checknested(subpath[len(prefix) + 1:])
667 return sub.checknested(subpath[len(prefix) + 1:])
668 else:
668 else:
669 parts.pop()
669 parts.pop()
670 return False
670 return False
671
671
672 def peer(self):
672 def peer(self):
673 return localpeer(self) # not cached to avoid reference cycle
673 return localpeer(self) # not cached to avoid reference cycle
674
674
675 def unfiltered(self):
675 def unfiltered(self):
676 """Return unfiltered version of the repository
676 """Return unfiltered version of the repository
677
677
678 Intended to be overwritten by filtered repo."""
678 Intended to be overwritten by filtered repo."""
679 return self
679 return self
680
680
681 def filtered(self, name):
681 def filtered(self, name):
682 """Return a filtered version of a repository"""
682 """Return a filtered version of a repository"""
683 # Python <3.4 easily leaks types via __mro__. See
683 # Python <3.4 easily leaks types via __mro__. See
684 # https://bugs.python.org/issue17950. We cache dynamically
684 # https://bugs.python.org/issue17950. We cache dynamically
685 # created types so this method doesn't leak on every
685 # created types so this method doesn't leak on every
686 # invocation.
686 # invocation.
687
687
688 key = self.unfiltered().__class__
688 key = self.unfiltered().__class__
689 if key not in self._filteredrepotypes:
689 if key not in self._filteredrepotypes:
690 # Build a new type with the repoview mixin and the base
690 # Build a new type with the repoview mixin and the base
691 # class of this repo. Give it a name containing the
691 # class of this repo. Give it a name containing the
692 # filter name to aid debugging.
692 # filter name to aid debugging.
693 bases = (repoview.repoview, key)
693 bases = (repoview.repoview, key)
694 cls = type(r'%sfilteredrepo' % name, bases, {})
694 cls = type(r'%sfilteredrepo' % name, bases, {})
695 self._filteredrepotypes[key] = cls
695 self._filteredrepotypes[key] = cls
696
696
697 return self._filteredrepotypes[key](self, name)
697 return self._filteredrepotypes[key](self, name)
698
698
699 @repofilecache('bookmarks', 'bookmarks.current')
699 @repofilecache('bookmarks', 'bookmarks.current')
700 def _bookmarks(self):
700 def _bookmarks(self):
701 return bookmarks.bmstore(self)
701 return bookmarks.bmstore(self)
702
702
703 @property
703 @property
704 def _activebookmark(self):
704 def _activebookmark(self):
705 return self._bookmarks.active
705 return self._bookmarks.active
706
706
707 # _phaserevs and _phasesets depend on changelog. what we need is to
707 # _phaserevs and _phasesets depend on changelog. what we need is to
708 # call _phasecache.invalidate() if '00changelog.i' was changed, but it
708 # call _phasecache.invalidate() if '00changelog.i' was changed, but it
709 # can't be easily expressed in filecache mechanism.
709 # can't be easily expressed in filecache mechanism.
710 @storecache('phaseroots', '00changelog.i')
710 @storecache('phaseroots', '00changelog.i')
711 def _phasecache(self):
711 def _phasecache(self):
712 return phases.phasecache(self, self._phasedefaults)
712 return phases.phasecache(self, self._phasedefaults)
713
713
714 @storecache('obsstore')
714 @storecache('obsstore')
715 def obsstore(self):
715 def obsstore(self):
716 return obsolete.makestore(self.ui, self)
716 return obsolete.makestore(self.ui, self)
717
717
718 @storecache('00changelog.i')
718 @storecache('00changelog.i')
719 def changelog(self):
719 def changelog(self):
720 return changelog.changelog(self.svfs,
720 return changelog.changelog(self.svfs,
721 trypending=txnutil.mayhavepending(self.root))
721 trypending=txnutil.mayhavepending(self.root))
722
722
723 def _constructmanifest(self):
723 def _constructmanifest(self):
724 # This is a temporary function while we migrate from manifest to
724 # This is a temporary function while we migrate from manifest to
725 # manifestlog. It allows bundlerepo and unionrepo to intercept the
725 # manifestlog. It allows bundlerepo and unionrepo to intercept the
726 # manifest creation.
726 # manifest creation.
727 return manifest.manifestrevlog(self.svfs)
727 return manifest.manifestrevlog(self.svfs)
728
728
729 @storecache('00manifest.i')
729 @storecache('00manifest.i')
730 def manifestlog(self):
730 def manifestlog(self):
731 return manifest.manifestlog(self.svfs, self)
731 return manifest.manifestlog(self.svfs, self)
732
732
733 @repofilecache('dirstate')
733 @repofilecache('dirstate')
734 def dirstate(self):
734 def dirstate(self):
735 sparsematchfn = lambda: sparse.matcher(self)
735 sparsematchfn = lambda: sparse.matcher(self)
736
736
737 return dirstate.dirstate(self.vfs, self.ui, self.root,
737 return dirstate.dirstate(self.vfs, self.ui, self.root,
738 self._dirstatevalidate, sparsematchfn)
738 self._dirstatevalidate, sparsematchfn)
739
739
740 def _dirstatevalidate(self, node):
740 def _dirstatevalidate(self, node):
741 try:
741 try:
742 self.changelog.rev(node)
742 self.changelog.rev(node)
743 return node
743 return node
744 except error.LookupError:
744 except error.LookupError:
745 if not self._dirstatevalidatewarned:
745 if not self._dirstatevalidatewarned:
746 self._dirstatevalidatewarned = True
746 self._dirstatevalidatewarned = True
747 self.ui.warn(_("warning: ignoring unknown"
747 self.ui.warn(_("warning: ignoring unknown"
748 " working parent %s!\n") % short(node))
748 " working parent %s!\n") % short(node))
749 return nullid
749 return nullid
750
750
751 def __getitem__(self, changeid):
751 def __getitem__(self, changeid):
752 if changeid is None:
752 if changeid is None:
753 return context.workingctx(self)
753 return context.workingctx(self)
754 if isinstance(changeid, slice):
754 if isinstance(changeid, slice):
755 # wdirrev isn't contiguous so the slice shouldn't include it
755 # wdirrev isn't contiguous so the slice shouldn't include it
756 return [context.changectx(self, i)
756 return [context.changectx(self, i)
757 for i in xrange(*changeid.indices(len(self)))
757 for i in xrange(*changeid.indices(len(self)))
758 if i not in self.changelog.filteredrevs]
758 if i not in self.changelog.filteredrevs]
759 try:
759 try:
760 return context.changectx(self, changeid)
760 return context.changectx(self, changeid)
761 except error.WdirUnsupported:
761 except error.WdirUnsupported:
762 return context.workingctx(self)
762 return context.workingctx(self)
763
763
764 def __contains__(self, changeid):
764 def __contains__(self, changeid):
765 """True if the given changeid exists
765 """True if the given changeid exists
766
766
767 error.LookupError is raised if an ambiguous node specified.
767 error.LookupError is raised if an ambiguous node specified.
768 """
768 """
769 try:
769 try:
770 self[changeid]
770 self[changeid]
771 return True
771 return True
772 except error.RepoLookupError:
772 except error.RepoLookupError:
773 return False
773 return False
774
774
775 def __nonzero__(self):
775 def __nonzero__(self):
776 return True
776 return True
777
777
778 __bool__ = __nonzero__
778 __bool__ = __nonzero__
779
779
780 def __len__(self):
780 def __len__(self):
781 return len(self.changelog)
781 return len(self.changelog)
782
782
783 def __iter__(self):
783 def __iter__(self):
784 return iter(self.changelog)
784 return iter(self.changelog)
785
785
786 def revs(self, expr, *args):
786 def revs(self, expr, *args):
787 '''Find revisions matching a revset.
787 '''Find revisions matching a revset.
788
788
789 The revset is specified as a string ``expr`` that may contain
789 The revset is specified as a string ``expr`` that may contain
790 %-formatting to escape certain types. See ``revsetlang.formatspec``.
790 %-formatting to escape certain types. See ``revsetlang.formatspec``.
791
791
792 Revset aliases from the configuration are not expanded. To expand
792 Revset aliases from the configuration are not expanded. To expand
793 user aliases, consider calling ``scmutil.revrange()`` or
793 user aliases, consider calling ``scmutil.revrange()`` or
794 ``repo.anyrevs([expr], user=True)``.
794 ``repo.anyrevs([expr], user=True)``.
795
795
796 Returns a revset.abstractsmartset, which is a list-like interface
796 Returns a revset.abstractsmartset, which is a list-like interface
797 that contains integer revisions.
797 that contains integer revisions.
798 '''
798 '''
799 expr = revsetlang.formatspec(expr, *args)
799 expr = revsetlang.formatspec(expr, *args)
800 m = revset.match(None, expr)
800 m = revset.match(None, expr)
801 return m(self)
801 return m(self)
802
802
803 def set(self, expr, *args):
803 def set(self, expr, *args):
804 '''Find revisions matching a revset and emit changectx instances.
804 '''Find revisions matching a revset and emit changectx instances.
805
805
806 This is a convenience wrapper around ``revs()`` that iterates the
806 This is a convenience wrapper around ``revs()`` that iterates the
807 result and is a generator of changectx instances.
807 result and is a generator of changectx instances.
808
808
809 Revset aliases from the configuration are not expanded. To expand
809 Revset aliases from the configuration are not expanded. To expand
810 user aliases, consider calling ``scmutil.revrange()``.
810 user aliases, consider calling ``scmutil.revrange()``.
811 '''
811 '''
812 for r in self.revs(expr, *args):
812 for r in self.revs(expr, *args):
813 yield self[r]
813 yield self[r]
814
814
815 def anyrevs(self, specs, user=False, localalias=None):
815 def anyrevs(self, specs, user=False, localalias=None):
816 '''Find revisions matching one of the given revsets.
816 '''Find revisions matching one of the given revsets.
817
817
818 Revset aliases from the configuration are not expanded by default. To
818 Revset aliases from the configuration are not expanded by default. To
819 expand user aliases, specify ``user=True``. To provide some local
819 expand user aliases, specify ``user=True``. To provide some local
820 definitions overriding user aliases, set ``localalias`` to
820 definitions overriding user aliases, set ``localalias`` to
821 ``{name: definitionstring}``.
821 ``{name: definitionstring}``.
822 '''
822 '''
823 if user:
823 if user:
824 m = revset.matchany(self.ui, specs, repo=self,
824 m = revset.matchany(self.ui, specs, repo=self,
825 localalias=localalias)
825 localalias=localalias)
826 else:
826 else:
827 m = revset.matchany(None, specs, localalias=localalias)
827 m = revset.matchany(None, specs, localalias=localalias)
828 return m(self)
828 return m(self)
829
829
830 def url(self):
830 def url(self):
831 return 'file:' + self.root
831 return 'file:' + self.root
832
832
833 def hook(self, name, throw=False, **args):
833 def hook(self, name, throw=False, **args):
834 """Call a hook, passing this repo instance.
834 """Call a hook, passing this repo instance.
835
835
836 This a convenience method to aid invoking hooks. Extensions likely
836 This a convenience method to aid invoking hooks. Extensions likely
837 won't call this unless they have registered a custom hook or are
837 won't call this unless they have registered a custom hook or are
838 replacing code that is expected to call a hook.
838 replacing code that is expected to call a hook.
839 """
839 """
840 return hook.hook(self.ui, self, name, throw, **args)
840 return hook.hook(self.ui, self, name, throw, **args)
841
841
842 @filteredpropertycache
842 @filteredpropertycache
843 def _tagscache(self):
843 def _tagscache(self):
844 '''Returns a tagscache object that contains various tags related
844 '''Returns a tagscache object that contains various tags related
845 caches.'''
845 caches.'''
846
846
847 # This simplifies its cache management by having one decorated
847 # This simplifies its cache management by having one decorated
848 # function (this one) and the rest simply fetch things from it.
848 # function (this one) and the rest simply fetch things from it.
849 class tagscache(object):
849 class tagscache(object):
850 def __init__(self):
850 def __init__(self):
851 # These two define the set of tags for this repository. tags
851 # These two define the set of tags for this repository. tags
852 # maps tag name to node; tagtypes maps tag name to 'global' or
852 # maps tag name to node; tagtypes maps tag name to 'global' or
853 # 'local'. (Global tags are defined by .hgtags across all
853 # 'local'. (Global tags are defined by .hgtags across all
854 # heads, and local tags are defined in .hg/localtags.)
854 # heads, and local tags are defined in .hg/localtags.)
855 # They constitute the in-memory cache of tags.
855 # They constitute the in-memory cache of tags.
856 self.tags = self.tagtypes = None
856 self.tags = self.tagtypes = None
857
857
858 self.nodetagscache = self.tagslist = None
858 self.nodetagscache = self.tagslist = None
859
859
860 cache = tagscache()
860 cache = tagscache()
861 cache.tags, cache.tagtypes = self._findtags()
861 cache.tags, cache.tagtypes = self._findtags()
862
862
863 return cache
863 return cache
864
864
865 def tags(self):
865 def tags(self):
866 '''return a mapping of tag to node'''
866 '''return a mapping of tag to node'''
867 t = {}
867 t = {}
868 if self.changelog.filteredrevs:
868 if self.changelog.filteredrevs:
869 tags, tt = self._findtags()
869 tags, tt = self._findtags()
870 else:
870 else:
871 tags = self._tagscache.tags
871 tags = self._tagscache.tags
872 for k, v in tags.iteritems():
872 for k, v in tags.iteritems():
873 try:
873 try:
874 # ignore tags to unknown nodes
874 # ignore tags to unknown nodes
875 self.changelog.rev(v)
875 self.changelog.rev(v)
876 t[k] = v
876 t[k] = v
877 except (error.LookupError, ValueError):
877 except (error.LookupError, ValueError):
878 pass
878 pass
879 return t
879 return t
880
880
881 def _findtags(self):
881 def _findtags(self):
882 '''Do the hard work of finding tags. Return a pair of dicts
882 '''Do the hard work of finding tags. Return a pair of dicts
883 (tags, tagtypes) where tags maps tag name to node, and tagtypes
883 (tags, tagtypes) where tags maps tag name to node, and tagtypes
884 maps tag name to a string like \'global\' or \'local\'.
884 maps tag name to a string like \'global\' or \'local\'.
885 Subclasses or extensions are free to add their own tags, but
885 Subclasses or extensions are free to add their own tags, but
886 should be aware that the returned dicts will be retained for the
886 should be aware that the returned dicts will be retained for the
887 duration of the localrepo object.'''
887 duration of the localrepo object.'''
888
888
889 # XXX what tagtype should subclasses/extensions use? Currently
889 # XXX what tagtype should subclasses/extensions use? Currently
890 # mq and bookmarks add tags, but do not set the tagtype at all.
890 # mq and bookmarks add tags, but do not set the tagtype at all.
891 # Should each extension invent its own tag type? Should there
891 # Should each extension invent its own tag type? Should there
892 # be one tagtype for all such "virtual" tags? Or is the status
892 # be one tagtype for all such "virtual" tags? Or is the status
893 # quo fine?
893 # quo fine?
894
894
895
895
896 # map tag name to (node, hist)
896 # map tag name to (node, hist)
897 alltags = tagsmod.findglobaltags(self.ui, self)
897 alltags = tagsmod.findglobaltags(self.ui, self)
898 # map tag name to tag type
898 # map tag name to tag type
899 tagtypes = dict((tag, 'global') for tag in alltags)
899 tagtypes = dict((tag, 'global') for tag in alltags)
900
900
901 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
901 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
902
902
903 # Build the return dicts. Have to re-encode tag names because
903 # Build the return dicts. Have to re-encode tag names because
904 # the tags module always uses UTF-8 (in order not to lose info
904 # the tags module always uses UTF-8 (in order not to lose info
905 # writing to the cache), but the rest of Mercurial wants them in
905 # writing to the cache), but the rest of Mercurial wants them in
906 # local encoding.
906 # local encoding.
907 tags = {}
907 tags = {}
908 for (name, (node, hist)) in alltags.iteritems():
908 for (name, (node, hist)) in alltags.iteritems():
909 if node != nullid:
909 if node != nullid:
910 tags[encoding.tolocal(name)] = node
910 tags[encoding.tolocal(name)] = node
911 tags['tip'] = self.changelog.tip()
911 tags['tip'] = self.changelog.tip()
912 tagtypes = dict([(encoding.tolocal(name), value)
912 tagtypes = dict([(encoding.tolocal(name), value)
913 for (name, value) in tagtypes.iteritems()])
913 for (name, value) in tagtypes.iteritems()])
914 return (tags, tagtypes)
914 return (tags, tagtypes)
915
915
916 def tagtype(self, tagname):
916 def tagtype(self, tagname):
917 '''
917 '''
918 return the type of the given tag. result can be:
918 return the type of the given tag. result can be:
919
919
920 'local' : a local tag
920 'local' : a local tag
921 'global' : a global tag
921 'global' : a global tag
922 None : tag does not exist
922 None : tag does not exist
923 '''
923 '''
924
924
925 return self._tagscache.tagtypes.get(tagname)
925 return self._tagscache.tagtypes.get(tagname)
926
926
927 def tagslist(self):
927 def tagslist(self):
928 '''return a list of tags ordered by revision'''
928 '''return a list of tags ordered by revision'''
929 if not self._tagscache.tagslist:
929 if not self._tagscache.tagslist:
930 l = []
930 l = []
931 for t, n in self.tags().iteritems():
931 for t, n in self.tags().iteritems():
932 l.append((self.changelog.rev(n), t, n))
932 l.append((self.changelog.rev(n), t, n))
933 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
933 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
934
934
935 return self._tagscache.tagslist
935 return self._tagscache.tagslist
936
936
937 def nodetags(self, node):
937 def nodetags(self, node):
938 '''return the tags associated with a node'''
938 '''return the tags associated with a node'''
939 if not self._tagscache.nodetagscache:
939 if not self._tagscache.nodetagscache:
940 nodetagscache = {}
940 nodetagscache = {}
941 for t, n in self._tagscache.tags.iteritems():
941 for t, n in self._tagscache.tags.iteritems():
942 nodetagscache.setdefault(n, []).append(t)
942 nodetagscache.setdefault(n, []).append(t)
943 for tags in nodetagscache.itervalues():
943 for tags in nodetagscache.itervalues():
944 tags.sort()
944 tags.sort()
945 self._tagscache.nodetagscache = nodetagscache
945 self._tagscache.nodetagscache = nodetagscache
946 return self._tagscache.nodetagscache.get(node, [])
946 return self._tagscache.nodetagscache.get(node, [])
947
947
948 def nodebookmarks(self, node):
948 def nodebookmarks(self, node):
949 """return the list of bookmarks pointing to the specified node"""
949 """return the list of bookmarks pointing to the specified node"""
950 marks = []
950 marks = []
951 for bookmark, n in self._bookmarks.iteritems():
951 for bookmark, n in self._bookmarks.iteritems():
952 if n == node:
952 if n == node:
953 marks.append(bookmark)
953 marks.append(bookmark)
954 return sorted(marks)
954 return sorted(marks)
955
955
956 def branchmap(self):
956 def branchmap(self):
957 '''returns a dictionary {branch: [branchheads]} with branchheads
957 '''returns a dictionary {branch: [branchheads]} with branchheads
958 ordered by increasing revision number'''
958 ordered by increasing revision number'''
959 branchmap.updatecache(self)
959 branchmap.updatecache(self)
960 return self._branchcaches[self.filtername]
960 return self._branchcaches[self.filtername]
961
961
962 @unfilteredmethod
962 @unfilteredmethod
963 def revbranchcache(self):
963 def revbranchcache(self):
964 if not self._revbranchcache:
964 if not self._revbranchcache:
965 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
965 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
966 return self._revbranchcache
966 return self._revbranchcache
967
967
968 def branchtip(self, branch, ignoremissing=False):
968 def branchtip(self, branch, ignoremissing=False):
969 '''return the tip node for a given branch
969 '''return the tip node for a given branch
970
970
971 If ignoremissing is True, then this method will not raise an error.
971 If ignoremissing is True, then this method will not raise an error.
972 This is helpful for callers that only expect None for a missing branch
972 This is helpful for callers that only expect None for a missing branch
973 (e.g. namespace).
973 (e.g. namespace).
974
974
975 '''
975 '''
976 try:
976 try:
977 return self.branchmap().branchtip(branch)
977 return self.branchmap().branchtip(branch)
978 except KeyError:
978 except KeyError:
979 if not ignoremissing:
979 if not ignoremissing:
980 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
980 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
981 else:
981 else:
982 pass
982 pass
983
983
984 def lookup(self, key):
984 def lookup(self, key):
985 return self[key].node()
985 return self[key].node()
986
986
987 def lookupbranch(self, key, remote=None):
987 def lookupbranch(self, key, remote=None):
988 repo = remote or self
988 repo = remote or self
989 if key in repo.branchmap():
989 if key in repo.branchmap():
990 return key
990 return key
991
991
992 repo = (remote and remote.local()) and remote or self
992 repo = (remote and remote.local()) and remote or self
993 return repo[key].branch()
993 return repo[key].branch()
994
994
995 def known(self, nodes):
995 def known(self, nodes):
996 cl = self.changelog
996 cl = self.changelog
997 nm = cl.nodemap
997 nm = cl.nodemap
998 filtered = cl.filteredrevs
998 filtered = cl.filteredrevs
999 result = []
999 result = []
1000 for n in nodes:
1000 for n in nodes:
1001 r = nm.get(n)
1001 r = nm.get(n)
1002 resp = not (r is None or r in filtered)
1002 resp = not (r is None or r in filtered)
1003 result.append(resp)
1003 result.append(resp)
1004 return result
1004 return result
1005
1005
1006 def local(self):
1006 def local(self):
1007 return self
1007 return self
1008
1008
1009 def publishing(self):
1009 def publishing(self):
1010 # it's safe (and desirable) to trust the publish flag unconditionally
1010 # it's safe (and desirable) to trust the publish flag unconditionally
1011 # so that we don't finalize changes shared between users via ssh or nfs
1011 # so that we don't finalize changes shared between users via ssh or nfs
1012 return self.ui.configbool('phases', 'publish', untrusted=True)
1012 return self.ui.configbool('phases', 'publish', untrusted=True)
1013
1013
1014 def cancopy(self):
1014 def cancopy(self):
1015 # so statichttprepo's override of local() works
1015 # so statichttprepo's override of local() works
1016 if not self.local():
1016 if not self.local():
1017 return False
1017 return False
1018 if not self.publishing():
1018 if not self.publishing():
1019 return True
1019 return True
1020 # if publishing we can't copy if there is filtered content
1020 # if publishing we can't copy if there is filtered content
1021 return not self.filtered('visible').changelog.filteredrevs
1021 return not self.filtered('visible').changelog.filteredrevs
1022
1022
1023 def shared(self):
1023 def shared(self):
1024 '''the type of shared repository (None if not shared)'''
1024 '''the type of shared repository (None if not shared)'''
1025 if self.sharedpath != self.path:
1025 if self.sharedpath != self.path:
1026 return 'store'
1026 return 'store'
1027 return None
1027 return None
1028
1028
1029 def wjoin(self, f, *insidef):
1029 def wjoin(self, f, *insidef):
1030 return self.vfs.reljoin(self.root, f, *insidef)
1030 return self.vfs.reljoin(self.root, f, *insidef)
1031
1031
1032 def file(self, f):
1032 def file(self, f):
1033 if f[0] == '/':
1033 if f[0] == '/':
1034 f = f[1:]
1034 f = f[1:]
1035 return filelog.filelog(self.svfs, f)
1035 return filelog.filelog(self.svfs, f)
1036
1036
1037 def changectx(self, changeid):
1037 def changectx(self, changeid):
1038 return self[changeid]
1038 return self[changeid]
1039
1039
1040 def setparents(self, p1, p2=nullid):
1040 def setparents(self, p1, p2=nullid):
1041 with self.dirstate.parentchange():
1041 with self.dirstate.parentchange():
1042 copies = self.dirstate.setparents(p1, p2)
1042 copies = self.dirstate.setparents(p1, p2)
1043 pctx = self[p1]
1043 pctx = self[p1]
1044 if copies:
1044 if copies:
1045 # Adjust copy records, the dirstate cannot do it, it
1045 # Adjust copy records, the dirstate cannot do it, it
1046 # requires access to parents manifests. Preserve them
1046 # requires access to parents manifests. Preserve them
1047 # only for entries added to first parent.
1047 # only for entries added to first parent.
1048 for f in copies:
1048 for f in copies:
1049 if f not in pctx and copies[f] in pctx:
1049 if f not in pctx and copies[f] in pctx:
1050 self.dirstate.copy(copies[f], f)
1050 self.dirstate.copy(copies[f], f)
1051 if p2 == nullid:
1051 if p2 == nullid:
1052 for f, s in sorted(self.dirstate.copies().items()):
1052 for f, s in sorted(self.dirstate.copies().items()):
1053 if f not in pctx and s not in pctx:
1053 if f not in pctx and s not in pctx:
1054 self.dirstate.copy(None, f)
1054 self.dirstate.copy(None, f)
1055
1055
1056 def filectx(self, path, changeid=None, fileid=None):
1056 def filectx(self, path, changeid=None, fileid=None):
1057 """changeid can be a changeset revision, node, or tag.
1057 """changeid can be a changeset revision, node, or tag.
1058 fileid can be a file revision or node."""
1058 fileid can be a file revision or node."""
1059 return context.filectx(self, path, changeid, fileid)
1059 return context.filectx(self, path, changeid, fileid)
1060
1060
1061 def getcwd(self):
1061 def getcwd(self):
1062 return self.dirstate.getcwd()
1062 return self.dirstate.getcwd()
1063
1063
1064 def pathto(self, f, cwd=None):
1064 def pathto(self, f, cwd=None):
1065 return self.dirstate.pathto(f, cwd)
1065 return self.dirstate.pathto(f, cwd)
1066
1066
1067 def _loadfilter(self, filter):
1067 def _loadfilter(self, filter):
1068 if filter not in self.filterpats:
1068 if filter not in self.filterpats:
1069 l = []
1069 l = []
1070 for pat, cmd in self.ui.configitems(filter):
1070 for pat, cmd in self.ui.configitems(filter):
1071 if cmd == '!':
1071 if cmd == '!':
1072 continue
1072 continue
1073 mf = matchmod.match(self.root, '', [pat])
1073 mf = matchmod.match(self.root, '', [pat])
1074 fn = None
1074 fn = None
1075 params = cmd
1075 params = cmd
1076 for name, filterfn in self._datafilters.iteritems():
1076 for name, filterfn in self._datafilters.iteritems():
1077 if cmd.startswith(name):
1077 if cmd.startswith(name):
1078 fn = filterfn
1078 fn = filterfn
1079 params = cmd[len(name):].lstrip()
1079 params = cmd[len(name):].lstrip()
1080 break
1080 break
1081 if not fn:
1081 if not fn:
1082 fn = lambda s, c, **kwargs: util.filter(s, c)
1082 fn = lambda s, c, **kwargs: util.filter(s, c)
1083 # Wrap old filters not supporting keyword arguments
1083 # Wrap old filters not supporting keyword arguments
1084 if not inspect.getargspec(fn)[2]:
1084 if not inspect.getargspec(fn)[2]:
1085 oldfn = fn
1085 oldfn = fn
1086 fn = lambda s, c, **kwargs: oldfn(s, c)
1086 fn = lambda s, c, **kwargs: oldfn(s, c)
1087 l.append((mf, fn, params))
1087 l.append((mf, fn, params))
1088 self.filterpats[filter] = l
1088 self.filterpats[filter] = l
1089 return self.filterpats[filter]
1089 return self.filterpats[filter]
1090
1090
1091 def _filter(self, filterpats, filename, data):
1091 def _filter(self, filterpats, filename, data):
1092 for mf, fn, cmd in filterpats:
1092 for mf, fn, cmd in filterpats:
1093 if mf(filename):
1093 if mf(filename):
1094 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
1094 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
1095 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
1095 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
1096 break
1096 break
1097
1097
1098 return data
1098 return data
1099
1099
1100 @unfilteredpropertycache
1100 @unfilteredpropertycache
1101 def _encodefilterpats(self):
1101 def _encodefilterpats(self):
1102 return self._loadfilter('encode')
1102 return self._loadfilter('encode')
1103
1103
1104 @unfilteredpropertycache
1104 @unfilteredpropertycache
1105 def _decodefilterpats(self):
1105 def _decodefilterpats(self):
1106 return self._loadfilter('decode')
1106 return self._loadfilter('decode')
1107
1107
1108 def adddatafilter(self, name, filter):
1108 def adddatafilter(self, name, filter):
1109 self._datafilters[name] = filter
1109 self._datafilters[name] = filter
1110
1110
1111 def wread(self, filename):
1111 def wread(self, filename):
1112 if self.wvfs.islink(filename):
1112 if self.wvfs.islink(filename):
1113 data = self.wvfs.readlink(filename)
1113 data = self.wvfs.readlink(filename)
1114 else:
1114 else:
1115 data = self.wvfs.read(filename)
1115 data = self.wvfs.read(filename)
1116 return self._filter(self._encodefilterpats, filename, data)
1116 return self._filter(self._encodefilterpats, filename, data)
1117
1117
1118 def wwrite(self, filename, data, flags, backgroundclose=False):
1118 def wwrite(self, filename, data, flags, backgroundclose=False):
1119 """write ``data`` into ``filename`` in the working directory
1119 """write ``data`` into ``filename`` in the working directory
1120
1120
1121 This returns length of written (maybe decoded) data.
1121 This returns length of written (maybe decoded) data.
1122 """
1122 """
1123 data = self._filter(self._decodefilterpats, filename, data)
1123 data = self._filter(self._decodefilterpats, filename, data)
1124 if 'l' in flags:
1124 if 'l' in flags:
1125 self.wvfs.symlink(data, filename)
1125 self.wvfs.symlink(data, filename)
1126 else:
1126 else:
1127 self.wvfs.write(filename, data, backgroundclose=backgroundclose)
1127 self.wvfs.write(filename, data, backgroundclose=backgroundclose)
1128 if 'x' in flags:
1128 if 'x' in flags:
1129 self.wvfs.setflags(filename, False, True)
1129 self.wvfs.setflags(filename, False, True)
1130 return len(data)
1130 return len(data)
1131
1131
1132 def wwritedata(self, filename, data):
1132 def wwritedata(self, filename, data):
1133 return self._filter(self._decodefilterpats, filename, data)
1133 return self._filter(self._decodefilterpats, filename, data)
1134
1134
1135 def currenttransaction(self):
1135 def currenttransaction(self):
1136 """return the current transaction or None if non exists"""
1136 """return the current transaction or None if non exists"""
1137 if self._transref:
1137 if self._transref:
1138 tr = self._transref()
1138 tr = self._transref()
1139 else:
1139 else:
1140 tr = None
1140 tr = None
1141
1141
1142 if tr and tr.running():
1142 if tr and tr.running():
1143 return tr
1143 return tr
1144 return None
1144 return None
1145
1145
1146 def transaction(self, desc, report=None):
1146 def transaction(self, desc, report=None):
1147 if (self.ui.configbool('devel', 'all-warnings')
1147 if (self.ui.configbool('devel', 'all-warnings')
1148 or self.ui.configbool('devel', 'check-locks')):
1148 or self.ui.configbool('devel', 'check-locks')):
1149 if self._currentlock(self._lockref) is None:
1149 if self._currentlock(self._lockref) is None:
1150 raise error.ProgrammingError('transaction requires locking')
1150 raise error.ProgrammingError('transaction requires locking')
1151 tr = self.currenttransaction()
1151 tr = self.currenttransaction()
1152 if tr is not None:
1152 if tr is not None:
1153 scmutil.registersummarycallback(self, tr, desc)
1153 scmutil.registersummarycallback(self, tr, desc)
1154 return tr.nest()
1154 return tr.nest()
1155
1155
1156 # abort here if the journal already exists
1156 # abort here if the journal already exists
1157 if self.svfs.exists("journal"):
1157 if self.svfs.exists("journal"):
1158 raise error.RepoError(
1158 raise error.RepoError(
1159 _("abandoned transaction found"),
1159 _("abandoned transaction found"),
1160 hint=_("run 'hg recover' to clean up transaction"))
1160 hint=_("run 'hg recover' to clean up transaction"))
1161
1161
1162 idbase = "%.40f#%f" % (random.random(), time.time())
1162 idbase = "%.40f#%f" % (random.random(), time.time())
1163 ha = hex(hashlib.sha1(idbase).digest())
1163 ha = hex(hashlib.sha1(idbase).digest())
1164 txnid = 'TXN:' + ha
1164 txnid = 'TXN:' + ha
1165 self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
1165 self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
1166
1166
1167 self._writejournal(desc)
1167 self._writejournal(desc)
1168 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
1168 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
1169 if report:
1169 if report:
1170 rp = report
1170 rp = report
1171 else:
1171 else:
1172 rp = self.ui.warn
1172 rp = self.ui.warn
1173 vfsmap = {'plain': self.vfs} # root of .hg/
1173 vfsmap = {'plain': self.vfs} # root of .hg/
1174 # we must avoid cyclic reference between repo and transaction.
1174 # we must avoid cyclic reference between repo and transaction.
1175 reporef = weakref.ref(self)
1175 reporef = weakref.ref(self)
1176 # Code to track tag movement
1176 # Code to track tag movement
1177 #
1177 #
1178 # Since tags are all handled as file content, it is actually quite hard
1178 # Since tags are all handled as file content, it is actually quite hard
1179 # to track these movement from a code perspective. So we fallback to a
1179 # to track these movement from a code perspective. So we fallback to a
1180 # tracking at the repository level. One could envision to track changes
1180 # tracking at the repository level. One could envision to track changes
1181 # to the '.hgtags' file through changegroup apply but that fails to
1181 # to the '.hgtags' file through changegroup apply but that fails to
1182 # cope with case where transaction expose new heads without changegroup
1182 # cope with case where transaction expose new heads without changegroup
1183 # being involved (eg: phase movement).
1183 # being involved (eg: phase movement).
1184 #
1184 #
1185 # For now, We gate the feature behind a flag since this likely comes
1185 # For now, We gate the feature behind a flag since this likely comes
1186 # with performance impacts. The current code run more often than needed
1186 # with performance impacts. The current code run more often than needed
1187 # and do not use caches as much as it could. The current focus is on
1187 # and do not use caches as much as it could. The current focus is on
1188 # the behavior of the feature so we disable it by default. The flag
1188 # the behavior of the feature so we disable it by default. The flag
1189 # will be removed when we are happy with the performance impact.
1189 # will be removed when we are happy with the performance impact.
1190 #
1190 #
1191 # Once this feature is no longer experimental move the following
1191 # Once this feature is no longer experimental move the following
1192 # documentation to the appropriate help section:
1192 # documentation to the appropriate help section:
1193 #
1193 #
1194 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
1194 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
1195 # tags (new or changed or deleted tags). In addition the details of
1195 # tags (new or changed or deleted tags). In addition the details of
1196 # these changes are made available in a file at:
1196 # these changes are made available in a file at:
1197 # ``REPOROOT/.hg/changes/tags.changes``.
1197 # ``REPOROOT/.hg/changes/tags.changes``.
1198 # Make sure you check for HG_TAG_MOVED before reading that file as it
1198 # Make sure you check for HG_TAG_MOVED before reading that file as it
1199 # might exist from a previous transaction even if no tag were touched
1199 # might exist from a previous transaction even if no tag were touched
1200 # in this one. Changes are recorded in a line base format::
1200 # in this one. Changes are recorded in a line base format::
1201 #
1201 #
1202 # <action> <hex-node> <tag-name>\n
1202 # <action> <hex-node> <tag-name>\n
1203 #
1203 #
1204 # Actions are defined as follow:
1204 # Actions are defined as follow:
1205 # "-R": tag is removed,
1205 # "-R": tag is removed,
1206 # "+A": tag is added,
1206 # "+A": tag is added,
1207 # "-M": tag is moved (old value),
1207 # "-M": tag is moved (old value),
1208 # "+M": tag is moved (new value),
1208 # "+M": tag is moved (new value),
1209 tracktags = lambda x: None
1209 tracktags = lambda x: None
1210 # experimental config: experimental.hook-track-tags
1210 # experimental config: experimental.hook-track-tags
1211 shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags')
1211 shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags')
1212 if desc != 'strip' and shouldtracktags:
1212 if desc != 'strip' and shouldtracktags:
1213 oldheads = self.changelog.headrevs()
1213 oldheads = self.changelog.headrevs()
1214 def tracktags(tr2):
1214 def tracktags(tr2):
1215 repo = reporef()
1215 repo = reporef()
1216 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
1216 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
1217 newheads = repo.changelog.headrevs()
1217 newheads = repo.changelog.headrevs()
1218 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
1218 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
1219 # notes: we compare lists here.
1219 # notes: we compare lists here.
1220 # As we do it only once buiding set would not be cheaper
1220 # As we do it only once buiding set would not be cheaper
1221 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
1221 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
1222 if changes:
1222 if changes:
1223 tr2.hookargs['tag_moved'] = '1'
1223 tr2.hookargs['tag_moved'] = '1'
1224 with repo.vfs('changes/tags.changes', 'w',
1224 with repo.vfs('changes/tags.changes', 'w',
1225 atomictemp=True) as changesfile:
1225 atomictemp=True) as changesfile:
1226 # note: we do not register the file to the transaction
1226 # note: we do not register the file to the transaction
1227 # because we needs it to still exist on the transaction
1227 # because we needs it to still exist on the transaction
1228 # is close (for txnclose hooks)
1228 # is close (for txnclose hooks)
1229 tagsmod.writediff(changesfile, changes)
1229 tagsmod.writediff(changesfile, changes)
1230 def validate(tr2):
1230 def validate(tr2):
1231 """will run pre-closing hooks"""
1231 """will run pre-closing hooks"""
1232 # XXX the transaction API is a bit lacking here so we take a hacky
1232 # XXX the transaction API is a bit lacking here so we take a hacky
1233 # path for now
1233 # path for now
1234 #
1234 #
1235 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
1235 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
1236 # dict is copied before these run. In addition we needs the data
1236 # dict is copied before these run. In addition we needs the data
1237 # available to in memory hooks too.
1237 # available to in memory hooks too.
1238 #
1238 #
1239 # Moreover, we also need to make sure this runs before txnclose
1239 # Moreover, we also need to make sure this runs before txnclose
1240 # hooks and there is no "pending" mechanism that would execute
1240 # hooks and there is no "pending" mechanism that would execute
1241 # logic only if hooks are about to run.
1241 # logic only if hooks are about to run.
1242 #
1242 #
1243 # Fixing this limitation of the transaction is also needed to track
1243 # Fixing this limitation of the transaction is also needed to track
1244 # other families of changes (bookmarks, phases, obsolescence).
1244 # other families of changes (bookmarks, phases, obsolescence).
1245 #
1245 #
1246 # This will have to be fixed before we remove the experimental
1246 # This will have to be fixed before we remove the experimental
1247 # gating.
1247 # gating.
1248 tracktags(tr2)
1248 tracktags(tr2)
1249 repo = reporef()
1249 repo = reporef()
1250 if repo.ui.configbool('experimental', 'single-head-per-branch'):
1250 if repo.ui.configbool('experimental', 'single-head-per-branch'):
1251 scmutil.enforcesinglehead(repo, tr2, desc)
1251 scmutil.enforcesinglehead(repo, tr2, desc)
1252 if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
1252 if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
1253 for name, (old, new) in sorted(tr.changes['bookmarks'].items()):
1253 for name, (old, new) in sorted(tr.changes['bookmarks'].items()):
1254 args = tr.hookargs.copy()
1254 args = tr.hookargs.copy()
1255 args.update(bookmarks.preparehookargs(name, old, new))
1255 args.update(bookmarks.preparehookargs(name, old, new))
1256 repo.hook('pretxnclose-bookmark', throw=True,
1256 repo.hook('pretxnclose-bookmark', throw=True,
1257 txnname=desc,
1257 txnname=desc,
1258 **pycompat.strkwargs(args))
1258 **pycompat.strkwargs(args))
1259 if hook.hashook(repo.ui, 'pretxnclose-phase'):
1259 if hook.hashook(repo.ui, 'pretxnclose-phase'):
1260 cl = repo.unfiltered().changelog
1260 cl = repo.unfiltered().changelog
1261 for rev, (old, new) in tr.changes['phases'].items():
1261 for rev, (old, new) in tr.changes['phases'].items():
1262 args = tr.hookargs.copy()
1262 args = tr.hookargs.copy()
1263 node = hex(cl.node(rev))
1263 node = hex(cl.node(rev))
1264 args.update(phases.preparehookargs(node, old, new))
1264 args.update(phases.preparehookargs(node, old, new))
1265 repo.hook('pretxnclose-phase', throw=True, txnname=desc,
1265 repo.hook('pretxnclose-phase', throw=True, txnname=desc,
1266 **pycompat.strkwargs(args))
1266 **pycompat.strkwargs(args))
1267
1267
1268 repo.hook('pretxnclose', throw=True,
1268 repo.hook('pretxnclose', throw=True,
1269 txnname=desc, **pycompat.strkwargs(tr.hookargs))
1269 txnname=desc, **pycompat.strkwargs(tr.hookargs))
1270 def releasefn(tr, success):
1270 def releasefn(tr, success):
1271 repo = reporef()
1271 repo = reporef()
1272 if success:
1272 if success:
1273 # this should be explicitly invoked here, because
1273 # this should be explicitly invoked here, because
1274 # in-memory changes aren't written out at closing
1274 # in-memory changes aren't written out at closing
1275 # transaction, if tr.addfilegenerator (via
1275 # transaction, if tr.addfilegenerator (via
1276 # dirstate.write or so) isn't invoked while
1276 # dirstate.write or so) isn't invoked while
1277 # transaction running
1277 # transaction running
1278 repo.dirstate.write(None)
1278 repo.dirstate.write(None)
1279 else:
1279 else:
1280 # discard all changes (including ones already written
1280 # discard all changes (including ones already written
1281 # out) in this transaction
1281 # out) in this transaction
1282 repo.dirstate.restorebackup(None, 'journal.dirstate')
1282 repo.dirstate.restorebackup(None, 'journal.dirstate')
1283
1283
1284 repo.invalidate(clearfilecache=True)
1284 repo.invalidate(clearfilecache=True)
1285
1285
1286 tr = transaction.transaction(rp, self.svfs, vfsmap,
1286 tr = transaction.transaction(rp, self.svfs, vfsmap,
1287 "journal",
1287 "journal",
1288 "undo",
1288 "undo",
1289 aftertrans(renames),
1289 aftertrans(renames),
1290 self.store.createmode,
1290 self.store.createmode,
1291 validator=validate,
1291 validator=validate,
1292 releasefn=releasefn,
1292 releasefn=releasefn,
1293 checkambigfiles=_cachedfiles)
1293 checkambigfiles=_cachedfiles)
1294 tr.changes['revs'] = set()
1294 tr.changes['revs'] = set()
1295 tr.changes['obsmarkers'] = set()
1295 tr.changes['obsmarkers'] = set()
1296 tr.changes['phases'] = {}
1296 tr.changes['phases'] = {}
1297 tr.changes['bookmarks'] = {}
1297 tr.changes['bookmarks'] = {}
1298
1298
1299 tr.hookargs['txnid'] = txnid
1299 tr.hookargs['txnid'] = txnid
1300 # note: writing the fncache only during finalize mean that the file is
1300 # note: writing the fncache only during finalize mean that the file is
1301 # outdated when running hooks. As fncache is used for streaming clone,
1301 # outdated when running hooks. As fncache is used for streaming clone,
1302 # this is not expected to break anything that happen during the hooks.
1302 # this is not expected to break anything that happen during the hooks.
1303 tr.addfinalize('flush-fncache', self.store.write)
1303 tr.addfinalize('flush-fncache', self.store.write)
1304 def txnclosehook(tr2):
1304 def txnclosehook(tr2):
1305 """To be run if transaction is successful, will schedule a hook run
1305 """To be run if transaction is successful, will schedule a hook run
1306 """
1306 """
1307 # Don't reference tr2 in hook() so we don't hold a reference.
1307 # Don't reference tr2 in hook() so we don't hold a reference.
1308 # This reduces memory consumption when there are multiple
1308 # This reduces memory consumption when there are multiple
1309 # transactions per lock. This can likely go away if issue5045
1309 # transactions per lock. This can likely go away if issue5045
1310 # fixes the function accumulation.
1310 # fixes the function accumulation.
1311 hookargs = tr2.hookargs
1311 hookargs = tr2.hookargs
1312
1312
1313 def hookfunc():
1313 def hookfunc():
1314 repo = reporef()
1314 repo = reporef()
1315 if hook.hashook(repo.ui, 'txnclose-bookmark'):
1315 if hook.hashook(repo.ui, 'txnclose-bookmark'):
1316 bmchanges = sorted(tr.changes['bookmarks'].items())
1316 bmchanges = sorted(tr.changes['bookmarks'].items())
1317 for name, (old, new) in bmchanges:
1317 for name, (old, new) in bmchanges:
1318 args = tr.hookargs.copy()
1318 args = tr.hookargs.copy()
1319 args.update(bookmarks.preparehookargs(name, old, new))
1319 args.update(bookmarks.preparehookargs(name, old, new))
1320 repo.hook('txnclose-bookmark', throw=False,
1320 repo.hook('txnclose-bookmark', throw=False,
1321 txnname=desc, **pycompat.strkwargs(args))
1321 txnname=desc, **pycompat.strkwargs(args))
1322
1322
1323 if hook.hashook(repo.ui, 'txnclose-phase'):
1323 if hook.hashook(repo.ui, 'txnclose-phase'):
1324 cl = repo.unfiltered().changelog
1324 cl = repo.unfiltered().changelog
1325 phasemv = sorted(tr.changes['phases'].items())
1325 phasemv = sorted(tr.changes['phases'].items())
1326 for rev, (old, new) in phasemv:
1326 for rev, (old, new) in phasemv:
1327 args = tr.hookargs.copy()
1327 args = tr.hookargs.copy()
1328 node = hex(cl.node(rev))
1328 node = hex(cl.node(rev))
1329 args.update(phases.preparehookargs(node, old, new))
1329 args.update(phases.preparehookargs(node, old, new))
1330 repo.hook('txnclose-phase', throw=False, txnname=desc,
1330 repo.hook('txnclose-phase', throw=False, txnname=desc,
1331 **pycompat.strkwargs(args))
1331 **pycompat.strkwargs(args))
1332
1332
1333 repo.hook('txnclose', throw=False, txnname=desc,
1333 repo.hook('txnclose', throw=False, txnname=desc,
1334 **pycompat.strkwargs(hookargs))
1334 **pycompat.strkwargs(hookargs))
1335 reporef()._afterlock(hookfunc)
1335 reporef()._afterlock(hookfunc)
1336 tr.addfinalize('txnclose-hook', txnclosehook)
1336 tr.addfinalize('txnclose-hook', txnclosehook)
1337 tr.addpostclose('warms-cache', self._buildcacheupdater(tr))
1337 tr.addpostclose('warms-cache', self._buildcacheupdater(tr))
1338 def txnaborthook(tr2):
1338 def txnaborthook(tr2):
1339 """To be run if transaction is aborted
1339 """To be run if transaction is aborted
1340 """
1340 """
1341 reporef().hook('txnabort', throw=False, txnname=desc,
1341 reporef().hook('txnabort', throw=False, txnname=desc,
1342 **tr2.hookargs)
1342 **tr2.hookargs)
1343 tr.addabort('txnabort-hook', txnaborthook)
1343 tr.addabort('txnabort-hook', txnaborthook)
1344 # avoid eager cache invalidation. in-memory data should be identical
1344 # avoid eager cache invalidation. in-memory data should be identical
1345 # to stored data if transaction has no error.
1345 # to stored data if transaction has no error.
1346 tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats)
1346 tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats)
1347 self._transref = weakref.ref(tr)
1347 self._transref = weakref.ref(tr)
1348 scmutil.registersummarycallback(self, tr, desc)
1348 scmutil.registersummarycallback(self, tr, desc)
1349 return tr
1349 return tr
1350
1350
1351 def _journalfiles(self):
1351 def _journalfiles(self):
1352 return ((self.svfs, 'journal'),
1352 return ((self.svfs, 'journal'),
1353 (self.vfs, 'journal.dirstate'),
1353 (self.vfs, 'journal.dirstate'),
1354 (self.vfs, 'journal.branch'),
1354 (self.vfs, 'journal.branch'),
1355 (self.vfs, 'journal.desc'),
1355 (self.vfs, 'journal.desc'),
1356 (self.vfs, 'journal.bookmarks'),
1356 (self.vfs, 'journal.bookmarks'),
1357 (self.svfs, 'journal.phaseroots'))
1357 (self.svfs, 'journal.phaseroots'))
1358
1358
1359 def undofiles(self):
1359 def undofiles(self):
1360 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
1360 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
1361
1361
1362 @unfilteredmethod
1362 @unfilteredmethod
1363 def _writejournal(self, desc):
1363 def _writejournal(self, desc):
1364 self.dirstate.savebackup(None, 'journal.dirstate')
1364 self.dirstate.savebackup(None, 'journal.dirstate')
1365 self.vfs.write("journal.branch",
1365 self.vfs.write("journal.branch",
1366 encoding.fromlocal(self.dirstate.branch()))
1366 encoding.fromlocal(self.dirstate.branch()))
1367 self.vfs.write("journal.desc",
1367 self.vfs.write("journal.desc",
1368 "%d\n%s\n" % (len(self), desc))
1368 "%d\n%s\n" % (len(self), desc))
1369 self.vfs.write("journal.bookmarks",
1369 self.vfs.write("journal.bookmarks",
1370 self.vfs.tryread("bookmarks"))
1370 self.vfs.tryread("bookmarks"))
1371 self.svfs.write("journal.phaseroots",
1371 self.svfs.write("journal.phaseroots",
1372 self.svfs.tryread("phaseroots"))
1372 self.svfs.tryread("phaseroots"))
1373
1373
1374 def recover(self):
1374 def recover(self):
1375 with self.lock():
1375 with self.lock():
1376 if self.svfs.exists("journal"):
1376 if self.svfs.exists("journal"):
1377 self.ui.status(_("rolling back interrupted transaction\n"))
1377 self.ui.status(_("rolling back interrupted transaction\n"))
1378 vfsmap = {'': self.svfs,
1378 vfsmap = {'': self.svfs,
1379 'plain': self.vfs,}
1379 'plain': self.vfs,}
1380 transaction.rollback(self.svfs, vfsmap, "journal",
1380 transaction.rollback(self.svfs, vfsmap, "journal",
1381 self.ui.warn,
1381 self.ui.warn,
1382 checkambigfiles=_cachedfiles)
1382 checkambigfiles=_cachedfiles)
1383 self.invalidate()
1383 self.invalidate()
1384 return True
1384 return True
1385 else:
1385 else:
1386 self.ui.warn(_("no interrupted transaction available\n"))
1386 self.ui.warn(_("no interrupted transaction available\n"))
1387 return False
1387 return False
1388
1388
1389 def rollback(self, dryrun=False, force=False):
1389 def rollback(self, dryrun=False, force=False):
1390 wlock = lock = dsguard = None
1390 wlock = lock = dsguard = None
1391 try:
1391 try:
1392 wlock = self.wlock()
1392 wlock = self.wlock()
1393 lock = self.lock()
1393 lock = self.lock()
1394 if self.svfs.exists("undo"):
1394 if self.svfs.exists("undo"):
1395 dsguard = dirstateguard.dirstateguard(self, 'rollback')
1395 dsguard = dirstateguard.dirstateguard(self, 'rollback')
1396
1396
1397 return self._rollback(dryrun, force, dsguard)
1397 return self._rollback(dryrun, force, dsguard)
1398 else:
1398 else:
1399 self.ui.warn(_("no rollback information available\n"))
1399 self.ui.warn(_("no rollback information available\n"))
1400 return 1
1400 return 1
1401 finally:
1401 finally:
1402 release(dsguard, lock, wlock)
1402 release(dsguard, lock, wlock)
1403
1403
1404 @unfilteredmethod # Until we get smarter cache management
1404 @unfilteredmethod # Until we get smarter cache management
1405 def _rollback(self, dryrun, force, dsguard):
1405 def _rollback(self, dryrun, force, dsguard):
1406 ui = self.ui
1406 ui = self.ui
1407 try:
1407 try:
1408 args = self.vfs.read('undo.desc').splitlines()
1408 args = self.vfs.read('undo.desc').splitlines()
1409 (oldlen, desc, detail) = (int(args[0]), args[1], None)
1409 (oldlen, desc, detail) = (int(args[0]), args[1], None)
1410 if len(args) >= 3:
1410 if len(args) >= 3:
1411 detail = args[2]
1411 detail = args[2]
1412 oldtip = oldlen - 1
1412 oldtip = oldlen - 1
1413
1413
1414 if detail and ui.verbose:
1414 if detail and ui.verbose:
1415 msg = (_('repository tip rolled back to revision %d'
1415 msg = (_('repository tip rolled back to revision %d'
1416 ' (undo %s: %s)\n')
1416 ' (undo %s: %s)\n')
1417 % (oldtip, desc, detail))
1417 % (oldtip, desc, detail))
1418 else:
1418 else:
1419 msg = (_('repository tip rolled back to revision %d'
1419 msg = (_('repository tip rolled back to revision %d'
1420 ' (undo %s)\n')
1420 ' (undo %s)\n')
1421 % (oldtip, desc))
1421 % (oldtip, desc))
1422 except IOError:
1422 except IOError:
1423 msg = _('rolling back unknown transaction\n')
1423 msg = _('rolling back unknown transaction\n')
1424 desc = None
1424 desc = None
1425
1425
1426 if not force and self['.'] != self['tip'] and desc == 'commit':
1426 if not force and self['.'] != self['tip'] and desc == 'commit':
1427 raise error.Abort(
1427 raise error.Abort(
1428 _('rollback of last commit while not checked out '
1428 _('rollback of last commit while not checked out '
1429 'may lose data'), hint=_('use -f to force'))
1429 'may lose data'), hint=_('use -f to force'))
1430
1430
1431 ui.status(msg)
1431 ui.status(msg)
1432 if dryrun:
1432 if dryrun:
1433 return 0
1433 return 0
1434
1434
1435 parents = self.dirstate.parents()
1435 parents = self.dirstate.parents()
1436 self.destroying()
1436 self.destroying()
1437 vfsmap = {'plain': self.vfs, '': self.svfs}
1437 vfsmap = {'plain': self.vfs, '': self.svfs}
1438 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn,
1438 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn,
1439 checkambigfiles=_cachedfiles)
1439 checkambigfiles=_cachedfiles)
1440 if self.vfs.exists('undo.bookmarks'):
1440 if self.vfs.exists('undo.bookmarks'):
1441 self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True)
1441 self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True)
1442 if self.svfs.exists('undo.phaseroots'):
1442 if self.svfs.exists('undo.phaseroots'):
1443 self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True)
1443 self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True)
1444 self.invalidate()
1444 self.invalidate()
1445
1445
1446 parentgone = (parents[0] not in self.changelog.nodemap or
1446 parentgone = (parents[0] not in self.changelog.nodemap or
1447 parents[1] not in self.changelog.nodemap)
1447 parents[1] not in self.changelog.nodemap)
1448 if parentgone:
1448 if parentgone:
1449 # prevent dirstateguard from overwriting already restored one
1449 # prevent dirstateguard from overwriting already restored one
1450 dsguard.close()
1450 dsguard.close()
1451
1451
1452 self.dirstate.restorebackup(None, 'undo.dirstate')
1452 self.dirstate.restorebackup(None, 'undo.dirstate')
1453 try:
1453 try:
1454 branch = self.vfs.read('undo.branch')
1454 branch = self.vfs.read('undo.branch')
1455 self.dirstate.setbranch(encoding.tolocal(branch))
1455 self.dirstate.setbranch(encoding.tolocal(branch))
1456 except IOError:
1456 except IOError:
1457 ui.warn(_('named branch could not be reset: '
1457 ui.warn(_('named branch could not be reset: '
1458 'current branch is still \'%s\'\n')
1458 'current branch is still \'%s\'\n')
1459 % self.dirstate.branch())
1459 % self.dirstate.branch())
1460
1460
1461 parents = tuple([p.rev() for p in self[None].parents()])
1461 parents = tuple([p.rev() for p in self[None].parents()])
1462 if len(parents) > 1:
1462 if len(parents) > 1:
1463 ui.status(_('working directory now based on '
1463 ui.status(_('working directory now based on '
1464 'revisions %d and %d\n') % parents)
1464 'revisions %d and %d\n') % parents)
1465 else:
1465 else:
1466 ui.status(_('working directory now based on '
1466 ui.status(_('working directory now based on '
1467 'revision %d\n') % parents)
1467 'revision %d\n') % parents)
1468 mergemod.mergestate.clean(self, self['.'].node())
1468 mergemod.mergestate.clean(self, self['.'].node())
1469
1469
1470 # TODO: if we know which new heads may result from this rollback, pass
1470 # TODO: if we know which new heads may result from this rollback, pass
1471 # them to destroy(), which will prevent the branchhead cache from being
1471 # them to destroy(), which will prevent the branchhead cache from being
1472 # invalidated.
1472 # invalidated.
1473 self.destroyed()
1473 self.destroyed()
1474 return 0
1474 return 0
1475
1475
1476 def _buildcacheupdater(self, newtransaction):
1476 def _buildcacheupdater(self, newtransaction):
1477 """called during transaction to build the callback updating cache
1477 """called during transaction to build the callback updating cache
1478
1478
1479 Lives on the repository to help extension who might want to augment
1479 Lives on the repository to help extension who might want to augment
1480 this logic. For this purpose, the created transaction is passed to the
1480 this logic. For this purpose, the created transaction is passed to the
1481 method.
1481 method.
1482 """
1482 """
1483 # we must avoid cyclic reference between repo and transaction.
1483 # we must avoid cyclic reference between repo and transaction.
1484 reporef = weakref.ref(self)
1484 reporef = weakref.ref(self)
1485 def updater(tr):
1485 def updater(tr):
1486 repo = reporef()
1486 repo = reporef()
1487 repo.updatecaches(tr)
1487 repo.updatecaches(tr)
1488 return updater
1488 return updater
1489
1489
1490 @unfilteredmethod
1490 @unfilteredmethod
1491 def updatecaches(self, tr=None):
1491 def updatecaches(self, tr=None):
1492 """warm appropriate caches
1492 """warm appropriate caches
1493
1493
1494 If this function is called after a transaction closed. The transaction
1494 If this function is called after a transaction closed. The transaction
1495 will be available in the 'tr' argument. This can be used to selectively
1495 will be available in the 'tr' argument. This can be used to selectively
1496 update caches relevant to the changes in that transaction.
1496 update caches relevant to the changes in that transaction.
1497 """
1497 """
1498 if tr is not None and tr.hookargs.get('source') == 'strip':
1498 if tr is not None and tr.hookargs.get('source') == 'strip':
1499 # During strip, many caches are invalid but
1499 # During strip, many caches are invalid but
1500 # later call to `destroyed` will refresh them.
1500 # later call to `destroyed` will refresh them.
1501 return
1501 return
1502
1502
1503 if tr is None or tr.changes['revs']:
1503 if tr is None or tr.changes['revs']:
1504 # updating the unfiltered branchmap should refresh all the others,
1504 # updating the unfiltered branchmap should refresh all the others,
1505 self.ui.debug('updating the branch cache\n')
1505 self.ui.debug('updating the branch cache\n')
1506 branchmap.updatecache(self.filtered('served'))
1506 branchmap.updatecache(self.filtered('served'))
1507
1507
1508 def invalidatecaches(self):
1508 def invalidatecaches(self):
1509
1509
1510 if '_tagscache' in vars(self):
1510 if '_tagscache' in vars(self):
1511 # can't use delattr on proxy
1511 # can't use delattr on proxy
1512 del self.__dict__['_tagscache']
1512 del self.__dict__['_tagscache']
1513
1513
1514 self.unfiltered()._branchcaches.clear()
1514 self.unfiltered()._branchcaches.clear()
1515 self.invalidatevolatilesets()
1515 self.invalidatevolatilesets()
1516 self._sparsesignaturecache.clear()
1516 self._sparsesignaturecache.clear()
1517
1517
1518 def invalidatevolatilesets(self):
1518 def invalidatevolatilesets(self):
1519 self.filteredrevcache.clear()
1519 self.filteredrevcache.clear()
1520 obsolete.clearobscaches(self)
1520 obsolete.clearobscaches(self)
1521
1521
1522 def invalidatedirstate(self):
1522 def invalidatedirstate(self):
1523 '''Invalidates the dirstate, causing the next call to dirstate
1523 '''Invalidates the dirstate, causing the next call to dirstate
1524 to check if it was modified since the last time it was read,
1524 to check if it was modified since the last time it was read,
1525 rereading it if it has.
1525 rereading it if it has.
1526
1526
1527 This is different to dirstate.invalidate() that it doesn't always
1527 This is different to dirstate.invalidate() that it doesn't always
1528 rereads the dirstate. Use dirstate.invalidate() if you want to
1528 rereads the dirstate. Use dirstate.invalidate() if you want to
1529 explicitly read the dirstate again (i.e. restoring it to a previous
1529 explicitly read the dirstate again (i.e. restoring it to a previous
1530 known good state).'''
1530 known good state).'''
1531 if hasunfilteredcache(self, 'dirstate'):
1531 if hasunfilteredcache(self, 'dirstate'):
1532 for k in self.dirstate._filecache:
1532 for k in self.dirstate._filecache:
1533 try:
1533 try:
1534 delattr(self.dirstate, k)
1534 delattr(self.dirstate, k)
1535 except AttributeError:
1535 except AttributeError:
1536 pass
1536 pass
1537 delattr(self.unfiltered(), 'dirstate')
1537 delattr(self.unfiltered(), 'dirstate')
1538
1538
1539 def invalidate(self, clearfilecache=False):
1539 def invalidate(self, clearfilecache=False):
1540 '''Invalidates both store and non-store parts other than dirstate
1540 '''Invalidates both store and non-store parts other than dirstate
1541
1541
1542 If a transaction is running, invalidation of store is omitted,
1542 If a transaction is running, invalidation of store is omitted,
1543 because discarding in-memory changes might cause inconsistency
1543 because discarding in-memory changes might cause inconsistency
1544 (e.g. incomplete fncache causes unintentional failure, but
1544 (e.g. incomplete fncache causes unintentional failure, but
1545 redundant one doesn't).
1545 redundant one doesn't).
1546 '''
1546 '''
1547 unfiltered = self.unfiltered() # all file caches are stored unfiltered
1547 unfiltered = self.unfiltered() # all file caches are stored unfiltered
1548 for k in list(self._filecache.keys()):
1548 for k in list(self._filecache.keys()):
1549 # dirstate is invalidated separately in invalidatedirstate()
1549 # dirstate is invalidated separately in invalidatedirstate()
1550 if k == 'dirstate':
1550 if k == 'dirstate':
1551 continue
1551 continue
1552 if (k == 'changelog' and
1552 if (k == 'changelog' and
1553 self.currenttransaction() and
1553 self.currenttransaction() and
1554 self.changelog._delayed):
1554 self.changelog._delayed):
1555 # The changelog object may store unwritten revisions. We don't
1555 # The changelog object may store unwritten revisions. We don't
1556 # want to lose them.
1556 # want to lose them.
1557 # TODO: Solve the problem instead of working around it.
1557 # TODO: Solve the problem instead of working around it.
1558 continue
1558 continue
1559
1559
1560 if clearfilecache:
1560 if clearfilecache:
1561 del self._filecache[k]
1561 del self._filecache[k]
1562 try:
1562 try:
1563 delattr(unfiltered, k)
1563 delattr(unfiltered, k)
1564 except AttributeError:
1564 except AttributeError:
1565 pass
1565 pass
1566 self.invalidatecaches()
1566 self.invalidatecaches()
1567 if not self.currenttransaction():
1567 if not self.currenttransaction():
1568 # TODO: Changing contents of store outside transaction
1568 # TODO: Changing contents of store outside transaction
1569 # causes inconsistency. We should make in-memory store
1569 # causes inconsistency. We should make in-memory store
1570 # changes detectable, and abort if changed.
1570 # changes detectable, and abort if changed.
1571 self.store.invalidatecaches()
1571 self.store.invalidatecaches()
1572
1572
1573 def invalidateall(self):
1573 def invalidateall(self):
1574 '''Fully invalidates both store and non-store parts, causing the
1574 '''Fully invalidates both store and non-store parts, causing the
1575 subsequent operation to reread any outside changes.'''
1575 subsequent operation to reread any outside changes.'''
1576 # extension should hook this to invalidate its caches
1576 # extension should hook this to invalidate its caches
1577 self.invalidate()
1577 self.invalidate()
1578 self.invalidatedirstate()
1578 self.invalidatedirstate()
1579
1579
1580 @unfilteredmethod
1580 @unfilteredmethod
1581 def _refreshfilecachestats(self, tr):
1581 def _refreshfilecachestats(self, tr):
1582 """Reload stats of cached files so that they are flagged as valid"""
1582 """Reload stats of cached files so that they are flagged as valid"""
1583 for k, ce in self._filecache.items():
1583 for k, ce in self._filecache.items():
1584 if k == 'dirstate' or k not in self.__dict__:
1584 if k == 'dirstate' or k not in self.__dict__:
1585 continue
1585 continue
1586 ce.refresh()
1586 ce.refresh()
1587
1587
1588 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc,
1588 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc,
1589 inheritchecker=None, parentenvvar=None):
1589 inheritchecker=None, parentenvvar=None):
1590 parentlock = None
1590 parentlock = None
1591 # the contents of parentenvvar are used by the underlying lock to
1591 # the contents of parentenvvar are used by the underlying lock to
1592 # determine whether it can be inherited
1592 # determine whether it can be inherited
1593 if parentenvvar is not None:
1593 if parentenvvar is not None:
1594 parentlock = encoding.environ.get(parentenvvar)
1594 parentlock = encoding.environ.get(parentenvvar)
1595
1595
1596 timeout = 0
1596 timeout = 0
1597 warntimeout = 0
1597 if wait:
1598 if wait:
1598 timeout = self.ui.configint("ui", "timeout")
1599 timeout = self.ui.configint("ui", "timeout")
1600 warntimeout = self.ui.configint("ui", "timeout.warn")
1599
1601
1600 l = lockmod.trylock(self.ui, vfs, lockname, timeout,
1602 l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout,
1601 releasefn=releasefn,
1603 releasefn=releasefn,
1602 acquirefn=acquirefn, desc=desc,
1604 acquirefn=acquirefn, desc=desc,
1603 inheritchecker=inheritchecker,
1605 inheritchecker=inheritchecker,
1604 parentlock=parentlock)
1606 parentlock=parentlock)
1605 return l
1607 return l
1606
1608
1607 def _afterlock(self, callback):
1609 def _afterlock(self, callback):
1608 """add a callback to be run when the repository is fully unlocked
1610 """add a callback to be run when the repository is fully unlocked
1609
1611
1610 The callback will be executed when the outermost lock is released
1612 The callback will be executed when the outermost lock is released
1611 (with wlock being higher level than 'lock')."""
1613 (with wlock being higher level than 'lock')."""
1612 for ref in (self._wlockref, self._lockref):
1614 for ref in (self._wlockref, self._lockref):
1613 l = ref and ref()
1615 l = ref and ref()
1614 if l and l.held:
1616 if l and l.held:
1615 l.postrelease.append(callback)
1617 l.postrelease.append(callback)
1616 break
1618 break
1617 else: # no lock have been found.
1619 else: # no lock have been found.
1618 callback()
1620 callback()
1619
1621
1620 def lock(self, wait=True):
1622 def lock(self, wait=True):
1621 '''Lock the repository store (.hg/store) and return a weak reference
1623 '''Lock the repository store (.hg/store) and return a weak reference
1622 to the lock. Use this before modifying the store (e.g. committing or
1624 to the lock. Use this before modifying the store (e.g. committing or
1623 stripping). If you are opening a transaction, get a lock as well.)
1625 stripping). If you are opening a transaction, get a lock as well.)
1624
1626
1625 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1627 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1626 'wlock' first to avoid a dead-lock hazard.'''
1628 'wlock' first to avoid a dead-lock hazard.'''
1627 l = self._currentlock(self._lockref)
1629 l = self._currentlock(self._lockref)
1628 if l is not None:
1630 if l is not None:
1629 l.lock()
1631 l.lock()
1630 return l
1632 return l
1631
1633
1632 l = self._lock(self.svfs, "lock", wait, None,
1634 l = self._lock(self.svfs, "lock", wait, None,
1633 self.invalidate, _('repository %s') % self.origroot)
1635 self.invalidate, _('repository %s') % self.origroot)
1634 self._lockref = weakref.ref(l)
1636 self._lockref = weakref.ref(l)
1635 return l
1637 return l
1636
1638
1637 def _wlockchecktransaction(self):
1639 def _wlockchecktransaction(self):
1638 if self.currenttransaction() is not None:
1640 if self.currenttransaction() is not None:
1639 raise error.LockInheritanceContractViolation(
1641 raise error.LockInheritanceContractViolation(
1640 'wlock cannot be inherited in the middle of a transaction')
1642 'wlock cannot be inherited in the middle of a transaction')
1641
1643
1642 def wlock(self, wait=True):
1644 def wlock(self, wait=True):
1643 '''Lock the non-store parts of the repository (everything under
1645 '''Lock the non-store parts of the repository (everything under
1644 .hg except .hg/store) and return a weak reference to the lock.
1646 .hg except .hg/store) and return a weak reference to the lock.
1645
1647
1646 Use this before modifying files in .hg.
1648 Use this before modifying files in .hg.
1647
1649
1648 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1650 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1649 'wlock' first to avoid a dead-lock hazard.'''
1651 'wlock' first to avoid a dead-lock hazard.'''
1650 l = self._wlockref and self._wlockref()
1652 l = self._wlockref and self._wlockref()
1651 if l is not None and l.held:
1653 if l is not None and l.held:
1652 l.lock()
1654 l.lock()
1653 return l
1655 return l
1654
1656
1655 # We do not need to check for non-waiting lock acquisition. Such
1657 # We do not need to check for non-waiting lock acquisition. Such
1656 # acquisition would not cause dead-lock as they would just fail.
1658 # acquisition would not cause dead-lock as they would just fail.
1657 if wait and (self.ui.configbool('devel', 'all-warnings')
1659 if wait and (self.ui.configbool('devel', 'all-warnings')
1658 or self.ui.configbool('devel', 'check-locks')):
1660 or self.ui.configbool('devel', 'check-locks')):
1659 if self._currentlock(self._lockref) is not None:
1661 if self._currentlock(self._lockref) is not None:
1660 self.ui.develwarn('"wlock" acquired after "lock"')
1662 self.ui.develwarn('"wlock" acquired after "lock"')
1661
1663
1662 def unlock():
1664 def unlock():
1663 if self.dirstate.pendingparentchange():
1665 if self.dirstate.pendingparentchange():
1664 self.dirstate.invalidate()
1666 self.dirstate.invalidate()
1665 else:
1667 else:
1666 self.dirstate.write(None)
1668 self.dirstate.write(None)
1667
1669
1668 self._filecache['dirstate'].refresh()
1670 self._filecache['dirstate'].refresh()
1669
1671
1670 l = self._lock(self.vfs, "wlock", wait, unlock,
1672 l = self._lock(self.vfs, "wlock", wait, unlock,
1671 self.invalidatedirstate, _('working directory of %s') %
1673 self.invalidatedirstate, _('working directory of %s') %
1672 self.origroot,
1674 self.origroot,
1673 inheritchecker=self._wlockchecktransaction,
1675 inheritchecker=self._wlockchecktransaction,
1674 parentenvvar='HG_WLOCK_LOCKER')
1676 parentenvvar='HG_WLOCK_LOCKER')
1675 self._wlockref = weakref.ref(l)
1677 self._wlockref = weakref.ref(l)
1676 return l
1678 return l
1677
1679
1678 def _currentlock(self, lockref):
1680 def _currentlock(self, lockref):
1679 """Returns the lock if it's held, or None if it's not."""
1681 """Returns the lock if it's held, or None if it's not."""
1680 if lockref is None:
1682 if lockref is None:
1681 return None
1683 return None
1682 l = lockref()
1684 l = lockref()
1683 if l is None or not l.held:
1685 if l is None or not l.held:
1684 return None
1686 return None
1685 return l
1687 return l
1686
1688
1687 def currentwlock(self):
1689 def currentwlock(self):
1688 """Returns the wlock if it's held, or None if it's not."""
1690 """Returns the wlock if it's held, or None if it's not."""
1689 return self._currentlock(self._wlockref)
1691 return self._currentlock(self._wlockref)
1690
1692
1691 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
1693 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
1692 """
1694 """
1693 commit an individual file as part of a larger transaction
1695 commit an individual file as part of a larger transaction
1694 """
1696 """
1695
1697
1696 fname = fctx.path()
1698 fname = fctx.path()
1697 fparent1 = manifest1.get(fname, nullid)
1699 fparent1 = manifest1.get(fname, nullid)
1698 fparent2 = manifest2.get(fname, nullid)
1700 fparent2 = manifest2.get(fname, nullid)
1699 if isinstance(fctx, context.filectx):
1701 if isinstance(fctx, context.filectx):
1700 node = fctx.filenode()
1702 node = fctx.filenode()
1701 if node in [fparent1, fparent2]:
1703 if node in [fparent1, fparent2]:
1702 self.ui.debug('reusing %s filelog entry\n' % fname)
1704 self.ui.debug('reusing %s filelog entry\n' % fname)
1703 if manifest1.flags(fname) != fctx.flags():
1705 if manifest1.flags(fname) != fctx.flags():
1704 changelist.append(fname)
1706 changelist.append(fname)
1705 return node
1707 return node
1706
1708
1707 flog = self.file(fname)
1709 flog = self.file(fname)
1708 meta = {}
1710 meta = {}
1709 copy = fctx.renamed()
1711 copy = fctx.renamed()
1710 if copy and copy[0] != fname:
1712 if copy and copy[0] != fname:
1711 # Mark the new revision of this file as a copy of another
1713 # Mark the new revision of this file as a copy of another
1712 # file. This copy data will effectively act as a parent
1714 # file. This copy data will effectively act as a parent
1713 # of this new revision. If this is a merge, the first
1715 # of this new revision. If this is a merge, the first
1714 # parent will be the nullid (meaning "look up the copy data")
1716 # parent will be the nullid (meaning "look up the copy data")
1715 # and the second one will be the other parent. For example:
1717 # and the second one will be the other parent. For example:
1716 #
1718 #
1717 # 0 --- 1 --- 3 rev1 changes file foo
1719 # 0 --- 1 --- 3 rev1 changes file foo
1718 # \ / rev2 renames foo to bar and changes it
1720 # \ / rev2 renames foo to bar and changes it
1719 # \- 2 -/ rev3 should have bar with all changes and
1721 # \- 2 -/ rev3 should have bar with all changes and
1720 # should record that bar descends from
1722 # should record that bar descends from
1721 # bar in rev2 and foo in rev1
1723 # bar in rev2 and foo in rev1
1722 #
1724 #
1723 # this allows this merge to succeed:
1725 # this allows this merge to succeed:
1724 #
1726 #
1725 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
1727 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
1726 # \ / merging rev3 and rev4 should use bar@rev2
1728 # \ / merging rev3 and rev4 should use bar@rev2
1727 # \- 2 --- 4 as the merge base
1729 # \- 2 --- 4 as the merge base
1728 #
1730 #
1729
1731
1730 cfname = copy[0]
1732 cfname = copy[0]
1731 crev = manifest1.get(cfname)
1733 crev = manifest1.get(cfname)
1732 newfparent = fparent2
1734 newfparent = fparent2
1733
1735
1734 if manifest2: # branch merge
1736 if manifest2: # branch merge
1735 if fparent2 == nullid or crev is None: # copied on remote side
1737 if fparent2 == nullid or crev is None: # copied on remote side
1736 if cfname in manifest2:
1738 if cfname in manifest2:
1737 crev = manifest2[cfname]
1739 crev = manifest2[cfname]
1738 newfparent = fparent1
1740 newfparent = fparent1
1739
1741
1740 # Here, we used to search backwards through history to try to find
1742 # Here, we used to search backwards through history to try to find
1741 # where the file copy came from if the source of a copy was not in
1743 # where the file copy came from if the source of a copy was not in
1742 # the parent directory. However, this doesn't actually make sense to
1744 # the parent directory. However, this doesn't actually make sense to
1743 # do (what does a copy from something not in your working copy even
1745 # do (what does a copy from something not in your working copy even
1744 # mean?) and it causes bugs (eg, issue4476). Instead, we will warn
1746 # mean?) and it causes bugs (eg, issue4476). Instead, we will warn
1745 # the user that copy information was dropped, so if they didn't
1747 # the user that copy information was dropped, so if they didn't
1746 # expect this outcome it can be fixed, but this is the correct
1748 # expect this outcome it can be fixed, but this is the correct
1747 # behavior in this circumstance.
1749 # behavior in this circumstance.
1748
1750
1749 if crev:
1751 if crev:
1750 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1752 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1751 meta["copy"] = cfname
1753 meta["copy"] = cfname
1752 meta["copyrev"] = hex(crev)
1754 meta["copyrev"] = hex(crev)
1753 fparent1, fparent2 = nullid, newfparent
1755 fparent1, fparent2 = nullid, newfparent
1754 else:
1756 else:
1755 self.ui.warn(_("warning: can't find ancestor for '%s' "
1757 self.ui.warn(_("warning: can't find ancestor for '%s' "
1756 "copied from '%s'!\n") % (fname, cfname))
1758 "copied from '%s'!\n") % (fname, cfname))
1757
1759
1758 elif fparent1 == nullid:
1760 elif fparent1 == nullid:
1759 fparent1, fparent2 = fparent2, nullid
1761 fparent1, fparent2 = fparent2, nullid
1760 elif fparent2 != nullid:
1762 elif fparent2 != nullid:
1761 # is one parent an ancestor of the other?
1763 # is one parent an ancestor of the other?
1762 fparentancestors = flog.commonancestorsheads(fparent1, fparent2)
1764 fparentancestors = flog.commonancestorsheads(fparent1, fparent2)
1763 if fparent1 in fparentancestors:
1765 if fparent1 in fparentancestors:
1764 fparent1, fparent2 = fparent2, nullid
1766 fparent1, fparent2 = fparent2, nullid
1765 elif fparent2 in fparentancestors:
1767 elif fparent2 in fparentancestors:
1766 fparent2 = nullid
1768 fparent2 = nullid
1767
1769
1768 # is the file changed?
1770 # is the file changed?
1769 text = fctx.data()
1771 text = fctx.data()
1770 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
1772 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
1771 changelist.append(fname)
1773 changelist.append(fname)
1772 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
1774 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
1773 # are just the flags changed during merge?
1775 # are just the flags changed during merge?
1774 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags():
1776 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags():
1775 changelist.append(fname)
1777 changelist.append(fname)
1776
1778
1777 return fparent1
1779 return fparent1
1778
1780
1779 def checkcommitpatterns(self, wctx, vdirs, match, status, fail):
1781 def checkcommitpatterns(self, wctx, vdirs, match, status, fail):
1780 """check for commit arguments that aren't committable"""
1782 """check for commit arguments that aren't committable"""
1781 if match.isexact() or match.prefix():
1783 if match.isexact() or match.prefix():
1782 matched = set(status.modified + status.added + status.removed)
1784 matched = set(status.modified + status.added + status.removed)
1783
1785
1784 for f in match.files():
1786 for f in match.files():
1785 f = self.dirstate.normalize(f)
1787 f = self.dirstate.normalize(f)
1786 if f == '.' or f in matched or f in wctx.substate:
1788 if f == '.' or f in matched or f in wctx.substate:
1787 continue
1789 continue
1788 if f in status.deleted:
1790 if f in status.deleted:
1789 fail(f, _('file not found!'))
1791 fail(f, _('file not found!'))
1790 if f in vdirs: # visited directory
1792 if f in vdirs: # visited directory
1791 d = f + '/'
1793 d = f + '/'
1792 for mf in matched:
1794 for mf in matched:
1793 if mf.startswith(d):
1795 if mf.startswith(d):
1794 break
1796 break
1795 else:
1797 else:
1796 fail(f, _("no match under directory!"))
1798 fail(f, _("no match under directory!"))
1797 elif f not in self.dirstate:
1799 elif f not in self.dirstate:
1798 fail(f, _("file not tracked!"))
1800 fail(f, _("file not tracked!"))
1799
1801
1800 @unfilteredmethod
1802 @unfilteredmethod
1801 def commit(self, text="", user=None, date=None, match=None, force=False,
1803 def commit(self, text="", user=None, date=None, match=None, force=False,
1802 editor=False, extra=None):
1804 editor=False, extra=None):
1803 """Add a new revision to current repository.
1805 """Add a new revision to current repository.
1804
1806
1805 Revision information is gathered from the working directory,
1807 Revision information is gathered from the working directory,
1806 match can be used to filter the committed files. If editor is
1808 match can be used to filter the committed files. If editor is
1807 supplied, it is called to get a commit message.
1809 supplied, it is called to get a commit message.
1808 """
1810 """
1809 if extra is None:
1811 if extra is None:
1810 extra = {}
1812 extra = {}
1811
1813
1812 def fail(f, msg):
1814 def fail(f, msg):
1813 raise error.Abort('%s: %s' % (f, msg))
1815 raise error.Abort('%s: %s' % (f, msg))
1814
1816
1815 if not match:
1817 if not match:
1816 match = matchmod.always(self.root, '')
1818 match = matchmod.always(self.root, '')
1817
1819
1818 if not force:
1820 if not force:
1819 vdirs = []
1821 vdirs = []
1820 match.explicitdir = vdirs.append
1822 match.explicitdir = vdirs.append
1821 match.bad = fail
1823 match.bad = fail
1822
1824
1823 wlock = lock = tr = None
1825 wlock = lock = tr = None
1824 try:
1826 try:
1825 wlock = self.wlock()
1827 wlock = self.wlock()
1826 lock = self.lock() # for recent changelog (see issue4368)
1828 lock = self.lock() # for recent changelog (see issue4368)
1827
1829
1828 wctx = self[None]
1830 wctx = self[None]
1829 merge = len(wctx.parents()) > 1
1831 merge = len(wctx.parents()) > 1
1830
1832
1831 if not force and merge and not match.always():
1833 if not force and merge and not match.always():
1832 raise error.Abort(_('cannot partially commit a merge '
1834 raise error.Abort(_('cannot partially commit a merge '
1833 '(do not specify files or patterns)'))
1835 '(do not specify files or patterns)'))
1834
1836
1835 status = self.status(match=match, clean=force)
1837 status = self.status(match=match, clean=force)
1836 if force:
1838 if force:
1837 status.modified.extend(status.clean) # mq may commit clean files
1839 status.modified.extend(status.clean) # mq may commit clean files
1838
1840
1839 # check subrepos
1841 # check subrepos
1840 subs, commitsubs, newstate = subrepo.precommit(
1842 subs, commitsubs, newstate = subrepo.precommit(
1841 self.ui, wctx, status, match, force=force)
1843 self.ui, wctx, status, match, force=force)
1842
1844
1843 # make sure all explicit patterns are matched
1845 # make sure all explicit patterns are matched
1844 if not force:
1846 if not force:
1845 self.checkcommitpatterns(wctx, vdirs, match, status, fail)
1847 self.checkcommitpatterns(wctx, vdirs, match, status, fail)
1846
1848
1847 cctx = context.workingcommitctx(self, status,
1849 cctx = context.workingcommitctx(self, status,
1848 text, user, date, extra)
1850 text, user, date, extra)
1849
1851
1850 # internal config: ui.allowemptycommit
1852 # internal config: ui.allowemptycommit
1851 allowemptycommit = (wctx.branch() != wctx.p1().branch()
1853 allowemptycommit = (wctx.branch() != wctx.p1().branch()
1852 or extra.get('close') or merge or cctx.files()
1854 or extra.get('close') or merge or cctx.files()
1853 or self.ui.configbool('ui', 'allowemptycommit'))
1855 or self.ui.configbool('ui', 'allowemptycommit'))
1854 if not allowemptycommit:
1856 if not allowemptycommit:
1855 return None
1857 return None
1856
1858
1857 if merge and cctx.deleted():
1859 if merge and cctx.deleted():
1858 raise error.Abort(_("cannot commit merge with missing files"))
1860 raise error.Abort(_("cannot commit merge with missing files"))
1859
1861
1860 ms = mergemod.mergestate.read(self)
1862 ms = mergemod.mergestate.read(self)
1861 mergeutil.checkunresolved(ms)
1863 mergeutil.checkunresolved(ms)
1862
1864
1863 if editor:
1865 if editor:
1864 cctx._text = editor(self, cctx, subs)
1866 cctx._text = editor(self, cctx, subs)
1865 edited = (text != cctx._text)
1867 edited = (text != cctx._text)
1866
1868
1867 # Save commit message in case this transaction gets rolled back
1869 # Save commit message in case this transaction gets rolled back
1868 # (e.g. by a pretxncommit hook). Leave the content alone on
1870 # (e.g. by a pretxncommit hook). Leave the content alone on
1869 # the assumption that the user will use the same editor again.
1871 # the assumption that the user will use the same editor again.
1870 msgfn = self.savecommitmessage(cctx._text)
1872 msgfn = self.savecommitmessage(cctx._text)
1871
1873
1872 # commit subs and write new state
1874 # commit subs and write new state
1873 if subs:
1875 if subs:
1874 for s in sorted(commitsubs):
1876 for s in sorted(commitsubs):
1875 sub = wctx.sub(s)
1877 sub = wctx.sub(s)
1876 self.ui.status(_('committing subrepository %s\n') %
1878 self.ui.status(_('committing subrepository %s\n') %
1877 subrepo.subrelpath(sub))
1879 subrepo.subrelpath(sub))
1878 sr = sub.commit(cctx._text, user, date)
1880 sr = sub.commit(cctx._text, user, date)
1879 newstate[s] = (newstate[s][0], sr)
1881 newstate[s] = (newstate[s][0], sr)
1880 subrepo.writestate(self, newstate)
1882 subrepo.writestate(self, newstate)
1881
1883
1882 p1, p2 = self.dirstate.parents()
1884 p1, p2 = self.dirstate.parents()
1883 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1885 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1884 try:
1886 try:
1885 self.hook("precommit", throw=True, parent1=hookp1,
1887 self.hook("precommit", throw=True, parent1=hookp1,
1886 parent2=hookp2)
1888 parent2=hookp2)
1887 tr = self.transaction('commit')
1889 tr = self.transaction('commit')
1888 ret = self.commitctx(cctx, True)
1890 ret = self.commitctx(cctx, True)
1889 except: # re-raises
1891 except: # re-raises
1890 if edited:
1892 if edited:
1891 self.ui.write(
1893 self.ui.write(
1892 _('note: commit message saved in %s\n') % msgfn)
1894 _('note: commit message saved in %s\n') % msgfn)
1893 raise
1895 raise
1894 # update bookmarks, dirstate and mergestate
1896 # update bookmarks, dirstate and mergestate
1895 bookmarks.update(self, [p1, p2], ret)
1897 bookmarks.update(self, [p1, p2], ret)
1896 cctx.markcommitted(ret)
1898 cctx.markcommitted(ret)
1897 ms.reset()
1899 ms.reset()
1898 tr.close()
1900 tr.close()
1899
1901
1900 finally:
1902 finally:
1901 lockmod.release(tr, lock, wlock)
1903 lockmod.release(tr, lock, wlock)
1902
1904
1903 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
1905 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
1904 # hack for command that use a temporary commit (eg: histedit)
1906 # hack for command that use a temporary commit (eg: histedit)
1905 # temporary commit got stripped before hook release
1907 # temporary commit got stripped before hook release
1906 if self.changelog.hasnode(ret):
1908 if self.changelog.hasnode(ret):
1907 self.hook("commit", node=node, parent1=parent1,
1909 self.hook("commit", node=node, parent1=parent1,
1908 parent2=parent2)
1910 parent2=parent2)
1909 self._afterlock(commithook)
1911 self._afterlock(commithook)
1910 return ret
1912 return ret
1911
1913
1912 @unfilteredmethod
1914 @unfilteredmethod
1913 def commitctx(self, ctx, error=False):
1915 def commitctx(self, ctx, error=False):
1914 """Add a new revision to current repository.
1916 """Add a new revision to current repository.
1915 Revision information is passed via the context argument.
1917 Revision information is passed via the context argument.
1916 """
1918 """
1917
1919
1918 tr = None
1920 tr = None
1919 p1, p2 = ctx.p1(), ctx.p2()
1921 p1, p2 = ctx.p1(), ctx.p2()
1920 user = ctx.user()
1922 user = ctx.user()
1921
1923
1922 lock = self.lock()
1924 lock = self.lock()
1923 try:
1925 try:
1924 tr = self.transaction("commit")
1926 tr = self.transaction("commit")
1925 trp = weakref.proxy(tr)
1927 trp = weakref.proxy(tr)
1926
1928
1927 if ctx.manifestnode():
1929 if ctx.manifestnode():
1928 # reuse an existing manifest revision
1930 # reuse an existing manifest revision
1929 mn = ctx.manifestnode()
1931 mn = ctx.manifestnode()
1930 files = ctx.files()
1932 files = ctx.files()
1931 elif ctx.files():
1933 elif ctx.files():
1932 m1ctx = p1.manifestctx()
1934 m1ctx = p1.manifestctx()
1933 m2ctx = p2.manifestctx()
1935 m2ctx = p2.manifestctx()
1934 mctx = m1ctx.copy()
1936 mctx = m1ctx.copy()
1935
1937
1936 m = mctx.read()
1938 m = mctx.read()
1937 m1 = m1ctx.read()
1939 m1 = m1ctx.read()
1938 m2 = m2ctx.read()
1940 m2 = m2ctx.read()
1939
1941
1940 # check in files
1942 # check in files
1941 added = []
1943 added = []
1942 changed = []
1944 changed = []
1943 removed = list(ctx.removed())
1945 removed = list(ctx.removed())
1944 linkrev = len(self)
1946 linkrev = len(self)
1945 self.ui.note(_("committing files:\n"))
1947 self.ui.note(_("committing files:\n"))
1946 for f in sorted(ctx.modified() + ctx.added()):
1948 for f in sorted(ctx.modified() + ctx.added()):
1947 self.ui.note(f + "\n")
1949 self.ui.note(f + "\n")
1948 try:
1950 try:
1949 fctx = ctx[f]
1951 fctx = ctx[f]
1950 if fctx is None:
1952 if fctx is None:
1951 removed.append(f)
1953 removed.append(f)
1952 else:
1954 else:
1953 added.append(f)
1955 added.append(f)
1954 m[f] = self._filecommit(fctx, m1, m2, linkrev,
1956 m[f] = self._filecommit(fctx, m1, m2, linkrev,
1955 trp, changed)
1957 trp, changed)
1956 m.setflag(f, fctx.flags())
1958 m.setflag(f, fctx.flags())
1957 except OSError as inst:
1959 except OSError as inst:
1958 self.ui.warn(_("trouble committing %s!\n") % f)
1960 self.ui.warn(_("trouble committing %s!\n") % f)
1959 raise
1961 raise
1960 except IOError as inst:
1962 except IOError as inst:
1961 errcode = getattr(inst, 'errno', errno.ENOENT)
1963 errcode = getattr(inst, 'errno', errno.ENOENT)
1962 if error or errcode and errcode != errno.ENOENT:
1964 if error or errcode and errcode != errno.ENOENT:
1963 self.ui.warn(_("trouble committing %s!\n") % f)
1965 self.ui.warn(_("trouble committing %s!\n") % f)
1964 raise
1966 raise
1965
1967
1966 # update manifest
1968 # update manifest
1967 self.ui.note(_("committing manifest\n"))
1969 self.ui.note(_("committing manifest\n"))
1968 removed = [f for f in sorted(removed) if f in m1 or f in m2]
1970 removed = [f for f in sorted(removed) if f in m1 or f in m2]
1969 drop = [f for f in removed if f in m]
1971 drop = [f for f in removed if f in m]
1970 for f in drop:
1972 for f in drop:
1971 del m[f]
1973 del m[f]
1972 mn = mctx.write(trp, linkrev,
1974 mn = mctx.write(trp, linkrev,
1973 p1.manifestnode(), p2.manifestnode(),
1975 p1.manifestnode(), p2.manifestnode(),
1974 added, drop)
1976 added, drop)
1975 files = changed + removed
1977 files = changed + removed
1976 else:
1978 else:
1977 mn = p1.manifestnode()
1979 mn = p1.manifestnode()
1978 files = []
1980 files = []
1979
1981
1980 # update changelog
1982 # update changelog
1981 self.ui.note(_("committing changelog\n"))
1983 self.ui.note(_("committing changelog\n"))
1982 self.changelog.delayupdate(tr)
1984 self.changelog.delayupdate(tr)
1983 n = self.changelog.add(mn, files, ctx.description(),
1985 n = self.changelog.add(mn, files, ctx.description(),
1984 trp, p1.node(), p2.node(),
1986 trp, p1.node(), p2.node(),
1985 user, ctx.date(), ctx.extra().copy())
1987 user, ctx.date(), ctx.extra().copy())
1986 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
1988 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
1987 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
1989 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
1988 parent2=xp2)
1990 parent2=xp2)
1989 # set the new commit is proper phase
1991 # set the new commit is proper phase
1990 targetphase = subrepo.newcommitphase(self.ui, ctx)
1992 targetphase = subrepo.newcommitphase(self.ui, ctx)
1991 if targetphase:
1993 if targetphase:
1992 # retract boundary do not alter parent changeset.
1994 # retract boundary do not alter parent changeset.
1993 # if a parent have higher the resulting phase will
1995 # if a parent have higher the resulting phase will
1994 # be compliant anyway
1996 # be compliant anyway
1995 #
1997 #
1996 # if minimal phase was 0 we don't need to retract anything
1998 # if minimal phase was 0 we don't need to retract anything
1997 phases.registernew(self, tr, targetphase, [n])
1999 phases.registernew(self, tr, targetphase, [n])
1998 tr.close()
2000 tr.close()
1999 return n
2001 return n
2000 finally:
2002 finally:
2001 if tr:
2003 if tr:
2002 tr.release()
2004 tr.release()
2003 lock.release()
2005 lock.release()
2004
2006
2005 @unfilteredmethod
2007 @unfilteredmethod
2006 def destroying(self):
2008 def destroying(self):
2007 '''Inform the repository that nodes are about to be destroyed.
2009 '''Inform the repository that nodes are about to be destroyed.
2008 Intended for use by strip and rollback, so there's a common
2010 Intended for use by strip and rollback, so there's a common
2009 place for anything that has to be done before destroying history.
2011 place for anything that has to be done before destroying history.
2010
2012
2011 This is mostly useful for saving state that is in memory and waiting
2013 This is mostly useful for saving state that is in memory and waiting
2012 to be flushed when the current lock is released. Because a call to
2014 to be flushed when the current lock is released. Because a call to
2013 destroyed is imminent, the repo will be invalidated causing those
2015 destroyed is imminent, the repo will be invalidated causing those
2014 changes to stay in memory (waiting for the next unlock), or vanish
2016 changes to stay in memory (waiting for the next unlock), or vanish
2015 completely.
2017 completely.
2016 '''
2018 '''
2017 # When using the same lock to commit and strip, the phasecache is left
2019 # When using the same lock to commit and strip, the phasecache is left
2018 # dirty after committing. Then when we strip, the repo is invalidated,
2020 # dirty after committing. Then when we strip, the repo is invalidated,
2019 # causing those changes to disappear.
2021 # causing those changes to disappear.
2020 if '_phasecache' in vars(self):
2022 if '_phasecache' in vars(self):
2021 self._phasecache.write()
2023 self._phasecache.write()
2022
2024
2023 @unfilteredmethod
2025 @unfilteredmethod
2024 def destroyed(self):
2026 def destroyed(self):
2025 '''Inform the repository that nodes have been destroyed.
2027 '''Inform the repository that nodes have been destroyed.
2026 Intended for use by strip and rollback, so there's a common
2028 Intended for use by strip and rollback, so there's a common
2027 place for anything that has to be done after destroying history.
2029 place for anything that has to be done after destroying history.
2028 '''
2030 '''
2029 # When one tries to:
2031 # When one tries to:
2030 # 1) destroy nodes thus calling this method (e.g. strip)
2032 # 1) destroy nodes thus calling this method (e.g. strip)
2031 # 2) use phasecache somewhere (e.g. commit)
2033 # 2) use phasecache somewhere (e.g. commit)
2032 #
2034 #
2033 # then 2) will fail because the phasecache contains nodes that were
2035 # then 2) will fail because the phasecache contains nodes that were
2034 # removed. We can either remove phasecache from the filecache,
2036 # removed. We can either remove phasecache from the filecache,
2035 # causing it to reload next time it is accessed, or simply filter
2037 # causing it to reload next time it is accessed, or simply filter
2036 # the removed nodes now and write the updated cache.
2038 # the removed nodes now and write the updated cache.
2037 self._phasecache.filterunknown(self)
2039 self._phasecache.filterunknown(self)
2038 self._phasecache.write()
2040 self._phasecache.write()
2039
2041
2040 # refresh all repository caches
2042 # refresh all repository caches
2041 self.updatecaches()
2043 self.updatecaches()
2042
2044
2043 # Ensure the persistent tag cache is updated. Doing it now
2045 # Ensure the persistent tag cache is updated. Doing it now
2044 # means that the tag cache only has to worry about destroyed
2046 # means that the tag cache only has to worry about destroyed
2045 # heads immediately after a strip/rollback. That in turn
2047 # heads immediately after a strip/rollback. That in turn
2046 # guarantees that "cachetip == currenttip" (comparing both rev
2048 # guarantees that "cachetip == currenttip" (comparing both rev
2047 # and node) always means no nodes have been added or destroyed.
2049 # and node) always means no nodes have been added or destroyed.
2048
2050
2049 # XXX this is suboptimal when qrefresh'ing: we strip the current
2051 # XXX this is suboptimal when qrefresh'ing: we strip the current
2050 # head, refresh the tag cache, then immediately add a new head.
2052 # head, refresh the tag cache, then immediately add a new head.
2051 # But I think doing it this way is necessary for the "instant
2053 # But I think doing it this way is necessary for the "instant
2052 # tag cache retrieval" case to work.
2054 # tag cache retrieval" case to work.
2053 self.invalidate()
2055 self.invalidate()
2054
2056
2055 def walk(self, match, node=None):
2057 def walk(self, match, node=None):
2056 '''
2058 '''
2057 walk recursively through the directory tree or a given
2059 walk recursively through the directory tree or a given
2058 changeset, finding all files matched by the match
2060 changeset, finding all files matched by the match
2059 function
2061 function
2060 '''
2062 '''
2061 self.ui.deprecwarn('use repo[node].walk instead of repo.walk', '4.3')
2063 self.ui.deprecwarn('use repo[node].walk instead of repo.walk', '4.3')
2062 return self[node].walk(match)
2064 return self[node].walk(match)
2063
2065
2064 def status(self, node1='.', node2=None, match=None,
2066 def status(self, node1='.', node2=None, match=None,
2065 ignored=False, clean=False, unknown=False,
2067 ignored=False, clean=False, unknown=False,
2066 listsubrepos=False):
2068 listsubrepos=False):
2067 '''a convenience method that calls node1.status(node2)'''
2069 '''a convenience method that calls node1.status(node2)'''
2068 return self[node1].status(node2, match, ignored, clean, unknown,
2070 return self[node1].status(node2, match, ignored, clean, unknown,
2069 listsubrepos)
2071 listsubrepos)
2070
2072
2071 def addpostdsstatus(self, ps):
2073 def addpostdsstatus(self, ps):
2072 """Add a callback to run within the wlock, at the point at which status
2074 """Add a callback to run within the wlock, at the point at which status
2073 fixups happen.
2075 fixups happen.
2074
2076
2075 On status completion, callback(wctx, status) will be called with the
2077 On status completion, callback(wctx, status) will be called with the
2076 wlock held, unless the dirstate has changed from underneath or the wlock
2078 wlock held, unless the dirstate has changed from underneath or the wlock
2077 couldn't be grabbed.
2079 couldn't be grabbed.
2078
2080
2079 Callbacks should not capture and use a cached copy of the dirstate --
2081 Callbacks should not capture and use a cached copy of the dirstate --
2080 it might change in the meanwhile. Instead, they should access the
2082 it might change in the meanwhile. Instead, they should access the
2081 dirstate via wctx.repo().dirstate.
2083 dirstate via wctx.repo().dirstate.
2082
2084
2083 This list is emptied out after each status run -- extensions should
2085 This list is emptied out after each status run -- extensions should
2084 make sure it adds to this list each time dirstate.status is called.
2086 make sure it adds to this list each time dirstate.status is called.
2085 Extensions should also make sure they don't call this for statuses
2087 Extensions should also make sure they don't call this for statuses
2086 that don't involve the dirstate.
2088 that don't involve the dirstate.
2087 """
2089 """
2088
2090
2089 # The list is located here for uniqueness reasons -- it is actually
2091 # The list is located here for uniqueness reasons -- it is actually
2090 # managed by the workingctx, but that isn't unique per-repo.
2092 # managed by the workingctx, but that isn't unique per-repo.
2091 self._postdsstatus.append(ps)
2093 self._postdsstatus.append(ps)
2092
2094
2093 def postdsstatus(self):
2095 def postdsstatus(self):
2094 """Used by workingctx to get the list of post-dirstate-status hooks."""
2096 """Used by workingctx to get the list of post-dirstate-status hooks."""
2095 return self._postdsstatus
2097 return self._postdsstatus
2096
2098
2097 def clearpostdsstatus(self):
2099 def clearpostdsstatus(self):
2098 """Used by workingctx to clear post-dirstate-status hooks."""
2100 """Used by workingctx to clear post-dirstate-status hooks."""
2099 del self._postdsstatus[:]
2101 del self._postdsstatus[:]
2100
2102
2101 def heads(self, start=None):
2103 def heads(self, start=None):
2102 if start is None:
2104 if start is None:
2103 cl = self.changelog
2105 cl = self.changelog
2104 headrevs = reversed(cl.headrevs())
2106 headrevs = reversed(cl.headrevs())
2105 return [cl.node(rev) for rev in headrevs]
2107 return [cl.node(rev) for rev in headrevs]
2106
2108
2107 heads = self.changelog.heads(start)
2109 heads = self.changelog.heads(start)
2108 # sort the output in rev descending order
2110 # sort the output in rev descending order
2109 return sorted(heads, key=self.changelog.rev, reverse=True)
2111 return sorted(heads, key=self.changelog.rev, reverse=True)
2110
2112
2111 def branchheads(self, branch=None, start=None, closed=False):
2113 def branchheads(self, branch=None, start=None, closed=False):
2112 '''return a (possibly filtered) list of heads for the given branch
2114 '''return a (possibly filtered) list of heads for the given branch
2113
2115
2114 Heads are returned in topological order, from newest to oldest.
2116 Heads are returned in topological order, from newest to oldest.
2115 If branch is None, use the dirstate branch.
2117 If branch is None, use the dirstate branch.
2116 If start is not None, return only heads reachable from start.
2118 If start is not None, return only heads reachable from start.
2117 If closed is True, return heads that are marked as closed as well.
2119 If closed is True, return heads that are marked as closed as well.
2118 '''
2120 '''
2119 if branch is None:
2121 if branch is None:
2120 branch = self[None].branch()
2122 branch = self[None].branch()
2121 branches = self.branchmap()
2123 branches = self.branchmap()
2122 if branch not in branches:
2124 if branch not in branches:
2123 return []
2125 return []
2124 # the cache returns heads ordered lowest to highest
2126 # the cache returns heads ordered lowest to highest
2125 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
2127 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
2126 if start is not None:
2128 if start is not None:
2127 # filter out the heads that cannot be reached from startrev
2129 # filter out the heads that cannot be reached from startrev
2128 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
2130 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
2129 bheads = [h for h in bheads if h in fbheads]
2131 bheads = [h for h in bheads if h in fbheads]
2130 return bheads
2132 return bheads
2131
2133
2132 def branches(self, nodes):
2134 def branches(self, nodes):
2133 if not nodes:
2135 if not nodes:
2134 nodes = [self.changelog.tip()]
2136 nodes = [self.changelog.tip()]
2135 b = []
2137 b = []
2136 for n in nodes:
2138 for n in nodes:
2137 t = n
2139 t = n
2138 while True:
2140 while True:
2139 p = self.changelog.parents(n)
2141 p = self.changelog.parents(n)
2140 if p[1] != nullid or p[0] == nullid:
2142 if p[1] != nullid or p[0] == nullid:
2141 b.append((t, n, p[0], p[1]))
2143 b.append((t, n, p[0], p[1]))
2142 break
2144 break
2143 n = p[0]
2145 n = p[0]
2144 return b
2146 return b
2145
2147
2146 def between(self, pairs):
2148 def between(self, pairs):
2147 r = []
2149 r = []
2148
2150
2149 for top, bottom in pairs:
2151 for top, bottom in pairs:
2150 n, l, i = top, [], 0
2152 n, l, i = top, [], 0
2151 f = 1
2153 f = 1
2152
2154
2153 while n != bottom and n != nullid:
2155 while n != bottom and n != nullid:
2154 p = self.changelog.parents(n)[0]
2156 p = self.changelog.parents(n)[0]
2155 if i == f:
2157 if i == f:
2156 l.append(n)
2158 l.append(n)
2157 f = f * 2
2159 f = f * 2
2158 n = p
2160 n = p
2159 i += 1
2161 i += 1
2160
2162
2161 r.append(l)
2163 r.append(l)
2162
2164
2163 return r
2165 return r
2164
2166
2165 def checkpush(self, pushop):
2167 def checkpush(self, pushop):
2166 """Extensions can override this function if additional checks have
2168 """Extensions can override this function if additional checks have
2167 to be performed before pushing, or call it if they override push
2169 to be performed before pushing, or call it if they override push
2168 command.
2170 command.
2169 """
2171 """
2170
2172
2171 @unfilteredpropertycache
2173 @unfilteredpropertycache
2172 def prepushoutgoinghooks(self):
2174 def prepushoutgoinghooks(self):
2173 """Return util.hooks consists of a pushop with repo, remote, outgoing
2175 """Return util.hooks consists of a pushop with repo, remote, outgoing
2174 methods, which are called before pushing changesets.
2176 methods, which are called before pushing changesets.
2175 """
2177 """
2176 return util.hooks()
2178 return util.hooks()
2177
2179
2178 def pushkey(self, namespace, key, old, new):
2180 def pushkey(self, namespace, key, old, new):
2179 try:
2181 try:
2180 tr = self.currenttransaction()
2182 tr = self.currenttransaction()
2181 hookargs = {}
2183 hookargs = {}
2182 if tr is not None:
2184 if tr is not None:
2183 hookargs.update(tr.hookargs)
2185 hookargs.update(tr.hookargs)
2184 hookargs['namespace'] = namespace
2186 hookargs['namespace'] = namespace
2185 hookargs['key'] = key
2187 hookargs['key'] = key
2186 hookargs['old'] = old
2188 hookargs['old'] = old
2187 hookargs['new'] = new
2189 hookargs['new'] = new
2188 self.hook('prepushkey', throw=True, **hookargs)
2190 self.hook('prepushkey', throw=True, **hookargs)
2189 except error.HookAbort as exc:
2191 except error.HookAbort as exc:
2190 self.ui.write_err(_("pushkey-abort: %s\n") % exc)
2192 self.ui.write_err(_("pushkey-abort: %s\n") % exc)
2191 if exc.hint:
2193 if exc.hint:
2192 self.ui.write_err(_("(%s)\n") % exc.hint)
2194 self.ui.write_err(_("(%s)\n") % exc.hint)
2193 return False
2195 return False
2194 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
2196 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
2195 ret = pushkey.push(self, namespace, key, old, new)
2197 ret = pushkey.push(self, namespace, key, old, new)
2196 def runhook():
2198 def runhook():
2197 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
2199 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
2198 ret=ret)
2200 ret=ret)
2199 self._afterlock(runhook)
2201 self._afterlock(runhook)
2200 return ret
2202 return ret
2201
2203
2202 def listkeys(self, namespace):
2204 def listkeys(self, namespace):
2203 self.hook('prelistkeys', throw=True, namespace=namespace)
2205 self.hook('prelistkeys', throw=True, namespace=namespace)
2204 self.ui.debug('listing keys for "%s"\n' % namespace)
2206 self.ui.debug('listing keys for "%s"\n' % namespace)
2205 values = pushkey.list(self, namespace)
2207 values = pushkey.list(self, namespace)
2206 self.hook('listkeys', namespace=namespace, values=values)
2208 self.hook('listkeys', namespace=namespace, values=values)
2207 return values
2209 return values
2208
2210
2209 def debugwireargs(self, one, two, three=None, four=None, five=None):
2211 def debugwireargs(self, one, two, three=None, four=None, five=None):
2210 '''used to test argument passing over the wire'''
2212 '''used to test argument passing over the wire'''
2211 return "%s %s %s %s %s" % (one, two, three, four, five)
2213 return "%s %s %s %s %s" % (one, two, three, four, five)
2212
2214
2213 def savecommitmessage(self, text):
2215 def savecommitmessage(self, text):
2214 fp = self.vfs('last-message.txt', 'wb')
2216 fp = self.vfs('last-message.txt', 'wb')
2215 try:
2217 try:
2216 fp.write(text)
2218 fp.write(text)
2217 finally:
2219 finally:
2218 fp.close()
2220 fp.close()
2219 return self.pathto(fp.name[len(self.root) + 1:])
2221 return self.pathto(fp.name[len(self.root) + 1:])
2220
2222
2221 # used to avoid circular references so destructors work
2223 # used to avoid circular references so destructors work
2222 def aftertrans(files):
2224 def aftertrans(files):
2223 renamefiles = [tuple(t) for t in files]
2225 renamefiles = [tuple(t) for t in files]
2224 def a():
2226 def a():
2225 for vfs, src, dest in renamefiles:
2227 for vfs, src, dest in renamefiles:
2226 # if src and dest refer to a same file, vfs.rename is a no-op,
2228 # if src and dest refer to a same file, vfs.rename is a no-op,
2227 # leaving both src and dest on disk. delete dest to make sure
2229 # leaving both src and dest on disk. delete dest to make sure
2228 # the rename couldn't be such a no-op.
2230 # the rename couldn't be such a no-op.
2229 vfs.tryunlink(dest)
2231 vfs.tryunlink(dest)
2230 try:
2232 try:
2231 vfs.rename(src, dest)
2233 vfs.rename(src, dest)
2232 except OSError: # journal file does not yet exist
2234 except OSError: # journal file does not yet exist
2233 pass
2235 pass
2234 return a
2236 return a
2235
2237
2236 def undoname(fn):
2238 def undoname(fn):
2237 base, name = os.path.split(fn)
2239 base, name = os.path.split(fn)
2238 assert name.startswith('journal')
2240 assert name.startswith('journal')
2239 return os.path.join(base, name.replace('journal', 'undo', 1))
2241 return os.path.join(base, name.replace('journal', 'undo', 1))
2240
2242
2241 def instance(ui, path, create):
2243 def instance(ui, path, create):
2242 return localrepository(ui, util.urllocalpath(path), create)
2244 return localrepository(ui, util.urllocalpath(path), create)
2243
2245
2244 def islocal(path):
2246 def islocal(path):
2245 return True
2247 return True
2246
2248
2247 def newreporequirements(repo):
2249 def newreporequirements(repo):
2248 """Determine the set of requirements for a new local repository.
2250 """Determine the set of requirements for a new local repository.
2249
2251
2250 Extensions can wrap this function to specify custom requirements for
2252 Extensions can wrap this function to specify custom requirements for
2251 new repositories.
2253 new repositories.
2252 """
2254 """
2253 ui = repo.ui
2255 ui = repo.ui
2254 requirements = {'revlogv1'}
2256 requirements = {'revlogv1'}
2255 if ui.configbool('format', 'usestore'):
2257 if ui.configbool('format', 'usestore'):
2256 requirements.add('store')
2258 requirements.add('store')
2257 if ui.configbool('format', 'usefncache'):
2259 if ui.configbool('format', 'usefncache'):
2258 requirements.add('fncache')
2260 requirements.add('fncache')
2259 if ui.configbool('format', 'dotencode'):
2261 if ui.configbool('format', 'dotencode'):
2260 requirements.add('dotencode')
2262 requirements.add('dotencode')
2261
2263
2262 compengine = ui.config('experimental', 'format.compression')
2264 compengine = ui.config('experimental', 'format.compression')
2263 if compengine not in util.compengines:
2265 if compengine not in util.compengines:
2264 raise error.Abort(_('compression engine %s defined by '
2266 raise error.Abort(_('compression engine %s defined by '
2265 'experimental.format.compression not available') %
2267 'experimental.format.compression not available') %
2266 compengine,
2268 compengine,
2267 hint=_('run "hg debuginstall" to list available '
2269 hint=_('run "hg debuginstall" to list available '
2268 'compression engines'))
2270 'compression engines'))
2269
2271
2270 # zlib is the historical default and doesn't need an explicit requirement.
2272 # zlib is the historical default and doesn't need an explicit requirement.
2271 if compengine != 'zlib':
2273 if compengine != 'zlib':
2272 requirements.add('exp-compression-%s' % compengine)
2274 requirements.add('exp-compression-%s' % compengine)
2273
2275
2274 if scmutil.gdinitconfig(ui):
2276 if scmutil.gdinitconfig(ui):
2275 requirements.add('generaldelta')
2277 requirements.add('generaldelta')
2276 if ui.configbool('experimental', 'treemanifest'):
2278 if ui.configbool('experimental', 'treemanifest'):
2277 requirements.add('treemanifest')
2279 requirements.add('treemanifest')
2278 if ui.configbool('experimental', 'manifestv2'):
2280 if ui.configbool('experimental', 'manifestv2'):
2279 requirements.add('manifestv2')
2281 requirements.add('manifestv2')
2280
2282
2281 revlogv2 = ui.config('experimental', 'revlogv2')
2283 revlogv2 = ui.config('experimental', 'revlogv2')
2282 if revlogv2 == 'enable-unstable-format-and-corrupt-my-data':
2284 if revlogv2 == 'enable-unstable-format-and-corrupt-my-data':
2283 requirements.remove('revlogv1')
2285 requirements.remove('revlogv1')
2284 # generaldelta is implied by revlogv2.
2286 # generaldelta is implied by revlogv2.
2285 requirements.discard('generaldelta')
2287 requirements.discard('generaldelta')
2286 requirements.add(REVLOGV2_REQUIREMENT)
2288 requirements.add(REVLOGV2_REQUIREMENT)
2287
2289
2288 return requirements
2290 return requirements
@@ -1,321 +1,329 b''
1 # lock.py - simple advisory locking scheme for mercurial
1 # lock.py - simple advisory locking scheme for mercurial
2 #
2 #
3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005, 2006 Matt Mackall <mpm@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 contextlib
10 import contextlib
11 import errno
11 import errno
12 import os
12 import os
13 import socket
13 import socket
14 import time
14 import time
15 import warnings
15 import warnings
16
16
17 from .i18n import _
17 from .i18n import _
18
18
19 from . import (
19 from . import (
20 encoding,
20 encoding,
21 error,
21 error,
22 pycompat,
22 pycompat,
23 util,
23 util,
24 )
24 )
25
25
26 def _getlockprefix():
26 def _getlockprefix():
27 """Return a string which is used to differentiate pid namespaces
27 """Return a string which is used to differentiate pid namespaces
28
28
29 It's useful to detect "dead" processes and remove stale locks with
29 It's useful to detect "dead" processes and remove stale locks with
30 confidence. Typically it's just hostname. On modern linux, we include an
30 confidence. Typically it's just hostname. On modern linux, we include an
31 extra Linux-specific pid namespace identifier.
31 extra Linux-specific pid namespace identifier.
32 """
32 """
33 result = socket.gethostname()
33 result = socket.gethostname()
34 if pycompat.ispy3:
34 if pycompat.ispy3:
35 result = result.encode(pycompat.sysstr(encoding.encoding), 'replace')
35 result = result.encode(pycompat.sysstr(encoding.encoding), 'replace')
36 if pycompat.sysplatform.startswith('linux'):
36 if pycompat.sysplatform.startswith('linux'):
37 try:
37 try:
38 result += '/%x' % os.stat('/proc/self/ns/pid').st_ino
38 result += '/%x' % os.stat('/proc/self/ns/pid').st_ino
39 except OSError as ex:
39 except OSError as ex:
40 if ex.errno not in (errno.ENOENT, errno.EACCES, errno.ENOTDIR):
40 if ex.errno not in (errno.ENOENT, errno.EACCES, errno.ENOTDIR):
41 raise
41 raise
42 return result
42 return result
43
43
44 def trylock(ui, vfs, lockname, timeout, *args, **kwargs):
44 def trylock(ui, vfs, lockname, timeout, warntimeout, *args, **kwargs):
45 """return an acquired lock or raise an a LockHeld exception
45 """return an acquired lock or raise an a LockHeld exception
46
46
47 This function is responsible to issue warnings about the held lock while
47 This function is responsible to issue warnings and or debug messages about
48 trying to acquires it."""
48 the held lock while trying to acquires it."""
49
49
50 def printwarning(printer, locker):
50 def printwarning(printer, locker):
51 """issue the usual "waiting on lock" message through any channel"""
51 """issue the usual "waiting on lock" message through any channel"""
52 # show more details for new-style locks
52 # show more details for new-style locks
53 if ':' in locker:
53 if ':' in locker:
54 host, pid = locker.split(":", 1)
54 host, pid = locker.split(":", 1)
55 msg = _("waiting for lock on %s held by process %r "
55 msg = _("waiting for lock on %s held by process %r "
56 "on host %r\n") % (l.desc, pid, host)
56 "on host %r\n") % (l.desc, pid, host)
57 else:
57 else:
58 msg = _("waiting for lock on %s held by %r\n") % (l.desc, locker)
58 msg = _("waiting for lock on %s held by %r\n") % (l.desc, locker)
59 printer(msg)
59 printer(msg)
60
60
61 l = lock(vfs, lockname, 0, *args, dolock=False, **kwargs)
61 l = lock(vfs, lockname, 0, *args, dolock=False, **kwargs)
62
62
63 debugidx = 0 if (warntimeout and timeout) else -1
63 warningidx = 0
64 warningidx = 0
64 if not timeout:
65 if not timeout:
65 warningidx = -1
66 warningidx = -1
67 elif warntimeout:
68 warningidx = warntimeout
66
69
67 delay = 0
70 delay = 0
68 while True:
71 while True:
69 try:
72 try:
70 l._trylock()
73 l._trylock()
71 break
74 break
72 except error.LockHeld as inst:
75 except error.LockHeld as inst:
76 if delay == debugidx:
77 printwarning(ui.debug, inst.locker)
73 if delay == warningidx:
78 if delay == warningidx:
74 printwarning(ui.warn, inst.locker)
79 printwarning(ui.warn, inst.locker)
75 if timeout <= delay:
80 if timeout <= delay:
76 raise error.LockHeld(errno.ETIMEDOUT, inst.filename,
81 raise error.LockHeld(errno.ETIMEDOUT, inst.filename,
77 l.desc, inst.locker)
82 l.desc, inst.locker)
78 time.sleep(1)
83 time.sleep(1)
79 delay += 1
84 delay += 1
80
85
81 l.delay = delay
86 l.delay = delay
82 if l.delay:
87 if l.delay:
83 ui.warn(_("got lock after %s seconds\n") % l.delay)
88 if 0 <= warningidx <= l.delay:
89 ui.warn(_("got lock after %s seconds\n") % l.delay)
90 else:
91 ui.debug("got lock after %s seconds\n" % l.delay)
84 if l.acquirefn:
92 if l.acquirefn:
85 l.acquirefn()
93 l.acquirefn()
86 return l
94 return l
87
95
88 class lock(object):
96 class lock(object):
89 '''An advisory lock held by one process to control access to a set
97 '''An advisory lock held by one process to control access to a set
90 of files. Non-cooperating processes or incorrectly written scripts
98 of files. Non-cooperating processes or incorrectly written scripts
91 can ignore Mercurial's locking scheme and stomp all over the
99 can ignore Mercurial's locking scheme and stomp all over the
92 repository, so don't do that.
100 repository, so don't do that.
93
101
94 Typically used via localrepository.lock() to lock the repository
102 Typically used via localrepository.lock() to lock the repository
95 store (.hg/store/) or localrepository.wlock() to lock everything
103 store (.hg/store/) or localrepository.wlock() to lock everything
96 else under .hg/.'''
104 else under .hg/.'''
97
105
98 # lock is symlink on platforms that support it, file on others.
106 # lock is symlink on platforms that support it, file on others.
99
107
100 # symlink is used because create of directory entry and contents
108 # symlink is used because create of directory entry and contents
101 # are atomic even over nfs.
109 # are atomic even over nfs.
102
110
103 # old-style lock: symlink to pid
111 # old-style lock: symlink to pid
104 # new-style lock: symlink to hostname:pid
112 # new-style lock: symlink to hostname:pid
105
113
106 _host = None
114 _host = None
107
115
108 def __init__(self, vfs, file, timeout=-1, releasefn=None, acquirefn=None,
116 def __init__(self, vfs, file, timeout=-1, releasefn=None, acquirefn=None,
109 desc=None, inheritchecker=None, parentlock=None,
117 desc=None, inheritchecker=None, parentlock=None,
110 dolock=True):
118 dolock=True):
111 self.vfs = vfs
119 self.vfs = vfs
112 self.f = file
120 self.f = file
113 self.held = 0
121 self.held = 0
114 self.timeout = timeout
122 self.timeout = timeout
115 self.releasefn = releasefn
123 self.releasefn = releasefn
116 self.acquirefn = acquirefn
124 self.acquirefn = acquirefn
117 self.desc = desc
125 self.desc = desc
118 self._inheritchecker = inheritchecker
126 self._inheritchecker = inheritchecker
119 self.parentlock = parentlock
127 self.parentlock = parentlock
120 self._parentheld = False
128 self._parentheld = False
121 self._inherited = False
129 self._inherited = False
122 self.postrelease = []
130 self.postrelease = []
123 self.pid = self._getpid()
131 self.pid = self._getpid()
124 if dolock:
132 if dolock:
125 self.delay = self.lock()
133 self.delay = self.lock()
126 if self.acquirefn:
134 if self.acquirefn:
127 self.acquirefn()
135 self.acquirefn()
128
136
129 def __enter__(self):
137 def __enter__(self):
130 return self
138 return self
131
139
132 def __exit__(self, exc_type, exc_value, exc_tb):
140 def __exit__(self, exc_type, exc_value, exc_tb):
133 self.release()
141 self.release()
134
142
135 def __del__(self):
143 def __del__(self):
136 if self.held:
144 if self.held:
137 warnings.warn("use lock.release instead of del lock",
145 warnings.warn("use lock.release instead of del lock",
138 category=DeprecationWarning,
146 category=DeprecationWarning,
139 stacklevel=2)
147 stacklevel=2)
140
148
141 # ensure the lock will be removed
149 # ensure the lock will be removed
142 # even if recursive locking did occur
150 # even if recursive locking did occur
143 self.held = 1
151 self.held = 1
144
152
145 self.release()
153 self.release()
146
154
147 def _getpid(self):
155 def _getpid(self):
148 # wrapper around util.getpid() to make testing easier
156 # wrapper around util.getpid() to make testing easier
149 return util.getpid()
157 return util.getpid()
150
158
151 def lock(self):
159 def lock(self):
152 timeout = self.timeout
160 timeout = self.timeout
153 while True:
161 while True:
154 try:
162 try:
155 self._trylock()
163 self._trylock()
156 return self.timeout - timeout
164 return self.timeout - timeout
157 except error.LockHeld as inst:
165 except error.LockHeld as inst:
158 if timeout != 0:
166 if timeout != 0:
159 time.sleep(1)
167 time.sleep(1)
160 if timeout > 0:
168 if timeout > 0:
161 timeout -= 1
169 timeout -= 1
162 continue
170 continue
163 raise error.LockHeld(errno.ETIMEDOUT, inst.filename, self.desc,
171 raise error.LockHeld(errno.ETIMEDOUT, inst.filename, self.desc,
164 inst.locker)
172 inst.locker)
165
173
166 def _trylock(self):
174 def _trylock(self):
167 if self.held:
175 if self.held:
168 self.held += 1
176 self.held += 1
169 return
177 return
170 if lock._host is None:
178 if lock._host is None:
171 lock._host = _getlockprefix()
179 lock._host = _getlockprefix()
172 lockname = '%s:%d' % (lock._host, self.pid)
180 lockname = '%s:%d' % (lock._host, self.pid)
173 retry = 5
181 retry = 5
174 while not self.held and retry:
182 while not self.held and retry:
175 retry -= 1
183 retry -= 1
176 try:
184 try:
177 self.vfs.makelock(lockname, self.f)
185 self.vfs.makelock(lockname, self.f)
178 self.held = 1
186 self.held = 1
179 except (OSError, IOError) as why:
187 except (OSError, IOError) as why:
180 if why.errno == errno.EEXIST:
188 if why.errno == errno.EEXIST:
181 locker = self._readlock()
189 locker = self._readlock()
182 if locker is None:
190 if locker is None:
183 continue
191 continue
184
192
185 # special case where a parent process holds the lock -- this
193 # special case where a parent process holds the lock -- this
186 # is different from the pid being different because we do
194 # is different from the pid being different because we do
187 # want the unlock and postrelease functions to be called,
195 # want the unlock and postrelease functions to be called,
188 # but the lockfile to not be removed.
196 # but the lockfile to not be removed.
189 if locker == self.parentlock:
197 if locker == self.parentlock:
190 self._parentheld = True
198 self._parentheld = True
191 self.held = 1
199 self.held = 1
192 return
200 return
193 locker = self._testlock(locker)
201 locker = self._testlock(locker)
194 if locker is not None:
202 if locker is not None:
195 raise error.LockHeld(errno.EAGAIN,
203 raise error.LockHeld(errno.EAGAIN,
196 self.vfs.join(self.f), self.desc,
204 self.vfs.join(self.f), self.desc,
197 locker)
205 locker)
198 else:
206 else:
199 raise error.LockUnavailable(why.errno, why.strerror,
207 raise error.LockUnavailable(why.errno, why.strerror,
200 why.filename, self.desc)
208 why.filename, self.desc)
201
209
202 if not self.held:
210 if not self.held:
203 # use empty locker to mean "busy for frequent lock/unlock
211 # use empty locker to mean "busy for frequent lock/unlock
204 # by many processes"
212 # by many processes"
205 raise error.LockHeld(errno.EAGAIN,
213 raise error.LockHeld(errno.EAGAIN,
206 self.vfs.join(self.f), self.desc, "")
214 self.vfs.join(self.f), self.desc, "")
207
215
208 def _readlock(self):
216 def _readlock(self):
209 """read lock and return its value
217 """read lock and return its value
210
218
211 Returns None if no lock exists, pid for old-style locks, and host:pid
219 Returns None if no lock exists, pid for old-style locks, and host:pid
212 for new-style locks.
220 for new-style locks.
213 """
221 """
214 try:
222 try:
215 return self.vfs.readlock(self.f)
223 return self.vfs.readlock(self.f)
216 except (OSError, IOError) as why:
224 except (OSError, IOError) as why:
217 if why.errno == errno.ENOENT:
225 if why.errno == errno.ENOENT:
218 return None
226 return None
219 raise
227 raise
220
228
221 def _testlock(self, locker):
229 def _testlock(self, locker):
222 if locker is None:
230 if locker is None:
223 return None
231 return None
224 try:
232 try:
225 host, pid = locker.split(":", 1)
233 host, pid = locker.split(":", 1)
226 except ValueError:
234 except ValueError:
227 return locker
235 return locker
228 if host != lock._host:
236 if host != lock._host:
229 return locker
237 return locker
230 try:
238 try:
231 pid = int(pid)
239 pid = int(pid)
232 except ValueError:
240 except ValueError:
233 return locker
241 return locker
234 if util.testpid(pid):
242 if util.testpid(pid):
235 return locker
243 return locker
236 # if locker dead, break lock. must do this with another lock
244 # if locker dead, break lock. must do this with another lock
237 # held, or can race and break valid lock.
245 # held, or can race and break valid lock.
238 try:
246 try:
239 l = lock(self.vfs, self.f + '.break', timeout=0)
247 l = lock(self.vfs, self.f + '.break', timeout=0)
240 self.vfs.unlink(self.f)
248 self.vfs.unlink(self.f)
241 l.release()
249 l.release()
242 except error.LockError:
250 except error.LockError:
243 return locker
251 return locker
244
252
245 def testlock(self):
253 def testlock(self):
246 """return id of locker if lock is valid, else None.
254 """return id of locker if lock is valid, else None.
247
255
248 If old-style lock, we cannot tell what machine locker is on.
256 If old-style lock, we cannot tell what machine locker is on.
249 with new-style lock, if locker is on this machine, we can
257 with new-style lock, if locker is on this machine, we can
250 see if locker is alive. If locker is on this machine but
258 see if locker is alive. If locker is on this machine but
251 not alive, we can safely break lock.
259 not alive, we can safely break lock.
252
260
253 The lock file is only deleted when None is returned.
261 The lock file is only deleted when None is returned.
254
262
255 """
263 """
256 locker = self._readlock()
264 locker = self._readlock()
257 return self._testlock(locker)
265 return self._testlock(locker)
258
266
259 @contextlib.contextmanager
267 @contextlib.contextmanager
260 def inherit(self):
268 def inherit(self):
261 """context for the lock to be inherited by a Mercurial subprocess.
269 """context for the lock to be inherited by a Mercurial subprocess.
262
270
263 Yields a string that will be recognized by the lock in the subprocess.
271 Yields a string that will be recognized by the lock in the subprocess.
264 Communicating this string to the subprocess needs to be done separately
272 Communicating this string to the subprocess needs to be done separately
265 -- typically by an environment variable.
273 -- typically by an environment variable.
266 """
274 """
267 if not self.held:
275 if not self.held:
268 raise error.LockInheritanceContractViolation(
276 raise error.LockInheritanceContractViolation(
269 'inherit can only be called while lock is held')
277 'inherit can only be called while lock is held')
270 if self._inherited:
278 if self._inherited:
271 raise error.LockInheritanceContractViolation(
279 raise error.LockInheritanceContractViolation(
272 'inherit cannot be called while lock is already inherited')
280 'inherit cannot be called while lock is already inherited')
273 if self._inheritchecker is not None:
281 if self._inheritchecker is not None:
274 self._inheritchecker()
282 self._inheritchecker()
275 if self.releasefn:
283 if self.releasefn:
276 self.releasefn()
284 self.releasefn()
277 if self._parentheld:
285 if self._parentheld:
278 lockname = self.parentlock
286 lockname = self.parentlock
279 else:
287 else:
280 lockname = '%s:%s' % (lock._host, self.pid)
288 lockname = '%s:%s' % (lock._host, self.pid)
281 self._inherited = True
289 self._inherited = True
282 try:
290 try:
283 yield lockname
291 yield lockname
284 finally:
292 finally:
285 if self.acquirefn:
293 if self.acquirefn:
286 self.acquirefn()
294 self.acquirefn()
287 self._inherited = False
295 self._inherited = False
288
296
289 def release(self):
297 def release(self):
290 """release the lock and execute callback function if any
298 """release the lock and execute callback function if any
291
299
292 If the lock has been acquired multiple times, the actual release is
300 If the lock has been acquired multiple times, the actual release is
293 delayed to the last release call."""
301 delayed to the last release call."""
294 if self.held > 1:
302 if self.held > 1:
295 self.held -= 1
303 self.held -= 1
296 elif self.held == 1:
304 elif self.held == 1:
297 self.held = 0
305 self.held = 0
298 if self._getpid() != self.pid:
306 if self._getpid() != self.pid:
299 # we forked, and are not the parent
307 # we forked, and are not the parent
300 return
308 return
301 try:
309 try:
302 if self.releasefn:
310 if self.releasefn:
303 self.releasefn()
311 self.releasefn()
304 finally:
312 finally:
305 if not self._parentheld:
313 if not self._parentheld:
306 try:
314 try:
307 self.vfs.unlink(self.f)
315 self.vfs.unlink(self.f)
308 except OSError:
316 except OSError:
309 pass
317 pass
310 # The postrelease functions typically assume the lock is not held
318 # The postrelease functions typically assume the lock is not held
311 # at all.
319 # at all.
312 if not self._parentheld:
320 if not self._parentheld:
313 for callback in self.postrelease:
321 for callback in self.postrelease:
314 callback()
322 callback()
315 # Prevent double usage and help clear cycles.
323 # Prevent double usage and help clear cycles.
316 self.postrelease = None
324 self.postrelease = None
317
325
318 def release(*locks):
326 def release(*locks):
319 for lock in locks:
327 for lock in locks:
320 if lock is not None:
328 if lock is not None:
321 lock.release()
329 lock.release()
@@ -1,78 +1,141 b''
1 #require unix-permissions no-root no-windows
1 #require unix-permissions no-root no-windows
2
2
3 Prepare
3 Prepare
4
4
5 $ hg init a
5 $ hg init a
6 $ echo a > a/a
6 $ echo a > a/a
7 $ hg -R a ci -A -m a
7 $ hg -R a ci -A -m a
8 adding a
8 adding a
9
9
10 $ hg clone a b
10 $ hg clone a b
11 updating to branch default
11 updating to branch default
12 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
12 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
13
13
14 Test that raising an exception in the release function doesn't cause the lock to choke
14 Test that raising an exception in the release function doesn't cause the lock to choke
15
15
16 $ cat > testlock.py << EOF
16 $ cat > testlock.py << EOF
17 > from mercurial import error, registrar
17 > from mercurial import error, registrar
18 >
18 >
19 > cmdtable = {}
19 > cmdtable = {}
20 > command = registrar.command(cmdtable)
20 > command = registrar.command(cmdtable)
21 >
21 >
22 > def acquiretestlock(repo, releaseexc):
22 > def acquiretestlock(repo, releaseexc):
23 > def unlock():
23 > def unlock():
24 > if releaseexc:
24 > if releaseexc:
25 > raise error.Abort('expected release exception')
25 > raise error.Abort('expected release exception')
26 > l = repo._lock(repo.vfs, 'testlock', False, unlock, None, 'test lock')
26 > l = repo._lock(repo.vfs, 'testlock', False, unlock, None, 'test lock')
27 > return l
27 > return l
28 >
28 >
29 > @command(b'testlockexc')
29 > @command(b'testlockexc')
30 > def testlockexc(ui, repo):
30 > def testlockexc(ui, repo):
31 > testlock = acquiretestlock(repo, True)
31 > testlock = acquiretestlock(repo, True)
32 > try:
32 > try:
33 > testlock.release()
33 > testlock.release()
34 > finally:
34 > finally:
35 > try:
35 > try:
36 > testlock = acquiretestlock(repo, False)
36 > testlock = acquiretestlock(repo, False)
37 > except error.LockHeld:
37 > except error.LockHeld:
38 > raise error.Abort('lockfile on disk even after releasing!')
38 > raise error.Abort('lockfile on disk even after releasing!')
39 > testlock.release()
39 > testlock.release()
40 > EOF
40 > EOF
41 $ cat >> $HGRCPATH << EOF
41 $ cat >> $HGRCPATH << EOF
42 > [extensions]
42 > [extensions]
43 > testlock=$TESTTMP/testlock.py
43 > testlock=$TESTTMP/testlock.py
44 > EOF
44 > EOF
45
45
46 $ hg -R b testlockexc
46 $ hg -R b testlockexc
47 abort: expected release exception
47 abort: expected release exception
48 [255]
48 [255]
49
49
50 One process waiting for another
50 One process waiting for another
51
51
52 $ cat > hooks.py << EOF
52 $ cat > hooks.py << EOF
53 > import time
53 > import time
54 > def sleepone(**x): time.sleep(1)
54 > def sleepone(**x): time.sleep(1)
55 > def sleephalf(**x): time.sleep(0.5)
55 > def sleephalf(**x): time.sleep(0.5)
56 > EOF
56 > EOF
57 $ echo b > b/b
57 $ echo b > b/b
58 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
58 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
59 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
59 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
60 > > preup 2>&1
60 > > preup-stdout 2>preup-stderr
61 $ wait
61 $ wait
62 $ cat preup
62 $ cat preup-stdout
63 $ cat preup-stderr
63 waiting for lock on working directory of b held by process '*' on host '*' (glob)
64 waiting for lock on working directory of b held by process '*' on host '*' (glob)
64 got lock after * seconds (glob)
65 got lock after * seconds (glob)
65 $ cat stdout
66 $ cat stdout
66 adding b
67 adding b
67
68
69 On processs waiting on another, warning after a long time.
70
71 $ echo b > b/c
72 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
73 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
74 > --config ui.timeout.warn=250 \
75 > > preup-stdout 2>preup-stderr
76 $ wait
77 $ cat preup-stdout
78 $ cat preup-stderr
79 $ cat stdout
80 adding c
81
82 On processs waiting on another, warning disabled.
83
84 $ echo b > b/d
85 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
86 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
87 > --config ui.timeout.warn=-1 \
88 > > preup-stdout 2>preup-stderr
89 $ wait
90 $ cat preup-stdout
91 $ cat preup-stderr
92 $ cat stdout
93 adding d
94
95 check we still print debug output
96
97 On processs waiting on another, warning after a long time (debug output on)
98
99 $ echo b > b/e
100 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
101 $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
102 > --config ui.timeout.warn=250 --debug\
103 > > preup-stdout 2>preup-stderr
104 $ wait
105 $ cat preup-stdout
106 calling hook pre-update: hghook_pre-update.sleephalf
107 waiting for lock on working directory of b held by process '*' on host '*' (glob)
108 got lock after * seconds (glob)
109 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 $ cat preup-stderr
111 $ cat stdout
112 adding e
113
114 On processs waiting on another, warning disabled, (debug output on)
115
116 $ echo b > b/f
117 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
118 $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
119 > --config ui.timeout.warn=-1 --debug\
120 > > preup-stdout 2>preup-stderr
121 $ wait
122 $ cat preup-stdout
123 calling hook pre-update: hghook_pre-update.sleephalf
124 waiting for lock on working directory of b held by process '*' on host '*' (glob)
125 got lock after * seconds (glob)
126 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
127 $ cat preup-stderr
128 $ cat stdout
129 adding f
130
68 Pushing to a local read-only repo that can't be locked
131 Pushing to a local read-only repo that can't be locked
69
132
70 $ chmod 100 a/.hg/store
133 $ chmod 100 a/.hg/store
71
134
72 $ hg -R b push a
135 $ hg -R b push a
73 pushing to a
136 pushing to a
74 searching for changes
137 searching for changes
75 abort: could not lock repository a: Permission denied
138 abort: could not lock repository a: Permission denied
76 [255]
139 [255]
77
140
78 $ chmod 700 a/.hg/store
141 $ chmod 700 a/.hg/store
General Comments 0
You need to be logged in to leave comments. Login now