Show More
The requested changes are too big and content was truncated. Show full diff
|
1 | NO CONTENT: new file 100644 | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,2703 +1,2709 b'' | |||
|
1 | 1 | # configitems.py - centralized declaration of configuration option |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import functools |
|
11 | 11 | import re |
|
12 | 12 | |
|
13 | 13 | from . import ( |
|
14 | 14 | encoding, |
|
15 | 15 | error, |
|
16 | 16 | ) |
|
17 | 17 | |
|
18 | 18 | |
|
19 | 19 | def loadconfigtable(ui, extname, configtable): |
|
20 | 20 | """update config item known to the ui with the extension ones""" |
|
21 | 21 | for section, items in sorted(configtable.items()): |
|
22 | 22 | knownitems = ui._knownconfig.setdefault(section, itemregister()) |
|
23 | 23 | knownkeys = set(knownitems) |
|
24 | 24 | newkeys = set(items) |
|
25 | 25 | for key in sorted(knownkeys & newkeys): |
|
26 | 26 | msg = b"extension '%s' overwrite config item '%s.%s'" |
|
27 | 27 | msg %= (extname, section, key) |
|
28 | 28 | ui.develwarn(msg, config=b'warn-config') |
|
29 | 29 | |
|
30 | 30 | knownitems.update(items) |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | class configitem(object): |
|
34 | 34 | """represent a known config item |
|
35 | 35 | |
|
36 | 36 | :section: the official config section where to find this item, |
|
37 | 37 | :name: the official name within the section, |
|
38 | 38 | :default: default value for this item, |
|
39 | 39 | :alias: optional list of tuples as alternatives, |
|
40 | 40 | :generic: this is a generic definition, match name using regular expression. |
|
41 | 41 | """ |
|
42 | 42 | |
|
43 | 43 | def __init__( |
|
44 | 44 | self, |
|
45 | 45 | section, |
|
46 | 46 | name, |
|
47 | 47 | default=None, |
|
48 | 48 | alias=(), |
|
49 | 49 | generic=False, |
|
50 | 50 | priority=0, |
|
51 | 51 | experimental=False, |
|
52 | 52 | ): |
|
53 | 53 | self.section = section |
|
54 | 54 | self.name = name |
|
55 | 55 | self.default = default |
|
56 | 56 | self.alias = list(alias) |
|
57 | 57 | self.generic = generic |
|
58 | 58 | self.priority = priority |
|
59 | 59 | self.experimental = experimental |
|
60 | 60 | self._re = None |
|
61 | 61 | if generic: |
|
62 | 62 | self._re = re.compile(self.name) |
|
63 | 63 | |
|
64 | 64 | |
|
65 | 65 | class itemregister(dict): |
|
66 | 66 | """A specialized dictionary that can handle wild-card selection""" |
|
67 | 67 | |
|
68 | 68 | def __init__(self): |
|
69 | 69 | super(itemregister, self).__init__() |
|
70 | 70 | self._generics = set() |
|
71 | 71 | |
|
72 | 72 | def update(self, other): |
|
73 | 73 | super(itemregister, self).update(other) |
|
74 | 74 | self._generics.update(other._generics) |
|
75 | 75 | |
|
76 | 76 | def __setitem__(self, key, item): |
|
77 | 77 | super(itemregister, self).__setitem__(key, item) |
|
78 | 78 | if item.generic: |
|
79 | 79 | self._generics.add(item) |
|
80 | 80 | |
|
81 | 81 | def get(self, key): |
|
82 | 82 | baseitem = super(itemregister, self).get(key) |
|
83 | 83 | if baseitem is not None and not baseitem.generic: |
|
84 | 84 | return baseitem |
|
85 | 85 | |
|
86 | 86 | # search for a matching generic item |
|
87 | 87 | generics = sorted(self._generics, key=(lambda x: (x.priority, x.name))) |
|
88 | 88 | for item in generics: |
|
89 | 89 | # we use 'match' instead of 'search' to make the matching simpler |
|
90 | 90 | # for people unfamiliar with regular expression. Having the match |
|
91 | 91 | # rooted to the start of the string will produce less surprising |
|
92 | 92 | # result for user writing simple regex for sub-attribute. |
|
93 | 93 | # |
|
94 | 94 | # For example using "color\..*" match produces an unsurprising |
|
95 | 95 | # result, while using search could suddenly match apparently |
|
96 | 96 | # unrelated configuration that happens to contains "color." |
|
97 | 97 | # anywhere. This is a tradeoff where we favor requiring ".*" on |
|
98 | 98 | # some match to avoid the need to prefix most pattern with "^". |
|
99 | 99 | # The "^" seems more error prone. |
|
100 | 100 | if item._re.match(key): |
|
101 | 101 | return item |
|
102 | 102 | |
|
103 | 103 | return None |
|
104 | 104 | |
|
105 | 105 | |
|
106 | 106 | coreitems = {} |
|
107 | 107 | |
|
108 | 108 | |
|
109 | 109 | def _register(configtable, *args, **kwargs): |
|
110 | 110 | item = configitem(*args, **kwargs) |
|
111 | 111 | section = configtable.setdefault(item.section, itemregister()) |
|
112 | 112 | if item.name in section: |
|
113 | 113 | msg = b"duplicated config item registration for '%s.%s'" |
|
114 | 114 | raise error.ProgrammingError(msg % (item.section, item.name)) |
|
115 | 115 | section[item.name] = item |
|
116 | 116 | |
|
117 | 117 | |
|
118 | 118 | # special value for case where the default is derived from other values |
|
119 | 119 | dynamicdefault = object() |
|
120 | 120 | |
|
121 | 121 | # Registering actual config items |
|
122 | 122 | |
|
123 | 123 | |
|
124 | 124 | def getitemregister(configtable): |
|
125 | 125 | f = functools.partial(_register, configtable) |
|
126 | 126 | # export pseudo enum as configitem.* |
|
127 | 127 | f.dynamicdefault = dynamicdefault |
|
128 | 128 | return f |
|
129 | 129 | |
|
130 | 130 | |
|
131 | 131 | coreconfigitem = getitemregister(coreitems) |
|
132 | 132 | |
|
133 | 133 | |
|
134 | 134 | def _registerdiffopts(section, configprefix=b''): |
|
135 | 135 | coreconfigitem( |
|
136 | 136 | section, |
|
137 | 137 | configprefix + b'nodates', |
|
138 | 138 | default=False, |
|
139 | 139 | ) |
|
140 | 140 | coreconfigitem( |
|
141 | 141 | section, |
|
142 | 142 | configprefix + b'showfunc', |
|
143 | 143 | default=False, |
|
144 | 144 | ) |
|
145 | 145 | coreconfigitem( |
|
146 | 146 | section, |
|
147 | 147 | configprefix + b'unified', |
|
148 | 148 | default=None, |
|
149 | 149 | ) |
|
150 | 150 | coreconfigitem( |
|
151 | 151 | section, |
|
152 | 152 | configprefix + b'git', |
|
153 | 153 | default=False, |
|
154 | 154 | ) |
|
155 | 155 | coreconfigitem( |
|
156 | 156 | section, |
|
157 | 157 | configprefix + b'ignorews', |
|
158 | 158 | default=False, |
|
159 | 159 | ) |
|
160 | 160 | coreconfigitem( |
|
161 | 161 | section, |
|
162 | 162 | configprefix + b'ignorewsamount', |
|
163 | 163 | default=False, |
|
164 | 164 | ) |
|
165 | 165 | coreconfigitem( |
|
166 | 166 | section, |
|
167 | 167 | configprefix + b'ignoreblanklines', |
|
168 | 168 | default=False, |
|
169 | 169 | ) |
|
170 | 170 | coreconfigitem( |
|
171 | 171 | section, |
|
172 | 172 | configprefix + b'ignorewseol', |
|
173 | 173 | default=False, |
|
174 | 174 | ) |
|
175 | 175 | coreconfigitem( |
|
176 | 176 | section, |
|
177 | 177 | configprefix + b'nobinary', |
|
178 | 178 | default=False, |
|
179 | 179 | ) |
|
180 | 180 | coreconfigitem( |
|
181 | 181 | section, |
|
182 | 182 | configprefix + b'noprefix', |
|
183 | 183 | default=False, |
|
184 | 184 | ) |
|
185 | 185 | coreconfigitem( |
|
186 | 186 | section, |
|
187 | 187 | configprefix + b'word-diff', |
|
188 | 188 | default=False, |
|
189 | 189 | ) |
|
190 | 190 | |
|
191 | 191 | |
|
192 | 192 | coreconfigitem( |
|
193 | 193 | b'alias', |
|
194 | 194 | b'.*', |
|
195 | 195 | default=dynamicdefault, |
|
196 | 196 | generic=True, |
|
197 | 197 | ) |
|
198 | 198 | coreconfigitem( |
|
199 | 199 | b'auth', |
|
200 | 200 | b'cookiefile', |
|
201 | 201 | default=None, |
|
202 | 202 | ) |
|
203 | 203 | _registerdiffopts(section=b'annotate') |
|
204 | 204 | # bookmarks.pushing: internal hack for discovery |
|
205 | 205 | coreconfigitem( |
|
206 | 206 | b'bookmarks', |
|
207 | 207 | b'pushing', |
|
208 | 208 | default=list, |
|
209 | 209 | ) |
|
210 | 210 | # bundle.mainreporoot: internal hack for bundlerepo |
|
211 | 211 | coreconfigitem( |
|
212 | 212 | b'bundle', |
|
213 | 213 | b'mainreporoot', |
|
214 | 214 | default=b'', |
|
215 | 215 | ) |
|
216 | 216 | coreconfigitem( |
|
217 | 217 | b'censor', |
|
218 | 218 | b'policy', |
|
219 | 219 | default=b'abort', |
|
220 | 220 | experimental=True, |
|
221 | 221 | ) |
|
222 | 222 | coreconfigitem( |
|
223 | 223 | b'chgserver', |
|
224 | 224 | b'idletimeout', |
|
225 | 225 | default=3600, |
|
226 | 226 | ) |
|
227 | 227 | coreconfigitem( |
|
228 | 228 | b'chgserver', |
|
229 | 229 | b'skiphash', |
|
230 | 230 | default=False, |
|
231 | 231 | ) |
|
232 | 232 | coreconfigitem( |
|
233 | 233 | b'cmdserver', |
|
234 | 234 | b'log', |
|
235 | 235 | default=None, |
|
236 | 236 | ) |
|
237 | 237 | coreconfigitem( |
|
238 | 238 | b'cmdserver', |
|
239 | 239 | b'max-log-files', |
|
240 | 240 | default=7, |
|
241 | 241 | ) |
|
242 | 242 | coreconfigitem( |
|
243 | 243 | b'cmdserver', |
|
244 | 244 | b'max-log-size', |
|
245 | 245 | default=b'1 MB', |
|
246 | 246 | ) |
|
247 | 247 | coreconfigitem( |
|
248 | 248 | b'cmdserver', |
|
249 | 249 | b'max-repo-cache', |
|
250 | 250 | default=0, |
|
251 | 251 | experimental=True, |
|
252 | 252 | ) |
|
253 | 253 | coreconfigitem( |
|
254 | 254 | b'cmdserver', |
|
255 | 255 | b'message-encodings', |
|
256 | 256 | default=list, |
|
257 | 257 | ) |
|
258 | 258 | coreconfigitem( |
|
259 | 259 | b'cmdserver', |
|
260 | 260 | b'track-log', |
|
261 | 261 | default=lambda: [b'chgserver', b'cmdserver', b'repocache'], |
|
262 | 262 | ) |
|
263 | 263 | coreconfigitem( |
|
264 | 264 | b'cmdserver', |
|
265 | 265 | b'shutdown-on-interrupt', |
|
266 | 266 | default=True, |
|
267 | 267 | ) |
|
268 | 268 | coreconfigitem( |
|
269 | 269 | b'color', |
|
270 | 270 | b'.*', |
|
271 | 271 | default=None, |
|
272 | 272 | generic=True, |
|
273 | 273 | ) |
|
274 | 274 | coreconfigitem( |
|
275 | 275 | b'color', |
|
276 | 276 | b'mode', |
|
277 | 277 | default=b'auto', |
|
278 | 278 | ) |
|
279 | 279 | coreconfigitem( |
|
280 | 280 | b'color', |
|
281 | 281 | b'pagermode', |
|
282 | 282 | default=dynamicdefault, |
|
283 | 283 | ) |
|
284 | 284 | coreconfigitem( |
|
285 | 285 | b'command-templates', |
|
286 | 286 | b'graphnode', |
|
287 | 287 | default=None, |
|
288 | 288 | alias=[(b'ui', b'graphnodetemplate')], |
|
289 | 289 | ) |
|
290 | 290 | coreconfigitem( |
|
291 | 291 | b'command-templates', |
|
292 | 292 | b'log', |
|
293 | 293 | default=None, |
|
294 | 294 | alias=[(b'ui', b'logtemplate')], |
|
295 | 295 | ) |
|
296 | 296 | coreconfigitem( |
|
297 | 297 | b'command-templates', |
|
298 | 298 | b'mergemarker', |
|
299 | 299 | default=( |
|
300 | 300 | b'{node|short} ' |
|
301 | 301 | b'{ifeq(tags, "tip", "", ' |
|
302 | 302 | b'ifeq(tags, "", "", "{tags} "))}' |
|
303 | 303 | b'{if(bookmarks, "{bookmarks} ")}' |
|
304 | 304 | b'{ifeq(branch, "default", "", "{branch} ")}' |
|
305 | 305 | b'- {author|user}: {desc|firstline}' |
|
306 | 306 | ), |
|
307 | 307 | alias=[(b'ui', b'mergemarkertemplate')], |
|
308 | 308 | ) |
|
309 | 309 | coreconfigitem( |
|
310 | 310 | b'command-templates', |
|
311 | 311 | b'pre-merge-tool-output', |
|
312 | 312 | default=None, |
|
313 | 313 | alias=[(b'ui', b'pre-merge-tool-output-template')], |
|
314 | 314 | ) |
|
315 | 315 | coreconfigitem( |
|
316 | 316 | b'command-templates', |
|
317 | 317 | b'oneline-summary', |
|
318 | 318 | default=None, |
|
319 | 319 | ) |
|
320 | 320 | coreconfigitem( |
|
321 | 321 | b'command-templates', |
|
322 | 322 | b'oneline-summary.*', |
|
323 | 323 | default=dynamicdefault, |
|
324 | 324 | generic=True, |
|
325 | 325 | ) |
|
326 | 326 | _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.') |
|
327 | 327 | coreconfigitem( |
|
328 | 328 | b'commands', |
|
329 | 329 | b'commit.post-status', |
|
330 | 330 | default=False, |
|
331 | 331 | ) |
|
332 | 332 | coreconfigitem( |
|
333 | 333 | b'commands', |
|
334 | 334 | b'grep.all-files', |
|
335 | 335 | default=False, |
|
336 | 336 | experimental=True, |
|
337 | 337 | ) |
|
338 | 338 | coreconfigitem( |
|
339 | 339 | b'commands', |
|
340 | 340 | b'merge.require-rev', |
|
341 | 341 | default=False, |
|
342 | 342 | ) |
|
343 | 343 | coreconfigitem( |
|
344 | 344 | b'commands', |
|
345 | 345 | b'push.require-revs', |
|
346 | 346 | default=False, |
|
347 | 347 | ) |
|
348 | 348 | coreconfigitem( |
|
349 | 349 | b'commands', |
|
350 | 350 | b'resolve.confirm', |
|
351 | 351 | default=False, |
|
352 | 352 | ) |
|
353 | 353 | coreconfigitem( |
|
354 | 354 | b'commands', |
|
355 | 355 | b'resolve.explicit-re-merge', |
|
356 | 356 | default=False, |
|
357 | 357 | ) |
|
358 | 358 | coreconfigitem( |
|
359 | 359 | b'commands', |
|
360 | 360 | b'resolve.mark-check', |
|
361 | 361 | default=b'none', |
|
362 | 362 | ) |
|
363 | 363 | _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.') |
|
364 | 364 | coreconfigitem( |
|
365 | 365 | b'commands', |
|
366 | 366 | b'show.aliasprefix', |
|
367 | 367 | default=list, |
|
368 | 368 | ) |
|
369 | 369 | coreconfigitem( |
|
370 | 370 | b'commands', |
|
371 | 371 | b'status.relative', |
|
372 | 372 | default=False, |
|
373 | 373 | ) |
|
374 | 374 | coreconfigitem( |
|
375 | 375 | b'commands', |
|
376 | 376 | b'status.skipstates', |
|
377 | 377 | default=[], |
|
378 | 378 | experimental=True, |
|
379 | 379 | ) |
|
380 | 380 | coreconfigitem( |
|
381 | 381 | b'commands', |
|
382 | 382 | b'status.terse', |
|
383 | 383 | default=b'', |
|
384 | 384 | ) |
|
385 | 385 | coreconfigitem( |
|
386 | 386 | b'commands', |
|
387 | 387 | b'status.verbose', |
|
388 | 388 | default=False, |
|
389 | 389 | ) |
|
390 | 390 | coreconfigitem( |
|
391 | 391 | b'commands', |
|
392 | 392 | b'update.check', |
|
393 | 393 | default=None, |
|
394 | 394 | ) |
|
395 | 395 | coreconfigitem( |
|
396 | 396 | b'commands', |
|
397 | 397 | b'update.requiredest', |
|
398 | 398 | default=False, |
|
399 | 399 | ) |
|
400 | 400 | coreconfigitem( |
|
401 | 401 | b'committemplate', |
|
402 | 402 | b'.*', |
|
403 | 403 | default=None, |
|
404 | 404 | generic=True, |
|
405 | 405 | ) |
|
406 | 406 | coreconfigitem( |
|
407 | 407 | b'convert', |
|
408 | 408 | b'bzr.saverev', |
|
409 | 409 | default=True, |
|
410 | 410 | ) |
|
411 | 411 | coreconfigitem( |
|
412 | 412 | b'convert', |
|
413 | 413 | b'cvsps.cache', |
|
414 | 414 | default=True, |
|
415 | 415 | ) |
|
416 | 416 | coreconfigitem( |
|
417 | 417 | b'convert', |
|
418 | 418 | b'cvsps.fuzz', |
|
419 | 419 | default=60, |
|
420 | 420 | ) |
|
421 | 421 | coreconfigitem( |
|
422 | 422 | b'convert', |
|
423 | 423 | b'cvsps.logencoding', |
|
424 | 424 | default=None, |
|
425 | 425 | ) |
|
426 | 426 | coreconfigitem( |
|
427 | 427 | b'convert', |
|
428 | 428 | b'cvsps.mergefrom', |
|
429 | 429 | default=None, |
|
430 | 430 | ) |
|
431 | 431 | coreconfigitem( |
|
432 | 432 | b'convert', |
|
433 | 433 | b'cvsps.mergeto', |
|
434 | 434 | default=None, |
|
435 | 435 | ) |
|
436 | 436 | coreconfigitem( |
|
437 | 437 | b'convert', |
|
438 | 438 | b'git.committeractions', |
|
439 | 439 | default=lambda: [b'messagedifferent'], |
|
440 | 440 | ) |
|
441 | 441 | coreconfigitem( |
|
442 | 442 | b'convert', |
|
443 | 443 | b'git.extrakeys', |
|
444 | 444 | default=list, |
|
445 | 445 | ) |
|
446 | 446 | coreconfigitem( |
|
447 | 447 | b'convert', |
|
448 | 448 | b'git.findcopiesharder', |
|
449 | 449 | default=False, |
|
450 | 450 | ) |
|
451 | 451 | coreconfigitem( |
|
452 | 452 | b'convert', |
|
453 | 453 | b'git.remoteprefix', |
|
454 | 454 | default=b'remote', |
|
455 | 455 | ) |
|
456 | 456 | coreconfigitem( |
|
457 | 457 | b'convert', |
|
458 | 458 | b'git.renamelimit', |
|
459 | 459 | default=400, |
|
460 | 460 | ) |
|
461 | 461 | coreconfigitem( |
|
462 | 462 | b'convert', |
|
463 | 463 | b'git.saverev', |
|
464 | 464 | default=True, |
|
465 | 465 | ) |
|
466 | 466 | coreconfigitem( |
|
467 | 467 | b'convert', |
|
468 | 468 | b'git.similarity', |
|
469 | 469 | default=50, |
|
470 | 470 | ) |
|
471 | 471 | coreconfigitem( |
|
472 | 472 | b'convert', |
|
473 | 473 | b'git.skipsubmodules', |
|
474 | 474 | default=False, |
|
475 | 475 | ) |
|
476 | 476 | coreconfigitem( |
|
477 | 477 | b'convert', |
|
478 | 478 | b'hg.clonebranches', |
|
479 | 479 | default=False, |
|
480 | 480 | ) |
|
481 | 481 | coreconfigitem( |
|
482 | 482 | b'convert', |
|
483 | 483 | b'hg.ignoreerrors', |
|
484 | 484 | default=False, |
|
485 | 485 | ) |
|
486 | 486 | coreconfigitem( |
|
487 | 487 | b'convert', |
|
488 | 488 | b'hg.preserve-hash', |
|
489 | 489 | default=False, |
|
490 | 490 | ) |
|
491 | 491 | coreconfigitem( |
|
492 | 492 | b'convert', |
|
493 | 493 | b'hg.revs', |
|
494 | 494 | default=None, |
|
495 | 495 | ) |
|
496 | 496 | coreconfigitem( |
|
497 | 497 | b'convert', |
|
498 | 498 | b'hg.saverev', |
|
499 | 499 | default=False, |
|
500 | 500 | ) |
|
501 | 501 | coreconfigitem( |
|
502 | 502 | b'convert', |
|
503 | 503 | b'hg.sourcename', |
|
504 | 504 | default=None, |
|
505 | 505 | ) |
|
506 | 506 | coreconfigitem( |
|
507 | 507 | b'convert', |
|
508 | 508 | b'hg.startrev', |
|
509 | 509 | default=None, |
|
510 | 510 | ) |
|
511 | 511 | coreconfigitem( |
|
512 | 512 | b'convert', |
|
513 | 513 | b'hg.tagsbranch', |
|
514 | 514 | default=b'default', |
|
515 | 515 | ) |
|
516 | 516 | coreconfigitem( |
|
517 | 517 | b'convert', |
|
518 | 518 | b'hg.usebranchnames', |
|
519 | 519 | default=True, |
|
520 | 520 | ) |
|
521 | 521 | coreconfigitem( |
|
522 | 522 | b'convert', |
|
523 | 523 | b'ignoreancestorcheck', |
|
524 | 524 | default=False, |
|
525 | 525 | experimental=True, |
|
526 | 526 | ) |
|
527 | 527 | coreconfigitem( |
|
528 | 528 | b'convert', |
|
529 | 529 | b'localtimezone', |
|
530 | 530 | default=False, |
|
531 | 531 | ) |
|
532 | 532 | coreconfigitem( |
|
533 | 533 | b'convert', |
|
534 | 534 | b'p4.encoding', |
|
535 | 535 | default=dynamicdefault, |
|
536 | 536 | ) |
|
537 | 537 | coreconfigitem( |
|
538 | 538 | b'convert', |
|
539 | 539 | b'p4.startrev', |
|
540 | 540 | default=0, |
|
541 | 541 | ) |
|
542 | 542 | coreconfigitem( |
|
543 | 543 | b'convert', |
|
544 | 544 | b'skiptags', |
|
545 | 545 | default=False, |
|
546 | 546 | ) |
|
547 | 547 | coreconfigitem( |
|
548 | 548 | b'convert', |
|
549 | 549 | b'svn.debugsvnlog', |
|
550 | 550 | default=True, |
|
551 | 551 | ) |
|
552 | 552 | coreconfigitem( |
|
553 | 553 | b'convert', |
|
554 | 554 | b'svn.trunk', |
|
555 | 555 | default=None, |
|
556 | 556 | ) |
|
557 | 557 | coreconfigitem( |
|
558 | 558 | b'convert', |
|
559 | 559 | b'svn.tags', |
|
560 | 560 | default=None, |
|
561 | 561 | ) |
|
562 | 562 | coreconfigitem( |
|
563 | 563 | b'convert', |
|
564 | 564 | b'svn.branches', |
|
565 | 565 | default=None, |
|
566 | 566 | ) |
|
567 | 567 | coreconfigitem( |
|
568 | 568 | b'convert', |
|
569 | 569 | b'svn.startrev', |
|
570 | 570 | default=0, |
|
571 | 571 | ) |
|
572 | 572 | coreconfigitem( |
|
573 | 573 | b'convert', |
|
574 | 574 | b'svn.dangerous-set-commit-dates', |
|
575 | 575 | default=False, |
|
576 | 576 | ) |
|
577 | 577 | coreconfigitem( |
|
578 | 578 | b'debug', |
|
579 | 579 | b'dirstate.delaywrite', |
|
580 | 580 | default=0, |
|
581 | 581 | ) |
|
582 | 582 | coreconfigitem( |
|
583 | 583 | b'debug', |
|
584 | 584 | b'revlog.verifyposition.changelog', |
|
585 | 585 | default=b'', |
|
586 | 586 | ) |
|
587 | 587 | coreconfigitem( |
|
588 | 588 | b'defaults', |
|
589 | 589 | b'.*', |
|
590 | 590 | default=None, |
|
591 | 591 | generic=True, |
|
592 | 592 | ) |
|
593 | 593 | coreconfigitem( |
|
594 | 594 | b'devel', |
|
595 | 595 | b'all-warnings', |
|
596 | 596 | default=False, |
|
597 | 597 | ) |
|
598 | 598 | coreconfigitem( |
|
599 | 599 | b'devel', |
|
600 | 600 | b'bundle2.debug', |
|
601 | 601 | default=False, |
|
602 | 602 | ) |
|
603 | 603 | coreconfigitem( |
|
604 | 604 | b'devel', |
|
605 | 605 | b'bundle.delta', |
|
606 | 606 | default=b'', |
|
607 | 607 | ) |
|
608 | 608 | coreconfigitem( |
|
609 | 609 | b'devel', |
|
610 | 610 | b'cache-vfs', |
|
611 | 611 | default=None, |
|
612 | 612 | ) |
|
613 | 613 | coreconfigitem( |
|
614 | 614 | b'devel', |
|
615 | 615 | b'check-locks', |
|
616 | 616 | default=False, |
|
617 | 617 | ) |
|
618 | 618 | coreconfigitem( |
|
619 | 619 | b'devel', |
|
620 | 620 | b'check-relroot', |
|
621 | 621 | default=False, |
|
622 | 622 | ) |
|
623 | 623 | # Track copy information for all file, not just "added" one (very slow) |
|
624 | 624 | coreconfigitem( |
|
625 | 625 | b'devel', |
|
626 | 626 | b'copy-tracing.trace-all-files', |
|
627 | 627 | default=False, |
|
628 | 628 | ) |
|
629 | 629 | coreconfigitem( |
|
630 | 630 | b'devel', |
|
631 | 631 | b'default-date', |
|
632 | 632 | default=None, |
|
633 | 633 | ) |
|
634 | 634 | coreconfigitem( |
|
635 | 635 | b'devel', |
|
636 | 636 | b'deprec-warn', |
|
637 | 637 | default=False, |
|
638 | 638 | ) |
|
639 | 639 | coreconfigitem( |
|
640 | 640 | b'devel', |
|
641 | 641 | b'disableloaddefaultcerts', |
|
642 | 642 | default=False, |
|
643 | 643 | ) |
|
644 | 644 | coreconfigitem( |
|
645 | 645 | b'devel', |
|
646 | 646 | b'warn-empty-changegroup', |
|
647 | 647 | default=False, |
|
648 | 648 | ) |
|
649 | 649 | coreconfigitem( |
|
650 | 650 | b'devel', |
|
651 | 651 | b'legacy.exchange', |
|
652 | 652 | default=list, |
|
653 | 653 | ) |
|
654 | 654 | # When True, revlogs use a special reference version of the nodemap, that is not |
|
655 | 655 | # performant but is "known" to behave properly. |
|
656 | 656 | coreconfigitem( |
|
657 | 657 | b'devel', |
|
658 | 658 | b'persistent-nodemap', |
|
659 | 659 | default=False, |
|
660 | 660 | ) |
|
661 | 661 | coreconfigitem( |
|
662 | 662 | b'devel', |
|
663 | 663 | b'servercafile', |
|
664 | 664 | default=b'', |
|
665 | 665 | ) |
|
666 | 666 | coreconfigitem( |
|
667 | 667 | b'devel', |
|
668 | 668 | b'serverexactprotocol', |
|
669 | 669 | default=b'', |
|
670 | 670 | ) |
|
671 | 671 | coreconfigitem( |
|
672 | 672 | b'devel', |
|
673 | 673 | b'serverrequirecert', |
|
674 | 674 | default=False, |
|
675 | 675 | ) |
|
676 | 676 | coreconfigitem( |
|
677 | 677 | b'devel', |
|
678 | 678 | b'strip-obsmarkers', |
|
679 | 679 | default=True, |
|
680 | 680 | ) |
|
681 | 681 | coreconfigitem( |
|
682 | 682 | b'devel', |
|
683 | 683 | b'warn-config', |
|
684 | 684 | default=None, |
|
685 | 685 | ) |
|
686 | 686 | coreconfigitem( |
|
687 | 687 | b'devel', |
|
688 | 688 | b'warn-config-default', |
|
689 | 689 | default=None, |
|
690 | 690 | ) |
|
691 | 691 | coreconfigitem( |
|
692 | 692 | b'devel', |
|
693 | 693 | b'user.obsmarker', |
|
694 | 694 | default=None, |
|
695 | 695 | ) |
|
696 | 696 | coreconfigitem( |
|
697 | 697 | b'devel', |
|
698 | 698 | b'warn-config-unknown', |
|
699 | 699 | default=None, |
|
700 | 700 | ) |
|
701 | 701 | coreconfigitem( |
|
702 | 702 | b'devel', |
|
703 | 703 | b'debug.copies', |
|
704 | 704 | default=False, |
|
705 | 705 | ) |
|
706 | 706 | coreconfigitem( |
|
707 | 707 | b'devel', |
|
708 | 708 | b'copy-tracing.multi-thread', |
|
709 | 709 | default=True, |
|
710 | 710 | ) |
|
711 | 711 | coreconfigitem( |
|
712 | 712 | b'devel', |
|
713 | 713 | b'debug.extensions', |
|
714 | 714 | default=False, |
|
715 | 715 | ) |
|
716 | 716 | coreconfigitem( |
|
717 | 717 | b'devel', |
|
718 | 718 | b'debug.repo-filters', |
|
719 | 719 | default=False, |
|
720 | 720 | ) |
|
721 | 721 | coreconfigitem( |
|
722 | 722 | b'devel', |
|
723 | 723 | b'debug.peer-request', |
|
724 | 724 | default=False, |
|
725 | 725 | ) |
|
726 | 726 | # If discovery.exchange-heads is False, the discovery will not start with |
|
727 | 727 | # remote head fetching and local head querying. |
|
728 | 728 | coreconfigitem( |
|
729 | 729 | b'devel', |
|
730 | 730 | b'discovery.exchange-heads', |
|
731 | 731 | default=True, |
|
732 | 732 | ) |
|
733 | 733 | # If discovery.grow-sample is False, the sample size used in set discovery will |
|
734 | 734 | # not be increased through the process |
|
735 | 735 | coreconfigitem( |
|
736 | 736 | b'devel', |
|
737 | 737 | b'discovery.grow-sample', |
|
738 | 738 | default=True, |
|
739 | 739 | ) |
|
740 | 740 | # When discovery.grow-sample.dynamic is True, the default, the sample size is |
|
741 | 741 | # adapted to the shape of the undecided set (it is set to the max of: |
|
742 | 742 | # <target-size>, len(roots(undecided)), len(heads(undecided) |
|
743 | 743 | coreconfigitem( |
|
744 | 744 | b'devel', |
|
745 | 745 | b'discovery.grow-sample.dynamic', |
|
746 | 746 | default=True, |
|
747 | 747 | ) |
|
748 | 748 | # discovery.grow-sample.rate control the rate at which the sample grow |
|
749 | 749 | coreconfigitem( |
|
750 | 750 | b'devel', |
|
751 | 751 | b'discovery.grow-sample.rate', |
|
752 | 752 | default=1.05, |
|
753 | 753 | ) |
|
754 | 754 | # If discovery.randomize is False, random sampling during discovery are |
|
755 | 755 | # deterministic. It is meant for integration tests. |
|
756 | 756 | coreconfigitem( |
|
757 | 757 | b'devel', |
|
758 | 758 | b'discovery.randomize', |
|
759 | 759 | default=True, |
|
760 | 760 | ) |
|
761 | 761 | # Control the initial size of the discovery sample |
|
762 | 762 | coreconfigitem( |
|
763 | 763 | b'devel', |
|
764 | 764 | b'discovery.sample-size', |
|
765 | 765 | default=200, |
|
766 | 766 | ) |
|
767 | 767 | # Control the initial size of the discovery for initial change |
|
768 | 768 | coreconfigitem( |
|
769 | 769 | b'devel', |
|
770 | 770 | b'discovery.sample-size.initial', |
|
771 | 771 | default=100, |
|
772 | 772 | ) |
|
773 | 773 | _registerdiffopts(section=b'diff') |
|
774 | 774 | coreconfigitem( |
|
775 | 775 | b'diff', |
|
776 | 776 | b'merge', |
|
777 | 777 | default=False, |
|
778 | 778 | experimental=True, |
|
779 | 779 | ) |
|
780 | 780 | coreconfigitem( |
|
781 | 781 | b'email', |
|
782 | 782 | b'bcc', |
|
783 | 783 | default=None, |
|
784 | 784 | ) |
|
785 | 785 | coreconfigitem( |
|
786 | 786 | b'email', |
|
787 | 787 | b'cc', |
|
788 | 788 | default=None, |
|
789 | 789 | ) |
|
790 | 790 | coreconfigitem( |
|
791 | 791 | b'email', |
|
792 | 792 | b'charsets', |
|
793 | 793 | default=list, |
|
794 | 794 | ) |
|
795 | 795 | coreconfigitem( |
|
796 | 796 | b'email', |
|
797 | 797 | b'from', |
|
798 | 798 | default=None, |
|
799 | 799 | ) |
|
800 | 800 | coreconfigitem( |
|
801 | 801 | b'email', |
|
802 | 802 | b'method', |
|
803 | 803 | default=b'smtp', |
|
804 | 804 | ) |
|
805 | 805 | coreconfigitem( |
|
806 | 806 | b'email', |
|
807 | 807 | b'reply-to', |
|
808 | 808 | default=None, |
|
809 | 809 | ) |
|
810 | 810 | coreconfigitem( |
|
811 | 811 | b'email', |
|
812 | 812 | b'to', |
|
813 | 813 | default=None, |
|
814 | 814 | ) |
|
815 | 815 | coreconfigitem( |
|
816 | 816 | b'experimental', |
|
817 | 817 | b'archivemetatemplate', |
|
818 | 818 | default=dynamicdefault, |
|
819 | 819 | ) |
|
820 | 820 | coreconfigitem( |
|
821 | 821 | b'experimental', |
|
822 | 822 | b'auto-publish', |
|
823 | 823 | default=b'publish', |
|
824 | 824 | ) |
|
825 | 825 | coreconfigitem( |
|
826 | 826 | b'experimental', |
|
827 | 827 | b'bundle-phases', |
|
828 | 828 | default=False, |
|
829 | 829 | ) |
|
830 | 830 | coreconfigitem( |
|
831 | 831 | b'experimental', |
|
832 | 832 | b'bundle2-advertise', |
|
833 | 833 | default=True, |
|
834 | 834 | ) |
|
835 | 835 | coreconfigitem( |
|
836 | 836 | b'experimental', |
|
837 | 837 | b'bundle2-output-capture', |
|
838 | 838 | default=False, |
|
839 | 839 | ) |
|
840 | 840 | coreconfigitem( |
|
841 | 841 | b'experimental', |
|
842 | 842 | b'bundle2.pushback', |
|
843 | 843 | default=False, |
|
844 | 844 | ) |
|
845 | 845 | coreconfigitem( |
|
846 | 846 | b'experimental', |
|
847 | 847 | b'bundle2lazylocking', |
|
848 | 848 | default=False, |
|
849 | 849 | ) |
|
850 | 850 | coreconfigitem( |
|
851 | 851 | b'experimental', |
|
852 | 852 | b'bundlecomplevel', |
|
853 | 853 | default=None, |
|
854 | 854 | ) |
|
855 | 855 | coreconfigitem( |
|
856 | 856 | b'experimental', |
|
857 | 857 | b'bundlecomplevel.bzip2', |
|
858 | 858 | default=None, |
|
859 | 859 | ) |
|
860 | 860 | coreconfigitem( |
|
861 | 861 | b'experimental', |
|
862 | 862 | b'bundlecomplevel.gzip', |
|
863 | 863 | default=None, |
|
864 | 864 | ) |
|
865 | 865 | coreconfigitem( |
|
866 | 866 | b'experimental', |
|
867 | 867 | b'bundlecomplevel.none', |
|
868 | 868 | default=None, |
|
869 | 869 | ) |
|
870 | 870 | coreconfigitem( |
|
871 | 871 | b'experimental', |
|
872 | 872 | b'bundlecomplevel.zstd', |
|
873 | 873 | default=None, |
|
874 | 874 | ) |
|
875 | 875 | coreconfigitem( |
|
876 | 876 | b'experimental', |
|
877 | 877 | b'bundlecompthreads', |
|
878 | 878 | default=None, |
|
879 | 879 | ) |
|
880 | 880 | coreconfigitem( |
|
881 | 881 | b'experimental', |
|
882 | 882 | b'bundlecompthreads.bzip2', |
|
883 | 883 | default=None, |
|
884 | 884 | ) |
|
885 | 885 | coreconfigitem( |
|
886 | 886 | b'experimental', |
|
887 | 887 | b'bundlecompthreads.gzip', |
|
888 | 888 | default=None, |
|
889 | 889 | ) |
|
890 | 890 | coreconfigitem( |
|
891 | 891 | b'experimental', |
|
892 | 892 | b'bundlecompthreads.none', |
|
893 | 893 | default=None, |
|
894 | 894 | ) |
|
895 | 895 | coreconfigitem( |
|
896 | 896 | b'experimental', |
|
897 | 897 | b'bundlecompthreads.zstd', |
|
898 | 898 | default=None, |
|
899 | 899 | ) |
|
900 | 900 | coreconfigitem( |
|
901 | 901 | b'experimental', |
|
902 | 902 | b'changegroup3', |
|
903 | 903 | default=False, |
|
904 | 904 | ) |
|
905 | 905 | coreconfigitem( |
|
906 | 906 | b'experimental', |
|
907 | 907 | b'changegroup4', |
|
908 | 908 | default=False, |
|
909 | 909 | ) |
|
910 | 910 | coreconfigitem( |
|
911 | 911 | b'experimental', |
|
912 | 912 | b'cleanup-as-archived', |
|
913 | 913 | default=False, |
|
914 | 914 | ) |
|
915 | 915 | coreconfigitem( |
|
916 | 916 | b'experimental', |
|
917 | 917 | b'clientcompressionengines', |
|
918 | 918 | default=list, |
|
919 | 919 | ) |
|
920 | 920 | coreconfigitem( |
|
921 | 921 | b'experimental', |
|
922 | 922 | b'copytrace', |
|
923 | 923 | default=b'on', |
|
924 | 924 | ) |
|
925 | 925 | coreconfigitem( |
|
926 | 926 | b'experimental', |
|
927 | 927 | b'copytrace.movecandidateslimit', |
|
928 | 928 | default=100, |
|
929 | 929 | ) |
|
930 | 930 | coreconfigitem( |
|
931 | 931 | b'experimental', |
|
932 | 932 | b'copytrace.sourcecommitlimit', |
|
933 | 933 | default=100, |
|
934 | 934 | ) |
|
935 | 935 | coreconfigitem( |
|
936 | 936 | b'experimental', |
|
937 | 937 | b'copies.read-from', |
|
938 | 938 | default=b"filelog-only", |
|
939 | 939 | ) |
|
940 | 940 | coreconfigitem( |
|
941 | 941 | b'experimental', |
|
942 | 942 | b'copies.write-to', |
|
943 | 943 | default=b'filelog-only', |
|
944 | 944 | ) |
|
945 | 945 | coreconfigitem( |
|
946 | 946 | b'experimental', |
|
947 | 947 | b'crecordtest', |
|
948 | 948 | default=None, |
|
949 | 949 | ) |
|
950 | 950 | coreconfigitem( |
|
951 | 951 | b'experimental', |
|
952 | 952 | b'directaccess', |
|
953 | 953 | default=False, |
|
954 | 954 | ) |
|
955 | 955 | coreconfigitem( |
|
956 | 956 | b'experimental', |
|
957 | 957 | b'directaccess.revnums', |
|
958 | 958 | default=False, |
|
959 | 959 | ) |
|
960 | 960 | coreconfigitem( |
|
961 | 961 | b'experimental', |
|
962 | 962 | b'editortmpinhg', |
|
963 | 963 | default=False, |
|
964 | 964 | ) |
|
965 | 965 | coreconfigitem( |
|
966 | 966 | b'experimental', |
|
967 | 967 | b'evolution', |
|
968 | 968 | default=list, |
|
969 | 969 | ) |
|
970 | 970 | coreconfigitem( |
|
971 | 971 | b'experimental', |
|
972 | 972 | b'evolution.allowdivergence', |
|
973 | 973 | default=False, |
|
974 | 974 | alias=[(b'experimental', b'allowdivergence')], |
|
975 | 975 | ) |
|
976 | 976 | coreconfigitem( |
|
977 | 977 | b'experimental', |
|
978 | 978 | b'evolution.allowunstable', |
|
979 | 979 | default=None, |
|
980 | 980 | ) |
|
981 | 981 | coreconfigitem( |
|
982 | 982 | b'experimental', |
|
983 | 983 | b'evolution.createmarkers', |
|
984 | 984 | default=None, |
|
985 | 985 | ) |
|
986 | 986 | coreconfigitem( |
|
987 | 987 | b'experimental', |
|
988 | 988 | b'evolution.effect-flags', |
|
989 | 989 | default=True, |
|
990 | 990 | alias=[(b'experimental', b'effect-flags')], |
|
991 | 991 | ) |
|
992 | 992 | coreconfigitem( |
|
993 | 993 | b'experimental', |
|
994 | 994 | b'evolution.exchange', |
|
995 | 995 | default=None, |
|
996 | 996 | ) |
|
997 | 997 | coreconfigitem( |
|
998 | 998 | b'experimental', |
|
999 | 999 | b'evolution.bundle-obsmarker', |
|
1000 | 1000 | default=False, |
|
1001 | 1001 | ) |
|
1002 | 1002 | coreconfigitem( |
|
1003 | 1003 | b'experimental', |
|
1004 | 1004 | b'evolution.bundle-obsmarker:mandatory', |
|
1005 | 1005 | default=True, |
|
1006 | 1006 | ) |
|
1007 | 1007 | coreconfigitem( |
|
1008 | 1008 | b'experimental', |
|
1009 | 1009 | b'log.topo', |
|
1010 | 1010 | default=False, |
|
1011 | 1011 | ) |
|
1012 | 1012 | coreconfigitem( |
|
1013 | 1013 | b'experimental', |
|
1014 | 1014 | b'evolution.report-instabilities', |
|
1015 | 1015 | default=True, |
|
1016 | 1016 | ) |
|
1017 | 1017 | coreconfigitem( |
|
1018 | 1018 | b'experimental', |
|
1019 | 1019 | b'evolution.track-operation', |
|
1020 | 1020 | default=True, |
|
1021 | 1021 | ) |
|
1022 | 1022 | # repo-level config to exclude a revset visibility |
|
1023 | 1023 | # |
|
1024 | 1024 | # The target use case is to use `share` to expose different subset of the same |
|
1025 | 1025 | # repository, especially server side. See also `server.view`. |
|
1026 | 1026 | coreconfigitem( |
|
1027 | 1027 | b'experimental', |
|
1028 | 1028 | b'extra-filter-revs', |
|
1029 | 1029 | default=None, |
|
1030 | 1030 | ) |
|
1031 | 1031 | coreconfigitem( |
|
1032 | 1032 | b'experimental', |
|
1033 | 1033 | b'maxdeltachainspan', |
|
1034 | 1034 | default=-1, |
|
1035 | 1035 | ) |
|
1036 | 1036 | # tracks files which were undeleted (merge might delete them but we explicitly |
|
1037 | 1037 | # kept/undeleted them) and creates new filenodes for them |
|
1038 | 1038 | coreconfigitem( |
|
1039 | 1039 | b'experimental', |
|
1040 | 1040 | b'merge-track-salvaged', |
|
1041 | 1041 | default=False, |
|
1042 | 1042 | ) |
|
1043 | 1043 | coreconfigitem( |
|
1044 | 1044 | b'experimental', |
|
1045 | 1045 | b'mergetempdirprefix', |
|
1046 | 1046 | default=None, |
|
1047 | 1047 | ) |
|
1048 | 1048 | coreconfigitem( |
|
1049 | 1049 | b'experimental', |
|
1050 | 1050 | b'mmapindexthreshold', |
|
1051 | 1051 | default=None, |
|
1052 | 1052 | ) |
|
1053 | 1053 | coreconfigitem( |
|
1054 | 1054 | b'experimental', |
|
1055 | 1055 | b'narrow', |
|
1056 | 1056 | default=False, |
|
1057 | 1057 | ) |
|
1058 | 1058 | coreconfigitem( |
|
1059 | 1059 | b'experimental', |
|
1060 | 1060 | b'nonnormalparanoidcheck', |
|
1061 | 1061 | default=False, |
|
1062 | 1062 | ) |
|
1063 | 1063 | coreconfigitem( |
|
1064 | 1064 | b'experimental', |
|
1065 | 1065 | b'exportableenviron', |
|
1066 | 1066 | default=list, |
|
1067 | 1067 | ) |
|
1068 | 1068 | coreconfigitem( |
|
1069 | 1069 | b'experimental', |
|
1070 | 1070 | b'extendedheader.index', |
|
1071 | 1071 | default=None, |
|
1072 | 1072 | ) |
|
1073 | 1073 | coreconfigitem( |
|
1074 | 1074 | b'experimental', |
|
1075 | 1075 | b'extendedheader.similarity', |
|
1076 | 1076 | default=False, |
|
1077 | 1077 | ) |
|
1078 | 1078 | coreconfigitem( |
|
1079 | 1079 | b'experimental', |
|
1080 | 1080 | b'graphshorten', |
|
1081 | 1081 | default=False, |
|
1082 | 1082 | ) |
|
1083 | 1083 | coreconfigitem( |
|
1084 | 1084 | b'experimental', |
|
1085 | 1085 | b'graphstyle.parent', |
|
1086 | 1086 | default=dynamicdefault, |
|
1087 | 1087 | ) |
|
1088 | 1088 | coreconfigitem( |
|
1089 | 1089 | b'experimental', |
|
1090 | 1090 | b'graphstyle.missing', |
|
1091 | 1091 | default=dynamicdefault, |
|
1092 | 1092 | ) |
|
1093 | 1093 | coreconfigitem( |
|
1094 | 1094 | b'experimental', |
|
1095 | 1095 | b'graphstyle.grandparent', |
|
1096 | 1096 | default=dynamicdefault, |
|
1097 | 1097 | ) |
|
1098 | 1098 | coreconfigitem( |
|
1099 | 1099 | b'experimental', |
|
1100 | 1100 | b'hook-track-tags', |
|
1101 | 1101 | default=False, |
|
1102 | 1102 | ) |
|
1103 | 1103 | coreconfigitem( |
|
1104 | 1104 | b'experimental', |
|
1105 | 1105 | b'httppostargs', |
|
1106 | 1106 | default=False, |
|
1107 | 1107 | ) |
|
1108 | 1108 | coreconfigitem(b'experimental', b'nointerrupt', default=False) |
|
1109 | 1109 | coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True) |
|
1110 | 1110 | |
|
1111 | 1111 | coreconfigitem( |
|
1112 | 1112 | b'experimental', |
|
1113 | 1113 | b'obsmarkers-exchange-debug', |
|
1114 | 1114 | default=False, |
|
1115 | 1115 | ) |
|
1116 | 1116 | coreconfigitem( |
|
1117 | 1117 | b'experimental', |
|
1118 | 1118 | b'remotenames', |
|
1119 | 1119 | default=False, |
|
1120 | 1120 | ) |
|
1121 | 1121 | coreconfigitem( |
|
1122 | 1122 | b'experimental', |
|
1123 | 1123 | b'removeemptydirs', |
|
1124 | 1124 | default=True, |
|
1125 | 1125 | ) |
|
1126 | 1126 | coreconfigitem( |
|
1127 | 1127 | b'experimental', |
|
1128 | 1128 | b'revert.interactive.select-to-keep', |
|
1129 | 1129 | default=False, |
|
1130 | 1130 | ) |
|
1131 | 1131 | coreconfigitem( |
|
1132 | 1132 | b'experimental', |
|
1133 | 1133 | b'revisions.prefixhexnode', |
|
1134 | 1134 | default=False, |
|
1135 | 1135 | ) |
|
1136 | 1136 | # "out of experimental" todo list. |
|
1137 | 1137 | # |
|
1138 | 1138 | # * include management of a persistent nodemap in the main docket |
|
1139 | 1139 | # * enforce a "no-truncate" policy for mmap safety |
|
1140 | 1140 | # - for censoring operation |
|
1141 | 1141 | # - for stripping operation |
|
1142 | 1142 | # - for rollback operation |
|
1143 | 1143 | # * proper streaming (race free) of the docket file |
|
1144 | 1144 | # * track garbage data to evemtually allow rewriting -existing- sidedata. |
|
1145 | 1145 | # * Exchange-wise, we will also need to do something more efficient than |
|
1146 | 1146 | # keeping references to the affected revlogs, especially memory-wise when |
|
1147 | 1147 | # rewriting sidedata. |
|
1148 | 1148 | # * introduce a proper solution to reduce the number of filelog related files. |
|
1149 | 1149 | # * use caching for reading sidedata (similar to what we do for data). |
|
1150 | 1150 | # * no longer set offset=0 if sidedata_size=0 (simplify cutoff computation). |
|
1151 | 1151 | # * Improvement to consider |
|
1152 | 1152 | # - avoid compression header in chunk using the default compression? |
|
1153 | 1153 | # - forbid "inline" compression mode entirely? |
|
1154 | 1154 | # - split the data offset and flag field (the 2 bytes save are mostly trouble) |
|
1155 | 1155 | # - keep track of uncompressed -chunk- size (to preallocate memory better) |
|
1156 | 1156 | # - keep track of chain base or size (probably not that useful anymore) |
|
1157 | 1157 | coreconfigitem( |
|
1158 | 1158 | b'experimental', |
|
1159 | 1159 | b'revlogv2', |
|
1160 | 1160 | default=None, |
|
1161 | 1161 | ) |
|
1162 | 1162 | coreconfigitem( |
|
1163 | 1163 | b'experimental', |
|
1164 | 1164 | b'revisions.disambiguatewithin', |
|
1165 | 1165 | default=None, |
|
1166 | 1166 | ) |
|
1167 | 1167 | coreconfigitem( |
|
1168 | 1168 | b'experimental', |
|
1169 | 1169 | b'rust.index', |
|
1170 | 1170 | default=False, |
|
1171 | 1171 | ) |
|
1172 | 1172 | coreconfigitem( |
|
1173 | 1173 | b'experimental', |
|
1174 | 1174 | b'server.filesdata.recommended-batch-size', |
|
1175 | 1175 | default=50000, |
|
1176 | 1176 | ) |
|
1177 | 1177 | coreconfigitem( |
|
1178 | 1178 | b'experimental', |
|
1179 | 1179 | b'server.manifestdata.recommended-batch-size', |
|
1180 | 1180 | default=100000, |
|
1181 | 1181 | ) |
|
1182 | 1182 | coreconfigitem( |
|
1183 | 1183 | b'experimental', |
|
1184 | 1184 | b'server.stream-narrow-clones', |
|
1185 | 1185 | default=False, |
|
1186 | 1186 | ) |
|
1187 | 1187 | coreconfigitem( |
|
1188 | 1188 | b'experimental', |
|
1189 | 1189 | b'single-head-per-branch', |
|
1190 | 1190 | default=False, |
|
1191 | 1191 | ) |
|
1192 | 1192 | coreconfigitem( |
|
1193 | 1193 | b'experimental', |
|
1194 | 1194 | b'single-head-per-branch:account-closed-heads', |
|
1195 | 1195 | default=False, |
|
1196 | 1196 | ) |
|
1197 | 1197 | coreconfigitem( |
|
1198 | 1198 | b'experimental', |
|
1199 | 1199 | b'single-head-per-branch:public-changes-only', |
|
1200 | 1200 | default=False, |
|
1201 | 1201 | ) |
|
1202 | 1202 | coreconfigitem( |
|
1203 | 1203 | b'experimental', |
|
1204 | 1204 | b'sparse-read', |
|
1205 | 1205 | default=False, |
|
1206 | 1206 | ) |
|
1207 | 1207 | coreconfigitem( |
|
1208 | 1208 | b'experimental', |
|
1209 | 1209 | b'sparse-read.density-threshold', |
|
1210 | 1210 | default=0.50, |
|
1211 | 1211 | ) |
|
1212 | 1212 | coreconfigitem( |
|
1213 | 1213 | b'experimental', |
|
1214 | 1214 | b'sparse-read.min-gap-size', |
|
1215 | 1215 | default=b'65K', |
|
1216 | 1216 | ) |
|
1217 | 1217 | coreconfigitem( |
|
1218 | 1218 | b'experimental', |
|
1219 | 1219 | b'treemanifest', |
|
1220 | 1220 | default=False, |
|
1221 | 1221 | ) |
|
1222 | 1222 | coreconfigitem( |
|
1223 | 1223 | b'experimental', |
|
1224 | 1224 | b'update.atomic-file', |
|
1225 | 1225 | default=False, |
|
1226 | 1226 | ) |
|
1227 | 1227 | coreconfigitem( |
|
1228 | 1228 | b'experimental', |
|
1229 | 1229 | b'web.full-garbage-collection-rate', |
|
1230 | 1230 | default=1, # still forcing a full collection on each request |
|
1231 | 1231 | ) |
|
1232 | 1232 | coreconfigitem( |
|
1233 | 1233 | b'experimental', |
|
1234 | 1234 | b'worker.wdir-get-thread-safe', |
|
1235 | 1235 | default=False, |
|
1236 | 1236 | ) |
|
1237 | 1237 | coreconfigitem( |
|
1238 | 1238 | b'experimental', |
|
1239 | 1239 | b'worker.repository-upgrade', |
|
1240 | 1240 | default=False, |
|
1241 | 1241 | ) |
|
1242 | 1242 | coreconfigitem( |
|
1243 | 1243 | b'experimental', |
|
1244 | 1244 | b'xdiff', |
|
1245 | 1245 | default=False, |
|
1246 | 1246 | ) |
|
1247 | 1247 | coreconfigitem( |
|
1248 | 1248 | b'extensions', |
|
1249 | 1249 | b'[^:]*', |
|
1250 | 1250 | default=None, |
|
1251 | 1251 | generic=True, |
|
1252 | 1252 | ) |
|
1253 | 1253 | coreconfigitem( |
|
1254 | 1254 | b'extensions', |
|
1255 | 1255 | b'[^:]*:required', |
|
1256 | 1256 | default=False, |
|
1257 | 1257 | generic=True, |
|
1258 | 1258 | ) |
|
1259 | 1259 | coreconfigitem( |
|
1260 | 1260 | b'extdata', |
|
1261 | 1261 | b'.*', |
|
1262 | 1262 | default=None, |
|
1263 | 1263 | generic=True, |
|
1264 | 1264 | ) |
|
1265 | 1265 | coreconfigitem( |
|
1266 | 1266 | b'format', |
|
1267 | 1267 | b'bookmarks-in-store', |
|
1268 | 1268 | default=False, |
|
1269 | 1269 | ) |
|
1270 | 1270 | coreconfigitem( |
|
1271 | 1271 | b'format', |
|
1272 | 1272 | b'chunkcachesize', |
|
1273 | 1273 | default=None, |
|
1274 | 1274 | experimental=True, |
|
1275 | 1275 | ) |
|
1276 | 1276 | coreconfigitem( |
|
1277 | 1277 | # Enable this dirstate format *when creating a new repository*. |
|
1278 | 1278 | # Which format to use for existing repos is controlled by .hg/requires |
|
1279 | 1279 | b'format', |
|
1280 | 1280 | b'use-dirstate-v2', |
|
1281 | 1281 | default=False, |
|
1282 | 1282 | experimental=True, |
|
1283 | 1283 | alias=[(b'format', b'exp-rc-dirstate-v2')], |
|
1284 | 1284 | ) |
|
1285 | 1285 | coreconfigitem( |
|
1286 | 1286 | b'format', |
|
1287 | b'exp-dirstate-tracked-key-version', | |
|
1288 | default=0, | |
|
1289 | experimental=True, | |
|
1290 | ) | |
|
1291 | coreconfigitem( | |
|
1292 | b'format', | |
|
1287 | 1293 | b'dotencode', |
|
1288 | 1294 | default=True, |
|
1289 | 1295 | ) |
|
1290 | 1296 | coreconfigitem( |
|
1291 | 1297 | b'format', |
|
1292 | 1298 | b'generaldelta', |
|
1293 | 1299 | default=False, |
|
1294 | 1300 | experimental=True, |
|
1295 | 1301 | ) |
|
1296 | 1302 | coreconfigitem( |
|
1297 | 1303 | b'format', |
|
1298 | 1304 | b'manifestcachesize', |
|
1299 | 1305 | default=None, |
|
1300 | 1306 | experimental=True, |
|
1301 | 1307 | ) |
|
1302 | 1308 | coreconfigitem( |
|
1303 | 1309 | b'format', |
|
1304 | 1310 | b'maxchainlen', |
|
1305 | 1311 | default=dynamicdefault, |
|
1306 | 1312 | experimental=True, |
|
1307 | 1313 | ) |
|
1308 | 1314 | coreconfigitem( |
|
1309 | 1315 | b'format', |
|
1310 | 1316 | b'obsstore-version', |
|
1311 | 1317 | default=None, |
|
1312 | 1318 | ) |
|
1313 | 1319 | coreconfigitem( |
|
1314 | 1320 | b'format', |
|
1315 | 1321 | b'sparse-revlog', |
|
1316 | 1322 | default=True, |
|
1317 | 1323 | ) |
|
1318 | 1324 | coreconfigitem( |
|
1319 | 1325 | b'format', |
|
1320 | 1326 | b'revlog-compression', |
|
1321 | 1327 | default=lambda: [b'zstd', b'zlib'], |
|
1322 | 1328 | alias=[(b'experimental', b'format.compression')], |
|
1323 | 1329 | ) |
|
1324 | 1330 | # Experimental TODOs: |
|
1325 | 1331 | # |
|
1326 | 1332 | # * Same as for revlogv2 (but for the reduction of the number of files) |
|
1327 | 1333 | # * Actually computing the rank of changesets |
|
1328 | 1334 | # * Improvement to investigate |
|
1329 | 1335 | # - storing .hgtags fnode |
|
1330 | 1336 | # - storing branch related identifier |
|
1331 | 1337 | |
|
1332 | 1338 | coreconfigitem( |
|
1333 | 1339 | b'format', |
|
1334 | 1340 | b'exp-use-changelog-v2', |
|
1335 | 1341 | default=None, |
|
1336 | 1342 | experimental=True, |
|
1337 | 1343 | ) |
|
1338 | 1344 | coreconfigitem( |
|
1339 | 1345 | b'format', |
|
1340 | 1346 | b'usefncache', |
|
1341 | 1347 | default=True, |
|
1342 | 1348 | ) |
|
1343 | 1349 | coreconfigitem( |
|
1344 | 1350 | b'format', |
|
1345 | 1351 | b'usegeneraldelta', |
|
1346 | 1352 | default=True, |
|
1347 | 1353 | ) |
|
1348 | 1354 | coreconfigitem( |
|
1349 | 1355 | b'format', |
|
1350 | 1356 | b'usestore', |
|
1351 | 1357 | default=True, |
|
1352 | 1358 | ) |
|
1353 | 1359 | |
|
1354 | 1360 | |
|
1355 | 1361 | def _persistent_nodemap_default(): |
|
1356 | 1362 | """compute `use-persistent-nodemap` default value |
|
1357 | 1363 | |
|
1358 | 1364 | The feature is disabled unless a fast implementation is available. |
|
1359 | 1365 | """ |
|
1360 | 1366 | from . import policy |
|
1361 | 1367 | |
|
1362 | 1368 | return policy.importrust('revlog') is not None |
|
1363 | 1369 | |
|
1364 | 1370 | |
|
1365 | 1371 | coreconfigitem( |
|
1366 | 1372 | b'format', |
|
1367 | 1373 | b'use-persistent-nodemap', |
|
1368 | 1374 | default=_persistent_nodemap_default, |
|
1369 | 1375 | ) |
|
1370 | 1376 | coreconfigitem( |
|
1371 | 1377 | b'format', |
|
1372 | 1378 | b'exp-use-copies-side-data-changeset', |
|
1373 | 1379 | default=False, |
|
1374 | 1380 | experimental=True, |
|
1375 | 1381 | ) |
|
1376 | 1382 | coreconfigitem( |
|
1377 | 1383 | b'format', |
|
1378 | 1384 | b'use-share-safe', |
|
1379 | 1385 | default=True, |
|
1380 | 1386 | ) |
|
1381 | 1387 | coreconfigitem( |
|
1382 | 1388 | b'format', |
|
1383 | 1389 | b'internal-phase', |
|
1384 | 1390 | default=False, |
|
1385 | 1391 | experimental=True, |
|
1386 | 1392 | ) |
|
1387 | 1393 | coreconfigitem( |
|
1388 | 1394 | b'fsmonitor', |
|
1389 | 1395 | b'warn_when_unused', |
|
1390 | 1396 | default=True, |
|
1391 | 1397 | ) |
|
1392 | 1398 | coreconfigitem( |
|
1393 | 1399 | b'fsmonitor', |
|
1394 | 1400 | b'warn_update_file_count', |
|
1395 | 1401 | default=50000, |
|
1396 | 1402 | ) |
|
1397 | 1403 | coreconfigitem( |
|
1398 | 1404 | b'fsmonitor', |
|
1399 | 1405 | b'warn_update_file_count_rust', |
|
1400 | 1406 | default=400000, |
|
1401 | 1407 | ) |
|
1402 | 1408 | coreconfigitem( |
|
1403 | 1409 | b'help', |
|
1404 | 1410 | br'hidden-command\..*', |
|
1405 | 1411 | default=False, |
|
1406 | 1412 | generic=True, |
|
1407 | 1413 | ) |
|
1408 | 1414 | coreconfigitem( |
|
1409 | 1415 | b'help', |
|
1410 | 1416 | br'hidden-topic\..*', |
|
1411 | 1417 | default=False, |
|
1412 | 1418 | generic=True, |
|
1413 | 1419 | ) |
|
1414 | 1420 | coreconfigitem( |
|
1415 | 1421 | b'hooks', |
|
1416 | 1422 | b'[^:]*', |
|
1417 | 1423 | default=dynamicdefault, |
|
1418 | 1424 | generic=True, |
|
1419 | 1425 | ) |
|
1420 | 1426 | coreconfigitem( |
|
1421 | 1427 | b'hooks', |
|
1422 | 1428 | b'.*:run-with-plain', |
|
1423 | 1429 | default=True, |
|
1424 | 1430 | generic=True, |
|
1425 | 1431 | ) |
|
1426 | 1432 | coreconfigitem( |
|
1427 | 1433 | b'hgweb-paths', |
|
1428 | 1434 | b'.*', |
|
1429 | 1435 | default=list, |
|
1430 | 1436 | generic=True, |
|
1431 | 1437 | ) |
|
1432 | 1438 | coreconfigitem( |
|
1433 | 1439 | b'hostfingerprints', |
|
1434 | 1440 | b'.*', |
|
1435 | 1441 | default=list, |
|
1436 | 1442 | generic=True, |
|
1437 | 1443 | ) |
|
1438 | 1444 | coreconfigitem( |
|
1439 | 1445 | b'hostsecurity', |
|
1440 | 1446 | b'ciphers', |
|
1441 | 1447 | default=None, |
|
1442 | 1448 | ) |
|
1443 | 1449 | coreconfigitem( |
|
1444 | 1450 | b'hostsecurity', |
|
1445 | 1451 | b'minimumprotocol', |
|
1446 | 1452 | default=dynamicdefault, |
|
1447 | 1453 | ) |
|
1448 | 1454 | coreconfigitem( |
|
1449 | 1455 | b'hostsecurity', |
|
1450 | 1456 | b'.*:minimumprotocol$', |
|
1451 | 1457 | default=dynamicdefault, |
|
1452 | 1458 | generic=True, |
|
1453 | 1459 | ) |
|
1454 | 1460 | coreconfigitem( |
|
1455 | 1461 | b'hostsecurity', |
|
1456 | 1462 | b'.*:ciphers$', |
|
1457 | 1463 | default=dynamicdefault, |
|
1458 | 1464 | generic=True, |
|
1459 | 1465 | ) |
|
1460 | 1466 | coreconfigitem( |
|
1461 | 1467 | b'hostsecurity', |
|
1462 | 1468 | b'.*:fingerprints$', |
|
1463 | 1469 | default=list, |
|
1464 | 1470 | generic=True, |
|
1465 | 1471 | ) |
|
1466 | 1472 | coreconfigitem( |
|
1467 | 1473 | b'hostsecurity', |
|
1468 | 1474 | b'.*:verifycertsfile$', |
|
1469 | 1475 | default=None, |
|
1470 | 1476 | generic=True, |
|
1471 | 1477 | ) |
|
1472 | 1478 | |
|
1473 | 1479 | coreconfigitem( |
|
1474 | 1480 | b'http_proxy', |
|
1475 | 1481 | b'always', |
|
1476 | 1482 | default=False, |
|
1477 | 1483 | ) |
|
1478 | 1484 | coreconfigitem( |
|
1479 | 1485 | b'http_proxy', |
|
1480 | 1486 | b'host', |
|
1481 | 1487 | default=None, |
|
1482 | 1488 | ) |
|
1483 | 1489 | coreconfigitem( |
|
1484 | 1490 | b'http_proxy', |
|
1485 | 1491 | b'no', |
|
1486 | 1492 | default=list, |
|
1487 | 1493 | ) |
|
1488 | 1494 | coreconfigitem( |
|
1489 | 1495 | b'http_proxy', |
|
1490 | 1496 | b'passwd', |
|
1491 | 1497 | default=None, |
|
1492 | 1498 | ) |
|
1493 | 1499 | coreconfigitem( |
|
1494 | 1500 | b'http_proxy', |
|
1495 | 1501 | b'user', |
|
1496 | 1502 | default=None, |
|
1497 | 1503 | ) |
|
1498 | 1504 | |
|
1499 | 1505 | coreconfigitem( |
|
1500 | 1506 | b'http', |
|
1501 | 1507 | b'timeout', |
|
1502 | 1508 | default=None, |
|
1503 | 1509 | ) |
|
1504 | 1510 | |
|
1505 | 1511 | coreconfigitem( |
|
1506 | 1512 | b'logtoprocess', |
|
1507 | 1513 | b'commandexception', |
|
1508 | 1514 | default=None, |
|
1509 | 1515 | ) |
|
1510 | 1516 | coreconfigitem( |
|
1511 | 1517 | b'logtoprocess', |
|
1512 | 1518 | b'commandfinish', |
|
1513 | 1519 | default=None, |
|
1514 | 1520 | ) |
|
1515 | 1521 | coreconfigitem( |
|
1516 | 1522 | b'logtoprocess', |
|
1517 | 1523 | b'command', |
|
1518 | 1524 | default=None, |
|
1519 | 1525 | ) |
|
1520 | 1526 | coreconfigitem( |
|
1521 | 1527 | b'logtoprocess', |
|
1522 | 1528 | b'develwarn', |
|
1523 | 1529 | default=None, |
|
1524 | 1530 | ) |
|
1525 | 1531 | coreconfigitem( |
|
1526 | 1532 | b'logtoprocess', |
|
1527 | 1533 | b'uiblocked', |
|
1528 | 1534 | default=None, |
|
1529 | 1535 | ) |
|
1530 | 1536 | coreconfigitem( |
|
1531 | 1537 | b'merge', |
|
1532 | 1538 | b'checkunknown', |
|
1533 | 1539 | default=b'abort', |
|
1534 | 1540 | ) |
|
1535 | 1541 | coreconfigitem( |
|
1536 | 1542 | b'merge', |
|
1537 | 1543 | b'checkignored', |
|
1538 | 1544 | default=b'abort', |
|
1539 | 1545 | ) |
|
1540 | 1546 | coreconfigitem( |
|
1541 | 1547 | b'experimental', |
|
1542 | 1548 | b'merge.checkpathconflicts', |
|
1543 | 1549 | default=False, |
|
1544 | 1550 | ) |
|
1545 | 1551 | coreconfigitem( |
|
1546 | 1552 | b'merge', |
|
1547 | 1553 | b'followcopies', |
|
1548 | 1554 | default=True, |
|
1549 | 1555 | ) |
|
1550 | 1556 | coreconfigitem( |
|
1551 | 1557 | b'merge', |
|
1552 | 1558 | b'on-failure', |
|
1553 | 1559 | default=b'continue', |
|
1554 | 1560 | ) |
|
1555 | 1561 | coreconfigitem( |
|
1556 | 1562 | b'merge', |
|
1557 | 1563 | b'preferancestor', |
|
1558 | 1564 | default=lambda: [b'*'], |
|
1559 | 1565 | experimental=True, |
|
1560 | 1566 | ) |
|
1561 | 1567 | coreconfigitem( |
|
1562 | 1568 | b'merge', |
|
1563 | 1569 | b'strict-capability-check', |
|
1564 | 1570 | default=False, |
|
1565 | 1571 | ) |
|
1566 | 1572 | coreconfigitem( |
|
1567 | 1573 | b'merge-tools', |
|
1568 | 1574 | b'.*', |
|
1569 | 1575 | default=None, |
|
1570 | 1576 | generic=True, |
|
1571 | 1577 | ) |
|
1572 | 1578 | coreconfigitem( |
|
1573 | 1579 | b'merge-tools', |
|
1574 | 1580 | br'.*\.args$', |
|
1575 | 1581 | default=b"$local $base $other", |
|
1576 | 1582 | generic=True, |
|
1577 | 1583 | priority=-1, |
|
1578 | 1584 | ) |
|
1579 | 1585 | coreconfigitem( |
|
1580 | 1586 | b'merge-tools', |
|
1581 | 1587 | br'.*\.binary$', |
|
1582 | 1588 | default=False, |
|
1583 | 1589 | generic=True, |
|
1584 | 1590 | priority=-1, |
|
1585 | 1591 | ) |
|
1586 | 1592 | coreconfigitem( |
|
1587 | 1593 | b'merge-tools', |
|
1588 | 1594 | br'.*\.check$', |
|
1589 | 1595 | default=list, |
|
1590 | 1596 | generic=True, |
|
1591 | 1597 | priority=-1, |
|
1592 | 1598 | ) |
|
1593 | 1599 | coreconfigitem( |
|
1594 | 1600 | b'merge-tools', |
|
1595 | 1601 | br'.*\.checkchanged$', |
|
1596 | 1602 | default=False, |
|
1597 | 1603 | generic=True, |
|
1598 | 1604 | priority=-1, |
|
1599 | 1605 | ) |
|
1600 | 1606 | coreconfigitem( |
|
1601 | 1607 | b'merge-tools', |
|
1602 | 1608 | br'.*\.executable$', |
|
1603 | 1609 | default=dynamicdefault, |
|
1604 | 1610 | generic=True, |
|
1605 | 1611 | priority=-1, |
|
1606 | 1612 | ) |
|
1607 | 1613 | coreconfigitem( |
|
1608 | 1614 | b'merge-tools', |
|
1609 | 1615 | br'.*\.fixeol$', |
|
1610 | 1616 | default=False, |
|
1611 | 1617 | generic=True, |
|
1612 | 1618 | priority=-1, |
|
1613 | 1619 | ) |
|
1614 | 1620 | coreconfigitem( |
|
1615 | 1621 | b'merge-tools', |
|
1616 | 1622 | br'.*\.gui$', |
|
1617 | 1623 | default=False, |
|
1618 | 1624 | generic=True, |
|
1619 | 1625 | priority=-1, |
|
1620 | 1626 | ) |
|
1621 | 1627 | coreconfigitem( |
|
1622 | 1628 | b'merge-tools', |
|
1623 | 1629 | br'.*\.mergemarkers$', |
|
1624 | 1630 | default=b'basic', |
|
1625 | 1631 | generic=True, |
|
1626 | 1632 | priority=-1, |
|
1627 | 1633 | ) |
|
1628 | 1634 | coreconfigitem( |
|
1629 | 1635 | b'merge-tools', |
|
1630 | 1636 | br'.*\.mergemarkertemplate$', |
|
1631 | 1637 | default=dynamicdefault, # take from command-templates.mergemarker |
|
1632 | 1638 | generic=True, |
|
1633 | 1639 | priority=-1, |
|
1634 | 1640 | ) |
|
1635 | 1641 | coreconfigitem( |
|
1636 | 1642 | b'merge-tools', |
|
1637 | 1643 | br'.*\.priority$', |
|
1638 | 1644 | default=0, |
|
1639 | 1645 | generic=True, |
|
1640 | 1646 | priority=-1, |
|
1641 | 1647 | ) |
|
1642 | 1648 | coreconfigitem( |
|
1643 | 1649 | b'merge-tools', |
|
1644 | 1650 | br'.*\.premerge$', |
|
1645 | 1651 | default=dynamicdefault, |
|
1646 | 1652 | generic=True, |
|
1647 | 1653 | priority=-1, |
|
1648 | 1654 | ) |
|
1649 | 1655 | coreconfigitem( |
|
1650 | 1656 | b'merge-tools', |
|
1651 | 1657 | br'.*\.symlink$', |
|
1652 | 1658 | default=False, |
|
1653 | 1659 | generic=True, |
|
1654 | 1660 | priority=-1, |
|
1655 | 1661 | ) |
|
1656 | 1662 | coreconfigitem( |
|
1657 | 1663 | b'pager', |
|
1658 | 1664 | b'attend-.*', |
|
1659 | 1665 | default=dynamicdefault, |
|
1660 | 1666 | generic=True, |
|
1661 | 1667 | ) |
|
1662 | 1668 | coreconfigitem( |
|
1663 | 1669 | b'pager', |
|
1664 | 1670 | b'ignore', |
|
1665 | 1671 | default=list, |
|
1666 | 1672 | ) |
|
1667 | 1673 | coreconfigitem( |
|
1668 | 1674 | b'pager', |
|
1669 | 1675 | b'pager', |
|
1670 | 1676 | default=dynamicdefault, |
|
1671 | 1677 | ) |
|
1672 | 1678 | coreconfigitem( |
|
1673 | 1679 | b'patch', |
|
1674 | 1680 | b'eol', |
|
1675 | 1681 | default=b'strict', |
|
1676 | 1682 | ) |
|
1677 | 1683 | coreconfigitem( |
|
1678 | 1684 | b'patch', |
|
1679 | 1685 | b'fuzz', |
|
1680 | 1686 | default=2, |
|
1681 | 1687 | ) |
|
1682 | 1688 | coreconfigitem( |
|
1683 | 1689 | b'paths', |
|
1684 | 1690 | b'default', |
|
1685 | 1691 | default=None, |
|
1686 | 1692 | ) |
|
1687 | 1693 | coreconfigitem( |
|
1688 | 1694 | b'paths', |
|
1689 | 1695 | b'default-push', |
|
1690 | 1696 | default=None, |
|
1691 | 1697 | ) |
|
1692 | 1698 | coreconfigitem( |
|
1693 | 1699 | b'paths', |
|
1694 | 1700 | b'.*', |
|
1695 | 1701 | default=None, |
|
1696 | 1702 | generic=True, |
|
1697 | 1703 | ) |
|
1698 | 1704 | coreconfigitem( |
|
1699 | 1705 | b'phases', |
|
1700 | 1706 | b'checksubrepos', |
|
1701 | 1707 | default=b'follow', |
|
1702 | 1708 | ) |
|
1703 | 1709 | coreconfigitem( |
|
1704 | 1710 | b'phases', |
|
1705 | 1711 | b'new-commit', |
|
1706 | 1712 | default=b'draft', |
|
1707 | 1713 | ) |
|
1708 | 1714 | coreconfigitem( |
|
1709 | 1715 | b'phases', |
|
1710 | 1716 | b'publish', |
|
1711 | 1717 | default=True, |
|
1712 | 1718 | ) |
|
1713 | 1719 | coreconfigitem( |
|
1714 | 1720 | b'profiling', |
|
1715 | 1721 | b'enabled', |
|
1716 | 1722 | default=False, |
|
1717 | 1723 | ) |
|
1718 | 1724 | coreconfigitem( |
|
1719 | 1725 | b'profiling', |
|
1720 | 1726 | b'format', |
|
1721 | 1727 | default=b'text', |
|
1722 | 1728 | ) |
|
1723 | 1729 | coreconfigitem( |
|
1724 | 1730 | b'profiling', |
|
1725 | 1731 | b'freq', |
|
1726 | 1732 | default=1000, |
|
1727 | 1733 | ) |
|
1728 | 1734 | coreconfigitem( |
|
1729 | 1735 | b'profiling', |
|
1730 | 1736 | b'limit', |
|
1731 | 1737 | default=30, |
|
1732 | 1738 | ) |
|
1733 | 1739 | coreconfigitem( |
|
1734 | 1740 | b'profiling', |
|
1735 | 1741 | b'nested', |
|
1736 | 1742 | default=0, |
|
1737 | 1743 | ) |
|
1738 | 1744 | coreconfigitem( |
|
1739 | 1745 | b'profiling', |
|
1740 | 1746 | b'output', |
|
1741 | 1747 | default=None, |
|
1742 | 1748 | ) |
|
1743 | 1749 | coreconfigitem( |
|
1744 | 1750 | b'profiling', |
|
1745 | 1751 | b'showmax', |
|
1746 | 1752 | default=0.999, |
|
1747 | 1753 | ) |
|
1748 | 1754 | coreconfigitem( |
|
1749 | 1755 | b'profiling', |
|
1750 | 1756 | b'showmin', |
|
1751 | 1757 | default=dynamicdefault, |
|
1752 | 1758 | ) |
|
1753 | 1759 | coreconfigitem( |
|
1754 | 1760 | b'profiling', |
|
1755 | 1761 | b'showtime', |
|
1756 | 1762 | default=True, |
|
1757 | 1763 | ) |
|
1758 | 1764 | coreconfigitem( |
|
1759 | 1765 | b'profiling', |
|
1760 | 1766 | b'sort', |
|
1761 | 1767 | default=b'inlinetime', |
|
1762 | 1768 | ) |
|
1763 | 1769 | coreconfigitem( |
|
1764 | 1770 | b'profiling', |
|
1765 | 1771 | b'statformat', |
|
1766 | 1772 | default=b'hotpath', |
|
1767 | 1773 | ) |
|
1768 | 1774 | coreconfigitem( |
|
1769 | 1775 | b'profiling', |
|
1770 | 1776 | b'time-track', |
|
1771 | 1777 | default=dynamicdefault, |
|
1772 | 1778 | ) |
|
1773 | 1779 | coreconfigitem( |
|
1774 | 1780 | b'profiling', |
|
1775 | 1781 | b'type', |
|
1776 | 1782 | default=b'stat', |
|
1777 | 1783 | ) |
|
1778 | 1784 | coreconfigitem( |
|
1779 | 1785 | b'progress', |
|
1780 | 1786 | b'assume-tty', |
|
1781 | 1787 | default=False, |
|
1782 | 1788 | ) |
|
1783 | 1789 | coreconfigitem( |
|
1784 | 1790 | b'progress', |
|
1785 | 1791 | b'changedelay', |
|
1786 | 1792 | default=1, |
|
1787 | 1793 | ) |
|
1788 | 1794 | coreconfigitem( |
|
1789 | 1795 | b'progress', |
|
1790 | 1796 | b'clear-complete', |
|
1791 | 1797 | default=True, |
|
1792 | 1798 | ) |
|
1793 | 1799 | coreconfigitem( |
|
1794 | 1800 | b'progress', |
|
1795 | 1801 | b'debug', |
|
1796 | 1802 | default=False, |
|
1797 | 1803 | ) |
|
1798 | 1804 | coreconfigitem( |
|
1799 | 1805 | b'progress', |
|
1800 | 1806 | b'delay', |
|
1801 | 1807 | default=3, |
|
1802 | 1808 | ) |
|
1803 | 1809 | coreconfigitem( |
|
1804 | 1810 | b'progress', |
|
1805 | 1811 | b'disable', |
|
1806 | 1812 | default=False, |
|
1807 | 1813 | ) |
|
1808 | 1814 | coreconfigitem( |
|
1809 | 1815 | b'progress', |
|
1810 | 1816 | b'estimateinterval', |
|
1811 | 1817 | default=60.0, |
|
1812 | 1818 | ) |
|
1813 | 1819 | coreconfigitem( |
|
1814 | 1820 | b'progress', |
|
1815 | 1821 | b'format', |
|
1816 | 1822 | default=lambda: [b'topic', b'bar', b'number', b'estimate'], |
|
1817 | 1823 | ) |
|
1818 | 1824 | coreconfigitem( |
|
1819 | 1825 | b'progress', |
|
1820 | 1826 | b'refresh', |
|
1821 | 1827 | default=0.1, |
|
1822 | 1828 | ) |
|
1823 | 1829 | coreconfigitem( |
|
1824 | 1830 | b'progress', |
|
1825 | 1831 | b'width', |
|
1826 | 1832 | default=dynamicdefault, |
|
1827 | 1833 | ) |
|
1828 | 1834 | coreconfigitem( |
|
1829 | 1835 | b'pull', |
|
1830 | 1836 | b'confirm', |
|
1831 | 1837 | default=False, |
|
1832 | 1838 | ) |
|
1833 | 1839 | coreconfigitem( |
|
1834 | 1840 | b'push', |
|
1835 | 1841 | b'pushvars.server', |
|
1836 | 1842 | default=False, |
|
1837 | 1843 | ) |
|
1838 | 1844 | coreconfigitem( |
|
1839 | 1845 | b'rewrite', |
|
1840 | 1846 | b'backup-bundle', |
|
1841 | 1847 | default=True, |
|
1842 | 1848 | alias=[(b'ui', b'history-editing-backup')], |
|
1843 | 1849 | ) |
|
1844 | 1850 | coreconfigitem( |
|
1845 | 1851 | b'rewrite', |
|
1846 | 1852 | b'update-timestamp', |
|
1847 | 1853 | default=False, |
|
1848 | 1854 | ) |
|
1849 | 1855 | coreconfigitem( |
|
1850 | 1856 | b'rewrite', |
|
1851 | 1857 | b'empty-successor', |
|
1852 | 1858 | default=b'skip', |
|
1853 | 1859 | experimental=True, |
|
1854 | 1860 | ) |
|
1855 | 1861 | # experimental as long as format.use-dirstate-v2 is. |
|
1856 | 1862 | coreconfigitem( |
|
1857 | 1863 | b'storage', |
|
1858 | 1864 | b'dirstate-v2.slow-path', |
|
1859 | 1865 | default=b"abort", |
|
1860 | 1866 | experimental=True, |
|
1861 | 1867 | ) |
|
1862 | 1868 | coreconfigitem( |
|
1863 | 1869 | b'storage', |
|
1864 | 1870 | b'new-repo-backend', |
|
1865 | 1871 | default=b'revlogv1', |
|
1866 | 1872 | experimental=True, |
|
1867 | 1873 | ) |
|
1868 | 1874 | coreconfigitem( |
|
1869 | 1875 | b'storage', |
|
1870 | 1876 | b'revlog.optimize-delta-parent-choice', |
|
1871 | 1877 | default=True, |
|
1872 | 1878 | alias=[(b'format', b'aggressivemergedeltas')], |
|
1873 | 1879 | ) |
|
1874 | 1880 | coreconfigitem( |
|
1875 | 1881 | b'storage', |
|
1876 | 1882 | b'revlog.issue6528.fix-incoming', |
|
1877 | 1883 | default=True, |
|
1878 | 1884 | ) |
|
1879 | 1885 | # experimental as long as rust is experimental (or a C version is implemented) |
|
1880 | 1886 | coreconfigitem( |
|
1881 | 1887 | b'storage', |
|
1882 | 1888 | b'revlog.persistent-nodemap.mmap', |
|
1883 | 1889 | default=True, |
|
1884 | 1890 | ) |
|
1885 | 1891 | # experimental as long as format.use-persistent-nodemap is. |
|
1886 | 1892 | coreconfigitem( |
|
1887 | 1893 | b'storage', |
|
1888 | 1894 | b'revlog.persistent-nodemap.slow-path', |
|
1889 | 1895 | default=b"abort", |
|
1890 | 1896 | ) |
|
1891 | 1897 | |
|
1892 | 1898 | coreconfigitem( |
|
1893 | 1899 | b'storage', |
|
1894 | 1900 | b'revlog.reuse-external-delta', |
|
1895 | 1901 | default=True, |
|
1896 | 1902 | ) |
|
1897 | 1903 | coreconfigitem( |
|
1898 | 1904 | b'storage', |
|
1899 | 1905 | b'revlog.reuse-external-delta-parent', |
|
1900 | 1906 | default=None, |
|
1901 | 1907 | ) |
|
1902 | 1908 | coreconfigitem( |
|
1903 | 1909 | b'storage', |
|
1904 | 1910 | b'revlog.zlib.level', |
|
1905 | 1911 | default=None, |
|
1906 | 1912 | ) |
|
1907 | 1913 | coreconfigitem( |
|
1908 | 1914 | b'storage', |
|
1909 | 1915 | b'revlog.zstd.level', |
|
1910 | 1916 | default=None, |
|
1911 | 1917 | ) |
|
1912 | 1918 | coreconfigitem( |
|
1913 | 1919 | b'server', |
|
1914 | 1920 | b'bookmarks-pushkey-compat', |
|
1915 | 1921 | default=True, |
|
1916 | 1922 | ) |
|
1917 | 1923 | coreconfigitem( |
|
1918 | 1924 | b'server', |
|
1919 | 1925 | b'bundle1', |
|
1920 | 1926 | default=True, |
|
1921 | 1927 | ) |
|
1922 | 1928 | coreconfigitem( |
|
1923 | 1929 | b'server', |
|
1924 | 1930 | b'bundle1gd', |
|
1925 | 1931 | default=None, |
|
1926 | 1932 | ) |
|
1927 | 1933 | coreconfigitem( |
|
1928 | 1934 | b'server', |
|
1929 | 1935 | b'bundle1.pull', |
|
1930 | 1936 | default=None, |
|
1931 | 1937 | ) |
|
1932 | 1938 | coreconfigitem( |
|
1933 | 1939 | b'server', |
|
1934 | 1940 | b'bundle1gd.pull', |
|
1935 | 1941 | default=None, |
|
1936 | 1942 | ) |
|
1937 | 1943 | coreconfigitem( |
|
1938 | 1944 | b'server', |
|
1939 | 1945 | b'bundle1.push', |
|
1940 | 1946 | default=None, |
|
1941 | 1947 | ) |
|
1942 | 1948 | coreconfigitem( |
|
1943 | 1949 | b'server', |
|
1944 | 1950 | b'bundle1gd.push', |
|
1945 | 1951 | default=None, |
|
1946 | 1952 | ) |
|
1947 | 1953 | coreconfigitem( |
|
1948 | 1954 | b'server', |
|
1949 | 1955 | b'bundle2.stream', |
|
1950 | 1956 | default=True, |
|
1951 | 1957 | alias=[(b'experimental', b'bundle2.stream')], |
|
1952 | 1958 | ) |
|
1953 | 1959 | coreconfigitem( |
|
1954 | 1960 | b'server', |
|
1955 | 1961 | b'compressionengines', |
|
1956 | 1962 | default=list, |
|
1957 | 1963 | ) |
|
1958 | 1964 | coreconfigitem( |
|
1959 | 1965 | b'server', |
|
1960 | 1966 | b'concurrent-push-mode', |
|
1961 | 1967 | default=b'check-related', |
|
1962 | 1968 | ) |
|
1963 | 1969 | coreconfigitem( |
|
1964 | 1970 | b'server', |
|
1965 | 1971 | b'disablefullbundle', |
|
1966 | 1972 | default=False, |
|
1967 | 1973 | ) |
|
1968 | 1974 | coreconfigitem( |
|
1969 | 1975 | b'server', |
|
1970 | 1976 | b'maxhttpheaderlen', |
|
1971 | 1977 | default=1024, |
|
1972 | 1978 | ) |
|
1973 | 1979 | coreconfigitem( |
|
1974 | 1980 | b'server', |
|
1975 | 1981 | b'pullbundle', |
|
1976 | 1982 | default=False, |
|
1977 | 1983 | ) |
|
1978 | 1984 | coreconfigitem( |
|
1979 | 1985 | b'server', |
|
1980 | 1986 | b'preferuncompressed', |
|
1981 | 1987 | default=False, |
|
1982 | 1988 | ) |
|
1983 | 1989 | coreconfigitem( |
|
1984 | 1990 | b'server', |
|
1985 | 1991 | b'streamunbundle', |
|
1986 | 1992 | default=False, |
|
1987 | 1993 | ) |
|
1988 | 1994 | coreconfigitem( |
|
1989 | 1995 | b'server', |
|
1990 | 1996 | b'uncompressed', |
|
1991 | 1997 | default=True, |
|
1992 | 1998 | ) |
|
1993 | 1999 | coreconfigitem( |
|
1994 | 2000 | b'server', |
|
1995 | 2001 | b'uncompressedallowsecret', |
|
1996 | 2002 | default=False, |
|
1997 | 2003 | ) |
|
1998 | 2004 | coreconfigitem( |
|
1999 | 2005 | b'server', |
|
2000 | 2006 | b'view', |
|
2001 | 2007 | default=b'served', |
|
2002 | 2008 | ) |
|
2003 | 2009 | coreconfigitem( |
|
2004 | 2010 | b'server', |
|
2005 | 2011 | b'validate', |
|
2006 | 2012 | default=False, |
|
2007 | 2013 | ) |
|
2008 | 2014 | coreconfigitem( |
|
2009 | 2015 | b'server', |
|
2010 | 2016 | b'zliblevel', |
|
2011 | 2017 | default=-1, |
|
2012 | 2018 | ) |
|
2013 | 2019 | coreconfigitem( |
|
2014 | 2020 | b'server', |
|
2015 | 2021 | b'zstdlevel', |
|
2016 | 2022 | default=3, |
|
2017 | 2023 | ) |
|
2018 | 2024 | coreconfigitem( |
|
2019 | 2025 | b'share', |
|
2020 | 2026 | b'pool', |
|
2021 | 2027 | default=None, |
|
2022 | 2028 | ) |
|
2023 | 2029 | coreconfigitem( |
|
2024 | 2030 | b'share', |
|
2025 | 2031 | b'poolnaming', |
|
2026 | 2032 | default=b'identity', |
|
2027 | 2033 | ) |
|
2028 | 2034 | coreconfigitem( |
|
2029 | 2035 | b'share', |
|
2030 | 2036 | b'safe-mismatch.source-not-safe', |
|
2031 | 2037 | default=b'abort', |
|
2032 | 2038 | ) |
|
2033 | 2039 | coreconfigitem( |
|
2034 | 2040 | b'share', |
|
2035 | 2041 | b'safe-mismatch.source-safe', |
|
2036 | 2042 | default=b'abort', |
|
2037 | 2043 | ) |
|
2038 | 2044 | coreconfigitem( |
|
2039 | 2045 | b'share', |
|
2040 | 2046 | b'safe-mismatch.source-not-safe.warn', |
|
2041 | 2047 | default=True, |
|
2042 | 2048 | ) |
|
2043 | 2049 | coreconfigitem( |
|
2044 | 2050 | b'share', |
|
2045 | 2051 | b'safe-mismatch.source-safe.warn', |
|
2046 | 2052 | default=True, |
|
2047 | 2053 | ) |
|
2048 | 2054 | coreconfigitem( |
|
2049 | 2055 | b'shelve', |
|
2050 | 2056 | b'maxbackups', |
|
2051 | 2057 | default=10, |
|
2052 | 2058 | ) |
|
2053 | 2059 | coreconfigitem( |
|
2054 | 2060 | b'smtp', |
|
2055 | 2061 | b'host', |
|
2056 | 2062 | default=None, |
|
2057 | 2063 | ) |
|
2058 | 2064 | coreconfigitem( |
|
2059 | 2065 | b'smtp', |
|
2060 | 2066 | b'local_hostname', |
|
2061 | 2067 | default=None, |
|
2062 | 2068 | ) |
|
2063 | 2069 | coreconfigitem( |
|
2064 | 2070 | b'smtp', |
|
2065 | 2071 | b'password', |
|
2066 | 2072 | default=None, |
|
2067 | 2073 | ) |
|
2068 | 2074 | coreconfigitem( |
|
2069 | 2075 | b'smtp', |
|
2070 | 2076 | b'port', |
|
2071 | 2077 | default=dynamicdefault, |
|
2072 | 2078 | ) |
|
2073 | 2079 | coreconfigitem( |
|
2074 | 2080 | b'smtp', |
|
2075 | 2081 | b'tls', |
|
2076 | 2082 | default=b'none', |
|
2077 | 2083 | ) |
|
2078 | 2084 | coreconfigitem( |
|
2079 | 2085 | b'smtp', |
|
2080 | 2086 | b'username', |
|
2081 | 2087 | default=None, |
|
2082 | 2088 | ) |
|
2083 | 2089 | coreconfigitem( |
|
2084 | 2090 | b'sparse', |
|
2085 | 2091 | b'missingwarning', |
|
2086 | 2092 | default=True, |
|
2087 | 2093 | experimental=True, |
|
2088 | 2094 | ) |
|
2089 | 2095 | coreconfigitem( |
|
2090 | 2096 | b'subrepos', |
|
2091 | 2097 | b'allowed', |
|
2092 | 2098 | default=dynamicdefault, # to make backporting simpler |
|
2093 | 2099 | ) |
|
2094 | 2100 | coreconfigitem( |
|
2095 | 2101 | b'subrepos', |
|
2096 | 2102 | b'hg:allowed', |
|
2097 | 2103 | default=dynamicdefault, |
|
2098 | 2104 | ) |
|
2099 | 2105 | coreconfigitem( |
|
2100 | 2106 | b'subrepos', |
|
2101 | 2107 | b'git:allowed', |
|
2102 | 2108 | default=dynamicdefault, |
|
2103 | 2109 | ) |
|
2104 | 2110 | coreconfigitem( |
|
2105 | 2111 | b'subrepos', |
|
2106 | 2112 | b'svn:allowed', |
|
2107 | 2113 | default=dynamicdefault, |
|
2108 | 2114 | ) |
|
2109 | 2115 | coreconfigitem( |
|
2110 | 2116 | b'templates', |
|
2111 | 2117 | b'.*', |
|
2112 | 2118 | default=None, |
|
2113 | 2119 | generic=True, |
|
2114 | 2120 | ) |
|
2115 | 2121 | coreconfigitem( |
|
2116 | 2122 | b'templateconfig', |
|
2117 | 2123 | b'.*', |
|
2118 | 2124 | default=dynamicdefault, |
|
2119 | 2125 | generic=True, |
|
2120 | 2126 | ) |
|
2121 | 2127 | coreconfigitem( |
|
2122 | 2128 | b'trusted', |
|
2123 | 2129 | b'groups', |
|
2124 | 2130 | default=list, |
|
2125 | 2131 | ) |
|
2126 | 2132 | coreconfigitem( |
|
2127 | 2133 | b'trusted', |
|
2128 | 2134 | b'users', |
|
2129 | 2135 | default=list, |
|
2130 | 2136 | ) |
|
2131 | 2137 | coreconfigitem( |
|
2132 | 2138 | b'ui', |
|
2133 | 2139 | b'_usedassubrepo', |
|
2134 | 2140 | default=False, |
|
2135 | 2141 | ) |
|
2136 | 2142 | coreconfigitem( |
|
2137 | 2143 | b'ui', |
|
2138 | 2144 | b'allowemptycommit', |
|
2139 | 2145 | default=False, |
|
2140 | 2146 | ) |
|
2141 | 2147 | coreconfigitem( |
|
2142 | 2148 | b'ui', |
|
2143 | 2149 | b'archivemeta', |
|
2144 | 2150 | default=True, |
|
2145 | 2151 | ) |
|
2146 | 2152 | coreconfigitem( |
|
2147 | 2153 | b'ui', |
|
2148 | 2154 | b'askusername', |
|
2149 | 2155 | default=False, |
|
2150 | 2156 | ) |
|
2151 | 2157 | coreconfigitem( |
|
2152 | 2158 | b'ui', |
|
2153 | 2159 | b'available-memory', |
|
2154 | 2160 | default=None, |
|
2155 | 2161 | ) |
|
2156 | 2162 | |
|
2157 | 2163 | coreconfigitem( |
|
2158 | 2164 | b'ui', |
|
2159 | 2165 | b'clonebundlefallback', |
|
2160 | 2166 | default=False, |
|
2161 | 2167 | ) |
|
2162 | 2168 | coreconfigitem( |
|
2163 | 2169 | b'ui', |
|
2164 | 2170 | b'clonebundleprefers', |
|
2165 | 2171 | default=list, |
|
2166 | 2172 | ) |
|
2167 | 2173 | coreconfigitem( |
|
2168 | 2174 | b'ui', |
|
2169 | 2175 | b'clonebundles', |
|
2170 | 2176 | default=True, |
|
2171 | 2177 | ) |
|
2172 | 2178 | coreconfigitem( |
|
2173 | 2179 | b'ui', |
|
2174 | 2180 | b'color', |
|
2175 | 2181 | default=b'auto', |
|
2176 | 2182 | ) |
|
2177 | 2183 | coreconfigitem( |
|
2178 | 2184 | b'ui', |
|
2179 | 2185 | b'commitsubrepos', |
|
2180 | 2186 | default=False, |
|
2181 | 2187 | ) |
|
2182 | 2188 | coreconfigitem( |
|
2183 | 2189 | b'ui', |
|
2184 | 2190 | b'debug', |
|
2185 | 2191 | default=False, |
|
2186 | 2192 | ) |
|
2187 | 2193 | coreconfigitem( |
|
2188 | 2194 | b'ui', |
|
2189 | 2195 | b'debugger', |
|
2190 | 2196 | default=None, |
|
2191 | 2197 | ) |
|
2192 | 2198 | coreconfigitem( |
|
2193 | 2199 | b'ui', |
|
2194 | 2200 | b'editor', |
|
2195 | 2201 | default=dynamicdefault, |
|
2196 | 2202 | ) |
|
2197 | 2203 | coreconfigitem( |
|
2198 | 2204 | b'ui', |
|
2199 | 2205 | b'detailed-exit-code', |
|
2200 | 2206 | default=False, |
|
2201 | 2207 | experimental=True, |
|
2202 | 2208 | ) |
|
2203 | 2209 | coreconfigitem( |
|
2204 | 2210 | b'ui', |
|
2205 | 2211 | b'fallbackencoding', |
|
2206 | 2212 | default=None, |
|
2207 | 2213 | ) |
|
2208 | 2214 | coreconfigitem( |
|
2209 | 2215 | b'ui', |
|
2210 | 2216 | b'forcecwd', |
|
2211 | 2217 | default=None, |
|
2212 | 2218 | ) |
|
2213 | 2219 | coreconfigitem( |
|
2214 | 2220 | b'ui', |
|
2215 | 2221 | b'forcemerge', |
|
2216 | 2222 | default=None, |
|
2217 | 2223 | ) |
|
2218 | 2224 | coreconfigitem( |
|
2219 | 2225 | b'ui', |
|
2220 | 2226 | b'formatdebug', |
|
2221 | 2227 | default=False, |
|
2222 | 2228 | ) |
|
2223 | 2229 | coreconfigitem( |
|
2224 | 2230 | b'ui', |
|
2225 | 2231 | b'formatjson', |
|
2226 | 2232 | default=False, |
|
2227 | 2233 | ) |
|
2228 | 2234 | coreconfigitem( |
|
2229 | 2235 | b'ui', |
|
2230 | 2236 | b'formatted', |
|
2231 | 2237 | default=None, |
|
2232 | 2238 | ) |
|
2233 | 2239 | coreconfigitem( |
|
2234 | 2240 | b'ui', |
|
2235 | 2241 | b'interactive', |
|
2236 | 2242 | default=None, |
|
2237 | 2243 | ) |
|
2238 | 2244 | coreconfigitem( |
|
2239 | 2245 | b'ui', |
|
2240 | 2246 | b'interface', |
|
2241 | 2247 | default=None, |
|
2242 | 2248 | ) |
|
2243 | 2249 | coreconfigitem( |
|
2244 | 2250 | b'ui', |
|
2245 | 2251 | b'interface.chunkselector', |
|
2246 | 2252 | default=None, |
|
2247 | 2253 | ) |
|
2248 | 2254 | coreconfigitem( |
|
2249 | 2255 | b'ui', |
|
2250 | 2256 | b'large-file-limit', |
|
2251 | 2257 | default=10000000, |
|
2252 | 2258 | ) |
|
2253 | 2259 | coreconfigitem( |
|
2254 | 2260 | b'ui', |
|
2255 | 2261 | b'logblockedtimes', |
|
2256 | 2262 | default=False, |
|
2257 | 2263 | ) |
|
2258 | 2264 | coreconfigitem( |
|
2259 | 2265 | b'ui', |
|
2260 | 2266 | b'merge', |
|
2261 | 2267 | default=None, |
|
2262 | 2268 | ) |
|
2263 | 2269 | coreconfigitem( |
|
2264 | 2270 | b'ui', |
|
2265 | 2271 | b'mergemarkers', |
|
2266 | 2272 | default=b'basic', |
|
2267 | 2273 | ) |
|
2268 | 2274 | coreconfigitem( |
|
2269 | 2275 | b'ui', |
|
2270 | 2276 | b'message-output', |
|
2271 | 2277 | default=b'stdio', |
|
2272 | 2278 | ) |
|
2273 | 2279 | coreconfigitem( |
|
2274 | 2280 | b'ui', |
|
2275 | 2281 | b'nontty', |
|
2276 | 2282 | default=False, |
|
2277 | 2283 | ) |
|
2278 | 2284 | coreconfigitem( |
|
2279 | 2285 | b'ui', |
|
2280 | 2286 | b'origbackuppath', |
|
2281 | 2287 | default=None, |
|
2282 | 2288 | ) |
|
2283 | 2289 | coreconfigitem( |
|
2284 | 2290 | b'ui', |
|
2285 | 2291 | b'paginate', |
|
2286 | 2292 | default=True, |
|
2287 | 2293 | ) |
|
2288 | 2294 | coreconfigitem( |
|
2289 | 2295 | b'ui', |
|
2290 | 2296 | b'patch', |
|
2291 | 2297 | default=None, |
|
2292 | 2298 | ) |
|
2293 | 2299 | coreconfigitem( |
|
2294 | 2300 | b'ui', |
|
2295 | 2301 | b'portablefilenames', |
|
2296 | 2302 | default=b'warn', |
|
2297 | 2303 | ) |
|
2298 | 2304 | coreconfigitem( |
|
2299 | 2305 | b'ui', |
|
2300 | 2306 | b'promptecho', |
|
2301 | 2307 | default=False, |
|
2302 | 2308 | ) |
|
2303 | 2309 | coreconfigitem( |
|
2304 | 2310 | b'ui', |
|
2305 | 2311 | b'quiet', |
|
2306 | 2312 | default=False, |
|
2307 | 2313 | ) |
|
2308 | 2314 | coreconfigitem( |
|
2309 | 2315 | b'ui', |
|
2310 | 2316 | b'quietbookmarkmove', |
|
2311 | 2317 | default=False, |
|
2312 | 2318 | ) |
|
2313 | 2319 | coreconfigitem( |
|
2314 | 2320 | b'ui', |
|
2315 | 2321 | b'relative-paths', |
|
2316 | 2322 | default=b'legacy', |
|
2317 | 2323 | ) |
|
2318 | 2324 | coreconfigitem( |
|
2319 | 2325 | b'ui', |
|
2320 | 2326 | b'remotecmd', |
|
2321 | 2327 | default=b'hg', |
|
2322 | 2328 | ) |
|
2323 | 2329 | coreconfigitem( |
|
2324 | 2330 | b'ui', |
|
2325 | 2331 | b'report_untrusted', |
|
2326 | 2332 | default=True, |
|
2327 | 2333 | ) |
|
2328 | 2334 | coreconfigitem( |
|
2329 | 2335 | b'ui', |
|
2330 | 2336 | b'rollback', |
|
2331 | 2337 | default=True, |
|
2332 | 2338 | ) |
|
2333 | 2339 | coreconfigitem( |
|
2334 | 2340 | b'ui', |
|
2335 | 2341 | b'signal-safe-lock', |
|
2336 | 2342 | default=True, |
|
2337 | 2343 | ) |
|
2338 | 2344 | coreconfigitem( |
|
2339 | 2345 | b'ui', |
|
2340 | 2346 | b'slash', |
|
2341 | 2347 | default=False, |
|
2342 | 2348 | ) |
|
2343 | 2349 | coreconfigitem( |
|
2344 | 2350 | b'ui', |
|
2345 | 2351 | b'ssh', |
|
2346 | 2352 | default=b'ssh', |
|
2347 | 2353 | ) |
|
2348 | 2354 | coreconfigitem( |
|
2349 | 2355 | b'ui', |
|
2350 | 2356 | b'ssherrorhint', |
|
2351 | 2357 | default=None, |
|
2352 | 2358 | ) |
|
2353 | 2359 | coreconfigitem( |
|
2354 | 2360 | b'ui', |
|
2355 | 2361 | b'statuscopies', |
|
2356 | 2362 | default=False, |
|
2357 | 2363 | ) |
|
2358 | 2364 | coreconfigitem( |
|
2359 | 2365 | b'ui', |
|
2360 | 2366 | b'strict', |
|
2361 | 2367 | default=False, |
|
2362 | 2368 | ) |
|
2363 | 2369 | coreconfigitem( |
|
2364 | 2370 | b'ui', |
|
2365 | 2371 | b'style', |
|
2366 | 2372 | default=b'', |
|
2367 | 2373 | ) |
|
2368 | 2374 | coreconfigitem( |
|
2369 | 2375 | b'ui', |
|
2370 | 2376 | b'supportcontact', |
|
2371 | 2377 | default=None, |
|
2372 | 2378 | ) |
|
2373 | 2379 | coreconfigitem( |
|
2374 | 2380 | b'ui', |
|
2375 | 2381 | b'textwidth', |
|
2376 | 2382 | default=78, |
|
2377 | 2383 | ) |
|
2378 | 2384 | coreconfigitem( |
|
2379 | 2385 | b'ui', |
|
2380 | 2386 | b'timeout', |
|
2381 | 2387 | default=b'600', |
|
2382 | 2388 | ) |
|
2383 | 2389 | coreconfigitem( |
|
2384 | 2390 | b'ui', |
|
2385 | 2391 | b'timeout.warn', |
|
2386 | 2392 | default=0, |
|
2387 | 2393 | ) |
|
2388 | 2394 | coreconfigitem( |
|
2389 | 2395 | b'ui', |
|
2390 | 2396 | b'timestamp-output', |
|
2391 | 2397 | default=False, |
|
2392 | 2398 | ) |
|
2393 | 2399 | coreconfigitem( |
|
2394 | 2400 | b'ui', |
|
2395 | 2401 | b'traceback', |
|
2396 | 2402 | default=False, |
|
2397 | 2403 | ) |
|
2398 | 2404 | coreconfigitem( |
|
2399 | 2405 | b'ui', |
|
2400 | 2406 | b'tweakdefaults', |
|
2401 | 2407 | default=False, |
|
2402 | 2408 | ) |
|
2403 | 2409 | coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')]) |
|
2404 | 2410 | coreconfigitem( |
|
2405 | 2411 | b'ui', |
|
2406 | 2412 | b'verbose', |
|
2407 | 2413 | default=False, |
|
2408 | 2414 | ) |
|
2409 | 2415 | coreconfigitem( |
|
2410 | 2416 | b'verify', |
|
2411 | 2417 | b'skipflags', |
|
2412 | 2418 | default=None, |
|
2413 | 2419 | ) |
|
2414 | 2420 | coreconfigitem( |
|
2415 | 2421 | b'web', |
|
2416 | 2422 | b'allowbz2', |
|
2417 | 2423 | default=False, |
|
2418 | 2424 | ) |
|
2419 | 2425 | coreconfigitem( |
|
2420 | 2426 | b'web', |
|
2421 | 2427 | b'allowgz', |
|
2422 | 2428 | default=False, |
|
2423 | 2429 | ) |
|
2424 | 2430 | coreconfigitem( |
|
2425 | 2431 | b'web', |
|
2426 | 2432 | b'allow-pull', |
|
2427 | 2433 | alias=[(b'web', b'allowpull')], |
|
2428 | 2434 | default=True, |
|
2429 | 2435 | ) |
|
2430 | 2436 | coreconfigitem( |
|
2431 | 2437 | b'web', |
|
2432 | 2438 | b'allow-push', |
|
2433 | 2439 | alias=[(b'web', b'allow_push')], |
|
2434 | 2440 | default=list, |
|
2435 | 2441 | ) |
|
2436 | 2442 | coreconfigitem( |
|
2437 | 2443 | b'web', |
|
2438 | 2444 | b'allowzip', |
|
2439 | 2445 | default=False, |
|
2440 | 2446 | ) |
|
2441 | 2447 | coreconfigitem( |
|
2442 | 2448 | b'web', |
|
2443 | 2449 | b'archivesubrepos', |
|
2444 | 2450 | default=False, |
|
2445 | 2451 | ) |
|
2446 | 2452 | coreconfigitem( |
|
2447 | 2453 | b'web', |
|
2448 | 2454 | b'cache', |
|
2449 | 2455 | default=True, |
|
2450 | 2456 | ) |
|
2451 | 2457 | coreconfigitem( |
|
2452 | 2458 | b'web', |
|
2453 | 2459 | b'comparisoncontext', |
|
2454 | 2460 | default=5, |
|
2455 | 2461 | ) |
|
2456 | 2462 | coreconfigitem( |
|
2457 | 2463 | b'web', |
|
2458 | 2464 | b'contact', |
|
2459 | 2465 | default=None, |
|
2460 | 2466 | ) |
|
2461 | 2467 | coreconfigitem( |
|
2462 | 2468 | b'web', |
|
2463 | 2469 | b'deny_push', |
|
2464 | 2470 | default=list, |
|
2465 | 2471 | ) |
|
2466 | 2472 | coreconfigitem( |
|
2467 | 2473 | b'web', |
|
2468 | 2474 | b'guessmime', |
|
2469 | 2475 | default=False, |
|
2470 | 2476 | ) |
|
2471 | 2477 | coreconfigitem( |
|
2472 | 2478 | b'web', |
|
2473 | 2479 | b'hidden', |
|
2474 | 2480 | default=False, |
|
2475 | 2481 | ) |
|
2476 | 2482 | coreconfigitem( |
|
2477 | 2483 | b'web', |
|
2478 | 2484 | b'labels', |
|
2479 | 2485 | default=list, |
|
2480 | 2486 | ) |
|
2481 | 2487 | coreconfigitem( |
|
2482 | 2488 | b'web', |
|
2483 | 2489 | b'logoimg', |
|
2484 | 2490 | default=b'hglogo.png', |
|
2485 | 2491 | ) |
|
2486 | 2492 | coreconfigitem( |
|
2487 | 2493 | b'web', |
|
2488 | 2494 | b'logourl', |
|
2489 | 2495 | default=b'https://mercurial-scm.org/', |
|
2490 | 2496 | ) |
|
2491 | 2497 | coreconfigitem( |
|
2492 | 2498 | b'web', |
|
2493 | 2499 | b'accesslog', |
|
2494 | 2500 | default=b'-', |
|
2495 | 2501 | ) |
|
2496 | 2502 | coreconfigitem( |
|
2497 | 2503 | b'web', |
|
2498 | 2504 | b'address', |
|
2499 | 2505 | default=b'', |
|
2500 | 2506 | ) |
|
2501 | 2507 | coreconfigitem( |
|
2502 | 2508 | b'web', |
|
2503 | 2509 | b'allow-archive', |
|
2504 | 2510 | alias=[(b'web', b'allow_archive')], |
|
2505 | 2511 | default=list, |
|
2506 | 2512 | ) |
|
2507 | 2513 | coreconfigitem( |
|
2508 | 2514 | b'web', |
|
2509 | 2515 | b'allow_read', |
|
2510 | 2516 | default=list, |
|
2511 | 2517 | ) |
|
2512 | 2518 | coreconfigitem( |
|
2513 | 2519 | b'web', |
|
2514 | 2520 | b'baseurl', |
|
2515 | 2521 | default=None, |
|
2516 | 2522 | ) |
|
2517 | 2523 | coreconfigitem( |
|
2518 | 2524 | b'web', |
|
2519 | 2525 | b'cacerts', |
|
2520 | 2526 | default=None, |
|
2521 | 2527 | ) |
|
2522 | 2528 | coreconfigitem( |
|
2523 | 2529 | b'web', |
|
2524 | 2530 | b'certificate', |
|
2525 | 2531 | default=None, |
|
2526 | 2532 | ) |
|
2527 | 2533 | coreconfigitem( |
|
2528 | 2534 | b'web', |
|
2529 | 2535 | b'collapse', |
|
2530 | 2536 | default=False, |
|
2531 | 2537 | ) |
|
2532 | 2538 | coreconfigitem( |
|
2533 | 2539 | b'web', |
|
2534 | 2540 | b'csp', |
|
2535 | 2541 | default=None, |
|
2536 | 2542 | ) |
|
2537 | 2543 | coreconfigitem( |
|
2538 | 2544 | b'web', |
|
2539 | 2545 | b'deny_read', |
|
2540 | 2546 | default=list, |
|
2541 | 2547 | ) |
|
2542 | 2548 | coreconfigitem( |
|
2543 | 2549 | b'web', |
|
2544 | 2550 | b'descend', |
|
2545 | 2551 | default=True, |
|
2546 | 2552 | ) |
|
2547 | 2553 | coreconfigitem( |
|
2548 | 2554 | b'web', |
|
2549 | 2555 | b'description', |
|
2550 | 2556 | default=b"", |
|
2551 | 2557 | ) |
|
2552 | 2558 | coreconfigitem( |
|
2553 | 2559 | b'web', |
|
2554 | 2560 | b'encoding', |
|
2555 | 2561 | default=lambda: encoding.encoding, |
|
2556 | 2562 | ) |
|
2557 | 2563 | coreconfigitem( |
|
2558 | 2564 | b'web', |
|
2559 | 2565 | b'errorlog', |
|
2560 | 2566 | default=b'-', |
|
2561 | 2567 | ) |
|
2562 | 2568 | coreconfigitem( |
|
2563 | 2569 | b'web', |
|
2564 | 2570 | b'ipv6', |
|
2565 | 2571 | default=False, |
|
2566 | 2572 | ) |
|
2567 | 2573 | coreconfigitem( |
|
2568 | 2574 | b'web', |
|
2569 | 2575 | b'maxchanges', |
|
2570 | 2576 | default=10, |
|
2571 | 2577 | ) |
|
2572 | 2578 | coreconfigitem( |
|
2573 | 2579 | b'web', |
|
2574 | 2580 | b'maxfiles', |
|
2575 | 2581 | default=10, |
|
2576 | 2582 | ) |
|
2577 | 2583 | coreconfigitem( |
|
2578 | 2584 | b'web', |
|
2579 | 2585 | b'maxshortchanges', |
|
2580 | 2586 | default=60, |
|
2581 | 2587 | ) |
|
2582 | 2588 | coreconfigitem( |
|
2583 | 2589 | b'web', |
|
2584 | 2590 | b'motd', |
|
2585 | 2591 | default=b'', |
|
2586 | 2592 | ) |
|
2587 | 2593 | coreconfigitem( |
|
2588 | 2594 | b'web', |
|
2589 | 2595 | b'name', |
|
2590 | 2596 | default=dynamicdefault, |
|
2591 | 2597 | ) |
|
2592 | 2598 | coreconfigitem( |
|
2593 | 2599 | b'web', |
|
2594 | 2600 | b'port', |
|
2595 | 2601 | default=8000, |
|
2596 | 2602 | ) |
|
2597 | 2603 | coreconfigitem( |
|
2598 | 2604 | b'web', |
|
2599 | 2605 | b'prefix', |
|
2600 | 2606 | default=b'', |
|
2601 | 2607 | ) |
|
2602 | 2608 | coreconfigitem( |
|
2603 | 2609 | b'web', |
|
2604 | 2610 | b'push_ssl', |
|
2605 | 2611 | default=True, |
|
2606 | 2612 | ) |
|
2607 | 2613 | coreconfigitem( |
|
2608 | 2614 | b'web', |
|
2609 | 2615 | b'refreshinterval', |
|
2610 | 2616 | default=20, |
|
2611 | 2617 | ) |
|
2612 | 2618 | coreconfigitem( |
|
2613 | 2619 | b'web', |
|
2614 | 2620 | b'server-header', |
|
2615 | 2621 | default=None, |
|
2616 | 2622 | ) |
|
2617 | 2623 | coreconfigitem( |
|
2618 | 2624 | b'web', |
|
2619 | 2625 | b'static', |
|
2620 | 2626 | default=None, |
|
2621 | 2627 | ) |
|
2622 | 2628 | coreconfigitem( |
|
2623 | 2629 | b'web', |
|
2624 | 2630 | b'staticurl', |
|
2625 | 2631 | default=None, |
|
2626 | 2632 | ) |
|
2627 | 2633 | coreconfigitem( |
|
2628 | 2634 | b'web', |
|
2629 | 2635 | b'stripes', |
|
2630 | 2636 | default=1, |
|
2631 | 2637 | ) |
|
2632 | 2638 | coreconfigitem( |
|
2633 | 2639 | b'web', |
|
2634 | 2640 | b'style', |
|
2635 | 2641 | default=b'paper', |
|
2636 | 2642 | ) |
|
2637 | 2643 | coreconfigitem( |
|
2638 | 2644 | b'web', |
|
2639 | 2645 | b'templates', |
|
2640 | 2646 | default=None, |
|
2641 | 2647 | ) |
|
2642 | 2648 | coreconfigitem( |
|
2643 | 2649 | b'web', |
|
2644 | 2650 | b'view', |
|
2645 | 2651 | default=b'served', |
|
2646 | 2652 | experimental=True, |
|
2647 | 2653 | ) |
|
2648 | 2654 | coreconfigitem( |
|
2649 | 2655 | b'worker', |
|
2650 | 2656 | b'backgroundclose', |
|
2651 | 2657 | default=dynamicdefault, |
|
2652 | 2658 | ) |
|
2653 | 2659 | # Windows defaults to a limit of 512 open files. A buffer of 128 |
|
2654 | 2660 | # should give us enough headway. |
|
2655 | 2661 | coreconfigitem( |
|
2656 | 2662 | b'worker', |
|
2657 | 2663 | b'backgroundclosemaxqueue', |
|
2658 | 2664 | default=384, |
|
2659 | 2665 | ) |
|
2660 | 2666 | coreconfigitem( |
|
2661 | 2667 | b'worker', |
|
2662 | 2668 | b'backgroundcloseminfilecount', |
|
2663 | 2669 | default=2048, |
|
2664 | 2670 | ) |
|
2665 | 2671 | coreconfigitem( |
|
2666 | 2672 | b'worker', |
|
2667 | 2673 | b'backgroundclosethreadcount', |
|
2668 | 2674 | default=4, |
|
2669 | 2675 | ) |
|
2670 | 2676 | coreconfigitem( |
|
2671 | 2677 | b'worker', |
|
2672 | 2678 | b'enabled', |
|
2673 | 2679 | default=True, |
|
2674 | 2680 | ) |
|
2675 | 2681 | coreconfigitem( |
|
2676 | 2682 | b'worker', |
|
2677 | 2683 | b'numcpus', |
|
2678 | 2684 | default=None, |
|
2679 | 2685 | ) |
|
2680 | 2686 | |
|
2681 | 2687 | # Rebase related configuration moved to core because other extension are doing |
|
2682 | 2688 | # strange things. For example, shelve import the extensions to reuse some bit |
|
2683 | 2689 | # without formally loading it. |
|
2684 | 2690 | coreconfigitem( |
|
2685 | 2691 | b'commands', |
|
2686 | 2692 | b'rebase.requiredest', |
|
2687 | 2693 | default=False, |
|
2688 | 2694 | ) |
|
2689 | 2695 | coreconfigitem( |
|
2690 | 2696 | b'experimental', |
|
2691 | 2697 | b'rebaseskipobsolete', |
|
2692 | 2698 | default=True, |
|
2693 | 2699 | ) |
|
2694 | 2700 | coreconfigitem( |
|
2695 | 2701 | b'rebase', |
|
2696 | 2702 | b'singletransaction', |
|
2697 | 2703 | default=False, |
|
2698 | 2704 | ) |
|
2699 | 2705 | coreconfigitem( |
|
2700 | 2706 | b'rebase', |
|
2701 | 2707 | b'experimental.inmemory', |
|
2702 | 2708 | default=False, |
|
2703 | 2709 | ) |
@@ -1,1430 +1,1477 b'' | |||
|
1 | 1 | # dirstate.py - working directory tracking for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import collections |
|
11 | 11 | import contextlib |
|
12 | 12 | import errno |
|
13 | 13 | import os |
|
14 | 14 | import stat |
|
15 | import uuid | |
|
15 | 16 | |
|
16 | 17 | from .i18n import _ |
|
17 | 18 | from .pycompat import delattr |
|
18 | 19 | |
|
19 | 20 | from hgdemandimport import tracing |
|
20 | 21 | |
|
21 | 22 | from . import ( |
|
22 | 23 | dirstatemap, |
|
23 | 24 | encoding, |
|
24 | 25 | error, |
|
25 | 26 | match as matchmod, |
|
27 | node, | |
|
26 | 28 | pathutil, |
|
27 | 29 | policy, |
|
28 | 30 | pycompat, |
|
29 | 31 | scmutil, |
|
30 | 32 | sparse, |
|
31 | 33 | util, |
|
32 | 34 | ) |
|
33 | 35 | |
|
34 | 36 | from .dirstateutils import ( |
|
35 | 37 | timestamp, |
|
36 | 38 | ) |
|
37 | 39 | |
|
38 | 40 | from .interfaces import ( |
|
39 | 41 | dirstate as intdirstate, |
|
40 | 42 | util as interfaceutil, |
|
41 | 43 | ) |
|
42 | 44 | |
|
43 | 45 | parsers = policy.importmod('parsers') |
|
44 | 46 | rustmod = policy.importrust('dirstate') |
|
45 | 47 | |
|
46 | 48 | HAS_FAST_DIRSTATE_V2 = rustmod is not None |
|
47 | 49 | |
|
48 | 50 | propertycache = util.propertycache |
|
49 | 51 | filecache = scmutil.filecache |
|
50 | 52 | _rangemask = dirstatemap.rangemask |
|
51 | 53 | |
|
52 | 54 | DirstateItem = dirstatemap.DirstateItem |
|
53 | 55 | |
|
54 | 56 | |
|
55 | 57 | class repocache(filecache): |
|
56 | 58 | """filecache for files in .hg/""" |
|
57 | 59 | |
|
58 | 60 | def join(self, obj, fname): |
|
59 | 61 | return obj._opener.join(fname) |
|
60 | 62 | |
|
61 | 63 | |
|
62 | 64 | class rootcache(filecache): |
|
63 | 65 | """filecache for files in the repository root""" |
|
64 | 66 | |
|
65 | 67 | def join(self, obj, fname): |
|
66 | 68 | return obj._join(fname) |
|
67 | 69 | |
|
68 | 70 | |
|
69 | 71 | def requires_parents_change(func): |
|
70 | 72 | def wrap(self, *args, **kwargs): |
|
71 | 73 | if not self.pendingparentchange(): |
|
72 | 74 | msg = 'calling `%s` outside of a parentchange context' |
|
73 | 75 | msg %= func.__name__ |
|
74 | 76 | raise error.ProgrammingError(msg) |
|
75 | 77 | return func(self, *args, **kwargs) |
|
76 | 78 | |
|
77 | 79 | return wrap |
|
78 | 80 | |
|
79 | 81 | |
|
80 | 82 | def requires_no_parents_change(func): |
|
81 | 83 | def wrap(self, *args, **kwargs): |
|
82 | 84 | if self.pendingparentchange(): |
|
83 | 85 | msg = 'calling `%s` inside of a parentchange context' |
|
84 | 86 | msg %= func.__name__ |
|
85 | 87 | raise error.ProgrammingError(msg) |
|
86 | 88 | return func(self, *args, **kwargs) |
|
87 | 89 | |
|
88 | 90 | return wrap |
|
89 | 91 | |
|
90 | 92 | |
|
91 | 93 | @interfaceutil.implementer(intdirstate.idirstate) |
|
92 | 94 | class dirstate(object): |
|
93 | 95 | def __init__( |
|
94 | 96 | self, |
|
95 | 97 | opener, |
|
96 | 98 | ui, |
|
97 | 99 | root, |
|
98 | 100 | validate, |
|
99 | 101 | sparsematchfn, |
|
100 | 102 | nodeconstants, |
|
101 | 103 | use_dirstate_v2, |
|
104 | use_tracked_key=False, | |
|
102 | 105 | ): |
|
103 | 106 | """Create a new dirstate object. |
|
104 | 107 | |
|
105 | 108 | opener is an open()-like callable that can be used to open the |
|
106 | 109 | dirstate file; root is the root of the directory tracked by |
|
107 | 110 | the dirstate. |
|
108 | 111 | """ |
|
109 | 112 | self._use_dirstate_v2 = use_dirstate_v2 |
|
113 | self._use_tracked_key = use_tracked_key | |
|
110 | 114 | self._nodeconstants = nodeconstants |
|
111 | 115 | self._opener = opener |
|
112 | 116 | self._validate = validate |
|
113 | 117 | self._root = root |
|
114 | 118 | self._sparsematchfn = sparsematchfn |
|
115 | 119 | # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is |
|
116 | 120 | # UNC path pointing to root share (issue4557) |
|
117 | 121 | self._rootdir = pathutil.normasprefix(root) |
|
122 | # True is any internal state may be different | |
|
118 | 123 | self._dirty = False |
|
124 | # True if the set of tracked file may be different | |
|
125 | self._dirty_tracked_set = False | |
|
119 | 126 | self._ui = ui |
|
120 | 127 | self._filecache = {} |
|
121 | 128 | self._parentwriters = 0 |
|
122 | 129 | self._filename = b'dirstate' |
|
130 | self._filename_tk = b'dirstate-tracked-key' | |
|
123 | 131 | self._pendingfilename = b'%s.pending' % self._filename |
|
124 | 132 | self._plchangecallbacks = {} |
|
125 | 133 | self._origpl = None |
|
126 | 134 | self._mapcls = dirstatemap.dirstatemap |
|
127 | 135 | # Access and cache cwd early, so we don't access it for the first time |
|
128 | 136 | # after a working-copy update caused it to not exist (accessing it then |
|
129 | 137 | # raises an exception). |
|
130 | 138 | self._cwd |
|
131 | 139 | |
|
132 | 140 | def prefetch_parents(self): |
|
133 | 141 | """make sure the parents are loaded |
|
134 | 142 | |
|
135 | 143 | Used to avoid a race condition. |
|
136 | 144 | """ |
|
137 | 145 | self._pl |
|
138 | 146 | |
|
139 | 147 | @contextlib.contextmanager |
|
140 | 148 | def parentchange(self): |
|
141 | 149 | """Context manager for handling dirstate parents. |
|
142 | 150 | |
|
143 | 151 | If an exception occurs in the scope of the context manager, |
|
144 | 152 | the incoherent dirstate won't be written when wlock is |
|
145 | 153 | released. |
|
146 | 154 | """ |
|
147 | 155 | self._parentwriters += 1 |
|
148 | 156 | yield |
|
149 | 157 | # Typically we want the "undo" step of a context manager in a |
|
150 | 158 | # finally block so it happens even when an exception |
|
151 | 159 | # occurs. In this case, however, we only want to decrement |
|
152 | 160 | # parentwriters if the code in the with statement exits |
|
153 | 161 | # normally, so we don't have a try/finally here on purpose. |
|
154 | 162 | self._parentwriters -= 1 |
|
155 | 163 | |
|
156 | 164 | def pendingparentchange(self): |
|
157 | 165 | """Returns true if the dirstate is in the middle of a set of changes |
|
158 | 166 | that modify the dirstate parent. |
|
159 | 167 | """ |
|
160 | 168 | return self._parentwriters > 0 |
|
161 | 169 | |
|
162 | 170 | @propertycache |
|
163 | 171 | def _map(self): |
|
164 | 172 | """Return the dirstate contents (see documentation for dirstatemap).""" |
|
165 | 173 | self._map = self._mapcls( |
|
166 | 174 | self._ui, |
|
167 | 175 | self._opener, |
|
168 | 176 | self._root, |
|
169 | 177 | self._nodeconstants, |
|
170 | 178 | self._use_dirstate_v2, |
|
171 | 179 | ) |
|
172 | 180 | return self._map |
|
173 | 181 | |
|
174 | 182 | @property |
|
175 | 183 | def _sparsematcher(self): |
|
176 | 184 | """The matcher for the sparse checkout. |
|
177 | 185 | |
|
178 | 186 | The working directory may not include every file from a manifest. The |
|
179 | 187 | matcher obtained by this property will match a path if it is to be |
|
180 | 188 | included in the working directory. |
|
181 | 189 | """ |
|
182 | 190 | # TODO there is potential to cache this property. For now, the matcher |
|
183 | 191 | # is resolved on every access. (But the called function does use a |
|
184 | 192 | # cache to keep the lookup fast.) |
|
185 | 193 | return self._sparsematchfn() |
|
186 | 194 | |
|
187 | 195 | @repocache(b'branch') |
|
188 | 196 | def _branch(self): |
|
189 | 197 | try: |
|
190 | 198 | return self._opener.read(b"branch").strip() or b"default" |
|
191 | 199 | except IOError as inst: |
|
192 | 200 | if inst.errno != errno.ENOENT: |
|
193 | 201 | raise |
|
194 | 202 | return b"default" |
|
195 | 203 | |
|
196 | 204 | @property |
|
197 | 205 | def _pl(self): |
|
198 | 206 | return self._map.parents() |
|
199 | 207 | |
|
200 | 208 | def hasdir(self, d): |
|
201 | 209 | return self._map.hastrackeddir(d) |
|
202 | 210 | |
|
203 | 211 | @rootcache(b'.hgignore') |
|
204 | 212 | def _ignore(self): |
|
205 | 213 | files = self._ignorefiles() |
|
206 | 214 | if not files: |
|
207 | 215 | return matchmod.never() |
|
208 | 216 | |
|
209 | 217 | pats = [b'include:%s' % f for f in files] |
|
210 | 218 | return matchmod.match(self._root, b'', [], pats, warn=self._ui.warn) |
|
211 | 219 | |
|
212 | 220 | @propertycache |
|
213 | 221 | def _slash(self): |
|
214 | 222 | return self._ui.configbool(b'ui', b'slash') and pycompat.ossep != b'/' |
|
215 | 223 | |
|
216 | 224 | @propertycache |
|
217 | 225 | def _checklink(self): |
|
218 | 226 | return util.checklink(self._root) |
|
219 | 227 | |
|
220 | 228 | @propertycache |
|
221 | 229 | def _checkexec(self): |
|
222 | 230 | return bool(util.checkexec(self._root)) |
|
223 | 231 | |
|
224 | 232 | @propertycache |
|
225 | 233 | def _checkcase(self): |
|
226 | 234 | return not util.fscasesensitive(self._join(b'.hg')) |
|
227 | 235 | |
|
228 | 236 | def _join(self, f): |
|
229 | 237 | # much faster than os.path.join() |
|
230 | 238 | # it's safe because f is always a relative path |
|
231 | 239 | return self._rootdir + f |
|
232 | 240 | |
|
233 | 241 | def flagfunc(self, buildfallback): |
|
234 | 242 | """build a callable that returns flags associated with a filename |
|
235 | 243 | |
|
236 | 244 | The information is extracted from three possible layers: |
|
237 | 245 | 1. the file system if it supports the information |
|
238 | 246 | 2. the "fallback" information stored in the dirstate if any |
|
239 | 247 | 3. a more expensive mechanism inferring the flags from the parents. |
|
240 | 248 | """ |
|
241 | 249 | |
|
242 | 250 | # small hack to cache the result of buildfallback() |
|
243 | 251 | fallback_func = [] |
|
244 | 252 | |
|
245 | 253 | def get_flags(x): |
|
246 | 254 | entry = None |
|
247 | 255 | fallback_value = None |
|
248 | 256 | try: |
|
249 | 257 | st = os.lstat(self._join(x)) |
|
250 | 258 | except OSError: |
|
251 | 259 | return b'' |
|
252 | 260 | |
|
253 | 261 | if self._checklink: |
|
254 | 262 | if util.statislink(st): |
|
255 | 263 | return b'l' |
|
256 | 264 | else: |
|
257 | 265 | entry = self.get_entry(x) |
|
258 | 266 | if entry.has_fallback_symlink: |
|
259 | 267 | if entry.fallback_symlink: |
|
260 | 268 | return b'l' |
|
261 | 269 | else: |
|
262 | 270 | if not fallback_func: |
|
263 | 271 | fallback_func.append(buildfallback()) |
|
264 | 272 | fallback_value = fallback_func[0](x) |
|
265 | 273 | if b'l' in fallback_value: |
|
266 | 274 | return b'l' |
|
267 | 275 | |
|
268 | 276 | if self._checkexec: |
|
269 | 277 | if util.statisexec(st): |
|
270 | 278 | return b'x' |
|
271 | 279 | else: |
|
272 | 280 | if entry is None: |
|
273 | 281 | entry = self.get_entry(x) |
|
274 | 282 | if entry.has_fallback_exec: |
|
275 | 283 | if entry.fallback_exec: |
|
276 | 284 | return b'x' |
|
277 | 285 | else: |
|
278 | 286 | if fallback_value is None: |
|
279 | 287 | if not fallback_func: |
|
280 | 288 | fallback_func.append(buildfallback()) |
|
281 | 289 | fallback_value = fallback_func[0](x) |
|
282 | 290 | if b'x' in fallback_value: |
|
283 | 291 | return b'x' |
|
284 | 292 | return b'' |
|
285 | 293 | |
|
286 | 294 | return get_flags |
|
287 | 295 | |
|
288 | 296 | @propertycache |
|
289 | 297 | def _cwd(self): |
|
290 | 298 | # internal config: ui.forcecwd |
|
291 | 299 | forcecwd = self._ui.config(b'ui', b'forcecwd') |
|
292 | 300 | if forcecwd: |
|
293 | 301 | return forcecwd |
|
294 | 302 | return encoding.getcwd() |
|
295 | 303 | |
|
296 | 304 | def getcwd(self): |
|
297 | 305 | """Return the path from which a canonical path is calculated. |
|
298 | 306 | |
|
299 | 307 | This path should be used to resolve file patterns or to convert |
|
300 | 308 | canonical paths back to file paths for display. It shouldn't be |
|
301 | 309 | used to get real file paths. Use vfs functions instead. |
|
302 | 310 | """ |
|
303 | 311 | cwd = self._cwd |
|
304 | 312 | if cwd == self._root: |
|
305 | 313 | return b'' |
|
306 | 314 | # self._root ends with a path separator if self._root is '/' or 'C:\' |
|
307 | 315 | rootsep = self._root |
|
308 | 316 | if not util.endswithsep(rootsep): |
|
309 | 317 | rootsep += pycompat.ossep |
|
310 | 318 | if cwd.startswith(rootsep): |
|
311 | 319 | return cwd[len(rootsep) :] |
|
312 | 320 | else: |
|
313 | 321 | # we're outside the repo. return an absolute path. |
|
314 | 322 | return cwd |
|
315 | 323 | |
|
316 | 324 | def pathto(self, f, cwd=None): |
|
317 | 325 | if cwd is None: |
|
318 | 326 | cwd = self.getcwd() |
|
319 | 327 | path = util.pathto(self._root, cwd, f) |
|
320 | 328 | if self._slash: |
|
321 | 329 | return util.pconvert(path) |
|
322 | 330 | return path |
|
323 | 331 | |
|
324 | 332 | def get_entry(self, path): |
|
325 | 333 | """return a DirstateItem for the associated path""" |
|
326 | 334 | entry = self._map.get(path) |
|
327 | 335 | if entry is None: |
|
328 | 336 | return DirstateItem() |
|
329 | 337 | return entry |
|
330 | 338 | |
|
331 | 339 | def __contains__(self, key): |
|
332 | 340 | return key in self._map |
|
333 | 341 | |
|
334 | 342 | def __iter__(self): |
|
335 | 343 | return iter(sorted(self._map)) |
|
336 | 344 | |
|
337 | 345 | def items(self): |
|
338 | 346 | return pycompat.iteritems(self._map) |
|
339 | 347 | |
|
340 | 348 | iteritems = items |
|
341 | 349 | |
|
342 | 350 | def parents(self): |
|
343 | 351 | return [self._validate(p) for p in self._pl] |
|
344 | 352 | |
|
345 | 353 | def p1(self): |
|
346 | 354 | return self._validate(self._pl[0]) |
|
347 | 355 | |
|
348 | 356 | def p2(self): |
|
349 | 357 | return self._validate(self._pl[1]) |
|
350 | 358 | |
|
351 | 359 | @property |
|
352 | 360 | def in_merge(self): |
|
353 | 361 | """True if a merge is in progress""" |
|
354 | 362 | return self._pl[1] != self._nodeconstants.nullid |
|
355 | 363 | |
|
356 | 364 | def branch(self): |
|
357 | 365 | return encoding.tolocal(self._branch) |
|
358 | 366 | |
|
359 | 367 | def setparents(self, p1, p2=None): |
|
360 | 368 | """Set dirstate parents to p1 and p2. |
|
361 | 369 | |
|
362 | 370 | When moving from two parents to one, "merged" entries a |
|
363 | 371 | adjusted to normal and previous copy records discarded and |
|
364 | 372 | returned by the call. |
|
365 | 373 | |
|
366 | 374 | See localrepo.setparents() |
|
367 | 375 | """ |
|
368 | 376 | if p2 is None: |
|
369 | 377 | p2 = self._nodeconstants.nullid |
|
370 | 378 | if self._parentwriters == 0: |
|
371 | 379 | raise ValueError( |
|
372 | 380 | b"cannot set dirstate parent outside of " |
|
373 | 381 | b"dirstate.parentchange context manager" |
|
374 | 382 | ) |
|
375 | 383 | |
|
376 | 384 | self._dirty = True |
|
377 | 385 | oldp2 = self._pl[1] |
|
378 | 386 | if self._origpl is None: |
|
379 | 387 | self._origpl = self._pl |
|
380 | 388 | nullid = self._nodeconstants.nullid |
|
381 | 389 | # True if we need to fold p2 related state back to a linear case |
|
382 | 390 | fold_p2 = oldp2 != nullid and p2 == nullid |
|
383 | 391 | return self._map.setparents(p1, p2, fold_p2=fold_p2) |
|
384 | 392 | |
|
385 | 393 | def setbranch(self, branch): |
|
386 | 394 | self.__class__._branch.set(self, encoding.fromlocal(branch)) |
|
387 | 395 | f = self._opener(b'branch', b'w', atomictemp=True, checkambig=True) |
|
388 | 396 | try: |
|
389 | 397 | f.write(self._branch + b'\n') |
|
390 | 398 | f.close() |
|
391 | 399 | |
|
392 | 400 | # make sure filecache has the correct stat info for _branch after |
|
393 | 401 | # replacing the underlying file |
|
394 | 402 | ce = self._filecache[b'_branch'] |
|
395 | 403 | if ce: |
|
396 | 404 | ce.refresh() |
|
397 | 405 | except: # re-raises |
|
398 | 406 | f.discard() |
|
399 | 407 | raise |
|
400 | 408 | |
|
401 | 409 | def invalidate(self): |
|
402 | 410 | """Causes the next access to reread the dirstate. |
|
403 | 411 | |
|
404 | 412 | This is different from localrepo.invalidatedirstate() because it always |
|
405 | 413 | rereads the dirstate. Use localrepo.invalidatedirstate() if you want to |
|
406 | 414 | check whether the dirstate has changed before rereading it.""" |
|
407 | 415 | |
|
408 | 416 | for a in ("_map", "_branch", "_ignore"): |
|
409 | 417 | if a in self.__dict__: |
|
410 | 418 | delattr(self, a) |
|
411 | 419 | self._dirty = False |
|
420 | self._dirty_tracked_set = False | |
|
412 | 421 | self._parentwriters = 0 |
|
413 | 422 | self._origpl = None |
|
414 | 423 | |
|
415 | 424 | def copy(self, source, dest): |
|
416 | 425 | """Mark dest as a copy of source. Unmark dest if source is None.""" |
|
417 | 426 | if source == dest: |
|
418 | 427 | return |
|
419 | 428 | self._dirty = True |
|
420 | 429 | if source is not None: |
|
421 | 430 | self._map.copymap[dest] = source |
|
422 | 431 | else: |
|
423 | 432 | self._map.copymap.pop(dest, None) |
|
424 | 433 | |
|
425 | 434 | def copied(self, file): |
|
426 | 435 | return self._map.copymap.get(file, None) |
|
427 | 436 | |
|
428 | 437 | def copies(self): |
|
429 | 438 | return self._map.copymap |
|
430 | 439 | |
|
431 | 440 | @requires_no_parents_change |
|
432 | 441 | def set_tracked(self, filename, reset_copy=False): |
|
433 | 442 | """a "public" method for generic code to mark a file as tracked |
|
434 | 443 | |
|
435 | 444 | This function is to be called outside of "update/merge" case. For |
|
436 | 445 | example by a command like `hg add X`. |
|
437 | 446 | |
|
438 | 447 | if reset_copy is set, any existing copy information will be dropped. |
|
439 | 448 | |
|
440 | 449 | return True the file was previously untracked, False otherwise. |
|
441 | 450 | """ |
|
442 | 451 | self._dirty = True |
|
443 | 452 | entry = self._map.get(filename) |
|
444 | 453 | if entry is None or not entry.tracked: |
|
445 | 454 | self._check_new_tracked_filename(filename) |
|
446 | 455 | pre_tracked = self._map.set_tracked(filename) |
|
447 | 456 | if reset_copy: |
|
448 | 457 | self._map.copymap.pop(filename, None) |
|
458 | if pre_tracked: | |
|
459 | self._dirty_tracked_set = True | |
|
449 | 460 | return pre_tracked |
|
450 | 461 | |
|
451 | 462 | @requires_no_parents_change |
|
452 | 463 | def set_untracked(self, filename): |
|
453 | 464 | """a "public" method for generic code to mark a file as untracked |
|
454 | 465 | |
|
455 | 466 | This function is to be called outside of "update/merge" case. For |
|
456 | 467 | example by a command like `hg remove X`. |
|
457 | 468 | |
|
458 | 469 | return True the file was previously tracked, False otherwise. |
|
459 | 470 | """ |
|
460 | 471 | ret = self._map.set_untracked(filename) |
|
461 | 472 | if ret: |
|
462 | 473 | self._dirty = True |
|
474 | self._dirty_tracked_set = True | |
|
463 | 475 | return ret |
|
464 | 476 | |
|
465 | 477 | @requires_no_parents_change |
|
466 | 478 | def set_clean(self, filename, parentfiledata): |
|
467 | 479 | """record that the current state of the file on disk is known to be clean""" |
|
468 | 480 | self._dirty = True |
|
469 | 481 | if not self._map[filename].tracked: |
|
470 | 482 | self._check_new_tracked_filename(filename) |
|
471 | 483 | (mode, size, mtime) = parentfiledata |
|
472 | 484 | self._map.set_clean(filename, mode, size, mtime) |
|
473 | 485 | |
|
474 | 486 | @requires_no_parents_change |
|
475 | 487 | def set_possibly_dirty(self, filename): |
|
476 | 488 | """record that the current state of the file on disk is unknown""" |
|
477 | 489 | self._dirty = True |
|
478 | 490 | self._map.set_possibly_dirty(filename) |
|
479 | 491 | |
|
480 | 492 | @requires_parents_change |
|
481 | 493 | def update_file_p1( |
|
482 | 494 | self, |
|
483 | 495 | filename, |
|
484 | 496 | p1_tracked, |
|
485 | 497 | ): |
|
486 | 498 | """Set a file as tracked in the parent (or not) |
|
487 | 499 | |
|
488 | 500 | This is to be called when adjust the dirstate to a new parent after an history |
|
489 | 501 | rewriting operation. |
|
490 | 502 | |
|
491 | 503 | It should not be called during a merge (p2 != nullid) and only within |
|
492 | 504 | a `with dirstate.parentchange():` context. |
|
493 | 505 | """ |
|
494 | 506 | if self.in_merge: |
|
495 | 507 | msg = b'update_file_reference should not be called when merging' |
|
496 | 508 | raise error.ProgrammingError(msg) |
|
497 | 509 | entry = self._map.get(filename) |
|
498 | 510 | if entry is None: |
|
499 | 511 | wc_tracked = False |
|
500 | 512 | else: |
|
501 | 513 | wc_tracked = entry.tracked |
|
502 | 514 | if not (p1_tracked or wc_tracked): |
|
503 | 515 | # the file is no longer relevant to anyone |
|
504 | 516 | if self._map.get(filename) is not None: |
|
505 | 517 | self._map.reset_state(filename) |
|
506 | 518 | self._dirty = True |
|
507 | 519 | elif (not p1_tracked) and wc_tracked: |
|
508 | 520 | if entry is not None and entry.added: |
|
509 | 521 | return # avoid dropping copy information (maybe?) |
|
510 | 522 | |
|
511 | 523 | self._map.reset_state( |
|
512 | 524 | filename, |
|
513 | 525 | wc_tracked, |
|
514 | 526 | p1_tracked, |
|
515 | 527 | # the underlying reference might have changed, we will have to |
|
516 | 528 | # check it. |
|
517 | 529 | has_meaningful_mtime=False, |
|
518 | 530 | ) |
|
519 | 531 | |
|
520 | 532 | @requires_parents_change |
|
521 | 533 | def update_file( |
|
522 | 534 | self, |
|
523 | 535 | filename, |
|
524 | 536 | wc_tracked, |
|
525 | 537 | p1_tracked, |
|
526 | 538 | p2_info=False, |
|
527 | 539 | possibly_dirty=False, |
|
528 | 540 | parentfiledata=None, |
|
529 | 541 | ): |
|
530 | 542 | """update the information about a file in the dirstate |
|
531 | 543 | |
|
532 | 544 | This is to be called when the direstates parent changes to keep track |
|
533 | 545 | of what is the file situation in regards to the working copy and its parent. |
|
534 | 546 | |
|
535 | 547 | This function must be called within a `dirstate.parentchange` context. |
|
536 | 548 | |
|
537 | 549 | note: the API is at an early stage and we might need to adjust it |
|
538 | 550 | depending of what information ends up being relevant and useful to |
|
539 | 551 | other processing. |
|
540 | 552 | """ |
|
541 | 553 | |
|
542 | 554 | # note: I do not think we need to double check name clash here since we |
|
543 | 555 | # are in a update/merge case that should already have taken care of |
|
544 | 556 | # this. The test agrees |
|
545 | 557 | |
|
546 | 558 | self._dirty = True |
|
559 | old_entry = self._map.get(filename) | |
|
560 | if old_entry is None: | |
|
561 | prev_tracked = False | |
|
562 | else: | |
|
563 | prev_tracked = old_entry.tracked | |
|
564 | if prev_tracked != wc_tracked: | |
|
565 | self._dirty_tracked_set = True | |
|
547 | 566 | |
|
548 | 567 | self._map.reset_state( |
|
549 | 568 | filename, |
|
550 | 569 | wc_tracked, |
|
551 | 570 | p1_tracked, |
|
552 | 571 | p2_info=p2_info, |
|
553 | 572 | has_meaningful_mtime=not possibly_dirty, |
|
554 | 573 | parentfiledata=parentfiledata, |
|
555 | 574 | ) |
|
556 | 575 | |
|
557 | 576 | def _check_new_tracked_filename(self, filename): |
|
558 | 577 | scmutil.checkfilename(filename) |
|
559 | 578 | if self._map.hastrackeddir(filename): |
|
560 | 579 | msg = _(b'directory %r already in dirstate') |
|
561 | 580 | msg %= pycompat.bytestr(filename) |
|
562 | 581 | raise error.Abort(msg) |
|
563 | 582 | # shadows |
|
564 | 583 | for d in pathutil.finddirs(filename): |
|
565 | 584 | if self._map.hastrackeddir(d): |
|
566 | 585 | break |
|
567 | 586 | entry = self._map.get(d) |
|
568 | 587 | if entry is not None and not entry.removed: |
|
569 | 588 | msg = _(b'file %r in dirstate clashes with %r') |
|
570 | 589 | msg %= (pycompat.bytestr(d), pycompat.bytestr(filename)) |
|
571 | 590 | raise error.Abort(msg) |
|
572 | 591 | |
|
573 | 592 | def _discoverpath(self, path, normed, ignoremissing, exists, storemap): |
|
574 | 593 | if exists is None: |
|
575 | 594 | exists = os.path.lexists(os.path.join(self._root, path)) |
|
576 | 595 | if not exists: |
|
577 | 596 | # Maybe a path component exists |
|
578 | 597 | if not ignoremissing and b'/' in path: |
|
579 | 598 | d, f = path.rsplit(b'/', 1) |
|
580 | 599 | d = self._normalize(d, False, ignoremissing, None) |
|
581 | 600 | folded = d + b"/" + f |
|
582 | 601 | else: |
|
583 | 602 | # No path components, preserve original case |
|
584 | 603 | folded = path |
|
585 | 604 | else: |
|
586 | 605 | # recursively normalize leading directory components |
|
587 | 606 | # against dirstate |
|
588 | 607 | if b'/' in normed: |
|
589 | 608 | d, f = normed.rsplit(b'/', 1) |
|
590 | 609 | d = self._normalize(d, False, ignoremissing, True) |
|
591 | 610 | r = self._root + b"/" + d |
|
592 | 611 | folded = d + b"/" + util.fspath(f, r) |
|
593 | 612 | else: |
|
594 | 613 | folded = util.fspath(normed, self._root) |
|
595 | 614 | storemap[normed] = folded |
|
596 | 615 | |
|
597 | 616 | return folded |
|
598 | 617 | |
|
599 | 618 | def _normalizefile(self, path, isknown, ignoremissing=False, exists=None): |
|
600 | 619 | normed = util.normcase(path) |
|
601 | 620 | folded = self._map.filefoldmap.get(normed, None) |
|
602 | 621 | if folded is None: |
|
603 | 622 | if isknown: |
|
604 | 623 | folded = path |
|
605 | 624 | else: |
|
606 | 625 | folded = self._discoverpath( |
|
607 | 626 | path, normed, ignoremissing, exists, self._map.filefoldmap |
|
608 | 627 | ) |
|
609 | 628 | return folded |
|
610 | 629 | |
|
611 | 630 | def _normalize(self, path, isknown, ignoremissing=False, exists=None): |
|
612 | 631 | normed = util.normcase(path) |
|
613 | 632 | folded = self._map.filefoldmap.get(normed, None) |
|
614 | 633 | if folded is None: |
|
615 | 634 | folded = self._map.dirfoldmap.get(normed, None) |
|
616 | 635 | if folded is None: |
|
617 | 636 | if isknown: |
|
618 | 637 | folded = path |
|
619 | 638 | else: |
|
620 | 639 | # store discovered result in dirfoldmap so that future |
|
621 | 640 | # normalizefile calls don't start matching directories |
|
622 | 641 | folded = self._discoverpath( |
|
623 | 642 | path, normed, ignoremissing, exists, self._map.dirfoldmap |
|
624 | 643 | ) |
|
625 | 644 | return folded |
|
626 | 645 | |
|
627 | 646 | def normalize(self, path, isknown=False, ignoremissing=False): |
|
628 | 647 | """ |
|
629 | 648 | normalize the case of a pathname when on a casefolding filesystem |
|
630 | 649 | |
|
631 | 650 | isknown specifies whether the filename came from walking the |
|
632 | 651 | disk, to avoid extra filesystem access. |
|
633 | 652 | |
|
634 | 653 | If ignoremissing is True, missing path are returned |
|
635 | 654 | unchanged. Otherwise, we try harder to normalize possibly |
|
636 | 655 | existing path components. |
|
637 | 656 | |
|
638 | 657 | The normalized case is determined based on the following precedence: |
|
639 | 658 | |
|
640 | 659 | - version of name already stored in the dirstate |
|
641 | 660 | - version of name stored on disk |
|
642 | 661 | - version provided via command arguments |
|
643 | 662 | """ |
|
644 | 663 | |
|
645 | 664 | if self._checkcase: |
|
646 | 665 | return self._normalize(path, isknown, ignoremissing) |
|
647 | 666 | return path |
|
648 | 667 | |
|
649 | 668 | def clear(self): |
|
650 | 669 | self._map.clear() |
|
651 | 670 | self._dirty = True |
|
652 | 671 | |
|
653 | 672 | def rebuild(self, parent, allfiles, changedfiles=None): |
|
654 | 673 | if changedfiles is None: |
|
655 | 674 | # Rebuild entire dirstate |
|
656 | 675 | to_lookup = allfiles |
|
657 | 676 | to_drop = [] |
|
658 | 677 | self.clear() |
|
659 | 678 | elif len(changedfiles) < 10: |
|
660 | 679 | # Avoid turning allfiles into a set, which can be expensive if it's |
|
661 | 680 | # large. |
|
662 | 681 | to_lookup = [] |
|
663 | 682 | to_drop = [] |
|
664 | 683 | for f in changedfiles: |
|
665 | 684 | if f in allfiles: |
|
666 | 685 | to_lookup.append(f) |
|
667 | 686 | else: |
|
668 | 687 | to_drop.append(f) |
|
669 | 688 | else: |
|
670 | 689 | changedfilesset = set(changedfiles) |
|
671 | 690 | to_lookup = changedfilesset & set(allfiles) |
|
672 | 691 | to_drop = changedfilesset - to_lookup |
|
673 | 692 | |
|
674 | 693 | if self._origpl is None: |
|
675 | 694 | self._origpl = self._pl |
|
676 | 695 | self._map.setparents(parent, self._nodeconstants.nullid) |
|
677 | 696 | |
|
678 | 697 | for f in to_lookup: |
|
679 | 698 | |
|
680 | 699 | if self.in_merge: |
|
681 | 700 | self.set_tracked(f) |
|
682 | 701 | else: |
|
683 | 702 | self._map.reset_state( |
|
684 | 703 | f, |
|
685 | 704 | wc_tracked=True, |
|
686 | 705 | p1_tracked=True, |
|
687 | 706 | ) |
|
688 | 707 | for f in to_drop: |
|
689 | 708 | self._map.reset_state(f) |
|
690 | 709 | |
|
691 | 710 | self._dirty = True |
|
692 | 711 | |
|
693 | 712 | def identity(self): |
|
694 | 713 | """Return identity of dirstate itself to detect changing in storage |
|
695 | 714 | |
|
696 | 715 | If identity of previous dirstate is equal to this, writing |
|
697 | 716 | changes based on the former dirstate out can keep consistency. |
|
698 | 717 | """ |
|
699 | 718 | return self._map.identity |
|
700 | 719 | |
|
701 | 720 | def write(self, tr): |
|
702 | 721 | if not self._dirty: |
|
703 | 722 | return |
|
704 | 723 | |
|
705 | filename = self._filename | |
|
724 | write_key = self._use_tracked_key and self._dirty_tracked_set | |
|
706 | 725 | if tr: |
|
707 | 726 | # delay writing in-memory changes out |
|
727 | if write_key: | |
|
728 | tr.addfilegenerator( | |
|
729 | b'dirstate-0-key-pre', | |
|
730 | (self._filename_tk,), | |
|
731 | lambda f: self._write_tracked_key(tr, f), | |
|
732 | location=b'plain', | |
|
733 | ) | |
|
708 | 734 | tr.addfilegenerator( |
|
709 | 735 | b'dirstate-1-main', |
|
710 | 736 | (self._filename,), |
|
711 | 737 | lambda f: self._writedirstate(tr, f), |
|
712 | 738 | location=b'plain', |
|
713 | 739 | ) |
|
740 | if write_key: | |
|
741 | tr.addfilegenerator( | |
|
742 | b'dirstate-2-key-post', | |
|
743 | (self._filename_tk,), | |
|
744 | lambda f: self._write_tracked_key(tr, f), | |
|
745 | location=b'plain', | |
|
746 | ) | |
|
714 | 747 | return |
|
715 | 748 | |
|
716 | 749 | file = lambda f: self._opener(f, b"w", atomictemp=True, checkambig=True) |
|
750 | if write_key: | |
|
751 | # we change the key-file before changing the dirstate to make sure | |
|
752 | # reading invalidate there cache before we start writing | |
|
753 | with file(self._filename_tk) as f: | |
|
754 | self._write_tracked_key(tr, f) | |
|
717 | 755 | with file(self._filename) as f: |
|
718 | 756 | self._writedirstate(tr, f) |
|
757 | if write_key: | |
|
758 | # we update the key-file after writing to make sure reader have a | |
|
759 | # key that match the newly written content | |
|
760 | with file(self._filename_tk) as f: | |
|
761 | self._write_tracked_key(tr, f) | |
|
719 | 762 | |
|
720 | 763 | def addparentchangecallback(self, category, callback): |
|
721 | 764 | """add a callback to be called when the wd parents are changed |
|
722 | 765 | |
|
723 | 766 | Callback will be called with the following arguments: |
|
724 | 767 | dirstate, (oldp1, oldp2), (newp1, newp2) |
|
725 | 768 | |
|
726 | 769 | Category is a unique identifier to allow overwriting an old callback |
|
727 | 770 | with a newer callback. |
|
728 | 771 | """ |
|
729 | 772 | self._plchangecallbacks[category] = callback |
|
730 | 773 | |
|
731 | 774 | def _writedirstate(self, tr, st): |
|
732 | 775 | # notify callbacks about parents change |
|
733 | 776 | if self._origpl is not None and self._origpl != self._pl: |
|
734 | 777 | for c, callback in sorted( |
|
735 | 778 | pycompat.iteritems(self._plchangecallbacks) |
|
736 | 779 | ): |
|
737 | 780 | callback(self, self._origpl, self._pl) |
|
738 | 781 | self._origpl = None |
|
739 | ||
|
740 | 782 | self._map.write(tr, st) |
|
741 | 783 | self._dirty = False |
|
784 | self._dirty_tracked_set = False | |
|
785 | ||
|
786 | def _write_tracked_key(self, tr, f): | |
|
787 | key = node.hex(uuid.uuid4().bytes) | |
|
788 | f.write(b"1\n%s\n" % key) # 1 is the format version | |
|
742 | 789 | |
|
743 | 790 | def _dirignore(self, f): |
|
744 | 791 | if self._ignore(f): |
|
745 | 792 | return True |
|
746 | 793 | for p in pathutil.finddirs(f): |
|
747 | 794 | if self._ignore(p): |
|
748 | 795 | return True |
|
749 | 796 | return False |
|
750 | 797 | |
|
751 | 798 | def _ignorefiles(self): |
|
752 | 799 | files = [] |
|
753 | 800 | if os.path.exists(self._join(b'.hgignore')): |
|
754 | 801 | files.append(self._join(b'.hgignore')) |
|
755 | 802 | for name, path in self._ui.configitems(b"ui"): |
|
756 | 803 | if name == b'ignore' or name.startswith(b'ignore.'): |
|
757 | 804 | # we need to use os.path.join here rather than self._join |
|
758 | 805 | # because path is arbitrary and user-specified |
|
759 | 806 | files.append(os.path.join(self._rootdir, util.expandpath(path))) |
|
760 | 807 | return files |
|
761 | 808 | |
|
762 | 809 | def _ignorefileandline(self, f): |
|
763 | 810 | files = collections.deque(self._ignorefiles()) |
|
764 | 811 | visited = set() |
|
765 | 812 | while files: |
|
766 | 813 | i = files.popleft() |
|
767 | 814 | patterns = matchmod.readpatternfile( |
|
768 | 815 | i, self._ui.warn, sourceinfo=True |
|
769 | 816 | ) |
|
770 | 817 | for pattern, lineno, line in patterns: |
|
771 | 818 | kind, p = matchmod._patsplit(pattern, b'glob') |
|
772 | 819 | if kind == b"subinclude": |
|
773 | 820 | if p not in visited: |
|
774 | 821 | files.append(p) |
|
775 | 822 | continue |
|
776 | 823 | m = matchmod.match( |
|
777 | 824 | self._root, b'', [], [pattern], warn=self._ui.warn |
|
778 | 825 | ) |
|
779 | 826 | if m(f): |
|
780 | 827 | return (i, lineno, line) |
|
781 | 828 | visited.add(i) |
|
782 | 829 | return (None, -1, b"") |
|
783 | 830 | |
|
784 | 831 | def _walkexplicit(self, match, subrepos): |
|
785 | 832 | """Get stat data about the files explicitly specified by match. |
|
786 | 833 | |
|
787 | 834 | Return a triple (results, dirsfound, dirsnotfound). |
|
788 | 835 | - results is a mapping from filename to stat result. It also contains |
|
789 | 836 | listings mapping subrepos and .hg to None. |
|
790 | 837 | - dirsfound is a list of files found to be directories. |
|
791 | 838 | - dirsnotfound is a list of files that the dirstate thinks are |
|
792 | 839 | directories and that were not found.""" |
|
793 | 840 | |
|
794 | 841 | def badtype(mode): |
|
795 | 842 | kind = _(b'unknown') |
|
796 | 843 | if stat.S_ISCHR(mode): |
|
797 | 844 | kind = _(b'character device') |
|
798 | 845 | elif stat.S_ISBLK(mode): |
|
799 | 846 | kind = _(b'block device') |
|
800 | 847 | elif stat.S_ISFIFO(mode): |
|
801 | 848 | kind = _(b'fifo') |
|
802 | 849 | elif stat.S_ISSOCK(mode): |
|
803 | 850 | kind = _(b'socket') |
|
804 | 851 | elif stat.S_ISDIR(mode): |
|
805 | 852 | kind = _(b'directory') |
|
806 | 853 | return _(b'unsupported file type (type is %s)') % kind |
|
807 | 854 | |
|
808 | 855 | badfn = match.bad |
|
809 | 856 | dmap = self._map |
|
810 | 857 | lstat = os.lstat |
|
811 | 858 | getkind = stat.S_IFMT |
|
812 | 859 | dirkind = stat.S_IFDIR |
|
813 | 860 | regkind = stat.S_IFREG |
|
814 | 861 | lnkkind = stat.S_IFLNK |
|
815 | 862 | join = self._join |
|
816 | 863 | dirsfound = [] |
|
817 | 864 | foundadd = dirsfound.append |
|
818 | 865 | dirsnotfound = [] |
|
819 | 866 | notfoundadd = dirsnotfound.append |
|
820 | 867 | |
|
821 | 868 | if not match.isexact() and self._checkcase: |
|
822 | 869 | normalize = self._normalize |
|
823 | 870 | else: |
|
824 | 871 | normalize = None |
|
825 | 872 | |
|
826 | 873 | files = sorted(match.files()) |
|
827 | 874 | subrepos.sort() |
|
828 | 875 | i, j = 0, 0 |
|
829 | 876 | while i < len(files) and j < len(subrepos): |
|
830 | 877 | subpath = subrepos[j] + b"/" |
|
831 | 878 | if files[i] < subpath: |
|
832 | 879 | i += 1 |
|
833 | 880 | continue |
|
834 | 881 | while i < len(files) and files[i].startswith(subpath): |
|
835 | 882 | del files[i] |
|
836 | 883 | j += 1 |
|
837 | 884 | |
|
838 | 885 | if not files or b'' in files: |
|
839 | 886 | files = [b''] |
|
840 | 887 | # constructing the foldmap is expensive, so don't do it for the |
|
841 | 888 | # common case where files is [''] |
|
842 | 889 | normalize = None |
|
843 | 890 | results = dict.fromkeys(subrepos) |
|
844 | 891 | results[b'.hg'] = None |
|
845 | 892 | |
|
846 | 893 | for ff in files: |
|
847 | 894 | if normalize: |
|
848 | 895 | nf = normalize(ff, False, True) |
|
849 | 896 | else: |
|
850 | 897 | nf = ff |
|
851 | 898 | if nf in results: |
|
852 | 899 | continue |
|
853 | 900 | |
|
854 | 901 | try: |
|
855 | 902 | st = lstat(join(nf)) |
|
856 | 903 | kind = getkind(st.st_mode) |
|
857 | 904 | if kind == dirkind: |
|
858 | 905 | if nf in dmap: |
|
859 | 906 | # file replaced by dir on disk but still in dirstate |
|
860 | 907 | results[nf] = None |
|
861 | 908 | foundadd((nf, ff)) |
|
862 | 909 | elif kind == regkind or kind == lnkkind: |
|
863 | 910 | results[nf] = st |
|
864 | 911 | else: |
|
865 | 912 | badfn(ff, badtype(kind)) |
|
866 | 913 | if nf in dmap: |
|
867 | 914 | results[nf] = None |
|
868 | 915 | except OSError as inst: # nf not found on disk - it is dirstate only |
|
869 | 916 | if nf in dmap: # does it exactly match a missing file? |
|
870 | 917 | results[nf] = None |
|
871 | 918 | else: # does it match a missing directory? |
|
872 | 919 | if self._map.hasdir(nf): |
|
873 | 920 | notfoundadd(nf) |
|
874 | 921 | else: |
|
875 | 922 | badfn(ff, encoding.strtolocal(inst.strerror)) |
|
876 | 923 | |
|
877 | 924 | # match.files() may contain explicitly-specified paths that shouldn't |
|
878 | 925 | # be taken; drop them from the list of files found. dirsfound/notfound |
|
879 | 926 | # aren't filtered here because they will be tested later. |
|
880 | 927 | if match.anypats(): |
|
881 | 928 | for f in list(results): |
|
882 | 929 | if f == b'.hg' or f in subrepos: |
|
883 | 930 | # keep sentinel to disable further out-of-repo walks |
|
884 | 931 | continue |
|
885 | 932 | if not match(f): |
|
886 | 933 | del results[f] |
|
887 | 934 | |
|
888 | 935 | # Case insensitive filesystems cannot rely on lstat() failing to detect |
|
889 | 936 | # a case-only rename. Prune the stat object for any file that does not |
|
890 | 937 | # match the case in the filesystem, if there are multiple files that |
|
891 | 938 | # normalize to the same path. |
|
892 | 939 | if match.isexact() and self._checkcase: |
|
893 | 940 | normed = {} |
|
894 | 941 | |
|
895 | 942 | for f, st in pycompat.iteritems(results): |
|
896 | 943 | if st is None: |
|
897 | 944 | continue |
|
898 | 945 | |
|
899 | 946 | nc = util.normcase(f) |
|
900 | 947 | paths = normed.get(nc) |
|
901 | 948 | |
|
902 | 949 | if paths is None: |
|
903 | 950 | paths = set() |
|
904 | 951 | normed[nc] = paths |
|
905 | 952 | |
|
906 | 953 | paths.add(f) |
|
907 | 954 | |
|
908 | 955 | for norm, paths in pycompat.iteritems(normed): |
|
909 | 956 | if len(paths) > 1: |
|
910 | 957 | for path in paths: |
|
911 | 958 | folded = self._discoverpath( |
|
912 | 959 | path, norm, True, None, self._map.dirfoldmap |
|
913 | 960 | ) |
|
914 | 961 | if path != folded: |
|
915 | 962 | results[path] = None |
|
916 | 963 | |
|
917 | 964 | return results, dirsfound, dirsnotfound |
|
918 | 965 | |
|
919 | 966 | def walk(self, match, subrepos, unknown, ignored, full=True): |
|
920 | 967 | """ |
|
921 | 968 | Walk recursively through the directory tree, finding all files |
|
922 | 969 | matched by match. |
|
923 | 970 | |
|
924 | 971 | If full is False, maybe skip some known-clean files. |
|
925 | 972 | |
|
926 | 973 | Return a dict mapping filename to stat-like object (either |
|
927 | 974 | mercurial.osutil.stat instance or return value of os.stat()). |
|
928 | 975 | |
|
929 | 976 | """ |
|
930 | 977 | # full is a flag that extensions that hook into walk can use -- this |
|
931 | 978 | # implementation doesn't use it at all. This satisfies the contract |
|
932 | 979 | # because we only guarantee a "maybe". |
|
933 | 980 | |
|
934 | 981 | if ignored: |
|
935 | 982 | ignore = util.never |
|
936 | 983 | dirignore = util.never |
|
937 | 984 | elif unknown: |
|
938 | 985 | ignore = self._ignore |
|
939 | 986 | dirignore = self._dirignore |
|
940 | 987 | else: |
|
941 | 988 | # if not unknown and not ignored, drop dir recursion and step 2 |
|
942 | 989 | ignore = util.always |
|
943 | 990 | dirignore = util.always |
|
944 | 991 | |
|
945 | 992 | matchfn = match.matchfn |
|
946 | 993 | matchalways = match.always() |
|
947 | 994 | matchtdir = match.traversedir |
|
948 | 995 | dmap = self._map |
|
949 | 996 | listdir = util.listdir |
|
950 | 997 | lstat = os.lstat |
|
951 | 998 | dirkind = stat.S_IFDIR |
|
952 | 999 | regkind = stat.S_IFREG |
|
953 | 1000 | lnkkind = stat.S_IFLNK |
|
954 | 1001 | join = self._join |
|
955 | 1002 | |
|
956 | 1003 | exact = skipstep3 = False |
|
957 | 1004 | if match.isexact(): # match.exact |
|
958 | 1005 | exact = True |
|
959 | 1006 | dirignore = util.always # skip step 2 |
|
960 | 1007 | elif match.prefix(): # match.match, no patterns |
|
961 | 1008 | skipstep3 = True |
|
962 | 1009 | |
|
963 | 1010 | if not exact and self._checkcase: |
|
964 | 1011 | normalize = self._normalize |
|
965 | 1012 | normalizefile = self._normalizefile |
|
966 | 1013 | skipstep3 = False |
|
967 | 1014 | else: |
|
968 | 1015 | normalize = self._normalize |
|
969 | 1016 | normalizefile = None |
|
970 | 1017 | |
|
971 | 1018 | # step 1: find all explicit files |
|
972 | 1019 | results, work, dirsnotfound = self._walkexplicit(match, subrepos) |
|
973 | 1020 | if matchtdir: |
|
974 | 1021 | for d in work: |
|
975 | 1022 | matchtdir(d[0]) |
|
976 | 1023 | for d in dirsnotfound: |
|
977 | 1024 | matchtdir(d) |
|
978 | 1025 | |
|
979 | 1026 | skipstep3 = skipstep3 and not (work or dirsnotfound) |
|
980 | 1027 | work = [d for d in work if not dirignore(d[0])] |
|
981 | 1028 | |
|
982 | 1029 | # step 2: visit subdirectories |
|
983 | 1030 | def traverse(work, alreadynormed): |
|
984 | 1031 | wadd = work.append |
|
985 | 1032 | while work: |
|
986 | 1033 | tracing.counter('dirstate.walk work', len(work)) |
|
987 | 1034 | nd = work.pop() |
|
988 | 1035 | visitentries = match.visitchildrenset(nd) |
|
989 | 1036 | if not visitentries: |
|
990 | 1037 | continue |
|
991 | 1038 | if visitentries == b'this' or visitentries == b'all': |
|
992 | 1039 | visitentries = None |
|
993 | 1040 | skip = None |
|
994 | 1041 | if nd != b'': |
|
995 | 1042 | skip = b'.hg' |
|
996 | 1043 | try: |
|
997 | 1044 | with tracing.log('dirstate.walk.traverse listdir %s', nd): |
|
998 | 1045 | entries = listdir(join(nd), stat=True, skip=skip) |
|
999 | 1046 | except OSError as inst: |
|
1000 | 1047 | if inst.errno in (errno.EACCES, errno.ENOENT): |
|
1001 | 1048 | match.bad( |
|
1002 | 1049 | self.pathto(nd), encoding.strtolocal(inst.strerror) |
|
1003 | 1050 | ) |
|
1004 | 1051 | continue |
|
1005 | 1052 | raise |
|
1006 | 1053 | for f, kind, st in entries: |
|
1007 | 1054 | # Some matchers may return files in the visitentries set, |
|
1008 | 1055 | # instead of 'this', if the matcher explicitly mentions them |
|
1009 | 1056 | # and is not an exactmatcher. This is acceptable; we do not |
|
1010 | 1057 | # make any hard assumptions about file-or-directory below |
|
1011 | 1058 | # based on the presence of `f` in visitentries. If |
|
1012 | 1059 | # visitchildrenset returned a set, we can always skip the |
|
1013 | 1060 | # entries *not* in the set it provided regardless of whether |
|
1014 | 1061 | # they're actually a file or a directory. |
|
1015 | 1062 | if visitentries and f not in visitentries: |
|
1016 | 1063 | continue |
|
1017 | 1064 | if normalizefile: |
|
1018 | 1065 | # even though f might be a directory, we're only |
|
1019 | 1066 | # interested in comparing it to files currently in the |
|
1020 | 1067 | # dmap -- therefore normalizefile is enough |
|
1021 | 1068 | nf = normalizefile( |
|
1022 | 1069 | nd and (nd + b"/" + f) or f, True, True |
|
1023 | 1070 | ) |
|
1024 | 1071 | else: |
|
1025 | 1072 | nf = nd and (nd + b"/" + f) or f |
|
1026 | 1073 | if nf not in results: |
|
1027 | 1074 | if kind == dirkind: |
|
1028 | 1075 | if not ignore(nf): |
|
1029 | 1076 | if matchtdir: |
|
1030 | 1077 | matchtdir(nf) |
|
1031 | 1078 | wadd(nf) |
|
1032 | 1079 | if nf in dmap and (matchalways or matchfn(nf)): |
|
1033 | 1080 | results[nf] = None |
|
1034 | 1081 | elif kind == regkind or kind == lnkkind: |
|
1035 | 1082 | if nf in dmap: |
|
1036 | 1083 | if matchalways or matchfn(nf): |
|
1037 | 1084 | results[nf] = st |
|
1038 | 1085 | elif (matchalways or matchfn(nf)) and not ignore( |
|
1039 | 1086 | nf |
|
1040 | 1087 | ): |
|
1041 | 1088 | # unknown file -- normalize if necessary |
|
1042 | 1089 | if not alreadynormed: |
|
1043 | 1090 | nf = normalize(nf, False, True) |
|
1044 | 1091 | results[nf] = st |
|
1045 | 1092 | elif nf in dmap and (matchalways or matchfn(nf)): |
|
1046 | 1093 | results[nf] = None |
|
1047 | 1094 | |
|
1048 | 1095 | for nd, d in work: |
|
1049 | 1096 | # alreadynormed means that processwork doesn't have to do any |
|
1050 | 1097 | # expensive directory normalization |
|
1051 | 1098 | alreadynormed = not normalize or nd == d |
|
1052 | 1099 | traverse([d], alreadynormed) |
|
1053 | 1100 | |
|
1054 | 1101 | for s in subrepos: |
|
1055 | 1102 | del results[s] |
|
1056 | 1103 | del results[b'.hg'] |
|
1057 | 1104 | |
|
1058 | 1105 | # step 3: visit remaining files from dmap |
|
1059 | 1106 | if not skipstep3 and not exact: |
|
1060 | 1107 | # If a dmap file is not in results yet, it was either |
|
1061 | 1108 | # a) not matching matchfn b) ignored, c) missing, or d) under a |
|
1062 | 1109 | # symlink directory. |
|
1063 | 1110 | if not results and matchalways: |
|
1064 | 1111 | visit = [f for f in dmap] |
|
1065 | 1112 | else: |
|
1066 | 1113 | visit = [f for f in dmap if f not in results and matchfn(f)] |
|
1067 | 1114 | visit.sort() |
|
1068 | 1115 | |
|
1069 | 1116 | if unknown: |
|
1070 | 1117 | # unknown == True means we walked all dirs under the roots |
|
1071 | 1118 | # that wasn't ignored, and everything that matched was stat'ed |
|
1072 | 1119 | # and is already in results. |
|
1073 | 1120 | # The rest must thus be ignored or under a symlink. |
|
1074 | 1121 | audit_path = pathutil.pathauditor(self._root, cached=True) |
|
1075 | 1122 | |
|
1076 | 1123 | for nf in iter(visit): |
|
1077 | 1124 | # If a stat for the same file was already added with a |
|
1078 | 1125 | # different case, don't add one for this, since that would |
|
1079 | 1126 | # make it appear as if the file exists under both names |
|
1080 | 1127 | # on disk. |
|
1081 | 1128 | if ( |
|
1082 | 1129 | normalizefile |
|
1083 | 1130 | and normalizefile(nf, True, True) in results |
|
1084 | 1131 | ): |
|
1085 | 1132 | results[nf] = None |
|
1086 | 1133 | # Report ignored items in the dmap as long as they are not |
|
1087 | 1134 | # under a symlink directory. |
|
1088 | 1135 | elif audit_path.check(nf): |
|
1089 | 1136 | try: |
|
1090 | 1137 | results[nf] = lstat(join(nf)) |
|
1091 | 1138 | # file was just ignored, no links, and exists |
|
1092 | 1139 | except OSError: |
|
1093 | 1140 | # file doesn't exist |
|
1094 | 1141 | results[nf] = None |
|
1095 | 1142 | else: |
|
1096 | 1143 | # It's either missing or under a symlink directory |
|
1097 | 1144 | # which we in this case report as missing |
|
1098 | 1145 | results[nf] = None |
|
1099 | 1146 | else: |
|
1100 | 1147 | # We may not have walked the full directory tree above, |
|
1101 | 1148 | # so stat and check everything we missed. |
|
1102 | 1149 | iv = iter(visit) |
|
1103 | 1150 | for st in util.statfiles([join(i) for i in visit]): |
|
1104 | 1151 | results[next(iv)] = st |
|
1105 | 1152 | return results |
|
1106 | 1153 | |
|
1107 | 1154 | def _rust_status(self, matcher, list_clean, list_ignored, list_unknown): |
|
1108 | 1155 | # Force Rayon (Rust parallelism library) to respect the number of |
|
1109 | 1156 | # workers. This is a temporary workaround until Rust code knows |
|
1110 | 1157 | # how to read the config file. |
|
1111 | 1158 | numcpus = self._ui.configint(b"worker", b"numcpus") |
|
1112 | 1159 | if numcpus is not None: |
|
1113 | 1160 | encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % numcpus) |
|
1114 | 1161 | |
|
1115 | 1162 | workers_enabled = self._ui.configbool(b"worker", b"enabled", True) |
|
1116 | 1163 | if not workers_enabled: |
|
1117 | 1164 | encoding.environ[b"RAYON_NUM_THREADS"] = b"1" |
|
1118 | 1165 | |
|
1119 | 1166 | ( |
|
1120 | 1167 | lookup, |
|
1121 | 1168 | modified, |
|
1122 | 1169 | added, |
|
1123 | 1170 | removed, |
|
1124 | 1171 | deleted, |
|
1125 | 1172 | clean, |
|
1126 | 1173 | ignored, |
|
1127 | 1174 | unknown, |
|
1128 | 1175 | warnings, |
|
1129 | 1176 | bad, |
|
1130 | 1177 | traversed, |
|
1131 | 1178 | dirty, |
|
1132 | 1179 | ) = rustmod.status( |
|
1133 | 1180 | self._map._map, |
|
1134 | 1181 | matcher, |
|
1135 | 1182 | self._rootdir, |
|
1136 | 1183 | self._ignorefiles(), |
|
1137 | 1184 | self._checkexec, |
|
1138 | 1185 | bool(list_clean), |
|
1139 | 1186 | bool(list_ignored), |
|
1140 | 1187 | bool(list_unknown), |
|
1141 | 1188 | bool(matcher.traversedir), |
|
1142 | 1189 | ) |
|
1143 | 1190 | |
|
1144 | 1191 | self._dirty |= dirty |
|
1145 | 1192 | |
|
1146 | 1193 | if matcher.traversedir: |
|
1147 | 1194 | for dir in traversed: |
|
1148 | 1195 | matcher.traversedir(dir) |
|
1149 | 1196 | |
|
1150 | 1197 | if self._ui.warn: |
|
1151 | 1198 | for item in warnings: |
|
1152 | 1199 | if isinstance(item, tuple): |
|
1153 | 1200 | file_path, syntax = item |
|
1154 | 1201 | msg = _(b"%s: ignoring invalid syntax '%s'\n") % ( |
|
1155 | 1202 | file_path, |
|
1156 | 1203 | syntax, |
|
1157 | 1204 | ) |
|
1158 | 1205 | self._ui.warn(msg) |
|
1159 | 1206 | else: |
|
1160 | 1207 | msg = _(b"skipping unreadable pattern file '%s': %s\n") |
|
1161 | 1208 | self._ui.warn( |
|
1162 | 1209 | msg |
|
1163 | 1210 | % ( |
|
1164 | 1211 | pathutil.canonpath( |
|
1165 | 1212 | self._rootdir, self._rootdir, item |
|
1166 | 1213 | ), |
|
1167 | 1214 | b"No such file or directory", |
|
1168 | 1215 | ) |
|
1169 | 1216 | ) |
|
1170 | 1217 | |
|
1171 | 1218 | for (fn, message) in bad: |
|
1172 | 1219 | matcher.bad(fn, encoding.strtolocal(message)) |
|
1173 | 1220 | |
|
1174 | 1221 | status = scmutil.status( |
|
1175 | 1222 | modified=modified, |
|
1176 | 1223 | added=added, |
|
1177 | 1224 | removed=removed, |
|
1178 | 1225 | deleted=deleted, |
|
1179 | 1226 | unknown=unknown, |
|
1180 | 1227 | ignored=ignored, |
|
1181 | 1228 | clean=clean, |
|
1182 | 1229 | ) |
|
1183 | 1230 | return (lookup, status) |
|
1184 | 1231 | |
|
1185 | 1232 | def status(self, match, subrepos, ignored, clean, unknown): |
|
1186 | 1233 | """Determine the status of the working copy relative to the |
|
1187 | 1234 | dirstate and return a pair of (unsure, status), where status is of type |
|
1188 | 1235 | scmutil.status and: |
|
1189 | 1236 | |
|
1190 | 1237 | unsure: |
|
1191 | 1238 | files that might have been modified since the dirstate was |
|
1192 | 1239 | written, but need to be read to be sure (size is the same |
|
1193 | 1240 | but mtime differs) |
|
1194 | 1241 | status.modified: |
|
1195 | 1242 | files that have definitely been modified since the dirstate |
|
1196 | 1243 | was written (different size or mode) |
|
1197 | 1244 | status.clean: |
|
1198 | 1245 | files that have definitely not been modified since the |
|
1199 | 1246 | dirstate was written |
|
1200 | 1247 | """ |
|
1201 | 1248 | listignored, listclean, listunknown = ignored, clean, unknown |
|
1202 | 1249 | lookup, modified, added, unknown, ignored = [], [], [], [], [] |
|
1203 | 1250 | removed, deleted, clean = [], [], [] |
|
1204 | 1251 | |
|
1205 | 1252 | dmap = self._map |
|
1206 | 1253 | dmap.preload() |
|
1207 | 1254 | |
|
1208 | 1255 | use_rust = True |
|
1209 | 1256 | |
|
1210 | 1257 | allowed_matchers = ( |
|
1211 | 1258 | matchmod.alwaysmatcher, |
|
1212 | 1259 | matchmod.exactmatcher, |
|
1213 | 1260 | matchmod.includematcher, |
|
1214 | 1261 | ) |
|
1215 | 1262 | |
|
1216 | 1263 | if rustmod is None: |
|
1217 | 1264 | use_rust = False |
|
1218 | 1265 | elif self._checkcase: |
|
1219 | 1266 | # Case-insensitive filesystems are not handled yet |
|
1220 | 1267 | use_rust = False |
|
1221 | 1268 | elif subrepos: |
|
1222 | 1269 | use_rust = False |
|
1223 | 1270 | elif sparse.enabled: |
|
1224 | 1271 | use_rust = False |
|
1225 | 1272 | elif not isinstance(match, allowed_matchers): |
|
1226 | 1273 | # Some matchers have yet to be implemented |
|
1227 | 1274 | use_rust = False |
|
1228 | 1275 | |
|
1229 | 1276 | # Get the time from the filesystem so we can disambiguate files that |
|
1230 | 1277 | # appear modified in the present or future. |
|
1231 | 1278 | try: |
|
1232 | 1279 | mtime_boundary = timestamp.get_fs_now(self._opener) |
|
1233 | 1280 | except OSError: |
|
1234 | 1281 | # In largefiles or readonly context |
|
1235 | 1282 | mtime_boundary = None |
|
1236 | 1283 | |
|
1237 | 1284 | if use_rust: |
|
1238 | 1285 | try: |
|
1239 | 1286 | res = self._rust_status( |
|
1240 | 1287 | match, listclean, listignored, listunknown |
|
1241 | 1288 | ) |
|
1242 | 1289 | return res + (mtime_boundary,) |
|
1243 | 1290 | except rustmod.FallbackError: |
|
1244 | 1291 | pass |
|
1245 | 1292 | |
|
1246 | 1293 | def noop(f): |
|
1247 | 1294 | pass |
|
1248 | 1295 | |
|
1249 | 1296 | dcontains = dmap.__contains__ |
|
1250 | 1297 | dget = dmap.__getitem__ |
|
1251 | 1298 | ladd = lookup.append # aka "unsure" |
|
1252 | 1299 | madd = modified.append |
|
1253 | 1300 | aadd = added.append |
|
1254 | 1301 | uadd = unknown.append if listunknown else noop |
|
1255 | 1302 | iadd = ignored.append if listignored else noop |
|
1256 | 1303 | radd = removed.append |
|
1257 | 1304 | dadd = deleted.append |
|
1258 | 1305 | cadd = clean.append if listclean else noop |
|
1259 | 1306 | mexact = match.exact |
|
1260 | 1307 | dirignore = self._dirignore |
|
1261 | 1308 | checkexec = self._checkexec |
|
1262 | 1309 | checklink = self._checklink |
|
1263 | 1310 | copymap = self._map.copymap |
|
1264 | 1311 | |
|
1265 | 1312 | # We need to do full walks when either |
|
1266 | 1313 | # - we're listing all clean files, or |
|
1267 | 1314 | # - match.traversedir does something, because match.traversedir should |
|
1268 | 1315 | # be called for every dir in the working dir |
|
1269 | 1316 | full = listclean or match.traversedir is not None |
|
1270 | 1317 | for fn, st in pycompat.iteritems( |
|
1271 | 1318 | self.walk(match, subrepos, listunknown, listignored, full=full) |
|
1272 | 1319 | ): |
|
1273 | 1320 | if not dcontains(fn): |
|
1274 | 1321 | if (listignored or mexact(fn)) and dirignore(fn): |
|
1275 | 1322 | if listignored: |
|
1276 | 1323 | iadd(fn) |
|
1277 | 1324 | else: |
|
1278 | 1325 | uadd(fn) |
|
1279 | 1326 | continue |
|
1280 | 1327 | |
|
1281 | 1328 | t = dget(fn) |
|
1282 | 1329 | mode = t.mode |
|
1283 | 1330 | size = t.size |
|
1284 | 1331 | |
|
1285 | 1332 | if not st and t.tracked: |
|
1286 | 1333 | dadd(fn) |
|
1287 | 1334 | elif t.p2_info: |
|
1288 | 1335 | madd(fn) |
|
1289 | 1336 | elif t.added: |
|
1290 | 1337 | aadd(fn) |
|
1291 | 1338 | elif t.removed: |
|
1292 | 1339 | radd(fn) |
|
1293 | 1340 | elif t.tracked: |
|
1294 | 1341 | if not checklink and t.has_fallback_symlink: |
|
1295 | 1342 | # If the file system does not support symlink, the mode |
|
1296 | 1343 | # might not be correctly stored in the dirstate, so do not |
|
1297 | 1344 | # trust it. |
|
1298 | 1345 | ladd(fn) |
|
1299 | 1346 | elif not checkexec and t.has_fallback_exec: |
|
1300 | 1347 | # If the file system does not support exec bits, the mode |
|
1301 | 1348 | # might not be correctly stored in the dirstate, so do not |
|
1302 | 1349 | # trust it. |
|
1303 | 1350 | ladd(fn) |
|
1304 | 1351 | elif ( |
|
1305 | 1352 | size >= 0 |
|
1306 | 1353 | and ( |
|
1307 | 1354 | (size != st.st_size and size != st.st_size & _rangemask) |
|
1308 | 1355 | or ((mode ^ st.st_mode) & 0o100 and checkexec) |
|
1309 | 1356 | ) |
|
1310 | 1357 | or fn in copymap |
|
1311 | 1358 | ): |
|
1312 | 1359 | if stat.S_ISLNK(st.st_mode) and size != st.st_size: |
|
1313 | 1360 | # issue6456: Size returned may be longer due to |
|
1314 | 1361 | # encryption on EXT-4 fscrypt, undecided. |
|
1315 | 1362 | ladd(fn) |
|
1316 | 1363 | else: |
|
1317 | 1364 | madd(fn) |
|
1318 | 1365 | elif not t.mtime_likely_equal_to(timestamp.mtime_of(st)): |
|
1319 | 1366 | # There might be a change in the future if for example the |
|
1320 | 1367 | # internal clock is off, but this is a case where the issues |
|
1321 | 1368 | # the user would face would be a lot worse and there is |
|
1322 | 1369 | # nothing we can really do. |
|
1323 | 1370 | ladd(fn) |
|
1324 | 1371 | elif listclean: |
|
1325 | 1372 | cadd(fn) |
|
1326 | 1373 | status = scmutil.status( |
|
1327 | 1374 | modified, added, removed, deleted, unknown, ignored, clean |
|
1328 | 1375 | ) |
|
1329 | 1376 | return (lookup, status, mtime_boundary) |
|
1330 | 1377 | |
|
1331 | 1378 | def matches(self, match): |
|
1332 | 1379 | """ |
|
1333 | 1380 | return files in the dirstate (in whatever state) filtered by match |
|
1334 | 1381 | """ |
|
1335 | 1382 | dmap = self._map |
|
1336 | 1383 | if rustmod is not None: |
|
1337 | 1384 | dmap = self._map._map |
|
1338 | 1385 | |
|
1339 | 1386 | if match.always(): |
|
1340 | 1387 | return dmap.keys() |
|
1341 | 1388 | files = match.files() |
|
1342 | 1389 | if match.isexact(): |
|
1343 | 1390 | # fast path -- filter the other way around, since typically files is |
|
1344 | 1391 | # much smaller than dmap |
|
1345 | 1392 | return [f for f in files if f in dmap] |
|
1346 | 1393 | if match.prefix() and all(fn in dmap for fn in files): |
|
1347 | 1394 | # fast path -- all the values are known to be files, so just return |
|
1348 | 1395 | # that |
|
1349 | 1396 | return list(files) |
|
1350 | 1397 | return [f for f in dmap if match(f)] |
|
1351 | 1398 | |
|
1352 | 1399 | def _actualfilename(self, tr): |
|
1353 | 1400 | if tr: |
|
1354 | 1401 | return self._pendingfilename |
|
1355 | 1402 | else: |
|
1356 | 1403 | return self._filename |
|
1357 | 1404 | |
|
1358 | 1405 | def savebackup(self, tr, backupname): |
|
1359 | 1406 | '''Save current dirstate into backup file''' |
|
1360 | 1407 | filename = self._actualfilename(tr) |
|
1361 | 1408 | assert backupname != filename |
|
1362 | 1409 | |
|
1363 | 1410 | # use '_writedirstate' instead of 'write' to write changes certainly, |
|
1364 | 1411 | # because the latter omits writing out if transaction is running. |
|
1365 | 1412 | # output file will be used to create backup of dirstate at this point. |
|
1366 | 1413 | if self._dirty or not self._opener.exists(filename): |
|
1367 | 1414 | self._writedirstate( |
|
1368 | 1415 | tr, |
|
1369 | 1416 | self._opener(filename, b"w", atomictemp=True, checkambig=True), |
|
1370 | 1417 | ) |
|
1371 | 1418 | |
|
1372 | 1419 | if tr: |
|
1373 | 1420 | # ensure that subsequent tr.writepending returns True for |
|
1374 | 1421 | # changes written out above, even if dirstate is never |
|
1375 | 1422 | # changed after this |
|
1376 | 1423 | tr.addfilegenerator( |
|
1377 | 1424 | b'dirstate-1-main', |
|
1378 | 1425 | (self._filename,), |
|
1379 | 1426 | lambda f: self._writedirstate(tr, f), |
|
1380 | 1427 | location=b'plain', |
|
1381 | 1428 | ) |
|
1382 | 1429 | |
|
1383 | 1430 | # ensure that pending file written above is unlinked at |
|
1384 | 1431 | # failure, even if tr.writepending isn't invoked until the |
|
1385 | 1432 | # end of this transaction |
|
1386 | 1433 | tr.registertmp(filename, location=b'plain') |
|
1387 | 1434 | |
|
1388 | 1435 | self._opener.tryunlink(backupname) |
|
1389 | 1436 | # hardlink backup is okay because _writedirstate is always called |
|
1390 | 1437 | # with an "atomictemp=True" file. |
|
1391 | 1438 | util.copyfile( |
|
1392 | 1439 | self._opener.join(filename), |
|
1393 | 1440 | self._opener.join(backupname), |
|
1394 | 1441 | hardlink=True, |
|
1395 | 1442 | ) |
|
1396 | 1443 | |
|
1397 | 1444 | def restorebackup(self, tr, backupname): |
|
1398 | 1445 | '''Restore dirstate by backup file''' |
|
1399 | 1446 | # this "invalidate()" prevents "wlock.release()" from writing |
|
1400 | 1447 | # changes of dirstate out after restoring from backup file |
|
1401 | 1448 | self.invalidate() |
|
1402 | 1449 | filename = self._actualfilename(tr) |
|
1403 | 1450 | o = self._opener |
|
1404 | 1451 | if util.samefile(o.join(backupname), o.join(filename)): |
|
1405 | 1452 | o.unlink(backupname) |
|
1406 | 1453 | else: |
|
1407 | 1454 | o.rename(backupname, filename, checkambig=True) |
|
1408 | 1455 | |
|
1409 | 1456 | def clearbackup(self, tr, backupname): |
|
1410 | 1457 | '''Clear backup file''' |
|
1411 | 1458 | self._opener.unlink(backupname) |
|
1412 | 1459 | |
|
1413 | 1460 | def verify(self, m1, m2): |
|
1414 | 1461 | """check the dirstate content again the parent manifest and yield errors""" |
|
1415 | 1462 | missing_from_p1 = b"%s in state %s, but not in manifest1\n" |
|
1416 | 1463 | unexpected_in_p1 = b"%s in state %s, but also in manifest1\n" |
|
1417 | 1464 | missing_from_ps = b"%s in state %s, but not in either manifest\n" |
|
1418 | 1465 | missing_from_ds = b"%s in manifest1, but listed as state %s\n" |
|
1419 | 1466 | for f, entry in self.items(): |
|
1420 | 1467 | state = entry.state |
|
1421 | 1468 | if state in b"nr" and f not in m1: |
|
1422 | 1469 | yield (missing_from_p1, f, state) |
|
1423 | 1470 | if state in b"a" and f in m1: |
|
1424 | 1471 | yield (unexpected_in_p1, f, state) |
|
1425 | 1472 | if state in b"m" and f not in m1 and f not in m2: |
|
1426 | 1473 | yield (missing_from_ps, f, state) |
|
1427 | 1474 | for f in m1: |
|
1428 | 1475 | state = self.get_entry(f).state |
|
1429 | 1476 | if state not in b"nrm": |
|
1430 | 1477 | yield (missing_from_ds, f, state) |
@@ -1,3174 +1,3210 b'' | |||
|
1 | 1 | The Mercurial system uses a set of configuration files to control |
|
2 | 2 | aspects of its behavior. |
|
3 | 3 | |
|
4 | 4 | Troubleshooting |
|
5 | 5 | =============== |
|
6 | 6 | |
|
7 | 7 | If you're having problems with your configuration, |
|
8 | 8 | :hg:`config --source` can help you understand what is introducing |
|
9 | 9 | a setting into your environment. |
|
10 | 10 | |
|
11 | 11 | See :hg:`help config.syntax` and :hg:`help config.files` |
|
12 | 12 | for information about how and where to override things. |
|
13 | 13 | |
|
14 | 14 | Structure |
|
15 | 15 | ========= |
|
16 | 16 | |
|
17 | 17 | The configuration files use a simple ini-file format. A configuration |
|
18 | 18 | file consists of sections, led by a ``[section]`` header and followed |
|
19 | 19 | by ``name = value`` entries:: |
|
20 | 20 | |
|
21 | 21 | [ui] |
|
22 | 22 | username = Firstname Lastname <firstname.lastname@example.net> |
|
23 | 23 | verbose = True |
|
24 | 24 | |
|
25 | 25 | The above entries will be referred to as ``ui.username`` and |
|
26 | 26 | ``ui.verbose``, respectively. See :hg:`help config.syntax`. |
|
27 | 27 | |
|
28 | 28 | Files |
|
29 | 29 | ===== |
|
30 | 30 | |
|
31 | 31 | Mercurial reads configuration data from several files, if they exist. |
|
32 | 32 | These files do not exist by default and you will have to create the |
|
33 | 33 | appropriate configuration files yourself: |
|
34 | 34 | |
|
35 | 35 | Local configuration is put into the per-repository ``<repo>/.hg/hgrc`` file. |
|
36 | 36 | |
|
37 | 37 | Global configuration like the username setting is typically put into: |
|
38 | 38 | |
|
39 | 39 | .. container:: windows |
|
40 | 40 | |
|
41 | 41 | - ``%USERPROFILE%\mercurial.ini`` (on Windows) |
|
42 | 42 | |
|
43 | 43 | .. container:: unix.plan9 |
|
44 | 44 | |
|
45 | 45 | - ``$HOME/.hgrc`` (on Unix, Plan9) |
|
46 | 46 | |
|
47 | 47 | The names of these files depend on the system on which Mercurial is |
|
48 | 48 | installed. ``*.rc`` files from a single directory are read in |
|
49 | 49 | alphabetical order, later ones overriding earlier ones. Where multiple |
|
50 | 50 | paths are given below, settings from earlier paths override later |
|
51 | 51 | ones. |
|
52 | 52 | |
|
53 | 53 | .. container:: verbose.unix |
|
54 | 54 | |
|
55 | 55 | On Unix, the following files are consulted: |
|
56 | 56 | |
|
57 | 57 | - ``<repo>/.hg/hgrc-not-shared`` (per-repository) |
|
58 | 58 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
59 | 59 | - ``$HOME/.hgrc`` (per-user) |
|
60 | 60 | - ``${XDG_CONFIG_HOME:-$HOME/.config}/hg/hgrc`` (per-user) |
|
61 | 61 | - ``<install-root>/etc/mercurial/hgrc`` (per-installation) |
|
62 | 62 | - ``<install-root>/etc/mercurial/hgrc.d/*.rc`` (per-installation) |
|
63 | 63 | - ``/etc/mercurial/hgrc`` (per-system) |
|
64 | 64 | - ``/etc/mercurial/hgrc.d/*.rc`` (per-system) |
|
65 | 65 | - ``<internal>/*.rc`` (defaults) |
|
66 | 66 | |
|
67 | 67 | .. container:: verbose.windows |
|
68 | 68 | |
|
69 | 69 | On Windows, the following files are consulted: |
|
70 | 70 | |
|
71 | 71 | - ``<repo>/.hg/hgrc-not-shared`` (per-repository) |
|
72 | 72 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
73 | 73 | - ``%USERPROFILE%\.hgrc`` (per-user) |
|
74 | 74 | - ``%USERPROFILE%\Mercurial.ini`` (per-user) |
|
75 | 75 | - ``%HOME%\.hgrc`` (per-user) |
|
76 | 76 | - ``%HOME%\Mercurial.ini`` (per-user) |
|
77 | 77 | - ``HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial`` (per-system) |
|
78 | 78 | - ``<install-dir>\hgrc.d\*.rc`` (per-installation) |
|
79 | 79 | - ``<install-dir>\Mercurial.ini`` (per-installation) |
|
80 | 80 | - ``%PROGRAMDATA%\Mercurial\hgrc`` (per-system) |
|
81 | 81 | - ``%PROGRAMDATA%\Mercurial\Mercurial.ini`` (per-system) |
|
82 | 82 | - ``%PROGRAMDATA%\Mercurial\hgrc.d\*.rc`` (per-system) |
|
83 | 83 | - ``<internal>/*.rc`` (defaults) |
|
84 | 84 | |
|
85 | 85 | .. note:: |
|
86 | 86 | |
|
87 | 87 | The registry key ``HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mercurial`` |
|
88 | 88 | is used when running 32-bit Python on 64-bit Windows. |
|
89 | 89 | |
|
90 | 90 | .. container:: verbose.plan9 |
|
91 | 91 | |
|
92 | 92 | On Plan9, the following files are consulted: |
|
93 | 93 | |
|
94 | 94 | - ``<repo>/.hg/hgrc-not-shared`` (per-repository) |
|
95 | 95 | - ``<repo>/.hg/hgrc`` (per-repository) |
|
96 | 96 | - ``$home/lib/hgrc`` (per-user) |
|
97 | 97 | - ``<install-root>/lib/mercurial/hgrc`` (per-installation) |
|
98 | 98 | - ``<install-root>/lib/mercurial/hgrc.d/*.rc`` (per-installation) |
|
99 | 99 | - ``/lib/mercurial/hgrc`` (per-system) |
|
100 | 100 | - ``/lib/mercurial/hgrc.d/*.rc`` (per-system) |
|
101 | 101 | - ``<internal>/*.rc`` (defaults) |
|
102 | 102 | |
|
103 | 103 | Per-repository configuration options only apply in a |
|
104 | 104 | particular repository. This file is not version-controlled, and |
|
105 | 105 | will not get transferred during a "clone" operation. Options in |
|
106 | 106 | this file override options in all other configuration files. |
|
107 | 107 | |
|
108 | 108 | .. container:: unix.plan9 |
|
109 | 109 | |
|
110 | 110 | On Plan 9 and Unix, most of this file will be ignored if it doesn't |
|
111 | 111 | belong to a trusted user or to a trusted group. See |
|
112 | 112 | :hg:`help config.trusted` for more details. |
|
113 | 113 | |
|
114 | 114 | Per-user configuration file(s) are for the user running Mercurial. Options |
|
115 | 115 | in these files apply to all Mercurial commands executed by this user in any |
|
116 | 116 | directory. Options in these files override per-system and per-installation |
|
117 | 117 | options. |
|
118 | 118 | |
|
119 | 119 | Per-installation configuration files are searched for in the |
|
120 | 120 | directory where Mercurial is installed. ``<install-root>`` is the |
|
121 | 121 | parent directory of the **hg** executable (or symlink) being run. |
|
122 | 122 | |
|
123 | 123 | .. container:: unix.plan9 |
|
124 | 124 | |
|
125 | 125 | For example, if installed in ``/shared/tools/bin/hg``, Mercurial |
|
126 | 126 | will look in ``/shared/tools/etc/mercurial/hgrc``. Options in these |
|
127 | 127 | files apply to all Mercurial commands executed by any user in any |
|
128 | 128 | directory. |
|
129 | 129 | |
|
130 | 130 | Per-installation configuration files are for the system on |
|
131 | 131 | which Mercurial is running. Options in these files apply to all |
|
132 | 132 | Mercurial commands executed by any user in any directory. Registry |
|
133 | 133 | keys contain PATH-like strings, every part of which must reference |
|
134 | 134 | a ``Mercurial.ini`` file or be a directory where ``*.rc`` files will |
|
135 | 135 | be read. Mercurial checks each of these locations in the specified |
|
136 | 136 | order until one or more configuration files are detected. |
|
137 | 137 | |
|
138 | 138 | Per-system configuration files are for the system on which Mercurial |
|
139 | 139 | is running. Options in these files apply to all Mercurial commands |
|
140 | 140 | executed by any user in any directory. Options in these files |
|
141 | 141 | override per-installation options. |
|
142 | 142 | |
|
143 | 143 | Mercurial comes with some default configuration. The default configuration |
|
144 | 144 | files are installed with Mercurial and will be overwritten on upgrades. Default |
|
145 | 145 | configuration files should never be edited by users or administrators but can |
|
146 | 146 | be overridden in other configuration files. So far the directory only contains |
|
147 | 147 | merge tool configuration but packagers can also put other default configuration |
|
148 | 148 | there. |
|
149 | 149 | |
|
150 | 150 | On versions 5.7 and later, if share-safe functionality is enabled, |
|
151 | 151 | shares will read config file of share source too. |
|
152 | 152 | `<share-source/.hg/hgrc>` is read before reading `<repo/.hg/hgrc>`. |
|
153 | 153 | |
|
154 | 154 | For configs which should not be shared, `<repo/.hg/hgrc-not-shared>` |
|
155 | 155 | should be used. |
|
156 | 156 | |
|
157 | 157 | Syntax |
|
158 | 158 | ====== |
|
159 | 159 | |
|
160 | 160 | A configuration file consists of sections, led by a ``[section]`` header |
|
161 | 161 | and followed by ``name = value`` entries (sometimes called |
|
162 | 162 | ``configuration keys``):: |
|
163 | 163 | |
|
164 | 164 | [spam] |
|
165 | 165 | eggs=ham |
|
166 | 166 | green= |
|
167 | 167 | eggs |
|
168 | 168 | |
|
169 | 169 | Each line contains one entry. If the lines that follow are indented, |
|
170 | 170 | they are treated as continuations of that entry. Leading whitespace is |
|
171 | 171 | removed from values. Empty lines are skipped. Lines beginning with |
|
172 | 172 | ``#`` or ``;`` are ignored and may be used to provide comments. |
|
173 | 173 | |
|
174 | 174 | Configuration keys can be set multiple times, in which case Mercurial |
|
175 | 175 | will use the value that was configured last. As an example:: |
|
176 | 176 | |
|
177 | 177 | [spam] |
|
178 | 178 | eggs=large |
|
179 | 179 | ham=serrano |
|
180 | 180 | eggs=small |
|
181 | 181 | |
|
182 | 182 | This would set the configuration key named ``eggs`` to ``small``. |
|
183 | 183 | |
|
184 | 184 | It is also possible to define a section multiple times. A section can |
|
185 | 185 | be redefined on the same and/or on different configuration files. For |
|
186 | 186 | example:: |
|
187 | 187 | |
|
188 | 188 | [foo] |
|
189 | 189 | eggs=large |
|
190 | 190 | ham=serrano |
|
191 | 191 | eggs=small |
|
192 | 192 | |
|
193 | 193 | [bar] |
|
194 | 194 | eggs=ham |
|
195 | 195 | green= |
|
196 | 196 | eggs |
|
197 | 197 | |
|
198 | 198 | [foo] |
|
199 | 199 | ham=prosciutto |
|
200 | 200 | eggs=medium |
|
201 | 201 | bread=toasted |
|
202 | 202 | |
|
203 | 203 | This would set the ``eggs``, ``ham``, and ``bread`` configuration keys |
|
204 | 204 | of the ``foo`` section to ``medium``, ``prosciutto``, and ``toasted``, |
|
205 | 205 | respectively. As you can see there only thing that matters is the last |
|
206 | 206 | value that was set for each of the configuration keys. |
|
207 | 207 | |
|
208 | 208 | If a configuration key is set multiple times in different |
|
209 | 209 | configuration files the final value will depend on the order in which |
|
210 | 210 | the different configuration files are read, with settings from earlier |
|
211 | 211 | paths overriding later ones as described on the ``Files`` section |
|
212 | 212 | above. |
|
213 | 213 | |
|
214 | 214 | A line of the form ``%include file`` will include ``file`` into the |
|
215 | 215 | current configuration file. The inclusion is recursive, which means |
|
216 | 216 | that included files can include other files. Filenames are relative to |
|
217 | 217 | the configuration file in which the ``%include`` directive is found. |
|
218 | 218 | Environment variables and ``~user`` constructs are expanded in |
|
219 | 219 | ``file``. This lets you do something like:: |
|
220 | 220 | |
|
221 | 221 | %include ~/.hgrc.d/$HOST.rc |
|
222 | 222 | |
|
223 | 223 | to include a different configuration file on each computer you use. |
|
224 | 224 | |
|
225 | 225 | A line with ``%unset name`` will remove ``name`` from the current |
|
226 | 226 | section, if it has been set previously. |
|
227 | 227 | |
|
228 | 228 | The values are either free-form text strings, lists of text strings, |
|
229 | 229 | or Boolean values. Boolean values can be set to true using any of "1", |
|
230 | 230 | "yes", "true", or "on" and to false using "0", "no", "false", or "off" |
|
231 | 231 | (all case insensitive). |
|
232 | 232 | |
|
233 | 233 | List values are separated by whitespace or comma, except when values are |
|
234 | 234 | placed in double quotation marks:: |
|
235 | 235 | |
|
236 | 236 | allow_read = "John Doe, PhD", brian, betty |
|
237 | 237 | |
|
238 | 238 | Quotation marks can be escaped by prefixing them with a backslash. Only |
|
239 | 239 | quotation marks at the beginning of a word is counted as a quotation |
|
240 | 240 | (e.g., ``foo"bar baz`` is the list of ``foo"bar`` and ``baz``). |
|
241 | 241 | |
|
242 | 242 | Sections |
|
243 | 243 | ======== |
|
244 | 244 | |
|
245 | 245 | This section describes the different sections that may appear in a |
|
246 | 246 | Mercurial configuration file, the purpose of each section, its possible |
|
247 | 247 | keys, and their possible values. |
|
248 | 248 | |
|
249 | 249 | ``alias`` |
|
250 | 250 | --------- |
|
251 | 251 | |
|
252 | 252 | Defines command aliases. |
|
253 | 253 | |
|
254 | 254 | Aliases allow you to define your own commands in terms of other |
|
255 | 255 | commands (or aliases), optionally including arguments. Positional |
|
256 | 256 | arguments in the form of ``$1``, ``$2``, etc. in the alias definition |
|
257 | 257 | are expanded by Mercurial before execution. Positional arguments not |
|
258 | 258 | already used by ``$N`` in the definition are put at the end of the |
|
259 | 259 | command to be executed. |
|
260 | 260 | |
|
261 | 261 | Alias definitions consist of lines of the form:: |
|
262 | 262 | |
|
263 | 263 | <alias> = <command> [<argument>]... |
|
264 | 264 | |
|
265 | 265 | For example, this definition:: |
|
266 | 266 | |
|
267 | 267 | latest = log --limit 5 |
|
268 | 268 | |
|
269 | 269 | creates a new command ``latest`` that shows only the five most recent |
|
270 | 270 | changesets. You can define subsequent aliases using earlier ones:: |
|
271 | 271 | |
|
272 | 272 | stable5 = latest -b stable |
|
273 | 273 | |
|
274 | 274 | .. note:: |
|
275 | 275 | |
|
276 | 276 | It is possible to create aliases with the same names as |
|
277 | 277 | existing commands, which will then override the original |
|
278 | 278 | definitions. This is almost always a bad idea! |
|
279 | 279 | |
|
280 | 280 | An alias can start with an exclamation point (``!``) to make it a |
|
281 | 281 | shell alias. A shell alias is executed with the shell and will let you |
|
282 | 282 | run arbitrary commands. As an example, :: |
|
283 | 283 | |
|
284 | 284 | echo = !echo $@ |
|
285 | 285 | |
|
286 | 286 | will let you do ``hg echo foo`` to have ``foo`` printed in your |
|
287 | 287 | terminal. A better example might be:: |
|
288 | 288 | |
|
289 | 289 | purge = !$HG status --no-status --unknown -0 re: | xargs -0 rm -f |
|
290 | 290 | |
|
291 | 291 | which will make ``hg purge`` delete all unknown files in the |
|
292 | 292 | repository in the same manner as the purge extension. |
|
293 | 293 | |
|
294 | 294 | Positional arguments like ``$1``, ``$2``, etc. in the alias definition |
|
295 | 295 | expand to the command arguments. Unmatched arguments are |
|
296 | 296 | removed. ``$0`` expands to the alias name and ``$@`` expands to all |
|
297 | 297 | arguments separated by a space. ``"$@"`` (with quotes) expands to all |
|
298 | 298 | arguments quoted individually and separated by a space. These expansions |
|
299 | 299 | happen before the command is passed to the shell. |
|
300 | 300 | |
|
301 | 301 | Shell aliases are executed in an environment where ``$HG`` expands to |
|
302 | 302 | the path of the Mercurial that was used to execute the alias. This is |
|
303 | 303 | useful when you want to call further Mercurial commands in a shell |
|
304 | 304 | alias, as was done above for the purge alias. In addition, |
|
305 | 305 | ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg |
|
306 | 306 | echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``. |
|
307 | 307 | |
|
308 | 308 | .. note:: |
|
309 | 309 | |
|
310 | 310 | Some global configuration options such as ``-R`` are |
|
311 | 311 | processed before shell aliases and will thus not be passed to |
|
312 | 312 | aliases. |
|
313 | 313 | |
|
314 | 314 | |
|
315 | 315 | ``annotate`` |
|
316 | 316 | ------------ |
|
317 | 317 | |
|
318 | 318 | Settings used when displaying file annotations. All values are |
|
319 | 319 | Booleans and default to False. See :hg:`help config.diff` for |
|
320 | 320 | related options for the diff command. |
|
321 | 321 | |
|
322 | 322 | ``ignorews`` |
|
323 | 323 | Ignore white space when comparing lines. |
|
324 | 324 | |
|
325 | 325 | ``ignorewseol`` |
|
326 | 326 | Ignore white space at the end of a line when comparing lines. |
|
327 | 327 | |
|
328 | 328 | ``ignorewsamount`` |
|
329 | 329 | Ignore changes in the amount of white space. |
|
330 | 330 | |
|
331 | 331 | ``ignoreblanklines`` |
|
332 | 332 | Ignore changes whose lines are all blank. |
|
333 | 333 | |
|
334 | 334 | |
|
335 | 335 | ``auth`` |
|
336 | 336 | -------- |
|
337 | 337 | |
|
338 | 338 | Authentication credentials and other authentication-like configuration |
|
339 | 339 | for HTTP connections. This section allows you to store usernames and |
|
340 | 340 | passwords for use when logging *into* HTTP servers. See |
|
341 | 341 | :hg:`help config.web` if you want to configure *who* can login to |
|
342 | 342 | your HTTP server. |
|
343 | 343 | |
|
344 | 344 | The following options apply to all hosts. |
|
345 | 345 | |
|
346 | 346 | ``cookiefile`` |
|
347 | 347 | Path to a file containing HTTP cookie lines. Cookies matching a |
|
348 | 348 | host will be sent automatically. |
|
349 | 349 | |
|
350 | 350 | The file format uses the Mozilla cookies.txt format, which defines cookies |
|
351 | 351 | on their own lines. Each line contains 7 fields delimited by the tab |
|
352 | 352 | character (domain, is_domain_cookie, path, is_secure, expires, name, |
|
353 | 353 | value). For more info, do an Internet search for "Netscape cookies.txt |
|
354 | 354 | format." |
|
355 | 355 | |
|
356 | 356 | Note: the cookies parser does not handle port numbers on domains. You |
|
357 | 357 | will need to remove ports from the domain for the cookie to be recognized. |
|
358 | 358 | This could result in a cookie being disclosed to an unwanted server. |
|
359 | 359 | |
|
360 | 360 | The cookies file is read-only. |
|
361 | 361 | |
|
362 | 362 | Other options in this section are grouped by name and have the following |
|
363 | 363 | format:: |
|
364 | 364 | |
|
365 | 365 | <name>.<argument> = <value> |
|
366 | 366 | |
|
367 | 367 | where ``<name>`` is used to group arguments into authentication |
|
368 | 368 | entries. Example:: |
|
369 | 369 | |
|
370 | 370 | foo.prefix = hg.intevation.de/mercurial |
|
371 | 371 | foo.username = foo |
|
372 | 372 | foo.password = bar |
|
373 | 373 | foo.schemes = http https |
|
374 | 374 | |
|
375 | 375 | bar.prefix = secure.example.org |
|
376 | 376 | bar.key = path/to/file.key |
|
377 | 377 | bar.cert = path/to/file.cert |
|
378 | 378 | bar.schemes = https |
|
379 | 379 | |
|
380 | 380 | Supported arguments: |
|
381 | 381 | |
|
382 | 382 | ``prefix`` |
|
383 | 383 | Either ``*`` or a URI prefix with or without the scheme part. |
|
384 | 384 | The authentication entry with the longest matching prefix is used |
|
385 | 385 | (where ``*`` matches everything and counts as a match of length |
|
386 | 386 | 1). If the prefix doesn't include a scheme, the match is performed |
|
387 | 387 | against the URI with its scheme stripped as well, and the schemes |
|
388 | 388 | argument, q.v., is then subsequently consulted. |
|
389 | 389 | |
|
390 | 390 | ``username`` |
|
391 | 391 | Optional. Username to authenticate with. If not given, and the |
|
392 | 392 | remote site requires basic or digest authentication, the user will |
|
393 | 393 | be prompted for it. Environment variables are expanded in the |
|
394 | 394 | username letting you do ``foo.username = $USER``. If the URI |
|
395 | 395 | includes a username, only ``[auth]`` entries with a matching |
|
396 | 396 | username or without a username will be considered. |
|
397 | 397 | |
|
398 | 398 | ``password`` |
|
399 | 399 | Optional. Password to authenticate with. If not given, and the |
|
400 | 400 | remote site requires basic or digest authentication, the user |
|
401 | 401 | will be prompted for it. |
|
402 | 402 | |
|
403 | 403 | ``key`` |
|
404 | 404 | Optional. PEM encoded client certificate key file. Environment |
|
405 | 405 | variables are expanded in the filename. |
|
406 | 406 | |
|
407 | 407 | ``cert`` |
|
408 | 408 | Optional. PEM encoded client certificate chain file. Environment |
|
409 | 409 | variables are expanded in the filename. |
|
410 | 410 | |
|
411 | 411 | ``schemes`` |
|
412 | 412 | Optional. Space separated list of URI schemes to use this |
|
413 | 413 | authentication entry with. Only used if the prefix doesn't include |
|
414 | 414 | a scheme. Supported schemes are http and https. They will match |
|
415 | 415 | static-http and static-https respectively, as well. |
|
416 | 416 | (default: https) |
|
417 | 417 | |
|
418 | 418 | If no suitable authentication entry is found, the user is prompted |
|
419 | 419 | for credentials as usual if required by the remote. |
|
420 | 420 | |
|
421 | 421 | ``cmdserver`` |
|
422 | 422 | ------------- |
|
423 | 423 | |
|
424 | 424 | Controls command server settings. (ADVANCED) |
|
425 | 425 | |
|
426 | 426 | ``message-encodings`` |
|
427 | 427 | List of encodings for the ``m`` (message) channel. The first encoding |
|
428 | 428 | supported by the server will be selected and advertised in the hello |
|
429 | 429 | message. This is useful only when ``ui.message-output`` is set to |
|
430 | 430 | ``channel``. Supported encodings are ``cbor``. |
|
431 | 431 | |
|
432 | 432 | ``shutdown-on-interrupt`` |
|
433 | 433 | If set to false, the server's main loop will continue running after |
|
434 | 434 | SIGINT received. ``runcommand`` requests can still be interrupted by |
|
435 | 435 | SIGINT. Close the write end of the pipe to shut down the server |
|
436 | 436 | process gracefully. |
|
437 | 437 | (default: True) |
|
438 | 438 | |
|
439 | 439 | ``color`` |
|
440 | 440 | --------- |
|
441 | 441 | |
|
442 | 442 | Configure the Mercurial color mode. For details about how to define your custom |
|
443 | 443 | effect and style see :hg:`help color`. |
|
444 | 444 | |
|
445 | 445 | ``mode`` |
|
446 | 446 | String: control the method used to output color. One of ``auto``, ``ansi``, |
|
447 | 447 | ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will |
|
448 | 448 | use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a |
|
449 | 449 | terminal. Any invalid value will disable color. |
|
450 | 450 | |
|
451 | 451 | ``pagermode`` |
|
452 | 452 | String: optional override of ``color.mode`` used with pager. |
|
453 | 453 | |
|
454 | 454 | On some systems, terminfo mode may cause problems when using |
|
455 | 455 | color with ``less -R`` as a pager program. less with the -R option |
|
456 | 456 | will only display ECMA-48 color codes, and terminfo mode may sometimes |
|
457 | 457 | emit codes that less doesn't understand. You can work around this by |
|
458 | 458 | either using ansi mode (or auto mode), or by using less -r (which will |
|
459 | 459 | pass through all terminal control codes, not just color control |
|
460 | 460 | codes). |
|
461 | 461 | |
|
462 | 462 | On some systems (such as MSYS in Windows), the terminal may support |
|
463 | 463 | a different color mode than the pager program. |
|
464 | 464 | |
|
465 | 465 | ``commands`` |
|
466 | 466 | ------------ |
|
467 | 467 | |
|
468 | 468 | ``commit.post-status`` |
|
469 | 469 | Show status of files in the working directory after successful commit. |
|
470 | 470 | (default: False) |
|
471 | 471 | |
|
472 | 472 | ``merge.require-rev`` |
|
473 | 473 | Require that the revision to merge the current commit with be specified on |
|
474 | 474 | the command line. If this is enabled and a revision is not specified, the |
|
475 | 475 | command aborts. |
|
476 | 476 | (default: False) |
|
477 | 477 | |
|
478 | 478 | ``push.require-revs`` |
|
479 | 479 | Require revisions to push be specified using one or more mechanisms such as |
|
480 | 480 | specifying them positionally on the command line, using ``-r``, ``-b``, |
|
481 | 481 | and/or ``-B`` on the command line, or using ``paths.<path>:pushrev`` in the |
|
482 | 482 | configuration. If this is enabled and revisions are not specified, the |
|
483 | 483 | command aborts. |
|
484 | 484 | (default: False) |
|
485 | 485 | |
|
486 | 486 | ``resolve.confirm`` |
|
487 | 487 | Confirm before performing action if no filename is passed. |
|
488 | 488 | (default: False) |
|
489 | 489 | |
|
490 | 490 | ``resolve.explicit-re-merge`` |
|
491 | 491 | Require uses of ``hg resolve`` to specify which action it should perform, |
|
492 | 492 | instead of re-merging files by default. |
|
493 | 493 | (default: False) |
|
494 | 494 | |
|
495 | 495 | ``resolve.mark-check`` |
|
496 | 496 | Determines what level of checking :hg:`resolve --mark` will perform before |
|
497 | 497 | marking files as resolved. Valid values are ``none`, ``warn``, and |
|
498 | 498 | ``abort``. ``warn`` will output a warning listing the file(s) that still |
|
499 | 499 | have conflict markers in them, but will still mark everything resolved. |
|
500 | 500 | ``abort`` will output the same warning but will not mark things as resolved. |
|
501 | 501 | If --all is passed and this is set to ``abort``, only a warning will be |
|
502 | 502 | shown (an error will not be raised). |
|
503 | 503 | (default: ``none``) |
|
504 | 504 | |
|
505 | 505 | ``status.relative`` |
|
506 | 506 | Make paths in :hg:`status` output relative to the current directory. |
|
507 | 507 | (default: False) |
|
508 | 508 | |
|
509 | 509 | ``status.terse`` |
|
510 | 510 | Default value for the --terse flag, which condenses status output. |
|
511 | 511 | (default: empty) |
|
512 | 512 | |
|
513 | 513 | ``update.check`` |
|
514 | 514 | Determines what level of checking :hg:`update` will perform before moving |
|
515 | 515 | to a destination revision. Valid values are ``abort``, ``none``, |
|
516 | 516 | ``linear``, and ``noconflict``. |
|
517 | 517 | |
|
518 | 518 | - ``abort`` always fails if the working directory has uncommitted changes. |
|
519 | 519 | |
|
520 | 520 | - ``none`` performs no checking, and may result in a merge with uncommitted changes. |
|
521 | 521 | |
|
522 | 522 | - ``linear`` allows any update as long as it follows a straight line in the |
|
523 | 523 | revision history, and may trigger a merge with uncommitted changes. |
|
524 | 524 | |
|
525 | 525 | - ``noconflict`` will allow any update which would not trigger a merge with |
|
526 | 526 | uncommitted changes, if any are present. |
|
527 | 527 | |
|
528 | 528 | (default: ``linear``) |
|
529 | 529 | |
|
530 | 530 | ``update.requiredest`` |
|
531 | 531 | Require that the user pass a destination when running :hg:`update`. |
|
532 | 532 | For example, :hg:`update .::` will be allowed, but a plain :hg:`update` |
|
533 | 533 | will be disallowed. |
|
534 | 534 | (default: False) |
|
535 | 535 | |
|
536 | 536 | ``committemplate`` |
|
537 | 537 | ------------------ |
|
538 | 538 | |
|
539 | 539 | ``changeset`` |
|
540 | 540 | String: configuration in this section is used as the template to |
|
541 | 541 | customize the text shown in the editor when committing. |
|
542 | 542 | |
|
543 | 543 | In addition to pre-defined template keywords, commit log specific one |
|
544 | 544 | below can be used for customization: |
|
545 | 545 | |
|
546 | 546 | ``extramsg`` |
|
547 | 547 | String: Extra message (typically 'Leave message empty to abort |
|
548 | 548 | commit.'). This may be changed by some commands or extensions. |
|
549 | 549 | |
|
550 | 550 | For example, the template configuration below shows as same text as |
|
551 | 551 | one shown by default:: |
|
552 | 552 | |
|
553 | 553 | [committemplate] |
|
554 | 554 | changeset = {desc}\n\n |
|
555 | 555 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
556 | 556 | HG: {extramsg} |
|
557 | 557 | HG: -- |
|
558 | 558 | HG: user: {author}\n{ifeq(p2rev, "-1", "", |
|
559 | 559 | "HG: branch merge\n") |
|
560 | 560 | }HG: branch '{branch}'\n{if(activebookmark, |
|
561 | 561 | "HG: bookmark '{activebookmark}'\n") }{subrepos % |
|
562 | 562 | "HG: subrepo {subrepo}\n" }{file_adds % |
|
563 | 563 | "HG: added {file}\n" }{file_mods % |
|
564 | 564 | "HG: changed {file}\n" }{file_dels % |
|
565 | 565 | "HG: removed {file}\n" }{if(files, "", |
|
566 | 566 | "HG: no files changed\n")} |
|
567 | 567 | |
|
568 | 568 | ``diff()`` |
|
569 | 569 | String: show the diff (see :hg:`help templates` for detail) |
|
570 | 570 | |
|
571 | 571 | Sometimes it is helpful to show the diff of the changeset in the editor without |
|
572 | 572 | having to prefix 'HG: ' to each line so that highlighting works correctly. For |
|
573 | 573 | this, Mercurial provides a special string which will ignore everything below |
|
574 | 574 | it:: |
|
575 | 575 | |
|
576 | 576 | HG: ------------------------ >8 ------------------------ |
|
577 | 577 | |
|
578 | 578 | For example, the template configuration below will show the diff below the |
|
579 | 579 | extra message:: |
|
580 | 580 | |
|
581 | 581 | [committemplate] |
|
582 | 582 | changeset = {desc}\n\n |
|
583 | 583 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
584 | 584 | HG: {extramsg} |
|
585 | 585 | HG: ------------------------ >8 ------------------------ |
|
586 | 586 | HG: Do not touch the line above. |
|
587 | 587 | HG: Everything below will be removed. |
|
588 | 588 | {diff()} |
|
589 | 589 | |
|
590 | 590 | .. note:: |
|
591 | 591 | |
|
592 | 592 | For some problematic encodings (see :hg:`help win32mbcs` for |
|
593 | 593 | detail), this customization should be configured carefully, to |
|
594 | 594 | avoid showing broken characters. |
|
595 | 595 | |
|
596 | 596 | For example, if a multibyte character ending with backslash (0x5c) is |
|
597 | 597 | followed by the ASCII character 'n' in the customized template, |
|
598 | 598 | the sequence of backslash and 'n' is treated as line-feed unexpectedly |
|
599 | 599 | (and the multibyte character is broken, too). |
|
600 | 600 | |
|
601 | 601 | Customized template is used for commands below (``--edit`` may be |
|
602 | 602 | required): |
|
603 | 603 | |
|
604 | 604 | - :hg:`backout` |
|
605 | 605 | - :hg:`commit` |
|
606 | 606 | - :hg:`fetch` (for merge commit only) |
|
607 | 607 | - :hg:`graft` |
|
608 | 608 | - :hg:`histedit` |
|
609 | 609 | - :hg:`import` |
|
610 | 610 | - :hg:`qfold`, :hg:`qnew` and :hg:`qrefresh` |
|
611 | 611 | - :hg:`rebase` |
|
612 | 612 | - :hg:`shelve` |
|
613 | 613 | - :hg:`sign` |
|
614 | 614 | - :hg:`tag` |
|
615 | 615 | - :hg:`transplant` |
|
616 | 616 | |
|
617 | 617 | Configuring items below instead of ``changeset`` allows showing |
|
618 | 618 | customized message only for specific actions, or showing different |
|
619 | 619 | messages for each action. |
|
620 | 620 | |
|
621 | 621 | - ``changeset.backout`` for :hg:`backout` |
|
622 | 622 | - ``changeset.commit.amend.merge`` for :hg:`commit --amend` on merges |
|
623 | 623 | - ``changeset.commit.amend.normal`` for :hg:`commit --amend` on other |
|
624 | 624 | - ``changeset.commit.normal.merge`` for :hg:`commit` on merges |
|
625 | 625 | - ``changeset.commit.normal.normal`` for :hg:`commit` on other |
|
626 | 626 | - ``changeset.fetch`` for :hg:`fetch` (impling merge commit) |
|
627 | 627 | - ``changeset.gpg.sign`` for :hg:`sign` |
|
628 | 628 | - ``changeset.graft`` for :hg:`graft` |
|
629 | 629 | - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit` |
|
630 | 630 | - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit` |
|
631 | 631 | - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit` |
|
632 | 632 | - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit` |
|
633 | 633 | - ``changeset.import.bypass`` for :hg:`import --bypass` |
|
634 | 634 | - ``changeset.import.normal.merge`` for :hg:`import` on merges |
|
635 | 635 | - ``changeset.import.normal.normal`` for :hg:`import` on other |
|
636 | 636 | - ``changeset.mq.qnew`` for :hg:`qnew` |
|
637 | 637 | - ``changeset.mq.qfold`` for :hg:`qfold` |
|
638 | 638 | - ``changeset.mq.qrefresh`` for :hg:`qrefresh` |
|
639 | 639 | - ``changeset.rebase.collapse`` for :hg:`rebase --collapse` |
|
640 | 640 | - ``changeset.rebase.merge`` for :hg:`rebase` on merges |
|
641 | 641 | - ``changeset.rebase.normal`` for :hg:`rebase` on other |
|
642 | 642 | - ``changeset.shelve.shelve`` for :hg:`shelve` |
|
643 | 643 | - ``changeset.tag.add`` for :hg:`tag` without ``--remove`` |
|
644 | 644 | - ``changeset.tag.remove`` for :hg:`tag --remove` |
|
645 | 645 | - ``changeset.transplant.merge`` for :hg:`transplant` on merges |
|
646 | 646 | - ``changeset.transplant.normal`` for :hg:`transplant` on other |
|
647 | 647 | |
|
648 | 648 | These dot-separated lists of names are treated as hierarchical ones. |
|
649 | 649 | For example, ``changeset.tag.remove`` customizes the commit message |
|
650 | 650 | only for :hg:`tag --remove`, but ``changeset.tag`` customizes the |
|
651 | 651 | commit message for :hg:`tag` regardless of ``--remove`` option. |
|
652 | 652 | |
|
653 | 653 | When the external editor is invoked for a commit, the corresponding |
|
654 | 654 | dot-separated list of names without the ``changeset.`` prefix |
|
655 | 655 | (e.g. ``commit.normal.normal``) is in the ``HGEDITFORM`` environment |
|
656 | 656 | variable. |
|
657 | 657 | |
|
658 | 658 | In this section, items other than ``changeset`` can be referred from |
|
659 | 659 | others. For example, the configuration to list committed files up |
|
660 | 660 | below can be referred as ``{listupfiles}``:: |
|
661 | 661 | |
|
662 | 662 | [committemplate] |
|
663 | 663 | listupfiles = {file_adds % |
|
664 | 664 | "HG: added {file}\n" }{file_mods % |
|
665 | 665 | "HG: changed {file}\n" }{file_dels % |
|
666 | 666 | "HG: removed {file}\n" }{if(files, "", |
|
667 | 667 | "HG: no files changed\n")} |
|
668 | 668 | |
|
669 | 669 | ``decode/encode`` |
|
670 | 670 | ----------------- |
|
671 | 671 | |
|
672 | 672 | Filters for transforming files on checkout/checkin. This would |
|
673 | 673 | typically be used for newline processing or other |
|
674 | 674 | localization/canonicalization of files. |
|
675 | 675 | |
|
676 | 676 | Filters consist of a filter pattern followed by a filter command. |
|
677 | 677 | Filter patterns are globs by default, rooted at the repository root. |
|
678 | 678 | For example, to match any file ending in ``.txt`` in the root |
|
679 | 679 | directory only, use the pattern ``*.txt``. To match any file ending |
|
680 | 680 | in ``.c`` anywhere in the repository, use the pattern ``**.c``. |
|
681 | 681 | For each file only the first matching filter applies. |
|
682 | 682 | |
|
683 | 683 | The filter command can start with a specifier, either ``pipe:`` or |
|
684 | 684 | ``tempfile:``. If no specifier is given, ``pipe:`` is used by default. |
|
685 | 685 | |
|
686 | 686 | A ``pipe:`` command must accept data on stdin and return the transformed |
|
687 | 687 | data on stdout. |
|
688 | 688 | |
|
689 | 689 | Pipe example:: |
|
690 | 690 | |
|
691 | 691 | [encode] |
|
692 | 692 | # uncompress gzip files on checkin to improve delta compression |
|
693 | 693 | # note: not necessarily a good idea, just an example |
|
694 | 694 | *.gz = pipe: gunzip |
|
695 | 695 | |
|
696 | 696 | [decode] |
|
697 | 697 | # recompress gzip files when writing them to the working dir (we |
|
698 | 698 | # can safely omit "pipe:", because it's the default) |
|
699 | 699 | *.gz = gzip |
|
700 | 700 | |
|
701 | 701 | A ``tempfile:`` command is a template. The string ``INFILE`` is replaced |
|
702 | 702 | with the name of a temporary file that contains the data to be |
|
703 | 703 | filtered by the command. The string ``OUTFILE`` is replaced with the name |
|
704 | 704 | of an empty temporary file, where the filtered data must be written by |
|
705 | 705 | the command. |
|
706 | 706 | |
|
707 | 707 | .. container:: windows |
|
708 | 708 | |
|
709 | 709 | .. note:: |
|
710 | 710 | |
|
711 | 711 | The tempfile mechanism is recommended for Windows systems, |
|
712 | 712 | where the standard shell I/O redirection operators often have |
|
713 | 713 | strange effects and may corrupt the contents of your files. |
|
714 | 714 | |
|
715 | 715 | This filter mechanism is used internally by the ``eol`` extension to |
|
716 | 716 | translate line ending characters between Windows (CRLF) and Unix (LF) |
|
717 | 717 | format. We suggest you use the ``eol`` extension for convenience. |
|
718 | 718 | |
|
719 | 719 | |
|
720 | 720 | ``defaults`` |
|
721 | 721 | ------------ |
|
722 | 722 | |
|
723 | 723 | (defaults are deprecated. Don't use them. Use aliases instead.) |
|
724 | 724 | |
|
725 | 725 | Use the ``[defaults]`` section to define command defaults, i.e. the |
|
726 | 726 | default options/arguments to pass to the specified commands. |
|
727 | 727 | |
|
728 | 728 | The following example makes :hg:`log` run in verbose mode, and |
|
729 | 729 | :hg:`status` show only the modified files, by default:: |
|
730 | 730 | |
|
731 | 731 | [defaults] |
|
732 | 732 | log = -v |
|
733 | 733 | status = -m |
|
734 | 734 | |
|
735 | 735 | The actual commands, instead of their aliases, must be used when |
|
736 | 736 | defining command defaults. The command defaults will also be applied |
|
737 | 737 | to the aliases of the commands defined. |
|
738 | 738 | |
|
739 | 739 | |
|
740 | 740 | ``diff`` |
|
741 | 741 | -------- |
|
742 | 742 | |
|
743 | 743 | Settings used when displaying diffs. Everything except for ``unified`` |
|
744 | 744 | is a Boolean and defaults to False. See :hg:`help config.annotate` |
|
745 | 745 | for related options for the annotate command. |
|
746 | 746 | |
|
747 | 747 | ``git`` |
|
748 | 748 | Use git extended diff format. |
|
749 | 749 | |
|
750 | 750 | ``nobinary`` |
|
751 | 751 | Omit git binary patches. |
|
752 | 752 | |
|
753 | 753 | ``nodates`` |
|
754 | 754 | Don't include dates in diff headers. |
|
755 | 755 | |
|
756 | 756 | ``noprefix`` |
|
757 | 757 | Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode. |
|
758 | 758 | |
|
759 | 759 | ``showfunc`` |
|
760 | 760 | Show which function each change is in. |
|
761 | 761 | |
|
762 | 762 | ``ignorews`` |
|
763 | 763 | Ignore white space when comparing lines. |
|
764 | 764 | |
|
765 | 765 | ``ignorewsamount`` |
|
766 | 766 | Ignore changes in the amount of white space. |
|
767 | 767 | |
|
768 | 768 | ``ignoreblanklines`` |
|
769 | 769 | Ignore changes whose lines are all blank. |
|
770 | 770 | |
|
771 | 771 | ``unified`` |
|
772 | 772 | Number of lines of context to show. |
|
773 | 773 | |
|
774 | 774 | ``word-diff`` |
|
775 | 775 | Highlight changed words. |
|
776 | 776 | |
|
777 | 777 | ``email`` |
|
778 | 778 | --------- |
|
779 | 779 | |
|
780 | 780 | Settings for extensions that send email messages. |
|
781 | 781 | |
|
782 | 782 | ``from`` |
|
783 | 783 | Optional. Email address to use in "From" header and SMTP envelope |
|
784 | 784 | of outgoing messages. |
|
785 | 785 | |
|
786 | 786 | ``to`` |
|
787 | 787 | Optional. Comma-separated list of recipients' email addresses. |
|
788 | 788 | |
|
789 | 789 | ``cc`` |
|
790 | 790 | Optional. Comma-separated list of carbon copy recipients' |
|
791 | 791 | email addresses. |
|
792 | 792 | |
|
793 | 793 | ``bcc`` |
|
794 | 794 | Optional. Comma-separated list of blind carbon copy recipients' |
|
795 | 795 | email addresses. |
|
796 | 796 | |
|
797 | 797 | ``method`` |
|
798 | 798 | Optional. Method to use to send email messages. If value is ``smtp`` |
|
799 | 799 | (default), use SMTP (see the ``[smtp]`` section for configuration). |
|
800 | 800 | Otherwise, use as name of program to run that acts like sendmail |
|
801 | 801 | (takes ``-f`` option for sender, list of recipients on command line, |
|
802 | 802 | message on stdin). Normally, setting this to ``sendmail`` or |
|
803 | 803 | ``/usr/sbin/sendmail`` is enough to use sendmail to send messages. |
|
804 | 804 | |
|
805 | 805 | ``charsets`` |
|
806 | 806 | Optional. Comma-separated list of character sets considered |
|
807 | 807 | convenient for recipients. Addresses, headers, and parts not |
|
808 | 808 | containing patches of outgoing messages will be encoded in the |
|
809 | 809 | first character set to which conversion from local encoding |
|
810 | 810 | (``$HGENCODING``, ``ui.fallbackencoding``) succeeds. If correct |
|
811 | 811 | conversion fails, the text in question is sent as is. |
|
812 | 812 | (default: '') |
|
813 | 813 | |
|
814 | 814 | Order of outgoing email character sets: |
|
815 | 815 | |
|
816 | 816 | 1. ``us-ascii``: always first, regardless of settings |
|
817 | 817 | 2. ``email.charsets``: in order given by user |
|
818 | 818 | 3. ``ui.fallbackencoding``: if not in email.charsets |
|
819 | 819 | 4. ``$HGENCODING``: if not in email.charsets |
|
820 | 820 | 5. ``utf-8``: always last, regardless of settings |
|
821 | 821 | |
|
822 | 822 | Email example:: |
|
823 | 823 | |
|
824 | 824 | [email] |
|
825 | 825 | from = Joseph User <joe.user@example.com> |
|
826 | 826 | method = /usr/sbin/sendmail |
|
827 | 827 | # charsets for western Europeans |
|
828 | 828 | # us-ascii, utf-8 omitted, as they are tried first and last |
|
829 | 829 | charsets = iso-8859-1, iso-8859-15, windows-1252 |
|
830 | 830 | |
|
831 | 831 | |
|
832 | 832 | ``extensions`` |
|
833 | 833 | -------------- |
|
834 | 834 | |
|
835 | 835 | Mercurial has an extension mechanism for adding new features. To |
|
836 | 836 | enable an extension, create an entry for it in this section. |
|
837 | 837 | |
|
838 | 838 | If you know that the extension is already in Python's search path, |
|
839 | 839 | you can give the name of the module, followed by ``=``, with nothing |
|
840 | 840 | after the ``=``. |
|
841 | 841 | |
|
842 | 842 | Otherwise, give a name that you choose, followed by ``=``, followed by |
|
843 | 843 | the path to the ``.py`` file (including the file name extension) that |
|
844 | 844 | defines the extension. |
|
845 | 845 | |
|
846 | 846 | To explicitly disable an extension that is enabled in an hgrc of |
|
847 | 847 | broader scope, prepend its path with ``!``, as in ``foo = !/ext/path`` |
|
848 | 848 | or ``foo = !`` when path is not supplied. |
|
849 | 849 | |
|
850 | 850 | Example for ``~/.hgrc``:: |
|
851 | 851 | |
|
852 | 852 | [extensions] |
|
853 | 853 | # (the churn extension will get loaded from Mercurial's path) |
|
854 | 854 | churn = |
|
855 | 855 | # (this extension will get loaded from the file specified) |
|
856 | 856 | myfeature = ~/.hgext/myfeature.py |
|
857 | 857 | |
|
858 | 858 | If an extension fails to load, a warning will be issued, and Mercurial will |
|
859 | 859 | proceed. To enforce that an extension must be loaded, one can set the `required` |
|
860 | 860 | suboption in the config:: |
|
861 | 861 | |
|
862 | 862 | [extensions] |
|
863 | 863 | myfeature = ~/.hgext/myfeature.py |
|
864 | 864 | myfeature:required = yes |
|
865 | 865 | |
|
866 | 866 | To debug extension loading issue, one can add `--traceback` to their mercurial |
|
867 | 867 | invocation. |
|
868 | 868 | |
|
869 | 869 | A default setting can we set using the special `*` extension key:: |
|
870 | 870 | |
|
871 | 871 | [extensions] |
|
872 | 872 | *:required = yes |
|
873 | 873 | myfeature = ~/.hgext/myfeature.py |
|
874 | 874 | rebase= |
|
875 | 875 | |
|
876 | 876 | |
|
877 | 877 | ``format`` |
|
878 | 878 | ---------- |
|
879 | 879 | |
|
880 | 880 | Configuration that controls the repository format. Newer format options are more |
|
881 | 881 | powerful, but incompatible with some older versions of Mercurial. Format options |
|
882 | 882 | are considered at repository initialization only. You need to make a new clone |
|
883 | 883 | for config changes to be taken into account. |
|
884 | 884 | |
|
885 | 885 | For more details about repository format and version compatibility, see |
|
886 | 886 | https://www.mercurial-scm.org/wiki/MissingRequirement |
|
887 | 887 | |
|
888 | 888 | ``usegeneraldelta`` |
|
889 | 889 | Enable or disable the "generaldelta" repository format which improves |
|
890 | 890 | repository compression by allowing "revlog" to store deltas against |
|
891 | 891 | arbitrary revisions instead of the previously stored one. This provides |
|
892 | 892 | significant improvement for repositories with branches. |
|
893 | 893 | |
|
894 | 894 | Repositories with this on-disk format require Mercurial version 1.9. |
|
895 | 895 | |
|
896 | 896 | Enabled by default. |
|
897 | 897 | |
|
898 | 898 | ``dotencode`` |
|
899 | 899 | Enable or disable the "dotencode" repository format which enhances |
|
900 | 900 | the "fncache" repository format (which has to be enabled to use |
|
901 | 901 | dotencode) to avoid issues with filenames starting with "._" on |
|
902 | 902 | Mac OS X and spaces on Windows. |
|
903 | 903 | |
|
904 | 904 | Repositories with this on-disk format require Mercurial version 1.7. |
|
905 | 905 | |
|
906 | 906 | Enabled by default. |
|
907 | 907 | |
|
908 | 908 | ``usefncache`` |
|
909 | 909 | Enable or disable the "fncache" repository format which enhances |
|
910 | 910 | the "store" repository format (which has to be enabled to use |
|
911 | 911 | fncache) to allow longer filenames and avoids using Windows |
|
912 | 912 | reserved names, e.g. "nul". |
|
913 | 913 | |
|
914 | 914 | Repositories with this on-disk format require Mercurial version 1.1. |
|
915 | 915 | |
|
916 | 916 | Enabled by default. |
|
917 | 917 | |
|
918 | 918 | ``use-dirstate-v2`` |
|
919 | 919 | Enable or disable the experimental "dirstate-v2" feature. The dirstate |
|
920 | 920 | functionality is shared by all commands interacting with the working copy. |
|
921 | 921 | The new version is more robust, faster and stores more information. |
|
922 | 922 | |
|
923 | 923 | The performance-improving version of this feature is currently only |
|
924 | 924 | implemented in Rust (see :hg:`help rust`), so people not using a version of |
|
925 | 925 | Mercurial compiled with the Rust parts might actually suffer some slowdown. |
|
926 | 926 | For this reason, such versions will by default refuse to access repositories |
|
927 | 927 | with "dirstate-v2" enabled. |
|
928 | 928 | |
|
929 | 929 | This behavior can be adjusted via configuration: check |
|
930 | 930 | :hg:`help config.storage.dirstate-v2.slow-path` for details. |
|
931 | 931 | |
|
932 | 932 | Repositories with this on-disk format require Mercurial 6.0 or above. |
|
933 | 933 | |
|
934 | 934 | By default this format variant is disabled if the fast implementation is not |
|
935 | 935 | available, and enabled by default if the fast implementation is available. |
|
936 | 936 | |
|
937 | 937 | To accomodate installations of Mercurial without the fast implementation, |
|
938 | 938 | you can downgrade your repository. To do so run the following command: |
|
939 | 939 | |
|
940 | 940 | $ hg debugupgraderepo \ |
|
941 | 941 | --run \ |
|
942 | 942 | --config format.use-dirstate-v2=False \ |
|
943 | 943 | --config storage.dirstate-v2.slow-path=allow |
|
944 | 944 | |
|
945 | 945 | For a more comprehensive guide, see :hg:`help internals.dirstate-v2`. |
|
946 | 946 | |
|
947 | ``exp-dirstate-tracked-key-version`` | |
|
948 | Enable or disable the writing of "tracked key" file alongside the dirstate. | |
|
949 | ||
|
950 | That "tracked-key" can help external automations to detect changes to the | |
|
951 | set of tracked files. | |
|
952 | ||
|
953 | Two values are currently supported: | |
|
954 | - 0: no file is written (the default), | |
|
955 | - 1: a file in version "1" is written. | |
|
956 | ||
|
957 | The tracked-key is written in a new `.hg/dirstate-tracked-key`. That file | |
|
958 | contains two lines: | |
|
959 | - the first line is the file version (currently: 1), | |
|
960 | - the second line contains the "tracked-key". | |
|
961 | ||
|
962 | The tracked-key changes whenever the set of file tracked in the dirstate | |
|
963 | changes. The general guarantees are: | |
|
964 | - if the tracked key is identical, the set of tracked file MUST not have changed, | |
|
965 | - if the tracked key is different, the set of tracked file MIGHT differ. | |
|
966 | ||
|
967 | They are two "ways" to use this feature: | |
|
968 | ||
|
969 | 1) monitoring changes to the `.hg/dirstate-tracked-key`, if the file changes | |
|
970 | the tracked set might have changed. | |
|
971 | ||
|
972 | 2) storing the value and comparing it to a later value. Beware that it is | |
|
973 | impossible to achieve atomic writing or reading of the two files involved | |
|
974 | files (`.hg/dirstate` and `.hg/dirstate-tracked-key`). So it is needed to | |
|
975 | read the `tracked-key` files twice: before and after reading the tracked | |
|
976 | set. The `tracked-key` is only usable as a cache key if it had the same | |
|
977 | value in both cases and must be discarded otherwise. | |
|
978 | ||
|
979 | To enforce that the `tracked-key` value can be used race-free (with double | |
|
980 | reading as explained in (2)), the `.hg/dirstate-tracked-key` is written | |
|
981 | twice: before and after we change the associated `.hg/dirstate` file. | |
|
982 | ||
|
947 | 983 | ``use-persistent-nodemap`` |
|
948 | 984 | Enable or disable the "persistent-nodemap" feature which improves |
|
949 | 985 | performance if the Rust extensions are available. |
|
950 | 986 | |
|
951 | 987 | The "persistent-nodemap" persist the "node -> rev" on disk removing the |
|
952 | 988 | need to dynamically build that mapping for each Mercurial invocation. This |
|
953 | 989 | significantly reduces the startup cost of various local and server-side |
|
954 | 990 | operation for larger repositories. |
|
955 | 991 | |
|
956 | 992 | The performance-improving version of this feature is currently only |
|
957 | 993 | implemented in Rust (see :hg:`help rust`), so people not using a version of |
|
958 | 994 | Mercurial compiled with the Rust parts might actually suffer some slowdown. |
|
959 | 995 | For this reason, such versions will by default refuse to access repositories |
|
960 | 996 | with "persistent-nodemap". |
|
961 | 997 | |
|
962 | 998 | This behavior can be adjusted via configuration: check |
|
963 | 999 | :hg:`help config.storage.revlog.persistent-nodemap.slow-path` for details. |
|
964 | 1000 | |
|
965 | 1001 | Repositories with this on-disk format require Mercurial 5.4 or above. |
|
966 | 1002 | |
|
967 | 1003 | By default this format variant is disabled if the fast implementation is not |
|
968 | 1004 | available, and enabled by default if the fast implementation is available. |
|
969 | 1005 | |
|
970 | 1006 | To accomodate installations of Mercurial without the fast implementation, |
|
971 | 1007 | you can downgrade your repository. To do so run the following command: |
|
972 | 1008 | |
|
973 | 1009 | $ hg debugupgraderepo \ |
|
974 | 1010 | --run \ |
|
975 | 1011 | --config format.use-persistent-nodemap=False \ |
|
976 | 1012 | --config storage.revlog.persistent-nodemap.slow-path=allow |
|
977 | 1013 | |
|
978 | 1014 | ``use-share-safe`` |
|
979 | 1015 | Enforce "safe" behaviors for all "shares" that access this repository. |
|
980 | 1016 | |
|
981 | 1017 | With this feature, "shares" using this repository as a source will: |
|
982 | 1018 | |
|
983 | 1019 | * read the source repository's configuration (`<source>/.hg/hgrc`). |
|
984 | 1020 | * read and use the source repository's "requirements" |
|
985 | 1021 | (except the working copy specific one). |
|
986 | 1022 | |
|
987 | 1023 | Without this feature, "shares" using this repository as a source will: |
|
988 | 1024 | |
|
989 | 1025 | * keep tracking the repository "requirements" in the share only, ignoring |
|
990 | 1026 | the source "requirements", possibly diverging from them. |
|
991 | 1027 | * ignore source repository config. This can create problems, like silently |
|
992 | 1028 | ignoring important hooks. |
|
993 | 1029 | |
|
994 | 1030 | Beware that existing shares will not be upgraded/downgraded, and by |
|
995 | 1031 | default, Mercurial will refuse to interact with them until the mismatch |
|
996 | 1032 | is resolved. See :hg:`help config share.safe-mismatch.source-safe` and |
|
997 | 1033 | :hg:`help config share.safe-mismatch.source-not-safe` for details. |
|
998 | 1034 | |
|
999 | 1035 | Introduced in Mercurial 5.7. |
|
1000 | 1036 | |
|
1001 | 1037 | Enabled by default in Mercurial 6.1. |
|
1002 | 1038 | |
|
1003 | 1039 | ``usestore`` |
|
1004 | 1040 | Enable or disable the "store" repository format which improves |
|
1005 | 1041 | compatibility with systems that fold case or otherwise mangle |
|
1006 | 1042 | filenames. Disabling this option will allow you to store longer filenames |
|
1007 | 1043 | in some situations at the expense of compatibility. |
|
1008 | 1044 | |
|
1009 | 1045 | Repositories with this on-disk format require Mercurial version 0.9.4. |
|
1010 | 1046 | |
|
1011 | 1047 | Enabled by default. |
|
1012 | 1048 | |
|
1013 | 1049 | ``sparse-revlog`` |
|
1014 | 1050 | Enable or disable the ``sparse-revlog`` delta strategy. This format improves |
|
1015 | 1051 | delta re-use inside revlog. For very branchy repositories, it results in a |
|
1016 | 1052 | smaller store. For repositories with many revisions, it also helps |
|
1017 | 1053 | performance (by using shortened delta chains.) |
|
1018 | 1054 | |
|
1019 | 1055 | Repositories with this on-disk format require Mercurial version 4.7 |
|
1020 | 1056 | |
|
1021 | 1057 | Enabled by default. |
|
1022 | 1058 | |
|
1023 | 1059 | ``revlog-compression`` |
|
1024 | 1060 | Compression algorithm used by revlog. Supported values are `zlib` and |
|
1025 | 1061 | `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is |
|
1026 | 1062 | a newer format that is usually a net win over `zlib`, operating faster at |
|
1027 | 1063 | better compression rates. Use `zstd` to reduce CPU usage. Multiple values |
|
1028 | 1064 | can be specified, the first available one will be used. |
|
1029 | 1065 | |
|
1030 | 1066 | On some systems, the Mercurial installation may lack `zstd` support. |
|
1031 | 1067 | |
|
1032 | 1068 | Default is `zstd` if available, `zlib` otherwise. |
|
1033 | 1069 | |
|
1034 | 1070 | ``bookmarks-in-store`` |
|
1035 | 1071 | Store bookmarks in .hg/store/. This means that bookmarks are shared when |
|
1036 | 1072 | using `hg share` regardless of the `-B` option. |
|
1037 | 1073 | |
|
1038 | 1074 | Repositories with this on-disk format require Mercurial version 5.1. |
|
1039 | 1075 | |
|
1040 | 1076 | Disabled by default. |
|
1041 | 1077 | |
|
1042 | 1078 | |
|
1043 | 1079 | ``graph`` |
|
1044 | 1080 | --------- |
|
1045 | 1081 | |
|
1046 | 1082 | Web graph view configuration. This section let you change graph |
|
1047 | 1083 | elements display properties by branches, for instance to make the |
|
1048 | 1084 | ``default`` branch stand out. |
|
1049 | 1085 | |
|
1050 | 1086 | Each line has the following format:: |
|
1051 | 1087 | |
|
1052 | 1088 | <branch>.<argument> = <value> |
|
1053 | 1089 | |
|
1054 | 1090 | where ``<branch>`` is the name of the branch being |
|
1055 | 1091 | customized. Example:: |
|
1056 | 1092 | |
|
1057 | 1093 | [graph] |
|
1058 | 1094 | # 2px width |
|
1059 | 1095 | default.width = 2 |
|
1060 | 1096 | # red color |
|
1061 | 1097 | default.color = FF0000 |
|
1062 | 1098 | |
|
1063 | 1099 | Supported arguments: |
|
1064 | 1100 | |
|
1065 | 1101 | ``width`` |
|
1066 | 1102 | Set branch edges width in pixels. |
|
1067 | 1103 | |
|
1068 | 1104 | ``color`` |
|
1069 | 1105 | Set branch edges color in hexadecimal RGB notation. |
|
1070 | 1106 | |
|
1071 | 1107 | ``hooks`` |
|
1072 | 1108 | --------- |
|
1073 | 1109 | |
|
1074 | 1110 | Commands or Python functions that get automatically executed by |
|
1075 | 1111 | various actions such as starting or finishing a commit. Multiple |
|
1076 | 1112 | hooks can be run for the same action by appending a suffix to the |
|
1077 | 1113 | action. Overriding a site-wide hook can be done by changing its |
|
1078 | 1114 | value or setting it to an empty string. Hooks can be prioritized |
|
1079 | 1115 | by adding a prefix of ``priority.`` to the hook name on a new line |
|
1080 | 1116 | and setting the priority. The default priority is 0. |
|
1081 | 1117 | |
|
1082 | 1118 | Example ``.hg/hgrc``:: |
|
1083 | 1119 | |
|
1084 | 1120 | [hooks] |
|
1085 | 1121 | # update working directory after adding changesets |
|
1086 | 1122 | changegroup.update = hg update |
|
1087 | 1123 | # do not use the site-wide hook |
|
1088 | 1124 | incoming = |
|
1089 | 1125 | incoming.email = /my/email/hook |
|
1090 | 1126 | incoming.autobuild = /my/build/hook |
|
1091 | 1127 | # force autobuild hook to run before other incoming hooks |
|
1092 | 1128 | priority.incoming.autobuild = 1 |
|
1093 | 1129 | ### control HGPLAIN setting when running autobuild hook |
|
1094 | 1130 | # HGPLAIN always set (default from Mercurial 5.7) |
|
1095 | 1131 | incoming.autobuild:run-with-plain = yes |
|
1096 | 1132 | # HGPLAIN never set |
|
1097 | 1133 | incoming.autobuild:run-with-plain = no |
|
1098 | 1134 | # HGPLAIN inherited from environment (default before Mercurial 5.7) |
|
1099 | 1135 | incoming.autobuild:run-with-plain = auto |
|
1100 | 1136 | |
|
1101 | 1137 | Most hooks are run with environment variables set that give useful |
|
1102 | 1138 | additional information. For each hook below, the environment variables |
|
1103 | 1139 | it is passed are listed with names in the form ``$HG_foo``. The |
|
1104 | 1140 | ``$HG_HOOKTYPE`` and ``$HG_HOOKNAME`` variables are set for all hooks. |
|
1105 | 1141 | They contain the type of hook which triggered the run and the full name |
|
1106 | 1142 | of the hook in the config, respectively. In the example above, this will |
|
1107 | 1143 | be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``. |
|
1108 | 1144 | |
|
1109 | 1145 | .. container:: windows |
|
1110 | 1146 | |
|
1111 | 1147 | Some basic Unix syntax can be enabled for portability, including ``$VAR`` |
|
1112 | 1148 | and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will |
|
1113 | 1149 | be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion |
|
1114 | 1150 | on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back |
|
1115 | 1151 | slash or inside of a strong quote. Strong quotes will be replaced by |
|
1116 | 1152 | double quotes after processing. |
|
1117 | 1153 | |
|
1118 | 1154 | This feature is enabled by adding a prefix of ``tonative.`` to the hook |
|
1119 | 1155 | name on a new line, and setting it to ``True``. For example:: |
|
1120 | 1156 | |
|
1121 | 1157 | [hooks] |
|
1122 | 1158 | incoming.autobuild = /my/build/hook |
|
1123 | 1159 | # enable translation to cmd.exe syntax for autobuild hook |
|
1124 | 1160 | tonative.incoming.autobuild = True |
|
1125 | 1161 | |
|
1126 | 1162 | ``changegroup`` |
|
1127 | 1163 | Run after a changegroup has been added via push, pull or unbundle. The ID of |
|
1128 | 1164 | the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``. |
|
1129 | 1165 | The URL from which changes came is in ``$HG_URL``. |
|
1130 | 1166 | |
|
1131 | 1167 | ``commit`` |
|
1132 | 1168 | Run after a changeset has been created in the local repository. The ID |
|
1133 | 1169 | of the newly created changeset is in ``$HG_NODE``. Parent changeset |
|
1134 | 1170 | IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
1135 | 1171 | |
|
1136 | 1172 | ``incoming`` |
|
1137 | 1173 | Run after a changeset has been pulled, pushed, or unbundled into |
|
1138 | 1174 | the local repository. The ID of the newly arrived changeset is in |
|
1139 | 1175 | ``$HG_NODE``. The URL that was source of the changes is in ``$HG_URL``. |
|
1140 | 1176 | |
|
1141 | 1177 | ``outgoing`` |
|
1142 | 1178 | Run after sending changes from the local repository to another. The ID of |
|
1143 | 1179 | first changeset sent is in ``$HG_NODE``. The source of operation is in |
|
1144 | 1180 | ``$HG_SOURCE``. Also see :hg:`help config.hooks.preoutgoing`. |
|
1145 | 1181 | |
|
1146 | 1182 | ``post-<command>`` |
|
1147 | 1183 | Run after successful invocations of the associated command. The |
|
1148 | 1184 | contents of the command line are passed as ``$HG_ARGS`` and the result |
|
1149 | 1185 | code in ``$HG_RESULT``. Parsed command line arguments are passed as |
|
1150 | 1186 | ``$HG_PATS`` and ``$HG_OPTS``. These contain string representations of |
|
1151 | 1187 | the python data internally passed to <command>. ``$HG_OPTS`` is a |
|
1152 | 1188 | dictionary of options (with unspecified options set to their defaults). |
|
1153 | 1189 | ``$HG_PATS`` is a list of arguments. Hook failure is ignored. |
|
1154 | 1190 | |
|
1155 | 1191 | ``fail-<command>`` |
|
1156 | 1192 | Run after a failed invocation of an associated command. The contents |
|
1157 | 1193 | of the command line are passed as ``$HG_ARGS``. Parsed command line |
|
1158 | 1194 | arguments are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain |
|
1159 | 1195 | string representations of the python data internally passed to |
|
1160 | 1196 | <command>. ``$HG_OPTS`` is a dictionary of options (with unspecified |
|
1161 | 1197 | options set to their defaults). ``$HG_PATS`` is a list of arguments. |
|
1162 | 1198 | Hook failure is ignored. |
|
1163 | 1199 | |
|
1164 | 1200 | ``pre-<command>`` |
|
1165 | 1201 | Run before executing the associated command. The contents of the |
|
1166 | 1202 | command line are passed as ``$HG_ARGS``. Parsed command line arguments |
|
1167 | 1203 | are passed as ``$HG_PATS`` and ``$HG_OPTS``. These contain string |
|
1168 | 1204 | representations of the data internally passed to <command>. ``$HG_OPTS`` |
|
1169 | 1205 | is a dictionary of options (with unspecified options set to their |
|
1170 | 1206 | defaults). ``$HG_PATS`` is a list of arguments. If the hook returns |
|
1171 | 1207 | failure, the command doesn't execute and Mercurial returns the failure |
|
1172 | 1208 | code. |
|
1173 | 1209 | |
|
1174 | 1210 | ``prechangegroup`` |
|
1175 | 1211 | Run before a changegroup is added via push, pull or unbundle. Exit |
|
1176 | 1212 | status 0 allows the changegroup to proceed. A non-zero status will |
|
1177 | 1213 | cause the push, pull or unbundle to fail. The URL from which changes |
|
1178 | 1214 | will come is in ``$HG_URL``. |
|
1179 | 1215 | |
|
1180 | 1216 | ``precommit`` |
|
1181 | 1217 | Run before starting a local commit. Exit status 0 allows the |
|
1182 | 1218 | commit to proceed. A non-zero status will cause the commit to fail. |
|
1183 | 1219 | Parent changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
1184 | 1220 | |
|
1185 | 1221 | ``prelistkeys`` |
|
1186 | 1222 | Run before listing pushkeys (like bookmarks) in the |
|
1187 | 1223 | repository. A non-zero status will cause failure. The key namespace is |
|
1188 | 1224 | in ``$HG_NAMESPACE``. |
|
1189 | 1225 | |
|
1190 | 1226 | ``preoutgoing`` |
|
1191 | 1227 | Run before collecting changes to send from the local repository to |
|
1192 | 1228 | another. A non-zero status will cause failure. This lets you prevent |
|
1193 | 1229 | pull over HTTP or SSH. It can also prevent propagating commits (via |
|
1194 | 1230 | local pull, push (outbound) or bundle commands), but not completely, |
|
1195 | 1231 | since you can just copy files instead. The source of operation is in |
|
1196 | 1232 | ``$HG_SOURCE``. If "serve", the operation is happening on behalf of a remote |
|
1197 | 1233 | SSH or HTTP repository. If "push", "pull" or "bundle", the operation |
|
1198 | 1234 | is happening on behalf of a repository on same system. |
|
1199 | 1235 | |
|
1200 | 1236 | ``prepushkey`` |
|
1201 | 1237 | Run before a pushkey (like a bookmark) is added to the |
|
1202 | 1238 | repository. A non-zero status will cause the key to be rejected. The |
|
1203 | 1239 | key namespace is in ``$HG_NAMESPACE``, the key is in ``$HG_KEY``, |
|
1204 | 1240 | the old value (if any) is in ``$HG_OLD``, and the new value is in |
|
1205 | 1241 | ``$HG_NEW``. |
|
1206 | 1242 | |
|
1207 | 1243 | ``pretag`` |
|
1208 | 1244 | Run before creating a tag. Exit status 0 allows the tag to be |
|
1209 | 1245 | created. A non-zero status will cause the tag to fail. The ID of the |
|
1210 | 1246 | changeset to tag is in ``$HG_NODE``. The name of tag is in ``$HG_TAG``. The |
|
1211 | 1247 | tag is local if ``$HG_LOCAL=1``, or in the repository if ``$HG_LOCAL=0``. |
|
1212 | 1248 | |
|
1213 | 1249 | ``pretxnopen`` |
|
1214 | 1250 | Run before any new repository transaction is open. The reason for the |
|
1215 | 1251 | transaction will be in ``$HG_TXNNAME``, and a unique identifier for the |
|
1216 | 1252 | transaction will be in ``$HG_TXNID``. A non-zero status will prevent the |
|
1217 | 1253 | transaction from being opened. |
|
1218 | 1254 | |
|
1219 | 1255 | ``pretxnclose`` |
|
1220 | 1256 | Run right before the transaction is actually finalized. Any repository change |
|
1221 | 1257 | will be visible to the hook program. This lets you validate the transaction |
|
1222 | 1258 | content or change it. Exit status 0 allows the commit to proceed. A non-zero |
|
1223 | 1259 | status will cause the transaction to be rolled back. The reason for the |
|
1224 | 1260 | transaction opening will be in ``$HG_TXNNAME``, and a unique identifier for |
|
1225 | 1261 | the transaction will be in ``$HG_TXNID``. The rest of the available data will |
|
1226 | 1262 | vary according the transaction type. Changes unbundled to the repository will |
|
1227 | 1263 | add ``$HG_URL`` and ``$HG_SOURCE``. New changesets will add ``$HG_NODE`` (the |
|
1228 | 1264 | ID of the first added changeset), ``$HG_NODE_LAST`` (the ID of the last added |
|
1229 | 1265 | changeset). Bookmark and phase changes will set ``$HG_BOOKMARK_MOVED`` and |
|
1230 | 1266 | ``$HG_PHASES_MOVED`` to ``1`` respectively. The number of new obsmarkers, if |
|
1231 | 1267 | any, will be in ``$HG_NEW_OBSMARKERS``, etc. |
|
1232 | 1268 | |
|
1233 | 1269 | ``pretxnclose-bookmark`` |
|
1234 | 1270 | Run right before a bookmark change is actually finalized. Any repository |
|
1235 | 1271 | change will be visible to the hook program. This lets you validate the |
|
1236 | 1272 | transaction content or change it. Exit status 0 allows the commit to |
|
1237 | 1273 | proceed. A non-zero status will cause the transaction to be rolled back. |
|
1238 | 1274 | The name of the bookmark will be available in ``$HG_BOOKMARK``, the new |
|
1239 | 1275 | bookmark location will be available in ``$HG_NODE`` while the previous |
|
1240 | 1276 | location will be available in ``$HG_OLDNODE``. In case of a bookmark |
|
1241 | 1277 | creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE`` |
|
1242 | 1278 | will be empty. |
|
1243 | 1279 | In addition, the reason for the transaction opening will be in |
|
1244 | 1280 | ``$HG_TXNNAME``, and a unique identifier for the transaction will be in |
|
1245 | 1281 | ``$HG_TXNID``. |
|
1246 | 1282 | |
|
1247 | 1283 | ``pretxnclose-phase`` |
|
1248 | 1284 | Run right before a phase change is actually finalized. Any repository change |
|
1249 | 1285 | will be visible to the hook program. This lets you validate the transaction |
|
1250 | 1286 | content or change it. Exit status 0 allows the commit to proceed. A non-zero |
|
1251 | 1287 | status will cause the transaction to be rolled back. The hook is called |
|
1252 | 1288 | multiple times, once for each revision affected by a phase change. |
|
1253 | 1289 | The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE`` |
|
1254 | 1290 | while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE`` |
|
1255 | 1291 | will be empty. In addition, the reason for the transaction opening will be in |
|
1256 | 1292 | ``$HG_TXNNAME``, and a unique identifier for the transaction will be in |
|
1257 | 1293 | ``$HG_TXNID``. The hook is also run for newly added revisions. In this case |
|
1258 | 1294 | the ``$HG_OLDPHASE`` entry will be empty. |
|
1259 | 1295 | |
|
1260 | 1296 | ``txnclose`` |
|
1261 | 1297 | Run after any repository transaction has been committed. At this |
|
1262 | 1298 | point, the transaction can no longer be rolled back. The hook will run |
|
1263 | 1299 | after the lock is released. See :hg:`help config.hooks.pretxnclose` for |
|
1264 | 1300 | details about available variables. |
|
1265 | 1301 | |
|
1266 | 1302 | ``txnclose-bookmark`` |
|
1267 | 1303 | Run after any bookmark change has been committed. At this point, the |
|
1268 | 1304 | transaction can no longer be rolled back. The hook will run after the lock |
|
1269 | 1305 | is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details |
|
1270 | 1306 | about available variables. |
|
1271 | 1307 | |
|
1272 | 1308 | ``txnclose-phase`` |
|
1273 | 1309 | Run after any phase change has been committed. At this point, the |
|
1274 | 1310 | transaction can no longer be rolled back. The hook will run after the lock |
|
1275 | 1311 | is released. See :hg:`help config.hooks.pretxnclose-phase` for details about |
|
1276 | 1312 | available variables. |
|
1277 | 1313 | |
|
1278 | 1314 | ``txnabort`` |
|
1279 | 1315 | Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose` |
|
1280 | 1316 | for details about available variables. |
|
1281 | 1317 | |
|
1282 | 1318 | ``pretxnchangegroup`` |
|
1283 | 1319 | Run after a changegroup has been added via push, pull or unbundle, but before |
|
1284 | 1320 | the transaction has been committed. The changegroup is visible to the hook |
|
1285 | 1321 | program. This allows validation of incoming changes before accepting them. |
|
1286 | 1322 | The ID of the first new changeset is in ``$HG_NODE`` and last is in |
|
1287 | 1323 | ``$HG_NODE_LAST``. Exit status 0 allows the transaction to commit. A non-zero |
|
1288 | 1324 | status will cause the transaction to be rolled back, and the push, pull or |
|
1289 | 1325 | unbundle will fail. The URL that was the source of changes is in ``$HG_URL``. |
|
1290 | 1326 | |
|
1291 | 1327 | ``pretxncommit`` |
|
1292 | 1328 | Run after a changeset has been created, but before the transaction is |
|
1293 | 1329 | committed. The changeset is visible to the hook program. This allows |
|
1294 | 1330 | validation of the commit message and changes. Exit status 0 allows the |
|
1295 | 1331 | commit to proceed. A non-zero status will cause the transaction to |
|
1296 | 1332 | be rolled back. The ID of the new changeset is in ``$HG_NODE``. The parent |
|
1297 | 1333 | changeset IDs are in ``$HG_PARENT1`` and ``$HG_PARENT2``. |
|
1298 | 1334 | |
|
1299 | 1335 | ``preupdate`` |
|
1300 | 1336 | Run before updating the working directory. Exit status 0 allows |
|
1301 | 1337 | the update to proceed. A non-zero status will prevent the update. |
|
1302 | 1338 | The changeset ID of first new parent is in ``$HG_PARENT1``. If updating to a |
|
1303 | 1339 | merge, the ID of second new parent is in ``$HG_PARENT2``. |
|
1304 | 1340 | |
|
1305 | 1341 | ``listkeys`` |
|
1306 | 1342 | Run after listing pushkeys (like bookmarks) in the repository. The |
|
1307 | 1343 | key namespace is in ``$HG_NAMESPACE``. ``$HG_VALUES`` is a |
|
1308 | 1344 | dictionary containing the keys and values. |
|
1309 | 1345 | |
|
1310 | 1346 | ``pushkey`` |
|
1311 | 1347 | Run after a pushkey (like a bookmark) is added to the |
|
1312 | 1348 | repository. The key namespace is in ``$HG_NAMESPACE``, the key is in |
|
1313 | 1349 | ``$HG_KEY``, the old value (if any) is in ``$HG_OLD``, and the new |
|
1314 | 1350 | value is in ``$HG_NEW``. |
|
1315 | 1351 | |
|
1316 | 1352 | ``tag`` |
|
1317 | 1353 | Run after a tag is created. The ID of the tagged changeset is in ``$HG_NODE``. |
|
1318 | 1354 | The name of tag is in ``$HG_TAG``. The tag is local if ``$HG_LOCAL=1``, or in |
|
1319 | 1355 | the repository if ``$HG_LOCAL=0``. |
|
1320 | 1356 | |
|
1321 | 1357 | ``update`` |
|
1322 | 1358 | Run after updating the working directory. The changeset ID of first |
|
1323 | 1359 | new parent is in ``$HG_PARENT1``. If updating to a merge, the ID of second new |
|
1324 | 1360 | parent is in ``$HG_PARENT2``. If the update succeeded, ``$HG_ERROR=0``. If the |
|
1325 | 1361 | update failed (e.g. because conflicts were not resolved), ``$HG_ERROR=1``. |
|
1326 | 1362 | |
|
1327 | 1363 | .. note:: |
|
1328 | 1364 | |
|
1329 | 1365 | It is generally better to use standard hooks rather than the |
|
1330 | 1366 | generic pre- and post- command hooks, as they are guaranteed to be |
|
1331 | 1367 | called in the appropriate contexts for influencing transactions. |
|
1332 | 1368 | Also, hooks like "commit" will be called in all contexts that |
|
1333 | 1369 | generate a commit (e.g. tag) and not just the commit command. |
|
1334 | 1370 | |
|
1335 | 1371 | .. note:: |
|
1336 | 1372 | |
|
1337 | 1373 | Environment variables with empty values may not be passed to |
|
1338 | 1374 | hooks on platforms such as Windows. As an example, ``$HG_PARENT2`` |
|
1339 | 1375 | will have an empty value under Unix-like platforms for non-merge |
|
1340 | 1376 | changesets, while it will not be available at all under Windows. |
|
1341 | 1377 | |
|
1342 | 1378 | The syntax for Python hooks is as follows:: |
|
1343 | 1379 | |
|
1344 | 1380 | hookname = python:modulename.submodule.callable |
|
1345 | 1381 | hookname = python:/path/to/python/module.py:callable |
|
1346 | 1382 | |
|
1347 | 1383 | Python hooks are run within the Mercurial process. Each hook is |
|
1348 | 1384 | called with at least three keyword arguments: a ui object (keyword |
|
1349 | 1385 | ``ui``), a repository object (keyword ``repo``), and a ``hooktype`` |
|
1350 | 1386 | keyword that tells what kind of hook is used. Arguments listed as |
|
1351 | 1387 | environment variables above are passed as keyword arguments, with no |
|
1352 | 1388 | ``HG_`` prefix, and names in lower case. |
|
1353 | 1389 | |
|
1354 | 1390 | If a Python hook returns a "true" value or raises an exception, this |
|
1355 | 1391 | is treated as a failure. |
|
1356 | 1392 | |
|
1357 | 1393 | |
|
1358 | 1394 | ``hostfingerprints`` |
|
1359 | 1395 | -------------------- |
|
1360 | 1396 | |
|
1361 | 1397 | (Deprecated. Use ``[hostsecurity]``'s ``fingerprints`` options instead.) |
|
1362 | 1398 | |
|
1363 | 1399 | Fingerprints of the certificates of known HTTPS servers. |
|
1364 | 1400 | |
|
1365 | 1401 | A HTTPS connection to a server with a fingerprint configured here will |
|
1366 | 1402 | only succeed if the servers certificate matches the fingerprint. |
|
1367 | 1403 | This is very similar to how ssh known hosts works. |
|
1368 | 1404 | |
|
1369 | 1405 | The fingerprint is the SHA-1 hash value of the DER encoded certificate. |
|
1370 | 1406 | Multiple values can be specified (separated by spaces or commas). This can |
|
1371 | 1407 | be used to define both old and new fingerprints while a host transitions |
|
1372 | 1408 | to a new certificate. |
|
1373 | 1409 | |
|
1374 | 1410 | The CA chain and web.cacerts is not used for servers with a fingerprint. |
|
1375 | 1411 | |
|
1376 | 1412 | For example:: |
|
1377 | 1413 | |
|
1378 | 1414 | [hostfingerprints] |
|
1379 | 1415 | hg.intevation.de = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33 |
|
1380 | 1416 | hg.intevation.org = fc:e2:8d:d9:51:cd:cb:c1:4d:18:6b:b7:44:8d:49:72:57:e6:cd:33 |
|
1381 | 1417 | |
|
1382 | 1418 | ``hostsecurity`` |
|
1383 | 1419 | ---------------- |
|
1384 | 1420 | |
|
1385 | 1421 | Used to specify global and per-host security settings for connecting to |
|
1386 | 1422 | other machines. |
|
1387 | 1423 | |
|
1388 | 1424 | The following options control default behavior for all hosts. |
|
1389 | 1425 | |
|
1390 | 1426 | ``ciphers`` |
|
1391 | 1427 | Defines the cryptographic ciphers to use for connections. |
|
1392 | 1428 | |
|
1393 | 1429 | Value must be a valid OpenSSL Cipher List Format as documented at |
|
1394 | 1430 | https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-LIST-FORMAT. |
|
1395 | 1431 | |
|
1396 | 1432 | This setting is for advanced users only. Setting to incorrect values |
|
1397 | 1433 | can significantly lower connection security or decrease performance. |
|
1398 | 1434 | You have been warned. |
|
1399 | 1435 | |
|
1400 | 1436 | This option requires Python 2.7. |
|
1401 | 1437 | |
|
1402 | 1438 | ``minimumprotocol`` |
|
1403 | 1439 | Defines the minimum channel encryption protocol to use. |
|
1404 | 1440 | |
|
1405 | 1441 | By default, the highest version of TLS supported by both client and server |
|
1406 | 1442 | is used. |
|
1407 | 1443 | |
|
1408 | 1444 | Allowed values are: ``tls1.0``, ``tls1.1``, ``tls1.2``. |
|
1409 | 1445 | |
|
1410 | 1446 | When running on an old Python version, only ``tls1.0`` is allowed since |
|
1411 | 1447 | old versions of Python only support up to TLS 1.0. |
|
1412 | 1448 | |
|
1413 | 1449 | When running a Python that supports modern TLS versions, the default is |
|
1414 | 1450 | ``tls1.1``. ``tls1.0`` can still be used to allow TLS 1.0. However, this |
|
1415 | 1451 | weakens security and should only be used as a feature of last resort if |
|
1416 | 1452 | a server does not support TLS 1.1+. |
|
1417 | 1453 | |
|
1418 | 1454 | Options in the ``[hostsecurity]`` section can have the form |
|
1419 | 1455 | ``hostname``:``setting``. This allows multiple settings to be defined on a |
|
1420 | 1456 | per-host basis. |
|
1421 | 1457 | |
|
1422 | 1458 | The following per-host settings can be defined. |
|
1423 | 1459 | |
|
1424 | 1460 | ``ciphers`` |
|
1425 | 1461 | This behaves like ``ciphers`` as described above except it only applies |
|
1426 | 1462 | to the host on which it is defined. |
|
1427 | 1463 | |
|
1428 | 1464 | ``fingerprints`` |
|
1429 | 1465 | A list of hashes of the DER encoded peer/remote certificate. Values have |
|
1430 | 1466 | the form ``algorithm``:``fingerprint``. e.g. |
|
1431 | 1467 | ``sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2``. |
|
1432 | 1468 | In addition, colons (``:``) can appear in the fingerprint part. |
|
1433 | 1469 | |
|
1434 | 1470 | The following algorithms/prefixes are supported: ``sha1``, ``sha256``, |
|
1435 | 1471 | ``sha512``. |
|
1436 | 1472 | |
|
1437 | 1473 | Use of ``sha256`` or ``sha512`` is preferred. |
|
1438 | 1474 | |
|
1439 | 1475 | If a fingerprint is specified, the CA chain is not validated for this |
|
1440 | 1476 | host and Mercurial will require the remote certificate to match one |
|
1441 | 1477 | of the fingerprints specified. This means if the server updates its |
|
1442 | 1478 | certificate, Mercurial will abort until a new fingerprint is defined. |
|
1443 | 1479 | This can provide stronger security than traditional CA-based validation |
|
1444 | 1480 | at the expense of convenience. |
|
1445 | 1481 | |
|
1446 | 1482 | This option takes precedence over ``verifycertsfile``. |
|
1447 | 1483 | |
|
1448 | 1484 | ``minimumprotocol`` |
|
1449 | 1485 | This behaves like ``minimumprotocol`` as described above except it |
|
1450 | 1486 | only applies to the host on which it is defined. |
|
1451 | 1487 | |
|
1452 | 1488 | ``verifycertsfile`` |
|
1453 | 1489 | Path to file a containing a list of PEM encoded certificates used to |
|
1454 | 1490 | verify the server certificate. Environment variables and ``~user`` |
|
1455 | 1491 | constructs are expanded in the filename. |
|
1456 | 1492 | |
|
1457 | 1493 | The server certificate or the certificate's certificate authority (CA) |
|
1458 | 1494 | must match a certificate from this file or certificate verification |
|
1459 | 1495 | will fail and connections to the server will be refused. |
|
1460 | 1496 | |
|
1461 | 1497 | If defined, only certificates provided by this file will be used: |
|
1462 | 1498 | ``web.cacerts`` and any system/default certificates will not be |
|
1463 | 1499 | used. |
|
1464 | 1500 | |
|
1465 | 1501 | This option has no effect if the per-host ``fingerprints`` option |
|
1466 | 1502 | is set. |
|
1467 | 1503 | |
|
1468 | 1504 | The format of the file is as follows:: |
|
1469 | 1505 | |
|
1470 | 1506 | -----BEGIN CERTIFICATE----- |
|
1471 | 1507 | ... (certificate in base64 PEM encoding) ... |
|
1472 | 1508 | -----END CERTIFICATE----- |
|
1473 | 1509 | -----BEGIN CERTIFICATE----- |
|
1474 | 1510 | ... (certificate in base64 PEM encoding) ... |
|
1475 | 1511 | -----END CERTIFICATE----- |
|
1476 | 1512 | |
|
1477 | 1513 | For example:: |
|
1478 | 1514 | |
|
1479 | 1515 | [hostsecurity] |
|
1480 | 1516 | hg.example.com:fingerprints = sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2 |
|
1481 | 1517 | 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 |
|
1482 | 1518 | 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 |
|
1483 | 1519 | foo.example.com:verifycertsfile = /etc/ssl/trusted-ca-certs.pem |
|
1484 | 1520 | |
|
1485 | 1521 | To change the default minimum protocol version to TLS 1.2 but to allow TLS 1.1 |
|
1486 | 1522 | when connecting to ``hg.example.com``:: |
|
1487 | 1523 | |
|
1488 | 1524 | [hostsecurity] |
|
1489 | 1525 | minimumprotocol = tls1.2 |
|
1490 | 1526 | hg.example.com:minimumprotocol = tls1.1 |
|
1491 | 1527 | |
|
1492 | 1528 | ``http_proxy`` |
|
1493 | 1529 | -------------- |
|
1494 | 1530 | |
|
1495 | 1531 | Used to access web-based Mercurial repositories through a HTTP |
|
1496 | 1532 | proxy. |
|
1497 | 1533 | |
|
1498 | 1534 | ``host`` |
|
1499 | 1535 | Host name and (optional) port of the proxy server, for example |
|
1500 | 1536 | "myproxy:8000". |
|
1501 | 1537 | |
|
1502 | 1538 | ``no`` |
|
1503 | 1539 | Optional. Comma-separated list of host names that should bypass |
|
1504 | 1540 | the proxy. |
|
1505 | 1541 | |
|
1506 | 1542 | ``passwd`` |
|
1507 | 1543 | Optional. Password to authenticate with at the proxy server. |
|
1508 | 1544 | |
|
1509 | 1545 | ``user`` |
|
1510 | 1546 | Optional. User name to authenticate with at the proxy server. |
|
1511 | 1547 | |
|
1512 | 1548 | ``always`` |
|
1513 | 1549 | Optional. Always use the proxy, even for localhost and any entries |
|
1514 | 1550 | in ``http_proxy.no``. (default: False) |
|
1515 | 1551 | |
|
1516 | 1552 | ``http`` |
|
1517 | 1553 | ---------- |
|
1518 | 1554 | |
|
1519 | 1555 | Used to configure access to Mercurial repositories via HTTP. |
|
1520 | 1556 | |
|
1521 | 1557 | ``timeout`` |
|
1522 | 1558 | If set, blocking operations will timeout after that many seconds. |
|
1523 | 1559 | (default: None) |
|
1524 | 1560 | |
|
1525 | 1561 | ``merge`` |
|
1526 | 1562 | --------- |
|
1527 | 1563 | |
|
1528 | 1564 | This section specifies behavior during merges and updates. |
|
1529 | 1565 | |
|
1530 | 1566 | ``checkignored`` |
|
1531 | 1567 | Controls behavior when an ignored file on disk has the same name as a tracked |
|
1532 | 1568 | file in the changeset being merged or updated to, and has different |
|
1533 | 1569 | contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``, |
|
1534 | 1570 | abort on such files. With ``warn``, warn on such files and back them up as |
|
1535 | 1571 | ``.orig``. With ``ignore``, don't print a warning and back them up as |
|
1536 | 1572 | ``.orig``. (default: ``abort``) |
|
1537 | 1573 | |
|
1538 | 1574 | ``checkunknown`` |
|
1539 | 1575 | Controls behavior when an unknown file that isn't ignored has the same name |
|
1540 | 1576 | as a tracked file in the changeset being merged or updated to, and has |
|
1541 | 1577 | different contents. Similar to ``merge.checkignored``, except for files that |
|
1542 | 1578 | are not ignored. (default: ``abort``) |
|
1543 | 1579 | |
|
1544 | 1580 | ``on-failure`` |
|
1545 | 1581 | When set to ``continue`` (the default), the merge process attempts to |
|
1546 | 1582 | merge all unresolved files using the merge chosen tool, regardless of |
|
1547 | 1583 | whether previous file merge attempts during the process succeeded or not. |
|
1548 | 1584 | Setting this to ``prompt`` will prompt after any merge failure continue |
|
1549 | 1585 | or halt the merge process. Setting this to ``halt`` will automatically |
|
1550 | 1586 | halt the merge process on any merge tool failure. The merge process |
|
1551 | 1587 | can be restarted by using the ``resolve`` command. When a merge is |
|
1552 | 1588 | halted, the repository is left in a normal ``unresolved`` merge state. |
|
1553 | 1589 | (default: ``continue``) |
|
1554 | 1590 | |
|
1555 | 1591 | ``strict-capability-check`` |
|
1556 | 1592 | Whether capabilities of internal merge tools are checked strictly |
|
1557 | 1593 | or not, while examining rules to decide merge tool to be used. |
|
1558 | 1594 | (default: False) |
|
1559 | 1595 | |
|
1560 | 1596 | ``merge-patterns`` |
|
1561 | 1597 | ------------------ |
|
1562 | 1598 | |
|
1563 | 1599 | This section specifies merge tools to associate with particular file |
|
1564 | 1600 | patterns. Tools matched here will take precedence over the default |
|
1565 | 1601 | merge tool. Patterns are globs by default, rooted at the repository |
|
1566 | 1602 | root. |
|
1567 | 1603 | |
|
1568 | 1604 | Example:: |
|
1569 | 1605 | |
|
1570 | 1606 | [merge-patterns] |
|
1571 | 1607 | **.c = kdiff3 |
|
1572 | 1608 | **.jpg = myimgmerge |
|
1573 | 1609 | |
|
1574 | 1610 | ``merge-tools`` |
|
1575 | 1611 | --------------- |
|
1576 | 1612 | |
|
1577 | 1613 | This section configures external merge tools to use for file-level |
|
1578 | 1614 | merges. This section has likely been preconfigured at install time. |
|
1579 | 1615 | Use :hg:`config merge-tools` to check the existing configuration. |
|
1580 | 1616 | Also see :hg:`help merge-tools` for more details. |
|
1581 | 1617 | |
|
1582 | 1618 | Example ``~/.hgrc``:: |
|
1583 | 1619 | |
|
1584 | 1620 | [merge-tools] |
|
1585 | 1621 | # Override stock tool location |
|
1586 | 1622 | kdiff3.executable = ~/bin/kdiff3 |
|
1587 | 1623 | # Specify command line |
|
1588 | 1624 | kdiff3.args = $base $local $other -o $output |
|
1589 | 1625 | # Give higher priority |
|
1590 | 1626 | kdiff3.priority = 1 |
|
1591 | 1627 | |
|
1592 | 1628 | # Changing the priority of preconfigured tool |
|
1593 | 1629 | meld.priority = 0 |
|
1594 | 1630 | |
|
1595 | 1631 | # Disable a preconfigured tool |
|
1596 | 1632 | vimdiff.disabled = yes |
|
1597 | 1633 | |
|
1598 | 1634 | # Define new tool |
|
1599 | 1635 | myHtmlTool.args = -m $local $other $base $output |
|
1600 | 1636 | myHtmlTool.regkey = Software\FooSoftware\HtmlMerge |
|
1601 | 1637 | myHtmlTool.priority = 1 |
|
1602 | 1638 | |
|
1603 | 1639 | Supported arguments: |
|
1604 | 1640 | |
|
1605 | 1641 | ``priority`` |
|
1606 | 1642 | The priority in which to evaluate this tool. |
|
1607 | 1643 | (default: 0) |
|
1608 | 1644 | |
|
1609 | 1645 | ``executable`` |
|
1610 | 1646 | Either just the name of the executable or its pathname. |
|
1611 | 1647 | |
|
1612 | 1648 | .. container:: windows |
|
1613 | 1649 | |
|
1614 | 1650 | On Windows, the path can use environment variables with ${ProgramFiles} |
|
1615 | 1651 | syntax. |
|
1616 | 1652 | |
|
1617 | 1653 | (default: the tool name) |
|
1618 | 1654 | |
|
1619 | 1655 | ``args`` |
|
1620 | 1656 | The arguments to pass to the tool executable. You can refer to the |
|
1621 | 1657 | files being merged as well as the output file through these |
|
1622 | 1658 | variables: ``$base``, ``$local``, ``$other``, ``$output``. |
|
1623 | 1659 | |
|
1624 | 1660 | The meaning of ``$local`` and ``$other`` can vary depending on which action is |
|
1625 | 1661 | being performed. During an update or merge, ``$local`` represents the original |
|
1626 | 1662 | state of the file, while ``$other`` represents the commit you are updating to or |
|
1627 | 1663 | the commit you are merging with. During a rebase, ``$local`` represents the |
|
1628 | 1664 | destination of the rebase, and ``$other`` represents the commit being rebased. |
|
1629 | 1665 | |
|
1630 | 1666 | Some operations define custom labels to assist with identifying the revisions, |
|
1631 | 1667 | accessible via ``$labellocal``, ``$labelother``, and ``$labelbase``. If custom |
|
1632 | 1668 | labels are not available, these will be ``local``, ``other``, and ``base``, |
|
1633 | 1669 | respectively. |
|
1634 | 1670 | (default: ``$local $base $other``) |
|
1635 | 1671 | |
|
1636 | 1672 | ``premerge`` |
|
1637 | 1673 | Attempt to run internal non-interactive 3-way merge tool before |
|
1638 | 1674 | launching external tool. Options are ``true``, ``false``, ``keep``, |
|
1639 | 1675 | ``keep-merge3``, or ``keep-mergediff`` (experimental). The ``keep`` option |
|
1640 | 1676 | will leave markers in the file if the premerge fails. The ``keep-merge3`` |
|
1641 | 1677 | will do the same but include information about the base of the merge in the |
|
1642 | 1678 | marker (see internal :merge3 in :hg:`help merge-tools`). The |
|
1643 | 1679 | ``keep-mergediff`` option is similar but uses a different marker style |
|
1644 | 1680 | (see internal :merge3 in :hg:`help merge-tools`). (default: True) |
|
1645 | 1681 | |
|
1646 | 1682 | ``binary`` |
|
1647 | 1683 | This tool can merge binary files. (default: False, unless tool |
|
1648 | 1684 | was selected by file pattern match) |
|
1649 | 1685 | |
|
1650 | 1686 | ``symlink`` |
|
1651 | 1687 | This tool can merge symlinks. (default: False) |
|
1652 | 1688 | |
|
1653 | 1689 | ``check`` |
|
1654 | 1690 | A list of merge success-checking options: |
|
1655 | 1691 | |
|
1656 | 1692 | ``changed`` |
|
1657 | 1693 | Ask whether merge was successful when the merged file shows no changes. |
|
1658 | 1694 | ``conflicts`` |
|
1659 | 1695 | Check whether there are conflicts even though the tool reported success. |
|
1660 | 1696 | ``prompt`` |
|
1661 | 1697 | Always prompt for merge success, regardless of success reported by tool. |
|
1662 | 1698 | |
|
1663 | 1699 | ``fixeol`` |
|
1664 | 1700 | Attempt to fix up EOL changes caused by the merge tool. |
|
1665 | 1701 | (default: False) |
|
1666 | 1702 | |
|
1667 | 1703 | ``gui`` |
|
1668 | 1704 | This tool requires a graphical interface to run. (default: False) |
|
1669 | 1705 | |
|
1670 | 1706 | ``mergemarkers`` |
|
1671 | 1707 | Controls whether the labels passed via ``$labellocal``, ``$labelother``, and |
|
1672 | 1708 | ``$labelbase`` are ``detailed`` (respecting ``mergemarkertemplate``) or |
|
1673 | 1709 | ``basic``. If ``premerge`` is ``keep`` or ``keep-merge3``, the conflict |
|
1674 | 1710 | markers generated during premerge will be ``detailed`` if either this option or |
|
1675 | 1711 | the corresponding option in the ``[ui]`` section is ``detailed``. |
|
1676 | 1712 | (default: ``basic``) |
|
1677 | 1713 | |
|
1678 | 1714 | ``mergemarkertemplate`` |
|
1679 | 1715 | This setting can be used to override ``mergemarker`` from the |
|
1680 | 1716 | ``[command-templates]`` section on a per-tool basis; this applies to the |
|
1681 | 1717 | ``$label``-prefixed variables and to the conflict markers that are generated |
|
1682 | 1718 | if ``premerge`` is ``keep` or ``keep-merge3``. See the corresponding variable |
|
1683 | 1719 | in ``[ui]`` for more information. |
|
1684 | 1720 | |
|
1685 | 1721 | .. container:: windows |
|
1686 | 1722 | |
|
1687 | 1723 | ``regkey`` |
|
1688 | 1724 | Windows registry key which describes install location of this |
|
1689 | 1725 | tool. Mercurial will search for this key first under |
|
1690 | 1726 | ``HKEY_CURRENT_USER`` and then under ``HKEY_LOCAL_MACHINE``. |
|
1691 | 1727 | (default: None) |
|
1692 | 1728 | |
|
1693 | 1729 | ``regkeyalt`` |
|
1694 | 1730 | An alternate Windows registry key to try if the first key is not |
|
1695 | 1731 | found. The alternate key uses the same ``regname`` and ``regappend`` |
|
1696 | 1732 | semantics of the primary key. The most common use for this key |
|
1697 | 1733 | is to search for 32bit applications on 64bit operating systems. |
|
1698 | 1734 | (default: None) |
|
1699 | 1735 | |
|
1700 | 1736 | ``regname`` |
|
1701 | 1737 | Name of value to read from specified registry key. |
|
1702 | 1738 | (default: the unnamed (default) value) |
|
1703 | 1739 | |
|
1704 | 1740 | ``regappend`` |
|
1705 | 1741 | String to append to the value read from the registry, typically |
|
1706 | 1742 | the executable name of the tool. |
|
1707 | 1743 | (default: None) |
|
1708 | 1744 | |
|
1709 | 1745 | ``pager`` |
|
1710 | 1746 | --------- |
|
1711 | 1747 | |
|
1712 | 1748 | Setting used to control when to paginate and with what external tool. See |
|
1713 | 1749 | :hg:`help pager` for details. |
|
1714 | 1750 | |
|
1715 | 1751 | ``pager`` |
|
1716 | 1752 | Define the external tool used as pager. |
|
1717 | 1753 | |
|
1718 | 1754 | If no pager is set, Mercurial uses the environment variable $PAGER. |
|
1719 | 1755 | If neither pager.pager, nor $PAGER is set, a default pager will be |
|
1720 | 1756 | used, typically `less` on Unix and `more` on Windows. Example:: |
|
1721 | 1757 | |
|
1722 | 1758 | [pager] |
|
1723 | 1759 | pager = less -FRX |
|
1724 | 1760 | |
|
1725 | 1761 | ``ignore`` |
|
1726 | 1762 | List of commands to disable the pager for. Example:: |
|
1727 | 1763 | |
|
1728 | 1764 | [pager] |
|
1729 | 1765 | ignore = version, help, update |
|
1730 | 1766 | |
|
1731 | 1767 | ``patch`` |
|
1732 | 1768 | --------- |
|
1733 | 1769 | |
|
1734 | 1770 | Settings used when applying patches, for instance through the 'import' |
|
1735 | 1771 | command or with Mercurial Queues extension. |
|
1736 | 1772 | |
|
1737 | 1773 | ``eol`` |
|
1738 | 1774 | When set to 'strict' patch content and patched files end of lines |
|
1739 | 1775 | are preserved. When set to ``lf`` or ``crlf``, both files end of |
|
1740 | 1776 | lines are ignored when patching and the result line endings are |
|
1741 | 1777 | normalized to either LF (Unix) or CRLF (Windows). When set to |
|
1742 | 1778 | ``auto``, end of lines are again ignored while patching but line |
|
1743 | 1779 | endings in patched files are normalized to their original setting |
|
1744 | 1780 | on a per-file basis. If target file does not exist or has no end |
|
1745 | 1781 | of line, patch line endings are preserved. |
|
1746 | 1782 | (default: strict) |
|
1747 | 1783 | |
|
1748 | 1784 | ``fuzz`` |
|
1749 | 1785 | The number of lines of 'fuzz' to allow when applying patches. This |
|
1750 | 1786 | controls how much context the patcher is allowed to ignore when |
|
1751 | 1787 | trying to apply a patch. |
|
1752 | 1788 | (default: 2) |
|
1753 | 1789 | |
|
1754 | 1790 | ``paths`` |
|
1755 | 1791 | --------- |
|
1756 | 1792 | |
|
1757 | 1793 | Assigns symbolic names and behavior to repositories. |
|
1758 | 1794 | |
|
1759 | 1795 | Options are symbolic names defining the URL or directory that is the |
|
1760 | 1796 | location of the repository. Example:: |
|
1761 | 1797 | |
|
1762 | 1798 | [paths] |
|
1763 | 1799 | my_server = https://example.com/my_repo |
|
1764 | 1800 | local_path = /home/me/repo |
|
1765 | 1801 | |
|
1766 | 1802 | These symbolic names can be used from the command line. To pull |
|
1767 | 1803 | from ``my_server``: :hg:`pull my_server`. To push to ``local_path``: |
|
1768 | 1804 | :hg:`push local_path`. You can check :hg:`help urls` for details about |
|
1769 | 1805 | valid URLs. |
|
1770 | 1806 | |
|
1771 | 1807 | Options containing colons (``:``) denote sub-options that can influence |
|
1772 | 1808 | behavior for that specific path. Example:: |
|
1773 | 1809 | |
|
1774 | 1810 | [paths] |
|
1775 | 1811 | my_server = https://example.com/my_path |
|
1776 | 1812 | my_server:pushurl = ssh://example.com/my_path |
|
1777 | 1813 | |
|
1778 | 1814 | Paths using the `path://otherpath` scheme will inherit the sub-options value from |
|
1779 | 1815 | the path they point to. |
|
1780 | 1816 | |
|
1781 | 1817 | The following sub-options can be defined: |
|
1782 | 1818 | |
|
1783 | 1819 | ``multi-urls`` |
|
1784 | 1820 | A boolean option. When enabled the value of the `[paths]` entry will be |
|
1785 | 1821 | parsed as a list and the alias will resolve to multiple destination. If some |
|
1786 | 1822 | of the list entry use the `path://` syntax, the suboption will be inherited |
|
1787 | 1823 | individually. |
|
1788 | 1824 | |
|
1789 | 1825 | ``pushurl`` |
|
1790 | 1826 | The URL to use for push operations. If not defined, the location |
|
1791 | 1827 | defined by the path's main entry is used. |
|
1792 | 1828 | |
|
1793 | 1829 | ``pushrev`` |
|
1794 | 1830 | A revset defining which revisions to push by default. |
|
1795 | 1831 | |
|
1796 | 1832 | When :hg:`push` is executed without a ``-r`` argument, the revset |
|
1797 | 1833 | defined by this sub-option is evaluated to determine what to push. |
|
1798 | 1834 | |
|
1799 | 1835 | For example, a value of ``.`` will push the working directory's |
|
1800 | 1836 | revision by default. |
|
1801 | 1837 | |
|
1802 | 1838 | Revsets specifying bookmarks will not result in the bookmark being |
|
1803 | 1839 | pushed. |
|
1804 | 1840 | |
|
1805 | 1841 | ``bookmarks.mode`` |
|
1806 | 1842 | How bookmark will be dealt during the exchange. It support the following value |
|
1807 | 1843 | |
|
1808 | 1844 | - ``default``: the default behavior, local and remote bookmarks are "merged" |
|
1809 | 1845 | on push/pull. |
|
1810 | 1846 | |
|
1811 | 1847 | - ``mirror``: when pulling, replace local bookmarks by remote bookmarks. This |
|
1812 | 1848 | is useful to replicate a repository, or as an optimization. |
|
1813 | 1849 | |
|
1814 | 1850 | - ``ignore``: ignore bookmarks during exchange. |
|
1815 | 1851 | (This currently only affect pulling) |
|
1816 | 1852 | |
|
1817 | 1853 | The following special named paths exist: |
|
1818 | 1854 | |
|
1819 | 1855 | ``default`` |
|
1820 | 1856 | The URL or directory to use when no source or remote is specified. |
|
1821 | 1857 | |
|
1822 | 1858 | :hg:`clone` will automatically define this path to the location the |
|
1823 | 1859 | repository was cloned from. |
|
1824 | 1860 | |
|
1825 | 1861 | ``default-push`` |
|
1826 | 1862 | (deprecated) The URL or directory for the default :hg:`push` location. |
|
1827 | 1863 | ``default:pushurl`` should be used instead. |
|
1828 | 1864 | |
|
1829 | 1865 | ``phases`` |
|
1830 | 1866 | ---------- |
|
1831 | 1867 | |
|
1832 | 1868 | Specifies default handling of phases. See :hg:`help phases` for more |
|
1833 | 1869 | information about working with phases. |
|
1834 | 1870 | |
|
1835 | 1871 | ``publish`` |
|
1836 | 1872 | Controls draft phase behavior when working as a server. When true, |
|
1837 | 1873 | pushed changesets are set to public in both client and server and |
|
1838 | 1874 | pulled or cloned changesets are set to public in the client. |
|
1839 | 1875 | (default: True) |
|
1840 | 1876 | |
|
1841 | 1877 | ``new-commit`` |
|
1842 | 1878 | Phase of newly-created commits. |
|
1843 | 1879 | (default: draft) |
|
1844 | 1880 | |
|
1845 | 1881 | ``checksubrepos`` |
|
1846 | 1882 | Check the phase of the current revision of each subrepository. Allowed |
|
1847 | 1883 | values are "ignore", "follow" and "abort". For settings other than |
|
1848 | 1884 | "ignore", the phase of the current revision of each subrepository is |
|
1849 | 1885 | checked before committing the parent repository. If any of those phases is |
|
1850 | 1886 | greater than the phase of the parent repository (e.g. if a subrepo is in a |
|
1851 | 1887 | "secret" phase while the parent repo is in "draft" phase), the commit is |
|
1852 | 1888 | either aborted (if checksubrepos is set to "abort") or the higher phase is |
|
1853 | 1889 | used for the parent repository commit (if set to "follow"). |
|
1854 | 1890 | (default: follow) |
|
1855 | 1891 | |
|
1856 | 1892 | |
|
1857 | 1893 | ``profiling`` |
|
1858 | 1894 | ------------- |
|
1859 | 1895 | |
|
1860 | 1896 | Specifies profiling type, format, and file output. Two profilers are |
|
1861 | 1897 | supported: an instrumenting profiler (named ``ls``), and a sampling |
|
1862 | 1898 | profiler (named ``stat``). |
|
1863 | 1899 | |
|
1864 | 1900 | In this section description, 'profiling data' stands for the raw data |
|
1865 | 1901 | collected during profiling, while 'profiling report' stands for a |
|
1866 | 1902 | statistical text report generated from the profiling data. |
|
1867 | 1903 | |
|
1868 | 1904 | ``enabled`` |
|
1869 | 1905 | Enable the profiler. |
|
1870 | 1906 | (default: false) |
|
1871 | 1907 | |
|
1872 | 1908 | This is equivalent to passing ``--profile`` on the command line. |
|
1873 | 1909 | |
|
1874 | 1910 | ``type`` |
|
1875 | 1911 | The type of profiler to use. |
|
1876 | 1912 | (default: stat) |
|
1877 | 1913 | |
|
1878 | 1914 | ``ls`` |
|
1879 | 1915 | Use Python's built-in instrumenting profiler. This profiler |
|
1880 | 1916 | works on all platforms, but each line number it reports is the |
|
1881 | 1917 | first line of a function. This restriction makes it difficult to |
|
1882 | 1918 | identify the expensive parts of a non-trivial function. |
|
1883 | 1919 | ``stat`` |
|
1884 | 1920 | Use a statistical profiler, statprof. This profiler is most |
|
1885 | 1921 | useful for profiling commands that run for longer than about 0.1 |
|
1886 | 1922 | seconds. |
|
1887 | 1923 | |
|
1888 | 1924 | ``format`` |
|
1889 | 1925 | Profiling format. Specific to the ``ls`` instrumenting profiler. |
|
1890 | 1926 | (default: text) |
|
1891 | 1927 | |
|
1892 | 1928 | ``text`` |
|
1893 | 1929 | Generate a profiling report. When saving to a file, it should be |
|
1894 | 1930 | noted that only the report is saved, and the profiling data is |
|
1895 | 1931 | not kept. |
|
1896 | 1932 | ``kcachegrind`` |
|
1897 | 1933 | Format profiling data for kcachegrind use: when saving to a |
|
1898 | 1934 | file, the generated file can directly be loaded into |
|
1899 | 1935 | kcachegrind. |
|
1900 | 1936 | |
|
1901 | 1937 | ``statformat`` |
|
1902 | 1938 | Profiling format for the ``stat`` profiler. |
|
1903 | 1939 | (default: hotpath) |
|
1904 | 1940 | |
|
1905 | 1941 | ``hotpath`` |
|
1906 | 1942 | Show a tree-based display containing the hot path of execution (where |
|
1907 | 1943 | most time was spent). |
|
1908 | 1944 | ``bymethod`` |
|
1909 | 1945 | Show a table of methods ordered by how frequently they are active. |
|
1910 | 1946 | ``byline`` |
|
1911 | 1947 | Show a table of lines in files ordered by how frequently they are active. |
|
1912 | 1948 | ``json`` |
|
1913 | 1949 | Render profiling data as JSON. |
|
1914 | 1950 | |
|
1915 | 1951 | ``freq`` |
|
1916 | 1952 | Sampling frequency. Specific to the ``stat`` sampling profiler. |
|
1917 | 1953 | (default: 1000) |
|
1918 | 1954 | |
|
1919 | 1955 | ``output`` |
|
1920 | 1956 | File path where profiling data or report should be saved. If the |
|
1921 | 1957 | file exists, it is replaced. (default: None, data is printed on |
|
1922 | 1958 | stderr) |
|
1923 | 1959 | |
|
1924 | 1960 | ``sort`` |
|
1925 | 1961 | Sort field. Specific to the ``ls`` instrumenting profiler. |
|
1926 | 1962 | One of ``callcount``, ``reccallcount``, ``totaltime`` and |
|
1927 | 1963 | ``inlinetime``. |
|
1928 | 1964 | (default: inlinetime) |
|
1929 | 1965 | |
|
1930 | 1966 | ``time-track`` |
|
1931 | 1967 | Control if the stat profiler track ``cpu`` or ``real`` time. |
|
1932 | 1968 | (default: ``cpu`` on Windows, otherwise ``real``) |
|
1933 | 1969 | |
|
1934 | 1970 | ``limit`` |
|
1935 | 1971 | Number of lines to show. Specific to the ``ls`` instrumenting profiler. |
|
1936 | 1972 | (default: 30) |
|
1937 | 1973 | |
|
1938 | 1974 | ``nested`` |
|
1939 | 1975 | Show at most this number of lines of drill-down info after each main entry. |
|
1940 | 1976 | This can help explain the difference between Total and Inline. |
|
1941 | 1977 | Specific to the ``ls`` instrumenting profiler. |
|
1942 | 1978 | (default: 0) |
|
1943 | 1979 | |
|
1944 | 1980 | ``showmin`` |
|
1945 | 1981 | Minimum fraction of samples an entry must have for it to be displayed. |
|
1946 | 1982 | Can be specified as a float between ``0.0`` and ``1.0`` or can have a |
|
1947 | 1983 | ``%`` afterwards to allow values up to ``100``. e.g. ``5%``. |
|
1948 | 1984 | |
|
1949 | 1985 | Only used by the ``stat`` profiler. |
|
1950 | 1986 | |
|
1951 | 1987 | For the ``hotpath`` format, default is ``0.05``. |
|
1952 | 1988 | For the ``chrome`` format, default is ``0.005``. |
|
1953 | 1989 | |
|
1954 | 1990 | The option is unused on other formats. |
|
1955 | 1991 | |
|
1956 | 1992 | ``showmax`` |
|
1957 | 1993 | Maximum fraction of samples an entry can have before it is ignored in |
|
1958 | 1994 | display. Values format is the same as ``showmin``. |
|
1959 | 1995 | |
|
1960 | 1996 | Only used by the ``stat`` profiler. |
|
1961 | 1997 | |
|
1962 | 1998 | For the ``chrome`` format, default is ``0.999``. |
|
1963 | 1999 | |
|
1964 | 2000 | The option is unused on other formats. |
|
1965 | 2001 | |
|
1966 | 2002 | ``showtime`` |
|
1967 | 2003 | Show time taken as absolute durations, in addition to percentages. |
|
1968 | 2004 | Only used by the ``hotpath`` format. |
|
1969 | 2005 | (default: true) |
|
1970 | 2006 | |
|
1971 | 2007 | ``progress`` |
|
1972 | 2008 | ------------ |
|
1973 | 2009 | |
|
1974 | 2010 | Mercurial commands can draw progress bars that are as informative as |
|
1975 | 2011 | possible. Some progress bars only offer indeterminate information, while others |
|
1976 | 2012 | have a definite end point. |
|
1977 | 2013 | |
|
1978 | 2014 | ``debug`` |
|
1979 | 2015 | Whether to print debug info when updating the progress bar. (default: False) |
|
1980 | 2016 | |
|
1981 | 2017 | ``delay`` |
|
1982 | 2018 | Number of seconds (float) before showing the progress bar. (default: 3) |
|
1983 | 2019 | |
|
1984 | 2020 | ``changedelay`` |
|
1985 | 2021 | Minimum delay before showing a new topic. When set to less than 3 * refresh, |
|
1986 | 2022 | that value will be used instead. (default: 1) |
|
1987 | 2023 | |
|
1988 | 2024 | ``estimateinterval`` |
|
1989 | 2025 | Maximum sampling interval in seconds for speed and estimated time |
|
1990 | 2026 | calculation. (default: 60) |
|
1991 | 2027 | |
|
1992 | 2028 | ``refresh`` |
|
1993 | 2029 | Time in seconds between refreshes of the progress bar. (default: 0.1) |
|
1994 | 2030 | |
|
1995 | 2031 | ``format`` |
|
1996 | 2032 | Format of the progress bar. |
|
1997 | 2033 | |
|
1998 | 2034 | Valid entries for the format field are ``topic``, ``bar``, ``number``, |
|
1999 | 2035 | ``unit``, ``estimate``, ``speed``, and ``item``. ``item`` defaults to the |
|
2000 | 2036 | last 20 characters of the item, but this can be changed by adding either |
|
2001 | 2037 | ``-<num>`` which would take the last num characters, or ``+<num>`` for the |
|
2002 | 2038 | first num characters. |
|
2003 | 2039 | |
|
2004 | 2040 | (default: topic bar number estimate) |
|
2005 | 2041 | |
|
2006 | 2042 | ``width`` |
|
2007 | 2043 | If set, the maximum width of the progress information (that is, min(width, |
|
2008 | 2044 | term width) will be used). |
|
2009 | 2045 | |
|
2010 | 2046 | ``clear-complete`` |
|
2011 | 2047 | Clear the progress bar after it's done. (default: True) |
|
2012 | 2048 | |
|
2013 | 2049 | ``disable`` |
|
2014 | 2050 | If true, don't show a progress bar. |
|
2015 | 2051 | |
|
2016 | 2052 | ``assume-tty`` |
|
2017 | 2053 | If true, ALWAYS show a progress bar, unless disable is given. |
|
2018 | 2054 | |
|
2019 | 2055 | ``rebase`` |
|
2020 | 2056 | ---------- |
|
2021 | 2057 | |
|
2022 | 2058 | ``evolution.allowdivergence`` |
|
2023 | 2059 | Default to False, when True allow creating divergence when performing |
|
2024 | 2060 | rebase of obsolete changesets. |
|
2025 | 2061 | |
|
2026 | 2062 | ``revsetalias`` |
|
2027 | 2063 | --------------- |
|
2028 | 2064 | |
|
2029 | 2065 | Alias definitions for revsets. See :hg:`help revsets` for details. |
|
2030 | 2066 | |
|
2031 | 2067 | ``rewrite`` |
|
2032 | 2068 | ----------- |
|
2033 | 2069 | |
|
2034 | 2070 | ``backup-bundle`` |
|
2035 | 2071 | Whether to save stripped changesets to a bundle file. (default: True) |
|
2036 | 2072 | |
|
2037 | 2073 | ``update-timestamp`` |
|
2038 | 2074 | If true, updates the date and time of the changeset to current. It is only |
|
2039 | 2075 | applicable for `hg amend`, `hg commit --amend` and `hg uncommit` in the |
|
2040 | 2076 | current version. |
|
2041 | 2077 | |
|
2042 | 2078 | ``empty-successor`` |
|
2043 | 2079 | |
|
2044 | 2080 | Control what happens with empty successors that are the result of rewrite |
|
2045 | 2081 | operations. If set to ``skip``, the successor is not created. If set to |
|
2046 | 2082 | ``keep``, the empty successor is created and kept. |
|
2047 | 2083 | |
|
2048 | 2084 | Currently, only the rebase and absorb commands consider this configuration. |
|
2049 | 2085 | (EXPERIMENTAL) |
|
2050 | 2086 | |
|
2051 | 2087 | ``share`` |
|
2052 | 2088 | --------- |
|
2053 | 2089 | |
|
2054 | 2090 | ``safe-mismatch.source-safe`` |
|
2055 | 2091 | |
|
2056 | 2092 | Controls what happens when the shared repository does not use the |
|
2057 | 2093 | share-safe mechanism but its source repository does. |
|
2058 | 2094 | |
|
2059 | 2095 | Possible values are `abort` (default), `allow`, `upgrade-abort` and |
|
2060 | 2096 | `upgrade-abort`. |
|
2061 | 2097 | |
|
2062 | 2098 | ``abort`` |
|
2063 | 2099 | Disallows running any command and aborts |
|
2064 | 2100 | ``allow`` |
|
2065 | 2101 | Respects the feature presence in the share source |
|
2066 | 2102 | ``upgrade-abort`` |
|
2067 | 2103 | tries to upgrade the share to use share-safe; if it fails, aborts |
|
2068 | 2104 | ``upgrade-allow`` |
|
2069 | 2105 | tries to upgrade the share; if it fails, continue by |
|
2070 | 2106 | respecting the share source setting |
|
2071 | 2107 | |
|
2072 | 2108 | Check :hg:`help config format.use-share-safe` for details about the |
|
2073 | 2109 | share-safe feature. |
|
2074 | 2110 | |
|
2075 | 2111 | ``safe-mismatch.source-safe.warn`` |
|
2076 | 2112 | Shows a warning on operations if the shared repository does not use |
|
2077 | 2113 | share-safe, but the source repository does. |
|
2078 | 2114 | (default: True) |
|
2079 | 2115 | |
|
2080 | 2116 | ``safe-mismatch.source-not-safe`` |
|
2081 | 2117 | |
|
2082 | 2118 | Controls what happens when the shared repository uses the share-safe |
|
2083 | 2119 | mechanism but its source does not. |
|
2084 | 2120 | |
|
2085 | 2121 | Possible values are `abort` (default), `allow`, `downgrade-abort` and |
|
2086 | 2122 | `downgrade-abort`. |
|
2087 | 2123 | |
|
2088 | 2124 | ``abort`` |
|
2089 | 2125 | Disallows running any command and aborts |
|
2090 | 2126 | ``allow`` |
|
2091 | 2127 | Respects the feature presence in the share source |
|
2092 | 2128 | ``downgrade-abort`` |
|
2093 | 2129 | tries to downgrade the share to not use share-safe; if it fails, aborts |
|
2094 | 2130 | ``downgrade-allow`` |
|
2095 | 2131 | tries to downgrade the share to not use share-safe; |
|
2096 | 2132 | if it fails, continue by respecting the shared source setting |
|
2097 | 2133 | |
|
2098 | 2134 | Check :hg:`help config format.use-share-safe` for details about the |
|
2099 | 2135 | share-safe feature. |
|
2100 | 2136 | |
|
2101 | 2137 | ``safe-mismatch.source-not-safe.warn`` |
|
2102 | 2138 | Shows a warning on operations if the shared repository uses share-safe, |
|
2103 | 2139 | but the source repository does not. |
|
2104 | 2140 | (default: True) |
|
2105 | 2141 | |
|
2106 | 2142 | ``storage`` |
|
2107 | 2143 | ----------- |
|
2108 | 2144 | |
|
2109 | 2145 | Control the strategy Mercurial uses internally to store history. Options in this |
|
2110 | 2146 | category impact performance and repository size. |
|
2111 | 2147 | |
|
2112 | 2148 | ``revlog.issue6528.fix-incoming`` |
|
2113 | 2149 | Version 5.8 of Mercurial had a bug leading to altering the parent of file |
|
2114 | 2150 | revision with copy information (or any other metadata) on exchange. This |
|
2115 | 2151 | leads to the copy metadata to be overlooked by various internal logic. The |
|
2116 | 2152 | issue was fixed in Mercurial 5.8.1. |
|
2117 | 2153 | (See https://bz.mercurial-scm.org/show_bug.cgi?id=6528 for details) |
|
2118 | 2154 | |
|
2119 | 2155 | As a result Mercurial is now checking and fixing incoming file revisions to |
|
2120 | 2156 | make sure there parents are in the right order. This behavior can be |
|
2121 | 2157 | disabled by setting this option to `no`. This apply to revisions added |
|
2122 | 2158 | through push, pull, clone and unbundle. |
|
2123 | 2159 | |
|
2124 | 2160 | To fix affected revisions that already exist within the repository, one can |
|
2125 | 2161 | use :hg:`debug-repair-issue-6528`. |
|
2126 | 2162 | |
|
2127 | 2163 | ``revlog.optimize-delta-parent-choice`` |
|
2128 | 2164 | When storing a merge revision, both parents will be equally considered as |
|
2129 | 2165 | a possible delta base. This results in better delta selection and improved |
|
2130 | 2166 | revlog compression. This option is enabled by default. |
|
2131 | 2167 | |
|
2132 | 2168 | Turning this option off can result in large increase of repository size for |
|
2133 | 2169 | repository with many merges. |
|
2134 | 2170 | |
|
2135 | 2171 | ``revlog.persistent-nodemap.mmap`` |
|
2136 | 2172 | Whether to use the Operating System "memory mapping" feature (when |
|
2137 | 2173 | possible) to access the persistent nodemap data. This improve performance |
|
2138 | 2174 | and reduce memory pressure. |
|
2139 | 2175 | |
|
2140 | 2176 | Default to True. |
|
2141 | 2177 | |
|
2142 | 2178 | For details on the "persistent-nodemap" feature, see: |
|
2143 | 2179 | :hg:`help config format.use-persistent-nodemap`. |
|
2144 | 2180 | |
|
2145 | 2181 | ``revlog.persistent-nodemap.slow-path`` |
|
2146 | 2182 | Control the behavior of Merucrial when using a repository with "persistent" |
|
2147 | 2183 | nodemap with an installation of Mercurial without a fast implementation for |
|
2148 | 2184 | the feature: |
|
2149 | 2185 | |
|
2150 | 2186 | ``allow``: Silently use the slower implementation to access the repository. |
|
2151 | 2187 | ``warn``: Warn, but use the slower implementation to access the repository. |
|
2152 | 2188 | ``abort``: Prevent access to such repositories. (This is the default) |
|
2153 | 2189 | |
|
2154 | 2190 | For details on the "persistent-nodemap" feature, see: |
|
2155 | 2191 | :hg:`help config format.use-persistent-nodemap`. |
|
2156 | 2192 | |
|
2157 | 2193 | ``revlog.reuse-external-delta-parent`` |
|
2158 | 2194 | Control the order in which delta parents are considered when adding new |
|
2159 | 2195 | revisions from an external source. |
|
2160 | 2196 | (typically: apply bundle from `hg pull` or `hg push`). |
|
2161 | 2197 | |
|
2162 | 2198 | New revisions are usually provided as a delta against other revisions. By |
|
2163 | 2199 | default, Mercurial will try to reuse this delta first, therefore using the |
|
2164 | 2200 | same "delta parent" as the source. Directly using delta's from the source |
|
2165 | 2201 | reduces CPU usage and usually speeds up operation. However, in some case, |
|
2166 | 2202 | the source might have sub-optimal delta bases and forcing their reevaluation |
|
2167 | 2203 | is useful. For example, pushes from an old client could have sub-optimal |
|
2168 | 2204 | delta's parent that the server want to optimize. (lack of general delta, bad |
|
2169 | 2205 | parents, choice, lack of sparse-revlog, etc). |
|
2170 | 2206 | |
|
2171 | 2207 | This option is enabled by default. Turning it off will ensure bad delta |
|
2172 | 2208 | parent choices from older client do not propagate to this repository, at |
|
2173 | 2209 | the cost of a small increase in CPU consumption. |
|
2174 | 2210 | |
|
2175 | 2211 | Note: this option only control the order in which delta parents are |
|
2176 | 2212 | considered. Even when disabled, the existing delta from the source will be |
|
2177 | 2213 | reused if the same delta parent is selected. |
|
2178 | 2214 | |
|
2179 | 2215 | ``revlog.reuse-external-delta`` |
|
2180 | 2216 | Control the reuse of delta from external source. |
|
2181 | 2217 | (typically: apply bundle from `hg pull` or `hg push`). |
|
2182 | 2218 | |
|
2183 | 2219 | New revisions are usually provided as a delta against another revision. By |
|
2184 | 2220 | default, Mercurial will not recompute the same delta again, trusting |
|
2185 | 2221 | externally provided deltas. There have been rare cases of small adjustment |
|
2186 | 2222 | to the diffing algorithm in the past. So in some rare case, recomputing |
|
2187 | 2223 | delta provided by ancient clients can provides better results. Disabling |
|
2188 | 2224 | this option means going through a full delta recomputation for all incoming |
|
2189 | 2225 | revisions. It means a large increase in CPU usage and will slow operations |
|
2190 | 2226 | down. |
|
2191 | 2227 | |
|
2192 | 2228 | This option is enabled by default. When disabled, it also disables the |
|
2193 | 2229 | related ``storage.revlog.reuse-external-delta-parent`` option. |
|
2194 | 2230 | |
|
2195 | 2231 | ``revlog.zlib.level`` |
|
2196 | 2232 | Zlib compression level used when storing data into the repository. Accepted |
|
2197 | 2233 | Value range from 1 (lowest compression) to 9 (highest compression). Zlib |
|
2198 | 2234 | default value is 6. |
|
2199 | 2235 | |
|
2200 | 2236 | |
|
2201 | 2237 | ``revlog.zstd.level`` |
|
2202 | 2238 | zstd compression level used when storing data into the repository. Accepted |
|
2203 | 2239 | Value range from 1 (lowest compression) to 22 (highest compression). |
|
2204 | 2240 | (default 3) |
|
2205 | 2241 | |
|
2206 | 2242 | ``server`` |
|
2207 | 2243 | ---------- |
|
2208 | 2244 | |
|
2209 | 2245 | Controls generic server settings. |
|
2210 | 2246 | |
|
2211 | 2247 | ``bookmarks-pushkey-compat`` |
|
2212 | 2248 | Trigger pushkey hook when being pushed bookmark updates. This config exist |
|
2213 | 2249 | for compatibility purpose (default to True) |
|
2214 | 2250 | |
|
2215 | 2251 | If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark |
|
2216 | 2252 | movement we recommend you migrate them to ``txnclose-bookmark`` and |
|
2217 | 2253 | ``pretxnclose-bookmark``. |
|
2218 | 2254 | |
|
2219 | 2255 | ``compressionengines`` |
|
2220 | 2256 | List of compression engines and their relative priority to advertise |
|
2221 | 2257 | to clients. |
|
2222 | 2258 | |
|
2223 | 2259 | The order of compression engines determines their priority, the first |
|
2224 | 2260 | having the highest priority. If a compression engine is not listed |
|
2225 | 2261 | here, it won't be advertised to clients. |
|
2226 | 2262 | |
|
2227 | 2263 | If not set (the default), built-in defaults are used. Run |
|
2228 | 2264 | :hg:`debuginstall` to list available compression engines and their |
|
2229 | 2265 | default wire protocol priority. |
|
2230 | 2266 | |
|
2231 | 2267 | Older Mercurial clients only support zlib compression and this setting |
|
2232 | 2268 | has no effect for legacy clients. |
|
2233 | 2269 | |
|
2234 | 2270 | ``uncompressed`` |
|
2235 | 2271 | Whether to allow clients to clone a repository using the |
|
2236 | 2272 | uncompressed streaming protocol. This transfers about 40% more |
|
2237 | 2273 | data than a regular clone, but uses less memory and CPU on both |
|
2238 | 2274 | server and client. Over a LAN (100 Mbps or better) or a very fast |
|
2239 | 2275 | WAN, an uncompressed streaming clone is a lot faster (~10x) than a |
|
2240 | 2276 | regular clone. Over most WAN connections (anything slower than |
|
2241 | 2277 | about 6 Mbps), uncompressed streaming is slower, because of the |
|
2242 | 2278 | extra data transfer overhead. This mode will also temporarily hold |
|
2243 | 2279 | the write lock while determining what data to transfer. |
|
2244 | 2280 | (default: True) |
|
2245 | 2281 | |
|
2246 | 2282 | ``uncompressedallowsecret`` |
|
2247 | 2283 | Whether to allow stream clones when the repository contains secret |
|
2248 | 2284 | changesets. (default: False) |
|
2249 | 2285 | |
|
2250 | 2286 | ``preferuncompressed`` |
|
2251 | 2287 | When set, clients will try to use the uncompressed streaming |
|
2252 | 2288 | protocol. (default: False) |
|
2253 | 2289 | |
|
2254 | 2290 | ``disablefullbundle`` |
|
2255 | 2291 | When set, servers will refuse attempts to do pull-based clones. |
|
2256 | 2292 | If this option is set, ``preferuncompressed`` and/or clone bundles |
|
2257 | 2293 | are highly recommended. Partial clones will still be allowed. |
|
2258 | 2294 | (default: False) |
|
2259 | 2295 | |
|
2260 | 2296 | ``streamunbundle`` |
|
2261 | 2297 | When set, servers will apply data sent from the client directly, |
|
2262 | 2298 | otherwise it will be written to a temporary file first. This option |
|
2263 | 2299 | effectively prevents concurrent pushes. |
|
2264 | 2300 | |
|
2265 | 2301 | ``pullbundle`` |
|
2266 | 2302 | When set, the server will check pullbundle.manifest for bundles |
|
2267 | 2303 | covering the requested heads and common nodes. The first matching |
|
2268 | 2304 | entry will be streamed to the client. |
|
2269 | 2305 | |
|
2270 | 2306 | For HTTP transport, the stream will still use zlib compression |
|
2271 | 2307 | for older clients. |
|
2272 | 2308 | |
|
2273 | 2309 | ``concurrent-push-mode`` |
|
2274 | 2310 | Level of allowed race condition between two pushing clients. |
|
2275 | 2311 | |
|
2276 | 2312 | - 'strict': push is abort if another client touched the repository |
|
2277 | 2313 | while the push was preparing. |
|
2278 | 2314 | - 'check-related': push is only aborted if it affects head that got also |
|
2279 | 2315 | affected while the push was preparing. (default since 5.4) |
|
2280 | 2316 | |
|
2281 | 2317 | 'check-related' only takes effect for compatible clients (version |
|
2282 | 2318 | 4.3 and later). Older clients will use 'strict'. |
|
2283 | 2319 | |
|
2284 | 2320 | ``validate`` |
|
2285 | 2321 | Whether to validate the completeness of pushed changesets by |
|
2286 | 2322 | checking that all new file revisions specified in manifests are |
|
2287 | 2323 | present. (default: False) |
|
2288 | 2324 | |
|
2289 | 2325 | ``maxhttpheaderlen`` |
|
2290 | 2326 | Instruct HTTP clients not to send request headers longer than this |
|
2291 | 2327 | many bytes. (default: 1024) |
|
2292 | 2328 | |
|
2293 | 2329 | ``bundle1`` |
|
2294 | 2330 | Whether to allow clients to push and pull using the legacy bundle1 |
|
2295 | 2331 | exchange format. (default: True) |
|
2296 | 2332 | |
|
2297 | 2333 | ``bundle1gd`` |
|
2298 | 2334 | Like ``bundle1`` but only used if the repository is using the |
|
2299 | 2335 | *generaldelta* storage format. (default: True) |
|
2300 | 2336 | |
|
2301 | 2337 | ``bundle1.push`` |
|
2302 | 2338 | Whether to allow clients to push using the legacy bundle1 exchange |
|
2303 | 2339 | format. (default: True) |
|
2304 | 2340 | |
|
2305 | 2341 | ``bundle1gd.push`` |
|
2306 | 2342 | Like ``bundle1.push`` but only used if the repository is using the |
|
2307 | 2343 | *generaldelta* storage format. (default: True) |
|
2308 | 2344 | |
|
2309 | 2345 | ``bundle1.pull`` |
|
2310 | 2346 | Whether to allow clients to pull using the legacy bundle1 exchange |
|
2311 | 2347 | format. (default: True) |
|
2312 | 2348 | |
|
2313 | 2349 | ``bundle1gd.pull`` |
|
2314 | 2350 | Like ``bundle1.pull`` but only used if the repository is using the |
|
2315 | 2351 | *generaldelta* storage format. (default: True) |
|
2316 | 2352 | |
|
2317 | 2353 | Large repositories using the *generaldelta* storage format should |
|
2318 | 2354 | consider setting this option because converting *generaldelta* |
|
2319 | 2355 | repositories to the exchange format required by the bundle1 data |
|
2320 | 2356 | format can consume a lot of CPU. |
|
2321 | 2357 | |
|
2322 | 2358 | ``bundle2.stream`` |
|
2323 | 2359 | Whether to allow clients to pull using the bundle2 streaming protocol. |
|
2324 | 2360 | (default: True) |
|
2325 | 2361 | |
|
2326 | 2362 | ``zliblevel`` |
|
2327 | 2363 | Integer between ``-1`` and ``9`` that controls the zlib compression level |
|
2328 | 2364 | for wire protocol commands that send zlib compressed output (notably the |
|
2329 | 2365 | commands that send repository history data). |
|
2330 | 2366 | |
|
2331 | 2367 | The default (``-1``) uses the default zlib compression level, which is |
|
2332 | 2368 | likely equivalent to ``6``. ``0`` means no compression. ``9`` means |
|
2333 | 2369 | maximum compression. |
|
2334 | 2370 | |
|
2335 | 2371 | Setting this option allows server operators to make trade-offs between |
|
2336 | 2372 | bandwidth and CPU used. Lowering the compression lowers CPU utilization |
|
2337 | 2373 | but sends more bytes to clients. |
|
2338 | 2374 | |
|
2339 | 2375 | This option only impacts the HTTP server. |
|
2340 | 2376 | |
|
2341 | 2377 | ``zstdlevel`` |
|
2342 | 2378 | Integer between ``1`` and ``22`` that controls the zstd compression level |
|
2343 | 2379 | for wire protocol commands. ``1`` is the minimal amount of compression and |
|
2344 | 2380 | ``22`` is the highest amount of compression. |
|
2345 | 2381 | |
|
2346 | 2382 | The default (``3``) should be significantly faster than zlib while likely |
|
2347 | 2383 | delivering better compression ratios. |
|
2348 | 2384 | |
|
2349 | 2385 | This option only impacts the HTTP server. |
|
2350 | 2386 | |
|
2351 | 2387 | See also ``server.zliblevel``. |
|
2352 | 2388 | |
|
2353 | 2389 | ``view`` |
|
2354 | 2390 | Repository filter used when exchanging revisions with the peer. |
|
2355 | 2391 | |
|
2356 | 2392 | The default view (``served``) excludes secret and hidden changesets. |
|
2357 | 2393 | Another useful value is ``immutable`` (no draft, secret or hidden |
|
2358 | 2394 | changesets). (EXPERIMENTAL) |
|
2359 | 2395 | |
|
2360 | 2396 | ``smtp`` |
|
2361 | 2397 | -------- |
|
2362 | 2398 | |
|
2363 | 2399 | Configuration for extensions that need to send email messages. |
|
2364 | 2400 | |
|
2365 | 2401 | ``host`` |
|
2366 | 2402 | Host name of mail server, e.g. "mail.example.com". |
|
2367 | 2403 | |
|
2368 | 2404 | ``port`` |
|
2369 | 2405 | Optional. Port to connect to on mail server. (default: 465 if |
|
2370 | 2406 | ``tls`` is smtps; 25 otherwise) |
|
2371 | 2407 | |
|
2372 | 2408 | ``tls`` |
|
2373 | 2409 | Optional. Method to enable TLS when connecting to mail server: starttls, |
|
2374 | 2410 | smtps or none. (default: none) |
|
2375 | 2411 | |
|
2376 | 2412 | ``username`` |
|
2377 | 2413 | Optional. User name for authenticating with the SMTP server. |
|
2378 | 2414 | (default: None) |
|
2379 | 2415 | |
|
2380 | 2416 | ``password`` |
|
2381 | 2417 | Optional. Password for authenticating with the SMTP server. If not |
|
2382 | 2418 | specified, interactive sessions will prompt the user for a |
|
2383 | 2419 | password; non-interactive sessions will fail. (default: None) |
|
2384 | 2420 | |
|
2385 | 2421 | ``local_hostname`` |
|
2386 | 2422 | Optional. The hostname that the sender can use to identify |
|
2387 | 2423 | itself to the MTA. |
|
2388 | 2424 | |
|
2389 | 2425 | |
|
2390 | 2426 | ``subpaths`` |
|
2391 | 2427 | ------------ |
|
2392 | 2428 | |
|
2393 | 2429 | Subrepository source URLs can go stale if a remote server changes name |
|
2394 | 2430 | or becomes temporarily unavailable. This section lets you define |
|
2395 | 2431 | rewrite rules of the form:: |
|
2396 | 2432 | |
|
2397 | 2433 | <pattern> = <replacement> |
|
2398 | 2434 | |
|
2399 | 2435 | where ``pattern`` is a regular expression matching a subrepository |
|
2400 | 2436 | source URL and ``replacement`` is the replacement string used to |
|
2401 | 2437 | rewrite it. Groups can be matched in ``pattern`` and referenced in |
|
2402 | 2438 | ``replacements``. For instance:: |
|
2403 | 2439 | |
|
2404 | 2440 | http://server/(.*)-hg/ = http://hg.server/\1/ |
|
2405 | 2441 | |
|
2406 | 2442 | rewrites ``http://server/foo-hg/`` into ``http://hg.server/foo/``. |
|
2407 | 2443 | |
|
2408 | 2444 | Relative subrepository paths are first made absolute, and the |
|
2409 | 2445 | rewrite rules are then applied on the full (absolute) path. If ``pattern`` |
|
2410 | 2446 | doesn't match the full path, an attempt is made to apply it on the |
|
2411 | 2447 | relative path alone. The rules are applied in definition order. |
|
2412 | 2448 | |
|
2413 | 2449 | ``subrepos`` |
|
2414 | 2450 | ------------ |
|
2415 | 2451 | |
|
2416 | 2452 | This section contains options that control the behavior of the |
|
2417 | 2453 | subrepositories feature. See also :hg:`help subrepos`. |
|
2418 | 2454 | |
|
2419 | 2455 | Security note: auditing in Mercurial is known to be insufficient to |
|
2420 | 2456 | prevent clone-time code execution with carefully constructed Git |
|
2421 | 2457 | subrepos. It is unknown if a similar detect is present in Subversion |
|
2422 | 2458 | subrepos. Both Git and Subversion subrepos are disabled by default |
|
2423 | 2459 | out of security concerns. These subrepo types can be enabled using |
|
2424 | 2460 | the respective options below. |
|
2425 | 2461 | |
|
2426 | 2462 | ``allowed`` |
|
2427 | 2463 | Whether subrepositories are allowed in the working directory. |
|
2428 | 2464 | |
|
2429 | 2465 | When false, commands involving subrepositories (like :hg:`update`) |
|
2430 | 2466 | will fail for all subrepository types. |
|
2431 | 2467 | (default: true) |
|
2432 | 2468 | |
|
2433 | 2469 | ``hg:allowed`` |
|
2434 | 2470 | Whether Mercurial subrepositories are allowed in the working |
|
2435 | 2471 | directory. This option only has an effect if ``subrepos.allowed`` |
|
2436 | 2472 | is true. |
|
2437 | 2473 | (default: true) |
|
2438 | 2474 | |
|
2439 | 2475 | ``git:allowed`` |
|
2440 | 2476 | Whether Git subrepositories are allowed in the working directory. |
|
2441 | 2477 | This option only has an effect if ``subrepos.allowed`` is true. |
|
2442 | 2478 | |
|
2443 | 2479 | See the security note above before enabling Git subrepos. |
|
2444 | 2480 | (default: false) |
|
2445 | 2481 | |
|
2446 | 2482 | ``svn:allowed`` |
|
2447 | 2483 | Whether Subversion subrepositories are allowed in the working |
|
2448 | 2484 | directory. This option only has an effect if ``subrepos.allowed`` |
|
2449 | 2485 | is true. |
|
2450 | 2486 | |
|
2451 | 2487 | See the security note above before enabling Subversion subrepos. |
|
2452 | 2488 | (default: false) |
|
2453 | 2489 | |
|
2454 | 2490 | ``templatealias`` |
|
2455 | 2491 | ----------------- |
|
2456 | 2492 | |
|
2457 | 2493 | Alias definitions for templates. See :hg:`help templates` for details. |
|
2458 | 2494 | |
|
2459 | 2495 | ``templates`` |
|
2460 | 2496 | ------------- |
|
2461 | 2497 | |
|
2462 | 2498 | Use the ``[templates]`` section to define template strings. |
|
2463 | 2499 | See :hg:`help templates` for details. |
|
2464 | 2500 | |
|
2465 | 2501 | ``trusted`` |
|
2466 | 2502 | ----------- |
|
2467 | 2503 | |
|
2468 | 2504 | Mercurial will not use the settings in the |
|
2469 | 2505 | ``.hg/hgrc`` file from a repository if it doesn't belong to a trusted |
|
2470 | 2506 | user or to a trusted group, as various hgrc features allow arbitrary |
|
2471 | 2507 | commands to be run. This issue is often encountered when configuring |
|
2472 | 2508 | hooks or extensions for shared repositories or servers. However, |
|
2473 | 2509 | the web interface will use some safe settings from the ``[web]`` |
|
2474 | 2510 | section. |
|
2475 | 2511 | |
|
2476 | 2512 | This section specifies what users and groups are trusted. The |
|
2477 | 2513 | current user is always trusted. To trust everybody, list a user or a |
|
2478 | 2514 | group with name ``*``. These settings must be placed in an |
|
2479 | 2515 | *already-trusted file* to take effect, such as ``$HOME/.hgrc`` of the |
|
2480 | 2516 | user or service running Mercurial. |
|
2481 | 2517 | |
|
2482 | 2518 | ``users`` |
|
2483 | 2519 | Comma-separated list of trusted users. |
|
2484 | 2520 | |
|
2485 | 2521 | ``groups`` |
|
2486 | 2522 | Comma-separated list of trusted groups. |
|
2487 | 2523 | |
|
2488 | 2524 | |
|
2489 | 2525 | ``ui`` |
|
2490 | 2526 | ------ |
|
2491 | 2527 | |
|
2492 | 2528 | User interface controls. |
|
2493 | 2529 | |
|
2494 | 2530 | ``archivemeta`` |
|
2495 | 2531 | Whether to include the .hg_archival.txt file containing meta data |
|
2496 | 2532 | (hashes for the repository base and for tip) in archives created |
|
2497 | 2533 | by the :hg:`archive` command or downloaded via hgweb. |
|
2498 | 2534 | (default: True) |
|
2499 | 2535 | |
|
2500 | 2536 | ``askusername`` |
|
2501 | 2537 | Whether to prompt for a username when committing. If True, and |
|
2502 | 2538 | neither ``$HGUSER`` nor ``$EMAIL`` has been specified, then the user will |
|
2503 | 2539 | be prompted to enter a username. If no username is entered, the |
|
2504 | 2540 | default ``USER@HOST`` is used instead. |
|
2505 | 2541 | (default: False) |
|
2506 | 2542 | |
|
2507 | 2543 | ``clonebundles`` |
|
2508 | 2544 | Whether the "clone bundles" feature is enabled. |
|
2509 | 2545 | |
|
2510 | 2546 | When enabled, :hg:`clone` may download and apply a server-advertised |
|
2511 | 2547 | bundle file from a URL instead of using the normal exchange mechanism. |
|
2512 | 2548 | |
|
2513 | 2549 | This can likely result in faster and more reliable clones. |
|
2514 | 2550 | |
|
2515 | 2551 | (default: True) |
|
2516 | 2552 | |
|
2517 | 2553 | ``clonebundlefallback`` |
|
2518 | 2554 | Whether failure to apply an advertised "clone bundle" from a server |
|
2519 | 2555 | should result in fallback to a regular clone. |
|
2520 | 2556 | |
|
2521 | 2557 | This is disabled by default because servers advertising "clone |
|
2522 | 2558 | bundles" often do so to reduce server load. If advertised bundles |
|
2523 | 2559 | start mass failing and clients automatically fall back to a regular |
|
2524 | 2560 | clone, this would add significant and unexpected load to the server |
|
2525 | 2561 | since the server is expecting clone operations to be offloaded to |
|
2526 | 2562 | pre-generated bundles. Failing fast (the default behavior) ensures |
|
2527 | 2563 | clients don't overwhelm the server when "clone bundle" application |
|
2528 | 2564 | fails. |
|
2529 | 2565 | |
|
2530 | 2566 | (default: False) |
|
2531 | 2567 | |
|
2532 | 2568 | ``clonebundleprefers`` |
|
2533 | 2569 | Defines preferences for which "clone bundles" to use. |
|
2534 | 2570 | |
|
2535 | 2571 | Servers advertising "clone bundles" may advertise multiple available |
|
2536 | 2572 | bundles. Each bundle may have different attributes, such as the bundle |
|
2537 | 2573 | type and compression format. This option is used to prefer a particular |
|
2538 | 2574 | bundle over another. |
|
2539 | 2575 | |
|
2540 | 2576 | The following keys are defined by Mercurial: |
|
2541 | 2577 | |
|
2542 | 2578 | BUNDLESPEC |
|
2543 | 2579 | A bundle type specifier. These are strings passed to :hg:`bundle -t`. |
|
2544 | 2580 | e.g. ``gzip-v2`` or ``bzip2-v1``. |
|
2545 | 2581 | |
|
2546 | 2582 | COMPRESSION |
|
2547 | 2583 | The compression format of the bundle. e.g. ``gzip`` and ``bzip2``. |
|
2548 | 2584 | |
|
2549 | 2585 | Server operators may define custom keys. |
|
2550 | 2586 | |
|
2551 | 2587 | Example values: ``COMPRESSION=bzip2``, |
|
2552 | 2588 | ``BUNDLESPEC=gzip-v2, COMPRESSION=gzip``. |
|
2553 | 2589 | |
|
2554 | 2590 | By default, the first bundle advertised by the server is used. |
|
2555 | 2591 | |
|
2556 | 2592 | ``color`` |
|
2557 | 2593 | When to colorize output. Possible value are Boolean ("yes" or "no"), or |
|
2558 | 2594 | "debug", or "always". (default: "yes"). "yes" will use color whenever it |
|
2559 | 2595 | seems possible. See :hg:`help color` for details. |
|
2560 | 2596 | |
|
2561 | 2597 | ``commitsubrepos`` |
|
2562 | 2598 | Whether to commit modified subrepositories when committing the |
|
2563 | 2599 | parent repository. If False and one subrepository has uncommitted |
|
2564 | 2600 | changes, abort the commit. |
|
2565 | 2601 | (default: False) |
|
2566 | 2602 | |
|
2567 | 2603 | ``debug`` |
|
2568 | 2604 | Print debugging information. (default: False) |
|
2569 | 2605 | |
|
2570 | 2606 | ``editor`` |
|
2571 | 2607 | The editor to use during a commit. (default: ``$EDITOR`` or ``vi``) |
|
2572 | 2608 | |
|
2573 | 2609 | ``fallbackencoding`` |
|
2574 | 2610 | Encoding to try if it's not possible to decode the changelog using |
|
2575 | 2611 | UTF-8. (default: ISO-8859-1) |
|
2576 | 2612 | |
|
2577 | 2613 | ``graphnodetemplate`` |
|
2578 | 2614 | (DEPRECATED) Use ``command-templates.graphnode`` instead. |
|
2579 | 2615 | |
|
2580 | 2616 | ``ignore`` |
|
2581 | 2617 | A file to read per-user ignore patterns from. This file should be |
|
2582 | 2618 | in the same format as a repository-wide .hgignore file. Filenames |
|
2583 | 2619 | are relative to the repository root. This option supports hook syntax, |
|
2584 | 2620 | so if you want to specify multiple ignore files, you can do so by |
|
2585 | 2621 | setting something like ``ignore.other = ~/.hgignore2``. For details |
|
2586 | 2622 | of the ignore file format, see the ``hgignore(5)`` man page. |
|
2587 | 2623 | |
|
2588 | 2624 | ``interactive`` |
|
2589 | 2625 | Allow to prompt the user. (default: True) |
|
2590 | 2626 | |
|
2591 | 2627 | ``interface`` |
|
2592 | 2628 | Select the default interface for interactive features (default: text). |
|
2593 | 2629 | Possible values are 'text' and 'curses'. |
|
2594 | 2630 | |
|
2595 | 2631 | ``interface.chunkselector`` |
|
2596 | 2632 | Select the interface for change recording (e.g. :hg:`commit -i`). |
|
2597 | 2633 | Possible values are 'text' and 'curses'. |
|
2598 | 2634 | This config overrides the interface specified by ui.interface. |
|
2599 | 2635 | |
|
2600 | 2636 | ``large-file-limit`` |
|
2601 | 2637 | Largest file size that gives no memory use warning. |
|
2602 | 2638 | Possible values are integers or 0 to disable the check. |
|
2603 | 2639 | (default: 10000000) |
|
2604 | 2640 | |
|
2605 | 2641 | ``logtemplate`` |
|
2606 | 2642 | (DEPRECATED) Use ``command-templates.log`` instead. |
|
2607 | 2643 | |
|
2608 | 2644 | ``merge`` |
|
2609 | 2645 | The conflict resolution program to use during a manual merge. |
|
2610 | 2646 | For more information on merge tools see :hg:`help merge-tools`. |
|
2611 | 2647 | For configuring merge tools see the ``[merge-tools]`` section. |
|
2612 | 2648 | |
|
2613 | 2649 | ``mergemarkers`` |
|
2614 | 2650 | Sets the merge conflict marker label styling. The ``detailed`` style |
|
2615 | 2651 | uses the ``command-templates.mergemarker`` setting to style the labels. |
|
2616 | 2652 | The ``basic`` style just uses 'local' and 'other' as the marker label. |
|
2617 | 2653 | One of ``basic`` or ``detailed``. |
|
2618 | 2654 | (default: ``basic``) |
|
2619 | 2655 | |
|
2620 | 2656 | ``mergemarkertemplate`` |
|
2621 | 2657 | (DEPRECATED) Use ``command-templates.mergemarker`` instead. |
|
2622 | 2658 | |
|
2623 | 2659 | ``message-output`` |
|
2624 | 2660 | Where to write status and error messages. (default: ``stdio``) |
|
2625 | 2661 | |
|
2626 | 2662 | ``channel`` |
|
2627 | 2663 | Use separate channel for structured output. (Command-server only) |
|
2628 | 2664 | ``stderr`` |
|
2629 | 2665 | Everything to stderr. |
|
2630 | 2666 | ``stdio`` |
|
2631 | 2667 | Status to stdout, and error to stderr. |
|
2632 | 2668 | |
|
2633 | 2669 | ``origbackuppath`` |
|
2634 | 2670 | The path to a directory used to store generated .orig files. If the path is |
|
2635 | 2671 | not a directory, one will be created. If set, files stored in this |
|
2636 | 2672 | directory have the same name as the original file and do not have a .orig |
|
2637 | 2673 | suffix. |
|
2638 | 2674 | |
|
2639 | 2675 | ``paginate`` |
|
2640 | 2676 | Control the pagination of command output (default: True). See :hg:`help pager` |
|
2641 | 2677 | for details. |
|
2642 | 2678 | |
|
2643 | 2679 | ``patch`` |
|
2644 | 2680 | An optional external tool that ``hg import`` and some extensions |
|
2645 | 2681 | will use for applying patches. By default Mercurial uses an |
|
2646 | 2682 | internal patch utility. The external tool must work as the common |
|
2647 | 2683 | Unix ``patch`` program. In particular, it must accept a ``-p`` |
|
2648 | 2684 | argument to strip patch headers, a ``-d`` argument to specify the |
|
2649 | 2685 | current directory, a file name to patch, and a patch file to take |
|
2650 | 2686 | from stdin. |
|
2651 | 2687 | |
|
2652 | 2688 | It is possible to specify a patch tool together with extra |
|
2653 | 2689 | arguments. For example, setting this option to ``patch --merge`` |
|
2654 | 2690 | will use the ``patch`` program with its 2-way merge option. |
|
2655 | 2691 | |
|
2656 | 2692 | ``portablefilenames`` |
|
2657 | 2693 | Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``. |
|
2658 | 2694 | (default: ``warn``) |
|
2659 | 2695 | |
|
2660 | 2696 | ``warn`` |
|
2661 | 2697 | Print a warning message on POSIX platforms, if a file with a non-portable |
|
2662 | 2698 | filename is added (e.g. a file with a name that can't be created on |
|
2663 | 2699 | Windows because it contains reserved parts like ``AUX``, reserved |
|
2664 | 2700 | characters like ``:``, or would cause a case collision with an existing |
|
2665 | 2701 | file). |
|
2666 | 2702 | |
|
2667 | 2703 | ``ignore`` |
|
2668 | 2704 | Don't print a warning. |
|
2669 | 2705 | |
|
2670 | 2706 | ``abort`` |
|
2671 | 2707 | The command is aborted. |
|
2672 | 2708 | |
|
2673 | 2709 | ``true`` |
|
2674 | 2710 | Alias for ``warn``. |
|
2675 | 2711 | |
|
2676 | 2712 | ``false`` |
|
2677 | 2713 | Alias for ``ignore``. |
|
2678 | 2714 | |
|
2679 | 2715 | .. container:: windows |
|
2680 | 2716 | |
|
2681 | 2717 | On Windows, this configuration option is ignored and the command aborted. |
|
2682 | 2718 | |
|
2683 | 2719 | ``pre-merge-tool-output-template`` |
|
2684 | 2720 | (DEPRECATED) Use ``command-template.pre-merge-tool-output`` instead. |
|
2685 | 2721 | |
|
2686 | 2722 | ``quiet`` |
|
2687 | 2723 | Reduce the amount of output printed. |
|
2688 | 2724 | (default: False) |
|
2689 | 2725 | |
|
2690 | 2726 | ``relative-paths`` |
|
2691 | 2727 | Prefer relative paths in the UI. |
|
2692 | 2728 | |
|
2693 | 2729 | ``remotecmd`` |
|
2694 | 2730 | Remote command to use for clone/push/pull operations. |
|
2695 | 2731 | (default: ``hg``) |
|
2696 | 2732 | |
|
2697 | 2733 | ``report_untrusted`` |
|
2698 | 2734 | Warn if a ``.hg/hgrc`` file is ignored due to not being owned by a |
|
2699 | 2735 | trusted user or group. |
|
2700 | 2736 | (default: True) |
|
2701 | 2737 | |
|
2702 | 2738 | ``slash`` |
|
2703 | 2739 | (Deprecated. Use ``slashpath`` template filter instead.) |
|
2704 | 2740 | |
|
2705 | 2741 | Display paths using a slash (``/``) as the path separator. This |
|
2706 | 2742 | only makes a difference on systems where the default path |
|
2707 | 2743 | separator is not the slash character (e.g. Windows uses the |
|
2708 | 2744 | backslash character (``\``)). |
|
2709 | 2745 | (default: False) |
|
2710 | 2746 | |
|
2711 | 2747 | ``statuscopies`` |
|
2712 | 2748 | Display copies in the status command. |
|
2713 | 2749 | |
|
2714 | 2750 | ``ssh`` |
|
2715 | 2751 | Command to use for SSH connections. (default: ``ssh``) |
|
2716 | 2752 | |
|
2717 | 2753 | ``ssherrorhint`` |
|
2718 | 2754 | A hint shown to the user in the case of SSH error (e.g. |
|
2719 | 2755 | ``Please see http://company/internalwiki/ssh.html``) |
|
2720 | 2756 | |
|
2721 | 2757 | ``strict`` |
|
2722 | 2758 | Require exact command names, instead of allowing unambiguous |
|
2723 | 2759 | abbreviations. (default: False) |
|
2724 | 2760 | |
|
2725 | 2761 | ``style`` |
|
2726 | 2762 | Name of style to use for command output. |
|
2727 | 2763 | |
|
2728 | 2764 | ``supportcontact`` |
|
2729 | 2765 | A URL where users should report a Mercurial traceback. Use this if you are a |
|
2730 | 2766 | large organisation with its own Mercurial deployment process and crash |
|
2731 | 2767 | reports should be addressed to your internal support. |
|
2732 | 2768 | |
|
2733 | 2769 | ``textwidth`` |
|
2734 | 2770 | Maximum width of help text. A longer line generated by ``hg help`` or |
|
2735 | 2771 | ``hg subcommand --help`` will be broken after white space to get this |
|
2736 | 2772 | width or the terminal width, whichever comes first. |
|
2737 | 2773 | A non-positive value will disable this and the terminal width will be |
|
2738 | 2774 | used. (default: 78) |
|
2739 | 2775 | |
|
2740 | 2776 | ``timeout`` |
|
2741 | 2777 | The timeout used when a lock is held (in seconds), a negative value |
|
2742 | 2778 | means no timeout. (default: 600) |
|
2743 | 2779 | |
|
2744 | 2780 | ``timeout.warn`` |
|
2745 | 2781 | Time (in seconds) before a warning is printed about held lock. A negative |
|
2746 | 2782 | value means no warning. (default: 0) |
|
2747 | 2783 | |
|
2748 | 2784 | ``traceback`` |
|
2749 | 2785 | Mercurial always prints a traceback when an unknown exception |
|
2750 | 2786 | occurs. Setting this to True will make Mercurial print a traceback |
|
2751 | 2787 | on all exceptions, even those recognized by Mercurial (such as |
|
2752 | 2788 | IOError or MemoryError). (default: False) |
|
2753 | 2789 | |
|
2754 | 2790 | ``tweakdefaults`` |
|
2755 | 2791 | |
|
2756 | 2792 | By default Mercurial's behavior changes very little from release |
|
2757 | 2793 | to release, but over time the recommended config settings |
|
2758 | 2794 | shift. Enable this config to opt in to get automatic tweaks to |
|
2759 | 2795 | Mercurial's behavior over time. This config setting will have no |
|
2760 | 2796 | effect if ``HGPLAIN`` is set or ``HGPLAINEXCEPT`` is set and does |
|
2761 | 2797 | not include ``tweakdefaults``. (default: False) |
|
2762 | 2798 | |
|
2763 | 2799 | It currently means:: |
|
2764 | 2800 | |
|
2765 | 2801 | .. tweakdefaultsmarker |
|
2766 | 2802 | |
|
2767 | 2803 | ``username`` |
|
2768 | 2804 | The committer of a changeset created when running "commit". |
|
2769 | 2805 | Typically a person's name and email address, e.g. ``Fred Widget |
|
2770 | 2806 | <fred@example.com>``. Environment variables in the |
|
2771 | 2807 | username are expanded. |
|
2772 | 2808 | |
|
2773 | 2809 | (default: ``$EMAIL`` or ``username@hostname``. If the username in |
|
2774 | 2810 | hgrc is empty, e.g. if the system admin set ``username =`` in the |
|
2775 | 2811 | system hgrc, it has to be specified manually or in a different |
|
2776 | 2812 | hgrc file) |
|
2777 | 2813 | |
|
2778 | 2814 | ``verbose`` |
|
2779 | 2815 | Increase the amount of output printed. (default: False) |
|
2780 | 2816 | |
|
2781 | 2817 | |
|
2782 | 2818 | ``command-templates`` |
|
2783 | 2819 | --------------------- |
|
2784 | 2820 | |
|
2785 | 2821 | Templates used for customizing the output of commands. |
|
2786 | 2822 | |
|
2787 | 2823 | ``graphnode`` |
|
2788 | 2824 | The template used to print changeset nodes in an ASCII revision graph. |
|
2789 | 2825 | (default: ``{graphnode}``) |
|
2790 | 2826 | |
|
2791 | 2827 | ``log`` |
|
2792 | 2828 | Template string for commands that print changesets. |
|
2793 | 2829 | |
|
2794 | 2830 | ``mergemarker`` |
|
2795 | 2831 | The template used to print the commit description next to each conflict |
|
2796 | 2832 | marker during merge conflicts. See :hg:`help templates` for the template |
|
2797 | 2833 | format. |
|
2798 | 2834 | |
|
2799 | 2835 | Defaults to showing the hash, tags, branches, bookmarks, author, and |
|
2800 | 2836 | the first line of the commit description. |
|
2801 | 2837 | |
|
2802 | 2838 | If you use non-ASCII characters in names for tags, branches, bookmarks, |
|
2803 | 2839 | authors, and/or commit descriptions, you must pay attention to encodings of |
|
2804 | 2840 | managed files. At template expansion, non-ASCII characters use the encoding |
|
2805 | 2841 | specified by the ``--encoding`` global option, ``HGENCODING`` or other |
|
2806 | 2842 | environment variables that govern your locale. If the encoding of the merge |
|
2807 | 2843 | markers is different from the encoding of the merged files, |
|
2808 | 2844 | serious problems may occur. |
|
2809 | 2845 | |
|
2810 | 2846 | Can be overridden per-merge-tool, see the ``[merge-tools]`` section. |
|
2811 | 2847 | |
|
2812 | 2848 | ``oneline-summary`` |
|
2813 | 2849 | A template used by `hg rebase` and other commands for showing a one-line |
|
2814 | 2850 | summary of a commit. If the template configured here is longer than one |
|
2815 | 2851 | line, then only the first line is used. |
|
2816 | 2852 | |
|
2817 | 2853 | The template can be overridden per command by defining a template in |
|
2818 | 2854 | `oneline-summary.<command>`, where `<command>` can be e.g. "rebase". |
|
2819 | 2855 | |
|
2820 | 2856 | ``pre-merge-tool-output`` |
|
2821 | 2857 | A template that is printed before executing an external merge tool. This can |
|
2822 | 2858 | be used to print out additional context that might be useful to have during |
|
2823 | 2859 | the conflict resolution, such as the description of the various commits |
|
2824 | 2860 | involved or bookmarks/tags. |
|
2825 | 2861 | |
|
2826 | 2862 | Additional information is available in the ``local`, ``base``, and ``other`` |
|
2827 | 2863 | dicts. For example: ``{local.label}``, ``{base.name}``, or |
|
2828 | 2864 | ``{other.islink}``. |
|
2829 | 2865 | |
|
2830 | 2866 | |
|
2831 | 2867 | ``web`` |
|
2832 | 2868 | ------- |
|
2833 | 2869 | |
|
2834 | 2870 | Web interface configuration. The settings in this section apply to |
|
2835 | 2871 | both the builtin webserver (started by :hg:`serve`) and the script you |
|
2836 | 2872 | run through a webserver (``hgweb.cgi`` and the derivatives for FastCGI |
|
2837 | 2873 | and WSGI). |
|
2838 | 2874 | |
|
2839 | 2875 | The Mercurial webserver does no authentication (it does not prompt for |
|
2840 | 2876 | usernames and passwords to validate *who* users are), but it does do |
|
2841 | 2877 | authorization (it grants or denies access for *authenticated users* |
|
2842 | 2878 | based on settings in this section). You must either configure your |
|
2843 | 2879 | webserver to do authentication for you, or disable the authorization |
|
2844 | 2880 | checks. |
|
2845 | 2881 | |
|
2846 | 2882 | For a quick setup in a trusted environment, e.g., a private LAN, where |
|
2847 | 2883 | you want it to accept pushes from anybody, you can use the following |
|
2848 | 2884 | command line:: |
|
2849 | 2885 | |
|
2850 | 2886 | $ hg --config web.allow-push=* --config web.push_ssl=False serve |
|
2851 | 2887 | |
|
2852 | 2888 | Note that this will allow anybody to push anything to the server and |
|
2853 | 2889 | that this should not be used for public servers. |
|
2854 | 2890 | |
|
2855 | 2891 | The full set of options is: |
|
2856 | 2892 | |
|
2857 | 2893 | ``accesslog`` |
|
2858 | 2894 | Where to output the access log. (default: stdout) |
|
2859 | 2895 | |
|
2860 | 2896 | ``address`` |
|
2861 | 2897 | Interface address to bind to. (default: all) |
|
2862 | 2898 | |
|
2863 | 2899 | ``allow-archive`` |
|
2864 | 2900 | List of archive format (bz2, gz, zip) allowed for downloading. |
|
2865 | 2901 | (default: empty) |
|
2866 | 2902 | |
|
2867 | 2903 | ``allowbz2`` |
|
2868 | 2904 | (DEPRECATED) Whether to allow .tar.bz2 downloading of repository |
|
2869 | 2905 | revisions. |
|
2870 | 2906 | (default: False) |
|
2871 | 2907 | |
|
2872 | 2908 | ``allowgz`` |
|
2873 | 2909 | (DEPRECATED) Whether to allow .tar.gz downloading of repository |
|
2874 | 2910 | revisions. |
|
2875 | 2911 | (default: False) |
|
2876 | 2912 | |
|
2877 | 2913 | ``allow-pull`` |
|
2878 | 2914 | Whether to allow pulling from the repository. (default: True) |
|
2879 | 2915 | |
|
2880 | 2916 | ``allow-push`` |
|
2881 | 2917 | Whether to allow pushing to the repository. If empty or not set, |
|
2882 | 2918 | pushing is not allowed. If the special value ``*``, any remote |
|
2883 | 2919 | user can push, including unauthenticated users. Otherwise, the |
|
2884 | 2920 | remote user must have been authenticated, and the authenticated |
|
2885 | 2921 | user name must be present in this list. The contents of the |
|
2886 | 2922 | allow-push list are examined after the deny_push list. |
|
2887 | 2923 | |
|
2888 | 2924 | ``allow_read`` |
|
2889 | 2925 | If the user has not already been denied repository access due to |
|
2890 | 2926 | the contents of deny_read, this list determines whether to grant |
|
2891 | 2927 | repository access to the user. If this list is not empty, and the |
|
2892 | 2928 | user is unauthenticated or not present in the list, then access is |
|
2893 | 2929 | denied for the user. If the list is empty or not set, then access |
|
2894 | 2930 | is permitted to all users by default. Setting allow_read to the |
|
2895 | 2931 | special value ``*`` is equivalent to it not being set (i.e. access |
|
2896 | 2932 | is permitted to all users). The contents of the allow_read list are |
|
2897 | 2933 | examined after the deny_read list. |
|
2898 | 2934 | |
|
2899 | 2935 | ``allowzip`` |
|
2900 | 2936 | (DEPRECATED) Whether to allow .zip downloading of repository |
|
2901 | 2937 | revisions. This feature creates temporary files. |
|
2902 | 2938 | (default: False) |
|
2903 | 2939 | |
|
2904 | 2940 | ``archivesubrepos`` |
|
2905 | 2941 | Whether to recurse into subrepositories when archiving. |
|
2906 | 2942 | (default: False) |
|
2907 | 2943 | |
|
2908 | 2944 | ``baseurl`` |
|
2909 | 2945 | Base URL to use when publishing URLs in other locations, so |
|
2910 | 2946 | third-party tools like email notification hooks can construct |
|
2911 | 2947 | URLs. Example: ``http://hgserver/repos/``. |
|
2912 | 2948 | |
|
2913 | 2949 | ``cacerts`` |
|
2914 | 2950 | Path to file containing a list of PEM encoded certificate |
|
2915 | 2951 | authority certificates. Environment variables and ``~user`` |
|
2916 | 2952 | constructs are expanded in the filename. If specified on the |
|
2917 | 2953 | client, then it will verify the identity of remote HTTPS servers |
|
2918 | 2954 | with these certificates. |
|
2919 | 2955 | |
|
2920 | 2956 | To disable SSL verification temporarily, specify ``--insecure`` from |
|
2921 | 2957 | command line. |
|
2922 | 2958 | |
|
2923 | 2959 | You can use OpenSSL's CA certificate file if your platform has |
|
2924 | 2960 | one. On most Linux systems this will be |
|
2925 | 2961 | ``/etc/ssl/certs/ca-certificates.crt``. Otherwise you will have to |
|
2926 | 2962 | generate this file manually. The form must be as follows:: |
|
2927 | 2963 | |
|
2928 | 2964 | -----BEGIN CERTIFICATE----- |
|
2929 | 2965 | ... (certificate in base64 PEM encoding) ... |
|
2930 | 2966 | -----END CERTIFICATE----- |
|
2931 | 2967 | -----BEGIN CERTIFICATE----- |
|
2932 | 2968 | ... (certificate in base64 PEM encoding) ... |
|
2933 | 2969 | -----END CERTIFICATE----- |
|
2934 | 2970 | |
|
2935 | 2971 | ``cache`` |
|
2936 | 2972 | Whether to support caching in hgweb. (default: True) |
|
2937 | 2973 | |
|
2938 | 2974 | ``certificate`` |
|
2939 | 2975 | Certificate to use when running :hg:`serve`. |
|
2940 | 2976 | |
|
2941 | 2977 | ``collapse`` |
|
2942 | 2978 | With ``descend`` enabled, repositories in subdirectories are shown at |
|
2943 | 2979 | a single level alongside repositories in the current path. With |
|
2944 | 2980 | ``collapse`` also enabled, repositories residing at a deeper level than |
|
2945 | 2981 | the current path are grouped behind navigable directory entries that |
|
2946 | 2982 | lead to the locations of these repositories. In effect, this setting |
|
2947 | 2983 | collapses each collection of repositories found within a subdirectory |
|
2948 | 2984 | into a single entry for that subdirectory. (default: False) |
|
2949 | 2985 | |
|
2950 | 2986 | ``comparisoncontext`` |
|
2951 | 2987 | Number of lines of context to show in side-by-side file comparison. If |
|
2952 | 2988 | negative or the value ``full``, whole files are shown. (default: 5) |
|
2953 | 2989 | |
|
2954 | 2990 | This setting can be overridden by a ``context`` request parameter to the |
|
2955 | 2991 | ``comparison`` command, taking the same values. |
|
2956 | 2992 | |
|
2957 | 2993 | ``contact`` |
|
2958 | 2994 | Name or email address of the person in charge of the repository. |
|
2959 | 2995 | (default: ui.username or ``$EMAIL`` or "unknown" if unset or empty) |
|
2960 | 2996 | |
|
2961 | 2997 | ``csp`` |
|
2962 | 2998 | Send a ``Content-Security-Policy`` HTTP header with this value. |
|
2963 | 2999 | |
|
2964 | 3000 | The value may contain a special string ``%nonce%``, which will be replaced |
|
2965 | 3001 | by a randomly-generated one-time use value. If the value contains |
|
2966 | 3002 | ``%nonce%``, ``web.cache`` will be disabled, as caching undermines the |
|
2967 | 3003 | one-time property of the nonce. This nonce will also be inserted into |
|
2968 | 3004 | ``<script>`` elements containing inline JavaScript. |
|
2969 | 3005 | |
|
2970 | 3006 | Note: lots of HTML content sent by the server is derived from repository |
|
2971 | 3007 | data. Please consider the potential for malicious repository data to |
|
2972 | 3008 | "inject" itself into generated HTML content as part of your security |
|
2973 | 3009 | threat model. |
|
2974 | 3010 | |
|
2975 | 3011 | ``deny_push`` |
|
2976 | 3012 | Whether to deny pushing to the repository. If empty or not set, |
|
2977 | 3013 | push is not denied. If the special value ``*``, all remote users are |
|
2978 | 3014 | denied push. Otherwise, unauthenticated users are all denied, and |
|
2979 | 3015 | any authenticated user name present in this list is also denied. The |
|
2980 | 3016 | contents of the deny_push list are examined before the allow-push list. |
|
2981 | 3017 | |
|
2982 | 3018 | ``deny_read`` |
|
2983 | 3019 | Whether to deny reading/viewing of the repository. If this list is |
|
2984 | 3020 | not empty, unauthenticated users are all denied, and any |
|
2985 | 3021 | authenticated user name present in this list is also denied access to |
|
2986 | 3022 | the repository. If set to the special value ``*``, all remote users |
|
2987 | 3023 | are denied access (rarely needed ;). If deny_read is empty or not set, |
|
2988 | 3024 | the determination of repository access depends on the presence and |
|
2989 | 3025 | content of the allow_read list (see description). If both |
|
2990 | 3026 | deny_read and allow_read are empty or not set, then access is |
|
2991 | 3027 | permitted to all users by default. If the repository is being |
|
2992 | 3028 | served via hgwebdir, denied users will not be able to see it in |
|
2993 | 3029 | the list of repositories. The contents of the deny_read list have |
|
2994 | 3030 | priority over (are examined before) the contents of the allow_read |
|
2995 | 3031 | list. |
|
2996 | 3032 | |
|
2997 | 3033 | ``descend`` |
|
2998 | 3034 | hgwebdir indexes will not descend into subdirectories. Only repositories |
|
2999 | 3035 | directly in the current path will be shown (other repositories are still |
|
3000 | 3036 | available from the index corresponding to their containing path). |
|
3001 | 3037 | |
|
3002 | 3038 | ``description`` |
|
3003 | 3039 | Textual description of the repository's purpose or contents. |
|
3004 | 3040 | (default: "unknown") |
|
3005 | 3041 | |
|
3006 | 3042 | ``encoding`` |
|
3007 | 3043 | Character encoding name. (default: the current locale charset) |
|
3008 | 3044 | Example: "UTF-8". |
|
3009 | 3045 | |
|
3010 | 3046 | ``errorlog`` |
|
3011 | 3047 | Where to output the error log. (default: stderr) |
|
3012 | 3048 | |
|
3013 | 3049 | ``guessmime`` |
|
3014 | 3050 | Control MIME types for raw download of file content. |
|
3015 | 3051 | Set to True to let hgweb guess the content type from the file |
|
3016 | 3052 | extension. This will serve HTML files as ``text/html`` and might |
|
3017 | 3053 | allow cross-site scripting attacks when serving untrusted |
|
3018 | 3054 | repositories. (default: False) |
|
3019 | 3055 | |
|
3020 | 3056 | ``hidden`` |
|
3021 | 3057 | Whether to hide the repository in the hgwebdir index. |
|
3022 | 3058 | (default: False) |
|
3023 | 3059 | |
|
3024 | 3060 | ``ipv6`` |
|
3025 | 3061 | Whether to use IPv6. (default: False) |
|
3026 | 3062 | |
|
3027 | 3063 | ``labels`` |
|
3028 | 3064 | List of string *labels* associated with the repository. |
|
3029 | 3065 | |
|
3030 | 3066 | Labels are exposed as a template keyword and can be used to customize |
|
3031 | 3067 | output. e.g. the ``index`` template can group or filter repositories |
|
3032 | 3068 | by labels and the ``summary`` template can display additional content |
|
3033 | 3069 | if a specific label is present. |
|
3034 | 3070 | |
|
3035 | 3071 | ``logoimg`` |
|
3036 | 3072 | File name of the logo image that some templates display on each page. |
|
3037 | 3073 | The file name is relative to ``staticurl``. That is, the full path to |
|
3038 | 3074 | the logo image is "staticurl/logoimg". |
|
3039 | 3075 | If unset, ``hglogo.png`` will be used. |
|
3040 | 3076 | |
|
3041 | 3077 | ``logourl`` |
|
3042 | 3078 | Base URL to use for logos. If unset, ``https://mercurial-scm.org/`` |
|
3043 | 3079 | will be used. |
|
3044 | 3080 | |
|
3045 | 3081 | ``maxchanges`` |
|
3046 | 3082 | Maximum number of changes to list on the changelog. (default: 10) |
|
3047 | 3083 | |
|
3048 | 3084 | ``maxfiles`` |
|
3049 | 3085 | Maximum number of files to list per changeset. (default: 10) |
|
3050 | 3086 | |
|
3051 | 3087 | ``maxshortchanges`` |
|
3052 | 3088 | Maximum number of changes to list on the shortlog, graph or filelog |
|
3053 | 3089 | pages. (default: 60) |
|
3054 | 3090 | |
|
3055 | 3091 | ``name`` |
|
3056 | 3092 | Repository name to use in the web interface. |
|
3057 | 3093 | (default: current working directory) |
|
3058 | 3094 | |
|
3059 | 3095 | ``port`` |
|
3060 | 3096 | Port to listen on. (default: 8000) |
|
3061 | 3097 | |
|
3062 | 3098 | ``prefix`` |
|
3063 | 3099 | Prefix path to serve from. (default: '' (server root)) |
|
3064 | 3100 | |
|
3065 | 3101 | ``push_ssl`` |
|
3066 | 3102 | Whether to require that inbound pushes be transported over SSL to |
|
3067 | 3103 | prevent password sniffing. (default: True) |
|
3068 | 3104 | |
|
3069 | 3105 | ``refreshinterval`` |
|
3070 | 3106 | How frequently directory listings re-scan the filesystem for new |
|
3071 | 3107 | repositories, in seconds. This is relevant when wildcards are used |
|
3072 | 3108 | to define paths. Depending on how much filesystem traversal is |
|
3073 | 3109 | required, refreshing may negatively impact performance. |
|
3074 | 3110 | |
|
3075 | 3111 | Values less than or equal to 0 always refresh. |
|
3076 | 3112 | (default: 20) |
|
3077 | 3113 | |
|
3078 | 3114 | ``server-header`` |
|
3079 | 3115 | Value for HTTP ``Server`` response header. |
|
3080 | 3116 | |
|
3081 | 3117 | ``static`` |
|
3082 | 3118 | Directory where static files are served from. |
|
3083 | 3119 | |
|
3084 | 3120 | ``staticurl`` |
|
3085 | 3121 | Base URL to use for static files. If unset, static files (e.g. the |
|
3086 | 3122 | hgicon.png favicon) will be served by the CGI script itself. Use |
|
3087 | 3123 | this setting to serve them directly with the HTTP server. |
|
3088 | 3124 | Example: ``http://hgserver/static/``. |
|
3089 | 3125 | |
|
3090 | 3126 | ``stripes`` |
|
3091 | 3127 | How many lines a "zebra stripe" should span in multi-line output. |
|
3092 | 3128 | Set to 0 to disable. (default: 1) |
|
3093 | 3129 | |
|
3094 | 3130 | ``style`` |
|
3095 | 3131 | Which template map style to use. The available options are the names of |
|
3096 | 3132 | subdirectories in the HTML templates path. (default: ``paper``) |
|
3097 | 3133 | Example: ``monoblue``. |
|
3098 | 3134 | |
|
3099 | 3135 | ``templates`` |
|
3100 | 3136 | Where to find the HTML templates. The default path to the HTML templates |
|
3101 | 3137 | can be obtained from ``hg debuginstall``. |
|
3102 | 3138 | |
|
3103 | 3139 | ``websub`` |
|
3104 | 3140 | ---------- |
|
3105 | 3141 | |
|
3106 | 3142 | Web substitution filter definition. You can use this section to |
|
3107 | 3143 | define a set of regular expression substitution patterns which |
|
3108 | 3144 | let you automatically modify the hgweb server output. |
|
3109 | 3145 | |
|
3110 | 3146 | The default hgweb templates only apply these substitution patterns |
|
3111 | 3147 | on the revision description fields. You can apply them anywhere |
|
3112 | 3148 | you want when you create your own templates by adding calls to the |
|
3113 | 3149 | "websub" filter (usually after calling the "escape" filter). |
|
3114 | 3150 | |
|
3115 | 3151 | This can be used, for example, to convert issue references to links |
|
3116 | 3152 | to your issue tracker, or to convert "markdown-like" syntax into |
|
3117 | 3153 | HTML (see the examples below). |
|
3118 | 3154 | |
|
3119 | 3155 | Each entry in this section names a substitution filter. |
|
3120 | 3156 | The value of each entry defines the substitution expression itself. |
|
3121 | 3157 | The websub expressions follow the old interhg extension syntax, |
|
3122 | 3158 | which in turn imitates the Unix sed replacement syntax:: |
|
3123 | 3159 | |
|
3124 | 3160 | patternname = s/SEARCH_REGEX/REPLACE_EXPRESSION/[i] |
|
3125 | 3161 | |
|
3126 | 3162 | You can use any separator other than "/". The final "i" is optional |
|
3127 | 3163 | and indicates that the search must be case insensitive. |
|
3128 | 3164 | |
|
3129 | 3165 | Examples:: |
|
3130 | 3166 | |
|
3131 | 3167 | [websub] |
|
3132 | 3168 | issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i |
|
3133 | 3169 | italic = s/\b_(\S+)_\b/<i>\1<\/i>/ |
|
3134 | 3170 | bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/ |
|
3135 | 3171 | |
|
3136 | 3172 | ``worker`` |
|
3137 | 3173 | ---------- |
|
3138 | 3174 | |
|
3139 | 3175 | Parallel master/worker configuration. We currently perform working |
|
3140 | 3176 | directory updates in parallel on Unix-like systems, which greatly |
|
3141 | 3177 | helps performance. |
|
3142 | 3178 | |
|
3143 | 3179 | ``enabled`` |
|
3144 | 3180 | Whether to enable workers code to be used. |
|
3145 | 3181 | (default: true) |
|
3146 | 3182 | |
|
3147 | 3183 | ``numcpus`` |
|
3148 | 3184 | Number of CPUs to use for parallel operations. A zero or |
|
3149 | 3185 | negative value is treated as ``use the default``. |
|
3150 | 3186 | (default: 4 or the number of CPUs on the system, whichever is larger) |
|
3151 | 3187 | |
|
3152 | 3188 | ``backgroundclose`` |
|
3153 | 3189 | Whether to enable closing file handles on background threads during certain |
|
3154 | 3190 | operations. Some platforms aren't very efficient at closing file |
|
3155 | 3191 | handles that have been written or appended to. By performing file closing |
|
3156 | 3192 | on background threads, file write rate can increase substantially. |
|
3157 | 3193 | (default: true on Windows, false elsewhere) |
|
3158 | 3194 | |
|
3159 | 3195 | ``backgroundcloseminfilecount`` |
|
3160 | 3196 | Minimum number of files required to trigger background file closing. |
|
3161 | 3197 | Operations not writing this many files won't start background close |
|
3162 | 3198 | threads. |
|
3163 | 3199 | (default: 2048) |
|
3164 | 3200 | |
|
3165 | 3201 | ``backgroundclosemaxqueue`` |
|
3166 | 3202 | The maximum number of opened file handles waiting to be closed in the |
|
3167 | 3203 | background. This option only has an effect if ``backgroundclose`` is |
|
3168 | 3204 | enabled. |
|
3169 | 3205 | (default: 384) |
|
3170 | 3206 | |
|
3171 | 3207 | ``backgroundclosethreadcount`` |
|
3172 | 3208 | Number of threads to process background file closes. Only relevant if |
|
3173 | 3209 | ``backgroundclose`` is enabled. |
|
3174 | 3210 | (default: 4) |
@@ -1,3917 +1,3932 b'' | |||
|
1 | 1 | # localrepo.py - read/write repository class for mercurial |
|
2 | 2 | # coding: utf-8 |
|
3 | 3 | # |
|
4 | 4 | # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> |
|
5 | 5 | # |
|
6 | 6 | # This software may be used and distributed according to the terms of the |
|
7 | 7 | # GNU General Public License version 2 or any later version. |
|
8 | 8 | |
|
9 | 9 | from __future__ import absolute_import |
|
10 | 10 | |
|
11 | 11 | import errno |
|
12 | 12 | import functools |
|
13 | 13 | import os |
|
14 | 14 | import random |
|
15 | 15 | import sys |
|
16 | 16 | import time |
|
17 | 17 | import weakref |
|
18 | 18 | |
|
19 | 19 | from .i18n import _ |
|
20 | 20 | from .node import ( |
|
21 | 21 | bin, |
|
22 | 22 | hex, |
|
23 | 23 | nullrev, |
|
24 | 24 | sha1nodeconstants, |
|
25 | 25 | short, |
|
26 | 26 | ) |
|
27 | 27 | from .pycompat import ( |
|
28 | 28 | delattr, |
|
29 | 29 | getattr, |
|
30 | 30 | ) |
|
31 | 31 | from . import ( |
|
32 | 32 | bookmarks, |
|
33 | 33 | branchmap, |
|
34 | 34 | bundle2, |
|
35 | 35 | bundlecaches, |
|
36 | 36 | changegroup, |
|
37 | 37 | color, |
|
38 | 38 | commit, |
|
39 | 39 | context, |
|
40 | 40 | dirstate, |
|
41 | 41 | dirstateguard, |
|
42 | 42 | discovery, |
|
43 | 43 | encoding, |
|
44 | 44 | error, |
|
45 | 45 | exchange, |
|
46 | 46 | extensions, |
|
47 | 47 | filelog, |
|
48 | 48 | hook, |
|
49 | 49 | lock as lockmod, |
|
50 | 50 | match as matchmod, |
|
51 | 51 | mergestate as mergestatemod, |
|
52 | 52 | mergeutil, |
|
53 | 53 | namespaces, |
|
54 | 54 | narrowspec, |
|
55 | 55 | obsolete, |
|
56 | 56 | pathutil, |
|
57 | 57 | phases, |
|
58 | 58 | pushkey, |
|
59 | 59 | pycompat, |
|
60 | 60 | rcutil, |
|
61 | 61 | repoview, |
|
62 | 62 | requirements as requirementsmod, |
|
63 | 63 | revlog, |
|
64 | 64 | revset, |
|
65 | 65 | revsetlang, |
|
66 | 66 | scmutil, |
|
67 | 67 | sparse, |
|
68 | 68 | store as storemod, |
|
69 | 69 | subrepoutil, |
|
70 | 70 | tags as tagsmod, |
|
71 | 71 | transaction, |
|
72 | 72 | txnutil, |
|
73 | 73 | util, |
|
74 | 74 | vfs as vfsmod, |
|
75 | 75 | wireprototypes, |
|
76 | 76 | ) |
|
77 | 77 | |
|
78 | 78 | from .interfaces import ( |
|
79 | 79 | repository, |
|
80 | 80 | util as interfaceutil, |
|
81 | 81 | ) |
|
82 | 82 | |
|
83 | 83 | from .utils import ( |
|
84 | 84 | hashutil, |
|
85 | 85 | procutil, |
|
86 | 86 | stringutil, |
|
87 | 87 | urlutil, |
|
88 | 88 | ) |
|
89 | 89 | |
|
90 | 90 | from .revlogutils import ( |
|
91 | 91 | concurrency_checker as revlogchecker, |
|
92 | 92 | constants as revlogconst, |
|
93 | 93 | sidedata as sidedatamod, |
|
94 | 94 | ) |
|
95 | 95 | |
|
96 | 96 | release = lockmod.release |
|
97 | 97 | urlerr = util.urlerr |
|
98 | 98 | urlreq = util.urlreq |
|
99 | 99 | |
|
100 | 100 | # set of (path, vfs-location) tuples. vfs-location is: |
|
101 | 101 | # - 'plain for vfs relative paths |
|
102 | 102 | # - '' for svfs relative paths |
|
103 | 103 | _cachedfiles = set() |
|
104 | 104 | |
|
105 | 105 | |
|
106 | 106 | class _basefilecache(scmutil.filecache): |
|
107 | 107 | """All filecache usage on repo are done for logic that should be unfiltered""" |
|
108 | 108 | |
|
109 | 109 | def __get__(self, repo, type=None): |
|
110 | 110 | if repo is None: |
|
111 | 111 | return self |
|
112 | 112 | # proxy to unfiltered __dict__ since filtered repo has no entry |
|
113 | 113 | unfi = repo.unfiltered() |
|
114 | 114 | try: |
|
115 | 115 | return unfi.__dict__[self.sname] |
|
116 | 116 | except KeyError: |
|
117 | 117 | pass |
|
118 | 118 | return super(_basefilecache, self).__get__(unfi, type) |
|
119 | 119 | |
|
120 | 120 | def set(self, repo, value): |
|
121 | 121 | return super(_basefilecache, self).set(repo.unfiltered(), value) |
|
122 | 122 | |
|
123 | 123 | |
|
124 | 124 | class repofilecache(_basefilecache): |
|
125 | 125 | """filecache for files in .hg but outside of .hg/store""" |
|
126 | 126 | |
|
127 | 127 | def __init__(self, *paths): |
|
128 | 128 | super(repofilecache, self).__init__(*paths) |
|
129 | 129 | for path in paths: |
|
130 | 130 | _cachedfiles.add((path, b'plain')) |
|
131 | 131 | |
|
132 | 132 | def join(self, obj, fname): |
|
133 | 133 | return obj.vfs.join(fname) |
|
134 | 134 | |
|
135 | 135 | |
|
136 | 136 | class storecache(_basefilecache): |
|
137 | 137 | """filecache for files in the store""" |
|
138 | 138 | |
|
139 | 139 | def __init__(self, *paths): |
|
140 | 140 | super(storecache, self).__init__(*paths) |
|
141 | 141 | for path in paths: |
|
142 | 142 | _cachedfiles.add((path, b'')) |
|
143 | 143 | |
|
144 | 144 | def join(self, obj, fname): |
|
145 | 145 | return obj.sjoin(fname) |
|
146 | 146 | |
|
147 | 147 | |
|
148 | 148 | class changelogcache(storecache): |
|
149 | 149 | """filecache for the changelog""" |
|
150 | 150 | |
|
151 | 151 | def __init__(self): |
|
152 | 152 | super(changelogcache, self).__init__() |
|
153 | 153 | _cachedfiles.add((b'00changelog.i', b'')) |
|
154 | 154 | _cachedfiles.add((b'00changelog.n', b'')) |
|
155 | 155 | |
|
156 | 156 | def tracked_paths(self, obj): |
|
157 | 157 | paths = [self.join(obj, b'00changelog.i')] |
|
158 | 158 | if obj.store.opener.options.get(b'persistent-nodemap', False): |
|
159 | 159 | paths.append(self.join(obj, b'00changelog.n')) |
|
160 | 160 | return paths |
|
161 | 161 | |
|
162 | 162 | |
|
163 | 163 | class manifestlogcache(storecache): |
|
164 | 164 | """filecache for the manifestlog""" |
|
165 | 165 | |
|
166 | 166 | def __init__(self): |
|
167 | 167 | super(manifestlogcache, self).__init__() |
|
168 | 168 | _cachedfiles.add((b'00manifest.i', b'')) |
|
169 | 169 | _cachedfiles.add((b'00manifest.n', b'')) |
|
170 | 170 | |
|
171 | 171 | def tracked_paths(self, obj): |
|
172 | 172 | paths = [self.join(obj, b'00manifest.i')] |
|
173 | 173 | if obj.store.opener.options.get(b'persistent-nodemap', False): |
|
174 | 174 | paths.append(self.join(obj, b'00manifest.n')) |
|
175 | 175 | return paths |
|
176 | 176 | |
|
177 | 177 | |
|
178 | 178 | class mixedrepostorecache(_basefilecache): |
|
179 | 179 | """filecache for a mix files in .hg/store and outside""" |
|
180 | 180 | |
|
181 | 181 | def __init__(self, *pathsandlocations): |
|
182 | 182 | # scmutil.filecache only uses the path for passing back into our |
|
183 | 183 | # join(), so we can safely pass a list of paths and locations |
|
184 | 184 | super(mixedrepostorecache, self).__init__(*pathsandlocations) |
|
185 | 185 | _cachedfiles.update(pathsandlocations) |
|
186 | 186 | |
|
187 | 187 | def join(self, obj, fnameandlocation): |
|
188 | 188 | fname, location = fnameandlocation |
|
189 | 189 | if location == b'plain': |
|
190 | 190 | return obj.vfs.join(fname) |
|
191 | 191 | else: |
|
192 | 192 | if location != b'': |
|
193 | 193 | raise error.ProgrammingError( |
|
194 | 194 | b'unexpected location: %s' % location |
|
195 | 195 | ) |
|
196 | 196 | return obj.sjoin(fname) |
|
197 | 197 | |
|
198 | 198 | |
|
199 | 199 | def isfilecached(repo, name): |
|
200 | 200 | """check if a repo has already cached "name" filecache-ed property |
|
201 | 201 | |
|
202 | 202 | This returns (cachedobj-or-None, iscached) tuple. |
|
203 | 203 | """ |
|
204 | 204 | cacheentry = repo.unfiltered()._filecache.get(name, None) |
|
205 | 205 | if not cacheentry: |
|
206 | 206 | return None, False |
|
207 | 207 | return cacheentry.obj, True |
|
208 | 208 | |
|
209 | 209 | |
|
210 | 210 | class unfilteredpropertycache(util.propertycache): |
|
211 | 211 | """propertycache that apply to unfiltered repo only""" |
|
212 | 212 | |
|
213 | 213 | def __get__(self, repo, type=None): |
|
214 | 214 | unfi = repo.unfiltered() |
|
215 | 215 | if unfi is repo: |
|
216 | 216 | return super(unfilteredpropertycache, self).__get__(unfi) |
|
217 | 217 | return getattr(unfi, self.name) |
|
218 | 218 | |
|
219 | 219 | |
|
220 | 220 | class filteredpropertycache(util.propertycache): |
|
221 | 221 | """propertycache that must take filtering in account""" |
|
222 | 222 | |
|
223 | 223 | def cachevalue(self, obj, value): |
|
224 | 224 | object.__setattr__(obj, self.name, value) |
|
225 | 225 | |
|
226 | 226 | |
|
227 | 227 | def hasunfilteredcache(repo, name): |
|
228 | 228 | """check if a repo has an unfilteredpropertycache value for <name>""" |
|
229 | 229 | return name in vars(repo.unfiltered()) |
|
230 | 230 | |
|
231 | 231 | |
|
232 | 232 | def unfilteredmethod(orig): |
|
233 | 233 | """decorate method that always need to be run on unfiltered version""" |
|
234 | 234 | |
|
235 | 235 | @functools.wraps(orig) |
|
236 | 236 | def wrapper(repo, *args, **kwargs): |
|
237 | 237 | return orig(repo.unfiltered(), *args, **kwargs) |
|
238 | 238 | |
|
239 | 239 | return wrapper |
|
240 | 240 | |
|
241 | 241 | |
|
242 | 242 | moderncaps = { |
|
243 | 243 | b'lookup', |
|
244 | 244 | b'branchmap', |
|
245 | 245 | b'pushkey', |
|
246 | 246 | b'known', |
|
247 | 247 | b'getbundle', |
|
248 | 248 | b'unbundle', |
|
249 | 249 | } |
|
250 | 250 | legacycaps = moderncaps.union({b'changegroupsubset'}) |
|
251 | 251 | |
|
252 | 252 | |
|
253 | 253 | @interfaceutil.implementer(repository.ipeercommandexecutor) |
|
254 | 254 | class localcommandexecutor(object): |
|
255 | 255 | def __init__(self, peer): |
|
256 | 256 | self._peer = peer |
|
257 | 257 | self._sent = False |
|
258 | 258 | self._closed = False |
|
259 | 259 | |
|
260 | 260 | def __enter__(self): |
|
261 | 261 | return self |
|
262 | 262 | |
|
263 | 263 | def __exit__(self, exctype, excvalue, exctb): |
|
264 | 264 | self.close() |
|
265 | 265 | |
|
266 | 266 | def callcommand(self, command, args): |
|
267 | 267 | if self._sent: |
|
268 | 268 | raise error.ProgrammingError( |
|
269 | 269 | b'callcommand() cannot be used after sendcommands()' |
|
270 | 270 | ) |
|
271 | 271 | |
|
272 | 272 | if self._closed: |
|
273 | 273 | raise error.ProgrammingError( |
|
274 | 274 | b'callcommand() cannot be used after close()' |
|
275 | 275 | ) |
|
276 | 276 | |
|
277 | 277 | # We don't need to support anything fancy. Just call the named |
|
278 | 278 | # method on the peer and return a resolved future. |
|
279 | 279 | fn = getattr(self._peer, pycompat.sysstr(command)) |
|
280 | 280 | |
|
281 | 281 | f = pycompat.futures.Future() |
|
282 | 282 | |
|
283 | 283 | try: |
|
284 | 284 | result = fn(**pycompat.strkwargs(args)) |
|
285 | 285 | except Exception: |
|
286 | 286 | pycompat.future_set_exception_info(f, sys.exc_info()[1:]) |
|
287 | 287 | else: |
|
288 | 288 | f.set_result(result) |
|
289 | 289 | |
|
290 | 290 | return f |
|
291 | 291 | |
|
292 | 292 | def sendcommands(self): |
|
293 | 293 | self._sent = True |
|
294 | 294 | |
|
295 | 295 | def close(self): |
|
296 | 296 | self._closed = True |
|
297 | 297 | |
|
298 | 298 | |
|
299 | 299 | @interfaceutil.implementer(repository.ipeercommands) |
|
300 | 300 | class localpeer(repository.peer): |
|
301 | 301 | '''peer for a local repo; reflects only the most recent API''' |
|
302 | 302 | |
|
303 | 303 | def __init__(self, repo, caps=None): |
|
304 | 304 | super(localpeer, self).__init__() |
|
305 | 305 | |
|
306 | 306 | if caps is None: |
|
307 | 307 | caps = moderncaps.copy() |
|
308 | 308 | self._repo = repo.filtered(b'served') |
|
309 | 309 | self.ui = repo.ui |
|
310 | 310 | |
|
311 | 311 | if repo._wanted_sidedata: |
|
312 | 312 | formatted = bundle2.format_remote_wanted_sidedata(repo) |
|
313 | 313 | caps.add(b'exp-wanted-sidedata=' + formatted) |
|
314 | 314 | |
|
315 | 315 | self._caps = repo._restrictcapabilities(caps) |
|
316 | 316 | |
|
317 | 317 | # Begin of _basepeer interface. |
|
318 | 318 | |
|
319 | 319 | def url(self): |
|
320 | 320 | return self._repo.url() |
|
321 | 321 | |
|
322 | 322 | def local(self): |
|
323 | 323 | return self._repo |
|
324 | 324 | |
|
325 | 325 | def peer(self): |
|
326 | 326 | return self |
|
327 | 327 | |
|
328 | 328 | def canpush(self): |
|
329 | 329 | return True |
|
330 | 330 | |
|
331 | 331 | def close(self): |
|
332 | 332 | self._repo.close() |
|
333 | 333 | |
|
334 | 334 | # End of _basepeer interface. |
|
335 | 335 | |
|
336 | 336 | # Begin of _basewirecommands interface. |
|
337 | 337 | |
|
338 | 338 | def branchmap(self): |
|
339 | 339 | return self._repo.branchmap() |
|
340 | 340 | |
|
341 | 341 | def capabilities(self): |
|
342 | 342 | return self._caps |
|
343 | 343 | |
|
344 | 344 | def clonebundles(self): |
|
345 | 345 | return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE) |
|
346 | 346 | |
|
347 | 347 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
348 | 348 | """Used to test argument passing over the wire""" |
|
349 | 349 | return b"%s %s %s %s %s" % ( |
|
350 | 350 | one, |
|
351 | 351 | two, |
|
352 | 352 | pycompat.bytestr(three), |
|
353 | 353 | pycompat.bytestr(four), |
|
354 | 354 | pycompat.bytestr(five), |
|
355 | 355 | ) |
|
356 | 356 | |
|
357 | 357 | def getbundle( |
|
358 | 358 | self, |
|
359 | 359 | source, |
|
360 | 360 | heads=None, |
|
361 | 361 | common=None, |
|
362 | 362 | bundlecaps=None, |
|
363 | 363 | remote_sidedata=None, |
|
364 | 364 | **kwargs |
|
365 | 365 | ): |
|
366 | 366 | chunks = exchange.getbundlechunks( |
|
367 | 367 | self._repo, |
|
368 | 368 | source, |
|
369 | 369 | heads=heads, |
|
370 | 370 | common=common, |
|
371 | 371 | bundlecaps=bundlecaps, |
|
372 | 372 | remote_sidedata=remote_sidedata, |
|
373 | 373 | **kwargs |
|
374 | 374 | )[1] |
|
375 | 375 | cb = util.chunkbuffer(chunks) |
|
376 | 376 | |
|
377 | 377 | if exchange.bundle2requested(bundlecaps): |
|
378 | 378 | # When requesting a bundle2, getbundle returns a stream to make the |
|
379 | 379 | # wire level function happier. We need to build a proper object |
|
380 | 380 | # from it in local peer. |
|
381 | 381 | return bundle2.getunbundler(self.ui, cb) |
|
382 | 382 | else: |
|
383 | 383 | return changegroup.getunbundler(b'01', cb, None) |
|
384 | 384 | |
|
385 | 385 | def heads(self): |
|
386 | 386 | return self._repo.heads() |
|
387 | 387 | |
|
388 | 388 | def known(self, nodes): |
|
389 | 389 | return self._repo.known(nodes) |
|
390 | 390 | |
|
391 | 391 | def listkeys(self, namespace): |
|
392 | 392 | return self._repo.listkeys(namespace) |
|
393 | 393 | |
|
394 | 394 | def lookup(self, key): |
|
395 | 395 | return self._repo.lookup(key) |
|
396 | 396 | |
|
397 | 397 | def pushkey(self, namespace, key, old, new): |
|
398 | 398 | return self._repo.pushkey(namespace, key, old, new) |
|
399 | 399 | |
|
400 | 400 | def stream_out(self): |
|
401 | 401 | raise error.Abort(_(b'cannot perform stream clone against local peer')) |
|
402 | 402 | |
|
403 | 403 | def unbundle(self, bundle, heads, url): |
|
404 | 404 | """apply a bundle on a repo |
|
405 | 405 | |
|
406 | 406 | This function handles the repo locking itself.""" |
|
407 | 407 | try: |
|
408 | 408 | try: |
|
409 | 409 | bundle = exchange.readbundle(self.ui, bundle, None) |
|
410 | 410 | ret = exchange.unbundle(self._repo, bundle, heads, b'push', url) |
|
411 | 411 | if util.safehasattr(ret, b'getchunks'): |
|
412 | 412 | # This is a bundle20 object, turn it into an unbundler. |
|
413 | 413 | # This little dance should be dropped eventually when the |
|
414 | 414 | # API is finally improved. |
|
415 | 415 | stream = util.chunkbuffer(ret.getchunks()) |
|
416 | 416 | ret = bundle2.getunbundler(self.ui, stream) |
|
417 | 417 | return ret |
|
418 | 418 | except Exception as exc: |
|
419 | 419 | # If the exception contains output salvaged from a bundle2 |
|
420 | 420 | # reply, we need to make sure it is printed before continuing |
|
421 | 421 | # to fail. So we build a bundle2 with such output and consume |
|
422 | 422 | # it directly. |
|
423 | 423 | # |
|
424 | 424 | # This is not very elegant but allows a "simple" solution for |
|
425 | 425 | # issue4594 |
|
426 | 426 | output = getattr(exc, '_bundle2salvagedoutput', ()) |
|
427 | 427 | if output: |
|
428 | 428 | bundler = bundle2.bundle20(self._repo.ui) |
|
429 | 429 | for out in output: |
|
430 | 430 | bundler.addpart(out) |
|
431 | 431 | stream = util.chunkbuffer(bundler.getchunks()) |
|
432 | 432 | b = bundle2.getunbundler(self.ui, stream) |
|
433 | 433 | bundle2.processbundle(self._repo, b) |
|
434 | 434 | raise |
|
435 | 435 | except error.PushRaced as exc: |
|
436 | 436 | raise error.ResponseError( |
|
437 | 437 | _(b'push failed:'), stringutil.forcebytestr(exc) |
|
438 | 438 | ) |
|
439 | 439 | |
|
440 | 440 | # End of _basewirecommands interface. |
|
441 | 441 | |
|
442 | 442 | # Begin of peer interface. |
|
443 | 443 | |
|
444 | 444 | def commandexecutor(self): |
|
445 | 445 | return localcommandexecutor(self) |
|
446 | 446 | |
|
447 | 447 | # End of peer interface. |
|
448 | 448 | |
|
449 | 449 | |
|
450 | 450 | @interfaceutil.implementer(repository.ipeerlegacycommands) |
|
451 | 451 | class locallegacypeer(localpeer): |
|
452 | 452 | """peer extension which implements legacy methods too; used for tests with |
|
453 | 453 | restricted capabilities""" |
|
454 | 454 | |
|
455 | 455 | def __init__(self, repo): |
|
456 | 456 | super(locallegacypeer, self).__init__(repo, caps=legacycaps) |
|
457 | 457 | |
|
458 | 458 | # Begin of baselegacywirecommands interface. |
|
459 | 459 | |
|
460 | 460 | def between(self, pairs): |
|
461 | 461 | return self._repo.between(pairs) |
|
462 | 462 | |
|
463 | 463 | def branches(self, nodes): |
|
464 | 464 | return self._repo.branches(nodes) |
|
465 | 465 | |
|
466 | 466 | def changegroup(self, nodes, source): |
|
467 | 467 | outgoing = discovery.outgoing( |
|
468 | 468 | self._repo, missingroots=nodes, ancestorsof=self._repo.heads() |
|
469 | 469 | ) |
|
470 | 470 | return changegroup.makechangegroup(self._repo, outgoing, b'01', source) |
|
471 | 471 | |
|
472 | 472 | def changegroupsubset(self, bases, heads, source): |
|
473 | 473 | outgoing = discovery.outgoing( |
|
474 | 474 | self._repo, missingroots=bases, ancestorsof=heads |
|
475 | 475 | ) |
|
476 | 476 | return changegroup.makechangegroup(self._repo, outgoing, b'01', source) |
|
477 | 477 | |
|
478 | 478 | # End of baselegacywirecommands interface. |
|
479 | 479 | |
|
480 | 480 | |
|
481 | 481 | # Functions receiving (ui, features) that extensions can register to impact |
|
482 | 482 | # the ability to load repositories with custom requirements. Only |
|
483 | 483 | # functions defined in loaded extensions are called. |
|
484 | 484 | # |
|
485 | 485 | # The function receives a set of requirement strings that the repository |
|
486 | 486 | # is capable of opening. Functions will typically add elements to the |
|
487 | 487 | # set to reflect that the extension knows how to handle that requirements. |
|
488 | 488 | featuresetupfuncs = set() |
|
489 | 489 | |
|
490 | 490 | |
|
491 | 491 | def _getsharedvfs(hgvfs, requirements): |
|
492 | 492 | """returns the vfs object pointing to root of shared source |
|
493 | 493 | repo for a shared repository |
|
494 | 494 | |
|
495 | 495 | hgvfs is vfs pointing at .hg/ of current repo (shared one) |
|
496 | 496 | requirements is a set of requirements of current repo (shared one) |
|
497 | 497 | """ |
|
498 | 498 | # The ``shared`` or ``relshared`` requirements indicate the |
|
499 | 499 | # store lives in the path contained in the ``.hg/sharedpath`` file. |
|
500 | 500 | # This is an absolute path for ``shared`` and relative to |
|
501 | 501 | # ``.hg/`` for ``relshared``. |
|
502 | 502 | sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') |
|
503 | 503 | if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements: |
|
504 | 504 | sharedpath = util.normpath(hgvfs.join(sharedpath)) |
|
505 | 505 | |
|
506 | 506 | sharedvfs = vfsmod.vfs(sharedpath, realpath=True) |
|
507 | 507 | |
|
508 | 508 | if not sharedvfs.exists(): |
|
509 | 509 | raise error.RepoError( |
|
510 | 510 | _(b'.hg/sharedpath points to nonexistent directory %s') |
|
511 | 511 | % sharedvfs.base |
|
512 | 512 | ) |
|
513 | 513 | return sharedvfs |
|
514 | 514 | |
|
515 | 515 | |
|
516 | 516 | def _readrequires(vfs, allowmissing): |
|
517 | 517 | """reads the require file present at root of this vfs |
|
518 | 518 | and return a set of requirements |
|
519 | 519 | |
|
520 | 520 | If allowmissing is True, we suppress ENOENT if raised""" |
|
521 | 521 | # requires file contains a newline-delimited list of |
|
522 | 522 | # features/capabilities the opener (us) must have in order to use |
|
523 | 523 | # the repository. This file was introduced in Mercurial 0.9.2, |
|
524 | 524 | # which means very old repositories may not have one. We assume |
|
525 | 525 | # a missing file translates to no requirements. |
|
526 | 526 | try: |
|
527 | 527 | requirements = set(vfs.read(b'requires').splitlines()) |
|
528 | 528 | except IOError as e: |
|
529 | 529 | if not (allowmissing and e.errno == errno.ENOENT): |
|
530 | 530 | raise |
|
531 | 531 | requirements = set() |
|
532 | 532 | return requirements |
|
533 | 533 | |
|
534 | 534 | |
|
535 | 535 | def makelocalrepository(baseui, path, intents=None): |
|
536 | 536 | """Create a local repository object. |
|
537 | 537 | |
|
538 | 538 | Given arguments needed to construct a local repository, this function |
|
539 | 539 | performs various early repository loading functionality (such as |
|
540 | 540 | reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that |
|
541 | 541 | the repository can be opened, derives a type suitable for representing |
|
542 | 542 | that repository, and returns an instance of it. |
|
543 | 543 | |
|
544 | 544 | The returned object conforms to the ``repository.completelocalrepository`` |
|
545 | 545 | interface. |
|
546 | 546 | |
|
547 | 547 | The repository type is derived by calling a series of factory functions |
|
548 | 548 | for each aspect/interface of the final repository. These are defined by |
|
549 | 549 | ``REPO_INTERFACES``. |
|
550 | 550 | |
|
551 | 551 | Each factory function is called to produce a type implementing a specific |
|
552 | 552 | interface. The cumulative list of returned types will be combined into a |
|
553 | 553 | new type and that type will be instantiated to represent the local |
|
554 | 554 | repository. |
|
555 | 555 | |
|
556 | 556 | The factory functions each receive various state that may be consulted |
|
557 | 557 | as part of deriving a type. |
|
558 | 558 | |
|
559 | 559 | Extensions should wrap these factory functions to customize repository type |
|
560 | 560 | creation. Note that an extension's wrapped function may be called even if |
|
561 | 561 | that extension is not loaded for the repo being constructed. Extensions |
|
562 | 562 | should check if their ``__name__`` appears in the |
|
563 | 563 | ``extensionmodulenames`` set passed to the factory function and no-op if |
|
564 | 564 | not. |
|
565 | 565 | """ |
|
566 | 566 | ui = baseui.copy() |
|
567 | 567 | # Prevent copying repo configuration. |
|
568 | 568 | ui.copy = baseui.copy |
|
569 | 569 | |
|
570 | 570 | # Working directory VFS rooted at repository root. |
|
571 | 571 | wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
|
572 | 572 | |
|
573 | 573 | # Main VFS for .hg/ directory. |
|
574 | 574 | hgpath = wdirvfs.join(b'.hg') |
|
575 | 575 | hgvfs = vfsmod.vfs(hgpath, cacheaudited=True) |
|
576 | 576 | # Whether this repository is shared one or not |
|
577 | 577 | shared = False |
|
578 | 578 | # If this repository is shared, vfs pointing to shared repo |
|
579 | 579 | sharedvfs = None |
|
580 | 580 | |
|
581 | 581 | # The .hg/ path should exist and should be a directory. All other |
|
582 | 582 | # cases are errors. |
|
583 | 583 | if not hgvfs.isdir(): |
|
584 | 584 | try: |
|
585 | 585 | hgvfs.stat() |
|
586 | 586 | except OSError as e: |
|
587 | 587 | if e.errno != errno.ENOENT: |
|
588 | 588 | raise |
|
589 | 589 | except ValueError as e: |
|
590 | 590 | # Can be raised on Python 3.8 when path is invalid. |
|
591 | 591 | raise error.Abort( |
|
592 | 592 | _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e)) |
|
593 | 593 | ) |
|
594 | 594 | |
|
595 | 595 | raise error.RepoError(_(b'repository %s not found') % path) |
|
596 | 596 | |
|
597 | 597 | requirements = _readrequires(hgvfs, True) |
|
598 | 598 | shared = ( |
|
599 | 599 | requirementsmod.SHARED_REQUIREMENT in requirements |
|
600 | 600 | or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements |
|
601 | 601 | ) |
|
602 | 602 | storevfs = None |
|
603 | 603 | if shared: |
|
604 | 604 | # This is a shared repo |
|
605 | 605 | sharedvfs = _getsharedvfs(hgvfs, requirements) |
|
606 | 606 | storevfs = vfsmod.vfs(sharedvfs.join(b'store')) |
|
607 | 607 | else: |
|
608 | 608 | storevfs = vfsmod.vfs(hgvfs.join(b'store')) |
|
609 | 609 | |
|
610 | 610 | # if .hg/requires contains the sharesafe requirement, it means |
|
611 | 611 | # there exists a `.hg/store/requires` too and we should read it |
|
612 | 612 | # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement |
|
613 | 613 | # is present. We never write SHARESAFE_REQUIREMENT for a repo if store |
|
614 | 614 | # is not present, refer checkrequirementscompat() for that |
|
615 | 615 | # |
|
616 | 616 | # However, if SHARESAFE_REQUIREMENT is not present, it means that the |
|
617 | 617 | # repository was shared the old way. We check the share source .hg/requires |
|
618 | 618 | # for SHARESAFE_REQUIREMENT to detect whether the current repository needs |
|
619 | 619 | # to be reshared |
|
620 | 620 | hint = _(b"see `hg help config.format.use-share-safe` for more information") |
|
621 | 621 | if requirementsmod.SHARESAFE_REQUIREMENT in requirements: |
|
622 | 622 | |
|
623 | 623 | if ( |
|
624 | 624 | shared |
|
625 | 625 | and requirementsmod.SHARESAFE_REQUIREMENT |
|
626 | 626 | not in _readrequires(sharedvfs, True) |
|
627 | 627 | ): |
|
628 | 628 | mismatch_warn = ui.configbool( |
|
629 | 629 | b'share', b'safe-mismatch.source-not-safe.warn' |
|
630 | 630 | ) |
|
631 | 631 | mismatch_config = ui.config( |
|
632 | 632 | b'share', b'safe-mismatch.source-not-safe' |
|
633 | 633 | ) |
|
634 | 634 | if mismatch_config in ( |
|
635 | 635 | b'downgrade-allow', |
|
636 | 636 | b'allow', |
|
637 | 637 | b'downgrade-abort', |
|
638 | 638 | ): |
|
639 | 639 | # prevent cyclic import localrepo -> upgrade -> localrepo |
|
640 | 640 | from . import upgrade |
|
641 | 641 | |
|
642 | 642 | upgrade.downgrade_share_to_non_safe( |
|
643 | 643 | ui, |
|
644 | 644 | hgvfs, |
|
645 | 645 | sharedvfs, |
|
646 | 646 | requirements, |
|
647 | 647 | mismatch_config, |
|
648 | 648 | mismatch_warn, |
|
649 | 649 | ) |
|
650 | 650 | elif mismatch_config == b'abort': |
|
651 | 651 | raise error.Abort( |
|
652 | 652 | _(b"share source does not support share-safe requirement"), |
|
653 | 653 | hint=hint, |
|
654 | 654 | ) |
|
655 | 655 | else: |
|
656 | 656 | raise error.Abort( |
|
657 | 657 | _( |
|
658 | 658 | b"share-safe mismatch with source.\nUnrecognized" |
|
659 | 659 | b" value '%s' of `share.safe-mismatch.source-not-safe`" |
|
660 | 660 | b" set." |
|
661 | 661 | ) |
|
662 | 662 | % mismatch_config, |
|
663 | 663 | hint=hint, |
|
664 | 664 | ) |
|
665 | 665 | else: |
|
666 | 666 | requirements |= _readrequires(storevfs, False) |
|
667 | 667 | elif shared: |
|
668 | 668 | sourcerequires = _readrequires(sharedvfs, False) |
|
669 | 669 | if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: |
|
670 | 670 | mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe') |
|
671 | 671 | mismatch_warn = ui.configbool( |
|
672 | 672 | b'share', b'safe-mismatch.source-safe.warn' |
|
673 | 673 | ) |
|
674 | 674 | if mismatch_config in ( |
|
675 | 675 | b'upgrade-allow', |
|
676 | 676 | b'allow', |
|
677 | 677 | b'upgrade-abort', |
|
678 | 678 | ): |
|
679 | 679 | # prevent cyclic import localrepo -> upgrade -> localrepo |
|
680 | 680 | from . import upgrade |
|
681 | 681 | |
|
682 | 682 | upgrade.upgrade_share_to_safe( |
|
683 | 683 | ui, |
|
684 | 684 | hgvfs, |
|
685 | 685 | storevfs, |
|
686 | 686 | requirements, |
|
687 | 687 | mismatch_config, |
|
688 | 688 | mismatch_warn, |
|
689 | 689 | ) |
|
690 | 690 | elif mismatch_config == b'abort': |
|
691 | 691 | raise error.Abort( |
|
692 | 692 | _( |
|
693 | 693 | b'version mismatch: source uses share-safe' |
|
694 | 694 | b' functionality while the current share does not' |
|
695 | 695 | ), |
|
696 | 696 | hint=hint, |
|
697 | 697 | ) |
|
698 | 698 | else: |
|
699 | 699 | raise error.Abort( |
|
700 | 700 | _( |
|
701 | 701 | b"share-safe mismatch with source.\nUnrecognized" |
|
702 | 702 | b" value '%s' of `share.safe-mismatch.source-safe` set." |
|
703 | 703 | ) |
|
704 | 704 | % mismatch_config, |
|
705 | 705 | hint=hint, |
|
706 | 706 | ) |
|
707 | 707 | |
|
708 | 708 | # The .hg/hgrc file may load extensions or contain config options |
|
709 | 709 | # that influence repository construction. Attempt to load it and |
|
710 | 710 | # process any new extensions that it may have pulled in. |
|
711 | 711 | if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs): |
|
712 | 712 | afterhgrcload(ui, wdirvfs, hgvfs, requirements) |
|
713 | 713 | extensions.loadall(ui) |
|
714 | 714 | extensions.populateui(ui) |
|
715 | 715 | |
|
716 | 716 | # Set of module names of extensions loaded for this repository. |
|
717 | 717 | extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)} |
|
718 | 718 | |
|
719 | 719 | supportedrequirements = gathersupportedrequirements(ui) |
|
720 | 720 | |
|
721 | 721 | # We first validate the requirements are known. |
|
722 | 722 | ensurerequirementsrecognized(requirements, supportedrequirements) |
|
723 | 723 | |
|
724 | 724 | # Then we validate that the known set is reasonable to use together. |
|
725 | 725 | ensurerequirementscompatible(ui, requirements) |
|
726 | 726 | |
|
727 | 727 | # TODO there are unhandled edge cases related to opening repositories with |
|
728 | 728 | # shared storage. If storage is shared, we should also test for requirements |
|
729 | 729 | # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in |
|
730 | 730 | # that repo, as that repo may load extensions needed to open it. This is a |
|
731 | 731 | # bit complicated because we don't want the other hgrc to overwrite settings |
|
732 | 732 | # in this hgrc. |
|
733 | 733 | # |
|
734 | 734 | # This bug is somewhat mitigated by the fact that we copy the .hg/requires |
|
735 | 735 | # file when sharing repos. But if a requirement is added after the share is |
|
736 | 736 | # performed, thereby introducing a new requirement for the opener, we may |
|
737 | 737 | # will not see that and could encounter a run-time error interacting with |
|
738 | 738 | # that shared store since it has an unknown-to-us requirement. |
|
739 | 739 | |
|
740 | 740 | # At this point, we know we should be capable of opening the repository. |
|
741 | 741 | # Now get on with doing that. |
|
742 | 742 | |
|
743 | 743 | features = set() |
|
744 | 744 | |
|
745 | 745 | # The "store" part of the repository holds versioned data. How it is |
|
746 | 746 | # accessed is determined by various requirements. If `shared` or |
|
747 | 747 | # `relshared` requirements are present, this indicates current repository |
|
748 | 748 | # is a share and store exists in path mentioned in `.hg/sharedpath` |
|
749 | 749 | if shared: |
|
750 | 750 | storebasepath = sharedvfs.base |
|
751 | 751 | cachepath = sharedvfs.join(b'cache') |
|
752 | 752 | features.add(repository.REPO_FEATURE_SHARED_STORAGE) |
|
753 | 753 | else: |
|
754 | 754 | storebasepath = hgvfs.base |
|
755 | 755 | cachepath = hgvfs.join(b'cache') |
|
756 | 756 | wcachepath = hgvfs.join(b'wcache') |
|
757 | 757 | |
|
758 | 758 | # The store has changed over time and the exact layout is dictated by |
|
759 | 759 | # requirements. The store interface abstracts differences across all |
|
760 | 760 | # of them. |
|
761 | 761 | store = makestore( |
|
762 | 762 | requirements, |
|
763 | 763 | storebasepath, |
|
764 | 764 | lambda base: vfsmod.vfs(base, cacheaudited=True), |
|
765 | 765 | ) |
|
766 | 766 | hgvfs.createmode = store.createmode |
|
767 | 767 | |
|
768 | 768 | storevfs = store.vfs |
|
769 | 769 | storevfs.options = resolvestorevfsoptions(ui, requirements, features) |
|
770 | 770 | |
|
771 | 771 | if ( |
|
772 | 772 | requirementsmod.REVLOGV2_REQUIREMENT in requirements |
|
773 | 773 | or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements |
|
774 | 774 | ): |
|
775 | 775 | features.add(repository.REPO_FEATURE_SIDE_DATA) |
|
776 | 776 | # the revlogv2 docket introduced race condition that we need to fix |
|
777 | 777 | features.discard(repository.REPO_FEATURE_STREAM_CLONE) |
|
778 | 778 | |
|
779 | 779 | # The cache vfs is used to manage cache files. |
|
780 | 780 | cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) |
|
781 | 781 | cachevfs.createmode = store.createmode |
|
782 | 782 | # The cache vfs is used to manage cache files related to the working copy |
|
783 | 783 | wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True) |
|
784 | 784 | wcachevfs.createmode = store.createmode |
|
785 | 785 | |
|
786 | 786 | # Now resolve the type for the repository object. We do this by repeatedly |
|
787 | 787 | # calling a factory function to produces types for specific aspects of the |
|
788 | 788 | # repo's operation. The aggregate returned types are used as base classes |
|
789 | 789 | # for a dynamically-derived type, which will represent our new repository. |
|
790 | 790 | |
|
791 | 791 | bases = [] |
|
792 | 792 | extrastate = {} |
|
793 | 793 | |
|
794 | 794 | for iface, fn in REPO_INTERFACES: |
|
795 | 795 | # We pass all potentially useful state to give extensions tons of |
|
796 | 796 | # flexibility. |
|
797 | 797 | typ = fn()( |
|
798 | 798 | ui=ui, |
|
799 | 799 | intents=intents, |
|
800 | 800 | requirements=requirements, |
|
801 | 801 | features=features, |
|
802 | 802 | wdirvfs=wdirvfs, |
|
803 | 803 | hgvfs=hgvfs, |
|
804 | 804 | store=store, |
|
805 | 805 | storevfs=storevfs, |
|
806 | 806 | storeoptions=storevfs.options, |
|
807 | 807 | cachevfs=cachevfs, |
|
808 | 808 | wcachevfs=wcachevfs, |
|
809 | 809 | extensionmodulenames=extensionmodulenames, |
|
810 | 810 | extrastate=extrastate, |
|
811 | 811 | baseclasses=bases, |
|
812 | 812 | ) |
|
813 | 813 | |
|
814 | 814 | if not isinstance(typ, type): |
|
815 | 815 | raise error.ProgrammingError( |
|
816 | 816 | b'unable to construct type for %s' % iface |
|
817 | 817 | ) |
|
818 | 818 | |
|
819 | 819 | bases.append(typ) |
|
820 | 820 | |
|
821 | 821 | # type() allows you to use characters in type names that wouldn't be |
|
822 | 822 | # recognized as Python symbols in source code. We abuse that to add |
|
823 | 823 | # rich information about our constructed repo. |
|
824 | 824 | name = pycompat.sysstr( |
|
825 | 825 | b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements))) |
|
826 | 826 | ) |
|
827 | 827 | |
|
828 | 828 | cls = type(name, tuple(bases), {}) |
|
829 | 829 | |
|
830 | 830 | return cls( |
|
831 | 831 | baseui=baseui, |
|
832 | 832 | ui=ui, |
|
833 | 833 | origroot=path, |
|
834 | 834 | wdirvfs=wdirvfs, |
|
835 | 835 | hgvfs=hgvfs, |
|
836 | 836 | requirements=requirements, |
|
837 | 837 | supportedrequirements=supportedrequirements, |
|
838 | 838 | sharedpath=storebasepath, |
|
839 | 839 | store=store, |
|
840 | 840 | cachevfs=cachevfs, |
|
841 | 841 | wcachevfs=wcachevfs, |
|
842 | 842 | features=features, |
|
843 | 843 | intents=intents, |
|
844 | 844 | ) |
|
845 | 845 | |
|
846 | 846 | |
|
847 | 847 | def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None): |
|
848 | 848 | """Load hgrc files/content into a ui instance. |
|
849 | 849 | |
|
850 | 850 | This is called during repository opening to load any additional |
|
851 | 851 | config files or settings relevant to the current repository. |
|
852 | 852 | |
|
853 | 853 | Returns a bool indicating whether any additional configs were loaded. |
|
854 | 854 | |
|
855 | 855 | Extensions should monkeypatch this function to modify how per-repo |
|
856 | 856 | configs are loaded. For example, an extension may wish to pull in |
|
857 | 857 | configs from alternate files or sources. |
|
858 | 858 | |
|
859 | 859 | sharedvfs is vfs object pointing to source repo if the current one is a |
|
860 | 860 | shared one |
|
861 | 861 | """ |
|
862 | 862 | if not rcutil.use_repo_hgrc(): |
|
863 | 863 | return False |
|
864 | 864 | |
|
865 | 865 | ret = False |
|
866 | 866 | # first load config from shared source if we has to |
|
867 | 867 | if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs: |
|
868 | 868 | try: |
|
869 | 869 | ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base) |
|
870 | 870 | ret = True |
|
871 | 871 | except IOError: |
|
872 | 872 | pass |
|
873 | 873 | |
|
874 | 874 | try: |
|
875 | 875 | ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base) |
|
876 | 876 | ret = True |
|
877 | 877 | except IOError: |
|
878 | 878 | pass |
|
879 | 879 | |
|
880 | 880 | try: |
|
881 | 881 | ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base) |
|
882 | 882 | ret = True |
|
883 | 883 | except IOError: |
|
884 | 884 | pass |
|
885 | 885 | |
|
886 | 886 | return ret |
|
887 | 887 | |
|
888 | 888 | |
|
889 | 889 | def afterhgrcload(ui, wdirvfs, hgvfs, requirements): |
|
890 | 890 | """Perform additional actions after .hg/hgrc is loaded. |
|
891 | 891 | |
|
892 | 892 | This function is called during repository loading immediately after |
|
893 | 893 | the .hg/hgrc file is loaded and before per-repo extensions are loaded. |
|
894 | 894 | |
|
895 | 895 | The function can be used to validate configs, automatically add |
|
896 | 896 | options (including extensions) based on requirements, etc. |
|
897 | 897 | """ |
|
898 | 898 | |
|
899 | 899 | # Map of requirements to list of extensions to load automatically when |
|
900 | 900 | # requirement is present. |
|
901 | 901 | autoextensions = { |
|
902 | 902 | b'git': [b'git'], |
|
903 | 903 | b'largefiles': [b'largefiles'], |
|
904 | 904 | b'lfs': [b'lfs'], |
|
905 | 905 | } |
|
906 | 906 | |
|
907 | 907 | for requirement, names in sorted(autoextensions.items()): |
|
908 | 908 | if requirement not in requirements: |
|
909 | 909 | continue |
|
910 | 910 | |
|
911 | 911 | for name in names: |
|
912 | 912 | if not ui.hasconfig(b'extensions', name): |
|
913 | 913 | ui.setconfig(b'extensions', name, b'', source=b'autoload') |
|
914 | 914 | |
|
915 | 915 | |
|
916 | 916 | def gathersupportedrequirements(ui): |
|
917 | 917 | """Determine the complete set of recognized requirements.""" |
|
918 | 918 | # Start with all requirements supported by this file. |
|
919 | 919 | supported = set(localrepository._basesupported) |
|
920 | 920 | |
|
921 | 921 | # Execute ``featuresetupfuncs`` entries if they belong to an extension |
|
922 | 922 | # relevant to this ui instance. |
|
923 | 923 | modules = {m.__name__ for n, m in extensions.extensions(ui)} |
|
924 | 924 | |
|
925 | 925 | for fn in featuresetupfuncs: |
|
926 | 926 | if fn.__module__ in modules: |
|
927 | 927 | fn(ui, supported) |
|
928 | 928 | |
|
929 | 929 | # Add derived requirements from registered compression engines. |
|
930 | 930 | for name in util.compengines: |
|
931 | 931 | engine = util.compengines[name] |
|
932 | 932 | if engine.available() and engine.revlogheader(): |
|
933 | 933 | supported.add(b'exp-compression-%s' % name) |
|
934 | 934 | if engine.name() == b'zstd': |
|
935 | 935 | supported.add(requirementsmod.REVLOG_COMPRESSION_ZSTD) |
|
936 | 936 | |
|
937 | 937 | return supported |
|
938 | 938 | |
|
939 | 939 | |
|
940 | 940 | def ensurerequirementsrecognized(requirements, supported): |
|
941 | 941 | """Validate that a set of local requirements is recognized. |
|
942 | 942 | |
|
943 | 943 | Receives a set of requirements. Raises an ``error.RepoError`` if there |
|
944 | 944 | exists any requirement in that set that currently loaded code doesn't |
|
945 | 945 | recognize. |
|
946 | 946 | |
|
947 | 947 | Returns a set of supported requirements. |
|
948 | 948 | """ |
|
949 | 949 | missing = set() |
|
950 | 950 | |
|
951 | 951 | for requirement in requirements: |
|
952 | 952 | if requirement in supported: |
|
953 | 953 | continue |
|
954 | 954 | |
|
955 | 955 | if not requirement or not requirement[0:1].isalnum(): |
|
956 | 956 | raise error.RequirementError(_(b'.hg/requires file is corrupt')) |
|
957 | 957 | |
|
958 | 958 | missing.add(requirement) |
|
959 | 959 | |
|
960 | 960 | if missing: |
|
961 | 961 | raise error.RequirementError( |
|
962 | 962 | _(b'repository requires features unknown to this Mercurial: %s') |
|
963 | 963 | % b' '.join(sorted(missing)), |
|
964 | 964 | hint=_( |
|
965 | 965 | b'see https://mercurial-scm.org/wiki/MissingRequirement ' |
|
966 | 966 | b'for more information' |
|
967 | 967 | ), |
|
968 | 968 | ) |
|
969 | 969 | |
|
970 | 970 | |
|
971 | 971 | def ensurerequirementscompatible(ui, requirements): |
|
972 | 972 | """Validates that a set of recognized requirements is mutually compatible. |
|
973 | 973 | |
|
974 | 974 | Some requirements may not be compatible with others or require |
|
975 | 975 | config options that aren't enabled. This function is called during |
|
976 | 976 | repository opening to ensure that the set of requirements needed |
|
977 | 977 | to open a repository is sane and compatible with config options. |
|
978 | 978 | |
|
979 | 979 | Extensions can monkeypatch this function to perform additional |
|
980 | 980 | checking. |
|
981 | 981 | |
|
982 | 982 | ``error.RepoError`` should be raised on failure. |
|
983 | 983 | """ |
|
984 | 984 | if ( |
|
985 | 985 | requirementsmod.SPARSE_REQUIREMENT in requirements |
|
986 | 986 | and not sparse.enabled |
|
987 | 987 | ): |
|
988 | 988 | raise error.RepoError( |
|
989 | 989 | _( |
|
990 | 990 | b'repository is using sparse feature but ' |
|
991 | 991 | b'sparse is not enabled; enable the ' |
|
992 | 992 | b'"sparse" extensions to access' |
|
993 | 993 | ) |
|
994 | 994 | ) |
|
995 | 995 | |
|
996 | 996 | |
|
997 | 997 | def makestore(requirements, path, vfstype): |
|
998 | 998 | """Construct a storage object for a repository.""" |
|
999 | 999 | if requirementsmod.STORE_REQUIREMENT in requirements: |
|
1000 | 1000 | if requirementsmod.FNCACHE_REQUIREMENT in requirements: |
|
1001 | 1001 | dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements |
|
1002 | 1002 | return storemod.fncachestore(path, vfstype, dotencode) |
|
1003 | 1003 | |
|
1004 | 1004 | return storemod.encodedstore(path, vfstype) |
|
1005 | 1005 | |
|
1006 | 1006 | return storemod.basicstore(path, vfstype) |
|
1007 | 1007 | |
|
1008 | 1008 | |
|
1009 | 1009 | def resolvestorevfsoptions(ui, requirements, features): |
|
1010 | 1010 | """Resolve the options to pass to the store vfs opener. |
|
1011 | 1011 | |
|
1012 | 1012 | The returned dict is used to influence behavior of the storage layer. |
|
1013 | 1013 | """ |
|
1014 | 1014 | options = {} |
|
1015 | 1015 | |
|
1016 | 1016 | if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements: |
|
1017 | 1017 | options[b'treemanifest'] = True |
|
1018 | 1018 | |
|
1019 | 1019 | # experimental config: format.manifestcachesize |
|
1020 | 1020 | manifestcachesize = ui.configint(b'format', b'manifestcachesize') |
|
1021 | 1021 | if manifestcachesize is not None: |
|
1022 | 1022 | options[b'manifestcachesize'] = manifestcachesize |
|
1023 | 1023 | |
|
1024 | 1024 | # In the absence of another requirement superseding a revlog-related |
|
1025 | 1025 | # requirement, we have to assume the repo is using revlog version 0. |
|
1026 | 1026 | # This revlog format is super old and we don't bother trying to parse |
|
1027 | 1027 | # opener options for it because those options wouldn't do anything |
|
1028 | 1028 | # meaningful on such old repos. |
|
1029 | 1029 | if ( |
|
1030 | 1030 | requirementsmod.REVLOGV1_REQUIREMENT in requirements |
|
1031 | 1031 | or requirementsmod.REVLOGV2_REQUIREMENT in requirements |
|
1032 | 1032 | ): |
|
1033 | 1033 | options.update(resolverevlogstorevfsoptions(ui, requirements, features)) |
|
1034 | 1034 | else: # explicitly mark repo as using revlogv0 |
|
1035 | 1035 | options[b'revlogv0'] = True |
|
1036 | 1036 | |
|
1037 | 1037 | if requirementsmod.COPIESSDC_REQUIREMENT in requirements: |
|
1038 | 1038 | options[b'copies-storage'] = b'changeset-sidedata' |
|
1039 | 1039 | else: |
|
1040 | 1040 | writecopiesto = ui.config(b'experimental', b'copies.write-to') |
|
1041 | 1041 | copiesextramode = (b'changeset-only', b'compatibility') |
|
1042 | 1042 | if writecopiesto in copiesextramode: |
|
1043 | 1043 | options[b'copies-storage'] = b'extra' |
|
1044 | 1044 | |
|
1045 | 1045 | return options |
|
1046 | 1046 | |
|
1047 | 1047 | |
|
1048 | 1048 | def resolverevlogstorevfsoptions(ui, requirements, features): |
|
1049 | 1049 | """Resolve opener options specific to revlogs.""" |
|
1050 | 1050 | |
|
1051 | 1051 | options = {} |
|
1052 | 1052 | options[b'flagprocessors'] = {} |
|
1053 | 1053 | |
|
1054 | 1054 | if requirementsmod.REVLOGV1_REQUIREMENT in requirements: |
|
1055 | 1055 | options[b'revlogv1'] = True |
|
1056 | 1056 | if requirementsmod.REVLOGV2_REQUIREMENT in requirements: |
|
1057 | 1057 | options[b'revlogv2'] = True |
|
1058 | 1058 | if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements: |
|
1059 | 1059 | options[b'changelogv2'] = True |
|
1060 | 1060 | |
|
1061 | 1061 | if requirementsmod.GENERALDELTA_REQUIREMENT in requirements: |
|
1062 | 1062 | options[b'generaldelta'] = True |
|
1063 | 1063 | |
|
1064 | 1064 | # experimental config: format.chunkcachesize |
|
1065 | 1065 | chunkcachesize = ui.configint(b'format', b'chunkcachesize') |
|
1066 | 1066 | if chunkcachesize is not None: |
|
1067 | 1067 | options[b'chunkcachesize'] = chunkcachesize |
|
1068 | 1068 | |
|
1069 | 1069 | deltabothparents = ui.configbool( |
|
1070 | 1070 | b'storage', b'revlog.optimize-delta-parent-choice' |
|
1071 | 1071 | ) |
|
1072 | 1072 | options[b'deltabothparents'] = deltabothparents |
|
1073 | 1073 | |
|
1074 | 1074 | issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming') |
|
1075 | 1075 | options[b'issue6528.fix-incoming'] = issue6528 |
|
1076 | 1076 | |
|
1077 | 1077 | lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta') |
|
1078 | 1078 | lazydeltabase = False |
|
1079 | 1079 | if lazydelta: |
|
1080 | 1080 | lazydeltabase = ui.configbool( |
|
1081 | 1081 | b'storage', b'revlog.reuse-external-delta-parent' |
|
1082 | 1082 | ) |
|
1083 | 1083 | if lazydeltabase is None: |
|
1084 | 1084 | lazydeltabase = not scmutil.gddeltaconfig(ui) |
|
1085 | 1085 | options[b'lazydelta'] = lazydelta |
|
1086 | 1086 | options[b'lazydeltabase'] = lazydeltabase |
|
1087 | 1087 | |
|
1088 | 1088 | chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan') |
|
1089 | 1089 | if 0 <= chainspan: |
|
1090 | 1090 | options[b'maxdeltachainspan'] = chainspan |
|
1091 | 1091 | |
|
1092 | 1092 | mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold') |
|
1093 | 1093 | if mmapindexthreshold is not None: |
|
1094 | 1094 | options[b'mmapindexthreshold'] = mmapindexthreshold |
|
1095 | 1095 | |
|
1096 | 1096 | withsparseread = ui.configbool(b'experimental', b'sparse-read') |
|
1097 | 1097 | srdensitythres = float( |
|
1098 | 1098 | ui.config(b'experimental', b'sparse-read.density-threshold') |
|
1099 | 1099 | ) |
|
1100 | 1100 | srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size') |
|
1101 | 1101 | options[b'with-sparse-read'] = withsparseread |
|
1102 | 1102 | options[b'sparse-read-density-threshold'] = srdensitythres |
|
1103 | 1103 | options[b'sparse-read-min-gap-size'] = srmingapsize |
|
1104 | 1104 | |
|
1105 | 1105 | sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements |
|
1106 | 1106 | options[b'sparse-revlog'] = sparserevlog |
|
1107 | 1107 | if sparserevlog: |
|
1108 | 1108 | options[b'generaldelta'] = True |
|
1109 | 1109 | |
|
1110 | 1110 | maxchainlen = None |
|
1111 | 1111 | if sparserevlog: |
|
1112 | 1112 | maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH |
|
1113 | 1113 | # experimental config: format.maxchainlen |
|
1114 | 1114 | maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen) |
|
1115 | 1115 | if maxchainlen is not None: |
|
1116 | 1116 | options[b'maxchainlen'] = maxchainlen |
|
1117 | 1117 | |
|
1118 | 1118 | for r in requirements: |
|
1119 | 1119 | # we allow multiple compression engine requirement to co-exist because |
|
1120 | 1120 | # strickly speaking, revlog seems to support mixed compression style. |
|
1121 | 1121 | # |
|
1122 | 1122 | # The compression used for new entries will be "the last one" |
|
1123 | 1123 | prefix = r.startswith |
|
1124 | 1124 | if prefix(b'revlog-compression-') or prefix(b'exp-compression-'): |
|
1125 | 1125 | options[b'compengine'] = r.split(b'-', 2)[2] |
|
1126 | 1126 | |
|
1127 | 1127 | options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level') |
|
1128 | 1128 | if options[b'zlib.level'] is not None: |
|
1129 | 1129 | if not (0 <= options[b'zlib.level'] <= 9): |
|
1130 | 1130 | msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d') |
|
1131 | 1131 | raise error.Abort(msg % options[b'zlib.level']) |
|
1132 | 1132 | options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level') |
|
1133 | 1133 | if options[b'zstd.level'] is not None: |
|
1134 | 1134 | if not (0 <= options[b'zstd.level'] <= 22): |
|
1135 | 1135 | msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d') |
|
1136 | 1136 | raise error.Abort(msg % options[b'zstd.level']) |
|
1137 | 1137 | |
|
1138 | 1138 | if requirementsmod.NARROW_REQUIREMENT in requirements: |
|
1139 | 1139 | options[b'enableellipsis'] = True |
|
1140 | 1140 | |
|
1141 | 1141 | if ui.configbool(b'experimental', b'rust.index'): |
|
1142 | 1142 | options[b'rust.index'] = True |
|
1143 | 1143 | if requirementsmod.NODEMAP_REQUIREMENT in requirements: |
|
1144 | 1144 | slow_path = ui.config( |
|
1145 | 1145 | b'storage', b'revlog.persistent-nodemap.slow-path' |
|
1146 | 1146 | ) |
|
1147 | 1147 | if slow_path not in (b'allow', b'warn', b'abort'): |
|
1148 | 1148 | default = ui.config_default( |
|
1149 | 1149 | b'storage', b'revlog.persistent-nodemap.slow-path' |
|
1150 | 1150 | ) |
|
1151 | 1151 | msg = _( |
|
1152 | 1152 | b'unknown value for config ' |
|
1153 | 1153 | b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n' |
|
1154 | 1154 | ) |
|
1155 | 1155 | ui.warn(msg % slow_path) |
|
1156 | 1156 | if not ui.quiet: |
|
1157 | 1157 | ui.warn(_(b'falling back to default value: %s\n') % default) |
|
1158 | 1158 | slow_path = default |
|
1159 | 1159 | |
|
1160 | 1160 | msg = _( |
|
1161 | 1161 | b"accessing `persistent-nodemap` repository without associated " |
|
1162 | 1162 | b"fast implementation." |
|
1163 | 1163 | ) |
|
1164 | 1164 | hint = _( |
|
1165 | 1165 | b"check `hg help config.format.use-persistent-nodemap` " |
|
1166 | 1166 | b"for details" |
|
1167 | 1167 | ) |
|
1168 | 1168 | if not revlog.HAS_FAST_PERSISTENT_NODEMAP: |
|
1169 | 1169 | if slow_path == b'warn': |
|
1170 | 1170 | msg = b"warning: " + msg + b'\n' |
|
1171 | 1171 | ui.warn(msg) |
|
1172 | 1172 | if not ui.quiet: |
|
1173 | 1173 | hint = b'(' + hint + b')\n' |
|
1174 | 1174 | ui.warn(hint) |
|
1175 | 1175 | if slow_path == b'abort': |
|
1176 | 1176 | raise error.Abort(msg, hint=hint) |
|
1177 | 1177 | options[b'persistent-nodemap'] = True |
|
1178 | 1178 | if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements: |
|
1179 | 1179 | slow_path = ui.config(b'storage', b'dirstate-v2.slow-path') |
|
1180 | 1180 | if slow_path not in (b'allow', b'warn', b'abort'): |
|
1181 | 1181 | default = ui.config_default(b'storage', b'dirstate-v2.slow-path') |
|
1182 | 1182 | msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n') |
|
1183 | 1183 | ui.warn(msg % slow_path) |
|
1184 | 1184 | if not ui.quiet: |
|
1185 | 1185 | ui.warn(_(b'falling back to default value: %s\n') % default) |
|
1186 | 1186 | slow_path = default |
|
1187 | 1187 | |
|
1188 | 1188 | msg = _( |
|
1189 | 1189 | b"accessing `dirstate-v2` repository without associated " |
|
1190 | 1190 | b"fast implementation." |
|
1191 | 1191 | ) |
|
1192 | 1192 | hint = _( |
|
1193 | 1193 | b"check `hg help config.format.use-dirstate-v2` " b"for details" |
|
1194 | 1194 | ) |
|
1195 | 1195 | if not dirstate.HAS_FAST_DIRSTATE_V2: |
|
1196 | 1196 | if slow_path == b'warn': |
|
1197 | 1197 | msg = b"warning: " + msg + b'\n' |
|
1198 | 1198 | ui.warn(msg) |
|
1199 | 1199 | if not ui.quiet: |
|
1200 | 1200 | hint = b'(' + hint + b')\n' |
|
1201 | 1201 | ui.warn(hint) |
|
1202 | 1202 | if slow_path == b'abort': |
|
1203 | 1203 | raise error.Abort(msg, hint=hint) |
|
1204 | 1204 | if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'): |
|
1205 | 1205 | options[b'persistent-nodemap.mmap'] = True |
|
1206 | 1206 | if ui.configbool(b'devel', b'persistent-nodemap'): |
|
1207 | 1207 | options[b'devel-force-nodemap'] = True |
|
1208 | 1208 | |
|
1209 | 1209 | return options |
|
1210 | 1210 | |
|
1211 | 1211 | |
|
1212 | 1212 | def makemain(**kwargs): |
|
1213 | 1213 | """Produce a type conforming to ``ilocalrepositorymain``.""" |
|
1214 | 1214 | return localrepository |
|
1215 | 1215 | |
|
1216 | 1216 | |
|
1217 | 1217 | @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) |
|
1218 | 1218 | class revlogfilestorage(object): |
|
1219 | 1219 | """File storage when using revlogs.""" |
|
1220 | 1220 | |
|
1221 | 1221 | def file(self, path): |
|
1222 | 1222 | if path.startswith(b'/'): |
|
1223 | 1223 | path = path[1:] |
|
1224 | 1224 | |
|
1225 | 1225 | return filelog.filelog(self.svfs, path) |
|
1226 | 1226 | |
|
1227 | 1227 | |
|
1228 | 1228 | @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) |
|
1229 | 1229 | class revlognarrowfilestorage(object): |
|
1230 | 1230 | """File storage when using revlogs and narrow files.""" |
|
1231 | 1231 | |
|
1232 | 1232 | def file(self, path): |
|
1233 | 1233 | if path.startswith(b'/'): |
|
1234 | 1234 | path = path[1:] |
|
1235 | 1235 | |
|
1236 | 1236 | return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch) |
|
1237 | 1237 | |
|
1238 | 1238 | |
|
1239 | 1239 | def makefilestorage(requirements, features, **kwargs): |
|
1240 | 1240 | """Produce a type conforming to ``ilocalrepositoryfilestorage``.""" |
|
1241 | 1241 | features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE) |
|
1242 | 1242 | features.add(repository.REPO_FEATURE_STREAM_CLONE) |
|
1243 | 1243 | |
|
1244 | 1244 | if requirementsmod.NARROW_REQUIREMENT in requirements: |
|
1245 | 1245 | return revlognarrowfilestorage |
|
1246 | 1246 | else: |
|
1247 | 1247 | return revlogfilestorage |
|
1248 | 1248 | |
|
1249 | 1249 | |
|
1250 | 1250 | # List of repository interfaces and factory functions for them. Each |
|
1251 | 1251 | # will be called in order during ``makelocalrepository()`` to iteratively |
|
1252 | 1252 | # derive the final type for a local repository instance. We capture the |
|
1253 | 1253 | # function as a lambda so we don't hold a reference and the module-level |
|
1254 | 1254 | # functions can be wrapped. |
|
1255 | 1255 | REPO_INTERFACES = [ |
|
1256 | 1256 | (repository.ilocalrepositorymain, lambda: makemain), |
|
1257 | 1257 | (repository.ilocalrepositoryfilestorage, lambda: makefilestorage), |
|
1258 | 1258 | ] |
|
1259 | 1259 | |
|
1260 | 1260 | |
|
1261 | 1261 | @interfaceutil.implementer(repository.ilocalrepositorymain) |
|
1262 | 1262 | class localrepository(object): |
|
1263 | 1263 | """Main class for representing local repositories. |
|
1264 | 1264 | |
|
1265 | 1265 | All local repositories are instances of this class. |
|
1266 | 1266 | |
|
1267 | 1267 | Constructed on its own, instances of this class are not usable as |
|
1268 | 1268 | repository objects. To obtain a usable repository object, call |
|
1269 | 1269 | ``hg.repository()``, ``localrepo.instance()``, or |
|
1270 | 1270 | ``localrepo.makelocalrepository()``. The latter is the lowest-level. |
|
1271 | 1271 | ``instance()`` adds support for creating new repositories. |
|
1272 | 1272 | ``hg.repository()`` adds more extension integration, including calling |
|
1273 | 1273 | ``reposetup()``. Generally speaking, ``hg.repository()`` should be |
|
1274 | 1274 | used. |
|
1275 | 1275 | """ |
|
1276 | 1276 | |
|
1277 | 1277 | _basesupported = { |
|
1278 | 1278 | requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT, |
|
1279 | 1279 | requirementsmod.CHANGELOGV2_REQUIREMENT, |
|
1280 | 1280 | requirementsmod.COPIESSDC_REQUIREMENT, |
|
1281 | requirementsmod.DIRSTATE_TRACKED_KEY_V1, | |
|
1281 | 1282 | requirementsmod.DIRSTATE_V2_REQUIREMENT, |
|
1282 | 1283 | requirementsmod.DOTENCODE_REQUIREMENT, |
|
1283 | 1284 | requirementsmod.FNCACHE_REQUIREMENT, |
|
1284 | 1285 | requirementsmod.GENERALDELTA_REQUIREMENT, |
|
1285 | 1286 | requirementsmod.INTERNAL_PHASE_REQUIREMENT, |
|
1286 | 1287 | requirementsmod.NODEMAP_REQUIREMENT, |
|
1287 | 1288 | requirementsmod.RELATIVE_SHARED_REQUIREMENT, |
|
1288 | 1289 | requirementsmod.REVLOGV1_REQUIREMENT, |
|
1289 | 1290 | requirementsmod.REVLOGV2_REQUIREMENT, |
|
1290 | 1291 | requirementsmod.SHARED_REQUIREMENT, |
|
1291 | 1292 | requirementsmod.SHARESAFE_REQUIREMENT, |
|
1292 | 1293 | requirementsmod.SPARSE_REQUIREMENT, |
|
1293 | 1294 | requirementsmod.SPARSEREVLOG_REQUIREMENT, |
|
1294 | 1295 | requirementsmod.STORE_REQUIREMENT, |
|
1295 | 1296 | requirementsmod.TREEMANIFEST_REQUIREMENT, |
|
1296 | 1297 | } |
|
1297 | 1298 | |
|
1298 | 1299 | # list of prefix for file which can be written without 'wlock' |
|
1299 | 1300 | # Extensions should extend this list when needed |
|
1300 | 1301 | _wlockfreeprefix = { |
|
1301 | 1302 | # We migh consider requiring 'wlock' for the next |
|
1302 | 1303 | # two, but pretty much all the existing code assume |
|
1303 | 1304 | # wlock is not needed so we keep them excluded for |
|
1304 | 1305 | # now. |
|
1305 | 1306 | b'hgrc', |
|
1306 | 1307 | b'requires', |
|
1307 | 1308 | # XXX cache is a complicatged business someone |
|
1308 | 1309 | # should investigate this in depth at some point |
|
1309 | 1310 | b'cache/', |
|
1310 | 1311 | # XXX shouldn't be dirstate covered by the wlock? |
|
1311 | 1312 | b'dirstate', |
|
1312 | 1313 | # XXX bisect was still a bit too messy at the time |
|
1313 | 1314 | # this changeset was introduced. Someone should fix |
|
1314 | 1315 | # the remainig bit and drop this line |
|
1315 | 1316 | b'bisect.state', |
|
1316 | 1317 | } |
|
1317 | 1318 | |
|
1318 | 1319 | def __init__( |
|
1319 | 1320 | self, |
|
1320 | 1321 | baseui, |
|
1321 | 1322 | ui, |
|
1322 | 1323 | origroot, |
|
1323 | 1324 | wdirvfs, |
|
1324 | 1325 | hgvfs, |
|
1325 | 1326 | requirements, |
|
1326 | 1327 | supportedrequirements, |
|
1327 | 1328 | sharedpath, |
|
1328 | 1329 | store, |
|
1329 | 1330 | cachevfs, |
|
1330 | 1331 | wcachevfs, |
|
1331 | 1332 | features, |
|
1332 | 1333 | intents=None, |
|
1333 | 1334 | ): |
|
1334 | 1335 | """Create a new local repository instance. |
|
1335 | 1336 | |
|
1336 | 1337 | Most callers should use ``hg.repository()``, ``localrepo.instance()``, |
|
1337 | 1338 | or ``localrepo.makelocalrepository()`` for obtaining a new repository |
|
1338 | 1339 | object. |
|
1339 | 1340 | |
|
1340 | 1341 | Arguments: |
|
1341 | 1342 | |
|
1342 | 1343 | baseui |
|
1343 | 1344 | ``ui.ui`` instance that ``ui`` argument was based off of. |
|
1344 | 1345 | |
|
1345 | 1346 | ui |
|
1346 | 1347 | ``ui.ui`` instance for use by the repository. |
|
1347 | 1348 | |
|
1348 | 1349 | origroot |
|
1349 | 1350 | ``bytes`` path to working directory root of this repository. |
|
1350 | 1351 | |
|
1351 | 1352 | wdirvfs |
|
1352 | 1353 | ``vfs.vfs`` rooted at the working directory. |
|
1353 | 1354 | |
|
1354 | 1355 | hgvfs |
|
1355 | 1356 | ``vfs.vfs`` rooted at .hg/ |
|
1356 | 1357 | |
|
1357 | 1358 | requirements |
|
1358 | 1359 | ``set`` of bytestrings representing repository opening requirements. |
|
1359 | 1360 | |
|
1360 | 1361 | supportedrequirements |
|
1361 | 1362 | ``set`` of bytestrings representing repository requirements that we |
|
1362 | 1363 | know how to open. May be a supetset of ``requirements``. |
|
1363 | 1364 | |
|
1364 | 1365 | sharedpath |
|
1365 | 1366 | ``bytes`` Defining path to storage base directory. Points to a |
|
1366 | 1367 | ``.hg/`` directory somewhere. |
|
1367 | 1368 | |
|
1368 | 1369 | store |
|
1369 | 1370 | ``store.basicstore`` (or derived) instance providing access to |
|
1370 | 1371 | versioned storage. |
|
1371 | 1372 | |
|
1372 | 1373 | cachevfs |
|
1373 | 1374 | ``vfs.vfs`` used for cache files. |
|
1374 | 1375 | |
|
1375 | 1376 | wcachevfs |
|
1376 | 1377 | ``vfs.vfs`` used for cache files related to the working copy. |
|
1377 | 1378 | |
|
1378 | 1379 | features |
|
1379 | 1380 | ``set`` of bytestrings defining features/capabilities of this |
|
1380 | 1381 | instance. |
|
1381 | 1382 | |
|
1382 | 1383 | intents |
|
1383 | 1384 | ``set`` of system strings indicating what this repo will be used |
|
1384 | 1385 | for. |
|
1385 | 1386 | """ |
|
1386 | 1387 | self.baseui = baseui |
|
1387 | 1388 | self.ui = ui |
|
1388 | 1389 | self.origroot = origroot |
|
1389 | 1390 | # vfs rooted at working directory. |
|
1390 | 1391 | self.wvfs = wdirvfs |
|
1391 | 1392 | self.root = wdirvfs.base |
|
1392 | 1393 | # vfs rooted at .hg/. Used to access most non-store paths. |
|
1393 | 1394 | self.vfs = hgvfs |
|
1394 | 1395 | self.path = hgvfs.base |
|
1395 | 1396 | self.requirements = requirements |
|
1396 | 1397 | self.nodeconstants = sha1nodeconstants |
|
1397 | 1398 | self.nullid = self.nodeconstants.nullid |
|
1398 | 1399 | self.supported = supportedrequirements |
|
1399 | 1400 | self.sharedpath = sharedpath |
|
1400 | 1401 | self.store = store |
|
1401 | 1402 | self.cachevfs = cachevfs |
|
1402 | 1403 | self.wcachevfs = wcachevfs |
|
1403 | 1404 | self.features = features |
|
1404 | 1405 | |
|
1405 | 1406 | self.filtername = None |
|
1406 | 1407 | |
|
1407 | 1408 | if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool( |
|
1408 | 1409 | b'devel', b'check-locks' |
|
1409 | 1410 | ): |
|
1410 | 1411 | self.vfs.audit = self._getvfsward(self.vfs.audit) |
|
1411 | 1412 | # A list of callback to shape the phase if no data were found. |
|
1412 | 1413 | # Callback are in the form: func(repo, roots) --> processed root. |
|
1413 | 1414 | # This list it to be filled by extension during repo setup |
|
1414 | 1415 | self._phasedefaults = [] |
|
1415 | 1416 | |
|
1416 | 1417 | color.setup(self.ui) |
|
1417 | 1418 | |
|
1418 | 1419 | self.spath = self.store.path |
|
1419 | 1420 | self.svfs = self.store.vfs |
|
1420 | 1421 | self.sjoin = self.store.join |
|
1421 | 1422 | if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool( |
|
1422 | 1423 | b'devel', b'check-locks' |
|
1423 | 1424 | ): |
|
1424 | 1425 | if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs |
|
1425 | 1426 | self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit) |
|
1426 | 1427 | else: # standard vfs |
|
1427 | 1428 | self.svfs.audit = self._getsvfsward(self.svfs.audit) |
|
1428 | 1429 | |
|
1429 | 1430 | self._dirstatevalidatewarned = False |
|
1430 | 1431 | |
|
1431 | 1432 | self._branchcaches = branchmap.BranchMapCache() |
|
1432 | 1433 | self._revbranchcache = None |
|
1433 | 1434 | self._filterpats = {} |
|
1434 | 1435 | self._datafilters = {} |
|
1435 | 1436 | self._transref = self._lockref = self._wlockref = None |
|
1436 | 1437 | |
|
1437 | 1438 | # A cache for various files under .hg/ that tracks file changes, |
|
1438 | 1439 | # (used by the filecache decorator) |
|
1439 | 1440 | # |
|
1440 | 1441 | # Maps a property name to its util.filecacheentry |
|
1441 | 1442 | self._filecache = {} |
|
1442 | 1443 | |
|
1443 | 1444 | # hold sets of revision to be filtered |
|
1444 | 1445 | # should be cleared when something might have changed the filter value: |
|
1445 | 1446 | # - new changesets, |
|
1446 | 1447 | # - phase change, |
|
1447 | 1448 | # - new obsolescence marker, |
|
1448 | 1449 | # - working directory parent change, |
|
1449 | 1450 | # - bookmark changes |
|
1450 | 1451 | self.filteredrevcache = {} |
|
1451 | 1452 | |
|
1452 | 1453 | # post-dirstate-status hooks |
|
1453 | 1454 | self._postdsstatus = [] |
|
1454 | 1455 | |
|
1455 | 1456 | # generic mapping between names and nodes |
|
1456 | 1457 | self.names = namespaces.namespaces() |
|
1457 | 1458 | |
|
1458 | 1459 | # Key to signature value. |
|
1459 | 1460 | self._sparsesignaturecache = {} |
|
1460 | 1461 | # Signature to cached matcher instance. |
|
1461 | 1462 | self._sparsematchercache = {} |
|
1462 | 1463 | |
|
1463 | 1464 | self._extrafilterid = repoview.extrafilter(ui) |
|
1464 | 1465 | |
|
1465 | 1466 | self.filecopiesmode = None |
|
1466 | 1467 | if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements: |
|
1467 | 1468 | self.filecopiesmode = b'changeset-sidedata' |
|
1468 | 1469 | |
|
1469 | 1470 | self._wanted_sidedata = set() |
|
1470 | 1471 | self._sidedata_computers = {} |
|
1471 | 1472 | sidedatamod.set_sidedata_spec_for_repo(self) |
|
1472 | 1473 | |
|
1473 | 1474 | def _getvfsward(self, origfunc): |
|
1474 | 1475 | """build a ward for self.vfs""" |
|
1475 | 1476 | rref = weakref.ref(self) |
|
1476 | 1477 | |
|
1477 | 1478 | def checkvfs(path, mode=None): |
|
1478 | 1479 | ret = origfunc(path, mode=mode) |
|
1479 | 1480 | repo = rref() |
|
1480 | 1481 | if ( |
|
1481 | 1482 | repo is None |
|
1482 | 1483 | or not util.safehasattr(repo, b'_wlockref') |
|
1483 | 1484 | or not util.safehasattr(repo, b'_lockref') |
|
1484 | 1485 | ): |
|
1485 | 1486 | return |
|
1486 | 1487 | if mode in (None, b'r', b'rb'): |
|
1487 | 1488 | return |
|
1488 | 1489 | if path.startswith(repo.path): |
|
1489 | 1490 | # truncate name relative to the repository (.hg) |
|
1490 | 1491 | path = path[len(repo.path) + 1 :] |
|
1491 | 1492 | if path.startswith(b'cache/'): |
|
1492 | 1493 | msg = b'accessing cache with vfs instead of cachevfs: "%s"' |
|
1493 | 1494 | repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs") |
|
1494 | 1495 | # path prefixes covered by 'lock' |
|
1495 | 1496 | vfs_path_prefixes = ( |
|
1496 | 1497 | b'journal.', |
|
1497 | 1498 | b'undo.', |
|
1498 | 1499 | b'strip-backup/', |
|
1499 | 1500 | b'cache/', |
|
1500 | 1501 | ) |
|
1501 | 1502 | if any(path.startswith(prefix) for prefix in vfs_path_prefixes): |
|
1502 | 1503 | if repo._currentlock(repo._lockref) is None: |
|
1503 | 1504 | repo.ui.develwarn( |
|
1504 | 1505 | b'write with no lock: "%s"' % path, |
|
1505 | 1506 | stacklevel=3, |
|
1506 | 1507 | config=b'check-locks', |
|
1507 | 1508 | ) |
|
1508 | 1509 | elif repo._currentlock(repo._wlockref) is None: |
|
1509 | 1510 | # rest of vfs files are covered by 'wlock' |
|
1510 | 1511 | # |
|
1511 | 1512 | # exclude special files |
|
1512 | 1513 | for prefix in self._wlockfreeprefix: |
|
1513 | 1514 | if path.startswith(prefix): |
|
1514 | 1515 | return |
|
1515 | 1516 | repo.ui.develwarn( |
|
1516 | 1517 | b'write with no wlock: "%s"' % path, |
|
1517 | 1518 | stacklevel=3, |
|
1518 | 1519 | config=b'check-locks', |
|
1519 | 1520 | ) |
|
1520 | 1521 | return ret |
|
1521 | 1522 | |
|
1522 | 1523 | return checkvfs |
|
1523 | 1524 | |
|
1524 | 1525 | def _getsvfsward(self, origfunc): |
|
1525 | 1526 | """build a ward for self.svfs""" |
|
1526 | 1527 | rref = weakref.ref(self) |
|
1527 | 1528 | |
|
1528 | 1529 | def checksvfs(path, mode=None): |
|
1529 | 1530 | ret = origfunc(path, mode=mode) |
|
1530 | 1531 | repo = rref() |
|
1531 | 1532 | if repo is None or not util.safehasattr(repo, b'_lockref'): |
|
1532 | 1533 | return |
|
1533 | 1534 | if mode in (None, b'r', b'rb'): |
|
1534 | 1535 | return |
|
1535 | 1536 | if path.startswith(repo.sharedpath): |
|
1536 | 1537 | # truncate name relative to the repository (.hg) |
|
1537 | 1538 | path = path[len(repo.sharedpath) + 1 :] |
|
1538 | 1539 | if repo._currentlock(repo._lockref) is None: |
|
1539 | 1540 | repo.ui.develwarn( |
|
1540 | 1541 | b'write with no lock: "%s"' % path, stacklevel=4 |
|
1541 | 1542 | ) |
|
1542 | 1543 | return ret |
|
1543 | 1544 | |
|
1544 | 1545 | return checksvfs |
|
1545 | 1546 | |
|
1546 | 1547 | def close(self): |
|
1547 | 1548 | self._writecaches() |
|
1548 | 1549 | |
|
1549 | 1550 | def _writecaches(self): |
|
1550 | 1551 | if self._revbranchcache: |
|
1551 | 1552 | self._revbranchcache.write() |
|
1552 | 1553 | |
|
1553 | 1554 | def _restrictcapabilities(self, caps): |
|
1554 | 1555 | if self.ui.configbool(b'experimental', b'bundle2-advertise'): |
|
1555 | 1556 | caps = set(caps) |
|
1556 | 1557 | capsblob = bundle2.encodecaps( |
|
1557 | 1558 | bundle2.getrepocaps(self, role=b'client') |
|
1558 | 1559 | ) |
|
1559 | 1560 | caps.add(b'bundle2=' + urlreq.quote(capsblob)) |
|
1560 | 1561 | if self.ui.configbool(b'experimental', b'narrow'): |
|
1561 | 1562 | caps.add(wireprototypes.NARROWCAP) |
|
1562 | 1563 | return caps |
|
1563 | 1564 | |
|
1564 | 1565 | # Don't cache auditor/nofsauditor, or you'll end up with reference cycle: |
|
1565 | 1566 | # self -> auditor -> self._checknested -> self |
|
1566 | 1567 | |
|
1567 | 1568 | @property |
|
1568 | 1569 | def auditor(self): |
|
1569 | 1570 | # This is only used by context.workingctx.match in order to |
|
1570 | 1571 | # detect files in subrepos. |
|
1571 | 1572 | return pathutil.pathauditor(self.root, callback=self._checknested) |
|
1572 | 1573 | |
|
1573 | 1574 | @property |
|
1574 | 1575 | def nofsauditor(self): |
|
1575 | 1576 | # This is only used by context.basectx.match in order to detect |
|
1576 | 1577 | # files in subrepos. |
|
1577 | 1578 | return pathutil.pathauditor( |
|
1578 | 1579 | self.root, callback=self._checknested, realfs=False, cached=True |
|
1579 | 1580 | ) |
|
1580 | 1581 | |
|
1581 | 1582 | def _checknested(self, path): |
|
1582 | 1583 | """Determine if path is a legal nested repository.""" |
|
1583 | 1584 | if not path.startswith(self.root): |
|
1584 | 1585 | return False |
|
1585 | 1586 | subpath = path[len(self.root) + 1 :] |
|
1586 | 1587 | normsubpath = util.pconvert(subpath) |
|
1587 | 1588 | |
|
1588 | 1589 | # XXX: Checking against the current working copy is wrong in |
|
1589 | 1590 | # the sense that it can reject things like |
|
1590 | 1591 | # |
|
1591 | 1592 | # $ hg cat -r 10 sub/x.txt |
|
1592 | 1593 | # |
|
1593 | 1594 | # if sub/ is no longer a subrepository in the working copy |
|
1594 | 1595 | # parent revision. |
|
1595 | 1596 | # |
|
1596 | 1597 | # However, it can of course also allow things that would have |
|
1597 | 1598 | # been rejected before, such as the above cat command if sub/ |
|
1598 | 1599 | # is a subrepository now, but was a normal directory before. |
|
1599 | 1600 | # The old path auditor would have rejected by mistake since it |
|
1600 | 1601 | # panics when it sees sub/.hg/. |
|
1601 | 1602 | # |
|
1602 | 1603 | # All in all, checking against the working copy seems sensible |
|
1603 | 1604 | # since we want to prevent access to nested repositories on |
|
1604 | 1605 | # the filesystem *now*. |
|
1605 | 1606 | ctx = self[None] |
|
1606 | 1607 | parts = util.splitpath(subpath) |
|
1607 | 1608 | while parts: |
|
1608 | 1609 | prefix = b'/'.join(parts) |
|
1609 | 1610 | if prefix in ctx.substate: |
|
1610 | 1611 | if prefix == normsubpath: |
|
1611 | 1612 | return True |
|
1612 | 1613 | else: |
|
1613 | 1614 | sub = ctx.sub(prefix) |
|
1614 | 1615 | return sub.checknested(subpath[len(prefix) + 1 :]) |
|
1615 | 1616 | else: |
|
1616 | 1617 | parts.pop() |
|
1617 | 1618 | return False |
|
1618 | 1619 | |
|
1619 | 1620 | def peer(self): |
|
1620 | 1621 | return localpeer(self) # not cached to avoid reference cycle |
|
1621 | 1622 | |
|
1622 | 1623 | def unfiltered(self): |
|
1623 | 1624 | """Return unfiltered version of the repository |
|
1624 | 1625 | |
|
1625 | 1626 | Intended to be overwritten by filtered repo.""" |
|
1626 | 1627 | return self |
|
1627 | 1628 | |
|
1628 | 1629 | def filtered(self, name, visibilityexceptions=None): |
|
1629 | 1630 | """Return a filtered version of a repository |
|
1630 | 1631 | |
|
1631 | 1632 | The `name` parameter is the identifier of the requested view. This |
|
1632 | 1633 | will return a repoview object set "exactly" to the specified view. |
|
1633 | 1634 | |
|
1634 | 1635 | This function does not apply recursive filtering to a repository. For |
|
1635 | 1636 | example calling `repo.filtered("served")` will return a repoview using |
|
1636 | 1637 | the "served" view, regardless of the initial view used by `repo`. |
|
1637 | 1638 | |
|
1638 | 1639 | In other word, there is always only one level of `repoview` "filtering". |
|
1639 | 1640 | """ |
|
1640 | 1641 | if self._extrafilterid is not None and b'%' not in name: |
|
1641 | 1642 | name = name + b'%' + self._extrafilterid |
|
1642 | 1643 | |
|
1643 | 1644 | cls = repoview.newtype(self.unfiltered().__class__) |
|
1644 | 1645 | return cls(self, name, visibilityexceptions) |
|
1645 | 1646 | |
|
1646 | 1647 | @mixedrepostorecache( |
|
1647 | 1648 | (b'bookmarks', b'plain'), |
|
1648 | 1649 | (b'bookmarks.current', b'plain'), |
|
1649 | 1650 | (b'bookmarks', b''), |
|
1650 | 1651 | (b'00changelog.i', b''), |
|
1651 | 1652 | ) |
|
1652 | 1653 | def _bookmarks(self): |
|
1653 | 1654 | # Since the multiple files involved in the transaction cannot be |
|
1654 | 1655 | # written atomically (with current repository format), there is a race |
|
1655 | 1656 | # condition here. |
|
1656 | 1657 | # |
|
1657 | 1658 | # 1) changelog content A is read |
|
1658 | 1659 | # 2) outside transaction update changelog to content B |
|
1659 | 1660 | # 3) outside transaction update bookmark file referring to content B |
|
1660 | 1661 | # 4) bookmarks file content is read and filtered against changelog-A |
|
1661 | 1662 | # |
|
1662 | 1663 | # When this happens, bookmarks against nodes missing from A are dropped. |
|
1663 | 1664 | # |
|
1664 | 1665 | # Having this happening during read is not great, but it become worse |
|
1665 | 1666 | # when this happen during write because the bookmarks to the "unknown" |
|
1666 | 1667 | # nodes will be dropped for good. However, writes happen within locks. |
|
1667 | 1668 | # This locking makes it possible to have a race free consistent read. |
|
1668 | 1669 | # For this purpose data read from disc before locking are |
|
1669 | 1670 | # "invalidated" right after the locks are taken. This invalidations are |
|
1670 | 1671 | # "light", the `filecache` mechanism keep the data in memory and will |
|
1671 | 1672 | # reuse them if the underlying files did not changed. Not parsing the |
|
1672 | 1673 | # same data multiple times helps performances. |
|
1673 | 1674 | # |
|
1674 | 1675 | # Unfortunately in the case describe above, the files tracked by the |
|
1675 | 1676 | # bookmarks file cache might not have changed, but the in-memory |
|
1676 | 1677 | # content is still "wrong" because we used an older changelog content |
|
1677 | 1678 | # to process the on-disk data. So after locking, the changelog would be |
|
1678 | 1679 | # refreshed but `_bookmarks` would be preserved. |
|
1679 | 1680 | # Adding `00changelog.i` to the list of tracked file is not |
|
1680 | 1681 | # enough, because at the time we build the content for `_bookmarks` in |
|
1681 | 1682 | # (4), the changelog file has already diverged from the content used |
|
1682 | 1683 | # for loading `changelog` in (1) |
|
1683 | 1684 | # |
|
1684 | 1685 | # To prevent the issue, we force the changelog to be explicitly |
|
1685 | 1686 | # reloaded while computing `_bookmarks`. The data race can still happen |
|
1686 | 1687 | # without the lock (with a narrower window), but it would no longer go |
|
1687 | 1688 | # undetected during the lock time refresh. |
|
1688 | 1689 | # |
|
1689 | 1690 | # The new schedule is as follow |
|
1690 | 1691 | # |
|
1691 | 1692 | # 1) filecache logic detect that `_bookmarks` needs to be computed |
|
1692 | 1693 | # 2) cachestat for `bookmarks` and `changelog` are captured (for book) |
|
1693 | 1694 | # 3) We force `changelog` filecache to be tested |
|
1694 | 1695 | # 4) cachestat for `changelog` are captured (for changelog) |
|
1695 | 1696 | # 5) `_bookmarks` is computed and cached |
|
1696 | 1697 | # |
|
1697 | 1698 | # The step in (3) ensure we have a changelog at least as recent as the |
|
1698 | 1699 | # cache stat computed in (1). As a result at locking time: |
|
1699 | 1700 | # * if the changelog did not changed since (1) -> we can reuse the data |
|
1700 | 1701 | # * otherwise -> the bookmarks get refreshed. |
|
1701 | 1702 | self._refreshchangelog() |
|
1702 | 1703 | return bookmarks.bmstore(self) |
|
1703 | 1704 | |
|
1704 | 1705 | def _refreshchangelog(self): |
|
1705 | 1706 | """make sure the in memory changelog match the on-disk one""" |
|
1706 | 1707 | if 'changelog' in vars(self) and self.currenttransaction() is None: |
|
1707 | 1708 | del self.changelog |
|
1708 | 1709 | |
|
1709 | 1710 | @property |
|
1710 | 1711 | def _activebookmark(self): |
|
1711 | 1712 | return self._bookmarks.active |
|
1712 | 1713 | |
|
1713 | 1714 | # _phasesets depend on changelog. what we need is to call |
|
1714 | 1715 | # _phasecache.invalidate() if '00changelog.i' was changed, but it |
|
1715 | 1716 | # can't be easily expressed in filecache mechanism. |
|
1716 | 1717 | @storecache(b'phaseroots', b'00changelog.i') |
|
1717 | 1718 | def _phasecache(self): |
|
1718 | 1719 | return phases.phasecache(self, self._phasedefaults) |
|
1719 | 1720 | |
|
1720 | 1721 | @storecache(b'obsstore') |
|
1721 | 1722 | def obsstore(self): |
|
1722 | 1723 | return obsolete.makestore(self.ui, self) |
|
1723 | 1724 | |
|
1724 | 1725 | @changelogcache() |
|
1725 | 1726 | def changelog(repo): |
|
1726 | 1727 | # load dirstate before changelog to avoid race see issue6303 |
|
1727 | 1728 | repo.dirstate.prefetch_parents() |
|
1728 | 1729 | return repo.store.changelog( |
|
1729 | 1730 | txnutil.mayhavepending(repo.root), |
|
1730 | 1731 | concurrencychecker=revlogchecker.get_checker(repo.ui, b'changelog'), |
|
1731 | 1732 | ) |
|
1732 | 1733 | |
|
1733 | 1734 | @manifestlogcache() |
|
1734 | 1735 | def manifestlog(self): |
|
1735 | 1736 | return self.store.manifestlog(self, self._storenarrowmatch) |
|
1736 | 1737 | |
|
1737 | 1738 | @repofilecache(b'dirstate') |
|
1738 | 1739 | def dirstate(self): |
|
1739 | 1740 | return self._makedirstate() |
|
1740 | 1741 | |
|
1741 | 1742 | def _makedirstate(self): |
|
1742 | 1743 | """Extension point for wrapping the dirstate per-repo.""" |
|
1743 | 1744 | sparsematchfn = lambda: sparse.matcher(self) |
|
1744 | 1745 | v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT |
|
1746 | tk = requirementsmod.DIRSTATE_TRACKED_KEY_V1 | |
|
1745 | 1747 | use_dirstate_v2 = v2_req in self.requirements |
|
1748 | use_tracked_key = tk in self.requirements | |
|
1746 | 1749 | |
|
1747 | 1750 | return dirstate.dirstate( |
|
1748 | 1751 | self.vfs, |
|
1749 | 1752 | self.ui, |
|
1750 | 1753 | self.root, |
|
1751 | 1754 | self._dirstatevalidate, |
|
1752 | 1755 | sparsematchfn, |
|
1753 | 1756 | self.nodeconstants, |
|
1754 | 1757 | use_dirstate_v2, |
|
1758 | use_tracked_key=use_tracked_key, | |
|
1755 | 1759 | ) |
|
1756 | 1760 | |
|
1757 | 1761 | def _dirstatevalidate(self, node): |
|
1758 | 1762 | try: |
|
1759 | 1763 | self.changelog.rev(node) |
|
1760 | 1764 | return node |
|
1761 | 1765 | except error.LookupError: |
|
1762 | 1766 | if not self._dirstatevalidatewarned: |
|
1763 | 1767 | self._dirstatevalidatewarned = True |
|
1764 | 1768 | self.ui.warn( |
|
1765 | 1769 | _(b"warning: ignoring unknown working parent %s!\n") |
|
1766 | 1770 | % short(node) |
|
1767 | 1771 | ) |
|
1768 | 1772 | return self.nullid |
|
1769 | 1773 | |
|
1770 | 1774 | @storecache(narrowspec.FILENAME) |
|
1771 | 1775 | def narrowpats(self): |
|
1772 | 1776 | """matcher patterns for this repository's narrowspec |
|
1773 | 1777 | |
|
1774 | 1778 | A tuple of (includes, excludes). |
|
1775 | 1779 | """ |
|
1776 | 1780 | return narrowspec.load(self) |
|
1777 | 1781 | |
|
1778 | 1782 | @storecache(narrowspec.FILENAME) |
|
1779 | 1783 | def _storenarrowmatch(self): |
|
1780 | 1784 | if requirementsmod.NARROW_REQUIREMENT not in self.requirements: |
|
1781 | 1785 | return matchmod.always() |
|
1782 | 1786 | include, exclude = self.narrowpats |
|
1783 | 1787 | return narrowspec.match(self.root, include=include, exclude=exclude) |
|
1784 | 1788 | |
|
1785 | 1789 | @storecache(narrowspec.FILENAME) |
|
1786 | 1790 | def _narrowmatch(self): |
|
1787 | 1791 | if requirementsmod.NARROW_REQUIREMENT not in self.requirements: |
|
1788 | 1792 | return matchmod.always() |
|
1789 | 1793 | narrowspec.checkworkingcopynarrowspec(self) |
|
1790 | 1794 | include, exclude = self.narrowpats |
|
1791 | 1795 | return narrowspec.match(self.root, include=include, exclude=exclude) |
|
1792 | 1796 | |
|
1793 | 1797 | def narrowmatch(self, match=None, includeexact=False): |
|
1794 | 1798 | """matcher corresponding the the repo's narrowspec |
|
1795 | 1799 | |
|
1796 | 1800 | If `match` is given, then that will be intersected with the narrow |
|
1797 | 1801 | matcher. |
|
1798 | 1802 | |
|
1799 | 1803 | If `includeexact` is True, then any exact matches from `match` will |
|
1800 | 1804 | be included even if they're outside the narrowspec. |
|
1801 | 1805 | """ |
|
1802 | 1806 | if match: |
|
1803 | 1807 | if includeexact and not self._narrowmatch.always(): |
|
1804 | 1808 | # do not exclude explicitly-specified paths so that they can |
|
1805 | 1809 | # be warned later on |
|
1806 | 1810 | em = matchmod.exact(match.files()) |
|
1807 | 1811 | nm = matchmod.unionmatcher([self._narrowmatch, em]) |
|
1808 | 1812 | return matchmod.intersectmatchers(match, nm) |
|
1809 | 1813 | return matchmod.intersectmatchers(match, self._narrowmatch) |
|
1810 | 1814 | return self._narrowmatch |
|
1811 | 1815 | |
|
1812 | 1816 | def setnarrowpats(self, newincludes, newexcludes): |
|
1813 | 1817 | narrowspec.save(self, newincludes, newexcludes) |
|
1814 | 1818 | self.invalidate(clearfilecache=True) |
|
1815 | 1819 | |
|
1816 | 1820 | @unfilteredpropertycache |
|
1817 | 1821 | def _quick_access_changeid_null(self): |
|
1818 | 1822 | return { |
|
1819 | 1823 | b'null': (nullrev, self.nodeconstants.nullid), |
|
1820 | 1824 | nullrev: (nullrev, self.nodeconstants.nullid), |
|
1821 | 1825 | self.nullid: (nullrev, self.nullid), |
|
1822 | 1826 | } |
|
1823 | 1827 | |
|
1824 | 1828 | @unfilteredpropertycache |
|
1825 | 1829 | def _quick_access_changeid_wc(self): |
|
1826 | 1830 | # also fast path access to the working copy parents |
|
1827 | 1831 | # however, only do it for filter that ensure wc is visible. |
|
1828 | 1832 | quick = self._quick_access_changeid_null.copy() |
|
1829 | 1833 | cl = self.unfiltered().changelog |
|
1830 | 1834 | for node in self.dirstate.parents(): |
|
1831 | 1835 | if node == self.nullid: |
|
1832 | 1836 | continue |
|
1833 | 1837 | rev = cl.index.get_rev(node) |
|
1834 | 1838 | if rev is None: |
|
1835 | 1839 | # unknown working copy parent case: |
|
1836 | 1840 | # |
|
1837 | 1841 | # skip the fast path and let higher code deal with it |
|
1838 | 1842 | continue |
|
1839 | 1843 | pair = (rev, node) |
|
1840 | 1844 | quick[rev] = pair |
|
1841 | 1845 | quick[node] = pair |
|
1842 | 1846 | # also add the parents of the parents |
|
1843 | 1847 | for r in cl.parentrevs(rev): |
|
1844 | 1848 | if r == nullrev: |
|
1845 | 1849 | continue |
|
1846 | 1850 | n = cl.node(r) |
|
1847 | 1851 | pair = (r, n) |
|
1848 | 1852 | quick[r] = pair |
|
1849 | 1853 | quick[n] = pair |
|
1850 | 1854 | p1node = self.dirstate.p1() |
|
1851 | 1855 | if p1node != self.nullid: |
|
1852 | 1856 | quick[b'.'] = quick[p1node] |
|
1853 | 1857 | return quick |
|
1854 | 1858 | |
|
1855 | 1859 | @unfilteredmethod |
|
1856 | 1860 | def _quick_access_changeid_invalidate(self): |
|
1857 | 1861 | if '_quick_access_changeid_wc' in vars(self): |
|
1858 | 1862 | del self.__dict__['_quick_access_changeid_wc'] |
|
1859 | 1863 | |
|
1860 | 1864 | @property |
|
1861 | 1865 | def _quick_access_changeid(self): |
|
1862 | 1866 | """an helper dictionnary for __getitem__ calls |
|
1863 | 1867 | |
|
1864 | 1868 | This contains a list of symbol we can recognise right away without |
|
1865 | 1869 | further processing. |
|
1866 | 1870 | """ |
|
1867 | 1871 | if self.filtername in repoview.filter_has_wc: |
|
1868 | 1872 | return self._quick_access_changeid_wc |
|
1869 | 1873 | return self._quick_access_changeid_null |
|
1870 | 1874 | |
|
1871 | 1875 | def __getitem__(self, changeid): |
|
1872 | 1876 | # dealing with special cases |
|
1873 | 1877 | if changeid is None: |
|
1874 | 1878 | return context.workingctx(self) |
|
1875 | 1879 | if isinstance(changeid, context.basectx): |
|
1876 | 1880 | return changeid |
|
1877 | 1881 | |
|
1878 | 1882 | # dealing with multiple revisions |
|
1879 | 1883 | if isinstance(changeid, slice): |
|
1880 | 1884 | # wdirrev isn't contiguous so the slice shouldn't include it |
|
1881 | 1885 | return [ |
|
1882 | 1886 | self[i] |
|
1883 | 1887 | for i in pycompat.xrange(*changeid.indices(len(self))) |
|
1884 | 1888 | if i not in self.changelog.filteredrevs |
|
1885 | 1889 | ] |
|
1886 | 1890 | |
|
1887 | 1891 | # dealing with some special values |
|
1888 | 1892 | quick_access = self._quick_access_changeid.get(changeid) |
|
1889 | 1893 | if quick_access is not None: |
|
1890 | 1894 | rev, node = quick_access |
|
1891 | 1895 | return context.changectx(self, rev, node, maybe_filtered=False) |
|
1892 | 1896 | if changeid == b'tip': |
|
1893 | 1897 | node = self.changelog.tip() |
|
1894 | 1898 | rev = self.changelog.rev(node) |
|
1895 | 1899 | return context.changectx(self, rev, node) |
|
1896 | 1900 | |
|
1897 | 1901 | # dealing with arbitrary values |
|
1898 | 1902 | try: |
|
1899 | 1903 | if isinstance(changeid, int): |
|
1900 | 1904 | node = self.changelog.node(changeid) |
|
1901 | 1905 | rev = changeid |
|
1902 | 1906 | elif changeid == b'.': |
|
1903 | 1907 | # this is a hack to delay/avoid loading obsmarkers |
|
1904 | 1908 | # when we know that '.' won't be hidden |
|
1905 | 1909 | node = self.dirstate.p1() |
|
1906 | 1910 | rev = self.unfiltered().changelog.rev(node) |
|
1907 | 1911 | elif len(changeid) == self.nodeconstants.nodelen: |
|
1908 | 1912 | try: |
|
1909 | 1913 | node = changeid |
|
1910 | 1914 | rev = self.changelog.rev(changeid) |
|
1911 | 1915 | except error.FilteredLookupError: |
|
1912 | 1916 | changeid = hex(changeid) # for the error message |
|
1913 | 1917 | raise |
|
1914 | 1918 | except LookupError: |
|
1915 | 1919 | # check if it might have come from damaged dirstate |
|
1916 | 1920 | # |
|
1917 | 1921 | # XXX we could avoid the unfiltered if we had a recognizable |
|
1918 | 1922 | # exception for filtered changeset access |
|
1919 | 1923 | if ( |
|
1920 | 1924 | self.local() |
|
1921 | 1925 | and changeid in self.unfiltered().dirstate.parents() |
|
1922 | 1926 | ): |
|
1923 | 1927 | msg = _(b"working directory has unknown parent '%s'!") |
|
1924 | 1928 | raise error.Abort(msg % short(changeid)) |
|
1925 | 1929 | changeid = hex(changeid) # for the error message |
|
1926 | 1930 | raise |
|
1927 | 1931 | |
|
1928 | 1932 | elif len(changeid) == 2 * self.nodeconstants.nodelen: |
|
1929 | 1933 | node = bin(changeid) |
|
1930 | 1934 | rev = self.changelog.rev(node) |
|
1931 | 1935 | else: |
|
1932 | 1936 | raise error.ProgrammingError( |
|
1933 | 1937 | b"unsupported changeid '%s' of type %s" |
|
1934 | 1938 | % (changeid, pycompat.bytestr(type(changeid))) |
|
1935 | 1939 | ) |
|
1936 | 1940 | |
|
1937 | 1941 | return context.changectx(self, rev, node) |
|
1938 | 1942 | |
|
1939 | 1943 | except (error.FilteredIndexError, error.FilteredLookupError): |
|
1940 | 1944 | raise error.FilteredRepoLookupError( |
|
1941 | 1945 | _(b"filtered revision '%s'") % pycompat.bytestr(changeid) |
|
1942 | 1946 | ) |
|
1943 | 1947 | except (IndexError, LookupError): |
|
1944 | 1948 | raise error.RepoLookupError( |
|
1945 | 1949 | _(b"unknown revision '%s'") % pycompat.bytestr(changeid) |
|
1946 | 1950 | ) |
|
1947 | 1951 | except error.WdirUnsupported: |
|
1948 | 1952 | return context.workingctx(self) |
|
1949 | 1953 | |
|
1950 | 1954 | def __contains__(self, changeid): |
|
1951 | 1955 | """True if the given changeid exists""" |
|
1952 | 1956 | try: |
|
1953 | 1957 | self[changeid] |
|
1954 | 1958 | return True |
|
1955 | 1959 | except error.RepoLookupError: |
|
1956 | 1960 | return False |
|
1957 | 1961 | |
|
1958 | 1962 | def __nonzero__(self): |
|
1959 | 1963 | return True |
|
1960 | 1964 | |
|
1961 | 1965 | __bool__ = __nonzero__ |
|
1962 | 1966 | |
|
1963 | 1967 | def __len__(self): |
|
1964 | 1968 | # no need to pay the cost of repoview.changelog |
|
1965 | 1969 | unfi = self.unfiltered() |
|
1966 | 1970 | return len(unfi.changelog) |
|
1967 | 1971 | |
|
1968 | 1972 | def __iter__(self): |
|
1969 | 1973 | return iter(self.changelog) |
|
1970 | 1974 | |
|
1971 | 1975 | def revs(self, expr, *args): |
|
1972 | 1976 | """Find revisions matching a revset. |
|
1973 | 1977 | |
|
1974 | 1978 | The revset is specified as a string ``expr`` that may contain |
|
1975 | 1979 | %-formatting to escape certain types. See ``revsetlang.formatspec``. |
|
1976 | 1980 | |
|
1977 | 1981 | Revset aliases from the configuration are not expanded. To expand |
|
1978 | 1982 | user aliases, consider calling ``scmutil.revrange()`` or |
|
1979 | 1983 | ``repo.anyrevs([expr], user=True)``. |
|
1980 | 1984 | |
|
1981 | 1985 | Returns a smartset.abstractsmartset, which is a list-like interface |
|
1982 | 1986 | that contains integer revisions. |
|
1983 | 1987 | """ |
|
1984 | 1988 | tree = revsetlang.spectree(expr, *args) |
|
1985 | 1989 | return revset.makematcher(tree)(self) |
|
1986 | 1990 | |
|
1987 | 1991 | def set(self, expr, *args): |
|
1988 | 1992 | """Find revisions matching a revset and emit changectx instances. |
|
1989 | 1993 | |
|
1990 | 1994 | This is a convenience wrapper around ``revs()`` that iterates the |
|
1991 | 1995 | result and is a generator of changectx instances. |
|
1992 | 1996 | |
|
1993 | 1997 | Revset aliases from the configuration are not expanded. To expand |
|
1994 | 1998 | user aliases, consider calling ``scmutil.revrange()``. |
|
1995 | 1999 | """ |
|
1996 | 2000 | for r in self.revs(expr, *args): |
|
1997 | 2001 | yield self[r] |
|
1998 | 2002 | |
|
1999 | 2003 | def anyrevs(self, specs, user=False, localalias=None): |
|
2000 | 2004 | """Find revisions matching one of the given revsets. |
|
2001 | 2005 | |
|
2002 | 2006 | Revset aliases from the configuration are not expanded by default. To |
|
2003 | 2007 | expand user aliases, specify ``user=True``. To provide some local |
|
2004 | 2008 | definitions overriding user aliases, set ``localalias`` to |
|
2005 | 2009 | ``{name: definitionstring}``. |
|
2006 | 2010 | """ |
|
2007 | 2011 | if specs == [b'null']: |
|
2008 | 2012 | return revset.baseset([nullrev]) |
|
2009 | 2013 | if specs == [b'.']: |
|
2010 | 2014 | quick_data = self._quick_access_changeid.get(b'.') |
|
2011 | 2015 | if quick_data is not None: |
|
2012 | 2016 | return revset.baseset([quick_data[0]]) |
|
2013 | 2017 | if user: |
|
2014 | 2018 | m = revset.matchany( |
|
2015 | 2019 | self.ui, |
|
2016 | 2020 | specs, |
|
2017 | 2021 | lookup=revset.lookupfn(self), |
|
2018 | 2022 | localalias=localalias, |
|
2019 | 2023 | ) |
|
2020 | 2024 | else: |
|
2021 | 2025 | m = revset.matchany(None, specs, localalias=localalias) |
|
2022 | 2026 | return m(self) |
|
2023 | 2027 | |
|
2024 | 2028 | def url(self): |
|
2025 | 2029 | return b'file:' + self.root |
|
2026 | 2030 | |
|
2027 | 2031 | def hook(self, name, throw=False, **args): |
|
2028 | 2032 | """Call a hook, passing this repo instance. |
|
2029 | 2033 | |
|
2030 | 2034 | This a convenience method to aid invoking hooks. Extensions likely |
|
2031 | 2035 | won't call this unless they have registered a custom hook or are |
|
2032 | 2036 | replacing code that is expected to call a hook. |
|
2033 | 2037 | """ |
|
2034 | 2038 | return hook.hook(self.ui, self, name, throw, **args) |
|
2035 | 2039 | |
|
2036 | 2040 | @filteredpropertycache |
|
2037 | 2041 | def _tagscache(self): |
|
2038 | 2042 | """Returns a tagscache object that contains various tags related |
|
2039 | 2043 | caches.""" |
|
2040 | 2044 | |
|
2041 | 2045 | # This simplifies its cache management by having one decorated |
|
2042 | 2046 | # function (this one) and the rest simply fetch things from it. |
|
2043 | 2047 | class tagscache(object): |
|
2044 | 2048 | def __init__(self): |
|
2045 | 2049 | # These two define the set of tags for this repository. tags |
|
2046 | 2050 | # maps tag name to node; tagtypes maps tag name to 'global' or |
|
2047 | 2051 | # 'local'. (Global tags are defined by .hgtags across all |
|
2048 | 2052 | # heads, and local tags are defined in .hg/localtags.) |
|
2049 | 2053 | # They constitute the in-memory cache of tags. |
|
2050 | 2054 | self.tags = self.tagtypes = None |
|
2051 | 2055 | |
|
2052 | 2056 | self.nodetagscache = self.tagslist = None |
|
2053 | 2057 | |
|
2054 | 2058 | cache = tagscache() |
|
2055 | 2059 | cache.tags, cache.tagtypes = self._findtags() |
|
2056 | 2060 | |
|
2057 | 2061 | return cache |
|
2058 | 2062 | |
|
2059 | 2063 | def tags(self): |
|
2060 | 2064 | '''return a mapping of tag to node''' |
|
2061 | 2065 | t = {} |
|
2062 | 2066 | if self.changelog.filteredrevs: |
|
2063 | 2067 | tags, tt = self._findtags() |
|
2064 | 2068 | else: |
|
2065 | 2069 | tags = self._tagscache.tags |
|
2066 | 2070 | rev = self.changelog.rev |
|
2067 | 2071 | for k, v in pycompat.iteritems(tags): |
|
2068 | 2072 | try: |
|
2069 | 2073 | # ignore tags to unknown nodes |
|
2070 | 2074 | rev(v) |
|
2071 | 2075 | t[k] = v |
|
2072 | 2076 | except (error.LookupError, ValueError): |
|
2073 | 2077 | pass |
|
2074 | 2078 | return t |
|
2075 | 2079 | |
|
2076 | 2080 | def _findtags(self): |
|
2077 | 2081 | """Do the hard work of finding tags. Return a pair of dicts |
|
2078 | 2082 | (tags, tagtypes) where tags maps tag name to node, and tagtypes |
|
2079 | 2083 | maps tag name to a string like \'global\' or \'local\'. |
|
2080 | 2084 | Subclasses or extensions are free to add their own tags, but |
|
2081 | 2085 | should be aware that the returned dicts will be retained for the |
|
2082 | 2086 | duration of the localrepo object.""" |
|
2083 | 2087 | |
|
2084 | 2088 | # XXX what tagtype should subclasses/extensions use? Currently |
|
2085 | 2089 | # mq and bookmarks add tags, but do not set the tagtype at all. |
|
2086 | 2090 | # Should each extension invent its own tag type? Should there |
|
2087 | 2091 | # be one tagtype for all such "virtual" tags? Or is the status |
|
2088 | 2092 | # quo fine? |
|
2089 | 2093 | |
|
2090 | 2094 | # map tag name to (node, hist) |
|
2091 | 2095 | alltags = tagsmod.findglobaltags(self.ui, self) |
|
2092 | 2096 | # map tag name to tag type |
|
2093 | 2097 | tagtypes = {tag: b'global' for tag in alltags} |
|
2094 | 2098 | |
|
2095 | 2099 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) |
|
2096 | 2100 | |
|
2097 | 2101 | # Build the return dicts. Have to re-encode tag names because |
|
2098 | 2102 | # the tags module always uses UTF-8 (in order not to lose info |
|
2099 | 2103 | # writing to the cache), but the rest of Mercurial wants them in |
|
2100 | 2104 | # local encoding. |
|
2101 | 2105 | tags = {} |
|
2102 | 2106 | for (name, (node, hist)) in pycompat.iteritems(alltags): |
|
2103 | 2107 | if node != self.nullid: |
|
2104 | 2108 | tags[encoding.tolocal(name)] = node |
|
2105 | 2109 | tags[b'tip'] = self.changelog.tip() |
|
2106 | 2110 | tagtypes = { |
|
2107 | 2111 | encoding.tolocal(name): value |
|
2108 | 2112 | for (name, value) in pycompat.iteritems(tagtypes) |
|
2109 | 2113 | } |
|
2110 | 2114 | return (tags, tagtypes) |
|
2111 | 2115 | |
|
2112 | 2116 | def tagtype(self, tagname): |
|
2113 | 2117 | """ |
|
2114 | 2118 | return the type of the given tag. result can be: |
|
2115 | 2119 | |
|
2116 | 2120 | 'local' : a local tag |
|
2117 | 2121 | 'global' : a global tag |
|
2118 | 2122 | None : tag does not exist |
|
2119 | 2123 | """ |
|
2120 | 2124 | |
|
2121 | 2125 | return self._tagscache.tagtypes.get(tagname) |
|
2122 | 2126 | |
|
2123 | 2127 | def tagslist(self): |
|
2124 | 2128 | '''return a list of tags ordered by revision''' |
|
2125 | 2129 | if not self._tagscache.tagslist: |
|
2126 | 2130 | l = [] |
|
2127 | 2131 | for t, n in pycompat.iteritems(self.tags()): |
|
2128 | 2132 | l.append((self.changelog.rev(n), t, n)) |
|
2129 | 2133 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] |
|
2130 | 2134 | |
|
2131 | 2135 | return self._tagscache.tagslist |
|
2132 | 2136 | |
|
2133 | 2137 | def nodetags(self, node): |
|
2134 | 2138 | '''return the tags associated with a node''' |
|
2135 | 2139 | if not self._tagscache.nodetagscache: |
|
2136 | 2140 | nodetagscache = {} |
|
2137 | 2141 | for t, n in pycompat.iteritems(self._tagscache.tags): |
|
2138 | 2142 | nodetagscache.setdefault(n, []).append(t) |
|
2139 | 2143 | for tags in pycompat.itervalues(nodetagscache): |
|
2140 | 2144 | tags.sort() |
|
2141 | 2145 | self._tagscache.nodetagscache = nodetagscache |
|
2142 | 2146 | return self._tagscache.nodetagscache.get(node, []) |
|
2143 | 2147 | |
|
2144 | 2148 | def nodebookmarks(self, node): |
|
2145 | 2149 | """return the list of bookmarks pointing to the specified node""" |
|
2146 | 2150 | return self._bookmarks.names(node) |
|
2147 | 2151 | |
|
2148 | 2152 | def branchmap(self): |
|
2149 | 2153 | """returns a dictionary {branch: [branchheads]} with branchheads |
|
2150 | 2154 | ordered by increasing revision number""" |
|
2151 | 2155 | return self._branchcaches[self] |
|
2152 | 2156 | |
|
2153 | 2157 | @unfilteredmethod |
|
2154 | 2158 | def revbranchcache(self): |
|
2155 | 2159 | if not self._revbranchcache: |
|
2156 | 2160 | self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) |
|
2157 | 2161 | return self._revbranchcache |
|
2158 | 2162 | |
|
2159 | 2163 | def register_changeset(self, rev, changelogrevision): |
|
2160 | 2164 | self.revbranchcache().setdata(rev, changelogrevision) |
|
2161 | 2165 | |
|
2162 | 2166 | def branchtip(self, branch, ignoremissing=False): |
|
2163 | 2167 | """return the tip node for a given branch |
|
2164 | 2168 | |
|
2165 | 2169 | If ignoremissing is True, then this method will not raise an error. |
|
2166 | 2170 | This is helpful for callers that only expect None for a missing branch |
|
2167 | 2171 | (e.g. namespace). |
|
2168 | 2172 | |
|
2169 | 2173 | """ |
|
2170 | 2174 | try: |
|
2171 | 2175 | return self.branchmap().branchtip(branch) |
|
2172 | 2176 | except KeyError: |
|
2173 | 2177 | if not ignoremissing: |
|
2174 | 2178 | raise error.RepoLookupError(_(b"unknown branch '%s'") % branch) |
|
2175 | 2179 | else: |
|
2176 | 2180 | pass |
|
2177 | 2181 | |
|
2178 | 2182 | def lookup(self, key): |
|
2179 | 2183 | node = scmutil.revsymbol(self, key).node() |
|
2180 | 2184 | if node is None: |
|
2181 | 2185 | raise error.RepoLookupError(_(b"unknown revision '%s'") % key) |
|
2182 | 2186 | return node |
|
2183 | 2187 | |
|
2184 | 2188 | def lookupbranch(self, key): |
|
2185 | 2189 | if self.branchmap().hasbranch(key): |
|
2186 | 2190 | return key |
|
2187 | 2191 | |
|
2188 | 2192 | return scmutil.revsymbol(self, key).branch() |
|
2189 | 2193 | |
|
2190 | 2194 | def known(self, nodes): |
|
2191 | 2195 | cl = self.changelog |
|
2192 | 2196 | get_rev = cl.index.get_rev |
|
2193 | 2197 | filtered = cl.filteredrevs |
|
2194 | 2198 | result = [] |
|
2195 | 2199 | for n in nodes: |
|
2196 | 2200 | r = get_rev(n) |
|
2197 | 2201 | resp = not (r is None or r in filtered) |
|
2198 | 2202 | result.append(resp) |
|
2199 | 2203 | return result |
|
2200 | 2204 | |
|
2201 | 2205 | def local(self): |
|
2202 | 2206 | return self |
|
2203 | 2207 | |
|
2204 | 2208 | def publishing(self): |
|
2205 | 2209 | # it's safe (and desirable) to trust the publish flag unconditionally |
|
2206 | 2210 | # so that we don't finalize changes shared between users via ssh or nfs |
|
2207 | 2211 | return self.ui.configbool(b'phases', b'publish', untrusted=True) |
|
2208 | 2212 | |
|
2209 | 2213 | def cancopy(self): |
|
2210 | 2214 | # so statichttprepo's override of local() works |
|
2211 | 2215 | if not self.local(): |
|
2212 | 2216 | return False |
|
2213 | 2217 | if not self.publishing(): |
|
2214 | 2218 | return True |
|
2215 | 2219 | # if publishing we can't copy if there is filtered content |
|
2216 | 2220 | return not self.filtered(b'visible').changelog.filteredrevs |
|
2217 | 2221 | |
|
2218 | 2222 | def shared(self): |
|
2219 | 2223 | '''the type of shared repository (None if not shared)''' |
|
2220 | 2224 | if self.sharedpath != self.path: |
|
2221 | 2225 | return b'store' |
|
2222 | 2226 | return None |
|
2223 | 2227 | |
|
2224 | 2228 | def wjoin(self, f, *insidef): |
|
2225 | 2229 | return self.vfs.reljoin(self.root, f, *insidef) |
|
2226 | 2230 | |
|
2227 | 2231 | def setparents(self, p1, p2=None): |
|
2228 | 2232 | if p2 is None: |
|
2229 | 2233 | p2 = self.nullid |
|
2230 | 2234 | self[None].setparents(p1, p2) |
|
2231 | 2235 | self._quick_access_changeid_invalidate() |
|
2232 | 2236 | |
|
2233 | 2237 | def filectx(self, path, changeid=None, fileid=None, changectx=None): |
|
2234 | 2238 | """changeid must be a changeset revision, if specified. |
|
2235 | 2239 | fileid can be a file revision or node.""" |
|
2236 | 2240 | return context.filectx( |
|
2237 | 2241 | self, path, changeid, fileid, changectx=changectx |
|
2238 | 2242 | ) |
|
2239 | 2243 | |
|
2240 | 2244 | def getcwd(self): |
|
2241 | 2245 | return self.dirstate.getcwd() |
|
2242 | 2246 | |
|
2243 | 2247 | def pathto(self, f, cwd=None): |
|
2244 | 2248 | return self.dirstate.pathto(f, cwd) |
|
2245 | 2249 | |
|
2246 | 2250 | def _loadfilter(self, filter): |
|
2247 | 2251 | if filter not in self._filterpats: |
|
2248 | 2252 | l = [] |
|
2249 | 2253 | for pat, cmd in self.ui.configitems(filter): |
|
2250 | 2254 | if cmd == b'!': |
|
2251 | 2255 | continue |
|
2252 | 2256 | mf = matchmod.match(self.root, b'', [pat]) |
|
2253 | 2257 | fn = None |
|
2254 | 2258 | params = cmd |
|
2255 | 2259 | for name, filterfn in pycompat.iteritems(self._datafilters): |
|
2256 | 2260 | if cmd.startswith(name): |
|
2257 | 2261 | fn = filterfn |
|
2258 | 2262 | params = cmd[len(name) :].lstrip() |
|
2259 | 2263 | break |
|
2260 | 2264 | if not fn: |
|
2261 | 2265 | fn = lambda s, c, **kwargs: procutil.filter(s, c) |
|
2262 | 2266 | fn.__name__ = 'commandfilter' |
|
2263 | 2267 | # Wrap old filters not supporting keyword arguments |
|
2264 | 2268 | if not pycompat.getargspec(fn)[2]: |
|
2265 | 2269 | oldfn = fn |
|
2266 | 2270 | fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c) |
|
2267 | 2271 | fn.__name__ = 'compat-' + oldfn.__name__ |
|
2268 | 2272 | l.append((mf, fn, params)) |
|
2269 | 2273 | self._filterpats[filter] = l |
|
2270 | 2274 | return self._filterpats[filter] |
|
2271 | 2275 | |
|
2272 | 2276 | def _filter(self, filterpats, filename, data): |
|
2273 | 2277 | for mf, fn, cmd in filterpats: |
|
2274 | 2278 | if mf(filename): |
|
2275 | 2279 | self.ui.debug( |
|
2276 | 2280 | b"filtering %s through %s\n" |
|
2277 | 2281 | % (filename, cmd or pycompat.sysbytes(fn.__name__)) |
|
2278 | 2282 | ) |
|
2279 | 2283 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
|
2280 | 2284 | break |
|
2281 | 2285 | |
|
2282 | 2286 | return data |
|
2283 | 2287 | |
|
2284 | 2288 | @unfilteredpropertycache |
|
2285 | 2289 | def _encodefilterpats(self): |
|
2286 | 2290 | return self._loadfilter(b'encode') |
|
2287 | 2291 | |
|
2288 | 2292 | @unfilteredpropertycache |
|
2289 | 2293 | def _decodefilterpats(self): |
|
2290 | 2294 | return self._loadfilter(b'decode') |
|
2291 | 2295 | |
|
2292 | 2296 | def adddatafilter(self, name, filter): |
|
2293 | 2297 | self._datafilters[name] = filter |
|
2294 | 2298 | |
|
2295 | 2299 | def wread(self, filename): |
|
2296 | 2300 | if self.wvfs.islink(filename): |
|
2297 | 2301 | data = self.wvfs.readlink(filename) |
|
2298 | 2302 | else: |
|
2299 | 2303 | data = self.wvfs.read(filename) |
|
2300 | 2304 | return self._filter(self._encodefilterpats, filename, data) |
|
2301 | 2305 | |
|
2302 | 2306 | def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs): |
|
2303 | 2307 | """write ``data`` into ``filename`` in the working directory |
|
2304 | 2308 | |
|
2305 | 2309 | This returns length of written (maybe decoded) data. |
|
2306 | 2310 | """ |
|
2307 | 2311 | data = self._filter(self._decodefilterpats, filename, data) |
|
2308 | 2312 | if b'l' in flags: |
|
2309 | 2313 | self.wvfs.symlink(data, filename) |
|
2310 | 2314 | else: |
|
2311 | 2315 | self.wvfs.write( |
|
2312 | 2316 | filename, data, backgroundclose=backgroundclose, **kwargs |
|
2313 | 2317 | ) |
|
2314 | 2318 | if b'x' in flags: |
|
2315 | 2319 | self.wvfs.setflags(filename, False, True) |
|
2316 | 2320 | else: |
|
2317 | 2321 | self.wvfs.setflags(filename, False, False) |
|
2318 | 2322 | return len(data) |
|
2319 | 2323 | |
|
2320 | 2324 | def wwritedata(self, filename, data): |
|
2321 | 2325 | return self._filter(self._decodefilterpats, filename, data) |
|
2322 | 2326 | |
|
2323 | 2327 | def currenttransaction(self): |
|
2324 | 2328 | """return the current transaction or None if non exists""" |
|
2325 | 2329 | if self._transref: |
|
2326 | 2330 | tr = self._transref() |
|
2327 | 2331 | else: |
|
2328 | 2332 | tr = None |
|
2329 | 2333 | |
|
2330 | 2334 | if tr and tr.running(): |
|
2331 | 2335 | return tr |
|
2332 | 2336 | return None |
|
2333 | 2337 | |
|
2334 | 2338 | def transaction(self, desc, report=None): |
|
2335 | 2339 | if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool( |
|
2336 | 2340 | b'devel', b'check-locks' |
|
2337 | 2341 | ): |
|
2338 | 2342 | if self._currentlock(self._lockref) is None: |
|
2339 | 2343 | raise error.ProgrammingError(b'transaction requires locking') |
|
2340 | 2344 | tr = self.currenttransaction() |
|
2341 | 2345 | if tr is not None: |
|
2342 | 2346 | return tr.nest(name=desc) |
|
2343 | 2347 | |
|
2344 | 2348 | # abort here if the journal already exists |
|
2345 | 2349 | if self.svfs.exists(b"journal"): |
|
2346 | 2350 | raise error.RepoError( |
|
2347 | 2351 | _(b"abandoned transaction found"), |
|
2348 | 2352 | hint=_(b"run 'hg recover' to clean up transaction"), |
|
2349 | 2353 | ) |
|
2350 | 2354 | |
|
2351 | 2355 | idbase = b"%.40f#%f" % (random.random(), time.time()) |
|
2352 | 2356 | ha = hex(hashutil.sha1(idbase).digest()) |
|
2353 | 2357 | txnid = b'TXN:' + ha |
|
2354 | 2358 | self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid) |
|
2355 | 2359 | |
|
2356 | 2360 | self._writejournal(desc) |
|
2357 | 2361 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
|
2358 | 2362 | if report: |
|
2359 | 2363 | rp = report |
|
2360 | 2364 | else: |
|
2361 | 2365 | rp = self.ui.warn |
|
2362 | 2366 | vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/ |
|
2363 | 2367 | # we must avoid cyclic reference between repo and transaction. |
|
2364 | 2368 | reporef = weakref.ref(self) |
|
2365 | 2369 | # Code to track tag movement |
|
2366 | 2370 | # |
|
2367 | 2371 | # Since tags are all handled as file content, it is actually quite hard |
|
2368 | 2372 | # to track these movement from a code perspective. So we fallback to a |
|
2369 | 2373 | # tracking at the repository level. One could envision to track changes |
|
2370 | 2374 | # to the '.hgtags' file through changegroup apply but that fails to |
|
2371 | 2375 | # cope with case where transaction expose new heads without changegroup |
|
2372 | 2376 | # being involved (eg: phase movement). |
|
2373 | 2377 | # |
|
2374 | 2378 | # For now, We gate the feature behind a flag since this likely comes |
|
2375 | 2379 | # with performance impacts. The current code run more often than needed |
|
2376 | 2380 | # and do not use caches as much as it could. The current focus is on |
|
2377 | 2381 | # the behavior of the feature so we disable it by default. The flag |
|
2378 | 2382 | # will be removed when we are happy with the performance impact. |
|
2379 | 2383 | # |
|
2380 | 2384 | # Once this feature is no longer experimental move the following |
|
2381 | 2385 | # documentation to the appropriate help section: |
|
2382 | 2386 | # |
|
2383 | 2387 | # The ``HG_TAG_MOVED`` variable will be set if the transaction touched |
|
2384 | 2388 | # tags (new or changed or deleted tags). In addition the details of |
|
2385 | 2389 | # these changes are made available in a file at: |
|
2386 | 2390 | # ``REPOROOT/.hg/changes/tags.changes``. |
|
2387 | 2391 | # Make sure you check for HG_TAG_MOVED before reading that file as it |
|
2388 | 2392 | # might exist from a previous transaction even if no tag were touched |
|
2389 | 2393 | # in this one. Changes are recorded in a line base format:: |
|
2390 | 2394 | # |
|
2391 | 2395 | # <action> <hex-node> <tag-name>\n |
|
2392 | 2396 | # |
|
2393 | 2397 | # Actions are defined as follow: |
|
2394 | 2398 | # "-R": tag is removed, |
|
2395 | 2399 | # "+A": tag is added, |
|
2396 | 2400 | # "-M": tag is moved (old value), |
|
2397 | 2401 | # "+M": tag is moved (new value), |
|
2398 | 2402 | tracktags = lambda x: None |
|
2399 | 2403 | # experimental config: experimental.hook-track-tags |
|
2400 | 2404 | shouldtracktags = self.ui.configbool( |
|
2401 | 2405 | b'experimental', b'hook-track-tags' |
|
2402 | 2406 | ) |
|
2403 | 2407 | if desc != b'strip' and shouldtracktags: |
|
2404 | 2408 | oldheads = self.changelog.headrevs() |
|
2405 | 2409 | |
|
2406 | 2410 | def tracktags(tr2): |
|
2407 | 2411 | repo = reporef() |
|
2408 | 2412 | assert repo is not None # help pytype |
|
2409 | 2413 | oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads) |
|
2410 | 2414 | newheads = repo.changelog.headrevs() |
|
2411 | 2415 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) |
|
2412 | 2416 | # notes: we compare lists here. |
|
2413 | 2417 | # As we do it only once buiding set would not be cheaper |
|
2414 | 2418 | changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes) |
|
2415 | 2419 | if changes: |
|
2416 | 2420 | tr2.hookargs[b'tag_moved'] = b'1' |
|
2417 | 2421 | with repo.vfs( |
|
2418 | 2422 | b'changes/tags.changes', b'w', atomictemp=True |
|
2419 | 2423 | ) as changesfile: |
|
2420 | 2424 | # note: we do not register the file to the transaction |
|
2421 | 2425 | # because we needs it to still exist on the transaction |
|
2422 | 2426 | # is close (for txnclose hooks) |
|
2423 | 2427 | tagsmod.writediff(changesfile, changes) |
|
2424 | 2428 | |
|
2425 | 2429 | def validate(tr2): |
|
2426 | 2430 | """will run pre-closing hooks""" |
|
2427 | 2431 | # XXX the transaction API is a bit lacking here so we take a hacky |
|
2428 | 2432 | # path for now |
|
2429 | 2433 | # |
|
2430 | 2434 | # We cannot add this as a "pending" hooks since the 'tr.hookargs' |
|
2431 | 2435 | # dict is copied before these run. In addition we needs the data |
|
2432 | 2436 | # available to in memory hooks too. |
|
2433 | 2437 | # |
|
2434 | 2438 | # Moreover, we also need to make sure this runs before txnclose |
|
2435 | 2439 | # hooks and there is no "pending" mechanism that would execute |
|
2436 | 2440 | # logic only if hooks are about to run. |
|
2437 | 2441 | # |
|
2438 | 2442 | # Fixing this limitation of the transaction is also needed to track |
|
2439 | 2443 | # other families of changes (bookmarks, phases, obsolescence). |
|
2440 | 2444 | # |
|
2441 | 2445 | # This will have to be fixed before we remove the experimental |
|
2442 | 2446 | # gating. |
|
2443 | 2447 | tracktags(tr2) |
|
2444 | 2448 | repo = reporef() |
|
2445 | 2449 | assert repo is not None # help pytype |
|
2446 | 2450 | |
|
2447 | 2451 | singleheadopt = (b'experimental', b'single-head-per-branch') |
|
2448 | 2452 | singlehead = repo.ui.configbool(*singleheadopt) |
|
2449 | 2453 | if singlehead: |
|
2450 | 2454 | singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1] |
|
2451 | 2455 | accountclosed = singleheadsub.get( |
|
2452 | 2456 | b"account-closed-heads", False |
|
2453 | 2457 | ) |
|
2454 | 2458 | if singleheadsub.get(b"public-changes-only", False): |
|
2455 | 2459 | filtername = b"immutable" |
|
2456 | 2460 | else: |
|
2457 | 2461 | filtername = b"visible" |
|
2458 | 2462 | scmutil.enforcesinglehead( |
|
2459 | 2463 | repo, tr2, desc, accountclosed, filtername |
|
2460 | 2464 | ) |
|
2461 | 2465 | if hook.hashook(repo.ui, b'pretxnclose-bookmark'): |
|
2462 | 2466 | for name, (old, new) in sorted( |
|
2463 | 2467 | tr.changes[b'bookmarks'].items() |
|
2464 | 2468 | ): |
|
2465 | 2469 | args = tr.hookargs.copy() |
|
2466 | 2470 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
2467 | 2471 | repo.hook( |
|
2468 | 2472 | b'pretxnclose-bookmark', |
|
2469 | 2473 | throw=True, |
|
2470 | 2474 | **pycompat.strkwargs(args) |
|
2471 | 2475 | ) |
|
2472 | 2476 | if hook.hashook(repo.ui, b'pretxnclose-phase'): |
|
2473 | 2477 | cl = repo.unfiltered().changelog |
|
2474 | 2478 | for revs, (old, new) in tr.changes[b'phases']: |
|
2475 | 2479 | for rev in revs: |
|
2476 | 2480 | args = tr.hookargs.copy() |
|
2477 | 2481 | node = hex(cl.node(rev)) |
|
2478 | 2482 | args.update(phases.preparehookargs(node, old, new)) |
|
2479 | 2483 | repo.hook( |
|
2480 | 2484 | b'pretxnclose-phase', |
|
2481 | 2485 | throw=True, |
|
2482 | 2486 | **pycompat.strkwargs(args) |
|
2483 | 2487 | ) |
|
2484 | 2488 | |
|
2485 | 2489 | repo.hook( |
|
2486 | 2490 | b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs) |
|
2487 | 2491 | ) |
|
2488 | 2492 | |
|
2489 | 2493 | def releasefn(tr, success): |
|
2490 | 2494 | repo = reporef() |
|
2491 | 2495 | if repo is None: |
|
2492 | 2496 | # If the repo has been GC'd (and this release function is being |
|
2493 | 2497 | # called from transaction.__del__), there's not much we can do, |
|
2494 | 2498 | # so just leave the unfinished transaction there and let the |
|
2495 | 2499 | # user run `hg recover`. |
|
2496 | 2500 | return |
|
2497 | 2501 | if success: |
|
2498 | 2502 | # this should be explicitly invoked here, because |
|
2499 | 2503 | # in-memory changes aren't written out at closing |
|
2500 | 2504 | # transaction, if tr.addfilegenerator (via |
|
2501 | 2505 | # dirstate.write or so) isn't invoked while |
|
2502 | 2506 | # transaction running |
|
2503 | 2507 | repo.dirstate.write(None) |
|
2504 | 2508 | else: |
|
2505 | 2509 | # discard all changes (including ones already written |
|
2506 | 2510 | # out) in this transaction |
|
2507 | 2511 | narrowspec.restorebackup(self, b'journal.narrowspec') |
|
2508 | 2512 | narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate') |
|
2509 | 2513 | repo.dirstate.restorebackup(None, b'journal.dirstate') |
|
2510 | 2514 | |
|
2511 | 2515 | repo.invalidate(clearfilecache=True) |
|
2512 | 2516 | |
|
2513 | 2517 | tr = transaction.transaction( |
|
2514 | 2518 | rp, |
|
2515 | 2519 | self.svfs, |
|
2516 | 2520 | vfsmap, |
|
2517 | 2521 | b"journal", |
|
2518 | 2522 | b"undo", |
|
2519 | 2523 | aftertrans(renames), |
|
2520 | 2524 | self.store.createmode, |
|
2521 | 2525 | validator=validate, |
|
2522 | 2526 | releasefn=releasefn, |
|
2523 | 2527 | checkambigfiles=_cachedfiles, |
|
2524 | 2528 | name=desc, |
|
2525 | 2529 | ) |
|
2526 | 2530 | tr.changes[b'origrepolen'] = len(self) |
|
2527 | 2531 | tr.changes[b'obsmarkers'] = set() |
|
2528 | 2532 | tr.changes[b'phases'] = [] |
|
2529 | 2533 | tr.changes[b'bookmarks'] = {} |
|
2530 | 2534 | |
|
2531 | 2535 | tr.hookargs[b'txnid'] = txnid |
|
2532 | 2536 | tr.hookargs[b'txnname'] = desc |
|
2533 | 2537 | tr.hookargs[b'changes'] = tr.changes |
|
2534 | 2538 | # note: writing the fncache only during finalize mean that the file is |
|
2535 | 2539 | # outdated when running hooks. As fncache is used for streaming clone, |
|
2536 | 2540 | # this is not expected to break anything that happen during the hooks. |
|
2537 | 2541 | tr.addfinalize(b'flush-fncache', self.store.write) |
|
2538 | 2542 | |
|
2539 | 2543 | def txnclosehook(tr2): |
|
2540 | 2544 | """To be run if transaction is successful, will schedule a hook run""" |
|
2541 | 2545 | # Don't reference tr2 in hook() so we don't hold a reference. |
|
2542 | 2546 | # This reduces memory consumption when there are multiple |
|
2543 | 2547 | # transactions per lock. This can likely go away if issue5045 |
|
2544 | 2548 | # fixes the function accumulation. |
|
2545 | 2549 | hookargs = tr2.hookargs |
|
2546 | 2550 | |
|
2547 | 2551 | def hookfunc(unused_success): |
|
2548 | 2552 | repo = reporef() |
|
2549 | 2553 | assert repo is not None # help pytype |
|
2550 | 2554 | |
|
2551 | 2555 | if hook.hashook(repo.ui, b'txnclose-bookmark'): |
|
2552 | 2556 | bmchanges = sorted(tr.changes[b'bookmarks'].items()) |
|
2553 | 2557 | for name, (old, new) in bmchanges: |
|
2554 | 2558 | args = tr.hookargs.copy() |
|
2555 | 2559 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
2556 | 2560 | repo.hook( |
|
2557 | 2561 | b'txnclose-bookmark', |
|
2558 | 2562 | throw=False, |
|
2559 | 2563 | **pycompat.strkwargs(args) |
|
2560 | 2564 | ) |
|
2561 | 2565 | |
|
2562 | 2566 | if hook.hashook(repo.ui, b'txnclose-phase'): |
|
2563 | 2567 | cl = repo.unfiltered().changelog |
|
2564 | 2568 | phasemv = sorted( |
|
2565 | 2569 | tr.changes[b'phases'], key=lambda r: r[0][0] |
|
2566 | 2570 | ) |
|
2567 | 2571 | for revs, (old, new) in phasemv: |
|
2568 | 2572 | for rev in revs: |
|
2569 | 2573 | args = tr.hookargs.copy() |
|
2570 | 2574 | node = hex(cl.node(rev)) |
|
2571 | 2575 | args.update(phases.preparehookargs(node, old, new)) |
|
2572 | 2576 | repo.hook( |
|
2573 | 2577 | b'txnclose-phase', |
|
2574 | 2578 | throw=False, |
|
2575 | 2579 | **pycompat.strkwargs(args) |
|
2576 | 2580 | ) |
|
2577 | 2581 | |
|
2578 | 2582 | repo.hook( |
|
2579 | 2583 | b'txnclose', throw=False, **pycompat.strkwargs(hookargs) |
|
2580 | 2584 | ) |
|
2581 | 2585 | |
|
2582 | 2586 | repo = reporef() |
|
2583 | 2587 | assert repo is not None # help pytype |
|
2584 | 2588 | repo._afterlock(hookfunc) |
|
2585 | 2589 | |
|
2586 | 2590 | tr.addfinalize(b'txnclose-hook', txnclosehook) |
|
2587 | 2591 | # Include a leading "-" to make it happen before the transaction summary |
|
2588 | 2592 | # reports registered via scmutil.registersummarycallback() whose names |
|
2589 | 2593 | # are 00-txnreport etc. That way, the caches will be warm when the |
|
2590 | 2594 | # callbacks run. |
|
2591 | 2595 | tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr)) |
|
2592 | 2596 | |
|
2593 | 2597 | def txnaborthook(tr2): |
|
2594 | 2598 | """To be run if transaction is aborted""" |
|
2595 | 2599 | repo = reporef() |
|
2596 | 2600 | assert repo is not None # help pytype |
|
2597 | 2601 | repo.hook( |
|
2598 | 2602 | b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs) |
|
2599 | 2603 | ) |
|
2600 | 2604 | |
|
2601 | 2605 | tr.addabort(b'txnabort-hook', txnaborthook) |
|
2602 | 2606 | # avoid eager cache invalidation. in-memory data should be identical |
|
2603 | 2607 | # to stored data if transaction has no error. |
|
2604 | 2608 | tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats) |
|
2605 | 2609 | self._transref = weakref.ref(tr) |
|
2606 | 2610 | scmutil.registersummarycallback(self, tr, desc) |
|
2607 | 2611 | return tr |
|
2608 | 2612 | |
|
2609 | 2613 | def _journalfiles(self): |
|
2610 | 2614 | return ( |
|
2611 | 2615 | (self.svfs, b'journal'), |
|
2612 | 2616 | (self.svfs, b'journal.narrowspec'), |
|
2613 | 2617 | (self.vfs, b'journal.narrowspec.dirstate'), |
|
2614 | 2618 | (self.vfs, b'journal.dirstate'), |
|
2615 | 2619 | (self.vfs, b'journal.branch'), |
|
2616 | 2620 | (self.vfs, b'journal.desc'), |
|
2617 | 2621 | (bookmarks.bookmarksvfs(self), b'journal.bookmarks'), |
|
2618 | 2622 | (self.svfs, b'journal.phaseroots'), |
|
2619 | 2623 | ) |
|
2620 | 2624 | |
|
2621 | 2625 | def undofiles(self): |
|
2622 | 2626 | return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] |
|
2623 | 2627 | |
|
2624 | 2628 | @unfilteredmethod |
|
2625 | 2629 | def _writejournal(self, desc): |
|
2626 | 2630 | self.dirstate.savebackup(None, b'journal.dirstate') |
|
2627 | 2631 | narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate') |
|
2628 | 2632 | narrowspec.savebackup(self, b'journal.narrowspec') |
|
2629 | 2633 | self.vfs.write( |
|
2630 | 2634 | b"journal.branch", encoding.fromlocal(self.dirstate.branch()) |
|
2631 | 2635 | ) |
|
2632 | 2636 | self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc)) |
|
2633 | 2637 | bookmarksvfs = bookmarks.bookmarksvfs(self) |
|
2634 | 2638 | bookmarksvfs.write( |
|
2635 | 2639 | b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks") |
|
2636 | 2640 | ) |
|
2637 | 2641 | self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots")) |
|
2638 | 2642 | |
|
2639 | 2643 | def recover(self): |
|
2640 | 2644 | with self.lock(): |
|
2641 | 2645 | if self.svfs.exists(b"journal"): |
|
2642 | 2646 | self.ui.status(_(b"rolling back interrupted transaction\n")) |
|
2643 | 2647 | vfsmap = { |
|
2644 | 2648 | b'': self.svfs, |
|
2645 | 2649 | b'plain': self.vfs, |
|
2646 | 2650 | } |
|
2647 | 2651 | transaction.rollback( |
|
2648 | 2652 | self.svfs, |
|
2649 | 2653 | vfsmap, |
|
2650 | 2654 | b"journal", |
|
2651 | 2655 | self.ui.warn, |
|
2652 | 2656 | checkambigfiles=_cachedfiles, |
|
2653 | 2657 | ) |
|
2654 | 2658 | self.invalidate() |
|
2655 | 2659 | return True |
|
2656 | 2660 | else: |
|
2657 | 2661 | self.ui.warn(_(b"no interrupted transaction available\n")) |
|
2658 | 2662 | return False |
|
2659 | 2663 | |
|
2660 | 2664 | def rollback(self, dryrun=False, force=False): |
|
2661 | 2665 | wlock = lock = dsguard = None |
|
2662 | 2666 | try: |
|
2663 | 2667 | wlock = self.wlock() |
|
2664 | 2668 | lock = self.lock() |
|
2665 | 2669 | if self.svfs.exists(b"undo"): |
|
2666 | 2670 | dsguard = dirstateguard.dirstateguard(self, b'rollback') |
|
2667 | 2671 | |
|
2668 | 2672 | return self._rollback(dryrun, force, dsguard) |
|
2669 | 2673 | else: |
|
2670 | 2674 | self.ui.warn(_(b"no rollback information available\n")) |
|
2671 | 2675 | return 1 |
|
2672 | 2676 | finally: |
|
2673 | 2677 | release(dsguard, lock, wlock) |
|
2674 | 2678 | |
|
2675 | 2679 | @unfilteredmethod # Until we get smarter cache management |
|
2676 | 2680 | def _rollback(self, dryrun, force, dsguard): |
|
2677 | 2681 | ui = self.ui |
|
2678 | 2682 | try: |
|
2679 | 2683 | args = self.vfs.read(b'undo.desc').splitlines() |
|
2680 | 2684 | (oldlen, desc, detail) = (int(args[0]), args[1], None) |
|
2681 | 2685 | if len(args) >= 3: |
|
2682 | 2686 | detail = args[2] |
|
2683 | 2687 | oldtip = oldlen - 1 |
|
2684 | 2688 | |
|
2685 | 2689 | if detail and ui.verbose: |
|
2686 | 2690 | msg = _( |
|
2687 | 2691 | b'repository tip rolled back to revision %d' |
|
2688 | 2692 | b' (undo %s: %s)\n' |
|
2689 | 2693 | ) % (oldtip, desc, detail) |
|
2690 | 2694 | else: |
|
2691 | 2695 | msg = _( |
|
2692 | 2696 | b'repository tip rolled back to revision %d (undo %s)\n' |
|
2693 | 2697 | ) % (oldtip, desc) |
|
2694 | 2698 | except IOError: |
|
2695 | 2699 | msg = _(b'rolling back unknown transaction\n') |
|
2696 | 2700 | desc = None |
|
2697 | 2701 | |
|
2698 | 2702 | if not force and self[b'.'] != self[b'tip'] and desc == b'commit': |
|
2699 | 2703 | raise error.Abort( |
|
2700 | 2704 | _( |
|
2701 | 2705 | b'rollback of last commit while not checked out ' |
|
2702 | 2706 | b'may lose data' |
|
2703 | 2707 | ), |
|
2704 | 2708 | hint=_(b'use -f to force'), |
|
2705 | 2709 | ) |
|
2706 | 2710 | |
|
2707 | 2711 | ui.status(msg) |
|
2708 | 2712 | if dryrun: |
|
2709 | 2713 | return 0 |
|
2710 | 2714 | |
|
2711 | 2715 | parents = self.dirstate.parents() |
|
2712 | 2716 | self.destroying() |
|
2713 | 2717 | vfsmap = {b'plain': self.vfs, b'': self.svfs} |
|
2714 | 2718 | transaction.rollback( |
|
2715 | 2719 | self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles |
|
2716 | 2720 | ) |
|
2717 | 2721 | bookmarksvfs = bookmarks.bookmarksvfs(self) |
|
2718 | 2722 | if bookmarksvfs.exists(b'undo.bookmarks'): |
|
2719 | 2723 | bookmarksvfs.rename( |
|
2720 | 2724 | b'undo.bookmarks', b'bookmarks', checkambig=True |
|
2721 | 2725 | ) |
|
2722 | 2726 | if self.svfs.exists(b'undo.phaseroots'): |
|
2723 | 2727 | self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True) |
|
2724 | 2728 | self.invalidate() |
|
2725 | 2729 | |
|
2726 | 2730 | has_node = self.changelog.index.has_node |
|
2727 | 2731 | parentgone = any(not has_node(p) for p in parents) |
|
2728 | 2732 | if parentgone: |
|
2729 | 2733 | # prevent dirstateguard from overwriting already restored one |
|
2730 | 2734 | dsguard.close() |
|
2731 | 2735 | |
|
2732 | 2736 | narrowspec.restorebackup(self, b'undo.narrowspec') |
|
2733 | 2737 | narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate') |
|
2734 | 2738 | self.dirstate.restorebackup(None, b'undo.dirstate') |
|
2735 | 2739 | try: |
|
2736 | 2740 | branch = self.vfs.read(b'undo.branch') |
|
2737 | 2741 | self.dirstate.setbranch(encoding.tolocal(branch)) |
|
2738 | 2742 | except IOError: |
|
2739 | 2743 | ui.warn( |
|
2740 | 2744 | _( |
|
2741 | 2745 | b'named branch could not be reset: ' |
|
2742 | 2746 | b'current branch is still \'%s\'\n' |
|
2743 | 2747 | ) |
|
2744 | 2748 | % self.dirstate.branch() |
|
2745 | 2749 | ) |
|
2746 | 2750 | |
|
2747 | 2751 | parents = tuple([p.rev() for p in self[None].parents()]) |
|
2748 | 2752 | if len(parents) > 1: |
|
2749 | 2753 | ui.status( |
|
2750 | 2754 | _( |
|
2751 | 2755 | b'working directory now based on ' |
|
2752 | 2756 | b'revisions %d and %d\n' |
|
2753 | 2757 | ) |
|
2754 | 2758 | % parents |
|
2755 | 2759 | ) |
|
2756 | 2760 | else: |
|
2757 | 2761 | ui.status( |
|
2758 | 2762 | _(b'working directory now based on revision %d\n') % parents |
|
2759 | 2763 | ) |
|
2760 | 2764 | mergestatemod.mergestate.clean(self) |
|
2761 | 2765 | |
|
2762 | 2766 | # TODO: if we know which new heads may result from this rollback, pass |
|
2763 | 2767 | # them to destroy(), which will prevent the branchhead cache from being |
|
2764 | 2768 | # invalidated. |
|
2765 | 2769 | self.destroyed() |
|
2766 | 2770 | return 0 |
|
2767 | 2771 | |
|
2768 | 2772 | def _buildcacheupdater(self, newtransaction): |
|
2769 | 2773 | """called during transaction to build the callback updating cache |
|
2770 | 2774 | |
|
2771 | 2775 | Lives on the repository to help extension who might want to augment |
|
2772 | 2776 | this logic. For this purpose, the created transaction is passed to the |
|
2773 | 2777 | method. |
|
2774 | 2778 | """ |
|
2775 | 2779 | # we must avoid cyclic reference between repo and transaction. |
|
2776 | 2780 | reporef = weakref.ref(self) |
|
2777 | 2781 | |
|
2778 | 2782 | def updater(tr): |
|
2779 | 2783 | repo = reporef() |
|
2780 | 2784 | assert repo is not None # help pytype |
|
2781 | 2785 | repo.updatecaches(tr) |
|
2782 | 2786 | |
|
2783 | 2787 | return updater |
|
2784 | 2788 | |
|
2785 | 2789 | @unfilteredmethod |
|
2786 | 2790 | def updatecaches(self, tr=None, full=False, caches=None): |
|
2787 | 2791 | """warm appropriate caches |
|
2788 | 2792 | |
|
2789 | 2793 | If this function is called after a transaction closed. The transaction |
|
2790 | 2794 | will be available in the 'tr' argument. This can be used to selectively |
|
2791 | 2795 | update caches relevant to the changes in that transaction. |
|
2792 | 2796 | |
|
2793 | 2797 | If 'full' is set, make sure all caches the function knows about have |
|
2794 | 2798 | up-to-date data. Even the ones usually loaded more lazily. |
|
2795 | 2799 | |
|
2796 | 2800 | The `full` argument can take a special "post-clone" value. In this case |
|
2797 | 2801 | the cache warming is made after a clone and of the slower cache might |
|
2798 | 2802 | be skipped, namely the `.fnodetags` one. This argument is 5.8 specific |
|
2799 | 2803 | as we plan for a cleaner way to deal with this for 5.9. |
|
2800 | 2804 | """ |
|
2801 | 2805 | if tr is not None and tr.hookargs.get(b'source') == b'strip': |
|
2802 | 2806 | # During strip, many caches are invalid but |
|
2803 | 2807 | # later call to `destroyed` will refresh them. |
|
2804 | 2808 | return |
|
2805 | 2809 | |
|
2806 | 2810 | unfi = self.unfiltered() |
|
2807 | 2811 | |
|
2808 | 2812 | if full: |
|
2809 | 2813 | msg = ( |
|
2810 | 2814 | "`full` argument for `repo.updatecaches` is deprecated\n" |
|
2811 | 2815 | "(use `caches=repository.CACHE_ALL` instead)" |
|
2812 | 2816 | ) |
|
2813 | 2817 | self.ui.deprecwarn(msg, b"5.9") |
|
2814 | 2818 | caches = repository.CACHES_ALL |
|
2815 | 2819 | if full == b"post-clone": |
|
2816 | 2820 | caches = repository.CACHES_POST_CLONE |
|
2817 | 2821 | caches = repository.CACHES_ALL |
|
2818 | 2822 | elif caches is None: |
|
2819 | 2823 | caches = repository.CACHES_DEFAULT |
|
2820 | 2824 | |
|
2821 | 2825 | if repository.CACHE_BRANCHMAP_SERVED in caches: |
|
2822 | 2826 | if tr is None or tr.changes[b'origrepolen'] < len(self): |
|
2823 | 2827 | # accessing the 'served' branchmap should refresh all the others, |
|
2824 | 2828 | self.ui.debug(b'updating the branch cache\n') |
|
2825 | 2829 | self.filtered(b'served').branchmap() |
|
2826 | 2830 | self.filtered(b'served.hidden').branchmap() |
|
2827 | 2831 | # flush all possibly delayed write. |
|
2828 | 2832 | self._branchcaches.write_delayed(self) |
|
2829 | 2833 | |
|
2830 | 2834 | if repository.CACHE_CHANGELOG_CACHE in caches: |
|
2831 | 2835 | self.changelog.update_caches(transaction=tr) |
|
2832 | 2836 | |
|
2833 | 2837 | if repository.CACHE_MANIFESTLOG_CACHE in caches: |
|
2834 | 2838 | self.manifestlog.update_caches(transaction=tr) |
|
2835 | 2839 | |
|
2836 | 2840 | if repository.CACHE_REV_BRANCH in caches: |
|
2837 | 2841 | rbc = unfi.revbranchcache() |
|
2838 | 2842 | for r in unfi.changelog: |
|
2839 | 2843 | rbc.branchinfo(r) |
|
2840 | 2844 | rbc.write() |
|
2841 | 2845 | |
|
2842 | 2846 | if repository.CACHE_FULL_MANIFEST in caches: |
|
2843 | 2847 | # ensure the working copy parents are in the manifestfulltextcache |
|
2844 | 2848 | for ctx in self[b'.'].parents(): |
|
2845 | 2849 | ctx.manifest() # accessing the manifest is enough |
|
2846 | 2850 | |
|
2847 | 2851 | if repository.CACHE_FILE_NODE_TAGS in caches: |
|
2848 | 2852 | # accessing fnode cache warms the cache |
|
2849 | 2853 | tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs()) |
|
2850 | 2854 | |
|
2851 | 2855 | if repository.CACHE_TAGS_DEFAULT in caches: |
|
2852 | 2856 | # accessing tags warm the cache |
|
2853 | 2857 | self.tags() |
|
2854 | 2858 | if repository.CACHE_TAGS_SERVED in caches: |
|
2855 | 2859 | self.filtered(b'served').tags() |
|
2856 | 2860 | |
|
2857 | 2861 | if repository.CACHE_BRANCHMAP_ALL in caches: |
|
2858 | 2862 | # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately, |
|
2859 | 2863 | # so we're forcing a write to cause these caches to be warmed up |
|
2860 | 2864 | # even if they haven't explicitly been requested yet (if they've |
|
2861 | 2865 | # never been used by hg, they won't ever have been written, even if |
|
2862 | 2866 | # they're a subset of another kind of cache that *has* been used). |
|
2863 | 2867 | for filt in repoview.filtertable.keys(): |
|
2864 | 2868 | filtered = self.filtered(filt) |
|
2865 | 2869 | filtered.branchmap().write(filtered) |
|
2866 | 2870 | |
|
2867 | 2871 | def invalidatecaches(self): |
|
2868 | 2872 | |
|
2869 | 2873 | if '_tagscache' in vars(self): |
|
2870 | 2874 | # can't use delattr on proxy |
|
2871 | 2875 | del self.__dict__['_tagscache'] |
|
2872 | 2876 | |
|
2873 | 2877 | self._branchcaches.clear() |
|
2874 | 2878 | self.invalidatevolatilesets() |
|
2875 | 2879 | self._sparsesignaturecache.clear() |
|
2876 | 2880 | |
|
2877 | 2881 | def invalidatevolatilesets(self): |
|
2878 | 2882 | self.filteredrevcache.clear() |
|
2879 | 2883 | obsolete.clearobscaches(self) |
|
2880 | 2884 | self._quick_access_changeid_invalidate() |
|
2881 | 2885 | |
|
2882 | 2886 | def invalidatedirstate(self): |
|
2883 | 2887 | """Invalidates the dirstate, causing the next call to dirstate |
|
2884 | 2888 | to check if it was modified since the last time it was read, |
|
2885 | 2889 | rereading it if it has. |
|
2886 | 2890 | |
|
2887 | 2891 | This is different to dirstate.invalidate() that it doesn't always |
|
2888 | 2892 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
2889 | 2893 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
2890 | 2894 | known good state).""" |
|
2891 | 2895 | if hasunfilteredcache(self, 'dirstate'): |
|
2892 | 2896 | for k in self.dirstate._filecache: |
|
2893 | 2897 | try: |
|
2894 | 2898 | delattr(self.dirstate, k) |
|
2895 | 2899 | except AttributeError: |
|
2896 | 2900 | pass |
|
2897 | 2901 | delattr(self.unfiltered(), 'dirstate') |
|
2898 | 2902 | |
|
2899 | 2903 | def invalidate(self, clearfilecache=False): |
|
2900 | 2904 | """Invalidates both store and non-store parts other than dirstate |
|
2901 | 2905 | |
|
2902 | 2906 | If a transaction is running, invalidation of store is omitted, |
|
2903 | 2907 | because discarding in-memory changes might cause inconsistency |
|
2904 | 2908 | (e.g. incomplete fncache causes unintentional failure, but |
|
2905 | 2909 | redundant one doesn't). |
|
2906 | 2910 | """ |
|
2907 | 2911 | unfiltered = self.unfiltered() # all file caches are stored unfiltered |
|
2908 | 2912 | for k in list(self._filecache.keys()): |
|
2909 | 2913 | # dirstate is invalidated separately in invalidatedirstate() |
|
2910 | 2914 | if k == b'dirstate': |
|
2911 | 2915 | continue |
|
2912 | 2916 | if ( |
|
2913 | 2917 | k == b'changelog' |
|
2914 | 2918 | and self.currenttransaction() |
|
2915 | 2919 | and self.changelog._delayed |
|
2916 | 2920 | ): |
|
2917 | 2921 | # The changelog object may store unwritten revisions. We don't |
|
2918 | 2922 | # want to lose them. |
|
2919 | 2923 | # TODO: Solve the problem instead of working around it. |
|
2920 | 2924 | continue |
|
2921 | 2925 | |
|
2922 | 2926 | if clearfilecache: |
|
2923 | 2927 | del self._filecache[k] |
|
2924 | 2928 | try: |
|
2925 | 2929 | delattr(unfiltered, k) |
|
2926 | 2930 | except AttributeError: |
|
2927 | 2931 | pass |
|
2928 | 2932 | self.invalidatecaches() |
|
2929 | 2933 | if not self.currenttransaction(): |
|
2930 | 2934 | # TODO: Changing contents of store outside transaction |
|
2931 | 2935 | # causes inconsistency. We should make in-memory store |
|
2932 | 2936 | # changes detectable, and abort if changed. |
|
2933 | 2937 | self.store.invalidatecaches() |
|
2934 | 2938 | |
|
2935 | 2939 | def invalidateall(self): |
|
2936 | 2940 | """Fully invalidates both store and non-store parts, causing the |
|
2937 | 2941 | subsequent operation to reread any outside changes.""" |
|
2938 | 2942 | # extension should hook this to invalidate its caches |
|
2939 | 2943 | self.invalidate() |
|
2940 | 2944 | self.invalidatedirstate() |
|
2941 | 2945 | |
|
2942 | 2946 | @unfilteredmethod |
|
2943 | 2947 | def _refreshfilecachestats(self, tr): |
|
2944 | 2948 | """Reload stats of cached files so that they are flagged as valid""" |
|
2945 | 2949 | for k, ce in self._filecache.items(): |
|
2946 | 2950 | k = pycompat.sysstr(k) |
|
2947 | 2951 | if k == 'dirstate' or k not in self.__dict__: |
|
2948 | 2952 | continue |
|
2949 | 2953 | ce.refresh() |
|
2950 | 2954 | |
|
2951 | 2955 | def _lock( |
|
2952 | 2956 | self, |
|
2953 | 2957 | vfs, |
|
2954 | 2958 | lockname, |
|
2955 | 2959 | wait, |
|
2956 | 2960 | releasefn, |
|
2957 | 2961 | acquirefn, |
|
2958 | 2962 | desc, |
|
2959 | 2963 | ): |
|
2960 | 2964 | timeout = 0 |
|
2961 | 2965 | warntimeout = 0 |
|
2962 | 2966 | if wait: |
|
2963 | 2967 | timeout = self.ui.configint(b"ui", b"timeout") |
|
2964 | 2968 | warntimeout = self.ui.configint(b"ui", b"timeout.warn") |
|
2965 | 2969 | # internal config: ui.signal-safe-lock |
|
2966 | 2970 | signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock') |
|
2967 | 2971 | |
|
2968 | 2972 | l = lockmod.trylock( |
|
2969 | 2973 | self.ui, |
|
2970 | 2974 | vfs, |
|
2971 | 2975 | lockname, |
|
2972 | 2976 | timeout, |
|
2973 | 2977 | warntimeout, |
|
2974 | 2978 | releasefn=releasefn, |
|
2975 | 2979 | acquirefn=acquirefn, |
|
2976 | 2980 | desc=desc, |
|
2977 | 2981 | signalsafe=signalsafe, |
|
2978 | 2982 | ) |
|
2979 | 2983 | return l |
|
2980 | 2984 | |
|
2981 | 2985 | def _afterlock(self, callback): |
|
2982 | 2986 | """add a callback to be run when the repository is fully unlocked |
|
2983 | 2987 | |
|
2984 | 2988 | The callback will be executed when the outermost lock is released |
|
2985 | 2989 | (with wlock being higher level than 'lock').""" |
|
2986 | 2990 | for ref in (self._wlockref, self._lockref): |
|
2987 | 2991 | l = ref and ref() |
|
2988 | 2992 | if l and l.held: |
|
2989 | 2993 | l.postrelease.append(callback) |
|
2990 | 2994 | break |
|
2991 | 2995 | else: # no lock have been found. |
|
2992 | 2996 | callback(True) |
|
2993 | 2997 | |
|
2994 | 2998 | def lock(self, wait=True): |
|
2995 | 2999 | """Lock the repository store (.hg/store) and return a weak reference |
|
2996 | 3000 | to the lock. Use this before modifying the store (e.g. committing or |
|
2997 | 3001 | stripping). If you are opening a transaction, get a lock as well.) |
|
2998 | 3002 | |
|
2999 | 3003 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
3000 | 3004 | 'wlock' first to avoid a dead-lock hazard.""" |
|
3001 | 3005 | l = self._currentlock(self._lockref) |
|
3002 | 3006 | if l is not None: |
|
3003 | 3007 | l.lock() |
|
3004 | 3008 | return l |
|
3005 | 3009 | |
|
3006 | 3010 | l = self._lock( |
|
3007 | 3011 | vfs=self.svfs, |
|
3008 | 3012 | lockname=b"lock", |
|
3009 | 3013 | wait=wait, |
|
3010 | 3014 | releasefn=None, |
|
3011 | 3015 | acquirefn=self.invalidate, |
|
3012 | 3016 | desc=_(b'repository %s') % self.origroot, |
|
3013 | 3017 | ) |
|
3014 | 3018 | self._lockref = weakref.ref(l) |
|
3015 | 3019 | return l |
|
3016 | 3020 | |
|
3017 | 3021 | def wlock(self, wait=True): |
|
3018 | 3022 | """Lock the non-store parts of the repository (everything under |
|
3019 | 3023 | .hg except .hg/store) and return a weak reference to the lock. |
|
3020 | 3024 | |
|
3021 | 3025 | Use this before modifying files in .hg. |
|
3022 | 3026 | |
|
3023 | 3027 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
3024 | 3028 | 'wlock' first to avoid a dead-lock hazard.""" |
|
3025 | 3029 | l = self._wlockref() if self._wlockref else None |
|
3026 | 3030 | if l is not None and l.held: |
|
3027 | 3031 | l.lock() |
|
3028 | 3032 | return l |
|
3029 | 3033 | |
|
3030 | 3034 | # We do not need to check for non-waiting lock acquisition. Such |
|
3031 | 3035 | # acquisition would not cause dead-lock as they would just fail. |
|
3032 | 3036 | if wait and ( |
|
3033 | 3037 | self.ui.configbool(b'devel', b'all-warnings') |
|
3034 | 3038 | or self.ui.configbool(b'devel', b'check-locks') |
|
3035 | 3039 | ): |
|
3036 | 3040 | if self._currentlock(self._lockref) is not None: |
|
3037 | 3041 | self.ui.develwarn(b'"wlock" acquired after "lock"') |
|
3038 | 3042 | |
|
3039 | 3043 | def unlock(): |
|
3040 | 3044 | if self.dirstate.pendingparentchange(): |
|
3041 | 3045 | self.dirstate.invalidate() |
|
3042 | 3046 | else: |
|
3043 | 3047 | self.dirstate.write(None) |
|
3044 | 3048 | |
|
3045 | 3049 | self._filecache[b'dirstate'].refresh() |
|
3046 | 3050 | |
|
3047 | 3051 | l = self._lock( |
|
3048 | 3052 | self.vfs, |
|
3049 | 3053 | b"wlock", |
|
3050 | 3054 | wait, |
|
3051 | 3055 | unlock, |
|
3052 | 3056 | self.invalidatedirstate, |
|
3053 | 3057 | _(b'working directory of %s') % self.origroot, |
|
3054 | 3058 | ) |
|
3055 | 3059 | self._wlockref = weakref.ref(l) |
|
3056 | 3060 | return l |
|
3057 | 3061 | |
|
3058 | 3062 | def _currentlock(self, lockref): |
|
3059 | 3063 | """Returns the lock if it's held, or None if it's not.""" |
|
3060 | 3064 | if lockref is None: |
|
3061 | 3065 | return None |
|
3062 | 3066 | l = lockref() |
|
3063 | 3067 | if l is None or not l.held: |
|
3064 | 3068 | return None |
|
3065 | 3069 | return l |
|
3066 | 3070 | |
|
3067 | 3071 | def currentwlock(self): |
|
3068 | 3072 | """Returns the wlock if it's held, or None if it's not.""" |
|
3069 | 3073 | return self._currentlock(self._wlockref) |
|
3070 | 3074 | |
|
3071 | 3075 | def checkcommitpatterns(self, wctx, match, status, fail): |
|
3072 | 3076 | """check for commit arguments that aren't committable""" |
|
3073 | 3077 | if match.isexact() or match.prefix(): |
|
3074 | 3078 | matched = set(status.modified + status.added + status.removed) |
|
3075 | 3079 | |
|
3076 | 3080 | for f in match.files(): |
|
3077 | 3081 | f = self.dirstate.normalize(f) |
|
3078 | 3082 | if f == b'.' or f in matched or f in wctx.substate: |
|
3079 | 3083 | continue |
|
3080 | 3084 | if f in status.deleted: |
|
3081 | 3085 | fail(f, _(b'file not found!')) |
|
3082 | 3086 | # Is it a directory that exists or used to exist? |
|
3083 | 3087 | if self.wvfs.isdir(f) or wctx.p1().hasdir(f): |
|
3084 | 3088 | d = f + b'/' |
|
3085 | 3089 | for mf in matched: |
|
3086 | 3090 | if mf.startswith(d): |
|
3087 | 3091 | break |
|
3088 | 3092 | else: |
|
3089 | 3093 | fail(f, _(b"no match under directory!")) |
|
3090 | 3094 | elif f not in self.dirstate: |
|
3091 | 3095 | fail(f, _(b"file not tracked!")) |
|
3092 | 3096 | |
|
3093 | 3097 | @unfilteredmethod |
|
3094 | 3098 | def commit( |
|
3095 | 3099 | self, |
|
3096 | 3100 | text=b"", |
|
3097 | 3101 | user=None, |
|
3098 | 3102 | date=None, |
|
3099 | 3103 | match=None, |
|
3100 | 3104 | force=False, |
|
3101 | 3105 | editor=None, |
|
3102 | 3106 | extra=None, |
|
3103 | 3107 | ): |
|
3104 | 3108 | """Add a new revision to current repository. |
|
3105 | 3109 | |
|
3106 | 3110 | Revision information is gathered from the working directory, |
|
3107 | 3111 | match can be used to filter the committed files. If editor is |
|
3108 | 3112 | supplied, it is called to get a commit message. |
|
3109 | 3113 | """ |
|
3110 | 3114 | if extra is None: |
|
3111 | 3115 | extra = {} |
|
3112 | 3116 | |
|
3113 | 3117 | def fail(f, msg): |
|
3114 | 3118 | raise error.InputError(b'%s: %s' % (f, msg)) |
|
3115 | 3119 | |
|
3116 | 3120 | if not match: |
|
3117 | 3121 | match = matchmod.always() |
|
3118 | 3122 | |
|
3119 | 3123 | if not force: |
|
3120 | 3124 | match.bad = fail |
|
3121 | 3125 | |
|
3122 | 3126 | # lock() for recent changelog (see issue4368) |
|
3123 | 3127 | with self.wlock(), self.lock(): |
|
3124 | 3128 | wctx = self[None] |
|
3125 | 3129 | merge = len(wctx.parents()) > 1 |
|
3126 | 3130 | |
|
3127 | 3131 | if not force and merge and not match.always(): |
|
3128 | 3132 | raise error.Abort( |
|
3129 | 3133 | _( |
|
3130 | 3134 | b'cannot partially commit a merge ' |
|
3131 | 3135 | b'(do not specify files or patterns)' |
|
3132 | 3136 | ) |
|
3133 | 3137 | ) |
|
3134 | 3138 | |
|
3135 | 3139 | status = self.status(match=match, clean=force) |
|
3136 | 3140 | if force: |
|
3137 | 3141 | status.modified.extend( |
|
3138 | 3142 | status.clean |
|
3139 | 3143 | ) # mq may commit clean files |
|
3140 | 3144 | |
|
3141 | 3145 | # check subrepos |
|
3142 | 3146 | subs, commitsubs, newstate = subrepoutil.precommit( |
|
3143 | 3147 | self.ui, wctx, status, match, force=force |
|
3144 | 3148 | ) |
|
3145 | 3149 | |
|
3146 | 3150 | # make sure all explicit patterns are matched |
|
3147 | 3151 | if not force: |
|
3148 | 3152 | self.checkcommitpatterns(wctx, match, status, fail) |
|
3149 | 3153 | |
|
3150 | 3154 | cctx = context.workingcommitctx( |
|
3151 | 3155 | self, status, text, user, date, extra |
|
3152 | 3156 | ) |
|
3153 | 3157 | |
|
3154 | 3158 | ms = mergestatemod.mergestate.read(self) |
|
3155 | 3159 | mergeutil.checkunresolved(ms) |
|
3156 | 3160 | |
|
3157 | 3161 | # internal config: ui.allowemptycommit |
|
3158 | 3162 | if cctx.isempty() and not self.ui.configbool( |
|
3159 | 3163 | b'ui', b'allowemptycommit' |
|
3160 | 3164 | ): |
|
3161 | 3165 | self.ui.debug(b'nothing to commit, clearing merge state\n') |
|
3162 | 3166 | ms.reset() |
|
3163 | 3167 | return None |
|
3164 | 3168 | |
|
3165 | 3169 | if merge and cctx.deleted(): |
|
3166 | 3170 | raise error.Abort(_(b"cannot commit merge with missing files")) |
|
3167 | 3171 | |
|
3168 | 3172 | if editor: |
|
3169 | 3173 | cctx._text = editor(self, cctx, subs) |
|
3170 | 3174 | edited = text != cctx._text |
|
3171 | 3175 | |
|
3172 | 3176 | # Save commit message in case this transaction gets rolled back |
|
3173 | 3177 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
3174 | 3178 | # the assumption that the user will use the same editor again. |
|
3175 | 3179 | msgfn = self.savecommitmessage(cctx._text) |
|
3176 | 3180 | |
|
3177 | 3181 | # commit subs and write new state |
|
3178 | 3182 | if subs: |
|
3179 | 3183 | uipathfn = scmutil.getuipathfn(self) |
|
3180 | 3184 | for s in sorted(commitsubs): |
|
3181 | 3185 | sub = wctx.sub(s) |
|
3182 | 3186 | self.ui.status( |
|
3183 | 3187 | _(b'committing subrepository %s\n') |
|
3184 | 3188 | % uipathfn(subrepoutil.subrelpath(sub)) |
|
3185 | 3189 | ) |
|
3186 | 3190 | sr = sub.commit(cctx._text, user, date) |
|
3187 | 3191 | newstate[s] = (newstate[s][0], sr) |
|
3188 | 3192 | subrepoutil.writestate(self, newstate) |
|
3189 | 3193 | |
|
3190 | 3194 | p1, p2 = self.dirstate.parents() |
|
3191 | 3195 | hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'') |
|
3192 | 3196 | try: |
|
3193 | 3197 | self.hook( |
|
3194 | 3198 | b"precommit", throw=True, parent1=hookp1, parent2=hookp2 |
|
3195 | 3199 | ) |
|
3196 | 3200 | with self.transaction(b'commit'): |
|
3197 | 3201 | ret = self.commitctx(cctx, True) |
|
3198 | 3202 | # update bookmarks, dirstate and mergestate |
|
3199 | 3203 | bookmarks.update(self, [p1, p2], ret) |
|
3200 | 3204 | cctx.markcommitted(ret) |
|
3201 | 3205 | ms.reset() |
|
3202 | 3206 | except: # re-raises |
|
3203 | 3207 | if edited: |
|
3204 | 3208 | self.ui.write( |
|
3205 | 3209 | _(b'note: commit message saved in %s\n') % msgfn |
|
3206 | 3210 | ) |
|
3207 | 3211 | self.ui.write( |
|
3208 | 3212 | _( |
|
3209 | 3213 | b"note: use 'hg commit --logfile " |
|
3210 | 3214 | b".hg/last-message.txt --edit' to reuse it\n" |
|
3211 | 3215 | ) |
|
3212 | 3216 | ) |
|
3213 | 3217 | raise |
|
3214 | 3218 | |
|
3215 | 3219 | def commithook(unused_success): |
|
3216 | 3220 | # hack for command that use a temporary commit (eg: histedit) |
|
3217 | 3221 | # temporary commit got stripped before hook release |
|
3218 | 3222 | if self.changelog.hasnode(ret): |
|
3219 | 3223 | self.hook( |
|
3220 | 3224 | b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2 |
|
3221 | 3225 | ) |
|
3222 | 3226 | |
|
3223 | 3227 | self._afterlock(commithook) |
|
3224 | 3228 | return ret |
|
3225 | 3229 | |
|
3226 | 3230 | @unfilteredmethod |
|
3227 | 3231 | def commitctx(self, ctx, error=False, origctx=None): |
|
3228 | 3232 | return commit.commitctx(self, ctx, error=error, origctx=origctx) |
|
3229 | 3233 | |
|
3230 | 3234 | @unfilteredmethod |
|
3231 | 3235 | def destroying(self): |
|
3232 | 3236 | """Inform the repository that nodes are about to be destroyed. |
|
3233 | 3237 | Intended for use by strip and rollback, so there's a common |
|
3234 | 3238 | place for anything that has to be done before destroying history. |
|
3235 | 3239 | |
|
3236 | 3240 | This is mostly useful for saving state that is in memory and waiting |
|
3237 | 3241 | to be flushed when the current lock is released. Because a call to |
|
3238 | 3242 | destroyed is imminent, the repo will be invalidated causing those |
|
3239 | 3243 | changes to stay in memory (waiting for the next unlock), or vanish |
|
3240 | 3244 | completely. |
|
3241 | 3245 | """ |
|
3242 | 3246 | # When using the same lock to commit and strip, the phasecache is left |
|
3243 | 3247 | # dirty after committing. Then when we strip, the repo is invalidated, |
|
3244 | 3248 | # causing those changes to disappear. |
|
3245 | 3249 | if '_phasecache' in vars(self): |
|
3246 | 3250 | self._phasecache.write() |
|
3247 | 3251 | |
|
3248 | 3252 | @unfilteredmethod |
|
3249 | 3253 | def destroyed(self): |
|
3250 | 3254 | """Inform the repository that nodes have been destroyed. |
|
3251 | 3255 | Intended for use by strip and rollback, so there's a common |
|
3252 | 3256 | place for anything that has to be done after destroying history. |
|
3253 | 3257 | """ |
|
3254 | 3258 | # When one tries to: |
|
3255 | 3259 | # 1) destroy nodes thus calling this method (e.g. strip) |
|
3256 | 3260 | # 2) use phasecache somewhere (e.g. commit) |
|
3257 | 3261 | # |
|
3258 | 3262 | # then 2) will fail because the phasecache contains nodes that were |
|
3259 | 3263 | # removed. We can either remove phasecache from the filecache, |
|
3260 | 3264 | # causing it to reload next time it is accessed, or simply filter |
|
3261 | 3265 | # the removed nodes now and write the updated cache. |
|
3262 | 3266 | self._phasecache.filterunknown(self) |
|
3263 | 3267 | self._phasecache.write() |
|
3264 | 3268 | |
|
3265 | 3269 | # refresh all repository caches |
|
3266 | 3270 | self.updatecaches() |
|
3267 | 3271 | |
|
3268 | 3272 | # Ensure the persistent tag cache is updated. Doing it now |
|
3269 | 3273 | # means that the tag cache only has to worry about destroyed |
|
3270 | 3274 | # heads immediately after a strip/rollback. That in turn |
|
3271 | 3275 | # guarantees that "cachetip == currenttip" (comparing both rev |
|
3272 | 3276 | # and node) always means no nodes have been added or destroyed. |
|
3273 | 3277 | |
|
3274 | 3278 | # XXX this is suboptimal when qrefresh'ing: we strip the current |
|
3275 | 3279 | # head, refresh the tag cache, then immediately add a new head. |
|
3276 | 3280 | # But I think doing it this way is necessary for the "instant |
|
3277 | 3281 | # tag cache retrieval" case to work. |
|
3278 | 3282 | self.invalidate() |
|
3279 | 3283 | |
|
3280 | 3284 | def status( |
|
3281 | 3285 | self, |
|
3282 | 3286 | node1=b'.', |
|
3283 | 3287 | node2=None, |
|
3284 | 3288 | match=None, |
|
3285 | 3289 | ignored=False, |
|
3286 | 3290 | clean=False, |
|
3287 | 3291 | unknown=False, |
|
3288 | 3292 | listsubrepos=False, |
|
3289 | 3293 | ): |
|
3290 | 3294 | '''a convenience method that calls node1.status(node2)''' |
|
3291 | 3295 | return self[node1].status( |
|
3292 | 3296 | node2, match, ignored, clean, unknown, listsubrepos |
|
3293 | 3297 | ) |
|
3294 | 3298 | |
|
3295 | 3299 | def addpostdsstatus(self, ps): |
|
3296 | 3300 | """Add a callback to run within the wlock, at the point at which status |
|
3297 | 3301 | fixups happen. |
|
3298 | 3302 | |
|
3299 | 3303 | On status completion, callback(wctx, status) will be called with the |
|
3300 | 3304 | wlock held, unless the dirstate has changed from underneath or the wlock |
|
3301 | 3305 | couldn't be grabbed. |
|
3302 | 3306 | |
|
3303 | 3307 | Callbacks should not capture and use a cached copy of the dirstate -- |
|
3304 | 3308 | it might change in the meanwhile. Instead, they should access the |
|
3305 | 3309 | dirstate via wctx.repo().dirstate. |
|
3306 | 3310 | |
|
3307 | 3311 | This list is emptied out after each status run -- extensions should |
|
3308 | 3312 | make sure it adds to this list each time dirstate.status is called. |
|
3309 | 3313 | Extensions should also make sure they don't call this for statuses |
|
3310 | 3314 | that don't involve the dirstate. |
|
3311 | 3315 | """ |
|
3312 | 3316 | |
|
3313 | 3317 | # The list is located here for uniqueness reasons -- it is actually |
|
3314 | 3318 | # managed by the workingctx, but that isn't unique per-repo. |
|
3315 | 3319 | self._postdsstatus.append(ps) |
|
3316 | 3320 | |
|
3317 | 3321 | def postdsstatus(self): |
|
3318 | 3322 | """Used by workingctx to get the list of post-dirstate-status hooks.""" |
|
3319 | 3323 | return self._postdsstatus |
|
3320 | 3324 | |
|
3321 | 3325 | def clearpostdsstatus(self): |
|
3322 | 3326 | """Used by workingctx to clear post-dirstate-status hooks.""" |
|
3323 | 3327 | del self._postdsstatus[:] |
|
3324 | 3328 | |
|
3325 | 3329 | def heads(self, start=None): |
|
3326 | 3330 | if start is None: |
|
3327 | 3331 | cl = self.changelog |
|
3328 | 3332 | headrevs = reversed(cl.headrevs()) |
|
3329 | 3333 | return [cl.node(rev) for rev in headrevs] |
|
3330 | 3334 | |
|
3331 | 3335 | heads = self.changelog.heads(start) |
|
3332 | 3336 | # sort the output in rev descending order |
|
3333 | 3337 | return sorted(heads, key=self.changelog.rev, reverse=True) |
|
3334 | 3338 | |
|
3335 | 3339 | def branchheads(self, branch=None, start=None, closed=False): |
|
3336 | 3340 | """return a (possibly filtered) list of heads for the given branch |
|
3337 | 3341 | |
|
3338 | 3342 | Heads are returned in topological order, from newest to oldest. |
|
3339 | 3343 | If branch is None, use the dirstate branch. |
|
3340 | 3344 | If start is not None, return only heads reachable from start. |
|
3341 | 3345 | If closed is True, return heads that are marked as closed as well. |
|
3342 | 3346 | """ |
|
3343 | 3347 | if branch is None: |
|
3344 | 3348 | branch = self[None].branch() |
|
3345 | 3349 | branches = self.branchmap() |
|
3346 | 3350 | if not branches.hasbranch(branch): |
|
3347 | 3351 | return [] |
|
3348 | 3352 | # the cache returns heads ordered lowest to highest |
|
3349 | 3353 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
|
3350 | 3354 | if start is not None: |
|
3351 | 3355 | # filter out the heads that cannot be reached from startrev |
|
3352 | 3356 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
3353 | 3357 | bheads = [h for h in bheads if h in fbheads] |
|
3354 | 3358 | return bheads |
|
3355 | 3359 | |
|
3356 | 3360 | def branches(self, nodes): |
|
3357 | 3361 | if not nodes: |
|
3358 | 3362 | nodes = [self.changelog.tip()] |
|
3359 | 3363 | b = [] |
|
3360 | 3364 | for n in nodes: |
|
3361 | 3365 | t = n |
|
3362 | 3366 | while True: |
|
3363 | 3367 | p = self.changelog.parents(n) |
|
3364 | 3368 | if p[1] != self.nullid or p[0] == self.nullid: |
|
3365 | 3369 | b.append((t, n, p[0], p[1])) |
|
3366 | 3370 | break |
|
3367 | 3371 | n = p[0] |
|
3368 | 3372 | return b |
|
3369 | 3373 | |
|
3370 | 3374 | def between(self, pairs): |
|
3371 | 3375 | r = [] |
|
3372 | 3376 | |
|
3373 | 3377 | for top, bottom in pairs: |
|
3374 | 3378 | n, l, i = top, [], 0 |
|
3375 | 3379 | f = 1 |
|
3376 | 3380 | |
|
3377 | 3381 | while n != bottom and n != self.nullid: |
|
3378 | 3382 | p = self.changelog.parents(n)[0] |
|
3379 | 3383 | if i == f: |
|
3380 | 3384 | l.append(n) |
|
3381 | 3385 | f = f * 2 |
|
3382 | 3386 | n = p |
|
3383 | 3387 | i += 1 |
|
3384 | 3388 | |
|
3385 | 3389 | r.append(l) |
|
3386 | 3390 | |
|
3387 | 3391 | return r |
|
3388 | 3392 | |
|
3389 | 3393 | def checkpush(self, pushop): |
|
3390 | 3394 | """Extensions can override this function if additional checks have |
|
3391 | 3395 | to be performed before pushing, or call it if they override push |
|
3392 | 3396 | command. |
|
3393 | 3397 | """ |
|
3394 | 3398 | |
|
3395 | 3399 | @unfilteredpropertycache |
|
3396 | 3400 | def prepushoutgoinghooks(self): |
|
3397 | 3401 | """Return util.hooks consists of a pushop with repo, remote, outgoing |
|
3398 | 3402 | methods, which are called before pushing changesets. |
|
3399 | 3403 | """ |
|
3400 | 3404 | return util.hooks() |
|
3401 | 3405 | |
|
3402 | 3406 | def pushkey(self, namespace, key, old, new): |
|
3403 | 3407 | try: |
|
3404 | 3408 | tr = self.currenttransaction() |
|
3405 | 3409 | hookargs = {} |
|
3406 | 3410 | if tr is not None: |
|
3407 | 3411 | hookargs.update(tr.hookargs) |
|
3408 | 3412 | hookargs = pycompat.strkwargs(hookargs) |
|
3409 | 3413 | hookargs['namespace'] = namespace |
|
3410 | 3414 | hookargs['key'] = key |
|
3411 | 3415 | hookargs['old'] = old |
|
3412 | 3416 | hookargs['new'] = new |
|
3413 | 3417 | self.hook(b'prepushkey', throw=True, **hookargs) |
|
3414 | 3418 | except error.HookAbort as exc: |
|
3415 | 3419 | self.ui.write_err(_(b"pushkey-abort: %s\n") % exc) |
|
3416 | 3420 | if exc.hint: |
|
3417 | 3421 | self.ui.write_err(_(b"(%s)\n") % exc.hint) |
|
3418 | 3422 | return False |
|
3419 | 3423 | self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key)) |
|
3420 | 3424 | ret = pushkey.push(self, namespace, key, old, new) |
|
3421 | 3425 | |
|
3422 | 3426 | def runhook(unused_success): |
|
3423 | 3427 | self.hook( |
|
3424 | 3428 | b'pushkey', |
|
3425 | 3429 | namespace=namespace, |
|
3426 | 3430 | key=key, |
|
3427 | 3431 | old=old, |
|
3428 | 3432 | new=new, |
|
3429 | 3433 | ret=ret, |
|
3430 | 3434 | ) |
|
3431 | 3435 | |
|
3432 | 3436 | self._afterlock(runhook) |
|
3433 | 3437 | return ret |
|
3434 | 3438 | |
|
3435 | 3439 | def listkeys(self, namespace): |
|
3436 | 3440 | self.hook(b'prelistkeys', throw=True, namespace=namespace) |
|
3437 | 3441 | self.ui.debug(b'listing keys for "%s"\n' % namespace) |
|
3438 | 3442 | values = pushkey.list(self, namespace) |
|
3439 | 3443 | self.hook(b'listkeys', namespace=namespace, values=values) |
|
3440 | 3444 | return values |
|
3441 | 3445 | |
|
3442 | 3446 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
3443 | 3447 | '''used to test argument passing over the wire''' |
|
3444 | 3448 | return b"%s %s %s %s %s" % ( |
|
3445 | 3449 | one, |
|
3446 | 3450 | two, |
|
3447 | 3451 | pycompat.bytestr(three), |
|
3448 | 3452 | pycompat.bytestr(four), |
|
3449 | 3453 | pycompat.bytestr(five), |
|
3450 | 3454 | ) |
|
3451 | 3455 | |
|
3452 | 3456 | def savecommitmessage(self, text): |
|
3453 | 3457 | fp = self.vfs(b'last-message.txt', b'wb') |
|
3454 | 3458 | try: |
|
3455 | 3459 | fp.write(text) |
|
3456 | 3460 | finally: |
|
3457 | 3461 | fp.close() |
|
3458 | 3462 | return self.pathto(fp.name[len(self.root) + 1 :]) |
|
3459 | 3463 | |
|
3460 | 3464 | def register_wanted_sidedata(self, category): |
|
3461 | 3465 | if repository.REPO_FEATURE_SIDE_DATA not in self.features: |
|
3462 | 3466 | # Only revlogv2 repos can want sidedata. |
|
3463 | 3467 | return |
|
3464 | 3468 | self._wanted_sidedata.add(pycompat.bytestr(category)) |
|
3465 | 3469 | |
|
3466 | 3470 | def register_sidedata_computer( |
|
3467 | 3471 | self, kind, category, keys, computer, flags, replace=False |
|
3468 | 3472 | ): |
|
3469 | 3473 | if kind not in revlogconst.ALL_KINDS: |
|
3470 | 3474 | msg = _(b"unexpected revlog kind '%s'.") |
|
3471 | 3475 | raise error.ProgrammingError(msg % kind) |
|
3472 | 3476 | category = pycompat.bytestr(category) |
|
3473 | 3477 | already_registered = category in self._sidedata_computers.get(kind, []) |
|
3474 | 3478 | if already_registered and not replace: |
|
3475 | 3479 | msg = _( |
|
3476 | 3480 | b"cannot register a sidedata computer twice for category '%s'." |
|
3477 | 3481 | ) |
|
3478 | 3482 | raise error.ProgrammingError(msg % category) |
|
3479 | 3483 | if replace and not already_registered: |
|
3480 | 3484 | msg = _( |
|
3481 | 3485 | b"cannot replace a sidedata computer that isn't registered " |
|
3482 | 3486 | b"for category '%s'." |
|
3483 | 3487 | ) |
|
3484 | 3488 | raise error.ProgrammingError(msg % category) |
|
3485 | 3489 | self._sidedata_computers.setdefault(kind, {}) |
|
3486 | 3490 | self._sidedata_computers[kind][category] = (keys, computer, flags) |
|
3487 | 3491 | |
|
3488 | 3492 | |
|
3489 | 3493 | # used to avoid circular references so destructors work |
|
3490 | 3494 | def aftertrans(files): |
|
3491 | 3495 | renamefiles = [tuple(t) for t in files] |
|
3492 | 3496 | |
|
3493 | 3497 | def a(): |
|
3494 | 3498 | for vfs, src, dest in renamefiles: |
|
3495 | 3499 | # if src and dest refer to a same file, vfs.rename is a no-op, |
|
3496 | 3500 | # leaving both src and dest on disk. delete dest to make sure |
|
3497 | 3501 | # the rename couldn't be such a no-op. |
|
3498 | 3502 | vfs.tryunlink(dest) |
|
3499 | 3503 | try: |
|
3500 | 3504 | vfs.rename(src, dest) |
|
3501 | 3505 | except OSError as exc: # journal file does not yet exist |
|
3502 | 3506 | if exc.errno != errno.ENOENT: |
|
3503 | 3507 | raise |
|
3504 | 3508 | |
|
3505 | 3509 | return a |
|
3506 | 3510 | |
|
3507 | 3511 | |
|
3508 | 3512 | def undoname(fn): |
|
3509 | 3513 | base, name = os.path.split(fn) |
|
3510 | 3514 | assert name.startswith(b'journal') |
|
3511 | 3515 | return os.path.join(base, name.replace(b'journal', b'undo', 1)) |
|
3512 | 3516 | |
|
3513 | 3517 | |
|
3514 | 3518 | def instance(ui, path, create, intents=None, createopts=None): |
|
3515 | 3519 | localpath = urlutil.urllocalpath(path) |
|
3516 | 3520 | if create: |
|
3517 | 3521 | createrepository(ui, localpath, createopts=createopts) |
|
3518 | 3522 | |
|
3519 | 3523 | return makelocalrepository(ui, localpath, intents=intents) |
|
3520 | 3524 | |
|
3521 | 3525 | |
|
3522 | 3526 | def islocal(path): |
|
3523 | 3527 | return True |
|
3524 | 3528 | |
|
3525 | 3529 | |
|
3526 | 3530 | def defaultcreateopts(ui, createopts=None): |
|
3527 | 3531 | """Populate the default creation options for a repository. |
|
3528 | 3532 | |
|
3529 | 3533 | A dictionary of explicitly requested creation options can be passed |
|
3530 | 3534 | in. Missing keys will be populated. |
|
3531 | 3535 | """ |
|
3532 | 3536 | createopts = dict(createopts or {}) |
|
3533 | 3537 | |
|
3534 | 3538 | if b'backend' not in createopts: |
|
3535 | 3539 | # experimental config: storage.new-repo-backend |
|
3536 | 3540 | createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend') |
|
3537 | 3541 | |
|
3538 | 3542 | return createopts |
|
3539 | 3543 | |
|
3540 | 3544 | |
|
3541 | 3545 | def clone_requirements(ui, createopts, srcrepo): |
|
3542 | 3546 | """clone the requirements of a local repo for a local clone |
|
3543 | 3547 | |
|
3544 | 3548 | The store requirements are unchanged while the working copy requirements |
|
3545 | 3549 | depends on the configuration |
|
3546 | 3550 | """ |
|
3547 | 3551 | target_requirements = set() |
|
3548 | 3552 | if not srcrepo.requirements: |
|
3549 | 3553 | # this is a legacy revlog "v0" repository, we cannot do anything fancy |
|
3550 | 3554 | # with it. |
|
3551 | 3555 | return target_requirements |
|
3552 | 3556 | createopts = defaultcreateopts(ui, createopts=createopts) |
|
3553 | 3557 | for r in newreporequirements(ui, createopts): |
|
3554 | 3558 | if r in requirementsmod.WORKING_DIR_REQUIREMENTS: |
|
3555 | 3559 | target_requirements.add(r) |
|
3556 | 3560 | |
|
3557 | 3561 | for r in srcrepo.requirements: |
|
3558 | 3562 | if r not in requirementsmod.WORKING_DIR_REQUIREMENTS: |
|
3559 | 3563 | target_requirements.add(r) |
|
3560 | 3564 | return target_requirements |
|
3561 | 3565 | |
|
3562 | 3566 | |
|
3563 | 3567 | def newreporequirements(ui, createopts): |
|
3564 | 3568 | """Determine the set of requirements for a new local repository. |
|
3565 | 3569 | |
|
3566 | 3570 | Extensions can wrap this function to specify custom requirements for |
|
3567 | 3571 | new repositories. |
|
3568 | 3572 | """ |
|
3569 | 3573 | |
|
3570 | 3574 | if b'backend' not in createopts: |
|
3571 | 3575 | raise error.ProgrammingError( |
|
3572 | 3576 | b'backend key not present in createopts; ' |
|
3573 | 3577 | b'was defaultcreateopts() called?' |
|
3574 | 3578 | ) |
|
3575 | 3579 | |
|
3576 | 3580 | if createopts[b'backend'] != b'revlogv1': |
|
3577 | 3581 | raise error.Abort( |
|
3578 | 3582 | _( |
|
3579 | 3583 | b'unable to determine repository requirements for ' |
|
3580 | 3584 | b'storage backend: %s' |
|
3581 | 3585 | ) |
|
3582 | 3586 | % createopts[b'backend'] |
|
3583 | 3587 | ) |
|
3584 | 3588 | |
|
3585 | 3589 | requirements = {requirementsmod.REVLOGV1_REQUIREMENT} |
|
3586 | 3590 | if ui.configbool(b'format', b'usestore'): |
|
3587 | 3591 | requirements.add(requirementsmod.STORE_REQUIREMENT) |
|
3588 | 3592 | if ui.configbool(b'format', b'usefncache'): |
|
3589 | 3593 | requirements.add(requirementsmod.FNCACHE_REQUIREMENT) |
|
3590 | 3594 | if ui.configbool(b'format', b'dotencode'): |
|
3591 | 3595 | requirements.add(requirementsmod.DOTENCODE_REQUIREMENT) |
|
3592 | 3596 | |
|
3593 | 3597 | compengines = ui.configlist(b'format', b'revlog-compression') |
|
3594 | 3598 | for compengine in compengines: |
|
3595 | 3599 | if compengine in util.compengines: |
|
3596 | 3600 | engine = util.compengines[compengine] |
|
3597 | 3601 | if engine.available() and engine.revlogheader(): |
|
3598 | 3602 | break |
|
3599 | 3603 | else: |
|
3600 | 3604 | raise error.Abort( |
|
3601 | 3605 | _( |
|
3602 | 3606 | b'compression engines %s defined by ' |
|
3603 | 3607 | b'format.revlog-compression not available' |
|
3604 | 3608 | ) |
|
3605 | 3609 | % b', '.join(b'"%s"' % e for e in compengines), |
|
3606 | 3610 | hint=_( |
|
3607 | 3611 | b'run "hg debuginstall" to list available ' |
|
3608 | 3612 | b'compression engines' |
|
3609 | 3613 | ), |
|
3610 | 3614 | ) |
|
3611 | 3615 | |
|
3612 | 3616 | # zlib is the historical default and doesn't need an explicit requirement. |
|
3613 | 3617 | if compengine == b'zstd': |
|
3614 | 3618 | requirements.add(b'revlog-compression-zstd') |
|
3615 | 3619 | elif compengine != b'zlib': |
|
3616 | 3620 | requirements.add(b'exp-compression-%s' % compengine) |
|
3617 | 3621 | |
|
3618 | 3622 | if scmutil.gdinitconfig(ui): |
|
3619 | 3623 | requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT) |
|
3620 | 3624 | if ui.configbool(b'format', b'sparse-revlog'): |
|
3621 | 3625 | requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT) |
|
3622 | 3626 | |
|
3623 | 3627 | # experimental config: format.use-dirstate-v2 |
|
3624 | 3628 | # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py` |
|
3625 | 3629 | if ui.configbool(b'format', b'use-dirstate-v2'): |
|
3626 | 3630 | requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT) |
|
3627 | 3631 | |
|
3628 | 3632 | # experimental config: format.exp-use-copies-side-data-changeset |
|
3629 | 3633 | if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'): |
|
3630 | 3634 | requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT) |
|
3631 | 3635 | requirements.add(requirementsmod.COPIESSDC_REQUIREMENT) |
|
3632 | 3636 | if ui.configbool(b'experimental', b'treemanifest'): |
|
3633 | 3637 | requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT) |
|
3634 | 3638 | |
|
3635 | 3639 | changelogv2 = ui.config(b'format', b'exp-use-changelog-v2') |
|
3636 | 3640 | if changelogv2 == b'enable-unstable-format-and-corrupt-my-data': |
|
3637 | 3641 | requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT) |
|
3638 | 3642 | |
|
3639 | 3643 | revlogv2 = ui.config(b'experimental', b'revlogv2') |
|
3640 | 3644 | if revlogv2 == b'enable-unstable-format-and-corrupt-my-data': |
|
3641 | 3645 | requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT) |
|
3642 | 3646 | requirements.add(requirementsmod.REVLOGV2_REQUIREMENT) |
|
3643 | 3647 | # experimental config: format.internal-phase |
|
3644 | 3648 | if ui.configbool(b'format', b'internal-phase'): |
|
3645 | 3649 | requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT) |
|
3646 | 3650 | |
|
3647 | 3651 | if createopts.get(b'narrowfiles'): |
|
3648 | 3652 | requirements.add(requirementsmod.NARROW_REQUIREMENT) |
|
3649 | 3653 | |
|
3650 | 3654 | if createopts.get(b'lfs'): |
|
3651 | 3655 | requirements.add(b'lfs') |
|
3652 | 3656 | |
|
3653 | 3657 | if ui.configbool(b'format', b'bookmarks-in-store'): |
|
3654 | 3658 | requirements.add(requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT) |
|
3655 | 3659 | |
|
3656 | 3660 | if ui.configbool(b'format', b'use-persistent-nodemap'): |
|
3657 | 3661 | requirements.add(requirementsmod.NODEMAP_REQUIREMENT) |
|
3658 | 3662 | |
|
3659 | 3663 | # if share-safe is enabled, let's create the new repository with the new |
|
3660 | 3664 | # requirement |
|
3661 | 3665 | if ui.configbool(b'format', b'use-share-safe'): |
|
3662 | 3666 | requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
3663 | 3667 | |
|
3664 | 3668 | # if we are creating a share-repo¹ we have to handle requirement |
|
3665 | 3669 | # differently. |
|
3666 | 3670 | # |
|
3667 | 3671 | # [1] (i.e. reusing the store from another repository, just having a |
|
3668 | 3672 | # working copy) |
|
3669 | 3673 | if b'sharedrepo' in createopts: |
|
3670 | 3674 | source_requirements = set(createopts[b'sharedrepo'].requirements) |
|
3671 | 3675 | |
|
3672 | 3676 | if requirementsmod.SHARESAFE_REQUIREMENT not in source_requirements: |
|
3673 | 3677 | # share to an old school repository, we have to copy the |
|
3674 | 3678 | # requirements and hope for the best. |
|
3675 | 3679 | requirements = source_requirements |
|
3676 | 3680 | else: |
|
3677 | 3681 | # We have control on the working copy only, so "copy" the non |
|
3678 | 3682 | # working copy part over, ignoring previous logic. |
|
3679 | 3683 | to_drop = set() |
|
3680 | 3684 | for req in requirements: |
|
3681 | 3685 | if req in requirementsmod.WORKING_DIR_REQUIREMENTS: |
|
3682 | 3686 | continue |
|
3683 | 3687 | if req in source_requirements: |
|
3684 | 3688 | continue |
|
3685 | 3689 | to_drop.add(req) |
|
3686 | 3690 | requirements -= to_drop |
|
3687 | 3691 | requirements |= source_requirements |
|
3688 | 3692 | |
|
3689 | 3693 | if createopts.get(b'sharedrelative'): |
|
3690 | 3694 | requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT) |
|
3691 | 3695 | else: |
|
3692 | 3696 | requirements.add(requirementsmod.SHARED_REQUIREMENT) |
|
3693 | 3697 | |
|
3698 | tracked_key = ui.configint(b'format', b'exp-dirstate-tracked-key-version') | |
|
3699 | if tracked_key: | |
|
3700 | if tracked_key != 1: | |
|
3701 | msg = _("ignoring unknown tracked key version: %d\n") | |
|
3702 | hint = _( | |
|
3703 | "see `hg help config.format.exp-dirstate-tracked-key-version" | |
|
3704 | ) | |
|
3705 | ui.warn(msg % tracked_key, hint=hint) | |
|
3706 | else: | |
|
3707 | requirements.add(requirementsmod.DIRSTATE_TRACKED_KEY_V1) | |
|
3708 | ||
|
3694 | 3709 | return requirements |
|
3695 | 3710 | |
|
3696 | 3711 | |
|
3697 | 3712 | def checkrequirementscompat(ui, requirements): |
|
3698 | 3713 | """Checks compatibility of repository requirements enabled and disabled. |
|
3699 | 3714 | |
|
3700 | 3715 | Returns a set of requirements which needs to be dropped because dependend |
|
3701 | 3716 | requirements are not enabled. Also warns users about it""" |
|
3702 | 3717 | |
|
3703 | 3718 | dropped = set() |
|
3704 | 3719 | |
|
3705 | 3720 | if requirementsmod.STORE_REQUIREMENT not in requirements: |
|
3706 | 3721 | if requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT in requirements: |
|
3707 | 3722 | ui.warn( |
|
3708 | 3723 | _( |
|
3709 | 3724 | b'ignoring enabled \'format.bookmarks-in-store\' config ' |
|
3710 | 3725 | b'beacuse it is incompatible with disabled ' |
|
3711 | 3726 | b'\'format.usestore\' config\n' |
|
3712 | 3727 | ) |
|
3713 | 3728 | ) |
|
3714 | 3729 | dropped.add(requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT) |
|
3715 | 3730 | |
|
3716 | 3731 | if ( |
|
3717 | 3732 | requirementsmod.SHARED_REQUIREMENT in requirements |
|
3718 | 3733 | or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements |
|
3719 | 3734 | ): |
|
3720 | 3735 | raise error.Abort( |
|
3721 | 3736 | _( |
|
3722 | 3737 | b"cannot create shared repository as source was created" |
|
3723 | 3738 | b" with 'format.usestore' config disabled" |
|
3724 | 3739 | ) |
|
3725 | 3740 | ) |
|
3726 | 3741 | |
|
3727 | 3742 | if requirementsmod.SHARESAFE_REQUIREMENT in requirements: |
|
3728 | 3743 | if ui.hasconfig(b'format', b'use-share-safe'): |
|
3729 | 3744 | msg = _( |
|
3730 | 3745 | b"ignoring enabled 'format.use-share-safe' config because " |
|
3731 | 3746 | b"it is incompatible with disabled 'format.usestore'" |
|
3732 | 3747 | b" config\n" |
|
3733 | 3748 | ) |
|
3734 | 3749 | ui.warn(msg) |
|
3735 | 3750 | dropped.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
3736 | 3751 | |
|
3737 | 3752 | return dropped |
|
3738 | 3753 | |
|
3739 | 3754 | |
|
3740 | 3755 | def filterknowncreateopts(ui, createopts): |
|
3741 | 3756 | """Filters a dict of repo creation options against options that are known. |
|
3742 | 3757 | |
|
3743 | 3758 | Receives a dict of repo creation options and returns a dict of those |
|
3744 | 3759 | options that we don't know how to handle. |
|
3745 | 3760 | |
|
3746 | 3761 | This function is called as part of repository creation. If the |
|
3747 | 3762 | returned dict contains any items, repository creation will not |
|
3748 | 3763 | be allowed, as it means there was a request to create a repository |
|
3749 | 3764 | with options not recognized by loaded code. |
|
3750 | 3765 | |
|
3751 | 3766 | Extensions can wrap this function to filter out creation options |
|
3752 | 3767 | they know how to handle. |
|
3753 | 3768 | """ |
|
3754 | 3769 | known = { |
|
3755 | 3770 | b'backend', |
|
3756 | 3771 | b'lfs', |
|
3757 | 3772 | b'narrowfiles', |
|
3758 | 3773 | b'sharedrepo', |
|
3759 | 3774 | b'sharedrelative', |
|
3760 | 3775 | b'shareditems', |
|
3761 | 3776 | b'shallowfilestore', |
|
3762 | 3777 | } |
|
3763 | 3778 | |
|
3764 | 3779 | return {k: v for k, v in createopts.items() if k not in known} |
|
3765 | 3780 | |
|
3766 | 3781 | |
|
3767 | 3782 | def createrepository(ui, path, createopts=None, requirements=None): |
|
3768 | 3783 | """Create a new repository in a vfs. |
|
3769 | 3784 | |
|
3770 | 3785 | ``path`` path to the new repo's working directory. |
|
3771 | 3786 | ``createopts`` options for the new repository. |
|
3772 | 3787 | ``requirement`` predefined set of requirements. |
|
3773 | 3788 | (incompatible with ``createopts``) |
|
3774 | 3789 | |
|
3775 | 3790 | The following keys for ``createopts`` are recognized: |
|
3776 | 3791 | |
|
3777 | 3792 | backend |
|
3778 | 3793 | The storage backend to use. |
|
3779 | 3794 | lfs |
|
3780 | 3795 | Repository will be created with ``lfs`` requirement. The lfs extension |
|
3781 | 3796 | will automatically be loaded when the repository is accessed. |
|
3782 | 3797 | narrowfiles |
|
3783 | 3798 | Set up repository to support narrow file storage. |
|
3784 | 3799 | sharedrepo |
|
3785 | 3800 | Repository object from which storage should be shared. |
|
3786 | 3801 | sharedrelative |
|
3787 | 3802 | Boolean indicating if the path to the shared repo should be |
|
3788 | 3803 | stored as relative. By default, the pointer to the "parent" repo |
|
3789 | 3804 | is stored as an absolute path. |
|
3790 | 3805 | shareditems |
|
3791 | 3806 | Set of items to share to the new repository (in addition to storage). |
|
3792 | 3807 | shallowfilestore |
|
3793 | 3808 | Indicates that storage for files should be shallow (not all ancestor |
|
3794 | 3809 | revisions are known). |
|
3795 | 3810 | """ |
|
3796 | 3811 | |
|
3797 | 3812 | if requirements is not None: |
|
3798 | 3813 | if createopts is not None: |
|
3799 | 3814 | msg = b'cannot specify both createopts and requirements' |
|
3800 | 3815 | raise error.ProgrammingError(msg) |
|
3801 | 3816 | createopts = {} |
|
3802 | 3817 | else: |
|
3803 | 3818 | createopts = defaultcreateopts(ui, createopts=createopts) |
|
3804 | 3819 | |
|
3805 | 3820 | unknownopts = filterknowncreateopts(ui, createopts) |
|
3806 | 3821 | |
|
3807 | 3822 | if not isinstance(unknownopts, dict): |
|
3808 | 3823 | raise error.ProgrammingError( |
|
3809 | 3824 | b'filterknowncreateopts() did not return a dict' |
|
3810 | 3825 | ) |
|
3811 | 3826 | |
|
3812 | 3827 | if unknownopts: |
|
3813 | 3828 | raise error.Abort( |
|
3814 | 3829 | _( |
|
3815 | 3830 | b'unable to create repository because of unknown ' |
|
3816 | 3831 | b'creation option: %s' |
|
3817 | 3832 | ) |
|
3818 | 3833 | % b', '.join(sorted(unknownopts)), |
|
3819 | 3834 | hint=_(b'is a required extension not loaded?'), |
|
3820 | 3835 | ) |
|
3821 | 3836 | |
|
3822 | 3837 | requirements = newreporequirements(ui, createopts=createopts) |
|
3823 | 3838 | requirements -= checkrequirementscompat(ui, requirements) |
|
3824 | 3839 | |
|
3825 | 3840 | wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
|
3826 | 3841 | |
|
3827 | 3842 | hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg')) |
|
3828 | 3843 | if hgvfs.exists(): |
|
3829 | 3844 | raise error.RepoError(_(b'repository %s already exists') % path) |
|
3830 | 3845 | |
|
3831 | 3846 | if b'sharedrepo' in createopts: |
|
3832 | 3847 | sharedpath = createopts[b'sharedrepo'].sharedpath |
|
3833 | 3848 | |
|
3834 | 3849 | if createopts.get(b'sharedrelative'): |
|
3835 | 3850 | try: |
|
3836 | 3851 | sharedpath = os.path.relpath(sharedpath, hgvfs.base) |
|
3837 | 3852 | sharedpath = util.pconvert(sharedpath) |
|
3838 | 3853 | except (IOError, ValueError) as e: |
|
3839 | 3854 | # ValueError is raised on Windows if the drive letters differ |
|
3840 | 3855 | # on each path. |
|
3841 | 3856 | raise error.Abort( |
|
3842 | 3857 | _(b'cannot calculate relative path'), |
|
3843 | 3858 | hint=stringutil.forcebytestr(e), |
|
3844 | 3859 | ) |
|
3845 | 3860 | |
|
3846 | 3861 | if not wdirvfs.exists(): |
|
3847 | 3862 | wdirvfs.makedirs() |
|
3848 | 3863 | |
|
3849 | 3864 | hgvfs.makedir(notindexed=True) |
|
3850 | 3865 | if b'sharedrepo' not in createopts: |
|
3851 | 3866 | hgvfs.mkdir(b'cache') |
|
3852 | 3867 | hgvfs.mkdir(b'wcache') |
|
3853 | 3868 | |
|
3854 | 3869 | has_store = requirementsmod.STORE_REQUIREMENT in requirements |
|
3855 | 3870 | if has_store and b'sharedrepo' not in createopts: |
|
3856 | 3871 | hgvfs.mkdir(b'store') |
|
3857 | 3872 | |
|
3858 | 3873 | # We create an invalid changelog outside the store so very old |
|
3859 | 3874 | # Mercurial versions (which didn't know about the requirements |
|
3860 | 3875 | # file) encounter an error on reading the changelog. This |
|
3861 | 3876 | # effectively locks out old clients and prevents them from |
|
3862 | 3877 | # mucking with a repo in an unknown format. |
|
3863 | 3878 | # |
|
3864 | 3879 | # The revlog header has version 65535, which won't be recognized by |
|
3865 | 3880 | # such old clients. |
|
3866 | 3881 | hgvfs.append( |
|
3867 | 3882 | b'00changelog.i', |
|
3868 | 3883 | b'\0\0\xFF\xFF dummy changelog to prevent using the old repo ' |
|
3869 | 3884 | b'layout', |
|
3870 | 3885 | ) |
|
3871 | 3886 | |
|
3872 | 3887 | # Filter the requirements into working copy and store ones |
|
3873 | 3888 | wcreq, storereq = scmutil.filterrequirements(requirements) |
|
3874 | 3889 | # write working copy ones |
|
3875 | 3890 | scmutil.writerequires(hgvfs, wcreq) |
|
3876 | 3891 | # If there are store requirements and the current repository |
|
3877 | 3892 | # is not a shared one, write stored requirements |
|
3878 | 3893 | # For new shared repository, we don't need to write the store |
|
3879 | 3894 | # requirements as they are already present in store requires |
|
3880 | 3895 | if storereq and b'sharedrepo' not in createopts: |
|
3881 | 3896 | storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True) |
|
3882 | 3897 | scmutil.writerequires(storevfs, storereq) |
|
3883 | 3898 | |
|
3884 | 3899 | # Write out file telling readers where to find the shared store. |
|
3885 | 3900 | if b'sharedrepo' in createopts: |
|
3886 | 3901 | hgvfs.write(b'sharedpath', sharedpath) |
|
3887 | 3902 | |
|
3888 | 3903 | if createopts.get(b'shareditems'): |
|
3889 | 3904 | shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n' |
|
3890 | 3905 | hgvfs.write(b'shared', shared) |
|
3891 | 3906 | |
|
3892 | 3907 | |
|
3893 | 3908 | def poisonrepository(repo): |
|
3894 | 3909 | """Poison a repository instance so it can no longer be used.""" |
|
3895 | 3910 | # Perform any cleanup on the instance. |
|
3896 | 3911 | repo.close() |
|
3897 | 3912 | |
|
3898 | 3913 | # Our strategy is to replace the type of the object with one that |
|
3899 | 3914 | # has all attribute lookups result in error. |
|
3900 | 3915 | # |
|
3901 | 3916 | # But we have to allow the close() method because some constructors |
|
3902 | 3917 | # of repos call close() on repo references. |
|
3903 | 3918 | class poisonedrepository(object): |
|
3904 | 3919 | def __getattribute__(self, item): |
|
3905 | 3920 | if item == 'close': |
|
3906 | 3921 | return object.__getattribute__(self, item) |
|
3907 | 3922 | |
|
3908 | 3923 | raise error.ProgrammingError( |
|
3909 | 3924 | b'repo instances should not be used after unshare' |
|
3910 | 3925 | ) |
|
3911 | 3926 | |
|
3912 | 3927 | def close(self): |
|
3913 | 3928 | pass |
|
3914 | 3929 | |
|
3915 | 3930 | # We may have a repoview, which intercepts __setattr__. So be sure |
|
3916 | 3931 | # we operate at the lowest level possible. |
|
3917 | 3932 | object.__setattr__(repo, '__class__', poisonedrepository) |
@@ -1,120 +1,122 b'' | |||
|
1 | 1 | # requirements.py - objects and functions related to repository requirements |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | # obsolete experimental requirements: |
|
11 | 11 | # - manifestv2: An experimental new manifest format that allowed |
|
12 | 12 | # for stem compression of long paths. Experiment ended up not |
|
13 | 13 | # being successful (repository sizes went up due to worse delta |
|
14 | 14 | # chains), and the code was deleted in 4.6. |
|
15 | 15 | |
|
16 | 16 | GENERALDELTA_REQUIREMENT = b'generaldelta' |
|
17 | 17 | DOTENCODE_REQUIREMENT = b'dotencode' |
|
18 | 18 | STORE_REQUIREMENT = b'store' |
|
19 | 19 | FNCACHE_REQUIREMENT = b'fncache' |
|
20 | 20 | |
|
21 | DIRSTATE_TRACKED_KEY_V1 = b'exp-dirstate-tracked-key-v1' | |
|
21 | 22 | DIRSTATE_V2_REQUIREMENT = b'dirstate-v2' |
|
22 | 23 | |
|
23 | 24 | # When narrowing is finalized and no longer subject to format changes, |
|
24 | 25 | # we should move this to just "narrow" or similar. |
|
25 | 26 | NARROW_REQUIREMENT = b'narrowhg-experimental' |
|
26 | 27 | |
|
27 | 28 | # Enables sparse working directory usage |
|
28 | 29 | SPARSE_REQUIREMENT = b'exp-sparse' |
|
29 | 30 | |
|
30 | 31 | # Enables the internal phase which is used to hide changesets instead |
|
31 | 32 | # of stripping them |
|
32 | 33 | INTERNAL_PHASE_REQUIREMENT = b'internal-phase' |
|
33 | 34 | |
|
34 | 35 | # Stores manifest in Tree structure |
|
35 | 36 | TREEMANIFEST_REQUIREMENT = b'treemanifest' |
|
36 | 37 | |
|
37 | 38 | REVLOGV1_REQUIREMENT = b'revlogv1' |
|
38 | 39 | |
|
39 | 40 | # allow using ZSTD as compression engine for revlog content |
|
40 | 41 | REVLOG_COMPRESSION_ZSTD = b'revlog-compression-zstd' |
|
41 | 42 | |
|
42 | 43 | # Increment the sub-version when the revlog v2 format changes to lock out old |
|
43 | 44 | # clients. |
|
44 | 45 | CHANGELOGV2_REQUIREMENT = b'exp-changelog-v2' |
|
45 | 46 | |
|
46 | 47 | # Increment the sub-version when the revlog v2 format changes to lock out old |
|
47 | 48 | # clients. |
|
48 | 49 | REVLOGV2_REQUIREMENT = b'exp-revlogv2.2' |
|
49 | 50 | |
|
50 | 51 | # A repository with the sparserevlog feature will have delta chains that |
|
51 | 52 | # can spread over a larger span. Sparse reading cuts these large spans into |
|
52 | 53 | # pieces, so that each piece isn't too big. |
|
53 | 54 | # Without the sparserevlog capability, reading from the repository could use |
|
54 | 55 | # huge amounts of memory, because the whole span would be read at once, |
|
55 | 56 | # including all the intermediate revisions that aren't pertinent for the chain. |
|
56 | 57 | # This is why once a repository has enabled sparse-read, it becomes required. |
|
57 | 58 | SPARSEREVLOG_REQUIREMENT = b'sparserevlog' |
|
58 | 59 | |
|
59 | 60 | # A repository with the the copies-sidedata-changeset requirement will store |
|
60 | 61 | # copies related information in changeset's sidedata. |
|
61 | 62 | COPIESSDC_REQUIREMENT = b'exp-copies-sidedata-changeset' |
|
62 | 63 | |
|
63 | 64 | # The repository use persistent nodemap for the changelog and the manifest. |
|
64 | 65 | NODEMAP_REQUIREMENT = b'persistent-nodemap' |
|
65 | 66 | |
|
66 | 67 | # Denotes that the current repository is a share |
|
67 | 68 | SHARED_REQUIREMENT = b'shared' |
|
68 | 69 | |
|
69 | 70 | # Denotes that current repository is a share and the shared source path is |
|
70 | 71 | # relative to the current repository root path |
|
71 | 72 | RELATIVE_SHARED_REQUIREMENT = b'relshared' |
|
72 | 73 | |
|
73 | 74 | # A repository with share implemented safely. The repository has different |
|
74 | 75 | # store and working copy requirements i.e. both `.hg/requires` and |
|
75 | 76 | # `.hg/store/requires` are present. |
|
76 | 77 | SHARESAFE_REQUIREMENT = b'share-safe' |
|
77 | 78 | |
|
78 | 79 | # Bookmarks must be stored in the `store` part of the repository and will be |
|
79 | 80 | # share accross shares |
|
80 | 81 | BOOKMARKS_IN_STORE_REQUIREMENT = b'bookmarksinstore' |
|
81 | 82 | |
|
82 | 83 | # List of requirements which are working directory specific |
|
83 | 84 | # These requirements cannot be shared between repositories if they |
|
84 | 85 | # share the same store |
|
85 | 86 | # * sparse is a working directory specific functionality and hence working |
|
86 | 87 | # directory specific requirement |
|
87 | 88 | # * SHARED_REQUIREMENT and RELATIVE_SHARED_REQUIREMENT are requirements which |
|
88 | 89 | # represents that the current working copy/repository shares store of another |
|
89 | 90 | # repo. Hence both of them should be stored in working copy |
|
90 | 91 | # * SHARESAFE_REQUIREMENT needs to be stored in working dir to mark that rest of |
|
91 | 92 | # the requirements are stored in store's requires |
|
92 | 93 | # * DIRSTATE_V2_REQUIREMENT affects .hg/dirstate, of which there is one per |
|
93 | 94 | # working directory. |
|
94 | 95 | WORKING_DIR_REQUIREMENTS = { |
|
95 | 96 | SPARSE_REQUIREMENT, |
|
96 | 97 | SHARED_REQUIREMENT, |
|
97 | 98 | RELATIVE_SHARED_REQUIREMENT, |
|
98 | 99 | SHARESAFE_REQUIREMENT, |
|
100 | DIRSTATE_TRACKED_KEY_V1, | |
|
99 | 101 | DIRSTATE_V2_REQUIREMENT, |
|
100 | 102 | } |
|
101 | 103 | |
|
102 | 104 | # List of requirement that impact "stream-clone" (and hardlink clone) and |
|
103 | 105 | # cannot be changed in such cases. |
|
104 | 106 | # |
|
105 | 107 | # requirements not in this list are safe to be altered during stream-clone. |
|
106 | 108 | # |
|
107 | 109 | # note: the list is currently inherited from previous code and miss some relevant requirement while containing some irrelevant ones. |
|
108 | 110 | STREAM_FIXED_REQUIREMENTS = { |
|
109 | 111 | BOOKMARKS_IN_STORE_REQUIREMENT, |
|
110 | 112 | CHANGELOGV2_REQUIREMENT, |
|
111 | 113 | COPIESSDC_REQUIREMENT, |
|
112 | 114 | GENERALDELTA_REQUIREMENT, |
|
113 | 115 | INTERNAL_PHASE_REQUIREMENT, |
|
114 | 116 | NODEMAP_REQUIREMENT, |
|
115 | 117 | REVLOG_COMPRESSION_ZSTD, |
|
116 | 118 | REVLOGV1_REQUIREMENT, |
|
117 | 119 | REVLOGV2_REQUIREMENT, |
|
118 | 120 | SPARSEREVLOG_REQUIREMENT, |
|
119 | 121 | TREEMANIFEST_REQUIREMENT, |
|
120 | 122 | } |
@@ -1,771 +1,773 b'' | |||
|
1 | 1 | # transaction.py - simple journaling scheme for mercurial |
|
2 | 2 | # |
|
3 | 3 | # This transaction scheme is intended to gracefully handle program |
|
4 | 4 | # errors and interruptions. More serious failures like system crashes |
|
5 | 5 | # can be recovered with an fsck-like tool. As the whole repository is |
|
6 | 6 | # effectively log-structured, this should amount to simply truncating |
|
7 | 7 | # anything that isn't referenced in the changelog. |
|
8 | 8 | # |
|
9 | 9 | # Copyright 2005, 2006 Olivia Mackall <olivia@selenic.com> |
|
10 | 10 | # |
|
11 | 11 | # This software may be used and distributed according to the terms of the |
|
12 | 12 | # GNU General Public License version 2 or any later version. |
|
13 | 13 | |
|
14 | 14 | from __future__ import absolute_import |
|
15 | 15 | |
|
16 | 16 | import errno |
|
17 | 17 | |
|
18 | 18 | from .i18n import _ |
|
19 | 19 | from . import ( |
|
20 | 20 | error, |
|
21 | 21 | pycompat, |
|
22 | 22 | util, |
|
23 | 23 | ) |
|
24 | 24 | from .utils import stringutil |
|
25 | 25 | |
|
26 | 26 | version = 2 |
|
27 | 27 | |
|
28 | 28 | # These are the file generators that should only be executed after the |
|
29 | 29 | # finalizers are done, since they rely on the output of the finalizers (like |
|
30 | 30 | # the changelog having been written). |
|
31 | 31 | postfinalizegenerators = { |
|
32 | 32 | b'bookmarks', |
|
33 | b'dirstate-0-key-pre', | |
|
33 | 34 | b'dirstate-1-main', |
|
35 | b'dirstate-2-key-post', | |
|
34 | 36 | } |
|
35 | 37 | |
|
36 | 38 | GEN_GROUP_ALL = b'all' |
|
37 | 39 | GEN_GROUP_PRE_FINALIZE = b'prefinalize' |
|
38 | 40 | GEN_GROUP_POST_FINALIZE = b'postfinalize' |
|
39 | 41 | |
|
40 | 42 | |
|
41 | 43 | def active(func): |
|
42 | 44 | def _active(self, *args, **kwds): |
|
43 | 45 | if self._count == 0: |
|
44 | 46 | raise error.ProgrammingError( |
|
45 | 47 | b'cannot use transaction when it is already committed/aborted' |
|
46 | 48 | ) |
|
47 | 49 | return func(self, *args, **kwds) |
|
48 | 50 | |
|
49 | 51 | return _active |
|
50 | 52 | |
|
51 | 53 | |
|
52 | 54 | def _playback( |
|
53 | 55 | journal, |
|
54 | 56 | report, |
|
55 | 57 | opener, |
|
56 | 58 | vfsmap, |
|
57 | 59 | entries, |
|
58 | 60 | backupentries, |
|
59 | 61 | unlink=True, |
|
60 | 62 | checkambigfiles=None, |
|
61 | 63 | ): |
|
62 | 64 | for f, o in sorted(dict(entries).items()): |
|
63 | 65 | if o or not unlink: |
|
64 | 66 | checkambig = checkambigfiles and (f, b'') in checkambigfiles |
|
65 | 67 | try: |
|
66 | 68 | fp = opener(f, b'a', checkambig=checkambig) |
|
67 | 69 | if fp.tell() < o: |
|
68 | 70 | raise error.Abort( |
|
69 | 71 | _( |
|
70 | 72 | b"attempted to truncate %s to %d bytes, but it was " |
|
71 | 73 | b"already %d bytes\n" |
|
72 | 74 | ) |
|
73 | 75 | % (f, o, fp.tell()) |
|
74 | 76 | ) |
|
75 | 77 | fp.truncate(o) |
|
76 | 78 | fp.close() |
|
77 | 79 | except IOError: |
|
78 | 80 | report(_(b"failed to truncate %s\n") % f) |
|
79 | 81 | raise |
|
80 | 82 | else: |
|
81 | 83 | try: |
|
82 | 84 | opener.unlink(f) |
|
83 | 85 | except (IOError, OSError) as inst: |
|
84 | 86 | if inst.errno != errno.ENOENT: |
|
85 | 87 | raise |
|
86 | 88 | |
|
87 | 89 | backupfiles = [] |
|
88 | 90 | for l, f, b, c in backupentries: |
|
89 | 91 | if l not in vfsmap and c: |
|
90 | 92 | report(b"couldn't handle %s: unknown cache location %s\n" % (b, l)) |
|
91 | 93 | vfs = vfsmap[l] |
|
92 | 94 | try: |
|
93 | 95 | if f and b: |
|
94 | 96 | filepath = vfs.join(f) |
|
95 | 97 | backuppath = vfs.join(b) |
|
96 | 98 | checkambig = checkambigfiles and (f, l) in checkambigfiles |
|
97 | 99 | try: |
|
98 | 100 | util.copyfile(backuppath, filepath, checkambig=checkambig) |
|
99 | 101 | backupfiles.append(b) |
|
100 | 102 | except IOError as exc: |
|
101 | 103 | e_msg = stringutil.forcebytestr(exc) |
|
102 | 104 | report(_(b"failed to recover %s (%s)\n") % (f, e_msg)) |
|
103 | 105 | else: |
|
104 | 106 | target = f or b |
|
105 | 107 | try: |
|
106 | 108 | vfs.unlink(target) |
|
107 | 109 | except (IOError, OSError) as inst: |
|
108 | 110 | if inst.errno != errno.ENOENT: |
|
109 | 111 | raise |
|
110 | 112 | except (IOError, OSError, error.Abort): |
|
111 | 113 | if not c: |
|
112 | 114 | raise |
|
113 | 115 | |
|
114 | 116 | backuppath = b"%s.backupfiles" % journal |
|
115 | 117 | if opener.exists(backuppath): |
|
116 | 118 | opener.unlink(backuppath) |
|
117 | 119 | opener.unlink(journal) |
|
118 | 120 | try: |
|
119 | 121 | for f in backupfiles: |
|
120 | 122 | if opener.exists(f): |
|
121 | 123 | opener.unlink(f) |
|
122 | 124 | except (IOError, OSError, error.Abort): |
|
123 | 125 | # only pure backup file remains, it is sage to ignore any error |
|
124 | 126 | pass |
|
125 | 127 | |
|
126 | 128 | |
|
127 | 129 | class transaction(util.transactional): |
|
128 | 130 | def __init__( |
|
129 | 131 | self, |
|
130 | 132 | report, |
|
131 | 133 | opener, |
|
132 | 134 | vfsmap, |
|
133 | 135 | journalname, |
|
134 | 136 | undoname=None, |
|
135 | 137 | after=None, |
|
136 | 138 | createmode=None, |
|
137 | 139 | validator=None, |
|
138 | 140 | releasefn=None, |
|
139 | 141 | checkambigfiles=None, |
|
140 | 142 | name='<unnamed>', |
|
141 | 143 | ): |
|
142 | 144 | """Begin a new transaction |
|
143 | 145 | |
|
144 | 146 | Begins a new transaction that allows rolling back writes in the event of |
|
145 | 147 | an exception. |
|
146 | 148 | |
|
147 | 149 | * `after`: called after the transaction has been committed |
|
148 | 150 | * `createmode`: the mode of the journal file that will be created |
|
149 | 151 | * `releasefn`: called after releasing (with transaction and result) |
|
150 | 152 | |
|
151 | 153 | `checkambigfiles` is a set of (path, vfs-location) tuples, |
|
152 | 154 | which determine whether file stat ambiguity should be avoided |
|
153 | 155 | for corresponded files. |
|
154 | 156 | """ |
|
155 | 157 | self._count = 1 |
|
156 | 158 | self._usages = 1 |
|
157 | 159 | self._report = report |
|
158 | 160 | # a vfs to the store content |
|
159 | 161 | self._opener = opener |
|
160 | 162 | # a map to access file in various {location -> vfs} |
|
161 | 163 | vfsmap = vfsmap.copy() |
|
162 | 164 | vfsmap[b''] = opener # set default value |
|
163 | 165 | self._vfsmap = vfsmap |
|
164 | 166 | self._after = after |
|
165 | 167 | self._offsetmap = {} |
|
166 | 168 | self._newfiles = set() |
|
167 | 169 | self._journal = journalname |
|
168 | 170 | self._undoname = undoname |
|
169 | 171 | self._queue = [] |
|
170 | 172 | # A callback to do something just after releasing transaction. |
|
171 | 173 | if releasefn is None: |
|
172 | 174 | releasefn = lambda tr, success: None |
|
173 | 175 | self._releasefn = releasefn |
|
174 | 176 | |
|
175 | 177 | self._checkambigfiles = set() |
|
176 | 178 | if checkambigfiles: |
|
177 | 179 | self._checkambigfiles.update(checkambigfiles) |
|
178 | 180 | |
|
179 | 181 | self._names = [name] |
|
180 | 182 | |
|
181 | 183 | # A dict dedicated to precisely tracking the changes introduced in the |
|
182 | 184 | # transaction. |
|
183 | 185 | self.changes = {} |
|
184 | 186 | |
|
185 | 187 | # a dict of arguments to be passed to hooks |
|
186 | 188 | self.hookargs = {} |
|
187 | 189 | self._file = opener.open(self._journal, b"w+") |
|
188 | 190 | |
|
189 | 191 | # a list of ('location', 'path', 'backuppath', cache) entries. |
|
190 | 192 | # - if 'backuppath' is empty, no file existed at backup time |
|
191 | 193 | # - if 'path' is empty, this is a temporary transaction file |
|
192 | 194 | # - if 'location' is not empty, the path is outside main opener reach. |
|
193 | 195 | # use 'location' value as a key in a vfsmap to find the right 'vfs' |
|
194 | 196 | # (cache is currently unused) |
|
195 | 197 | self._backupentries = [] |
|
196 | 198 | self._backupmap = {} |
|
197 | 199 | self._backupjournal = b"%s.backupfiles" % self._journal |
|
198 | 200 | self._backupsfile = opener.open(self._backupjournal, b'w') |
|
199 | 201 | self._backupsfile.write(b'%d\n' % version) |
|
200 | 202 | |
|
201 | 203 | if createmode is not None: |
|
202 | 204 | opener.chmod(self._journal, createmode & 0o666) |
|
203 | 205 | opener.chmod(self._backupjournal, createmode & 0o666) |
|
204 | 206 | |
|
205 | 207 | # hold file generations to be performed on commit |
|
206 | 208 | self._filegenerators = {} |
|
207 | 209 | # hold callback to write pending data for hooks |
|
208 | 210 | self._pendingcallback = {} |
|
209 | 211 | # True is any pending data have been written ever |
|
210 | 212 | self._anypending = False |
|
211 | 213 | # holds callback to call when writing the transaction |
|
212 | 214 | self._finalizecallback = {} |
|
213 | 215 | # holds callback to call when validating the transaction |
|
214 | 216 | # should raise exception if anything is wrong |
|
215 | 217 | self._validatecallback = {} |
|
216 | 218 | if validator is not None: |
|
217 | 219 | self._validatecallback[b'001-userhooks'] = validator |
|
218 | 220 | # hold callback for post transaction close |
|
219 | 221 | self._postclosecallback = {} |
|
220 | 222 | # holds callbacks to call during abort |
|
221 | 223 | self._abortcallback = {} |
|
222 | 224 | |
|
223 | 225 | def __repr__(self): |
|
224 | 226 | name = '/'.join(self._names) |
|
225 | 227 | return '<transaction name=%s, count=%d, usages=%d>' % ( |
|
226 | 228 | name, |
|
227 | 229 | self._count, |
|
228 | 230 | self._usages, |
|
229 | 231 | ) |
|
230 | 232 | |
|
231 | 233 | def __del__(self): |
|
232 | 234 | if self._journal: |
|
233 | 235 | self._abort() |
|
234 | 236 | |
|
235 | 237 | @property |
|
236 | 238 | def finalized(self): |
|
237 | 239 | return self._finalizecallback is None |
|
238 | 240 | |
|
239 | 241 | @active |
|
240 | 242 | def startgroup(self): |
|
241 | 243 | """delay registration of file entry |
|
242 | 244 | |
|
243 | 245 | This is used by strip to delay vision of strip offset. The transaction |
|
244 | 246 | sees either none or all of the strip actions to be done.""" |
|
245 | 247 | self._queue.append([]) |
|
246 | 248 | |
|
247 | 249 | @active |
|
248 | 250 | def endgroup(self): |
|
249 | 251 | """apply delayed registration of file entry. |
|
250 | 252 | |
|
251 | 253 | This is used by strip to delay vision of strip offset. The transaction |
|
252 | 254 | sees either none or all of the strip actions to be done.""" |
|
253 | 255 | q = self._queue.pop() |
|
254 | 256 | for f, o in q: |
|
255 | 257 | self._addentry(f, o) |
|
256 | 258 | |
|
257 | 259 | @active |
|
258 | 260 | def add(self, file, offset): |
|
259 | 261 | """record the state of an append-only file before update""" |
|
260 | 262 | if ( |
|
261 | 263 | file in self._newfiles |
|
262 | 264 | or file in self._offsetmap |
|
263 | 265 | or file in self._backupmap |
|
264 | 266 | ): |
|
265 | 267 | return |
|
266 | 268 | if self._queue: |
|
267 | 269 | self._queue[-1].append((file, offset)) |
|
268 | 270 | return |
|
269 | 271 | |
|
270 | 272 | self._addentry(file, offset) |
|
271 | 273 | |
|
272 | 274 | def _addentry(self, file, offset): |
|
273 | 275 | """add a append-only entry to memory and on-disk state""" |
|
274 | 276 | if ( |
|
275 | 277 | file in self._newfiles |
|
276 | 278 | or file in self._offsetmap |
|
277 | 279 | or file in self._backupmap |
|
278 | 280 | ): |
|
279 | 281 | return |
|
280 | 282 | if offset: |
|
281 | 283 | self._offsetmap[file] = offset |
|
282 | 284 | else: |
|
283 | 285 | self._newfiles.add(file) |
|
284 | 286 | # add enough data to the journal to do the truncate |
|
285 | 287 | self._file.write(b"%s\0%d\n" % (file, offset)) |
|
286 | 288 | self._file.flush() |
|
287 | 289 | |
|
288 | 290 | @active |
|
289 | 291 | def addbackup(self, file, hardlink=True, location=b''): |
|
290 | 292 | """Adds a backup of the file to the transaction |
|
291 | 293 | |
|
292 | 294 | Calling addbackup() creates a hardlink backup of the specified file |
|
293 | 295 | that is used to recover the file in the event of the transaction |
|
294 | 296 | aborting. |
|
295 | 297 | |
|
296 | 298 | * `file`: the file path, relative to .hg/store |
|
297 | 299 | * `hardlink`: use a hardlink to quickly create the backup |
|
298 | 300 | """ |
|
299 | 301 | if self._queue: |
|
300 | 302 | msg = b'cannot use transaction.addbackup inside "group"' |
|
301 | 303 | raise error.ProgrammingError(msg) |
|
302 | 304 | |
|
303 | 305 | if ( |
|
304 | 306 | file in self._newfiles |
|
305 | 307 | or file in self._offsetmap |
|
306 | 308 | or file in self._backupmap |
|
307 | 309 | ): |
|
308 | 310 | return |
|
309 | 311 | vfs = self._vfsmap[location] |
|
310 | 312 | dirname, filename = vfs.split(file) |
|
311 | 313 | backupfilename = b"%s.backup.%s" % (self._journal, filename) |
|
312 | 314 | backupfile = vfs.reljoin(dirname, backupfilename) |
|
313 | 315 | if vfs.exists(file): |
|
314 | 316 | filepath = vfs.join(file) |
|
315 | 317 | backuppath = vfs.join(backupfile) |
|
316 | 318 | util.copyfile(filepath, backuppath, hardlink=hardlink) |
|
317 | 319 | else: |
|
318 | 320 | backupfile = b'' |
|
319 | 321 | |
|
320 | 322 | self._addbackupentry((location, file, backupfile, False)) |
|
321 | 323 | |
|
322 | 324 | def _addbackupentry(self, entry): |
|
323 | 325 | """register a new backup entry and write it to disk""" |
|
324 | 326 | self._backupentries.append(entry) |
|
325 | 327 | self._backupmap[entry[1]] = len(self._backupentries) - 1 |
|
326 | 328 | self._backupsfile.write(b"%s\0%s\0%s\0%d\n" % entry) |
|
327 | 329 | self._backupsfile.flush() |
|
328 | 330 | |
|
329 | 331 | @active |
|
330 | 332 | def registertmp(self, tmpfile, location=b''): |
|
331 | 333 | """register a temporary transaction file |
|
332 | 334 | |
|
333 | 335 | Such files will be deleted when the transaction exits (on both |
|
334 | 336 | failure and success). |
|
335 | 337 | """ |
|
336 | 338 | self._addbackupentry((location, b'', tmpfile, False)) |
|
337 | 339 | |
|
338 | 340 | @active |
|
339 | 341 | def addfilegenerator( |
|
340 | 342 | self, genid, filenames, genfunc, order=0, location=b'' |
|
341 | 343 | ): |
|
342 | 344 | """add a function to generates some files at transaction commit |
|
343 | 345 | |
|
344 | 346 | The `genfunc` argument is a function capable of generating proper |
|
345 | 347 | content of each entry in the `filename` tuple. |
|
346 | 348 | |
|
347 | 349 | At transaction close time, `genfunc` will be called with one file |
|
348 | 350 | object argument per entries in `filenames`. |
|
349 | 351 | |
|
350 | 352 | The transaction itself is responsible for the backup, creation and |
|
351 | 353 | final write of such file. |
|
352 | 354 | |
|
353 | 355 | The `genid` argument is used to ensure the same set of file is only |
|
354 | 356 | generated once. Call to `addfilegenerator` for a `genid` already |
|
355 | 357 | present will overwrite the old entry. |
|
356 | 358 | |
|
357 | 359 | The `order` argument may be used to control the order in which multiple |
|
358 | 360 | generator will be executed. |
|
359 | 361 | |
|
360 | 362 | The `location` arguments may be used to indicate the files are located |
|
361 | 363 | outside of the the standard directory for transaction. It should match |
|
362 | 364 | one of the key of the `transaction.vfsmap` dictionary. |
|
363 | 365 | """ |
|
364 | 366 | # For now, we are unable to do proper backup and restore of custom vfs |
|
365 | 367 | # but for bookmarks that are handled outside this mechanism. |
|
366 | 368 | self._filegenerators[genid] = (order, filenames, genfunc, location) |
|
367 | 369 | |
|
368 | 370 | @active |
|
369 | 371 | def removefilegenerator(self, genid): |
|
370 | 372 | """reverse of addfilegenerator, remove a file generator function""" |
|
371 | 373 | if genid in self._filegenerators: |
|
372 | 374 | del self._filegenerators[genid] |
|
373 | 375 | |
|
374 | 376 | def _generatefiles(self, suffix=b'', group=GEN_GROUP_ALL): |
|
375 | 377 | # write files registered for generation |
|
376 | 378 | any = False |
|
377 | 379 | |
|
378 | 380 | if group == GEN_GROUP_ALL: |
|
379 | 381 | skip_post = skip_pre = False |
|
380 | 382 | else: |
|
381 | 383 | skip_pre = group == GEN_GROUP_POST_FINALIZE |
|
382 | 384 | skip_post = group == GEN_GROUP_PRE_FINALIZE |
|
383 | 385 | |
|
384 | 386 | for id, entry in sorted(pycompat.iteritems(self._filegenerators)): |
|
385 | 387 | any = True |
|
386 | 388 | order, filenames, genfunc, location = entry |
|
387 | 389 | |
|
388 | 390 | # for generation at closing, check if it's before or after finalize |
|
389 | 391 | is_post = id in postfinalizegenerators |
|
390 | 392 | if skip_post and is_post: |
|
391 | 393 | continue |
|
392 | 394 | elif skip_pre and not is_post: |
|
393 | 395 | continue |
|
394 | 396 | |
|
395 | 397 | vfs = self._vfsmap[location] |
|
396 | 398 | files = [] |
|
397 | 399 | try: |
|
398 | 400 | for name in filenames: |
|
399 | 401 | name += suffix |
|
400 | 402 | if suffix: |
|
401 | 403 | self.registertmp(name, location=location) |
|
402 | 404 | checkambig = False |
|
403 | 405 | else: |
|
404 | 406 | self.addbackup(name, location=location) |
|
405 | 407 | checkambig = (name, location) in self._checkambigfiles |
|
406 | 408 | files.append( |
|
407 | 409 | vfs(name, b'w', atomictemp=True, checkambig=checkambig) |
|
408 | 410 | ) |
|
409 | 411 | genfunc(*files) |
|
410 | 412 | for f in files: |
|
411 | 413 | f.close() |
|
412 | 414 | # skip discard() loop since we're sure no open file remains |
|
413 | 415 | del files[:] |
|
414 | 416 | finally: |
|
415 | 417 | for f in files: |
|
416 | 418 | f.discard() |
|
417 | 419 | return any |
|
418 | 420 | |
|
419 | 421 | @active |
|
420 | 422 | def findoffset(self, file): |
|
421 | 423 | if file in self._newfiles: |
|
422 | 424 | return 0 |
|
423 | 425 | return self._offsetmap.get(file) |
|
424 | 426 | |
|
425 | 427 | @active |
|
426 | 428 | def readjournal(self): |
|
427 | 429 | self._file.seek(0) |
|
428 | 430 | entries = [] |
|
429 | 431 | for l in self._file.readlines(): |
|
430 | 432 | file, troffset = l.split(b'\0') |
|
431 | 433 | entries.append((file, int(troffset))) |
|
432 | 434 | return entries |
|
433 | 435 | |
|
434 | 436 | @active |
|
435 | 437 | def replace(self, file, offset): |
|
436 | 438 | """ |
|
437 | 439 | replace can only replace already committed entries |
|
438 | 440 | that are not pending in the queue |
|
439 | 441 | """ |
|
440 | 442 | if file in self._newfiles: |
|
441 | 443 | if not offset: |
|
442 | 444 | return |
|
443 | 445 | self._newfiles.remove(file) |
|
444 | 446 | self._offsetmap[file] = offset |
|
445 | 447 | elif file in self._offsetmap: |
|
446 | 448 | if not offset: |
|
447 | 449 | del self._offsetmap[file] |
|
448 | 450 | self._newfiles.add(file) |
|
449 | 451 | else: |
|
450 | 452 | self._offsetmap[file] = offset |
|
451 | 453 | else: |
|
452 | 454 | raise KeyError(file) |
|
453 | 455 | self._file.write(b"%s\0%d\n" % (file, offset)) |
|
454 | 456 | self._file.flush() |
|
455 | 457 | |
|
456 | 458 | @active |
|
457 | 459 | def nest(self, name='<unnamed>'): |
|
458 | 460 | self._count += 1 |
|
459 | 461 | self._usages += 1 |
|
460 | 462 | self._names.append(name) |
|
461 | 463 | return self |
|
462 | 464 | |
|
463 | 465 | def release(self): |
|
464 | 466 | if self._count > 0: |
|
465 | 467 | self._usages -= 1 |
|
466 | 468 | if self._names: |
|
467 | 469 | self._names.pop() |
|
468 | 470 | # if the transaction scopes are left without being closed, fail |
|
469 | 471 | if self._count > 0 and self._usages == 0: |
|
470 | 472 | self._abort() |
|
471 | 473 | |
|
472 | 474 | def running(self): |
|
473 | 475 | return self._count > 0 |
|
474 | 476 | |
|
475 | 477 | def addpending(self, category, callback): |
|
476 | 478 | """add a callback to be called when the transaction is pending |
|
477 | 479 | |
|
478 | 480 | The transaction will be given as callback's first argument. |
|
479 | 481 | |
|
480 | 482 | Category is a unique identifier to allow overwriting an old callback |
|
481 | 483 | with a newer callback. |
|
482 | 484 | """ |
|
483 | 485 | self._pendingcallback[category] = callback |
|
484 | 486 | |
|
485 | 487 | @active |
|
486 | 488 | def writepending(self): |
|
487 | 489 | """write pending file to temporary version |
|
488 | 490 | |
|
489 | 491 | This is used to allow hooks to view a transaction before commit""" |
|
490 | 492 | categories = sorted(self._pendingcallback) |
|
491 | 493 | for cat in categories: |
|
492 | 494 | # remove callback since the data will have been flushed |
|
493 | 495 | any = self._pendingcallback.pop(cat)(self) |
|
494 | 496 | self._anypending = self._anypending or any |
|
495 | 497 | self._anypending |= self._generatefiles(suffix=b'.pending') |
|
496 | 498 | return self._anypending |
|
497 | 499 | |
|
498 | 500 | @active |
|
499 | 501 | def hasfinalize(self, category): |
|
500 | 502 | """check is a callback already exist for a category""" |
|
501 | 503 | return category in self._finalizecallback |
|
502 | 504 | |
|
503 | 505 | @active |
|
504 | 506 | def addfinalize(self, category, callback): |
|
505 | 507 | """add a callback to be called when the transaction is closed |
|
506 | 508 | |
|
507 | 509 | The transaction will be given as callback's first argument. |
|
508 | 510 | |
|
509 | 511 | Category is a unique identifier to allow overwriting old callbacks with |
|
510 | 512 | newer callbacks. |
|
511 | 513 | """ |
|
512 | 514 | self._finalizecallback[category] = callback |
|
513 | 515 | |
|
514 | 516 | @active |
|
515 | 517 | def addpostclose(self, category, callback): |
|
516 | 518 | """add or replace a callback to be called after the transaction closed |
|
517 | 519 | |
|
518 | 520 | The transaction will be given as callback's first argument. |
|
519 | 521 | |
|
520 | 522 | Category is a unique identifier to allow overwriting an old callback |
|
521 | 523 | with a newer callback. |
|
522 | 524 | """ |
|
523 | 525 | self._postclosecallback[category] = callback |
|
524 | 526 | |
|
525 | 527 | @active |
|
526 | 528 | def getpostclose(self, category): |
|
527 | 529 | """return a postclose callback added before, or None""" |
|
528 | 530 | return self._postclosecallback.get(category, None) |
|
529 | 531 | |
|
530 | 532 | @active |
|
531 | 533 | def addabort(self, category, callback): |
|
532 | 534 | """add a callback to be called when the transaction is aborted. |
|
533 | 535 | |
|
534 | 536 | The transaction will be given as the first argument to the callback. |
|
535 | 537 | |
|
536 | 538 | Category is a unique identifier to allow overwriting an old callback |
|
537 | 539 | with a newer callback. |
|
538 | 540 | """ |
|
539 | 541 | self._abortcallback[category] = callback |
|
540 | 542 | |
|
541 | 543 | @active |
|
542 | 544 | def addvalidator(self, category, callback): |
|
543 | 545 | """adds a callback to be called when validating the transaction. |
|
544 | 546 | |
|
545 | 547 | The transaction will be given as the first argument to the callback. |
|
546 | 548 | |
|
547 | 549 | callback should raise exception if to abort transaction""" |
|
548 | 550 | self._validatecallback[category] = callback |
|
549 | 551 | |
|
550 | 552 | @active |
|
551 | 553 | def close(self): |
|
552 | 554 | '''commit the transaction''' |
|
553 | 555 | if self._count == 1: |
|
554 | 556 | for category in sorted(self._validatecallback): |
|
555 | 557 | self._validatecallback[category](self) |
|
556 | 558 | self._validatecallback = None # Help prevent cycles. |
|
557 | 559 | self._generatefiles(group=GEN_GROUP_PRE_FINALIZE) |
|
558 | 560 | while self._finalizecallback: |
|
559 | 561 | callbacks = self._finalizecallback |
|
560 | 562 | self._finalizecallback = {} |
|
561 | 563 | categories = sorted(callbacks) |
|
562 | 564 | for cat in categories: |
|
563 | 565 | callbacks[cat](self) |
|
564 | 566 | # Prevent double usage and help clear cycles. |
|
565 | 567 | self._finalizecallback = None |
|
566 | 568 | self._generatefiles(group=GEN_GROUP_POST_FINALIZE) |
|
567 | 569 | |
|
568 | 570 | self._count -= 1 |
|
569 | 571 | if self._count != 0: |
|
570 | 572 | return |
|
571 | 573 | self._file.close() |
|
572 | 574 | self._backupsfile.close() |
|
573 | 575 | # cleanup temporary files |
|
574 | 576 | for l, f, b, c in self._backupentries: |
|
575 | 577 | if l not in self._vfsmap and c: |
|
576 | 578 | self._report( |
|
577 | 579 | b"couldn't remove %s: unknown cache location %s\n" % (b, l) |
|
578 | 580 | ) |
|
579 | 581 | continue |
|
580 | 582 | vfs = self._vfsmap[l] |
|
581 | 583 | if not f and b and vfs.exists(b): |
|
582 | 584 | try: |
|
583 | 585 | vfs.unlink(b) |
|
584 | 586 | except (IOError, OSError, error.Abort) as inst: |
|
585 | 587 | if not c: |
|
586 | 588 | raise |
|
587 | 589 | # Abort may be raise by read only opener |
|
588 | 590 | self._report( |
|
589 | 591 | b"couldn't remove %s: %s\n" % (vfs.join(b), inst) |
|
590 | 592 | ) |
|
591 | 593 | self._offsetmap = {} |
|
592 | 594 | self._newfiles = set() |
|
593 | 595 | self._writeundo() |
|
594 | 596 | if self._after: |
|
595 | 597 | self._after() |
|
596 | 598 | self._after = None # Help prevent cycles. |
|
597 | 599 | if self._opener.isfile(self._backupjournal): |
|
598 | 600 | self._opener.unlink(self._backupjournal) |
|
599 | 601 | if self._opener.isfile(self._journal): |
|
600 | 602 | self._opener.unlink(self._journal) |
|
601 | 603 | for l, _f, b, c in self._backupentries: |
|
602 | 604 | if l not in self._vfsmap and c: |
|
603 | 605 | self._report( |
|
604 | 606 | b"couldn't remove %s: unknown cache location" |
|
605 | 607 | b"%s\n" % (b, l) |
|
606 | 608 | ) |
|
607 | 609 | continue |
|
608 | 610 | vfs = self._vfsmap[l] |
|
609 | 611 | if b and vfs.exists(b): |
|
610 | 612 | try: |
|
611 | 613 | vfs.unlink(b) |
|
612 | 614 | except (IOError, OSError, error.Abort) as inst: |
|
613 | 615 | if not c: |
|
614 | 616 | raise |
|
615 | 617 | # Abort may be raise by read only opener |
|
616 | 618 | self._report( |
|
617 | 619 | b"couldn't remove %s: %s\n" % (vfs.join(b), inst) |
|
618 | 620 | ) |
|
619 | 621 | self._backupentries = [] |
|
620 | 622 | self._journal = None |
|
621 | 623 | |
|
622 | 624 | self._releasefn(self, True) # notify success of closing transaction |
|
623 | 625 | self._releasefn = None # Help prevent cycles. |
|
624 | 626 | |
|
625 | 627 | # run post close action |
|
626 | 628 | categories = sorted(self._postclosecallback) |
|
627 | 629 | for cat in categories: |
|
628 | 630 | self._postclosecallback[cat](self) |
|
629 | 631 | # Prevent double usage and help clear cycles. |
|
630 | 632 | self._postclosecallback = None |
|
631 | 633 | |
|
632 | 634 | @active |
|
633 | 635 | def abort(self): |
|
634 | 636 | """abort the transaction (generally called on error, or when the |
|
635 | 637 | transaction is not explicitly committed before going out of |
|
636 | 638 | scope)""" |
|
637 | 639 | self._abort() |
|
638 | 640 | |
|
639 | 641 | def _writeundo(self): |
|
640 | 642 | """write transaction data for possible future undo call""" |
|
641 | 643 | if self._undoname is None: |
|
642 | 644 | return |
|
643 | 645 | |
|
644 | 646 | undo_backup_path = b"%s.backupfiles" % self._undoname |
|
645 | 647 | undobackupfile = self._opener.open(undo_backup_path, b'w') |
|
646 | 648 | undobackupfile.write(b'%d\n' % version) |
|
647 | 649 | for l, f, b, c in self._backupentries: |
|
648 | 650 | if not f: # temporary file |
|
649 | 651 | continue |
|
650 | 652 | if not b: |
|
651 | 653 | u = b'' |
|
652 | 654 | else: |
|
653 | 655 | if l not in self._vfsmap and c: |
|
654 | 656 | self._report( |
|
655 | 657 | b"couldn't remove %s: unknown cache location" |
|
656 | 658 | b"%s\n" % (b, l) |
|
657 | 659 | ) |
|
658 | 660 | continue |
|
659 | 661 | vfs = self._vfsmap[l] |
|
660 | 662 | base, name = vfs.split(b) |
|
661 | 663 | assert name.startswith(self._journal), name |
|
662 | 664 | uname = name.replace(self._journal, self._undoname, 1) |
|
663 | 665 | u = vfs.reljoin(base, uname) |
|
664 | 666 | util.copyfile(vfs.join(b), vfs.join(u), hardlink=True) |
|
665 | 667 | undobackupfile.write(b"%s\0%s\0%s\0%d\n" % (l, f, u, c)) |
|
666 | 668 | undobackupfile.close() |
|
667 | 669 | |
|
668 | 670 | def _abort(self): |
|
669 | 671 | entries = self.readjournal() |
|
670 | 672 | self._count = 0 |
|
671 | 673 | self._usages = 0 |
|
672 | 674 | self._file.close() |
|
673 | 675 | self._backupsfile.close() |
|
674 | 676 | |
|
675 | 677 | try: |
|
676 | 678 | if not entries and not self._backupentries: |
|
677 | 679 | if self._backupjournal: |
|
678 | 680 | self._opener.unlink(self._backupjournal) |
|
679 | 681 | if self._journal: |
|
680 | 682 | self._opener.unlink(self._journal) |
|
681 | 683 | return |
|
682 | 684 | |
|
683 | 685 | self._report(_(b"transaction abort!\n")) |
|
684 | 686 | |
|
685 | 687 | try: |
|
686 | 688 | for cat in sorted(self._abortcallback): |
|
687 | 689 | self._abortcallback[cat](self) |
|
688 | 690 | # Prevent double usage and help clear cycles. |
|
689 | 691 | self._abortcallback = None |
|
690 | 692 | _playback( |
|
691 | 693 | self._journal, |
|
692 | 694 | self._report, |
|
693 | 695 | self._opener, |
|
694 | 696 | self._vfsmap, |
|
695 | 697 | entries, |
|
696 | 698 | self._backupentries, |
|
697 | 699 | False, |
|
698 | 700 | checkambigfiles=self._checkambigfiles, |
|
699 | 701 | ) |
|
700 | 702 | self._report(_(b"rollback completed\n")) |
|
701 | 703 | except BaseException as exc: |
|
702 | 704 | self._report(_(b"rollback failed - please run hg recover\n")) |
|
703 | 705 | self._report( |
|
704 | 706 | _(b"(failure reason: %s)\n") % stringutil.forcebytestr(exc) |
|
705 | 707 | ) |
|
706 | 708 | finally: |
|
707 | 709 | self._journal = None |
|
708 | 710 | self._releasefn(self, False) # notify failure of transaction |
|
709 | 711 | self._releasefn = None # Help prevent cycles. |
|
710 | 712 | |
|
711 | 713 | |
|
712 | 714 | BAD_VERSION_MSG = _( |
|
713 | 715 | b"journal was created by a different version of Mercurial\n" |
|
714 | 716 | ) |
|
715 | 717 | |
|
716 | 718 | |
|
717 | 719 | def rollback(opener, vfsmap, file, report, checkambigfiles=None): |
|
718 | 720 | """Rolls back the transaction contained in the given file |
|
719 | 721 | |
|
720 | 722 | Reads the entries in the specified file, and the corresponding |
|
721 | 723 | '*.backupfiles' file, to recover from an incomplete transaction. |
|
722 | 724 | |
|
723 | 725 | * `file`: a file containing a list of entries, specifying where |
|
724 | 726 | to truncate each file. The file should contain a list of |
|
725 | 727 | file\0offset pairs, delimited by newlines. The corresponding |
|
726 | 728 | '*.backupfiles' file should contain a list of file\0backupfile |
|
727 | 729 | pairs, delimited by \0. |
|
728 | 730 | |
|
729 | 731 | `checkambigfiles` is a set of (path, vfs-location) tuples, |
|
730 | 732 | which determine whether file stat ambiguity should be avoided at |
|
731 | 733 | restoring corresponded files. |
|
732 | 734 | """ |
|
733 | 735 | entries = [] |
|
734 | 736 | backupentries = [] |
|
735 | 737 | |
|
736 | 738 | with opener.open(file) as fp: |
|
737 | 739 | lines = fp.readlines() |
|
738 | 740 | for l in lines: |
|
739 | 741 | try: |
|
740 | 742 | f, o = l.split(b'\0') |
|
741 | 743 | entries.append((f, int(o))) |
|
742 | 744 | except ValueError: |
|
743 | 745 | report( |
|
744 | 746 | _(b"couldn't read journal entry %r!\n") % pycompat.bytestr(l) |
|
745 | 747 | ) |
|
746 | 748 | |
|
747 | 749 | backupjournal = b"%s.backupfiles" % file |
|
748 | 750 | if opener.exists(backupjournal): |
|
749 | 751 | fp = opener.open(backupjournal) |
|
750 | 752 | lines = fp.readlines() |
|
751 | 753 | if lines: |
|
752 | 754 | ver = lines[0][:-1] |
|
753 | 755 | if ver != (b'%d' % version): |
|
754 | 756 | report(BAD_VERSION_MSG) |
|
755 | 757 | else: |
|
756 | 758 | for line in lines[1:]: |
|
757 | 759 | if line: |
|
758 | 760 | # Shave off the trailing newline |
|
759 | 761 | line = line[:-1] |
|
760 | 762 | l, f, b, c = line.split(b'\0') |
|
761 | 763 | backupentries.append((l, f, b, bool(c))) |
|
762 | 764 | |
|
763 | 765 | _playback( |
|
764 | 766 | file, |
|
765 | 767 | report, |
|
766 | 768 | opener, |
|
767 | 769 | vfsmap, |
|
768 | 770 | entries, |
|
769 | 771 | backupentries, |
|
770 | 772 | checkambigfiles=checkambigfiles, |
|
771 | 773 | ) |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now