Show More
@@ -1,2857 +1,2874 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 | |
|
9 | 9 | import functools |
|
10 | 10 | import re |
|
11 | 11 | |
|
12 | 12 | from . import ( |
|
13 | 13 | encoding, |
|
14 | 14 | error, |
|
15 | 15 | ) |
|
16 | 16 | |
|
17 | 17 | |
|
18 | 18 | def loadconfigtable(ui, extname, configtable): |
|
19 | 19 | """update config item known to the ui with the extension ones""" |
|
20 | 20 | for section, items in sorted(configtable.items()): |
|
21 | 21 | knownitems = ui._knownconfig.setdefault(section, itemregister()) |
|
22 | 22 | knownkeys = set(knownitems) |
|
23 | 23 | newkeys = set(items) |
|
24 | 24 | for key in sorted(knownkeys & newkeys): |
|
25 | 25 | msg = b"extension '%s' overwrite config item '%s.%s'" |
|
26 | 26 | msg %= (extname, section, key) |
|
27 | 27 | ui.develwarn(msg, config=b'warn-config') |
|
28 | 28 | |
|
29 | 29 | knownitems.update(items) |
|
30 | 30 | |
|
31 | 31 | |
|
32 | 32 | class configitem: |
|
33 | 33 | """represent a known config item |
|
34 | 34 | |
|
35 | 35 | :section: the official config section where to find this item, |
|
36 | 36 | :name: the official name within the section, |
|
37 | 37 | :default: default value for this item, |
|
38 | 38 | :alias: optional list of tuples as alternatives, |
|
39 | 39 | :generic: this is a generic definition, match name using regular expression. |
|
40 | 40 | """ |
|
41 | 41 | |
|
42 | 42 | def __init__( |
|
43 | 43 | self, |
|
44 | 44 | section, |
|
45 | 45 | name, |
|
46 | 46 | default=None, |
|
47 | 47 | alias=(), |
|
48 | 48 | generic=False, |
|
49 | 49 | priority=0, |
|
50 | 50 | experimental=False, |
|
51 | 51 | ): |
|
52 | 52 | self.section = section |
|
53 | 53 | self.name = name |
|
54 | 54 | self.default = default |
|
55 | 55 | self.alias = list(alias) |
|
56 | 56 | self.generic = generic |
|
57 | 57 | self.priority = priority |
|
58 | 58 | self.experimental = experimental |
|
59 | 59 | self._re = None |
|
60 | 60 | if generic: |
|
61 | 61 | self._re = re.compile(self.name) |
|
62 | 62 | |
|
63 | 63 | |
|
64 | 64 | class itemregister(dict): |
|
65 | 65 | """A specialized dictionary that can handle wild-card selection""" |
|
66 | 66 | |
|
67 | 67 | def __init__(self): |
|
68 | 68 | super(itemregister, self).__init__() |
|
69 | 69 | self._generics = set() |
|
70 | 70 | |
|
71 | 71 | def update(self, other): |
|
72 | 72 | super(itemregister, self).update(other) |
|
73 | 73 | self._generics.update(other._generics) |
|
74 | 74 | |
|
75 | 75 | def __setitem__(self, key, item): |
|
76 | 76 | super(itemregister, self).__setitem__(key, item) |
|
77 | 77 | if item.generic: |
|
78 | 78 | self._generics.add(item) |
|
79 | 79 | |
|
80 | 80 | def get(self, key): |
|
81 | 81 | baseitem = super(itemregister, self).get(key) |
|
82 | 82 | if baseitem is not None and not baseitem.generic: |
|
83 | 83 | return baseitem |
|
84 | 84 | |
|
85 | 85 | # search for a matching generic item |
|
86 | 86 | generics = sorted(self._generics, key=(lambda x: (x.priority, x.name))) |
|
87 | 87 | for item in generics: |
|
88 | 88 | # we use 'match' instead of 'search' to make the matching simpler |
|
89 | 89 | # for people unfamiliar with regular expression. Having the match |
|
90 | 90 | # rooted to the start of the string will produce less surprising |
|
91 | 91 | # result for user writing simple regex for sub-attribute. |
|
92 | 92 | # |
|
93 | 93 | # For example using "color\..*" match produces an unsurprising |
|
94 | 94 | # result, while using search could suddenly match apparently |
|
95 | 95 | # unrelated configuration that happens to contains "color." |
|
96 | 96 | # anywhere. This is a tradeoff where we favor requiring ".*" on |
|
97 | 97 | # some match to avoid the need to prefix most pattern with "^". |
|
98 | 98 | # The "^" seems more error prone. |
|
99 | 99 | if item._re.match(key): |
|
100 | 100 | return item |
|
101 | 101 | |
|
102 | 102 | return None |
|
103 | 103 | |
|
104 | 104 | |
|
105 | 105 | coreitems = {} |
|
106 | 106 | |
|
107 | 107 | |
|
108 | 108 | def _register(configtable, *args, **kwargs): |
|
109 | 109 | item = configitem(*args, **kwargs) |
|
110 | 110 | section = configtable.setdefault(item.section, itemregister()) |
|
111 | 111 | if item.name in section: |
|
112 | 112 | msg = b"duplicated config item registration for '%s.%s'" |
|
113 | 113 | raise error.ProgrammingError(msg % (item.section, item.name)) |
|
114 | 114 | section[item.name] = item |
|
115 | 115 | |
|
116 | 116 | |
|
117 | 117 | # special value for case where the default is derived from other values |
|
118 | 118 | dynamicdefault = object() |
|
119 | 119 | |
|
120 | 120 | # Registering actual config items |
|
121 | 121 | |
|
122 | 122 | |
|
123 | 123 | def getitemregister(configtable): |
|
124 | 124 | f = functools.partial(_register, configtable) |
|
125 | 125 | # export pseudo enum as configitem.* |
|
126 | 126 | f.dynamicdefault = dynamicdefault |
|
127 | 127 | return f |
|
128 | 128 | |
|
129 | 129 | |
|
130 | 130 | coreconfigitem = getitemregister(coreitems) |
|
131 | 131 | |
|
132 | 132 | |
|
133 | 133 | def _registerdiffopts(section, configprefix=b''): |
|
134 | 134 | coreconfigitem( |
|
135 | 135 | section, |
|
136 | 136 | configprefix + b'nodates', |
|
137 | 137 | default=False, |
|
138 | 138 | ) |
|
139 | 139 | coreconfigitem( |
|
140 | 140 | section, |
|
141 | 141 | configprefix + b'showfunc', |
|
142 | 142 | default=False, |
|
143 | 143 | ) |
|
144 | 144 | coreconfigitem( |
|
145 | 145 | section, |
|
146 | 146 | configprefix + b'unified', |
|
147 | 147 | default=None, |
|
148 | 148 | ) |
|
149 | 149 | coreconfigitem( |
|
150 | 150 | section, |
|
151 | 151 | configprefix + b'git', |
|
152 | 152 | default=False, |
|
153 | 153 | ) |
|
154 | 154 | coreconfigitem( |
|
155 | 155 | section, |
|
156 | 156 | configprefix + b'ignorews', |
|
157 | 157 | default=False, |
|
158 | 158 | ) |
|
159 | 159 | coreconfigitem( |
|
160 | 160 | section, |
|
161 | 161 | configprefix + b'ignorewsamount', |
|
162 | 162 | default=False, |
|
163 | 163 | ) |
|
164 | 164 | coreconfigitem( |
|
165 | 165 | section, |
|
166 | 166 | configprefix + b'ignoreblanklines', |
|
167 | 167 | default=False, |
|
168 | 168 | ) |
|
169 | 169 | coreconfigitem( |
|
170 | 170 | section, |
|
171 | 171 | configprefix + b'ignorewseol', |
|
172 | 172 | default=False, |
|
173 | 173 | ) |
|
174 | 174 | coreconfigitem( |
|
175 | 175 | section, |
|
176 | 176 | configprefix + b'nobinary', |
|
177 | 177 | default=False, |
|
178 | 178 | ) |
|
179 | 179 | coreconfigitem( |
|
180 | 180 | section, |
|
181 | 181 | configprefix + b'noprefix', |
|
182 | 182 | default=False, |
|
183 | 183 | ) |
|
184 | 184 | coreconfigitem( |
|
185 | 185 | section, |
|
186 | 186 | configprefix + b'word-diff', |
|
187 | 187 | default=False, |
|
188 | 188 | ) |
|
189 | 189 | |
|
190 | 190 | |
|
191 | 191 | coreconfigitem( |
|
192 | 192 | b'alias', |
|
193 | 193 | b'.*', |
|
194 | 194 | default=dynamicdefault, |
|
195 | 195 | generic=True, |
|
196 | 196 | ) |
|
197 | 197 | coreconfigitem( |
|
198 | 198 | b'auth', |
|
199 | 199 | b'cookiefile', |
|
200 | 200 | default=None, |
|
201 | 201 | ) |
|
202 | 202 | _registerdiffopts(section=b'annotate') |
|
203 | 203 | # bookmarks.pushing: internal hack for discovery |
|
204 | 204 | coreconfigitem( |
|
205 | 205 | b'bookmarks', |
|
206 | 206 | b'pushing', |
|
207 | 207 | default=list, |
|
208 | 208 | ) |
|
209 | 209 | # bundle.mainreporoot: internal hack for bundlerepo |
|
210 | 210 | coreconfigitem( |
|
211 | 211 | b'bundle', |
|
212 | 212 | b'mainreporoot', |
|
213 | 213 | default=b'', |
|
214 | 214 | ) |
|
215 | 215 | coreconfigitem( |
|
216 | 216 | b'censor', |
|
217 | 217 | b'policy', |
|
218 | 218 | default=b'abort', |
|
219 | 219 | experimental=True, |
|
220 | 220 | ) |
|
221 | 221 | coreconfigitem( |
|
222 | 222 | b'chgserver', |
|
223 | 223 | b'idletimeout', |
|
224 | 224 | default=3600, |
|
225 | 225 | ) |
|
226 | 226 | coreconfigitem( |
|
227 | 227 | b'chgserver', |
|
228 | 228 | b'skiphash', |
|
229 | 229 | default=False, |
|
230 | 230 | ) |
|
231 | 231 | coreconfigitem( |
|
232 | 232 | b'cmdserver', |
|
233 | 233 | b'log', |
|
234 | 234 | default=None, |
|
235 | 235 | ) |
|
236 | 236 | coreconfigitem( |
|
237 | 237 | b'cmdserver', |
|
238 | 238 | b'max-log-files', |
|
239 | 239 | default=7, |
|
240 | 240 | ) |
|
241 | 241 | coreconfigitem( |
|
242 | 242 | b'cmdserver', |
|
243 | 243 | b'max-log-size', |
|
244 | 244 | default=b'1 MB', |
|
245 | 245 | ) |
|
246 | 246 | coreconfigitem( |
|
247 | 247 | b'cmdserver', |
|
248 | 248 | b'max-repo-cache', |
|
249 | 249 | default=0, |
|
250 | 250 | experimental=True, |
|
251 | 251 | ) |
|
252 | 252 | coreconfigitem( |
|
253 | 253 | b'cmdserver', |
|
254 | 254 | b'message-encodings', |
|
255 | 255 | default=list, |
|
256 | 256 | ) |
|
257 | 257 | coreconfigitem( |
|
258 | 258 | b'cmdserver', |
|
259 | 259 | b'track-log', |
|
260 | 260 | default=lambda: [b'chgserver', b'cmdserver', b'repocache'], |
|
261 | 261 | ) |
|
262 | 262 | coreconfigitem( |
|
263 | 263 | b'cmdserver', |
|
264 | 264 | b'shutdown-on-interrupt', |
|
265 | 265 | default=True, |
|
266 | 266 | ) |
|
267 | 267 | coreconfigitem( |
|
268 | 268 | b'color', |
|
269 | 269 | b'.*', |
|
270 | 270 | default=None, |
|
271 | 271 | generic=True, |
|
272 | 272 | ) |
|
273 | 273 | coreconfigitem( |
|
274 | 274 | b'color', |
|
275 | 275 | b'mode', |
|
276 | 276 | default=b'auto', |
|
277 | 277 | ) |
|
278 | 278 | coreconfigitem( |
|
279 | 279 | b'color', |
|
280 | 280 | b'pagermode', |
|
281 | 281 | default=dynamicdefault, |
|
282 | 282 | ) |
|
283 | 283 | coreconfigitem( |
|
284 | 284 | b'command-templates', |
|
285 | 285 | b'graphnode', |
|
286 | 286 | default=None, |
|
287 | 287 | alias=[(b'ui', b'graphnodetemplate')], |
|
288 | 288 | ) |
|
289 | 289 | coreconfigitem( |
|
290 | 290 | b'command-templates', |
|
291 | 291 | b'log', |
|
292 | 292 | default=None, |
|
293 | 293 | alias=[(b'ui', b'logtemplate')], |
|
294 | 294 | ) |
|
295 | 295 | coreconfigitem( |
|
296 | 296 | b'command-templates', |
|
297 | 297 | b'mergemarker', |
|
298 | 298 | default=( |
|
299 | 299 | b'{node|short} ' |
|
300 | 300 | b'{ifeq(tags, "tip", "", ' |
|
301 | 301 | b'ifeq(tags, "", "", "{tags} "))}' |
|
302 | 302 | b'{if(bookmarks, "{bookmarks} ")}' |
|
303 | 303 | b'{ifeq(branch, "default", "", "{branch} ")}' |
|
304 | 304 | b'- {author|user}: {desc|firstline}' |
|
305 | 305 | ), |
|
306 | 306 | alias=[(b'ui', b'mergemarkertemplate')], |
|
307 | 307 | ) |
|
308 | 308 | coreconfigitem( |
|
309 | 309 | b'command-templates', |
|
310 | 310 | b'pre-merge-tool-output', |
|
311 | 311 | default=None, |
|
312 | 312 | alias=[(b'ui', b'pre-merge-tool-output-template')], |
|
313 | 313 | ) |
|
314 | 314 | coreconfigitem( |
|
315 | 315 | b'command-templates', |
|
316 | 316 | b'oneline-summary', |
|
317 | 317 | default=None, |
|
318 | 318 | ) |
|
319 | 319 | coreconfigitem( |
|
320 | 320 | b'command-templates', |
|
321 | 321 | b'oneline-summary.*', |
|
322 | 322 | default=dynamicdefault, |
|
323 | 323 | generic=True, |
|
324 | 324 | ) |
|
325 | 325 | _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.') |
|
326 | 326 | coreconfigitem( |
|
327 | 327 | b'commands', |
|
328 | 328 | b'commit.post-status', |
|
329 | 329 | default=False, |
|
330 | 330 | ) |
|
331 | 331 | coreconfigitem( |
|
332 | 332 | b'commands', |
|
333 | 333 | b'grep.all-files', |
|
334 | 334 | default=False, |
|
335 | 335 | experimental=True, |
|
336 | 336 | ) |
|
337 | 337 | coreconfigitem( |
|
338 | 338 | b'commands', |
|
339 | 339 | b'merge.require-rev', |
|
340 | 340 | default=False, |
|
341 | 341 | ) |
|
342 | 342 | coreconfigitem( |
|
343 | 343 | b'commands', |
|
344 | 344 | b'push.require-revs', |
|
345 | 345 | default=False, |
|
346 | 346 | ) |
|
347 | 347 | coreconfigitem( |
|
348 | 348 | b'commands', |
|
349 | 349 | b'resolve.confirm', |
|
350 | 350 | default=False, |
|
351 | 351 | ) |
|
352 | 352 | coreconfigitem( |
|
353 | 353 | b'commands', |
|
354 | 354 | b'resolve.explicit-re-merge', |
|
355 | 355 | default=False, |
|
356 | 356 | ) |
|
357 | 357 | coreconfigitem( |
|
358 | 358 | b'commands', |
|
359 | 359 | b'resolve.mark-check', |
|
360 | 360 | default=b'none', |
|
361 | 361 | ) |
|
362 | 362 | _registerdiffopts(section=b'commands', configprefix=b'revert.interactive.') |
|
363 | 363 | coreconfigitem( |
|
364 | 364 | b'commands', |
|
365 | 365 | b'show.aliasprefix', |
|
366 | 366 | default=list, |
|
367 | 367 | ) |
|
368 | 368 | coreconfigitem( |
|
369 | 369 | b'commands', |
|
370 | 370 | b'status.relative', |
|
371 | 371 | default=False, |
|
372 | 372 | ) |
|
373 | 373 | coreconfigitem( |
|
374 | 374 | b'commands', |
|
375 | 375 | b'status.skipstates', |
|
376 | 376 | default=[], |
|
377 | 377 | experimental=True, |
|
378 | 378 | ) |
|
379 | 379 | coreconfigitem( |
|
380 | 380 | b'commands', |
|
381 | 381 | b'status.terse', |
|
382 | 382 | default=b'', |
|
383 | 383 | ) |
|
384 | 384 | coreconfigitem( |
|
385 | 385 | b'commands', |
|
386 | 386 | b'status.verbose', |
|
387 | 387 | default=False, |
|
388 | 388 | ) |
|
389 | 389 | coreconfigitem( |
|
390 | 390 | b'commands', |
|
391 | 391 | b'update.check', |
|
392 | 392 | default=None, |
|
393 | 393 | ) |
|
394 | 394 | coreconfigitem( |
|
395 | 395 | b'commands', |
|
396 | 396 | b'update.requiredest', |
|
397 | 397 | default=False, |
|
398 | 398 | ) |
|
399 | 399 | coreconfigitem( |
|
400 | 400 | b'committemplate', |
|
401 | 401 | b'.*', |
|
402 | 402 | default=None, |
|
403 | 403 | generic=True, |
|
404 | 404 | ) |
|
405 | 405 | coreconfigitem( |
|
406 | 406 | b'convert', |
|
407 | 407 | b'bzr.saverev', |
|
408 | 408 | default=True, |
|
409 | 409 | ) |
|
410 | 410 | coreconfigitem( |
|
411 | 411 | b'convert', |
|
412 | 412 | b'cvsps.cache', |
|
413 | 413 | default=True, |
|
414 | 414 | ) |
|
415 | 415 | coreconfigitem( |
|
416 | 416 | b'convert', |
|
417 | 417 | b'cvsps.fuzz', |
|
418 | 418 | default=60, |
|
419 | 419 | ) |
|
420 | 420 | coreconfigitem( |
|
421 | 421 | b'convert', |
|
422 | 422 | b'cvsps.logencoding', |
|
423 | 423 | default=None, |
|
424 | 424 | ) |
|
425 | 425 | coreconfigitem( |
|
426 | 426 | b'convert', |
|
427 | 427 | b'cvsps.mergefrom', |
|
428 | 428 | default=None, |
|
429 | 429 | ) |
|
430 | 430 | coreconfigitem( |
|
431 | 431 | b'convert', |
|
432 | 432 | b'cvsps.mergeto', |
|
433 | 433 | default=None, |
|
434 | 434 | ) |
|
435 | 435 | coreconfigitem( |
|
436 | 436 | b'convert', |
|
437 | 437 | b'git.committeractions', |
|
438 | 438 | default=lambda: [b'messagedifferent'], |
|
439 | 439 | ) |
|
440 | 440 | coreconfigitem( |
|
441 | 441 | b'convert', |
|
442 | 442 | b'git.extrakeys', |
|
443 | 443 | default=list, |
|
444 | 444 | ) |
|
445 | 445 | coreconfigitem( |
|
446 | 446 | b'convert', |
|
447 | 447 | b'git.findcopiesharder', |
|
448 | 448 | default=False, |
|
449 | 449 | ) |
|
450 | 450 | coreconfigitem( |
|
451 | 451 | b'convert', |
|
452 | 452 | b'git.remoteprefix', |
|
453 | 453 | default=b'remote', |
|
454 | 454 | ) |
|
455 | 455 | coreconfigitem( |
|
456 | 456 | b'convert', |
|
457 | 457 | b'git.renamelimit', |
|
458 | 458 | default=400, |
|
459 | 459 | ) |
|
460 | 460 | coreconfigitem( |
|
461 | 461 | b'convert', |
|
462 | 462 | b'git.saverev', |
|
463 | 463 | default=True, |
|
464 | 464 | ) |
|
465 | 465 | coreconfigitem( |
|
466 | 466 | b'convert', |
|
467 | 467 | b'git.similarity', |
|
468 | 468 | default=50, |
|
469 | 469 | ) |
|
470 | 470 | coreconfigitem( |
|
471 | 471 | b'convert', |
|
472 | 472 | b'git.skipsubmodules', |
|
473 | 473 | default=False, |
|
474 | 474 | ) |
|
475 | 475 | coreconfigitem( |
|
476 | 476 | b'convert', |
|
477 | 477 | b'hg.clonebranches', |
|
478 | 478 | default=False, |
|
479 | 479 | ) |
|
480 | 480 | coreconfigitem( |
|
481 | 481 | b'convert', |
|
482 | 482 | b'hg.ignoreerrors', |
|
483 | 483 | default=False, |
|
484 | 484 | ) |
|
485 | 485 | coreconfigitem( |
|
486 | 486 | b'convert', |
|
487 | 487 | b'hg.preserve-hash', |
|
488 | 488 | default=False, |
|
489 | 489 | ) |
|
490 | 490 | coreconfigitem( |
|
491 | 491 | b'convert', |
|
492 | 492 | b'hg.revs', |
|
493 | 493 | default=None, |
|
494 | 494 | ) |
|
495 | 495 | coreconfigitem( |
|
496 | 496 | b'convert', |
|
497 | 497 | b'hg.saverev', |
|
498 | 498 | default=False, |
|
499 | 499 | ) |
|
500 | 500 | coreconfigitem( |
|
501 | 501 | b'convert', |
|
502 | 502 | b'hg.sourcename', |
|
503 | 503 | default=None, |
|
504 | 504 | ) |
|
505 | 505 | coreconfigitem( |
|
506 | 506 | b'convert', |
|
507 | 507 | b'hg.startrev', |
|
508 | 508 | default=None, |
|
509 | 509 | ) |
|
510 | 510 | coreconfigitem( |
|
511 | 511 | b'convert', |
|
512 | 512 | b'hg.tagsbranch', |
|
513 | 513 | default=b'default', |
|
514 | 514 | ) |
|
515 | 515 | coreconfigitem( |
|
516 | 516 | b'convert', |
|
517 | 517 | b'hg.usebranchnames', |
|
518 | 518 | default=True, |
|
519 | 519 | ) |
|
520 | 520 | coreconfigitem( |
|
521 | 521 | b'convert', |
|
522 | 522 | b'ignoreancestorcheck', |
|
523 | 523 | default=False, |
|
524 | 524 | experimental=True, |
|
525 | 525 | ) |
|
526 | 526 | coreconfigitem( |
|
527 | 527 | b'convert', |
|
528 | 528 | b'localtimezone', |
|
529 | 529 | default=False, |
|
530 | 530 | ) |
|
531 | 531 | coreconfigitem( |
|
532 | 532 | b'convert', |
|
533 | 533 | b'p4.encoding', |
|
534 | 534 | default=dynamicdefault, |
|
535 | 535 | ) |
|
536 | 536 | coreconfigitem( |
|
537 | 537 | b'convert', |
|
538 | 538 | b'p4.startrev', |
|
539 | 539 | default=0, |
|
540 | 540 | ) |
|
541 | 541 | coreconfigitem( |
|
542 | 542 | b'convert', |
|
543 | 543 | b'skiptags', |
|
544 | 544 | default=False, |
|
545 | 545 | ) |
|
546 | 546 | coreconfigitem( |
|
547 | 547 | b'convert', |
|
548 | 548 | b'svn.debugsvnlog', |
|
549 | 549 | default=True, |
|
550 | 550 | ) |
|
551 | 551 | coreconfigitem( |
|
552 | 552 | b'convert', |
|
553 | 553 | b'svn.trunk', |
|
554 | 554 | default=None, |
|
555 | 555 | ) |
|
556 | 556 | coreconfigitem( |
|
557 | 557 | b'convert', |
|
558 | 558 | b'svn.tags', |
|
559 | 559 | default=None, |
|
560 | 560 | ) |
|
561 | 561 | coreconfigitem( |
|
562 | 562 | b'convert', |
|
563 | 563 | b'svn.branches', |
|
564 | 564 | default=None, |
|
565 | 565 | ) |
|
566 | 566 | coreconfigitem( |
|
567 | 567 | b'convert', |
|
568 | 568 | b'svn.startrev', |
|
569 | 569 | default=0, |
|
570 | 570 | ) |
|
571 | 571 | coreconfigitem( |
|
572 | 572 | b'convert', |
|
573 | 573 | b'svn.dangerous-set-commit-dates', |
|
574 | 574 | default=False, |
|
575 | 575 | ) |
|
576 | 576 | coreconfigitem( |
|
577 | 577 | b'debug', |
|
578 | 578 | b'dirstate.delaywrite', |
|
579 | 579 | default=0, |
|
580 | 580 | ) |
|
581 | 581 | coreconfigitem( |
|
582 | 582 | b'debug', |
|
583 | 583 | b'revlog.verifyposition.changelog', |
|
584 | 584 | default=b'', |
|
585 | 585 | ) |
|
586 | 586 | coreconfigitem( |
|
587 | 587 | b'debug', |
|
588 | 588 | b'revlog.debug-delta', |
|
589 | 589 | default=False, |
|
590 | 590 | ) |
|
591 | 591 | coreconfigitem( |
|
592 | 592 | b'defaults', |
|
593 | 593 | b'.*', |
|
594 | 594 | default=None, |
|
595 | 595 | generic=True, |
|
596 | 596 | ) |
|
597 | 597 | coreconfigitem( |
|
598 | 598 | b'devel', |
|
599 | 599 | b'all-warnings', |
|
600 | 600 | default=False, |
|
601 | 601 | ) |
|
602 | 602 | coreconfigitem( |
|
603 | 603 | b'devel', |
|
604 | 604 | b'bundle2.debug', |
|
605 | 605 | default=False, |
|
606 | 606 | ) |
|
607 | 607 | coreconfigitem( |
|
608 | 608 | b'devel', |
|
609 | 609 | b'bundle.delta', |
|
610 | 610 | default=b'', |
|
611 | 611 | ) |
|
612 | 612 | coreconfigitem( |
|
613 | 613 | b'devel', |
|
614 | 614 | b'cache-vfs', |
|
615 | 615 | default=None, |
|
616 | 616 | ) |
|
617 | 617 | coreconfigitem( |
|
618 | 618 | b'devel', |
|
619 | 619 | b'check-locks', |
|
620 | 620 | default=False, |
|
621 | 621 | ) |
|
622 | 622 | coreconfigitem( |
|
623 | 623 | b'devel', |
|
624 | 624 | b'check-relroot', |
|
625 | 625 | default=False, |
|
626 | 626 | ) |
|
627 | 627 | # Track copy information for all file, not just "added" one (very slow) |
|
628 | 628 | coreconfigitem( |
|
629 | 629 | b'devel', |
|
630 | 630 | b'copy-tracing.trace-all-files', |
|
631 | 631 | default=False, |
|
632 | 632 | ) |
|
633 | 633 | coreconfigitem( |
|
634 | 634 | b'devel', |
|
635 | 635 | b'default-date', |
|
636 | 636 | default=None, |
|
637 | 637 | ) |
|
638 | 638 | coreconfigitem( |
|
639 | 639 | b'devel', |
|
640 | 640 | b'deprec-warn', |
|
641 | 641 | default=False, |
|
642 | 642 | ) |
|
643 | 643 | coreconfigitem( |
|
644 | 644 | b'devel', |
|
645 | 645 | b'disableloaddefaultcerts', |
|
646 | 646 | default=False, |
|
647 | 647 | ) |
|
648 | 648 | coreconfigitem( |
|
649 | 649 | b'devel', |
|
650 | 650 | b'warn-empty-changegroup', |
|
651 | 651 | default=False, |
|
652 | 652 | ) |
|
653 | 653 | coreconfigitem( |
|
654 | 654 | b'devel', |
|
655 | 655 | b'legacy.exchange', |
|
656 | 656 | default=list, |
|
657 | 657 | ) |
|
658 | 658 | # When True, revlogs use a special reference version of the nodemap, that is not |
|
659 | 659 | # performant but is "known" to behave properly. |
|
660 | 660 | coreconfigitem( |
|
661 | 661 | b'devel', |
|
662 | 662 | b'persistent-nodemap', |
|
663 | 663 | default=False, |
|
664 | 664 | ) |
|
665 | 665 | coreconfigitem( |
|
666 | 666 | b'devel', |
|
667 | 667 | b'servercafile', |
|
668 | 668 | default=b'', |
|
669 | 669 | ) |
|
670 | 670 | coreconfigitem( |
|
671 | 671 | b'devel', |
|
672 | 672 | b'serverexactprotocol', |
|
673 | 673 | default=b'', |
|
674 | 674 | ) |
|
675 | 675 | coreconfigitem( |
|
676 | 676 | b'devel', |
|
677 | 677 | b'serverrequirecert', |
|
678 | 678 | default=False, |
|
679 | 679 | ) |
|
680 | 680 | coreconfigitem( |
|
681 | 681 | b'devel', |
|
682 | 682 | b'strip-obsmarkers', |
|
683 | 683 | default=True, |
|
684 | 684 | ) |
|
685 | 685 | coreconfigitem( |
|
686 | 686 | b'devel', |
|
687 | 687 | b'warn-config', |
|
688 | 688 | default=None, |
|
689 | 689 | ) |
|
690 | 690 | coreconfigitem( |
|
691 | 691 | b'devel', |
|
692 | 692 | b'warn-config-default', |
|
693 | 693 | default=None, |
|
694 | 694 | ) |
|
695 | 695 | coreconfigitem( |
|
696 | 696 | b'devel', |
|
697 | 697 | b'user.obsmarker', |
|
698 | 698 | default=None, |
|
699 | 699 | ) |
|
700 | 700 | coreconfigitem( |
|
701 | 701 | b'devel', |
|
702 | 702 | b'warn-config-unknown', |
|
703 | 703 | default=None, |
|
704 | 704 | ) |
|
705 | 705 | coreconfigitem( |
|
706 | 706 | b'devel', |
|
707 | 707 | b'debug.copies', |
|
708 | 708 | default=False, |
|
709 | 709 | ) |
|
710 | 710 | coreconfigitem( |
|
711 | 711 | b'devel', |
|
712 | 712 | b'copy-tracing.multi-thread', |
|
713 | 713 | default=True, |
|
714 | 714 | ) |
|
715 | 715 | coreconfigitem( |
|
716 | 716 | b'devel', |
|
717 | 717 | b'debug.extensions', |
|
718 | 718 | default=False, |
|
719 | 719 | ) |
|
720 | 720 | coreconfigitem( |
|
721 | 721 | b'devel', |
|
722 | 722 | b'debug.repo-filters', |
|
723 | 723 | default=False, |
|
724 | 724 | ) |
|
725 | 725 | coreconfigitem( |
|
726 | 726 | b'devel', |
|
727 | 727 | b'debug.peer-request', |
|
728 | 728 | default=False, |
|
729 | 729 | ) |
|
730 | 730 | # If discovery.exchange-heads is False, the discovery will not start with |
|
731 | 731 | # remote head fetching and local head querying. |
|
732 | 732 | coreconfigitem( |
|
733 | 733 | b'devel', |
|
734 | 734 | b'discovery.exchange-heads', |
|
735 | 735 | default=True, |
|
736 | 736 | ) |
|
737 | 737 | # If discovery.grow-sample is False, the sample size used in set discovery will |
|
738 | 738 | # not be increased through the process |
|
739 | 739 | coreconfigitem( |
|
740 | 740 | b'devel', |
|
741 | 741 | b'discovery.grow-sample', |
|
742 | 742 | default=True, |
|
743 | 743 | ) |
|
744 | 744 | # When discovery.grow-sample.dynamic is True, the default, the sample size is |
|
745 | 745 | # adapted to the shape of the undecided set (it is set to the max of: |
|
746 | 746 | # <target-size>, len(roots(undecided)), len(heads(undecided) |
|
747 | 747 | coreconfigitem( |
|
748 | 748 | b'devel', |
|
749 | 749 | b'discovery.grow-sample.dynamic', |
|
750 | 750 | default=True, |
|
751 | 751 | ) |
|
752 | 752 | # discovery.grow-sample.rate control the rate at which the sample grow |
|
753 | 753 | coreconfigitem( |
|
754 | 754 | b'devel', |
|
755 | 755 | b'discovery.grow-sample.rate', |
|
756 | 756 | default=1.05, |
|
757 | 757 | ) |
|
758 | 758 | # If discovery.randomize is False, random sampling during discovery are |
|
759 | 759 | # deterministic. It is meant for integration tests. |
|
760 | 760 | coreconfigitem( |
|
761 | 761 | b'devel', |
|
762 | 762 | b'discovery.randomize', |
|
763 | 763 | default=True, |
|
764 | 764 | ) |
|
765 | 765 | # Control the initial size of the discovery sample |
|
766 | 766 | coreconfigitem( |
|
767 | 767 | b'devel', |
|
768 | 768 | b'discovery.sample-size', |
|
769 | 769 | default=200, |
|
770 | 770 | ) |
|
771 | 771 | # Control the initial size of the discovery for initial change |
|
772 | 772 | coreconfigitem( |
|
773 | 773 | b'devel', |
|
774 | 774 | b'discovery.sample-size.initial', |
|
775 | 775 | default=100, |
|
776 | 776 | ) |
|
777 | 777 | _registerdiffopts(section=b'diff') |
|
778 | 778 | coreconfigitem( |
|
779 | 779 | b'diff', |
|
780 | 780 | b'merge', |
|
781 | 781 | default=False, |
|
782 | 782 | experimental=True, |
|
783 | 783 | ) |
|
784 | 784 | coreconfigitem( |
|
785 | 785 | b'email', |
|
786 | 786 | b'bcc', |
|
787 | 787 | default=None, |
|
788 | 788 | ) |
|
789 | 789 | coreconfigitem( |
|
790 | 790 | b'email', |
|
791 | 791 | b'cc', |
|
792 | 792 | default=None, |
|
793 | 793 | ) |
|
794 | 794 | coreconfigitem( |
|
795 | 795 | b'email', |
|
796 | 796 | b'charsets', |
|
797 | 797 | default=list, |
|
798 | 798 | ) |
|
799 | 799 | coreconfigitem( |
|
800 | 800 | b'email', |
|
801 | 801 | b'from', |
|
802 | 802 | default=None, |
|
803 | 803 | ) |
|
804 | 804 | coreconfigitem( |
|
805 | 805 | b'email', |
|
806 | 806 | b'method', |
|
807 | 807 | default=b'smtp', |
|
808 | 808 | ) |
|
809 | 809 | coreconfigitem( |
|
810 | 810 | b'email', |
|
811 | 811 | b'reply-to', |
|
812 | 812 | default=None, |
|
813 | 813 | ) |
|
814 | 814 | coreconfigitem( |
|
815 | 815 | b'email', |
|
816 | 816 | b'to', |
|
817 | 817 | default=None, |
|
818 | 818 | ) |
|
819 | 819 | coreconfigitem( |
|
820 | 820 | b'experimental', |
|
821 | 821 | b'archivemetatemplate', |
|
822 | 822 | default=dynamicdefault, |
|
823 | 823 | ) |
|
824 | 824 | coreconfigitem( |
|
825 | 825 | b'experimental', |
|
826 | 826 | b'auto-publish', |
|
827 | 827 | default=b'publish', |
|
828 | 828 | ) |
|
829 | 829 | coreconfigitem( |
|
830 | 830 | b'experimental', |
|
831 | 831 | b'bundle-phases', |
|
832 | 832 | default=False, |
|
833 | 833 | ) |
|
834 | 834 | coreconfigitem( |
|
835 | 835 | b'experimental', |
|
836 | 836 | b'bundle2-advertise', |
|
837 | 837 | default=True, |
|
838 | 838 | ) |
|
839 | 839 | coreconfigitem( |
|
840 | 840 | b'experimental', |
|
841 | 841 | b'bundle2-output-capture', |
|
842 | 842 | default=False, |
|
843 | 843 | ) |
|
844 | 844 | coreconfigitem( |
|
845 | 845 | b'experimental', |
|
846 | 846 | b'bundle2.pushback', |
|
847 | 847 | default=False, |
|
848 | 848 | ) |
|
849 | 849 | coreconfigitem( |
|
850 | 850 | b'experimental', |
|
851 | 851 | b'bundle2lazylocking', |
|
852 | 852 | default=False, |
|
853 | 853 | ) |
|
854 | 854 | coreconfigitem( |
|
855 | 855 | b'experimental', |
|
856 | 856 | b'bundlecomplevel', |
|
857 | 857 | default=None, |
|
858 | 858 | ) |
|
859 | 859 | coreconfigitem( |
|
860 | 860 | b'experimental', |
|
861 | 861 | b'bundlecomplevel.bzip2', |
|
862 | 862 | default=None, |
|
863 | 863 | ) |
|
864 | 864 | coreconfigitem( |
|
865 | 865 | b'experimental', |
|
866 | 866 | b'bundlecomplevel.gzip', |
|
867 | 867 | default=None, |
|
868 | 868 | ) |
|
869 | 869 | coreconfigitem( |
|
870 | 870 | b'experimental', |
|
871 | 871 | b'bundlecomplevel.none', |
|
872 | 872 | default=None, |
|
873 | 873 | ) |
|
874 | 874 | coreconfigitem( |
|
875 | 875 | b'experimental', |
|
876 | 876 | b'bundlecomplevel.zstd', |
|
877 | 877 | default=None, |
|
878 | 878 | ) |
|
879 | 879 | coreconfigitem( |
|
880 | 880 | b'experimental', |
|
881 | 881 | b'bundlecompthreads', |
|
882 | 882 | default=None, |
|
883 | 883 | ) |
|
884 | 884 | coreconfigitem( |
|
885 | 885 | b'experimental', |
|
886 | 886 | b'bundlecompthreads.bzip2', |
|
887 | 887 | default=None, |
|
888 | 888 | ) |
|
889 | 889 | coreconfigitem( |
|
890 | 890 | b'experimental', |
|
891 | 891 | b'bundlecompthreads.gzip', |
|
892 | 892 | default=None, |
|
893 | 893 | ) |
|
894 | 894 | coreconfigitem( |
|
895 | 895 | b'experimental', |
|
896 | 896 | b'bundlecompthreads.none', |
|
897 | 897 | default=None, |
|
898 | 898 | ) |
|
899 | 899 | coreconfigitem( |
|
900 | 900 | b'experimental', |
|
901 | 901 | b'bundlecompthreads.zstd', |
|
902 | 902 | default=None, |
|
903 | 903 | ) |
|
904 | 904 | coreconfigitem( |
|
905 | 905 | b'experimental', |
|
906 | 906 | b'changegroup3', |
|
907 | 907 | default=False, |
|
908 | 908 | ) |
|
909 | 909 | coreconfigitem( |
|
910 | 910 | b'experimental', |
|
911 | 911 | b'changegroup4', |
|
912 | 912 | default=False, |
|
913 | 913 | ) |
|
914 | 914 | coreconfigitem( |
|
915 | 915 | b'experimental', |
|
916 | 916 | b'cleanup-as-archived', |
|
917 | 917 | default=False, |
|
918 | 918 | ) |
|
919 | 919 | coreconfigitem( |
|
920 | 920 | b'experimental', |
|
921 | 921 | b'clientcompressionengines', |
|
922 | 922 | default=list, |
|
923 | 923 | ) |
|
924 | 924 | coreconfigitem( |
|
925 | 925 | b'experimental', |
|
926 | 926 | b'copytrace', |
|
927 | 927 | default=b'on', |
|
928 | 928 | ) |
|
929 | 929 | coreconfigitem( |
|
930 | 930 | b'experimental', |
|
931 | 931 | b'copytrace.movecandidateslimit', |
|
932 | 932 | default=100, |
|
933 | 933 | ) |
|
934 | 934 | coreconfigitem( |
|
935 | 935 | b'experimental', |
|
936 | 936 | b'copytrace.sourcecommitlimit', |
|
937 | 937 | default=100, |
|
938 | 938 | ) |
|
939 | 939 | coreconfigitem( |
|
940 | 940 | b'experimental', |
|
941 | 941 | b'copies.read-from', |
|
942 | 942 | default=b"filelog-only", |
|
943 | 943 | ) |
|
944 | 944 | coreconfigitem( |
|
945 | 945 | b'experimental', |
|
946 | 946 | b'copies.write-to', |
|
947 | 947 | default=b'filelog-only', |
|
948 | 948 | ) |
|
949 | 949 | coreconfigitem( |
|
950 | 950 | b'experimental', |
|
951 | 951 | b'crecordtest', |
|
952 | 952 | default=None, |
|
953 | 953 | ) |
|
954 | 954 | coreconfigitem( |
|
955 | 955 | b'experimental', |
|
956 | 956 | b'directaccess', |
|
957 | 957 | default=False, |
|
958 | 958 | ) |
|
959 | 959 | coreconfigitem( |
|
960 | 960 | b'experimental', |
|
961 | 961 | b'directaccess.revnums', |
|
962 | 962 | default=False, |
|
963 | 963 | ) |
|
964 | 964 | coreconfigitem( |
|
965 | 965 | b'experimental', |
|
966 | 966 | b'editortmpinhg', |
|
967 | 967 | default=False, |
|
968 | 968 | ) |
|
969 | 969 | coreconfigitem( |
|
970 | 970 | b'experimental', |
|
971 | 971 | b'evolution', |
|
972 | 972 | default=list, |
|
973 | 973 | ) |
|
974 | 974 | coreconfigitem( |
|
975 | 975 | b'experimental', |
|
976 | 976 | b'evolution.allowdivergence', |
|
977 | 977 | default=False, |
|
978 | 978 | alias=[(b'experimental', b'allowdivergence')], |
|
979 | 979 | ) |
|
980 | 980 | coreconfigitem( |
|
981 | 981 | b'experimental', |
|
982 | 982 | b'evolution.allowunstable', |
|
983 | 983 | default=None, |
|
984 | 984 | ) |
|
985 | 985 | coreconfigitem( |
|
986 | 986 | b'experimental', |
|
987 | 987 | b'evolution.createmarkers', |
|
988 | 988 | default=None, |
|
989 | 989 | ) |
|
990 | 990 | coreconfigitem( |
|
991 | 991 | b'experimental', |
|
992 | 992 | b'evolution.effect-flags', |
|
993 | 993 | default=True, |
|
994 | 994 | alias=[(b'experimental', b'effect-flags')], |
|
995 | 995 | ) |
|
996 | 996 | coreconfigitem( |
|
997 | 997 | b'experimental', |
|
998 | 998 | b'evolution.exchange', |
|
999 | 999 | default=None, |
|
1000 | 1000 | ) |
|
1001 | 1001 | coreconfigitem( |
|
1002 | 1002 | b'experimental', |
|
1003 | 1003 | b'evolution.bundle-obsmarker', |
|
1004 | 1004 | default=False, |
|
1005 | 1005 | ) |
|
1006 | 1006 | coreconfigitem( |
|
1007 | 1007 | b'experimental', |
|
1008 | 1008 | b'evolution.bundle-obsmarker:mandatory', |
|
1009 | 1009 | default=True, |
|
1010 | 1010 | ) |
|
1011 | 1011 | coreconfigitem( |
|
1012 | 1012 | b'experimental', |
|
1013 | 1013 | b'log.topo', |
|
1014 | 1014 | default=False, |
|
1015 | 1015 | ) |
|
1016 | 1016 | coreconfigitem( |
|
1017 | 1017 | b'experimental', |
|
1018 | 1018 | b'evolution.report-instabilities', |
|
1019 | 1019 | default=True, |
|
1020 | 1020 | ) |
|
1021 | 1021 | coreconfigitem( |
|
1022 | 1022 | b'experimental', |
|
1023 | 1023 | b'evolution.track-operation', |
|
1024 | 1024 | default=True, |
|
1025 | 1025 | ) |
|
1026 | 1026 | # repo-level config to exclude a revset visibility |
|
1027 | 1027 | # |
|
1028 | 1028 | # The target use case is to use `share` to expose different subset of the same |
|
1029 | 1029 | # repository, especially server side. See also `server.view`. |
|
1030 | 1030 | coreconfigitem( |
|
1031 | 1031 | b'experimental', |
|
1032 | 1032 | b'extra-filter-revs', |
|
1033 | 1033 | default=None, |
|
1034 | 1034 | ) |
|
1035 | 1035 | coreconfigitem( |
|
1036 | 1036 | b'experimental', |
|
1037 | 1037 | b'maxdeltachainspan', |
|
1038 | 1038 | default=-1, |
|
1039 | 1039 | ) |
|
1040 | 1040 | # tracks files which were undeleted (merge might delete them but we explicitly |
|
1041 | 1041 | # kept/undeleted them) and creates new filenodes for them |
|
1042 | 1042 | coreconfigitem( |
|
1043 | 1043 | b'experimental', |
|
1044 | 1044 | b'merge-track-salvaged', |
|
1045 | 1045 | default=False, |
|
1046 | 1046 | ) |
|
1047 | 1047 | coreconfigitem( |
|
1048 | 1048 | b'experimental', |
|
1049 | 1049 | b'mmapindexthreshold', |
|
1050 | 1050 | default=None, |
|
1051 | 1051 | ) |
|
1052 | 1052 | coreconfigitem( |
|
1053 | 1053 | b'experimental', |
|
1054 | 1054 | b'narrow', |
|
1055 | 1055 | default=False, |
|
1056 | 1056 | ) |
|
1057 | 1057 | coreconfigitem( |
|
1058 | 1058 | b'experimental', |
|
1059 | 1059 | b'nonnormalparanoidcheck', |
|
1060 | 1060 | default=False, |
|
1061 | 1061 | ) |
|
1062 | 1062 | coreconfigitem( |
|
1063 | 1063 | b'experimental', |
|
1064 | 1064 | b'exportableenviron', |
|
1065 | 1065 | default=list, |
|
1066 | 1066 | ) |
|
1067 | 1067 | coreconfigitem( |
|
1068 | 1068 | b'experimental', |
|
1069 | 1069 | b'extendedheader.index', |
|
1070 | 1070 | default=None, |
|
1071 | 1071 | ) |
|
1072 | 1072 | coreconfigitem( |
|
1073 | 1073 | b'experimental', |
|
1074 | 1074 | b'extendedheader.similarity', |
|
1075 | 1075 | default=False, |
|
1076 | 1076 | ) |
|
1077 | 1077 | coreconfigitem( |
|
1078 | 1078 | b'experimental', |
|
1079 | 1079 | b'graphshorten', |
|
1080 | 1080 | default=False, |
|
1081 | 1081 | ) |
|
1082 | 1082 | coreconfigitem( |
|
1083 | 1083 | b'experimental', |
|
1084 | 1084 | b'graphstyle.parent', |
|
1085 | 1085 | default=dynamicdefault, |
|
1086 | 1086 | ) |
|
1087 | 1087 | coreconfigitem( |
|
1088 | 1088 | b'experimental', |
|
1089 | 1089 | b'graphstyle.missing', |
|
1090 | 1090 | default=dynamicdefault, |
|
1091 | 1091 | ) |
|
1092 | 1092 | coreconfigitem( |
|
1093 | 1093 | b'experimental', |
|
1094 | 1094 | b'graphstyle.grandparent', |
|
1095 | 1095 | default=dynamicdefault, |
|
1096 | 1096 | ) |
|
1097 | 1097 | coreconfigitem( |
|
1098 | 1098 | b'experimental', |
|
1099 | 1099 | b'hook-track-tags', |
|
1100 | 1100 | default=False, |
|
1101 | 1101 | ) |
|
1102 | 1102 | coreconfigitem( |
|
1103 | 1103 | b'experimental', |
|
1104 | 1104 | b'httppostargs', |
|
1105 | 1105 | default=False, |
|
1106 | 1106 | ) |
|
1107 | 1107 | coreconfigitem(b'experimental', b'nointerrupt', default=False) |
|
1108 | 1108 | coreconfigitem(b'experimental', b'nointerrupt-interactiveonly', default=True) |
|
1109 | 1109 | |
|
1110 | 1110 | coreconfigitem( |
|
1111 | 1111 | b'experimental', |
|
1112 | 1112 | b'obsmarkers-exchange-debug', |
|
1113 | 1113 | default=False, |
|
1114 | 1114 | ) |
|
1115 | 1115 | coreconfigitem( |
|
1116 | 1116 | b'experimental', |
|
1117 | 1117 | b'remotenames', |
|
1118 | 1118 | default=False, |
|
1119 | 1119 | ) |
|
1120 | 1120 | coreconfigitem( |
|
1121 | 1121 | b'experimental', |
|
1122 | 1122 | b'removeemptydirs', |
|
1123 | 1123 | default=True, |
|
1124 | 1124 | ) |
|
1125 | 1125 | coreconfigitem( |
|
1126 | 1126 | b'experimental', |
|
1127 | 1127 | b'revert.interactive.select-to-keep', |
|
1128 | 1128 | default=False, |
|
1129 | 1129 | ) |
|
1130 | 1130 | coreconfigitem( |
|
1131 | 1131 | b'experimental', |
|
1132 | 1132 | b'revisions.prefixhexnode', |
|
1133 | 1133 | default=False, |
|
1134 | 1134 | ) |
|
1135 | 1135 | # "out of experimental" todo list. |
|
1136 | 1136 | # |
|
1137 | 1137 | # * include management of a persistent nodemap in the main docket |
|
1138 | 1138 | # * enforce a "no-truncate" policy for mmap safety |
|
1139 | 1139 | # - for censoring operation |
|
1140 | 1140 | # - for stripping operation |
|
1141 | 1141 | # - for rollback operation |
|
1142 | 1142 | # * proper streaming (race free) of the docket file |
|
1143 | 1143 | # * track garbage data to evemtually allow rewriting -existing- sidedata. |
|
1144 | 1144 | # * Exchange-wise, we will also need to do something more efficient than |
|
1145 | 1145 | # keeping references to the affected revlogs, especially memory-wise when |
|
1146 | 1146 | # rewriting sidedata. |
|
1147 | 1147 | # * introduce a proper solution to reduce the number of filelog related files. |
|
1148 | 1148 | # * use caching for reading sidedata (similar to what we do for data). |
|
1149 | 1149 | # * no longer set offset=0 if sidedata_size=0 (simplify cutoff computation). |
|
1150 | 1150 | # * Improvement to consider |
|
1151 | 1151 | # - avoid compression header in chunk using the default compression? |
|
1152 | 1152 | # - forbid "inline" compression mode entirely? |
|
1153 | 1153 | # - split the data offset and flag field (the 2 bytes save are mostly trouble) |
|
1154 | 1154 | # - keep track of uncompressed -chunk- size (to preallocate memory better) |
|
1155 | 1155 | # - keep track of chain base or size (probably not that useful anymore) |
|
1156 | 1156 | coreconfigitem( |
|
1157 | 1157 | b'experimental', |
|
1158 | 1158 | b'revlogv2', |
|
1159 | 1159 | default=None, |
|
1160 | 1160 | ) |
|
1161 | 1161 | coreconfigitem( |
|
1162 | 1162 | b'experimental', |
|
1163 | 1163 | b'revisions.disambiguatewithin', |
|
1164 | 1164 | default=None, |
|
1165 | 1165 | ) |
|
1166 | 1166 | coreconfigitem( |
|
1167 | 1167 | b'experimental', |
|
1168 | 1168 | b'rust.index', |
|
1169 | 1169 | default=False, |
|
1170 | 1170 | ) |
|
1171 | 1171 | coreconfigitem( |
|
1172 | 1172 | b'experimental', |
|
1173 | 1173 | b'server.filesdata.recommended-batch-size', |
|
1174 | 1174 | default=50000, |
|
1175 | 1175 | ) |
|
1176 | 1176 | coreconfigitem( |
|
1177 | 1177 | b'experimental', |
|
1178 | 1178 | b'server.manifestdata.recommended-batch-size', |
|
1179 | 1179 | default=100000, |
|
1180 | 1180 | ) |
|
1181 | 1181 | coreconfigitem( |
|
1182 | 1182 | b'experimental', |
|
1183 | 1183 | b'server.stream-narrow-clones', |
|
1184 | 1184 | default=False, |
|
1185 | 1185 | ) |
|
1186 | 1186 | coreconfigitem( |
|
1187 | 1187 | b'experimental', |
|
1188 | 1188 | b'single-head-per-branch', |
|
1189 | 1189 | default=False, |
|
1190 | 1190 | ) |
|
1191 | 1191 | coreconfigitem( |
|
1192 | 1192 | b'experimental', |
|
1193 | 1193 | b'single-head-per-branch:account-closed-heads', |
|
1194 | 1194 | default=False, |
|
1195 | 1195 | ) |
|
1196 | 1196 | coreconfigitem( |
|
1197 | 1197 | b'experimental', |
|
1198 | 1198 | b'single-head-per-branch:public-changes-only', |
|
1199 | 1199 | default=False, |
|
1200 | 1200 | ) |
|
1201 | 1201 | coreconfigitem( |
|
1202 | 1202 | b'experimental', |
|
1203 | 1203 | b'sparse-read', |
|
1204 | 1204 | default=False, |
|
1205 | 1205 | ) |
|
1206 | 1206 | coreconfigitem( |
|
1207 | 1207 | b'experimental', |
|
1208 | 1208 | b'sparse-read.density-threshold', |
|
1209 | 1209 | default=0.50, |
|
1210 | 1210 | ) |
|
1211 | 1211 | coreconfigitem( |
|
1212 | 1212 | b'experimental', |
|
1213 | 1213 | b'sparse-read.min-gap-size', |
|
1214 | 1214 | default=b'65K', |
|
1215 | 1215 | ) |
|
1216 | 1216 | coreconfigitem( |
|
1217 | 1217 | b'experimental', |
|
1218 | 1218 | b'treemanifest', |
|
1219 | 1219 | default=False, |
|
1220 | 1220 | ) |
|
1221 | 1221 | coreconfigitem( |
|
1222 | 1222 | b'experimental', |
|
1223 | 1223 | b'update.atomic-file', |
|
1224 | 1224 | default=False, |
|
1225 | 1225 | ) |
|
1226 | 1226 | coreconfigitem( |
|
1227 | 1227 | b'experimental', |
|
1228 | 1228 | b'web.full-garbage-collection-rate', |
|
1229 | 1229 | default=1, # still forcing a full collection on each request |
|
1230 | 1230 | ) |
|
1231 | 1231 | coreconfigitem( |
|
1232 | 1232 | b'experimental', |
|
1233 | 1233 | b'worker.wdir-get-thread-safe', |
|
1234 | 1234 | default=False, |
|
1235 | 1235 | ) |
|
1236 | 1236 | coreconfigitem( |
|
1237 | 1237 | b'experimental', |
|
1238 | 1238 | b'worker.repository-upgrade', |
|
1239 | 1239 | default=False, |
|
1240 | 1240 | ) |
|
1241 | 1241 | coreconfigitem( |
|
1242 | 1242 | b'experimental', |
|
1243 | 1243 | b'xdiff', |
|
1244 | 1244 | default=False, |
|
1245 | 1245 | ) |
|
1246 | 1246 | coreconfigitem( |
|
1247 | 1247 | b'extensions', |
|
1248 | 1248 | b'[^:]*', |
|
1249 | 1249 | default=None, |
|
1250 | 1250 | generic=True, |
|
1251 | 1251 | ) |
|
1252 | 1252 | coreconfigitem( |
|
1253 | 1253 | b'extensions', |
|
1254 | 1254 | b'[^:]*:required', |
|
1255 | 1255 | default=False, |
|
1256 | 1256 | generic=True, |
|
1257 | 1257 | ) |
|
1258 | 1258 | coreconfigitem( |
|
1259 | 1259 | b'extdata', |
|
1260 | 1260 | b'.*', |
|
1261 | 1261 | default=None, |
|
1262 | 1262 | generic=True, |
|
1263 | 1263 | ) |
|
1264 | 1264 | coreconfigitem( |
|
1265 | 1265 | b'format', |
|
1266 | 1266 | b'bookmarks-in-store', |
|
1267 | 1267 | default=False, |
|
1268 | 1268 | ) |
|
1269 | 1269 | coreconfigitem( |
|
1270 | 1270 | b'format', |
|
1271 | 1271 | b'chunkcachesize', |
|
1272 | 1272 | default=None, |
|
1273 | 1273 | experimental=True, |
|
1274 | 1274 | ) |
|
1275 | 1275 | coreconfigitem( |
|
1276 | 1276 | # Enable this dirstate format *when creating a new repository*. |
|
1277 | 1277 | # Which format to use for existing repos is controlled by .hg/requires |
|
1278 | 1278 | b'format', |
|
1279 | 1279 | b'use-dirstate-v2', |
|
1280 | 1280 | default=False, |
|
1281 | 1281 | experimental=True, |
|
1282 | 1282 | alias=[(b'format', b'exp-rc-dirstate-v2')], |
|
1283 | 1283 | ) |
|
1284 | 1284 | coreconfigitem( |
|
1285 | 1285 | b'format', |
|
1286 | 1286 | b'use-dirstate-v2.automatic-upgrade-of-mismatching-repositories', |
|
1287 | 1287 | default=False, |
|
1288 | 1288 | experimental=True, |
|
1289 | 1289 | ) |
|
1290 | 1290 | coreconfigitem( |
|
1291 | 1291 | b'format', |
|
1292 | 1292 | b'use-dirstate-v2.automatic-upgrade-of-mismatching-repositories:quiet', |
|
1293 | 1293 | default=False, |
|
1294 | 1294 | experimental=True, |
|
1295 | 1295 | ) |
|
1296 | 1296 | coreconfigitem( |
|
1297 | 1297 | b'format', |
|
1298 | 1298 | b'use-dirstate-tracked-hint', |
|
1299 | 1299 | default=False, |
|
1300 | 1300 | experimental=True, |
|
1301 | 1301 | ) |
|
1302 | 1302 | coreconfigitem( |
|
1303 | 1303 | b'format', |
|
1304 | 1304 | b'use-dirstate-tracked-hint.version', |
|
1305 | 1305 | default=1, |
|
1306 | 1306 | experimental=True, |
|
1307 | 1307 | ) |
|
1308 | 1308 | coreconfigitem( |
|
1309 | 1309 | b'format', |
|
1310 | 1310 | b'use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories', |
|
1311 | 1311 | default=False, |
|
1312 | 1312 | experimental=True, |
|
1313 | 1313 | ) |
|
1314 | 1314 | coreconfigitem( |
|
1315 | 1315 | b'format', |
|
1316 | 1316 | b'use-dirstate-tracked-hint.automatic-upgrade-of-mismatching-repositories:quiet', |
|
1317 | 1317 | default=False, |
|
1318 | 1318 | experimental=True, |
|
1319 | 1319 | ) |
|
1320 | 1320 | coreconfigitem( |
|
1321 | 1321 | b'format', |
|
1322 | 1322 | b'dotencode', |
|
1323 | 1323 | default=True, |
|
1324 | 1324 | ) |
|
1325 | 1325 | coreconfigitem( |
|
1326 | 1326 | b'format', |
|
1327 | 1327 | b'generaldelta', |
|
1328 | 1328 | default=False, |
|
1329 | 1329 | experimental=True, |
|
1330 | 1330 | ) |
|
1331 | 1331 | coreconfigitem( |
|
1332 | 1332 | b'format', |
|
1333 | 1333 | b'manifestcachesize', |
|
1334 | 1334 | default=None, |
|
1335 | 1335 | experimental=True, |
|
1336 | 1336 | ) |
|
1337 | 1337 | coreconfigitem( |
|
1338 | 1338 | b'format', |
|
1339 | 1339 | b'maxchainlen', |
|
1340 | 1340 | default=dynamicdefault, |
|
1341 | 1341 | experimental=True, |
|
1342 | 1342 | ) |
|
1343 | 1343 | coreconfigitem( |
|
1344 | 1344 | b'format', |
|
1345 | 1345 | b'obsstore-version', |
|
1346 | 1346 | default=None, |
|
1347 | 1347 | ) |
|
1348 | 1348 | coreconfigitem( |
|
1349 | 1349 | b'format', |
|
1350 | 1350 | b'sparse-revlog', |
|
1351 | 1351 | default=True, |
|
1352 | 1352 | ) |
|
1353 | 1353 | coreconfigitem( |
|
1354 | 1354 | b'format', |
|
1355 | 1355 | b'revlog-compression', |
|
1356 | 1356 | default=lambda: [b'zstd', b'zlib'], |
|
1357 | 1357 | alias=[(b'experimental', b'format.compression')], |
|
1358 | 1358 | ) |
|
1359 | 1359 | # Experimental TODOs: |
|
1360 | 1360 | # |
|
1361 | 1361 | # * Same as for revlogv2 (but for the reduction of the number of files) |
|
1362 | 1362 | # * Actually computing the rank of changesets |
|
1363 | 1363 | # * Improvement to investigate |
|
1364 | 1364 | # - storing .hgtags fnode |
|
1365 | 1365 | # - storing branch related identifier |
|
1366 | 1366 | |
|
1367 | 1367 | coreconfigitem( |
|
1368 | 1368 | b'format', |
|
1369 | 1369 | b'exp-use-changelog-v2', |
|
1370 | 1370 | default=None, |
|
1371 | 1371 | experimental=True, |
|
1372 | 1372 | ) |
|
1373 | 1373 | coreconfigitem( |
|
1374 | 1374 | b'format', |
|
1375 | 1375 | b'usefncache', |
|
1376 | 1376 | default=True, |
|
1377 | 1377 | ) |
|
1378 | 1378 | coreconfigitem( |
|
1379 | 1379 | b'format', |
|
1380 | 1380 | b'usegeneraldelta', |
|
1381 | 1381 | default=True, |
|
1382 | 1382 | ) |
|
1383 | 1383 | coreconfigitem( |
|
1384 | 1384 | b'format', |
|
1385 | 1385 | b'usestore', |
|
1386 | 1386 | default=True, |
|
1387 | 1387 | ) |
|
1388 | 1388 | |
|
1389 | 1389 | |
|
1390 | 1390 | def _persistent_nodemap_default(): |
|
1391 | 1391 | """compute `use-persistent-nodemap` default value |
|
1392 | 1392 | |
|
1393 | 1393 | The feature is disabled unless a fast implementation is available. |
|
1394 | 1394 | """ |
|
1395 | 1395 | from . import policy |
|
1396 | 1396 | |
|
1397 | 1397 | return policy.importrust('revlog') is not None |
|
1398 | 1398 | |
|
1399 | 1399 | |
|
1400 | 1400 | coreconfigitem( |
|
1401 | 1401 | b'format', |
|
1402 | 1402 | b'use-persistent-nodemap', |
|
1403 | 1403 | default=_persistent_nodemap_default, |
|
1404 | 1404 | ) |
|
1405 | 1405 | coreconfigitem( |
|
1406 | 1406 | b'format', |
|
1407 | 1407 | b'exp-use-copies-side-data-changeset', |
|
1408 | 1408 | default=False, |
|
1409 | 1409 | experimental=True, |
|
1410 | 1410 | ) |
|
1411 | 1411 | coreconfigitem( |
|
1412 | 1412 | b'format', |
|
1413 | 1413 | b'use-share-safe', |
|
1414 | 1414 | default=True, |
|
1415 | 1415 | ) |
|
1416 | 1416 | coreconfigitem( |
|
1417 | 1417 | b'format', |
|
1418 | 1418 | b'use-share-safe.automatic-upgrade-of-mismatching-repositories', |
|
1419 | 1419 | default=False, |
|
1420 | 1420 | experimental=True, |
|
1421 | 1421 | ) |
|
1422 | 1422 | coreconfigitem( |
|
1423 | 1423 | b'format', |
|
1424 | 1424 | b'use-share-safe.automatic-upgrade-of-mismatching-repositories:quiet', |
|
1425 | 1425 | default=False, |
|
1426 | 1426 | experimental=True, |
|
1427 | 1427 | ) |
|
1428 | 1428 | coreconfigitem( |
|
1429 | 1429 | b'format', |
|
1430 | 1430 | b'internal-phase', |
|
1431 | 1431 | default=False, |
|
1432 | 1432 | experimental=True, |
|
1433 | 1433 | ) |
|
1434 | # The interaction between the archived phase and obsolescence markers needs to | |
|
1435 | # be sorted out before wider usage of this are to be considered. | |
|
1436 | # | |
|
1437 | # At the time this message is written, behavior when archiving obsolete | |
|
1438 | # changeset differ significantly from stripping. As part of stripping, we also | |
|
1439 | # remove the obsolescence marker associated to the stripped changesets, | |
|
1440 | # revealing the precedecessors changesets when applicable. When archiving, we | |
|
1441 | # don't touch the obsolescence markers, keeping everything hidden. This can | |
|
1442 | # result in quite confusing situation for people combining exchanging draft | |
|
1443 | # with the archived phases. As some markers needed by others may be skipped | |
|
1444 | # during exchange. | |
|
1445 | coreconfigitem( | |
|
1446 | b'format', | |
|
1447 | b'exp-archived-phase', | |
|
1448 | default=False, | |
|
1449 | experimental=True, | |
|
1450 | ) | |
|
1434 | 1451 | coreconfigitem( |
|
1435 | 1452 | b'shelve', |
|
1436 | 1453 | b'store', |
|
1437 | 1454 | default='internal', |
|
1438 | 1455 | experimental=True, |
|
1439 | 1456 | ) |
|
1440 | 1457 | coreconfigitem( |
|
1441 | 1458 | b'fsmonitor', |
|
1442 | 1459 | b'warn_when_unused', |
|
1443 | 1460 | default=True, |
|
1444 | 1461 | ) |
|
1445 | 1462 | coreconfigitem( |
|
1446 | 1463 | b'fsmonitor', |
|
1447 | 1464 | b'warn_update_file_count', |
|
1448 | 1465 | default=50000, |
|
1449 | 1466 | ) |
|
1450 | 1467 | coreconfigitem( |
|
1451 | 1468 | b'fsmonitor', |
|
1452 | 1469 | b'warn_update_file_count_rust', |
|
1453 | 1470 | default=400000, |
|
1454 | 1471 | ) |
|
1455 | 1472 | coreconfigitem( |
|
1456 | 1473 | b'help', |
|
1457 | 1474 | br'hidden-command\..*', |
|
1458 | 1475 | default=False, |
|
1459 | 1476 | generic=True, |
|
1460 | 1477 | ) |
|
1461 | 1478 | coreconfigitem( |
|
1462 | 1479 | b'help', |
|
1463 | 1480 | br'hidden-topic\..*', |
|
1464 | 1481 | default=False, |
|
1465 | 1482 | generic=True, |
|
1466 | 1483 | ) |
|
1467 | 1484 | coreconfigitem( |
|
1468 | 1485 | b'hooks', |
|
1469 | 1486 | b'[^:]*', |
|
1470 | 1487 | default=dynamicdefault, |
|
1471 | 1488 | generic=True, |
|
1472 | 1489 | ) |
|
1473 | 1490 | coreconfigitem( |
|
1474 | 1491 | b'hooks', |
|
1475 | 1492 | b'.*:run-with-plain', |
|
1476 | 1493 | default=True, |
|
1477 | 1494 | generic=True, |
|
1478 | 1495 | ) |
|
1479 | 1496 | coreconfigitem( |
|
1480 | 1497 | b'hgweb-paths', |
|
1481 | 1498 | b'.*', |
|
1482 | 1499 | default=list, |
|
1483 | 1500 | generic=True, |
|
1484 | 1501 | ) |
|
1485 | 1502 | coreconfigitem( |
|
1486 | 1503 | b'hostfingerprints', |
|
1487 | 1504 | b'.*', |
|
1488 | 1505 | default=list, |
|
1489 | 1506 | generic=True, |
|
1490 | 1507 | ) |
|
1491 | 1508 | coreconfigitem( |
|
1492 | 1509 | b'hostsecurity', |
|
1493 | 1510 | b'ciphers', |
|
1494 | 1511 | default=None, |
|
1495 | 1512 | ) |
|
1496 | 1513 | coreconfigitem( |
|
1497 | 1514 | b'hostsecurity', |
|
1498 | 1515 | b'minimumprotocol', |
|
1499 | 1516 | default=dynamicdefault, |
|
1500 | 1517 | ) |
|
1501 | 1518 | coreconfigitem( |
|
1502 | 1519 | b'hostsecurity', |
|
1503 | 1520 | b'.*:minimumprotocol$', |
|
1504 | 1521 | default=dynamicdefault, |
|
1505 | 1522 | generic=True, |
|
1506 | 1523 | ) |
|
1507 | 1524 | coreconfigitem( |
|
1508 | 1525 | b'hostsecurity', |
|
1509 | 1526 | b'.*:ciphers$', |
|
1510 | 1527 | default=dynamicdefault, |
|
1511 | 1528 | generic=True, |
|
1512 | 1529 | ) |
|
1513 | 1530 | coreconfigitem( |
|
1514 | 1531 | b'hostsecurity', |
|
1515 | 1532 | b'.*:fingerprints$', |
|
1516 | 1533 | default=list, |
|
1517 | 1534 | generic=True, |
|
1518 | 1535 | ) |
|
1519 | 1536 | coreconfigitem( |
|
1520 | 1537 | b'hostsecurity', |
|
1521 | 1538 | b'.*:verifycertsfile$', |
|
1522 | 1539 | default=None, |
|
1523 | 1540 | generic=True, |
|
1524 | 1541 | ) |
|
1525 | 1542 | |
|
1526 | 1543 | coreconfigitem( |
|
1527 | 1544 | b'http_proxy', |
|
1528 | 1545 | b'always', |
|
1529 | 1546 | default=False, |
|
1530 | 1547 | ) |
|
1531 | 1548 | coreconfigitem( |
|
1532 | 1549 | b'http_proxy', |
|
1533 | 1550 | b'host', |
|
1534 | 1551 | default=None, |
|
1535 | 1552 | ) |
|
1536 | 1553 | coreconfigitem( |
|
1537 | 1554 | b'http_proxy', |
|
1538 | 1555 | b'no', |
|
1539 | 1556 | default=list, |
|
1540 | 1557 | ) |
|
1541 | 1558 | coreconfigitem( |
|
1542 | 1559 | b'http_proxy', |
|
1543 | 1560 | b'passwd', |
|
1544 | 1561 | default=None, |
|
1545 | 1562 | ) |
|
1546 | 1563 | coreconfigitem( |
|
1547 | 1564 | b'http_proxy', |
|
1548 | 1565 | b'user', |
|
1549 | 1566 | default=None, |
|
1550 | 1567 | ) |
|
1551 | 1568 | |
|
1552 | 1569 | coreconfigitem( |
|
1553 | 1570 | b'http', |
|
1554 | 1571 | b'timeout', |
|
1555 | 1572 | default=None, |
|
1556 | 1573 | ) |
|
1557 | 1574 | |
|
1558 | 1575 | coreconfigitem( |
|
1559 | 1576 | b'logtoprocess', |
|
1560 | 1577 | b'commandexception', |
|
1561 | 1578 | default=None, |
|
1562 | 1579 | ) |
|
1563 | 1580 | coreconfigitem( |
|
1564 | 1581 | b'logtoprocess', |
|
1565 | 1582 | b'commandfinish', |
|
1566 | 1583 | default=None, |
|
1567 | 1584 | ) |
|
1568 | 1585 | coreconfigitem( |
|
1569 | 1586 | b'logtoprocess', |
|
1570 | 1587 | b'command', |
|
1571 | 1588 | default=None, |
|
1572 | 1589 | ) |
|
1573 | 1590 | coreconfigitem( |
|
1574 | 1591 | b'logtoprocess', |
|
1575 | 1592 | b'develwarn', |
|
1576 | 1593 | default=None, |
|
1577 | 1594 | ) |
|
1578 | 1595 | coreconfigitem( |
|
1579 | 1596 | b'logtoprocess', |
|
1580 | 1597 | b'uiblocked', |
|
1581 | 1598 | default=None, |
|
1582 | 1599 | ) |
|
1583 | 1600 | coreconfigitem( |
|
1584 | 1601 | b'merge', |
|
1585 | 1602 | b'checkunknown', |
|
1586 | 1603 | default=b'abort', |
|
1587 | 1604 | ) |
|
1588 | 1605 | coreconfigitem( |
|
1589 | 1606 | b'merge', |
|
1590 | 1607 | b'checkignored', |
|
1591 | 1608 | default=b'abort', |
|
1592 | 1609 | ) |
|
1593 | 1610 | coreconfigitem( |
|
1594 | 1611 | b'experimental', |
|
1595 | 1612 | b'merge.checkpathconflicts', |
|
1596 | 1613 | default=False, |
|
1597 | 1614 | ) |
|
1598 | 1615 | coreconfigitem( |
|
1599 | 1616 | b'merge', |
|
1600 | 1617 | b'followcopies', |
|
1601 | 1618 | default=True, |
|
1602 | 1619 | ) |
|
1603 | 1620 | coreconfigitem( |
|
1604 | 1621 | b'merge', |
|
1605 | 1622 | b'on-failure', |
|
1606 | 1623 | default=b'continue', |
|
1607 | 1624 | ) |
|
1608 | 1625 | coreconfigitem( |
|
1609 | 1626 | b'merge', |
|
1610 | 1627 | b'preferancestor', |
|
1611 | 1628 | default=lambda: [b'*'], |
|
1612 | 1629 | experimental=True, |
|
1613 | 1630 | ) |
|
1614 | 1631 | coreconfigitem( |
|
1615 | 1632 | b'merge', |
|
1616 | 1633 | b'strict-capability-check', |
|
1617 | 1634 | default=False, |
|
1618 | 1635 | ) |
|
1619 | 1636 | coreconfigitem( |
|
1620 | 1637 | b'merge', |
|
1621 | 1638 | b'disable-partial-tools', |
|
1622 | 1639 | default=False, |
|
1623 | 1640 | experimental=True, |
|
1624 | 1641 | ) |
|
1625 | 1642 | coreconfigitem( |
|
1626 | 1643 | b'partial-merge-tools', |
|
1627 | 1644 | b'.*', |
|
1628 | 1645 | default=None, |
|
1629 | 1646 | generic=True, |
|
1630 | 1647 | experimental=True, |
|
1631 | 1648 | ) |
|
1632 | 1649 | coreconfigitem( |
|
1633 | 1650 | b'partial-merge-tools', |
|
1634 | 1651 | br'.*\.patterns', |
|
1635 | 1652 | default=dynamicdefault, |
|
1636 | 1653 | generic=True, |
|
1637 | 1654 | priority=-1, |
|
1638 | 1655 | experimental=True, |
|
1639 | 1656 | ) |
|
1640 | 1657 | coreconfigitem( |
|
1641 | 1658 | b'partial-merge-tools', |
|
1642 | 1659 | br'.*\.executable$', |
|
1643 | 1660 | default=dynamicdefault, |
|
1644 | 1661 | generic=True, |
|
1645 | 1662 | priority=-1, |
|
1646 | 1663 | experimental=True, |
|
1647 | 1664 | ) |
|
1648 | 1665 | coreconfigitem( |
|
1649 | 1666 | b'partial-merge-tools', |
|
1650 | 1667 | br'.*\.order', |
|
1651 | 1668 | default=0, |
|
1652 | 1669 | generic=True, |
|
1653 | 1670 | priority=-1, |
|
1654 | 1671 | experimental=True, |
|
1655 | 1672 | ) |
|
1656 | 1673 | coreconfigitem( |
|
1657 | 1674 | b'partial-merge-tools', |
|
1658 | 1675 | br'.*\.args', |
|
1659 | 1676 | default=b"$local $base $other", |
|
1660 | 1677 | generic=True, |
|
1661 | 1678 | priority=-1, |
|
1662 | 1679 | experimental=True, |
|
1663 | 1680 | ) |
|
1664 | 1681 | coreconfigitem( |
|
1665 | 1682 | b'partial-merge-tools', |
|
1666 | 1683 | br'.*\.disable', |
|
1667 | 1684 | default=False, |
|
1668 | 1685 | generic=True, |
|
1669 | 1686 | priority=-1, |
|
1670 | 1687 | experimental=True, |
|
1671 | 1688 | ) |
|
1672 | 1689 | coreconfigitem( |
|
1673 | 1690 | b'merge-tools', |
|
1674 | 1691 | b'.*', |
|
1675 | 1692 | default=None, |
|
1676 | 1693 | generic=True, |
|
1677 | 1694 | ) |
|
1678 | 1695 | coreconfigitem( |
|
1679 | 1696 | b'merge-tools', |
|
1680 | 1697 | br'.*\.args$', |
|
1681 | 1698 | default=b"$local $base $other", |
|
1682 | 1699 | generic=True, |
|
1683 | 1700 | priority=-1, |
|
1684 | 1701 | ) |
|
1685 | 1702 | coreconfigitem( |
|
1686 | 1703 | b'merge-tools', |
|
1687 | 1704 | br'.*\.binary$', |
|
1688 | 1705 | default=False, |
|
1689 | 1706 | generic=True, |
|
1690 | 1707 | priority=-1, |
|
1691 | 1708 | ) |
|
1692 | 1709 | coreconfigitem( |
|
1693 | 1710 | b'merge-tools', |
|
1694 | 1711 | br'.*\.check$', |
|
1695 | 1712 | default=list, |
|
1696 | 1713 | generic=True, |
|
1697 | 1714 | priority=-1, |
|
1698 | 1715 | ) |
|
1699 | 1716 | coreconfigitem( |
|
1700 | 1717 | b'merge-tools', |
|
1701 | 1718 | br'.*\.checkchanged$', |
|
1702 | 1719 | default=False, |
|
1703 | 1720 | generic=True, |
|
1704 | 1721 | priority=-1, |
|
1705 | 1722 | ) |
|
1706 | 1723 | coreconfigitem( |
|
1707 | 1724 | b'merge-tools', |
|
1708 | 1725 | br'.*\.executable$', |
|
1709 | 1726 | default=dynamicdefault, |
|
1710 | 1727 | generic=True, |
|
1711 | 1728 | priority=-1, |
|
1712 | 1729 | ) |
|
1713 | 1730 | coreconfigitem( |
|
1714 | 1731 | b'merge-tools', |
|
1715 | 1732 | br'.*\.fixeol$', |
|
1716 | 1733 | default=False, |
|
1717 | 1734 | generic=True, |
|
1718 | 1735 | priority=-1, |
|
1719 | 1736 | ) |
|
1720 | 1737 | coreconfigitem( |
|
1721 | 1738 | b'merge-tools', |
|
1722 | 1739 | br'.*\.gui$', |
|
1723 | 1740 | default=False, |
|
1724 | 1741 | generic=True, |
|
1725 | 1742 | priority=-1, |
|
1726 | 1743 | ) |
|
1727 | 1744 | coreconfigitem( |
|
1728 | 1745 | b'merge-tools', |
|
1729 | 1746 | br'.*\.mergemarkers$', |
|
1730 | 1747 | default=b'basic', |
|
1731 | 1748 | generic=True, |
|
1732 | 1749 | priority=-1, |
|
1733 | 1750 | ) |
|
1734 | 1751 | coreconfigitem( |
|
1735 | 1752 | b'merge-tools', |
|
1736 | 1753 | br'.*\.mergemarkertemplate$', |
|
1737 | 1754 | default=dynamicdefault, # take from command-templates.mergemarker |
|
1738 | 1755 | generic=True, |
|
1739 | 1756 | priority=-1, |
|
1740 | 1757 | ) |
|
1741 | 1758 | coreconfigitem( |
|
1742 | 1759 | b'merge-tools', |
|
1743 | 1760 | br'.*\.priority$', |
|
1744 | 1761 | default=0, |
|
1745 | 1762 | generic=True, |
|
1746 | 1763 | priority=-1, |
|
1747 | 1764 | ) |
|
1748 | 1765 | coreconfigitem( |
|
1749 | 1766 | b'merge-tools', |
|
1750 | 1767 | br'.*\.premerge$', |
|
1751 | 1768 | default=dynamicdefault, |
|
1752 | 1769 | generic=True, |
|
1753 | 1770 | priority=-1, |
|
1754 | 1771 | ) |
|
1755 | 1772 | coreconfigitem( |
|
1756 | 1773 | b'merge-tools', |
|
1757 | 1774 | br'.*\.symlink$', |
|
1758 | 1775 | default=False, |
|
1759 | 1776 | generic=True, |
|
1760 | 1777 | priority=-1, |
|
1761 | 1778 | ) |
|
1762 | 1779 | coreconfigitem( |
|
1763 | 1780 | b'pager', |
|
1764 | 1781 | b'attend-.*', |
|
1765 | 1782 | default=dynamicdefault, |
|
1766 | 1783 | generic=True, |
|
1767 | 1784 | ) |
|
1768 | 1785 | coreconfigitem( |
|
1769 | 1786 | b'pager', |
|
1770 | 1787 | b'ignore', |
|
1771 | 1788 | default=list, |
|
1772 | 1789 | ) |
|
1773 | 1790 | coreconfigitem( |
|
1774 | 1791 | b'pager', |
|
1775 | 1792 | b'pager', |
|
1776 | 1793 | default=dynamicdefault, |
|
1777 | 1794 | ) |
|
1778 | 1795 | coreconfigitem( |
|
1779 | 1796 | b'patch', |
|
1780 | 1797 | b'eol', |
|
1781 | 1798 | default=b'strict', |
|
1782 | 1799 | ) |
|
1783 | 1800 | coreconfigitem( |
|
1784 | 1801 | b'patch', |
|
1785 | 1802 | b'fuzz', |
|
1786 | 1803 | default=2, |
|
1787 | 1804 | ) |
|
1788 | 1805 | coreconfigitem( |
|
1789 | 1806 | b'paths', |
|
1790 | 1807 | b'default', |
|
1791 | 1808 | default=None, |
|
1792 | 1809 | ) |
|
1793 | 1810 | coreconfigitem( |
|
1794 | 1811 | b'paths', |
|
1795 | 1812 | b'default-push', |
|
1796 | 1813 | default=None, |
|
1797 | 1814 | ) |
|
1798 | 1815 | coreconfigitem( |
|
1799 | 1816 | b'paths', |
|
1800 | 1817 | b'.*', |
|
1801 | 1818 | default=None, |
|
1802 | 1819 | generic=True, |
|
1803 | 1820 | ) |
|
1804 | 1821 | coreconfigitem( |
|
1805 | 1822 | b'paths', |
|
1806 | 1823 | b'.*:bookmarks.mode', |
|
1807 | 1824 | default='default', |
|
1808 | 1825 | generic=True, |
|
1809 | 1826 | ) |
|
1810 | 1827 | coreconfigitem( |
|
1811 | 1828 | b'paths', |
|
1812 | 1829 | b'.*:multi-urls', |
|
1813 | 1830 | default=False, |
|
1814 | 1831 | generic=True, |
|
1815 | 1832 | ) |
|
1816 | 1833 | coreconfigitem( |
|
1817 | 1834 | b'paths', |
|
1818 | 1835 | b'.*:pushrev', |
|
1819 | 1836 | default=None, |
|
1820 | 1837 | generic=True, |
|
1821 | 1838 | ) |
|
1822 | 1839 | coreconfigitem( |
|
1823 | 1840 | b'paths', |
|
1824 | 1841 | b'.*:pushurl', |
|
1825 | 1842 | default=None, |
|
1826 | 1843 | generic=True, |
|
1827 | 1844 | ) |
|
1828 | 1845 | coreconfigitem( |
|
1829 | 1846 | b'phases', |
|
1830 | 1847 | b'checksubrepos', |
|
1831 | 1848 | default=b'follow', |
|
1832 | 1849 | ) |
|
1833 | 1850 | coreconfigitem( |
|
1834 | 1851 | b'phases', |
|
1835 | 1852 | b'new-commit', |
|
1836 | 1853 | default=b'draft', |
|
1837 | 1854 | ) |
|
1838 | 1855 | coreconfigitem( |
|
1839 | 1856 | b'phases', |
|
1840 | 1857 | b'publish', |
|
1841 | 1858 | default=True, |
|
1842 | 1859 | ) |
|
1843 | 1860 | coreconfigitem( |
|
1844 | 1861 | b'profiling', |
|
1845 | 1862 | b'enabled', |
|
1846 | 1863 | default=False, |
|
1847 | 1864 | ) |
|
1848 | 1865 | coreconfigitem( |
|
1849 | 1866 | b'profiling', |
|
1850 | 1867 | b'format', |
|
1851 | 1868 | default=b'text', |
|
1852 | 1869 | ) |
|
1853 | 1870 | coreconfigitem( |
|
1854 | 1871 | b'profiling', |
|
1855 | 1872 | b'freq', |
|
1856 | 1873 | default=1000, |
|
1857 | 1874 | ) |
|
1858 | 1875 | coreconfigitem( |
|
1859 | 1876 | b'profiling', |
|
1860 | 1877 | b'limit', |
|
1861 | 1878 | default=30, |
|
1862 | 1879 | ) |
|
1863 | 1880 | coreconfigitem( |
|
1864 | 1881 | b'profiling', |
|
1865 | 1882 | b'nested', |
|
1866 | 1883 | default=0, |
|
1867 | 1884 | ) |
|
1868 | 1885 | coreconfigitem( |
|
1869 | 1886 | b'profiling', |
|
1870 | 1887 | b'output', |
|
1871 | 1888 | default=None, |
|
1872 | 1889 | ) |
|
1873 | 1890 | coreconfigitem( |
|
1874 | 1891 | b'profiling', |
|
1875 | 1892 | b'showmax', |
|
1876 | 1893 | default=0.999, |
|
1877 | 1894 | ) |
|
1878 | 1895 | coreconfigitem( |
|
1879 | 1896 | b'profiling', |
|
1880 | 1897 | b'showmin', |
|
1881 | 1898 | default=dynamicdefault, |
|
1882 | 1899 | ) |
|
1883 | 1900 | coreconfigitem( |
|
1884 | 1901 | b'profiling', |
|
1885 | 1902 | b'showtime', |
|
1886 | 1903 | default=True, |
|
1887 | 1904 | ) |
|
1888 | 1905 | coreconfigitem( |
|
1889 | 1906 | b'profiling', |
|
1890 | 1907 | b'sort', |
|
1891 | 1908 | default=b'inlinetime', |
|
1892 | 1909 | ) |
|
1893 | 1910 | coreconfigitem( |
|
1894 | 1911 | b'profiling', |
|
1895 | 1912 | b'statformat', |
|
1896 | 1913 | default=b'hotpath', |
|
1897 | 1914 | ) |
|
1898 | 1915 | coreconfigitem( |
|
1899 | 1916 | b'profiling', |
|
1900 | 1917 | b'time-track', |
|
1901 | 1918 | default=dynamicdefault, |
|
1902 | 1919 | ) |
|
1903 | 1920 | coreconfigitem( |
|
1904 | 1921 | b'profiling', |
|
1905 | 1922 | b'type', |
|
1906 | 1923 | default=b'stat', |
|
1907 | 1924 | ) |
|
1908 | 1925 | coreconfigitem( |
|
1909 | 1926 | b'progress', |
|
1910 | 1927 | b'assume-tty', |
|
1911 | 1928 | default=False, |
|
1912 | 1929 | ) |
|
1913 | 1930 | coreconfigitem( |
|
1914 | 1931 | b'progress', |
|
1915 | 1932 | b'changedelay', |
|
1916 | 1933 | default=1, |
|
1917 | 1934 | ) |
|
1918 | 1935 | coreconfigitem( |
|
1919 | 1936 | b'progress', |
|
1920 | 1937 | b'clear-complete', |
|
1921 | 1938 | default=True, |
|
1922 | 1939 | ) |
|
1923 | 1940 | coreconfigitem( |
|
1924 | 1941 | b'progress', |
|
1925 | 1942 | b'debug', |
|
1926 | 1943 | default=False, |
|
1927 | 1944 | ) |
|
1928 | 1945 | coreconfigitem( |
|
1929 | 1946 | b'progress', |
|
1930 | 1947 | b'delay', |
|
1931 | 1948 | default=3, |
|
1932 | 1949 | ) |
|
1933 | 1950 | coreconfigitem( |
|
1934 | 1951 | b'progress', |
|
1935 | 1952 | b'disable', |
|
1936 | 1953 | default=False, |
|
1937 | 1954 | ) |
|
1938 | 1955 | coreconfigitem( |
|
1939 | 1956 | b'progress', |
|
1940 | 1957 | b'estimateinterval', |
|
1941 | 1958 | default=60.0, |
|
1942 | 1959 | ) |
|
1943 | 1960 | coreconfigitem( |
|
1944 | 1961 | b'progress', |
|
1945 | 1962 | b'format', |
|
1946 | 1963 | default=lambda: [b'topic', b'bar', b'number', b'estimate'], |
|
1947 | 1964 | ) |
|
1948 | 1965 | coreconfigitem( |
|
1949 | 1966 | b'progress', |
|
1950 | 1967 | b'refresh', |
|
1951 | 1968 | default=0.1, |
|
1952 | 1969 | ) |
|
1953 | 1970 | coreconfigitem( |
|
1954 | 1971 | b'progress', |
|
1955 | 1972 | b'width', |
|
1956 | 1973 | default=dynamicdefault, |
|
1957 | 1974 | ) |
|
1958 | 1975 | coreconfigitem( |
|
1959 | 1976 | b'pull', |
|
1960 | 1977 | b'confirm', |
|
1961 | 1978 | default=False, |
|
1962 | 1979 | ) |
|
1963 | 1980 | coreconfigitem( |
|
1964 | 1981 | b'push', |
|
1965 | 1982 | b'pushvars.server', |
|
1966 | 1983 | default=False, |
|
1967 | 1984 | ) |
|
1968 | 1985 | coreconfigitem( |
|
1969 | 1986 | b'rewrite', |
|
1970 | 1987 | b'backup-bundle', |
|
1971 | 1988 | default=True, |
|
1972 | 1989 | alias=[(b'ui', b'history-editing-backup')], |
|
1973 | 1990 | ) |
|
1974 | 1991 | coreconfigitem( |
|
1975 | 1992 | b'rewrite', |
|
1976 | 1993 | b'update-timestamp', |
|
1977 | 1994 | default=False, |
|
1978 | 1995 | ) |
|
1979 | 1996 | coreconfigitem( |
|
1980 | 1997 | b'rewrite', |
|
1981 | 1998 | b'empty-successor', |
|
1982 | 1999 | default=b'skip', |
|
1983 | 2000 | experimental=True, |
|
1984 | 2001 | ) |
|
1985 | 2002 | # experimental as long as format.use-dirstate-v2 is. |
|
1986 | 2003 | coreconfigitem( |
|
1987 | 2004 | b'storage', |
|
1988 | 2005 | b'dirstate-v2.slow-path', |
|
1989 | 2006 | default=b"abort", |
|
1990 | 2007 | experimental=True, |
|
1991 | 2008 | ) |
|
1992 | 2009 | coreconfigitem( |
|
1993 | 2010 | b'storage', |
|
1994 | 2011 | b'new-repo-backend', |
|
1995 | 2012 | default=b'revlogv1', |
|
1996 | 2013 | experimental=True, |
|
1997 | 2014 | ) |
|
1998 | 2015 | coreconfigitem( |
|
1999 | 2016 | b'storage', |
|
2000 | 2017 | b'revlog.optimize-delta-parent-choice', |
|
2001 | 2018 | default=True, |
|
2002 | 2019 | alias=[(b'format', b'aggressivemergedeltas')], |
|
2003 | 2020 | ) |
|
2004 | 2021 | coreconfigitem( |
|
2005 | 2022 | b'storage', |
|
2006 | 2023 | b'revlog.issue6528.fix-incoming', |
|
2007 | 2024 | default=True, |
|
2008 | 2025 | ) |
|
2009 | 2026 | # experimental as long as rust is experimental (or a C version is implemented) |
|
2010 | 2027 | coreconfigitem( |
|
2011 | 2028 | b'storage', |
|
2012 | 2029 | b'revlog.persistent-nodemap.mmap', |
|
2013 | 2030 | default=True, |
|
2014 | 2031 | ) |
|
2015 | 2032 | # experimental as long as format.use-persistent-nodemap is. |
|
2016 | 2033 | coreconfigitem( |
|
2017 | 2034 | b'storage', |
|
2018 | 2035 | b'revlog.persistent-nodemap.slow-path', |
|
2019 | 2036 | default=b"abort", |
|
2020 | 2037 | ) |
|
2021 | 2038 | |
|
2022 | 2039 | coreconfigitem( |
|
2023 | 2040 | b'storage', |
|
2024 | 2041 | b'revlog.reuse-external-delta', |
|
2025 | 2042 | default=True, |
|
2026 | 2043 | ) |
|
2027 | 2044 | coreconfigitem( |
|
2028 | 2045 | b'storage', |
|
2029 | 2046 | b'revlog.reuse-external-delta-parent', |
|
2030 | 2047 | default=None, |
|
2031 | 2048 | ) |
|
2032 | 2049 | coreconfigitem( |
|
2033 | 2050 | b'storage', |
|
2034 | 2051 | b'revlog.zlib.level', |
|
2035 | 2052 | default=None, |
|
2036 | 2053 | ) |
|
2037 | 2054 | coreconfigitem( |
|
2038 | 2055 | b'storage', |
|
2039 | 2056 | b'revlog.zstd.level', |
|
2040 | 2057 | default=None, |
|
2041 | 2058 | ) |
|
2042 | 2059 | coreconfigitem( |
|
2043 | 2060 | b'server', |
|
2044 | 2061 | b'bookmarks-pushkey-compat', |
|
2045 | 2062 | default=True, |
|
2046 | 2063 | ) |
|
2047 | 2064 | coreconfigitem( |
|
2048 | 2065 | b'server', |
|
2049 | 2066 | b'bundle1', |
|
2050 | 2067 | default=True, |
|
2051 | 2068 | ) |
|
2052 | 2069 | coreconfigitem( |
|
2053 | 2070 | b'server', |
|
2054 | 2071 | b'bundle1gd', |
|
2055 | 2072 | default=None, |
|
2056 | 2073 | ) |
|
2057 | 2074 | coreconfigitem( |
|
2058 | 2075 | b'server', |
|
2059 | 2076 | b'bundle1.pull', |
|
2060 | 2077 | default=None, |
|
2061 | 2078 | ) |
|
2062 | 2079 | coreconfigitem( |
|
2063 | 2080 | b'server', |
|
2064 | 2081 | b'bundle1gd.pull', |
|
2065 | 2082 | default=None, |
|
2066 | 2083 | ) |
|
2067 | 2084 | coreconfigitem( |
|
2068 | 2085 | b'server', |
|
2069 | 2086 | b'bundle1.push', |
|
2070 | 2087 | default=None, |
|
2071 | 2088 | ) |
|
2072 | 2089 | coreconfigitem( |
|
2073 | 2090 | b'server', |
|
2074 | 2091 | b'bundle1gd.push', |
|
2075 | 2092 | default=None, |
|
2076 | 2093 | ) |
|
2077 | 2094 | coreconfigitem( |
|
2078 | 2095 | b'server', |
|
2079 | 2096 | b'bundle2.stream', |
|
2080 | 2097 | default=True, |
|
2081 | 2098 | alias=[(b'experimental', b'bundle2.stream')], |
|
2082 | 2099 | ) |
|
2083 | 2100 | coreconfigitem( |
|
2084 | 2101 | b'server', |
|
2085 | 2102 | b'compressionengines', |
|
2086 | 2103 | default=list, |
|
2087 | 2104 | ) |
|
2088 | 2105 | coreconfigitem( |
|
2089 | 2106 | b'server', |
|
2090 | 2107 | b'concurrent-push-mode', |
|
2091 | 2108 | default=b'check-related', |
|
2092 | 2109 | ) |
|
2093 | 2110 | coreconfigitem( |
|
2094 | 2111 | b'server', |
|
2095 | 2112 | b'disablefullbundle', |
|
2096 | 2113 | default=False, |
|
2097 | 2114 | ) |
|
2098 | 2115 | coreconfigitem( |
|
2099 | 2116 | b'server', |
|
2100 | 2117 | b'maxhttpheaderlen', |
|
2101 | 2118 | default=1024, |
|
2102 | 2119 | ) |
|
2103 | 2120 | coreconfigitem( |
|
2104 | 2121 | b'server', |
|
2105 | 2122 | b'pullbundle', |
|
2106 | 2123 | default=False, |
|
2107 | 2124 | ) |
|
2108 | 2125 | coreconfigitem( |
|
2109 | 2126 | b'server', |
|
2110 | 2127 | b'preferuncompressed', |
|
2111 | 2128 | default=False, |
|
2112 | 2129 | ) |
|
2113 | 2130 | coreconfigitem( |
|
2114 | 2131 | b'server', |
|
2115 | 2132 | b'streamunbundle', |
|
2116 | 2133 | default=False, |
|
2117 | 2134 | ) |
|
2118 | 2135 | coreconfigitem( |
|
2119 | 2136 | b'server', |
|
2120 | 2137 | b'uncompressed', |
|
2121 | 2138 | default=True, |
|
2122 | 2139 | ) |
|
2123 | 2140 | coreconfigitem( |
|
2124 | 2141 | b'server', |
|
2125 | 2142 | b'uncompressedallowsecret', |
|
2126 | 2143 | default=False, |
|
2127 | 2144 | ) |
|
2128 | 2145 | coreconfigitem( |
|
2129 | 2146 | b'server', |
|
2130 | 2147 | b'view', |
|
2131 | 2148 | default=b'served', |
|
2132 | 2149 | ) |
|
2133 | 2150 | coreconfigitem( |
|
2134 | 2151 | b'server', |
|
2135 | 2152 | b'validate', |
|
2136 | 2153 | default=False, |
|
2137 | 2154 | ) |
|
2138 | 2155 | coreconfigitem( |
|
2139 | 2156 | b'server', |
|
2140 | 2157 | b'zliblevel', |
|
2141 | 2158 | default=-1, |
|
2142 | 2159 | ) |
|
2143 | 2160 | coreconfigitem( |
|
2144 | 2161 | b'server', |
|
2145 | 2162 | b'zstdlevel', |
|
2146 | 2163 | default=3, |
|
2147 | 2164 | ) |
|
2148 | 2165 | coreconfigitem( |
|
2149 | 2166 | b'share', |
|
2150 | 2167 | b'pool', |
|
2151 | 2168 | default=None, |
|
2152 | 2169 | ) |
|
2153 | 2170 | coreconfigitem( |
|
2154 | 2171 | b'share', |
|
2155 | 2172 | b'poolnaming', |
|
2156 | 2173 | default=b'identity', |
|
2157 | 2174 | ) |
|
2158 | 2175 | coreconfigitem( |
|
2159 | 2176 | b'share', |
|
2160 | 2177 | b'safe-mismatch.source-not-safe', |
|
2161 | 2178 | default=b'abort', |
|
2162 | 2179 | ) |
|
2163 | 2180 | coreconfigitem( |
|
2164 | 2181 | b'share', |
|
2165 | 2182 | b'safe-mismatch.source-safe', |
|
2166 | 2183 | default=b'abort', |
|
2167 | 2184 | ) |
|
2168 | 2185 | coreconfigitem( |
|
2169 | 2186 | b'share', |
|
2170 | 2187 | b'safe-mismatch.source-not-safe.warn', |
|
2171 | 2188 | default=True, |
|
2172 | 2189 | ) |
|
2173 | 2190 | coreconfigitem( |
|
2174 | 2191 | b'share', |
|
2175 | 2192 | b'safe-mismatch.source-safe.warn', |
|
2176 | 2193 | default=True, |
|
2177 | 2194 | ) |
|
2178 | 2195 | coreconfigitem( |
|
2179 | 2196 | b'share', |
|
2180 | 2197 | b'safe-mismatch.source-not-safe:verbose-upgrade', |
|
2181 | 2198 | default=True, |
|
2182 | 2199 | ) |
|
2183 | 2200 | coreconfigitem( |
|
2184 | 2201 | b'share', |
|
2185 | 2202 | b'safe-mismatch.source-safe:verbose-upgrade', |
|
2186 | 2203 | default=True, |
|
2187 | 2204 | ) |
|
2188 | 2205 | coreconfigitem( |
|
2189 | 2206 | b'shelve', |
|
2190 | 2207 | b'maxbackups', |
|
2191 | 2208 | default=10, |
|
2192 | 2209 | ) |
|
2193 | 2210 | coreconfigitem( |
|
2194 | 2211 | b'smtp', |
|
2195 | 2212 | b'host', |
|
2196 | 2213 | default=None, |
|
2197 | 2214 | ) |
|
2198 | 2215 | coreconfigitem( |
|
2199 | 2216 | b'smtp', |
|
2200 | 2217 | b'local_hostname', |
|
2201 | 2218 | default=None, |
|
2202 | 2219 | ) |
|
2203 | 2220 | coreconfigitem( |
|
2204 | 2221 | b'smtp', |
|
2205 | 2222 | b'password', |
|
2206 | 2223 | default=None, |
|
2207 | 2224 | ) |
|
2208 | 2225 | coreconfigitem( |
|
2209 | 2226 | b'smtp', |
|
2210 | 2227 | b'port', |
|
2211 | 2228 | default=dynamicdefault, |
|
2212 | 2229 | ) |
|
2213 | 2230 | coreconfigitem( |
|
2214 | 2231 | b'smtp', |
|
2215 | 2232 | b'tls', |
|
2216 | 2233 | default=b'none', |
|
2217 | 2234 | ) |
|
2218 | 2235 | coreconfigitem( |
|
2219 | 2236 | b'smtp', |
|
2220 | 2237 | b'username', |
|
2221 | 2238 | default=None, |
|
2222 | 2239 | ) |
|
2223 | 2240 | coreconfigitem( |
|
2224 | 2241 | b'sparse', |
|
2225 | 2242 | b'missingwarning', |
|
2226 | 2243 | default=True, |
|
2227 | 2244 | experimental=True, |
|
2228 | 2245 | ) |
|
2229 | 2246 | coreconfigitem( |
|
2230 | 2247 | b'subrepos', |
|
2231 | 2248 | b'allowed', |
|
2232 | 2249 | default=dynamicdefault, # to make backporting simpler |
|
2233 | 2250 | ) |
|
2234 | 2251 | coreconfigitem( |
|
2235 | 2252 | b'subrepos', |
|
2236 | 2253 | b'hg:allowed', |
|
2237 | 2254 | default=dynamicdefault, |
|
2238 | 2255 | ) |
|
2239 | 2256 | coreconfigitem( |
|
2240 | 2257 | b'subrepos', |
|
2241 | 2258 | b'git:allowed', |
|
2242 | 2259 | default=dynamicdefault, |
|
2243 | 2260 | ) |
|
2244 | 2261 | coreconfigitem( |
|
2245 | 2262 | b'subrepos', |
|
2246 | 2263 | b'svn:allowed', |
|
2247 | 2264 | default=dynamicdefault, |
|
2248 | 2265 | ) |
|
2249 | 2266 | coreconfigitem( |
|
2250 | 2267 | b'templates', |
|
2251 | 2268 | b'.*', |
|
2252 | 2269 | default=None, |
|
2253 | 2270 | generic=True, |
|
2254 | 2271 | ) |
|
2255 | 2272 | coreconfigitem( |
|
2256 | 2273 | b'templateconfig', |
|
2257 | 2274 | b'.*', |
|
2258 | 2275 | default=dynamicdefault, |
|
2259 | 2276 | generic=True, |
|
2260 | 2277 | ) |
|
2261 | 2278 | coreconfigitem( |
|
2262 | 2279 | b'trusted', |
|
2263 | 2280 | b'groups', |
|
2264 | 2281 | default=list, |
|
2265 | 2282 | ) |
|
2266 | 2283 | coreconfigitem( |
|
2267 | 2284 | b'trusted', |
|
2268 | 2285 | b'users', |
|
2269 | 2286 | default=list, |
|
2270 | 2287 | ) |
|
2271 | 2288 | coreconfigitem( |
|
2272 | 2289 | b'ui', |
|
2273 | 2290 | b'_usedassubrepo', |
|
2274 | 2291 | default=False, |
|
2275 | 2292 | ) |
|
2276 | 2293 | coreconfigitem( |
|
2277 | 2294 | b'ui', |
|
2278 | 2295 | b'allowemptycommit', |
|
2279 | 2296 | default=False, |
|
2280 | 2297 | ) |
|
2281 | 2298 | coreconfigitem( |
|
2282 | 2299 | b'ui', |
|
2283 | 2300 | b'archivemeta', |
|
2284 | 2301 | default=True, |
|
2285 | 2302 | ) |
|
2286 | 2303 | coreconfigitem( |
|
2287 | 2304 | b'ui', |
|
2288 | 2305 | b'askusername', |
|
2289 | 2306 | default=False, |
|
2290 | 2307 | ) |
|
2291 | 2308 | coreconfigitem( |
|
2292 | 2309 | b'ui', |
|
2293 | 2310 | b'available-memory', |
|
2294 | 2311 | default=None, |
|
2295 | 2312 | ) |
|
2296 | 2313 | |
|
2297 | 2314 | coreconfigitem( |
|
2298 | 2315 | b'ui', |
|
2299 | 2316 | b'clonebundlefallback', |
|
2300 | 2317 | default=False, |
|
2301 | 2318 | ) |
|
2302 | 2319 | coreconfigitem( |
|
2303 | 2320 | b'ui', |
|
2304 | 2321 | b'clonebundleprefers', |
|
2305 | 2322 | default=list, |
|
2306 | 2323 | ) |
|
2307 | 2324 | coreconfigitem( |
|
2308 | 2325 | b'ui', |
|
2309 | 2326 | b'clonebundles', |
|
2310 | 2327 | default=True, |
|
2311 | 2328 | ) |
|
2312 | 2329 | coreconfigitem( |
|
2313 | 2330 | b'ui', |
|
2314 | 2331 | b'color', |
|
2315 | 2332 | default=b'auto', |
|
2316 | 2333 | ) |
|
2317 | 2334 | coreconfigitem( |
|
2318 | 2335 | b'ui', |
|
2319 | 2336 | b'commitsubrepos', |
|
2320 | 2337 | default=False, |
|
2321 | 2338 | ) |
|
2322 | 2339 | coreconfigitem( |
|
2323 | 2340 | b'ui', |
|
2324 | 2341 | b'debug', |
|
2325 | 2342 | default=False, |
|
2326 | 2343 | ) |
|
2327 | 2344 | coreconfigitem( |
|
2328 | 2345 | b'ui', |
|
2329 | 2346 | b'debugger', |
|
2330 | 2347 | default=None, |
|
2331 | 2348 | ) |
|
2332 | 2349 | coreconfigitem( |
|
2333 | 2350 | b'ui', |
|
2334 | 2351 | b'editor', |
|
2335 | 2352 | default=dynamicdefault, |
|
2336 | 2353 | ) |
|
2337 | 2354 | coreconfigitem( |
|
2338 | 2355 | b'ui', |
|
2339 | 2356 | b'detailed-exit-code', |
|
2340 | 2357 | default=False, |
|
2341 | 2358 | experimental=True, |
|
2342 | 2359 | ) |
|
2343 | 2360 | coreconfigitem( |
|
2344 | 2361 | b'ui', |
|
2345 | 2362 | b'fallbackencoding', |
|
2346 | 2363 | default=None, |
|
2347 | 2364 | ) |
|
2348 | 2365 | coreconfigitem( |
|
2349 | 2366 | b'ui', |
|
2350 | 2367 | b'forcecwd', |
|
2351 | 2368 | default=None, |
|
2352 | 2369 | ) |
|
2353 | 2370 | coreconfigitem( |
|
2354 | 2371 | b'ui', |
|
2355 | 2372 | b'forcemerge', |
|
2356 | 2373 | default=None, |
|
2357 | 2374 | ) |
|
2358 | 2375 | coreconfigitem( |
|
2359 | 2376 | b'ui', |
|
2360 | 2377 | b'formatdebug', |
|
2361 | 2378 | default=False, |
|
2362 | 2379 | ) |
|
2363 | 2380 | coreconfigitem( |
|
2364 | 2381 | b'ui', |
|
2365 | 2382 | b'formatjson', |
|
2366 | 2383 | default=False, |
|
2367 | 2384 | ) |
|
2368 | 2385 | coreconfigitem( |
|
2369 | 2386 | b'ui', |
|
2370 | 2387 | b'formatted', |
|
2371 | 2388 | default=None, |
|
2372 | 2389 | ) |
|
2373 | 2390 | coreconfigitem( |
|
2374 | 2391 | b'ui', |
|
2375 | 2392 | b'interactive', |
|
2376 | 2393 | default=None, |
|
2377 | 2394 | ) |
|
2378 | 2395 | coreconfigitem( |
|
2379 | 2396 | b'ui', |
|
2380 | 2397 | b'interface', |
|
2381 | 2398 | default=None, |
|
2382 | 2399 | ) |
|
2383 | 2400 | coreconfigitem( |
|
2384 | 2401 | b'ui', |
|
2385 | 2402 | b'interface.chunkselector', |
|
2386 | 2403 | default=None, |
|
2387 | 2404 | ) |
|
2388 | 2405 | coreconfigitem( |
|
2389 | 2406 | b'ui', |
|
2390 | 2407 | b'large-file-limit', |
|
2391 | 2408 | default=10 * (2 ** 20), |
|
2392 | 2409 | ) |
|
2393 | 2410 | coreconfigitem( |
|
2394 | 2411 | b'ui', |
|
2395 | 2412 | b'logblockedtimes', |
|
2396 | 2413 | default=False, |
|
2397 | 2414 | ) |
|
2398 | 2415 | coreconfigitem( |
|
2399 | 2416 | b'ui', |
|
2400 | 2417 | b'merge', |
|
2401 | 2418 | default=None, |
|
2402 | 2419 | ) |
|
2403 | 2420 | coreconfigitem( |
|
2404 | 2421 | b'ui', |
|
2405 | 2422 | b'mergemarkers', |
|
2406 | 2423 | default=b'basic', |
|
2407 | 2424 | ) |
|
2408 | 2425 | coreconfigitem( |
|
2409 | 2426 | b'ui', |
|
2410 | 2427 | b'message-output', |
|
2411 | 2428 | default=b'stdio', |
|
2412 | 2429 | ) |
|
2413 | 2430 | coreconfigitem( |
|
2414 | 2431 | b'ui', |
|
2415 | 2432 | b'nontty', |
|
2416 | 2433 | default=False, |
|
2417 | 2434 | ) |
|
2418 | 2435 | coreconfigitem( |
|
2419 | 2436 | b'ui', |
|
2420 | 2437 | b'origbackuppath', |
|
2421 | 2438 | default=None, |
|
2422 | 2439 | ) |
|
2423 | 2440 | coreconfigitem( |
|
2424 | 2441 | b'ui', |
|
2425 | 2442 | b'paginate', |
|
2426 | 2443 | default=True, |
|
2427 | 2444 | ) |
|
2428 | 2445 | coreconfigitem( |
|
2429 | 2446 | b'ui', |
|
2430 | 2447 | b'patch', |
|
2431 | 2448 | default=None, |
|
2432 | 2449 | ) |
|
2433 | 2450 | coreconfigitem( |
|
2434 | 2451 | b'ui', |
|
2435 | 2452 | b'portablefilenames', |
|
2436 | 2453 | default=b'warn', |
|
2437 | 2454 | ) |
|
2438 | 2455 | coreconfigitem( |
|
2439 | 2456 | b'ui', |
|
2440 | 2457 | b'promptecho', |
|
2441 | 2458 | default=False, |
|
2442 | 2459 | ) |
|
2443 | 2460 | coreconfigitem( |
|
2444 | 2461 | b'ui', |
|
2445 | 2462 | b'quiet', |
|
2446 | 2463 | default=False, |
|
2447 | 2464 | ) |
|
2448 | 2465 | coreconfigitem( |
|
2449 | 2466 | b'ui', |
|
2450 | 2467 | b'quietbookmarkmove', |
|
2451 | 2468 | default=False, |
|
2452 | 2469 | ) |
|
2453 | 2470 | coreconfigitem( |
|
2454 | 2471 | b'ui', |
|
2455 | 2472 | b'relative-paths', |
|
2456 | 2473 | default=b'legacy', |
|
2457 | 2474 | ) |
|
2458 | 2475 | coreconfigitem( |
|
2459 | 2476 | b'ui', |
|
2460 | 2477 | b'remotecmd', |
|
2461 | 2478 | default=b'hg', |
|
2462 | 2479 | ) |
|
2463 | 2480 | coreconfigitem( |
|
2464 | 2481 | b'ui', |
|
2465 | 2482 | b'report_untrusted', |
|
2466 | 2483 | default=True, |
|
2467 | 2484 | ) |
|
2468 | 2485 | coreconfigitem( |
|
2469 | 2486 | b'ui', |
|
2470 | 2487 | b'rollback', |
|
2471 | 2488 | default=True, |
|
2472 | 2489 | ) |
|
2473 | 2490 | coreconfigitem( |
|
2474 | 2491 | b'ui', |
|
2475 | 2492 | b'signal-safe-lock', |
|
2476 | 2493 | default=True, |
|
2477 | 2494 | ) |
|
2478 | 2495 | coreconfigitem( |
|
2479 | 2496 | b'ui', |
|
2480 | 2497 | b'slash', |
|
2481 | 2498 | default=False, |
|
2482 | 2499 | ) |
|
2483 | 2500 | coreconfigitem( |
|
2484 | 2501 | b'ui', |
|
2485 | 2502 | b'ssh', |
|
2486 | 2503 | default=b'ssh', |
|
2487 | 2504 | ) |
|
2488 | 2505 | coreconfigitem( |
|
2489 | 2506 | b'ui', |
|
2490 | 2507 | b'ssherrorhint', |
|
2491 | 2508 | default=None, |
|
2492 | 2509 | ) |
|
2493 | 2510 | coreconfigitem( |
|
2494 | 2511 | b'ui', |
|
2495 | 2512 | b'statuscopies', |
|
2496 | 2513 | default=False, |
|
2497 | 2514 | ) |
|
2498 | 2515 | coreconfigitem( |
|
2499 | 2516 | b'ui', |
|
2500 | 2517 | b'strict', |
|
2501 | 2518 | default=False, |
|
2502 | 2519 | ) |
|
2503 | 2520 | coreconfigitem( |
|
2504 | 2521 | b'ui', |
|
2505 | 2522 | b'style', |
|
2506 | 2523 | default=b'', |
|
2507 | 2524 | ) |
|
2508 | 2525 | coreconfigitem( |
|
2509 | 2526 | b'ui', |
|
2510 | 2527 | b'supportcontact', |
|
2511 | 2528 | default=None, |
|
2512 | 2529 | ) |
|
2513 | 2530 | coreconfigitem( |
|
2514 | 2531 | b'ui', |
|
2515 | 2532 | b'textwidth', |
|
2516 | 2533 | default=78, |
|
2517 | 2534 | ) |
|
2518 | 2535 | coreconfigitem( |
|
2519 | 2536 | b'ui', |
|
2520 | 2537 | b'timeout', |
|
2521 | 2538 | default=b'600', |
|
2522 | 2539 | ) |
|
2523 | 2540 | coreconfigitem( |
|
2524 | 2541 | b'ui', |
|
2525 | 2542 | b'timeout.warn', |
|
2526 | 2543 | default=0, |
|
2527 | 2544 | ) |
|
2528 | 2545 | coreconfigitem( |
|
2529 | 2546 | b'ui', |
|
2530 | 2547 | b'timestamp-output', |
|
2531 | 2548 | default=False, |
|
2532 | 2549 | ) |
|
2533 | 2550 | coreconfigitem( |
|
2534 | 2551 | b'ui', |
|
2535 | 2552 | b'traceback', |
|
2536 | 2553 | default=False, |
|
2537 | 2554 | ) |
|
2538 | 2555 | coreconfigitem( |
|
2539 | 2556 | b'ui', |
|
2540 | 2557 | b'tweakdefaults', |
|
2541 | 2558 | default=False, |
|
2542 | 2559 | ) |
|
2543 | 2560 | coreconfigitem(b'ui', b'username', alias=[(b'ui', b'user')]) |
|
2544 | 2561 | coreconfigitem( |
|
2545 | 2562 | b'ui', |
|
2546 | 2563 | b'verbose', |
|
2547 | 2564 | default=False, |
|
2548 | 2565 | ) |
|
2549 | 2566 | coreconfigitem( |
|
2550 | 2567 | b'verify', |
|
2551 | 2568 | b'skipflags', |
|
2552 | 2569 | default=None, |
|
2553 | 2570 | ) |
|
2554 | 2571 | coreconfigitem( |
|
2555 | 2572 | b'web', |
|
2556 | 2573 | b'allowbz2', |
|
2557 | 2574 | default=False, |
|
2558 | 2575 | ) |
|
2559 | 2576 | coreconfigitem( |
|
2560 | 2577 | b'web', |
|
2561 | 2578 | b'allowgz', |
|
2562 | 2579 | default=False, |
|
2563 | 2580 | ) |
|
2564 | 2581 | coreconfigitem( |
|
2565 | 2582 | b'web', |
|
2566 | 2583 | b'allow-pull', |
|
2567 | 2584 | alias=[(b'web', b'allowpull')], |
|
2568 | 2585 | default=True, |
|
2569 | 2586 | ) |
|
2570 | 2587 | coreconfigitem( |
|
2571 | 2588 | b'web', |
|
2572 | 2589 | b'allow-push', |
|
2573 | 2590 | alias=[(b'web', b'allow_push')], |
|
2574 | 2591 | default=list, |
|
2575 | 2592 | ) |
|
2576 | 2593 | coreconfigitem( |
|
2577 | 2594 | b'web', |
|
2578 | 2595 | b'allowzip', |
|
2579 | 2596 | default=False, |
|
2580 | 2597 | ) |
|
2581 | 2598 | coreconfigitem( |
|
2582 | 2599 | b'web', |
|
2583 | 2600 | b'archivesubrepos', |
|
2584 | 2601 | default=False, |
|
2585 | 2602 | ) |
|
2586 | 2603 | coreconfigitem( |
|
2587 | 2604 | b'web', |
|
2588 | 2605 | b'cache', |
|
2589 | 2606 | default=True, |
|
2590 | 2607 | ) |
|
2591 | 2608 | coreconfigitem( |
|
2592 | 2609 | b'web', |
|
2593 | 2610 | b'comparisoncontext', |
|
2594 | 2611 | default=5, |
|
2595 | 2612 | ) |
|
2596 | 2613 | coreconfigitem( |
|
2597 | 2614 | b'web', |
|
2598 | 2615 | b'contact', |
|
2599 | 2616 | default=None, |
|
2600 | 2617 | ) |
|
2601 | 2618 | coreconfigitem( |
|
2602 | 2619 | b'web', |
|
2603 | 2620 | b'deny_push', |
|
2604 | 2621 | default=list, |
|
2605 | 2622 | ) |
|
2606 | 2623 | coreconfigitem( |
|
2607 | 2624 | b'web', |
|
2608 | 2625 | b'guessmime', |
|
2609 | 2626 | default=False, |
|
2610 | 2627 | ) |
|
2611 | 2628 | coreconfigitem( |
|
2612 | 2629 | b'web', |
|
2613 | 2630 | b'hidden', |
|
2614 | 2631 | default=False, |
|
2615 | 2632 | ) |
|
2616 | 2633 | coreconfigitem( |
|
2617 | 2634 | b'web', |
|
2618 | 2635 | b'labels', |
|
2619 | 2636 | default=list, |
|
2620 | 2637 | ) |
|
2621 | 2638 | coreconfigitem( |
|
2622 | 2639 | b'web', |
|
2623 | 2640 | b'logoimg', |
|
2624 | 2641 | default=b'hglogo.png', |
|
2625 | 2642 | ) |
|
2626 | 2643 | coreconfigitem( |
|
2627 | 2644 | b'web', |
|
2628 | 2645 | b'logourl', |
|
2629 | 2646 | default=b'https://mercurial-scm.org/', |
|
2630 | 2647 | ) |
|
2631 | 2648 | coreconfigitem( |
|
2632 | 2649 | b'web', |
|
2633 | 2650 | b'accesslog', |
|
2634 | 2651 | default=b'-', |
|
2635 | 2652 | ) |
|
2636 | 2653 | coreconfigitem( |
|
2637 | 2654 | b'web', |
|
2638 | 2655 | b'address', |
|
2639 | 2656 | default=b'', |
|
2640 | 2657 | ) |
|
2641 | 2658 | coreconfigitem( |
|
2642 | 2659 | b'web', |
|
2643 | 2660 | b'allow-archive', |
|
2644 | 2661 | alias=[(b'web', b'allow_archive')], |
|
2645 | 2662 | default=list, |
|
2646 | 2663 | ) |
|
2647 | 2664 | coreconfigitem( |
|
2648 | 2665 | b'web', |
|
2649 | 2666 | b'allow_read', |
|
2650 | 2667 | default=list, |
|
2651 | 2668 | ) |
|
2652 | 2669 | coreconfigitem( |
|
2653 | 2670 | b'web', |
|
2654 | 2671 | b'baseurl', |
|
2655 | 2672 | default=None, |
|
2656 | 2673 | ) |
|
2657 | 2674 | coreconfigitem( |
|
2658 | 2675 | b'web', |
|
2659 | 2676 | b'cacerts', |
|
2660 | 2677 | default=None, |
|
2661 | 2678 | ) |
|
2662 | 2679 | coreconfigitem( |
|
2663 | 2680 | b'web', |
|
2664 | 2681 | b'certificate', |
|
2665 | 2682 | default=None, |
|
2666 | 2683 | ) |
|
2667 | 2684 | coreconfigitem( |
|
2668 | 2685 | b'web', |
|
2669 | 2686 | b'collapse', |
|
2670 | 2687 | default=False, |
|
2671 | 2688 | ) |
|
2672 | 2689 | coreconfigitem( |
|
2673 | 2690 | b'web', |
|
2674 | 2691 | b'csp', |
|
2675 | 2692 | default=None, |
|
2676 | 2693 | ) |
|
2677 | 2694 | coreconfigitem( |
|
2678 | 2695 | b'web', |
|
2679 | 2696 | b'deny_read', |
|
2680 | 2697 | default=list, |
|
2681 | 2698 | ) |
|
2682 | 2699 | coreconfigitem( |
|
2683 | 2700 | b'web', |
|
2684 | 2701 | b'descend', |
|
2685 | 2702 | default=True, |
|
2686 | 2703 | ) |
|
2687 | 2704 | coreconfigitem( |
|
2688 | 2705 | b'web', |
|
2689 | 2706 | b'description', |
|
2690 | 2707 | default=b"", |
|
2691 | 2708 | ) |
|
2692 | 2709 | coreconfigitem( |
|
2693 | 2710 | b'web', |
|
2694 | 2711 | b'encoding', |
|
2695 | 2712 | default=lambda: encoding.encoding, |
|
2696 | 2713 | ) |
|
2697 | 2714 | coreconfigitem( |
|
2698 | 2715 | b'web', |
|
2699 | 2716 | b'errorlog', |
|
2700 | 2717 | default=b'-', |
|
2701 | 2718 | ) |
|
2702 | 2719 | coreconfigitem( |
|
2703 | 2720 | b'web', |
|
2704 | 2721 | b'ipv6', |
|
2705 | 2722 | default=False, |
|
2706 | 2723 | ) |
|
2707 | 2724 | coreconfigitem( |
|
2708 | 2725 | b'web', |
|
2709 | 2726 | b'maxchanges', |
|
2710 | 2727 | default=10, |
|
2711 | 2728 | ) |
|
2712 | 2729 | coreconfigitem( |
|
2713 | 2730 | b'web', |
|
2714 | 2731 | b'maxfiles', |
|
2715 | 2732 | default=10, |
|
2716 | 2733 | ) |
|
2717 | 2734 | coreconfigitem( |
|
2718 | 2735 | b'web', |
|
2719 | 2736 | b'maxshortchanges', |
|
2720 | 2737 | default=60, |
|
2721 | 2738 | ) |
|
2722 | 2739 | coreconfigitem( |
|
2723 | 2740 | b'web', |
|
2724 | 2741 | b'motd', |
|
2725 | 2742 | default=b'', |
|
2726 | 2743 | ) |
|
2727 | 2744 | coreconfigitem( |
|
2728 | 2745 | b'web', |
|
2729 | 2746 | b'name', |
|
2730 | 2747 | default=dynamicdefault, |
|
2731 | 2748 | ) |
|
2732 | 2749 | coreconfigitem( |
|
2733 | 2750 | b'web', |
|
2734 | 2751 | b'port', |
|
2735 | 2752 | default=8000, |
|
2736 | 2753 | ) |
|
2737 | 2754 | coreconfigitem( |
|
2738 | 2755 | b'web', |
|
2739 | 2756 | b'prefix', |
|
2740 | 2757 | default=b'', |
|
2741 | 2758 | ) |
|
2742 | 2759 | coreconfigitem( |
|
2743 | 2760 | b'web', |
|
2744 | 2761 | b'push_ssl', |
|
2745 | 2762 | default=True, |
|
2746 | 2763 | ) |
|
2747 | 2764 | coreconfigitem( |
|
2748 | 2765 | b'web', |
|
2749 | 2766 | b'refreshinterval', |
|
2750 | 2767 | default=20, |
|
2751 | 2768 | ) |
|
2752 | 2769 | coreconfigitem( |
|
2753 | 2770 | b'web', |
|
2754 | 2771 | b'server-header', |
|
2755 | 2772 | default=None, |
|
2756 | 2773 | ) |
|
2757 | 2774 | coreconfigitem( |
|
2758 | 2775 | b'web', |
|
2759 | 2776 | b'static', |
|
2760 | 2777 | default=None, |
|
2761 | 2778 | ) |
|
2762 | 2779 | coreconfigitem( |
|
2763 | 2780 | b'web', |
|
2764 | 2781 | b'staticurl', |
|
2765 | 2782 | default=None, |
|
2766 | 2783 | ) |
|
2767 | 2784 | coreconfigitem( |
|
2768 | 2785 | b'web', |
|
2769 | 2786 | b'stripes', |
|
2770 | 2787 | default=1, |
|
2771 | 2788 | ) |
|
2772 | 2789 | coreconfigitem( |
|
2773 | 2790 | b'web', |
|
2774 | 2791 | b'style', |
|
2775 | 2792 | default=b'paper', |
|
2776 | 2793 | ) |
|
2777 | 2794 | coreconfigitem( |
|
2778 | 2795 | b'web', |
|
2779 | 2796 | b'templates', |
|
2780 | 2797 | default=None, |
|
2781 | 2798 | ) |
|
2782 | 2799 | coreconfigitem( |
|
2783 | 2800 | b'web', |
|
2784 | 2801 | b'view', |
|
2785 | 2802 | default=b'served', |
|
2786 | 2803 | experimental=True, |
|
2787 | 2804 | ) |
|
2788 | 2805 | coreconfigitem( |
|
2789 | 2806 | b'worker', |
|
2790 | 2807 | b'backgroundclose', |
|
2791 | 2808 | default=dynamicdefault, |
|
2792 | 2809 | ) |
|
2793 | 2810 | # Windows defaults to a limit of 512 open files. A buffer of 128 |
|
2794 | 2811 | # should give us enough headway. |
|
2795 | 2812 | coreconfigitem( |
|
2796 | 2813 | b'worker', |
|
2797 | 2814 | b'backgroundclosemaxqueue', |
|
2798 | 2815 | default=384, |
|
2799 | 2816 | ) |
|
2800 | 2817 | coreconfigitem( |
|
2801 | 2818 | b'worker', |
|
2802 | 2819 | b'backgroundcloseminfilecount', |
|
2803 | 2820 | default=2048, |
|
2804 | 2821 | ) |
|
2805 | 2822 | coreconfigitem( |
|
2806 | 2823 | b'worker', |
|
2807 | 2824 | b'backgroundclosethreadcount', |
|
2808 | 2825 | default=4, |
|
2809 | 2826 | ) |
|
2810 | 2827 | coreconfigitem( |
|
2811 | 2828 | b'worker', |
|
2812 | 2829 | b'enabled', |
|
2813 | 2830 | default=True, |
|
2814 | 2831 | ) |
|
2815 | 2832 | coreconfigitem( |
|
2816 | 2833 | b'worker', |
|
2817 | 2834 | b'numcpus', |
|
2818 | 2835 | default=None, |
|
2819 | 2836 | ) |
|
2820 | 2837 | |
|
2821 | 2838 | # Rebase related configuration moved to core because other extension are doing |
|
2822 | 2839 | # strange things. For example, shelve import the extensions to reuse some bit |
|
2823 | 2840 | # without formally loading it. |
|
2824 | 2841 | coreconfigitem( |
|
2825 | 2842 | b'commands', |
|
2826 | 2843 | b'rebase.requiredest', |
|
2827 | 2844 | default=False, |
|
2828 | 2845 | ) |
|
2829 | 2846 | coreconfigitem( |
|
2830 | 2847 | b'experimental', |
|
2831 | 2848 | b'rebaseskipobsolete', |
|
2832 | 2849 | default=True, |
|
2833 | 2850 | ) |
|
2834 | 2851 | coreconfigitem( |
|
2835 | 2852 | b'rebase', |
|
2836 | 2853 | b'singletransaction', |
|
2837 | 2854 | default=False, |
|
2838 | 2855 | ) |
|
2839 | 2856 | coreconfigitem( |
|
2840 | 2857 | b'rebase', |
|
2841 | 2858 | b'experimental.inmemory', |
|
2842 | 2859 | default=False, |
|
2843 | 2860 | ) |
|
2844 | 2861 | |
|
2845 | 2862 | # This setting controls creation of a rebase_source extra field |
|
2846 | 2863 | # during rebase. When False, no such field is created. This is |
|
2847 | 2864 | # useful eg for incrementally converting changesets and then |
|
2848 | 2865 | # rebasing them onto an existing repo. |
|
2849 | 2866 | # WARNING: this is an advanced setting reserved for people who know |
|
2850 | 2867 | # exactly what they are doing. Misuse of this setting can easily |
|
2851 | 2868 | # result in obsmarker cycles and a vivid headache. |
|
2852 | 2869 | coreconfigitem( |
|
2853 | 2870 | b'rebase', |
|
2854 | 2871 | b'store-source', |
|
2855 | 2872 | default=True, |
|
2856 | 2873 | experimental=True, |
|
2857 | 2874 | ) |
@@ -1,3946 +1,3951 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 | |
|
10 | 10 | import functools |
|
11 | 11 | import os |
|
12 | 12 | import random |
|
13 | 13 | import sys |
|
14 | 14 | import time |
|
15 | 15 | import weakref |
|
16 | 16 | |
|
17 | 17 | from concurrent import futures |
|
18 | 18 | from .i18n import _ |
|
19 | 19 | from .node import ( |
|
20 | 20 | bin, |
|
21 | 21 | hex, |
|
22 | 22 | nullrev, |
|
23 | 23 | sha1nodeconstants, |
|
24 | 24 | short, |
|
25 | 25 | ) |
|
26 | 26 | from .pycompat import ( |
|
27 | 27 | delattr, |
|
28 | 28 | getattr, |
|
29 | 29 | ) |
|
30 | 30 | from . import ( |
|
31 | 31 | bookmarks, |
|
32 | 32 | branchmap, |
|
33 | 33 | bundle2, |
|
34 | 34 | bundlecaches, |
|
35 | 35 | changegroup, |
|
36 | 36 | color, |
|
37 | 37 | commit, |
|
38 | 38 | context, |
|
39 | 39 | dirstate, |
|
40 | 40 | dirstateguard, |
|
41 | 41 | discovery, |
|
42 | 42 | encoding, |
|
43 | 43 | error, |
|
44 | 44 | exchange, |
|
45 | 45 | extensions, |
|
46 | 46 | filelog, |
|
47 | 47 | hook, |
|
48 | 48 | lock as lockmod, |
|
49 | 49 | match as matchmod, |
|
50 | 50 | mergestate as mergestatemod, |
|
51 | 51 | mergeutil, |
|
52 | 52 | namespaces, |
|
53 | 53 | narrowspec, |
|
54 | 54 | obsolete, |
|
55 | 55 | pathutil, |
|
56 | 56 | phases, |
|
57 | 57 | pushkey, |
|
58 | 58 | pycompat, |
|
59 | 59 | rcutil, |
|
60 | 60 | repoview, |
|
61 | 61 | requirements as requirementsmod, |
|
62 | 62 | revlog, |
|
63 | 63 | revset, |
|
64 | 64 | revsetlang, |
|
65 | 65 | scmutil, |
|
66 | 66 | sparse, |
|
67 | 67 | store as storemod, |
|
68 | 68 | subrepoutil, |
|
69 | 69 | tags as tagsmod, |
|
70 | 70 | transaction, |
|
71 | 71 | txnutil, |
|
72 | 72 | util, |
|
73 | 73 | vfs as vfsmod, |
|
74 | 74 | wireprototypes, |
|
75 | 75 | ) |
|
76 | 76 | |
|
77 | 77 | from .interfaces import ( |
|
78 | 78 | repository, |
|
79 | 79 | util as interfaceutil, |
|
80 | 80 | ) |
|
81 | 81 | |
|
82 | 82 | from .utils import ( |
|
83 | 83 | hashutil, |
|
84 | 84 | procutil, |
|
85 | 85 | stringutil, |
|
86 | 86 | urlutil, |
|
87 | 87 | ) |
|
88 | 88 | |
|
89 | 89 | from .revlogutils import ( |
|
90 | 90 | concurrency_checker as revlogchecker, |
|
91 | 91 | constants as revlogconst, |
|
92 | 92 | sidedata as sidedatamod, |
|
93 | 93 | ) |
|
94 | 94 | |
|
95 | 95 | release = lockmod.release |
|
96 | 96 | urlerr = util.urlerr |
|
97 | 97 | urlreq = util.urlreq |
|
98 | 98 | |
|
99 | 99 | # set of (path, vfs-location) tuples. vfs-location is: |
|
100 | 100 | # - 'plain for vfs relative paths |
|
101 | 101 | # - '' for svfs relative paths |
|
102 | 102 | _cachedfiles = set() |
|
103 | 103 | |
|
104 | 104 | |
|
105 | 105 | class _basefilecache(scmutil.filecache): |
|
106 | 106 | """All filecache usage on repo are done for logic that should be unfiltered""" |
|
107 | 107 | |
|
108 | 108 | def __get__(self, repo, type=None): |
|
109 | 109 | if repo is None: |
|
110 | 110 | return self |
|
111 | 111 | # proxy to unfiltered __dict__ since filtered repo has no entry |
|
112 | 112 | unfi = repo.unfiltered() |
|
113 | 113 | try: |
|
114 | 114 | return unfi.__dict__[self.sname] |
|
115 | 115 | except KeyError: |
|
116 | 116 | pass |
|
117 | 117 | return super(_basefilecache, self).__get__(unfi, type) |
|
118 | 118 | |
|
119 | 119 | def set(self, repo, value): |
|
120 | 120 | return super(_basefilecache, self).set(repo.unfiltered(), value) |
|
121 | 121 | |
|
122 | 122 | |
|
123 | 123 | class repofilecache(_basefilecache): |
|
124 | 124 | """filecache for files in .hg but outside of .hg/store""" |
|
125 | 125 | |
|
126 | 126 | def __init__(self, *paths): |
|
127 | 127 | super(repofilecache, self).__init__(*paths) |
|
128 | 128 | for path in paths: |
|
129 | 129 | _cachedfiles.add((path, b'plain')) |
|
130 | 130 | |
|
131 | 131 | def join(self, obj, fname): |
|
132 | 132 | return obj.vfs.join(fname) |
|
133 | 133 | |
|
134 | 134 | |
|
135 | 135 | class storecache(_basefilecache): |
|
136 | 136 | """filecache for files in the store""" |
|
137 | 137 | |
|
138 | 138 | def __init__(self, *paths): |
|
139 | 139 | super(storecache, self).__init__(*paths) |
|
140 | 140 | for path in paths: |
|
141 | 141 | _cachedfiles.add((path, b'')) |
|
142 | 142 | |
|
143 | 143 | def join(self, obj, fname): |
|
144 | 144 | return obj.sjoin(fname) |
|
145 | 145 | |
|
146 | 146 | |
|
147 | 147 | class changelogcache(storecache): |
|
148 | 148 | """filecache for the changelog""" |
|
149 | 149 | |
|
150 | 150 | def __init__(self): |
|
151 | 151 | super(changelogcache, self).__init__() |
|
152 | 152 | _cachedfiles.add((b'00changelog.i', b'')) |
|
153 | 153 | _cachedfiles.add((b'00changelog.n', b'')) |
|
154 | 154 | |
|
155 | 155 | def tracked_paths(self, obj): |
|
156 | 156 | paths = [self.join(obj, b'00changelog.i')] |
|
157 | 157 | if obj.store.opener.options.get(b'persistent-nodemap', False): |
|
158 | 158 | paths.append(self.join(obj, b'00changelog.n')) |
|
159 | 159 | return paths |
|
160 | 160 | |
|
161 | 161 | |
|
162 | 162 | class manifestlogcache(storecache): |
|
163 | 163 | """filecache for the manifestlog""" |
|
164 | 164 | |
|
165 | 165 | def __init__(self): |
|
166 | 166 | super(manifestlogcache, self).__init__() |
|
167 | 167 | _cachedfiles.add((b'00manifest.i', b'')) |
|
168 | 168 | _cachedfiles.add((b'00manifest.n', b'')) |
|
169 | 169 | |
|
170 | 170 | def tracked_paths(self, obj): |
|
171 | 171 | paths = [self.join(obj, b'00manifest.i')] |
|
172 | 172 | if obj.store.opener.options.get(b'persistent-nodemap', False): |
|
173 | 173 | paths.append(self.join(obj, b'00manifest.n')) |
|
174 | 174 | return paths |
|
175 | 175 | |
|
176 | 176 | |
|
177 | 177 | class mixedrepostorecache(_basefilecache): |
|
178 | 178 | """filecache for a mix files in .hg/store and outside""" |
|
179 | 179 | |
|
180 | 180 | def __init__(self, *pathsandlocations): |
|
181 | 181 | # scmutil.filecache only uses the path for passing back into our |
|
182 | 182 | # join(), so we can safely pass a list of paths and locations |
|
183 | 183 | super(mixedrepostorecache, self).__init__(*pathsandlocations) |
|
184 | 184 | _cachedfiles.update(pathsandlocations) |
|
185 | 185 | |
|
186 | 186 | def join(self, obj, fnameandlocation): |
|
187 | 187 | fname, location = fnameandlocation |
|
188 | 188 | if location == b'plain': |
|
189 | 189 | return obj.vfs.join(fname) |
|
190 | 190 | else: |
|
191 | 191 | if location != b'': |
|
192 | 192 | raise error.ProgrammingError( |
|
193 | 193 | b'unexpected location: %s' % location |
|
194 | 194 | ) |
|
195 | 195 | return obj.sjoin(fname) |
|
196 | 196 | |
|
197 | 197 | |
|
198 | 198 | def isfilecached(repo, name): |
|
199 | 199 | """check if a repo has already cached "name" filecache-ed property |
|
200 | 200 | |
|
201 | 201 | This returns (cachedobj-or-None, iscached) tuple. |
|
202 | 202 | """ |
|
203 | 203 | cacheentry = repo.unfiltered()._filecache.get(name, None) |
|
204 | 204 | if not cacheentry: |
|
205 | 205 | return None, False |
|
206 | 206 | return cacheentry.obj, True |
|
207 | 207 | |
|
208 | 208 | |
|
209 | 209 | class unfilteredpropertycache(util.propertycache): |
|
210 | 210 | """propertycache that apply to unfiltered repo only""" |
|
211 | 211 | |
|
212 | 212 | def __get__(self, repo, type=None): |
|
213 | 213 | unfi = repo.unfiltered() |
|
214 | 214 | if unfi is repo: |
|
215 | 215 | return super(unfilteredpropertycache, self).__get__(unfi) |
|
216 | 216 | return getattr(unfi, self.name) |
|
217 | 217 | |
|
218 | 218 | |
|
219 | 219 | class filteredpropertycache(util.propertycache): |
|
220 | 220 | """propertycache that must take filtering in account""" |
|
221 | 221 | |
|
222 | 222 | def cachevalue(self, obj, value): |
|
223 | 223 | object.__setattr__(obj, self.name, value) |
|
224 | 224 | |
|
225 | 225 | |
|
226 | 226 | def hasunfilteredcache(repo, name): |
|
227 | 227 | """check if a repo has an unfilteredpropertycache value for <name>""" |
|
228 | 228 | return name in vars(repo.unfiltered()) |
|
229 | 229 | |
|
230 | 230 | |
|
231 | 231 | def unfilteredmethod(orig): |
|
232 | 232 | """decorate method that always need to be run on unfiltered version""" |
|
233 | 233 | |
|
234 | 234 | @functools.wraps(orig) |
|
235 | 235 | def wrapper(repo, *args, **kwargs): |
|
236 | 236 | return orig(repo.unfiltered(), *args, **kwargs) |
|
237 | 237 | |
|
238 | 238 | return wrapper |
|
239 | 239 | |
|
240 | 240 | |
|
241 | 241 | moderncaps = { |
|
242 | 242 | b'lookup', |
|
243 | 243 | b'branchmap', |
|
244 | 244 | b'pushkey', |
|
245 | 245 | b'known', |
|
246 | 246 | b'getbundle', |
|
247 | 247 | b'unbundle', |
|
248 | 248 | } |
|
249 | 249 | legacycaps = moderncaps.union({b'changegroupsubset'}) |
|
250 | 250 | |
|
251 | 251 | |
|
252 | 252 | @interfaceutil.implementer(repository.ipeercommandexecutor) |
|
253 | 253 | class localcommandexecutor: |
|
254 | 254 | def __init__(self, peer): |
|
255 | 255 | self._peer = peer |
|
256 | 256 | self._sent = False |
|
257 | 257 | self._closed = False |
|
258 | 258 | |
|
259 | 259 | def __enter__(self): |
|
260 | 260 | return self |
|
261 | 261 | |
|
262 | 262 | def __exit__(self, exctype, excvalue, exctb): |
|
263 | 263 | self.close() |
|
264 | 264 | |
|
265 | 265 | def callcommand(self, command, args): |
|
266 | 266 | if self._sent: |
|
267 | 267 | raise error.ProgrammingError( |
|
268 | 268 | b'callcommand() cannot be used after sendcommands()' |
|
269 | 269 | ) |
|
270 | 270 | |
|
271 | 271 | if self._closed: |
|
272 | 272 | raise error.ProgrammingError( |
|
273 | 273 | b'callcommand() cannot be used after close()' |
|
274 | 274 | ) |
|
275 | 275 | |
|
276 | 276 | # We don't need to support anything fancy. Just call the named |
|
277 | 277 | # method on the peer and return a resolved future. |
|
278 | 278 | fn = getattr(self._peer, pycompat.sysstr(command)) |
|
279 | 279 | |
|
280 | 280 | f = futures.Future() |
|
281 | 281 | |
|
282 | 282 | try: |
|
283 | 283 | result = fn(**pycompat.strkwargs(args)) |
|
284 | 284 | except Exception: |
|
285 | 285 | pycompat.future_set_exception_info(f, sys.exc_info()[1:]) |
|
286 | 286 | else: |
|
287 | 287 | f.set_result(result) |
|
288 | 288 | |
|
289 | 289 | return f |
|
290 | 290 | |
|
291 | 291 | def sendcommands(self): |
|
292 | 292 | self._sent = True |
|
293 | 293 | |
|
294 | 294 | def close(self): |
|
295 | 295 | self._closed = True |
|
296 | 296 | |
|
297 | 297 | |
|
298 | 298 | @interfaceutil.implementer(repository.ipeercommands) |
|
299 | 299 | class localpeer(repository.peer): |
|
300 | 300 | '''peer for a local repo; reflects only the most recent API''' |
|
301 | 301 | |
|
302 | 302 | def __init__(self, repo, caps=None): |
|
303 | 303 | super(localpeer, self).__init__() |
|
304 | 304 | |
|
305 | 305 | if caps is None: |
|
306 | 306 | caps = moderncaps.copy() |
|
307 | 307 | self._repo = repo.filtered(b'served') |
|
308 | 308 | self.ui = repo.ui |
|
309 | 309 | |
|
310 | 310 | if repo._wanted_sidedata: |
|
311 | 311 | formatted = bundle2.format_remote_wanted_sidedata(repo) |
|
312 | 312 | caps.add(b'exp-wanted-sidedata=' + formatted) |
|
313 | 313 | |
|
314 | 314 | self._caps = repo._restrictcapabilities(caps) |
|
315 | 315 | |
|
316 | 316 | # Begin of _basepeer interface. |
|
317 | 317 | |
|
318 | 318 | def url(self): |
|
319 | 319 | return self._repo.url() |
|
320 | 320 | |
|
321 | 321 | def local(self): |
|
322 | 322 | return self._repo |
|
323 | 323 | |
|
324 | 324 | def peer(self): |
|
325 | 325 | return self |
|
326 | 326 | |
|
327 | 327 | def canpush(self): |
|
328 | 328 | return True |
|
329 | 329 | |
|
330 | 330 | def close(self): |
|
331 | 331 | self._repo.close() |
|
332 | 332 | |
|
333 | 333 | # End of _basepeer interface. |
|
334 | 334 | |
|
335 | 335 | # Begin of _basewirecommands interface. |
|
336 | 336 | |
|
337 | 337 | def branchmap(self): |
|
338 | 338 | return self._repo.branchmap() |
|
339 | 339 | |
|
340 | 340 | def capabilities(self): |
|
341 | 341 | return self._caps |
|
342 | 342 | |
|
343 | 343 | def clonebundles(self): |
|
344 | 344 | return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE) |
|
345 | 345 | |
|
346 | 346 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
347 | 347 | """Used to test argument passing over the wire""" |
|
348 | 348 | return b"%s %s %s %s %s" % ( |
|
349 | 349 | one, |
|
350 | 350 | two, |
|
351 | 351 | pycompat.bytestr(three), |
|
352 | 352 | pycompat.bytestr(four), |
|
353 | 353 | pycompat.bytestr(five), |
|
354 | 354 | ) |
|
355 | 355 | |
|
356 | 356 | def getbundle( |
|
357 | 357 | self, |
|
358 | 358 | source, |
|
359 | 359 | heads=None, |
|
360 | 360 | common=None, |
|
361 | 361 | bundlecaps=None, |
|
362 | 362 | remote_sidedata=None, |
|
363 | 363 | **kwargs |
|
364 | 364 | ): |
|
365 | 365 | chunks = exchange.getbundlechunks( |
|
366 | 366 | self._repo, |
|
367 | 367 | source, |
|
368 | 368 | heads=heads, |
|
369 | 369 | common=common, |
|
370 | 370 | bundlecaps=bundlecaps, |
|
371 | 371 | remote_sidedata=remote_sidedata, |
|
372 | 372 | **kwargs |
|
373 | 373 | )[1] |
|
374 | 374 | cb = util.chunkbuffer(chunks) |
|
375 | 375 | |
|
376 | 376 | if exchange.bundle2requested(bundlecaps): |
|
377 | 377 | # When requesting a bundle2, getbundle returns a stream to make the |
|
378 | 378 | # wire level function happier. We need to build a proper object |
|
379 | 379 | # from it in local peer. |
|
380 | 380 | return bundle2.getunbundler(self.ui, cb) |
|
381 | 381 | else: |
|
382 | 382 | return changegroup.getunbundler(b'01', cb, None) |
|
383 | 383 | |
|
384 | 384 | def heads(self): |
|
385 | 385 | return self._repo.heads() |
|
386 | 386 | |
|
387 | 387 | def known(self, nodes): |
|
388 | 388 | return self._repo.known(nodes) |
|
389 | 389 | |
|
390 | 390 | def listkeys(self, namespace): |
|
391 | 391 | return self._repo.listkeys(namespace) |
|
392 | 392 | |
|
393 | 393 | def lookup(self, key): |
|
394 | 394 | return self._repo.lookup(key) |
|
395 | 395 | |
|
396 | 396 | def pushkey(self, namespace, key, old, new): |
|
397 | 397 | return self._repo.pushkey(namespace, key, old, new) |
|
398 | 398 | |
|
399 | 399 | def stream_out(self): |
|
400 | 400 | raise error.Abort(_(b'cannot perform stream clone against local peer')) |
|
401 | 401 | |
|
402 | 402 | def unbundle(self, bundle, heads, url): |
|
403 | 403 | """apply a bundle on a repo |
|
404 | 404 | |
|
405 | 405 | This function handles the repo locking itself.""" |
|
406 | 406 | try: |
|
407 | 407 | try: |
|
408 | 408 | bundle = exchange.readbundle(self.ui, bundle, None) |
|
409 | 409 | ret = exchange.unbundle(self._repo, bundle, heads, b'push', url) |
|
410 | 410 | if util.safehasattr(ret, b'getchunks'): |
|
411 | 411 | # This is a bundle20 object, turn it into an unbundler. |
|
412 | 412 | # This little dance should be dropped eventually when the |
|
413 | 413 | # API is finally improved. |
|
414 | 414 | stream = util.chunkbuffer(ret.getchunks()) |
|
415 | 415 | ret = bundle2.getunbundler(self.ui, stream) |
|
416 | 416 | return ret |
|
417 | 417 | except Exception as exc: |
|
418 | 418 | # If the exception contains output salvaged from a bundle2 |
|
419 | 419 | # reply, we need to make sure it is printed before continuing |
|
420 | 420 | # to fail. So we build a bundle2 with such output and consume |
|
421 | 421 | # it directly. |
|
422 | 422 | # |
|
423 | 423 | # This is not very elegant but allows a "simple" solution for |
|
424 | 424 | # issue4594 |
|
425 | 425 | output = getattr(exc, '_bundle2salvagedoutput', ()) |
|
426 | 426 | if output: |
|
427 | 427 | bundler = bundle2.bundle20(self._repo.ui) |
|
428 | 428 | for out in output: |
|
429 | 429 | bundler.addpart(out) |
|
430 | 430 | stream = util.chunkbuffer(bundler.getchunks()) |
|
431 | 431 | b = bundle2.getunbundler(self.ui, stream) |
|
432 | 432 | bundle2.processbundle(self._repo, b) |
|
433 | 433 | raise |
|
434 | 434 | except error.PushRaced as exc: |
|
435 | 435 | raise error.ResponseError( |
|
436 | 436 | _(b'push failed:'), stringutil.forcebytestr(exc) |
|
437 | 437 | ) |
|
438 | 438 | |
|
439 | 439 | # End of _basewirecommands interface. |
|
440 | 440 | |
|
441 | 441 | # Begin of peer interface. |
|
442 | 442 | |
|
443 | 443 | def commandexecutor(self): |
|
444 | 444 | return localcommandexecutor(self) |
|
445 | 445 | |
|
446 | 446 | # End of peer interface. |
|
447 | 447 | |
|
448 | 448 | |
|
449 | 449 | @interfaceutil.implementer(repository.ipeerlegacycommands) |
|
450 | 450 | class locallegacypeer(localpeer): |
|
451 | 451 | """peer extension which implements legacy methods too; used for tests with |
|
452 | 452 | restricted capabilities""" |
|
453 | 453 | |
|
454 | 454 | def __init__(self, repo): |
|
455 | 455 | super(locallegacypeer, self).__init__(repo, caps=legacycaps) |
|
456 | 456 | |
|
457 | 457 | # Begin of baselegacywirecommands interface. |
|
458 | 458 | |
|
459 | 459 | def between(self, pairs): |
|
460 | 460 | return self._repo.between(pairs) |
|
461 | 461 | |
|
462 | 462 | def branches(self, nodes): |
|
463 | 463 | return self._repo.branches(nodes) |
|
464 | 464 | |
|
465 | 465 | def changegroup(self, nodes, source): |
|
466 | 466 | outgoing = discovery.outgoing( |
|
467 | 467 | self._repo, missingroots=nodes, ancestorsof=self._repo.heads() |
|
468 | 468 | ) |
|
469 | 469 | return changegroup.makechangegroup(self._repo, outgoing, b'01', source) |
|
470 | 470 | |
|
471 | 471 | def changegroupsubset(self, bases, heads, source): |
|
472 | 472 | outgoing = discovery.outgoing( |
|
473 | 473 | self._repo, missingroots=bases, ancestorsof=heads |
|
474 | 474 | ) |
|
475 | 475 | return changegroup.makechangegroup(self._repo, outgoing, b'01', source) |
|
476 | 476 | |
|
477 | 477 | # End of baselegacywirecommands interface. |
|
478 | 478 | |
|
479 | 479 | |
|
480 | 480 | # Functions receiving (ui, features) that extensions can register to impact |
|
481 | 481 | # the ability to load repositories with custom requirements. Only |
|
482 | 482 | # functions defined in loaded extensions are called. |
|
483 | 483 | # |
|
484 | 484 | # The function receives a set of requirement strings that the repository |
|
485 | 485 | # is capable of opening. Functions will typically add elements to the |
|
486 | 486 | # set to reflect that the extension knows how to handle that requirements. |
|
487 | 487 | featuresetupfuncs = set() |
|
488 | 488 | |
|
489 | 489 | |
|
490 | 490 | def _getsharedvfs(hgvfs, requirements): |
|
491 | 491 | """returns the vfs object pointing to root of shared source |
|
492 | 492 | repo for a shared repository |
|
493 | 493 | |
|
494 | 494 | hgvfs is vfs pointing at .hg/ of current repo (shared one) |
|
495 | 495 | requirements is a set of requirements of current repo (shared one) |
|
496 | 496 | """ |
|
497 | 497 | # The ``shared`` or ``relshared`` requirements indicate the |
|
498 | 498 | # store lives in the path contained in the ``.hg/sharedpath`` file. |
|
499 | 499 | # This is an absolute path for ``shared`` and relative to |
|
500 | 500 | # ``.hg/`` for ``relshared``. |
|
501 | 501 | sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') |
|
502 | 502 | if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements: |
|
503 | 503 | sharedpath = util.normpath(hgvfs.join(sharedpath)) |
|
504 | 504 | |
|
505 | 505 | sharedvfs = vfsmod.vfs(sharedpath, realpath=True) |
|
506 | 506 | |
|
507 | 507 | if not sharedvfs.exists(): |
|
508 | 508 | raise error.RepoError( |
|
509 | 509 | _(b'.hg/sharedpath points to nonexistent directory %s') |
|
510 | 510 | % sharedvfs.base |
|
511 | 511 | ) |
|
512 | 512 | return sharedvfs |
|
513 | 513 | |
|
514 | 514 | |
|
515 | 515 | def _readrequires(vfs, allowmissing): |
|
516 | 516 | """reads the require file present at root of this vfs |
|
517 | 517 | and return a set of requirements |
|
518 | 518 | |
|
519 | 519 | If allowmissing is True, we suppress FileNotFoundError if raised""" |
|
520 | 520 | # requires file contains a newline-delimited list of |
|
521 | 521 | # features/capabilities the opener (us) must have in order to use |
|
522 | 522 | # the repository. This file was introduced in Mercurial 0.9.2, |
|
523 | 523 | # which means very old repositories may not have one. We assume |
|
524 | 524 | # a missing file translates to no requirements. |
|
525 | 525 | try: |
|
526 | 526 | return set(vfs.read(b'requires').splitlines()) |
|
527 | 527 | except FileNotFoundError: |
|
528 | 528 | if not allowmissing: |
|
529 | 529 | raise |
|
530 | 530 | return set() |
|
531 | 531 | |
|
532 | 532 | |
|
533 | 533 | def makelocalrepository(baseui, path, intents=None): |
|
534 | 534 | """Create a local repository object. |
|
535 | 535 | |
|
536 | 536 | Given arguments needed to construct a local repository, this function |
|
537 | 537 | performs various early repository loading functionality (such as |
|
538 | 538 | reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that |
|
539 | 539 | the repository can be opened, derives a type suitable for representing |
|
540 | 540 | that repository, and returns an instance of it. |
|
541 | 541 | |
|
542 | 542 | The returned object conforms to the ``repository.completelocalrepository`` |
|
543 | 543 | interface. |
|
544 | 544 | |
|
545 | 545 | The repository type is derived by calling a series of factory functions |
|
546 | 546 | for each aspect/interface of the final repository. These are defined by |
|
547 | 547 | ``REPO_INTERFACES``. |
|
548 | 548 | |
|
549 | 549 | Each factory function is called to produce a type implementing a specific |
|
550 | 550 | interface. The cumulative list of returned types will be combined into a |
|
551 | 551 | new type and that type will be instantiated to represent the local |
|
552 | 552 | repository. |
|
553 | 553 | |
|
554 | 554 | The factory functions each receive various state that may be consulted |
|
555 | 555 | as part of deriving a type. |
|
556 | 556 | |
|
557 | 557 | Extensions should wrap these factory functions to customize repository type |
|
558 | 558 | creation. Note that an extension's wrapped function may be called even if |
|
559 | 559 | that extension is not loaded for the repo being constructed. Extensions |
|
560 | 560 | should check if their ``__name__`` appears in the |
|
561 | 561 | ``extensionmodulenames`` set passed to the factory function and no-op if |
|
562 | 562 | not. |
|
563 | 563 | """ |
|
564 | 564 | ui = baseui.copy() |
|
565 | 565 | # Prevent copying repo configuration. |
|
566 | 566 | ui.copy = baseui.copy |
|
567 | 567 | |
|
568 | 568 | # Working directory VFS rooted at repository root. |
|
569 | 569 | wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
|
570 | 570 | |
|
571 | 571 | # Main VFS for .hg/ directory. |
|
572 | 572 | hgpath = wdirvfs.join(b'.hg') |
|
573 | 573 | hgvfs = vfsmod.vfs(hgpath, cacheaudited=True) |
|
574 | 574 | # Whether this repository is shared one or not |
|
575 | 575 | shared = False |
|
576 | 576 | # If this repository is shared, vfs pointing to shared repo |
|
577 | 577 | sharedvfs = None |
|
578 | 578 | |
|
579 | 579 | # The .hg/ path should exist and should be a directory. All other |
|
580 | 580 | # cases are errors. |
|
581 | 581 | if not hgvfs.isdir(): |
|
582 | 582 | try: |
|
583 | 583 | hgvfs.stat() |
|
584 | 584 | except FileNotFoundError: |
|
585 | 585 | pass |
|
586 | 586 | except ValueError as e: |
|
587 | 587 | # Can be raised on Python 3.8 when path is invalid. |
|
588 | 588 | raise error.Abort( |
|
589 | 589 | _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e)) |
|
590 | 590 | ) |
|
591 | 591 | |
|
592 | 592 | raise error.RepoError(_(b'repository %s not found') % path) |
|
593 | 593 | |
|
594 | 594 | requirements = _readrequires(hgvfs, True) |
|
595 | 595 | shared = ( |
|
596 | 596 | requirementsmod.SHARED_REQUIREMENT in requirements |
|
597 | 597 | or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements |
|
598 | 598 | ) |
|
599 | 599 | storevfs = None |
|
600 | 600 | if shared: |
|
601 | 601 | # This is a shared repo |
|
602 | 602 | sharedvfs = _getsharedvfs(hgvfs, requirements) |
|
603 | 603 | storevfs = vfsmod.vfs(sharedvfs.join(b'store')) |
|
604 | 604 | else: |
|
605 | 605 | storevfs = vfsmod.vfs(hgvfs.join(b'store')) |
|
606 | 606 | |
|
607 | 607 | # if .hg/requires contains the sharesafe requirement, it means |
|
608 | 608 | # there exists a `.hg/store/requires` too and we should read it |
|
609 | 609 | # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement |
|
610 | 610 | # is present. We never write SHARESAFE_REQUIREMENT for a repo if store |
|
611 | 611 | # is not present, refer checkrequirementscompat() for that |
|
612 | 612 | # |
|
613 | 613 | # However, if SHARESAFE_REQUIREMENT is not present, it means that the |
|
614 | 614 | # repository was shared the old way. We check the share source .hg/requires |
|
615 | 615 | # for SHARESAFE_REQUIREMENT to detect whether the current repository needs |
|
616 | 616 | # to be reshared |
|
617 | 617 | hint = _(b"see `hg help config.format.use-share-safe` for more information") |
|
618 | 618 | if requirementsmod.SHARESAFE_REQUIREMENT in requirements: |
|
619 | 619 | |
|
620 | 620 | if ( |
|
621 | 621 | shared |
|
622 | 622 | and requirementsmod.SHARESAFE_REQUIREMENT |
|
623 | 623 | not in _readrequires(sharedvfs, True) |
|
624 | 624 | ): |
|
625 | 625 | mismatch_warn = ui.configbool( |
|
626 | 626 | b'share', b'safe-mismatch.source-not-safe.warn' |
|
627 | 627 | ) |
|
628 | 628 | mismatch_config = ui.config( |
|
629 | 629 | b'share', b'safe-mismatch.source-not-safe' |
|
630 | 630 | ) |
|
631 | 631 | mismatch_verbose_upgrade = ui.configbool( |
|
632 | 632 | b'share', b'safe-mismatch.source-not-safe:verbose-upgrade' |
|
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 | mismatch_verbose_upgrade, |
|
650 | 650 | ) |
|
651 | 651 | elif mismatch_config == b'abort': |
|
652 | 652 | raise error.Abort( |
|
653 | 653 | _(b"share source does not support share-safe requirement"), |
|
654 | 654 | hint=hint, |
|
655 | 655 | ) |
|
656 | 656 | else: |
|
657 | 657 | raise error.Abort( |
|
658 | 658 | _( |
|
659 | 659 | b"share-safe mismatch with source.\nUnrecognized" |
|
660 | 660 | b" value '%s' of `share.safe-mismatch.source-not-safe`" |
|
661 | 661 | b" set." |
|
662 | 662 | ) |
|
663 | 663 | % mismatch_config, |
|
664 | 664 | hint=hint, |
|
665 | 665 | ) |
|
666 | 666 | else: |
|
667 | 667 | requirements |= _readrequires(storevfs, False) |
|
668 | 668 | elif shared: |
|
669 | 669 | sourcerequires = _readrequires(sharedvfs, False) |
|
670 | 670 | if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: |
|
671 | 671 | mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe') |
|
672 | 672 | mismatch_warn = ui.configbool( |
|
673 | 673 | b'share', b'safe-mismatch.source-safe.warn' |
|
674 | 674 | ) |
|
675 | 675 | mismatch_verbose_upgrade = ui.configbool( |
|
676 | 676 | b'share', b'safe-mismatch.source-safe:verbose-upgrade' |
|
677 | 677 | ) |
|
678 | 678 | if mismatch_config in ( |
|
679 | 679 | b'upgrade-allow', |
|
680 | 680 | b'allow', |
|
681 | 681 | b'upgrade-abort', |
|
682 | 682 | ): |
|
683 | 683 | # prevent cyclic import localrepo -> upgrade -> localrepo |
|
684 | 684 | from . import upgrade |
|
685 | 685 | |
|
686 | 686 | upgrade.upgrade_share_to_safe( |
|
687 | 687 | ui, |
|
688 | 688 | hgvfs, |
|
689 | 689 | storevfs, |
|
690 | 690 | requirements, |
|
691 | 691 | mismatch_config, |
|
692 | 692 | mismatch_warn, |
|
693 | 693 | mismatch_verbose_upgrade, |
|
694 | 694 | ) |
|
695 | 695 | elif mismatch_config == b'abort': |
|
696 | 696 | raise error.Abort( |
|
697 | 697 | _( |
|
698 | 698 | b'version mismatch: source uses share-safe' |
|
699 | 699 | b' functionality while the current share does not' |
|
700 | 700 | ), |
|
701 | 701 | hint=hint, |
|
702 | 702 | ) |
|
703 | 703 | else: |
|
704 | 704 | raise error.Abort( |
|
705 | 705 | _( |
|
706 | 706 | b"share-safe mismatch with source.\nUnrecognized" |
|
707 | 707 | b" value '%s' of `share.safe-mismatch.source-safe` set." |
|
708 | 708 | ) |
|
709 | 709 | % mismatch_config, |
|
710 | 710 | hint=hint, |
|
711 | 711 | ) |
|
712 | 712 | |
|
713 | 713 | # The .hg/hgrc file may load extensions or contain config options |
|
714 | 714 | # that influence repository construction. Attempt to load it and |
|
715 | 715 | # process any new extensions that it may have pulled in. |
|
716 | 716 | if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs): |
|
717 | 717 | afterhgrcload(ui, wdirvfs, hgvfs, requirements) |
|
718 | 718 | extensions.loadall(ui) |
|
719 | 719 | extensions.populateui(ui) |
|
720 | 720 | |
|
721 | 721 | # Set of module names of extensions loaded for this repository. |
|
722 | 722 | extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)} |
|
723 | 723 | |
|
724 | 724 | supportedrequirements = gathersupportedrequirements(ui) |
|
725 | 725 | |
|
726 | 726 | # We first validate the requirements are known. |
|
727 | 727 | ensurerequirementsrecognized(requirements, supportedrequirements) |
|
728 | 728 | |
|
729 | 729 | # Then we validate that the known set is reasonable to use together. |
|
730 | 730 | ensurerequirementscompatible(ui, requirements) |
|
731 | 731 | |
|
732 | 732 | # TODO there are unhandled edge cases related to opening repositories with |
|
733 | 733 | # shared storage. If storage is shared, we should also test for requirements |
|
734 | 734 | # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in |
|
735 | 735 | # that repo, as that repo may load extensions needed to open it. This is a |
|
736 | 736 | # bit complicated because we don't want the other hgrc to overwrite settings |
|
737 | 737 | # in this hgrc. |
|
738 | 738 | # |
|
739 | 739 | # This bug is somewhat mitigated by the fact that we copy the .hg/requires |
|
740 | 740 | # file when sharing repos. But if a requirement is added after the share is |
|
741 | 741 | # performed, thereby introducing a new requirement for the opener, we may |
|
742 | 742 | # will not see that and could encounter a run-time error interacting with |
|
743 | 743 | # that shared store since it has an unknown-to-us requirement. |
|
744 | 744 | |
|
745 | 745 | # At this point, we know we should be capable of opening the repository. |
|
746 | 746 | # Now get on with doing that. |
|
747 | 747 | |
|
748 | 748 | features = set() |
|
749 | 749 | |
|
750 | 750 | # The "store" part of the repository holds versioned data. How it is |
|
751 | 751 | # accessed is determined by various requirements. If `shared` or |
|
752 | 752 | # `relshared` requirements are present, this indicates current repository |
|
753 | 753 | # is a share and store exists in path mentioned in `.hg/sharedpath` |
|
754 | 754 | if shared: |
|
755 | 755 | storebasepath = sharedvfs.base |
|
756 | 756 | cachepath = sharedvfs.join(b'cache') |
|
757 | 757 | features.add(repository.REPO_FEATURE_SHARED_STORAGE) |
|
758 | 758 | else: |
|
759 | 759 | storebasepath = hgvfs.base |
|
760 | 760 | cachepath = hgvfs.join(b'cache') |
|
761 | 761 | wcachepath = hgvfs.join(b'wcache') |
|
762 | 762 | |
|
763 | 763 | # The store has changed over time and the exact layout is dictated by |
|
764 | 764 | # requirements. The store interface abstracts differences across all |
|
765 | 765 | # of them. |
|
766 | 766 | store = makestore( |
|
767 | 767 | requirements, |
|
768 | 768 | storebasepath, |
|
769 | 769 | lambda base: vfsmod.vfs(base, cacheaudited=True), |
|
770 | 770 | ) |
|
771 | 771 | hgvfs.createmode = store.createmode |
|
772 | 772 | |
|
773 | 773 | storevfs = store.vfs |
|
774 | 774 | storevfs.options = resolvestorevfsoptions(ui, requirements, features) |
|
775 | 775 | |
|
776 | 776 | if ( |
|
777 | 777 | requirementsmod.REVLOGV2_REQUIREMENT in requirements |
|
778 | 778 | or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements |
|
779 | 779 | ): |
|
780 | 780 | features.add(repository.REPO_FEATURE_SIDE_DATA) |
|
781 | 781 | # the revlogv2 docket introduced race condition that we need to fix |
|
782 | 782 | features.discard(repository.REPO_FEATURE_STREAM_CLONE) |
|
783 | 783 | |
|
784 | 784 | # The cache vfs is used to manage cache files. |
|
785 | 785 | cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) |
|
786 | 786 | cachevfs.createmode = store.createmode |
|
787 | 787 | # The cache vfs is used to manage cache files related to the working copy |
|
788 | 788 | wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True) |
|
789 | 789 | wcachevfs.createmode = store.createmode |
|
790 | 790 | |
|
791 | 791 | # Now resolve the type for the repository object. We do this by repeatedly |
|
792 | 792 | # calling a factory function to produces types for specific aspects of the |
|
793 | 793 | # repo's operation. The aggregate returned types are used as base classes |
|
794 | 794 | # for a dynamically-derived type, which will represent our new repository. |
|
795 | 795 | |
|
796 | 796 | bases = [] |
|
797 | 797 | extrastate = {} |
|
798 | 798 | |
|
799 | 799 | for iface, fn in REPO_INTERFACES: |
|
800 | 800 | # We pass all potentially useful state to give extensions tons of |
|
801 | 801 | # flexibility. |
|
802 | 802 | typ = fn()( |
|
803 | 803 | ui=ui, |
|
804 | 804 | intents=intents, |
|
805 | 805 | requirements=requirements, |
|
806 | 806 | features=features, |
|
807 | 807 | wdirvfs=wdirvfs, |
|
808 | 808 | hgvfs=hgvfs, |
|
809 | 809 | store=store, |
|
810 | 810 | storevfs=storevfs, |
|
811 | 811 | storeoptions=storevfs.options, |
|
812 | 812 | cachevfs=cachevfs, |
|
813 | 813 | wcachevfs=wcachevfs, |
|
814 | 814 | extensionmodulenames=extensionmodulenames, |
|
815 | 815 | extrastate=extrastate, |
|
816 | 816 | baseclasses=bases, |
|
817 | 817 | ) |
|
818 | 818 | |
|
819 | 819 | if not isinstance(typ, type): |
|
820 | 820 | raise error.ProgrammingError( |
|
821 | 821 | b'unable to construct type for %s' % iface |
|
822 | 822 | ) |
|
823 | 823 | |
|
824 | 824 | bases.append(typ) |
|
825 | 825 | |
|
826 | 826 | # type() allows you to use characters in type names that wouldn't be |
|
827 | 827 | # recognized as Python symbols in source code. We abuse that to add |
|
828 | 828 | # rich information about our constructed repo. |
|
829 | 829 | name = pycompat.sysstr( |
|
830 | 830 | b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements))) |
|
831 | 831 | ) |
|
832 | 832 | |
|
833 | 833 | cls = type(name, tuple(bases), {}) |
|
834 | 834 | |
|
835 | 835 | return cls( |
|
836 | 836 | baseui=baseui, |
|
837 | 837 | ui=ui, |
|
838 | 838 | origroot=path, |
|
839 | 839 | wdirvfs=wdirvfs, |
|
840 | 840 | hgvfs=hgvfs, |
|
841 | 841 | requirements=requirements, |
|
842 | 842 | supportedrequirements=supportedrequirements, |
|
843 | 843 | sharedpath=storebasepath, |
|
844 | 844 | store=store, |
|
845 | 845 | cachevfs=cachevfs, |
|
846 | 846 | wcachevfs=wcachevfs, |
|
847 | 847 | features=features, |
|
848 | 848 | intents=intents, |
|
849 | 849 | ) |
|
850 | 850 | |
|
851 | 851 | |
|
852 | 852 | def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None): |
|
853 | 853 | """Load hgrc files/content into a ui instance. |
|
854 | 854 | |
|
855 | 855 | This is called during repository opening to load any additional |
|
856 | 856 | config files or settings relevant to the current repository. |
|
857 | 857 | |
|
858 | 858 | Returns a bool indicating whether any additional configs were loaded. |
|
859 | 859 | |
|
860 | 860 | Extensions should monkeypatch this function to modify how per-repo |
|
861 | 861 | configs are loaded. For example, an extension may wish to pull in |
|
862 | 862 | configs from alternate files or sources. |
|
863 | 863 | |
|
864 | 864 | sharedvfs is vfs object pointing to source repo if the current one is a |
|
865 | 865 | shared one |
|
866 | 866 | """ |
|
867 | 867 | if not rcutil.use_repo_hgrc(): |
|
868 | 868 | return False |
|
869 | 869 | |
|
870 | 870 | ret = False |
|
871 | 871 | # first load config from shared source if we has to |
|
872 | 872 | if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs: |
|
873 | 873 | try: |
|
874 | 874 | ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base) |
|
875 | 875 | ret = True |
|
876 | 876 | except IOError: |
|
877 | 877 | pass |
|
878 | 878 | |
|
879 | 879 | try: |
|
880 | 880 | ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base) |
|
881 | 881 | ret = True |
|
882 | 882 | except IOError: |
|
883 | 883 | pass |
|
884 | 884 | |
|
885 | 885 | try: |
|
886 | 886 | ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base) |
|
887 | 887 | ret = True |
|
888 | 888 | except IOError: |
|
889 | 889 | pass |
|
890 | 890 | |
|
891 | 891 | return ret |
|
892 | 892 | |
|
893 | 893 | |
|
894 | 894 | def afterhgrcload(ui, wdirvfs, hgvfs, requirements): |
|
895 | 895 | """Perform additional actions after .hg/hgrc is loaded. |
|
896 | 896 | |
|
897 | 897 | This function is called during repository loading immediately after |
|
898 | 898 | the .hg/hgrc file is loaded and before per-repo extensions are loaded. |
|
899 | 899 | |
|
900 | 900 | The function can be used to validate configs, automatically add |
|
901 | 901 | options (including extensions) based on requirements, etc. |
|
902 | 902 | """ |
|
903 | 903 | |
|
904 | 904 | # Map of requirements to list of extensions to load automatically when |
|
905 | 905 | # requirement is present. |
|
906 | 906 | autoextensions = { |
|
907 | 907 | b'git': [b'git'], |
|
908 | 908 | b'largefiles': [b'largefiles'], |
|
909 | 909 | b'lfs': [b'lfs'], |
|
910 | 910 | } |
|
911 | 911 | |
|
912 | 912 | for requirement, names in sorted(autoextensions.items()): |
|
913 | 913 | if requirement not in requirements: |
|
914 | 914 | continue |
|
915 | 915 | |
|
916 | 916 | for name in names: |
|
917 | 917 | if not ui.hasconfig(b'extensions', name): |
|
918 | 918 | ui.setconfig(b'extensions', name, b'', source=b'autoload') |
|
919 | 919 | |
|
920 | 920 | |
|
921 | 921 | def gathersupportedrequirements(ui): |
|
922 | 922 | """Determine the complete set of recognized requirements.""" |
|
923 | 923 | # Start with all requirements supported by this file. |
|
924 | 924 | supported = set(localrepository._basesupported) |
|
925 | 925 | |
|
926 | 926 | # Execute ``featuresetupfuncs`` entries if they belong to an extension |
|
927 | 927 | # relevant to this ui instance. |
|
928 | 928 | modules = {m.__name__ for n, m in extensions.extensions(ui)} |
|
929 | 929 | |
|
930 | 930 | for fn in featuresetupfuncs: |
|
931 | 931 | if fn.__module__ in modules: |
|
932 | 932 | fn(ui, supported) |
|
933 | 933 | |
|
934 | 934 | # Add derived requirements from registered compression engines. |
|
935 | 935 | for name in util.compengines: |
|
936 | 936 | engine = util.compengines[name] |
|
937 | 937 | if engine.available() and engine.revlogheader(): |
|
938 | 938 | supported.add(b'exp-compression-%s' % name) |
|
939 | 939 | if engine.name() == b'zstd': |
|
940 | 940 | supported.add(requirementsmod.REVLOG_COMPRESSION_ZSTD) |
|
941 | 941 | |
|
942 | 942 | return supported |
|
943 | 943 | |
|
944 | 944 | |
|
945 | 945 | def ensurerequirementsrecognized(requirements, supported): |
|
946 | 946 | """Validate that a set of local requirements is recognized. |
|
947 | 947 | |
|
948 | 948 | Receives a set of requirements. Raises an ``error.RepoError`` if there |
|
949 | 949 | exists any requirement in that set that currently loaded code doesn't |
|
950 | 950 | recognize. |
|
951 | 951 | |
|
952 | 952 | Returns a set of supported requirements. |
|
953 | 953 | """ |
|
954 | 954 | missing = set() |
|
955 | 955 | |
|
956 | 956 | for requirement in requirements: |
|
957 | 957 | if requirement in supported: |
|
958 | 958 | continue |
|
959 | 959 | |
|
960 | 960 | if not requirement or not requirement[0:1].isalnum(): |
|
961 | 961 | raise error.RequirementError(_(b'.hg/requires file is corrupt')) |
|
962 | 962 | |
|
963 | 963 | missing.add(requirement) |
|
964 | 964 | |
|
965 | 965 | if missing: |
|
966 | 966 | raise error.RequirementError( |
|
967 | 967 | _(b'repository requires features unknown to this Mercurial: %s') |
|
968 | 968 | % b' '.join(sorted(missing)), |
|
969 | 969 | hint=_( |
|
970 | 970 | b'see https://mercurial-scm.org/wiki/MissingRequirement ' |
|
971 | 971 | b'for more information' |
|
972 | 972 | ), |
|
973 | 973 | ) |
|
974 | 974 | |
|
975 | 975 | |
|
976 | 976 | def ensurerequirementscompatible(ui, requirements): |
|
977 | 977 | """Validates that a set of recognized requirements is mutually compatible. |
|
978 | 978 | |
|
979 | 979 | Some requirements may not be compatible with others or require |
|
980 | 980 | config options that aren't enabled. This function is called during |
|
981 | 981 | repository opening to ensure that the set of requirements needed |
|
982 | 982 | to open a repository is sane and compatible with config options. |
|
983 | 983 | |
|
984 | 984 | Extensions can monkeypatch this function to perform additional |
|
985 | 985 | checking. |
|
986 | 986 | |
|
987 | 987 | ``error.RepoError`` should be raised on failure. |
|
988 | 988 | """ |
|
989 | 989 | if ( |
|
990 | 990 | requirementsmod.SPARSE_REQUIREMENT in requirements |
|
991 | 991 | and not sparse.enabled |
|
992 | 992 | ): |
|
993 | 993 | raise error.RepoError( |
|
994 | 994 | _( |
|
995 | 995 | b'repository is using sparse feature but ' |
|
996 | 996 | b'sparse is not enabled; enable the ' |
|
997 | 997 | b'"sparse" extensions to access' |
|
998 | 998 | ) |
|
999 | 999 | ) |
|
1000 | 1000 | |
|
1001 | 1001 | |
|
1002 | 1002 | def makestore(requirements, path, vfstype): |
|
1003 | 1003 | """Construct a storage object for a repository.""" |
|
1004 | 1004 | if requirementsmod.STORE_REQUIREMENT in requirements: |
|
1005 | 1005 | if requirementsmod.FNCACHE_REQUIREMENT in requirements: |
|
1006 | 1006 | dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements |
|
1007 | 1007 | return storemod.fncachestore(path, vfstype, dotencode) |
|
1008 | 1008 | |
|
1009 | 1009 | return storemod.encodedstore(path, vfstype) |
|
1010 | 1010 | |
|
1011 | 1011 | return storemod.basicstore(path, vfstype) |
|
1012 | 1012 | |
|
1013 | 1013 | |
|
1014 | 1014 | def resolvestorevfsoptions(ui, requirements, features): |
|
1015 | 1015 | """Resolve the options to pass to the store vfs opener. |
|
1016 | 1016 | |
|
1017 | 1017 | The returned dict is used to influence behavior of the storage layer. |
|
1018 | 1018 | """ |
|
1019 | 1019 | options = {} |
|
1020 | 1020 | |
|
1021 | 1021 | if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements: |
|
1022 | 1022 | options[b'treemanifest'] = True |
|
1023 | 1023 | |
|
1024 | 1024 | # experimental config: format.manifestcachesize |
|
1025 | 1025 | manifestcachesize = ui.configint(b'format', b'manifestcachesize') |
|
1026 | 1026 | if manifestcachesize is not None: |
|
1027 | 1027 | options[b'manifestcachesize'] = manifestcachesize |
|
1028 | 1028 | |
|
1029 | 1029 | # In the absence of another requirement superseding a revlog-related |
|
1030 | 1030 | # requirement, we have to assume the repo is using revlog version 0. |
|
1031 | 1031 | # This revlog format is super old and we don't bother trying to parse |
|
1032 | 1032 | # opener options for it because those options wouldn't do anything |
|
1033 | 1033 | # meaningful on such old repos. |
|
1034 | 1034 | if ( |
|
1035 | 1035 | requirementsmod.REVLOGV1_REQUIREMENT in requirements |
|
1036 | 1036 | or requirementsmod.REVLOGV2_REQUIREMENT in requirements |
|
1037 | 1037 | ): |
|
1038 | 1038 | options.update(resolverevlogstorevfsoptions(ui, requirements, features)) |
|
1039 | 1039 | else: # explicitly mark repo as using revlogv0 |
|
1040 | 1040 | options[b'revlogv0'] = True |
|
1041 | 1041 | |
|
1042 | 1042 | if requirementsmod.COPIESSDC_REQUIREMENT in requirements: |
|
1043 | 1043 | options[b'copies-storage'] = b'changeset-sidedata' |
|
1044 | 1044 | else: |
|
1045 | 1045 | writecopiesto = ui.config(b'experimental', b'copies.write-to') |
|
1046 | 1046 | copiesextramode = (b'changeset-only', b'compatibility') |
|
1047 | 1047 | if writecopiesto in copiesextramode: |
|
1048 | 1048 | options[b'copies-storage'] = b'extra' |
|
1049 | 1049 | |
|
1050 | 1050 | return options |
|
1051 | 1051 | |
|
1052 | 1052 | |
|
1053 | 1053 | def resolverevlogstorevfsoptions(ui, requirements, features): |
|
1054 | 1054 | """Resolve opener options specific to revlogs.""" |
|
1055 | 1055 | |
|
1056 | 1056 | options = {} |
|
1057 | 1057 | options[b'flagprocessors'] = {} |
|
1058 | 1058 | |
|
1059 | 1059 | if requirementsmod.REVLOGV1_REQUIREMENT in requirements: |
|
1060 | 1060 | options[b'revlogv1'] = True |
|
1061 | 1061 | if requirementsmod.REVLOGV2_REQUIREMENT in requirements: |
|
1062 | 1062 | options[b'revlogv2'] = True |
|
1063 | 1063 | if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements: |
|
1064 | 1064 | options[b'changelogv2'] = True |
|
1065 | 1065 | |
|
1066 | 1066 | if requirementsmod.GENERALDELTA_REQUIREMENT in requirements: |
|
1067 | 1067 | options[b'generaldelta'] = True |
|
1068 | 1068 | |
|
1069 | 1069 | # experimental config: format.chunkcachesize |
|
1070 | 1070 | chunkcachesize = ui.configint(b'format', b'chunkcachesize') |
|
1071 | 1071 | if chunkcachesize is not None: |
|
1072 | 1072 | options[b'chunkcachesize'] = chunkcachesize |
|
1073 | 1073 | |
|
1074 | 1074 | deltabothparents = ui.configbool( |
|
1075 | 1075 | b'storage', b'revlog.optimize-delta-parent-choice' |
|
1076 | 1076 | ) |
|
1077 | 1077 | options[b'deltabothparents'] = deltabothparents |
|
1078 | 1078 | options[b'debug-delta'] = ui.configbool(b'debug', b'revlog.debug-delta') |
|
1079 | 1079 | |
|
1080 | 1080 | issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming') |
|
1081 | 1081 | options[b'issue6528.fix-incoming'] = issue6528 |
|
1082 | 1082 | |
|
1083 | 1083 | lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta') |
|
1084 | 1084 | lazydeltabase = False |
|
1085 | 1085 | if lazydelta: |
|
1086 | 1086 | lazydeltabase = ui.configbool( |
|
1087 | 1087 | b'storage', b'revlog.reuse-external-delta-parent' |
|
1088 | 1088 | ) |
|
1089 | 1089 | if lazydeltabase is None: |
|
1090 | 1090 | lazydeltabase = not scmutil.gddeltaconfig(ui) |
|
1091 | 1091 | options[b'lazydelta'] = lazydelta |
|
1092 | 1092 | options[b'lazydeltabase'] = lazydeltabase |
|
1093 | 1093 | |
|
1094 | 1094 | chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan') |
|
1095 | 1095 | if 0 <= chainspan: |
|
1096 | 1096 | options[b'maxdeltachainspan'] = chainspan |
|
1097 | 1097 | |
|
1098 | 1098 | mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold') |
|
1099 | 1099 | if mmapindexthreshold is not None: |
|
1100 | 1100 | options[b'mmapindexthreshold'] = mmapindexthreshold |
|
1101 | 1101 | |
|
1102 | 1102 | withsparseread = ui.configbool(b'experimental', b'sparse-read') |
|
1103 | 1103 | srdensitythres = float( |
|
1104 | 1104 | ui.config(b'experimental', b'sparse-read.density-threshold') |
|
1105 | 1105 | ) |
|
1106 | 1106 | srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size') |
|
1107 | 1107 | options[b'with-sparse-read'] = withsparseread |
|
1108 | 1108 | options[b'sparse-read-density-threshold'] = srdensitythres |
|
1109 | 1109 | options[b'sparse-read-min-gap-size'] = srmingapsize |
|
1110 | 1110 | |
|
1111 | 1111 | sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements |
|
1112 | 1112 | options[b'sparse-revlog'] = sparserevlog |
|
1113 | 1113 | if sparserevlog: |
|
1114 | 1114 | options[b'generaldelta'] = True |
|
1115 | 1115 | |
|
1116 | 1116 | maxchainlen = None |
|
1117 | 1117 | if sparserevlog: |
|
1118 | 1118 | maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH |
|
1119 | 1119 | # experimental config: format.maxchainlen |
|
1120 | 1120 | maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen) |
|
1121 | 1121 | if maxchainlen is not None: |
|
1122 | 1122 | options[b'maxchainlen'] = maxchainlen |
|
1123 | 1123 | |
|
1124 | 1124 | for r in requirements: |
|
1125 | 1125 | # we allow multiple compression engine requirement to co-exist because |
|
1126 | 1126 | # strickly speaking, revlog seems to support mixed compression style. |
|
1127 | 1127 | # |
|
1128 | 1128 | # The compression used for new entries will be "the last one" |
|
1129 | 1129 | prefix = r.startswith |
|
1130 | 1130 | if prefix(b'revlog-compression-') or prefix(b'exp-compression-'): |
|
1131 | 1131 | options[b'compengine'] = r.split(b'-', 2)[2] |
|
1132 | 1132 | |
|
1133 | 1133 | options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level') |
|
1134 | 1134 | if options[b'zlib.level'] is not None: |
|
1135 | 1135 | if not (0 <= options[b'zlib.level'] <= 9): |
|
1136 | 1136 | msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d') |
|
1137 | 1137 | raise error.Abort(msg % options[b'zlib.level']) |
|
1138 | 1138 | options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level') |
|
1139 | 1139 | if options[b'zstd.level'] is not None: |
|
1140 | 1140 | if not (0 <= options[b'zstd.level'] <= 22): |
|
1141 | 1141 | msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d') |
|
1142 | 1142 | raise error.Abort(msg % options[b'zstd.level']) |
|
1143 | 1143 | |
|
1144 | 1144 | if requirementsmod.NARROW_REQUIREMENT in requirements: |
|
1145 | 1145 | options[b'enableellipsis'] = True |
|
1146 | 1146 | |
|
1147 | 1147 | if ui.configbool(b'experimental', b'rust.index'): |
|
1148 | 1148 | options[b'rust.index'] = True |
|
1149 | 1149 | if requirementsmod.NODEMAP_REQUIREMENT in requirements: |
|
1150 | 1150 | slow_path = ui.config( |
|
1151 | 1151 | b'storage', b'revlog.persistent-nodemap.slow-path' |
|
1152 | 1152 | ) |
|
1153 | 1153 | if slow_path not in (b'allow', b'warn', b'abort'): |
|
1154 | 1154 | default = ui.config_default( |
|
1155 | 1155 | b'storage', b'revlog.persistent-nodemap.slow-path' |
|
1156 | 1156 | ) |
|
1157 | 1157 | msg = _( |
|
1158 | 1158 | b'unknown value for config ' |
|
1159 | 1159 | b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n' |
|
1160 | 1160 | ) |
|
1161 | 1161 | ui.warn(msg % slow_path) |
|
1162 | 1162 | if not ui.quiet: |
|
1163 | 1163 | ui.warn(_(b'falling back to default value: %s\n') % default) |
|
1164 | 1164 | slow_path = default |
|
1165 | 1165 | |
|
1166 | 1166 | msg = _( |
|
1167 | 1167 | b"accessing `persistent-nodemap` repository without associated " |
|
1168 | 1168 | b"fast implementation." |
|
1169 | 1169 | ) |
|
1170 | 1170 | hint = _( |
|
1171 | 1171 | b"check `hg help config.format.use-persistent-nodemap` " |
|
1172 | 1172 | b"for details" |
|
1173 | 1173 | ) |
|
1174 | 1174 | if not revlog.HAS_FAST_PERSISTENT_NODEMAP: |
|
1175 | 1175 | if slow_path == b'warn': |
|
1176 | 1176 | msg = b"warning: " + msg + b'\n' |
|
1177 | 1177 | ui.warn(msg) |
|
1178 | 1178 | if not ui.quiet: |
|
1179 | 1179 | hint = b'(' + hint + b')\n' |
|
1180 | 1180 | ui.warn(hint) |
|
1181 | 1181 | if slow_path == b'abort': |
|
1182 | 1182 | raise error.Abort(msg, hint=hint) |
|
1183 | 1183 | options[b'persistent-nodemap'] = True |
|
1184 | 1184 | if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements: |
|
1185 | 1185 | slow_path = ui.config(b'storage', b'dirstate-v2.slow-path') |
|
1186 | 1186 | if slow_path not in (b'allow', b'warn', b'abort'): |
|
1187 | 1187 | default = ui.config_default(b'storage', b'dirstate-v2.slow-path') |
|
1188 | 1188 | msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n') |
|
1189 | 1189 | ui.warn(msg % slow_path) |
|
1190 | 1190 | if not ui.quiet: |
|
1191 | 1191 | ui.warn(_(b'falling back to default value: %s\n') % default) |
|
1192 | 1192 | slow_path = default |
|
1193 | 1193 | |
|
1194 | 1194 | msg = _( |
|
1195 | 1195 | b"accessing `dirstate-v2` repository without associated " |
|
1196 | 1196 | b"fast implementation." |
|
1197 | 1197 | ) |
|
1198 | 1198 | hint = _( |
|
1199 | 1199 | b"check `hg help config.format.use-dirstate-v2` " b"for details" |
|
1200 | 1200 | ) |
|
1201 | 1201 | if not dirstate.HAS_FAST_DIRSTATE_V2: |
|
1202 | 1202 | if slow_path == b'warn': |
|
1203 | 1203 | msg = b"warning: " + msg + b'\n' |
|
1204 | 1204 | ui.warn(msg) |
|
1205 | 1205 | if not ui.quiet: |
|
1206 | 1206 | hint = b'(' + hint + b')\n' |
|
1207 | 1207 | ui.warn(hint) |
|
1208 | 1208 | if slow_path == b'abort': |
|
1209 | 1209 | raise error.Abort(msg, hint=hint) |
|
1210 | 1210 | if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'): |
|
1211 | 1211 | options[b'persistent-nodemap.mmap'] = True |
|
1212 | 1212 | if ui.configbool(b'devel', b'persistent-nodemap'): |
|
1213 | 1213 | options[b'devel-force-nodemap'] = True |
|
1214 | 1214 | |
|
1215 | 1215 | return options |
|
1216 | 1216 | |
|
1217 | 1217 | |
|
1218 | 1218 | def makemain(**kwargs): |
|
1219 | 1219 | """Produce a type conforming to ``ilocalrepositorymain``.""" |
|
1220 | 1220 | return localrepository |
|
1221 | 1221 | |
|
1222 | 1222 | |
|
1223 | 1223 | @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) |
|
1224 | 1224 | class revlogfilestorage: |
|
1225 | 1225 | """File storage when using revlogs.""" |
|
1226 | 1226 | |
|
1227 | 1227 | def file(self, path): |
|
1228 | 1228 | if path.startswith(b'/'): |
|
1229 | 1229 | path = path[1:] |
|
1230 | 1230 | |
|
1231 | 1231 | return filelog.filelog(self.svfs, path) |
|
1232 | 1232 | |
|
1233 | 1233 | |
|
1234 | 1234 | @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) |
|
1235 | 1235 | class revlognarrowfilestorage: |
|
1236 | 1236 | """File storage when using revlogs and narrow files.""" |
|
1237 | 1237 | |
|
1238 | 1238 | def file(self, path): |
|
1239 | 1239 | if path.startswith(b'/'): |
|
1240 | 1240 | path = path[1:] |
|
1241 | 1241 | |
|
1242 | 1242 | return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch) |
|
1243 | 1243 | |
|
1244 | 1244 | |
|
1245 | 1245 | def makefilestorage(requirements, features, **kwargs): |
|
1246 | 1246 | """Produce a type conforming to ``ilocalrepositoryfilestorage``.""" |
|
1247 | 1247 | features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE) |
|
1248 | 1248 | features.add(repository.REPO_FEATURE_STREAM_CLONE) |
|
1249 | 1249 | |
|
1250 | 1250 | if requirementsmod.NARROW_REQUIREMENT in requirements: |
|
1251 | 1251 | return revlognarrowfilestorage |
|
1252 | 1252 | else: |
|
1253 | 1253 | return revlogfilestorage |
|
1254 | 1254 | |
|
1255 | 1255 | |
|
1256 | 1256 | # List of repository interfaces and factory functions for them. Each |
|
1257 | 1257 | # will be called in order during ``makelocalrepository()`` to iteratively |
|
1258 | 1258 | # derive the final type for a local repository instance. We capture the |
|
1259 | 1259 | # function as a lambda so we don't hold a reference and the module-level |
|
1260 | 1260 | # functions can be wrapped. |
|
1261 | 1261 | REPO_INTERFACES = [ |
|
1262 | 1262 | (repository.ilocalrepositorymain, lambda: makemain), |
|
1263 | 1263 | (repository.ilocalrepositoryfilestorage, lambda: makefilestorage), |
|
1264 | 1264 | ] |
|
1265 | 1265 | |
|
1266 | 1266 | |
|
1267 | 1267 | @interfaceutil.implementer(repository.ilocalrepositorymain) |
|
1268 | 1268 | class localrepository: |
|
1269 | 1269 | """Main class for representing local repositories. |
|
1270 | 1270 | |
|
1271 | 1271 | All local repositories are instances of this class. |
|
1272 | 1272 | |
|
1273 | 1273 | Constructed on its own, instances of this class are not usable as |
|
1274 | 1274 | repository objects. To obtain a usable repository object, call |
|
1275 | 1275 | ``hg.repository()``, ``localrepo.instance()``, or |
|
1276 | 1276 | ``localrepo.makelocalrepository()``. The latter is the lowest-level. |
|
1277 | 1277 | ``instance()`` adds support for creating new repositories. |
|
1278 | 1278 | ``hg.repository()`` adds more extension integration, including calling |
|
1279 | 1279 | ``reposetup()``. Generally speaking, ``hg.repository()`` should be |
|
1280 | 1280 | used. |
|
1281 | 1281 | """ |
|
1282 | 1282 | |
|
1283 | 1283 | _basesupported = { |
|
1284 | requirementsmod.ARCHIVED_PHASE_REQUIREMENT, | |
|
1284 | 1285 | requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT, |
|
1285 | 1286 | requirementsmod.CHANGELOGV2_REQUIREMENT, |
|
1286 | 1287 | requirementsmod.COPIESSDC_REQUIREMENT, |
|
1287 | 1288 | requirementsmod.DIRSTATE_TRACKED_HINT_V1, |
|
1288 | 1289 | requirementsmod.DIRSTATE_V2_REQUIREMENT, |
|
1289 | 1290 | requirementsmod.DOTENCODE_REQUIREMENT, |
|
1290 | 1291 | requirementsmod.FNCACHE_REQUIREMENT, |
|
1291 | 1292 | requirementsmod.GENERALDELTA_REQUIREMENT, |
|
1292 | 1293 | requirementsmod.INTERNAL_PHASE_REQUIREMENT, |
|
1293 | 1294 | requirementsmod.NODEMAP_REQUIREMENT, |
|
1294 | 1295 | requirementsmod.RELATIVE_SHARED_REQUIREMENT, |
|
1295 | 1296 | requirementsmod.REVLOGV1_REQUIREMENT, |
|
1296 | 1297 | requirementsmod.REVLOGV2_REQUIREMENT, |
|
1297 | 1298 | requirementsmod.SHARED_REQUIREMENT, |
|
1298 | 1299 | requirementsmod.SHARESAFE_REQUIREMENT, |
|
1299 | 1300 | requirementsmod.SPARSE_REQUIREMENT, |
|
1300 | 1301 | requirementsmod.SPARSEREVLOG_REQUIREMENT, |
|
1301 | 1302 | requirementsmod.STORE_REQUIREMENT, |
|
1302 | 1303 | requirementsmod.TREEMANIFEST_REQUIREMENT, |
|
1303 | 1304 | } |
|
1304 | 1305 | |
|
1305 | 1306 | # list of prefix for file which can be written without 'wlock' |
|
1306 | 1307 | # Extensions should extend this list when needed |
|
1307 | 1308 | _wlockfreeprefix = { |
|
1308 | 1309 | # We migh consider requiring 'wlock' for the next |
|
1309 | 1310 | # two, but pretty much all the existing code assume |
|
1310 | 1311 | # wlock is not needed so we keep them excluded for |
|
1311 | 1312 | # now. |
|
1312 | 1313 | b'hgrc', |
|
1313 | 1314 | b'requires', |
|
1314 | 1315 | # XXX cache is a complicatged business someone |
|
1315 | 1316 | # should investigate this in depth at some point |
|
1316 | 1317 | b'cache/', |
|
1317 | 1318 | # XXX shouldn't be dirstate covered by the wlock? |
|
1318 | 1319 | b'dirstate', |
|
1319 | 1320 | # XXX bisect was still a bit too messy at the time |
|
1320 | 1321 | # this changeset was introduced. Someone should fix |
|
1321 | 1322 | # the remainig bit and drop this line |
|
1322 | 1323 | b'bisect.state', |
|
1323 | 1324 | } |
|
1324 | 1325 | |
|
1325 | 1326 | def __init__( |
|
1326 | 1327 | self, |
|
1327 | 1328 | baseui, |
|
1328 | 1329 | ui, |
|
1329 | 1330 | origroot, |
|
1330 | 1331 | wdirvfs, |
|
1331 | 1332 | hgvfs, |
|
1332 | 1333 | requirements, |
|
1333 | 1334 | supportedrequirements, |
|
1334 | 1335 | sharedpath, |
|
1335 | 1336 | store, |
|
1336 | 1337 | cachevfs, |
|
1337 | 1338 | wcachevfs, |
|
1338 | 1339 | features, |
|
1339 | 1340 | intents=None, |
|
1340 | 1341 | ): |
|
1341 | 1342 | """Create a new local repository instance. |
|
1342 | 1343 | |
|
1343 | 1344 | Most callers should use ``hg.repository()``, ``localrepo.instance()``, |
|
1344 | 1345 | or ``localrepo.makelocalrepository()`` for obtaining a new repository |
|
1345 | 1346 | object. |
|
1346 | 1347 | |
|
1347 | 1348 | Arguments: |
|
1348 | 1349 | |
|
1349 | 1350 | baseui |
|
1350 | 1351 | ``ui.ui`` instance that ``ui`` argument was based off of. |
|
1351 | 1352 | |
|
1352 | 1353 | ui |
|
1353 | 1354 | ``ui.ui`` instance for use by the repository. |
|
1354 | 1355 | |
|
1355 | 1356 | origroot |
|
1356 | 1357 | ``bytes`` path to working directory root of this repository. |
|
1357 | 1358 | |
|
1358 | 1359 | wdirvfs |
|
1359 | 1360 | ``vfs.vfs`` rooted at the working directory. |
|
1360 | 1361 | |
|
1361 | 1362 | hgvfs |
|
1362 | 1363 | ``vfs.vfs`` rooted at .hg/ |
|
1363 | 1364 | |
|
1364 | 1365 | requirements |
|
1365 | 1366 | ``set`` of bytestrings representing repository opening requirements. |
|
1366 | 1367 | |
|
1367 | 1368 | supportedrequirements |
|
1368 | 1369 | ``set`` of bytestrings representing repository requirements that we |
|
1369 | 1370 | know how to open. May be a supetset of ``requirements``. |
|
1370 | 1371 | |
|
1371 | 1372 | sharedpath |
|
1372 | 1373 | ``bytes`` Defining path to storage base directory. Points to a |
|
1373 | 1374 | ``.hg/`` directory somewhere. |
|
1374 | 1375 | |
|
1375 | 1376 | store |
|
1376 | 1377 | ``store.basicstore`` (or derived) instance providing access to |
|
1377 | 1378 | versioned storage. |
|
1378 | 1379 | |
|
1379 | 1380 | cachevfs |
|
1380 | 1381 | ``vfs.vfs`` used for cache files. |
|
1381 | 1382 | |
|
1382 | 1383 | wcachevfs |
|
1383 | 1384 | ``vfs.vfs`` used for cache files related to the working copy. |
|
1384 | 1385 | |
|
1385 | 1386 | features |
|
1386 | 1387 | ``set`` of bytestrings defining features/capabilities of this |
|
1387 | 1388 | instance. |
|
1388 | 1389 | |
|
1389 | 1390 | intents |
|
1390 | 1391 | ``set`` of system strings indicating what this repo will be used |
|
1391 | 1392 | for. |
|
1392 | 1393 | """ |
|
1393 | 1394 | self.baseui = baseui |
|
1394 | 1395 | self.ui = ui |
|
1395 | 1396 | self.origroot = origroot |
|
1396 | 1397 | # vfs rooted at working directory. |
|
1397 | 1398 | self.wvfs = wdirvfs |
|
1398 | 1399 | self.root = wdirvfs.base |
|
1399 | 1400 | # vfs rooted at .hg/. Used to access most non-store paths. |
|
1400 | 1401 | self.vfs = hgvfs |
|
1401 | 1402 | self.path = hgvfs.base |
|
1402 | 1403 | self.requirements = requirements |
|
1403 | 1404 | self.nodeconstants = sha1nodeconstants |
|
1404 | 1405 | self.nullid = self.nodeconstants.nullid |
|
1405 | 1406 | self.supported = supportedrequirements |
|
1406 | 1407 | self.sharedpath = sharedpath |
|
1407 | 1408 | self.store = store |
|
1408 | 1409 | self.cachevfs = cachevfs |
|
1409 | 1410 | self.wcachevfs = wcachevfs |
|
1410 | 1411 | self.features = features |
|
1411 | 1412 | |
|
1412 | 1413 | self.filtername = None |
|
1413 | 1414 | |
|
1414 | 1415 | if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool( |
|
1415 | 1416 | b'devel', b'check-locks' |
|
1416 | 1417 | ): |
|
1417 | 1418 | self.vfs.audit = self._getvfsward(self.vfs.audit) |
|
1418 | 1419 | # A list of callback to shape the phase if no data were found. |
|
1419 | 1420 | # Callback are in the form: func(repo, roots) --> processed root. |
|
1420 | 1421 | # This list it to be filled by extension during repo setup |
|
1421 | 1422 | self._phasedefaults = [] |
|
1422 | 1423 | |
|
1423 | 1424 | color.setup(self.ui) |
|
1424 | 1425 | |
|
1425 | 1426 | self.spath = self.store.path |
|
1426 | 1427 | self.svfs = self.store.vfs |
|
1427 | 1428 | self.sjoin = self.store.join |
|
1428 | 1429 | if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool( |
|
1429 | 1430 | b'devel', b'check-locks' |
|
1430 | 1431 | ): |
|
1431 | 1432 | if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs |
|
1432 | 1433 | self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit) |
|
1433 | 1434 | else: # standard vfs |
|
1434 | 1435 | self.svfs.audit = self._getsvfsward(self.svfs.audit) |
|
1435 | 1436 | |
|
1436 | 1437 | self._dirstatevalidatewarned = False |
|
1437 | 1438 | |
|
1438 | 1439 | self._branchcaches = branchmap.BranchMapCache() |
|
1439 | 1440 | self._revbranchcache = None |
|
1440 | 1441 | self._filterpats = {} |
|
1441 | 1442 | self._datafilters = {} |
|
1442 | 1443 | self._transref = self._lockref = self._wlockref = None |
|
1443 | 1444 | |
|
1444 | 1445 | # A cache for various files under .hg/ that tracks file changes, |
|
1445 | 1446 | # (used by the filecache decorator) |
|
1446 | 1447 | # |
|
1447 | 1448 | # Maps a property name to its util.filecacheentry |
|
1448 | 1449 | self._filecache = {} |
|
1449 | 1450 | |
|
1450 | 1451 | # hold sets of revision to be filtered |
|
1451 | 1452 | # should be cleared when something might have changed the filter value: |
|
1452 | 1453 | # - new changesets, |
|
1453 | 1454 | # - phase change, |
|
1454 | 1455 | # - new obsolescence marker, |
|
1455 | 1456 | # - working directory parent change, |
|
1456 | 1457 | # - bookmark changes |
|
1457 | 1458 | self.filteredrevcache = {} |
|
1458 | 1459 | |
|
1459 | 1460 | # post-dirstate-status hooks |
|
1460 | 1461 | self._postdsstatus = [] |
|
1461 | 1462 | |
|
1462 | 1463 | # generic mapping between names and nodes |
|
1463 | 1464 | self.names = namespaces.namespaces() |
|
1464 | 1465 | |
|
1465 | 1466 | # Key to signature value. |
|
1466 | 1467 | self._sparsesignaturecache = {} |
|
1467 | 1468 | # Signature to cached matcher instance. |
|
1468 | 1469 | self._sparsematchercache = {} |
|
1469 | 1470 | |
|
1470 | 1471 | self._extrafilterid = repoview.extrafilter(ui) |
|
1471 | 1472 | |
|
1472 | 1473 | self.filecopiesmode = None |
|
1473 | 1474 | if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements: |
|
1474 | 1475 | self.filecopiesmode = b'changeset-sidedata' |
|
1475 | 1476 | |
|
1476 | 1477 | self._wanted_sidedata = set() |
|
1477 | 1478 | self._sidedata_computers = {} |
|
1478 | 1479 | sidedatamod.set_sidedata_spec_for_repo(self) |
|
1479 | 1480 | |
|
1480 | 1481 | def _getvfsward(self, origfunc): |
|
1481 | 1482 | """build a ward for self.vfs""" |
|
1482 | 1483 | rref = weakref.ref(self) |
|
1483 | 1484 | |
|
1484 | 1485 | def checkvfs(path, mode=None): |
|
1485 | 1486 | ret = origfunc(path, mode=mode) |
|
1486 | 1487 | repo = rref() |
|
1487 | 1488 | if ( |
|
1488 | 1489 | repo is None |
|
1489 | 1490 | or not util.safehasattr(repo, b'_wlockref') |
|
1490 | 1491 | or not util.safehasattr(repo, b'_lockref') |
|
1491 | 1492 | ): |
|
1492 | 1493 | return |
|
1493 | 1494 | if mode in (None, b'r', b'rb'): |
|
1494 | 1495 | return |
|
1495 | 1496 | if path.startswith(repo.path): |
|
1496 | 1497 | # truncate name relative to the repository (.hg) |
|
1497 | 1498 | path = path[len(repo.path) + 1 :] |
|
1498 | 1499 | if path.startswith(b'cache/'): |
|
1499 | 1500 | msg = b'accessing cache with vfs instead of cachevfs: "%s"' |
|
1500 | 1501 | repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs") |
|
1501 | 1502 | # path prefixes covered by 'lock' |
|
1502 | 1503 | vfs_path_prefixes = ( |
|
1503 | 1504 | b'journal.', |
|
1504 | 1505 | b'undo.', |
|
1505 | 1506 | b'strip-backup/', |
|
1506 | 1507 | b'cache/', |
|
1507 | 1508 | ) |
|
1508 | 1509 | if any(path.startswith(prefix) for prefix in vfs_path_prefixes): |
|
1509 | 1510 | if repo._currentlock(repo._lockref) is None: |
|
1510 | 1511 | repo.ui.develwarn( |
|
1511 | 1512 | b'write with no lock: "%s"' % path, |
|
1512 | 1513 | stacklevel=3, |
|
1513 | 1514 | config=b'check-locks', |
|
1514 | 1515 | ) |
|
1515 | 1516 | elif repo._currentlock(repo._wlockref) is None: |
|
1516 | 1517 | # rest of vfs files are covered by 'wlock' |
|
1517 | 1518 | # |
|
1518 | 1519 | # exclude special files |
|
1519 | 1520 | for prefix in self._wlockfreeprefix: |
|
1520 | 1521 | if path.startswith(prefix): |
|
1521 | 1522 | return |
|
1522 | 1523 | repo.ui.develwarn( |
|
1523 | 1524 | b'write with no wlock: "%s"' % path, |
|
1524 | 1525 | stacklevel=3, |
|
1525 | 1526 | config=b'check-locks', |
|
1526 | 1527 | ) |
|
1527 | 1528 | return ret |
|
1528 | 1529 | |
|
1529 | 1530 | return checkvfs |
|
1530 | 1531 | |
|
1531 | 1532 | def _getsvfsward(self, origfunc): |
|
1532 | 1533 | """build a ward for self.svfs""" |
|
1533 | 1534 | rref = weakref.ref(self) |
|
1534 | 1535 | |
|
1535 | 1536 | def checksvfs(path, mode=None): |
|
1536 | 1537 | ret = origfunc(path, mode=mode) |
|
1537 | 1538 | repo = rref() |
|
1538 | 1539 | if repo is None or not util.safehasattr(repo, b'_lockref'): |
|
1539 | 1540 | return |
|
1540 | 1541 | if mode in (None, b'r', b'rb'): |
|
1541 | 1542 | return |
|
1542 | 1543 | if path.startswith(repo.sharedpath): |
|
1543 | 1544 | # truncate name relative to the repository (.hg) |
|
1544 | 1545 | path = path[len(repo.sharedpath) + 1 :] |
|
1545 | 1546 | if repo._currentlock(repo._lockref) is None: |
|
1546 | 1547 | repo.ui.develwarn( |
|
1547 | 1548 | b'write with no lock: "%s"' % path, stacklevel=4 |
|
1548 | 1549 | ) |
|
1549 | 1550 | return ret |
|
1550 | 1551 | |
|
1551 | 1552 | return checksvfs |
|
1552 | 1553 | |
|
1553 | 1554 | def close(self): |
|
1554 | 1555 | self._writecaches() |
|
1555 | 1556 | |
|
1556 | 1557 | def _writecaches(self): |
|
1557 | 1558 | if self._revbranchcache: |
|
1558 | 1559 | self._revbranchcache.write() |
|
1559 | 1560 | |
|
1560 | 1561 | def _restrictcapabilities(self, caps): |
|
1561 | 1562 | if self.ui.configbool(b'experimental', b'bundle2-advertise'): |
|
1562 | 1563 | caps = set(caps) |
|
1563 | 1564 | capsblob = bundle2.encodecaps( |
|
1564 | 1565 | bundle2.getrepocaps(self, role=b'client') |
|
1565 | 1566 | ) |
|
1566 | 1567 | caps.add(b'bundle2=' + urlreq.quote(capsblob)) |
|
1567 | 1568 | if self.ui.configbool(b'experimental', b'narrow'): |
|
1568 | 1569 | caps.add(wireprototypes.NARROWCAP) |
|
1569 | 1570 | return caps |
|
1570 | 1571 | |
|
1571 | 1572 | # Don't cache auditor/nofsauditor, or you'll end up with reference cycle: |
|
1572 | 1573 | # self -> auditor -> self._checknested -> self |
|
1573 | 1574 | |
|
1574 | 1575 | @property |
|
1575 | 1576 | def auditor(self): |
|
1576 | 1577 | # This is only used by context.workingctx.match in order to |
|
1577 | 1578 | # detect files in subrepos. |
|
1578 | 1579 | return pathutil.pathauditor(self.root, callback=self._checknested) |
|
1579 | 1580 | |
|
1580 | 1581 | @property |
|
1581 | 1582 | def nofsauditor(self): |
|
1582 | 1583 | # This is only used by context.basectx.match in order to detect |
|
1583 | 1584 | # files in subrepos. |
|
1584 | 1585 | return pathutil.pathauditor( |
|
1585 | 1586 | self.root, callback=self._checknested, realfs=False, cached=True |
|
1586 | 1587 | ) |
|
1587 | 1588 | |
|
1588 | 1589 | def _checknested(self, path): |
|
1589 | 1590 | """Determine if path is a legal nested repository.""" |
|
1590 | 1591 | if not path.startswith(self.root): |
|
1591 | 1592 | return False |
|
1592 | 1593 | subpath = path[len(self.root) + 1 :] |
|
1593 | 1594 | normsubpath = util.pconvert(subpath) |
|
1594 | 1595 | |
|
1595 | 1596 | # XXX: Checking against the current working copy is wrong in |
|
1596 | 1597 | # the sense that it can reject things like |
|
1597 | 1598 | # |
|
1598 | 1599 | # $ hg cat -r 10 sub/x.txt |
|
1599 | 1600 | # |
|
1600 | 1601 | # if sub/ is no longer a subrepository in the working copy |
|
1601 | 1602 | # parent revision. |
|
1602 | 1603 | # |
|
1603 | 1604 | # However, it can of course also allow things that would have |
|
1604 | 1605 | # been rejected before, such as the above cat command if sub/ |
|
1605 | 1606 | # is a subrepository now, but was a normal directory before. |
|
1606 | 1607 | # The old path auditor would have rejected by mistake since it |
|
1607 | 1608 | # panics when it sees sub/.hg/. |
|
1608 | 1609 | # |
|
1609 | 1610 | # All in all, checking against the working copy seems sensible |
|
1610 | 1611 | # since we want to prevent access to nested repositories on |
|
1611 | 1612 | # the filesystem *now*. |
|
1612 | 1613 | ctx = self[None] |
|
1613 | 1614 | parts = util.splitpath(subpath) |
|
1614 | 1615 | while parts: |
|
1615 | 1616 | prefix = b'/'.join(parts) |
|
1616 | 1617 | if prefix in ctx.substate: |
|
1617 | 1618 | if prefix == normsubpath: |
|
1618 | 1619 | return True |
|
1619 | 1620 | else: |
|
1620 | 1621 | sub = ctx.sub(prefix) |
|
1621 | 1622 | return sub.checknested(subpath[len(prefix) + 1 :]) |
|
1622 | 1623 | else: |
|
1623 | 1624 | parts.pop() |
|
1624 | 1625 | return False |
|
1625 | 1626 | |
|
1626 | 1627 | def peer(self): |
|
1627 | 1628 | return localpeer(self) # not cached to avoid reference cycle |
|
1628 | 1629 | |
|
1629 | 1630 | def unfiltered(self): |
|
1630 | 1631 | """Return unfiltered version of the repository |
|
1631 | 1632 | |
|
1632 | 1633 | Intended to be overwritten by filtered repo.""" |
|
1633 | 1634 | return self |
|
1634 | 1635 | |
|
1635 | 1636 | def filtered(self, name, visibilityexceptions=None): |
|
1636 | 1637 | """Return a filtered version of a repository |
|
1637 | 1638 | |
|
1638 | 1639 | The `name` parameter is the identifier of the requested view. This |
|
1639 | 1640 | will return a repoview object set "exactly" to the specified view. |
|
1640 | 1641 | |
|
1641 | 1642 | This function does not apply recursive filtering to a repository. For |
|
1642 | 1643 | example calling `repo.filtered("served")` will return a repoview using |
|
1643 | 1644 | the "served" view, regardless of the initial view used by `repo`. |
|
1644 | 1645 | |
|
1645 | 1646 | In other word, there is always only one level of `repoview` "filtering". |
|
1646 | 1647 | """ |
|
1647 | 1648 | if self._extrafilterid is not None and b'%' not in name: |
|
1648 | 1649 | name = name + b'%' + self._extrafilterid |
|
1649 | 1650 | |
|
1650 | 1651 | cls = repoview.newtype(self.unfiltered().__class__) |
|
1651 | 1652 | return cls(self, name, visibilityexceptions) |
|
1652 | 1653 | |
|
1653 | 1654 | @mixedrepostorecache( |
|
1654 | 1655 | (b'bookmarks', b'plain'), |
|
1655 | 1656 | (b'bookmarks.current', b'plain'), |
|
1656 | 1657 | (b'bookmarks', b''), |
|
1657 | 1658 | (b'00changelog.i', b''), |
|
1658 | 1659 | ) |
|
1659 | 1660 | def _bookmarks(self): |
|
1660 | 1661 | # Since the multiple files involved in the transaction cannot be |
|
1661 | 1662 | # written atomically (with current repository format), there is a race |
|
1662 | 1663 | # condition here. |
|
1663 | 1664 | # |
|
1664 | 1665 | # 1) changelog content A is read |
|
1665 | 1666 | # 2) outside transaction update changelog to content B |
|
1666 | 1667 | # 3) outside transaction update bookmark file referring to content B |
|
1667 | 1668 | # 4) bookmarks file content is read and filtered against changelog-A |
|
1668 | 1669 | # |
|
1669 | 1670 | # When this happens, bookmarks against nodes missing from A are dropped. |
|
1670 | 1671 | # |
|
1671 | 1672 | # Having this happening during read is not great, but it become worse |
|
1672 | 1673 | # when this happen during write because the bookmarks to the "unknown" |
|
1673 | 1674 | # nodes will be dropped for good. However, writes happen within locks. |
|
1674 | 1675 | # This locking makes it possible to have a race free consistent read. |
|
1675 | 1676 | # For this purpose data read from disc before locking are |
|
1676 | 1677 | # "invalidated" right after the locks are taken. This invalidations are |
|
1677 | 1678 | # "light", the `filecache` mechanism keep the data in memory and will |
|
1678 | 1679 | # reuse them if the underlying files did not changed. Not parsing the |
|
1679 | 1680 | # same data multiple times helps performances. |
|
1680 | 1681 | # |
|
1681 | 1682 | # Unfortunately in the case describe above, the files tracked by the |
|
1682 | 1683 | # bookmarks file cache might not have changed, but the in-memory |
|
1683 | 1684 | # content is still "wrong" because we used an older changelog content |
|
1684 | 1685 | # to process the on-disk data. So after locking, the changelog would be |
|
1685 | 1686 | # refreshed but `_bookmarks` would be preserved. |
|
1686 | 1687 | # Adding `00changelog.i` to the list of tracked file is not |
|
1687 | 1688 | # enough, because at the time we build the content for `_bookmarks` in |
|
1688 | 1689 | # (4), the changelog file has already diverged from the content used |
|
1689 | 1690 | # for loading `changelog` in (1) |
|
1690 | 1691 | # |
|
1691 | 1692 | # To prevent the issue, we force the changelog to be explicitly |
|
1692 | 1693 | # reloaded while computing `_bookmarks`. The data race can still happen |
|
1693 | 1694 | # without the lock (with a narrower window), but it would no longer go |
|
1694 | 1695 | # undetected during the lock time refresh. |
|
1695 | 1696 | # |
|
1696 | 1697 | # The new schedule is as follow |
|
1697 | 1698 | # |
|
1698 | 1699 | # 1) filecache logic detect that `_bookmarks` needs to be computed |
|
1699 | 1700 | # 2) cachestat for `bookmarks` and `changelog` are captured (for book) |
|
1700 | 1701 | # 3) We force `changelog` filecache to be tested |
|
1701 | 1702 | # 4) cachestat for `changelog` are captured (for changelog) |
|
1702 | 1703 | # 5) `_bookmarks` is computed and cached |
|
1703 | 1704 | # |
|
1704 | 1705 | # The step in (3) ensure we have a changelog at least as recent as the |
|
1705 | 1706 | # cache stat computed in (1). As a result at locking time: |
|
1706 | 1707 | # * if the changelog did not changed since (1) -> we can reuse the data |
|
1707 | 1708 | # * otherwise -> the bookmarks get refreshed. |
|
1708 | 1709 | self._refreshchangelog() |
|
1709 | 1710 | return bookmarks.bmstore(self) |
|
1710 | 1711 | |
|
1711 | 1712 | def _refreshchangelog(self): |
|
1712 | 1713 | """make sure the in memory changelog match the on-disk one""" |
|
1713 | 1714 | if 'changelog' in vars(self) and self.currenttransaction() is None: |
|
1714 | 1715 | del self.changelog |
|
1715 | 1716 | |
|
1716 | 1717 | @property |
|
1717 | 1718 | def _activebookmark(self): |
|
1718 | 1719 | return self._bookmarks.active |
|
1719 | 1720 | |
|
1720 | 1721 | # _phasesets depend on changelog. what we need is to call |
|
1721 | 1722 | # _phasecache.invalidate() if '00changelog.i' was changed, but it |
|
1722 | 1723 | # can't be easily expressed in filecache mechanism. |
|
1723 | 1724 | @storecache(b'phaseroots', b'00changelog.i') |
|
1724 | 1725 | def _phasecache(self): |
|
1725 | 1726 | return phases.phasecache(self, self._phasedefaults) |
|
1726 | 1727 | |
|
1727 | 1728 | @storecache(b'obsstore') |
|
1728 | 1729 | def obsstore(self): |
|
1729 | 1730 | return obsolete.makestore(self.ui, self) |
|
1730 | 1731 | |
|
1731 | 1732 | @changelogcache() |
|
1732 | 1733 | def changelog(repo): |
|
1733 | 1734 | # load dirstate before changelog to avoid race see issue6303 |
|
1734 | 1735 | repo.dirstate.prefetch_parents() |
|
1735 | 1736 | return repo.store.changelog( |
|
1736 | 1737 | txnutil.mayhavepending(repo.root), |
|
1737 | 1738 | concurrencychecker=revlogchecker.get_checker(repo.ui, b'changelog'), |
|
1738 | 1739 | ) |
|
1739 | 1740 | |
|
1740 | 1741 | @manifestlogcache() |
|
1741 | 1742 | def manifestlog(self): |
|
1742 | 1743 | return self.store.manifestlog(self, self._storenarrowmatch) |
|
1743 | 1744 | |
|
1744 | 1745 | @repofilecache(b'dirstate') |
|
1745 | 1746 | def dirstate(self): |
|
1746 | 1747 | return self._makedirstate() |
|
1747 | 1748 | |
|
1748 | 1749 | def _makedirstate(self): |
|
1749 | 1750 | """Extension point for wrapping the dirstate per-repo.""" |
|
1750 | 1751 | sparsematchfn = None |
|
1751 | 1752 | if sparse.use_sparse(self): |
|
1752 | 1753 | sparsematchfn = lambda: sparse.matcher(self) |
|
1753 | 1754 | v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT |
|
1754 | 1755 | th = requirementsmod.DIRSTATE_TRACKED_HINT_V1 |
|
1755 | 1756 | use_dirstate_v2 = v2_req in self.requirements |
|
1756 | 1757 | use_tracked_hint = th in self.requirements |
|
1757 | 1758 | |
|
1758 | 1759 | return dirstate.dirstate( |
|
1759 | 1760 | self.vfs, |
|
1760 | 1761 | self.ui, |
|
1761 | 1762 | self.root, |
|
1762 | 1763 | self._dirstatevalidate, |
|
1763 | 1764 | sparsematchfn, |
|
1764 | 1765 | self.nodeconstants, |
|
1765 | 1766 | use_dirstate_v2, |
|
1766 | 1767 | use_tracked_hint=use_tracked_hint, |
|
1767 | 1768 | ) |
|
1768 | 1769 | |
|
1769 | 1770 | def _dirstatevalidate(self, node): |
|
1770 | 1771 | try: |
|
1771 | 1772 | self.changelog.rev(node) |
|
1772 | 1773 | return node |
|
1773 | 1774 | except error.LookupError: |
|
1774 | 1775 | if not self._dirstatevalidatewarned: |
|
1775 | 1776 | self._dirstatevalidatewarned = True |
|
1776 | 1777 | self.ui.warn( |
|
1777 | 1778 | _(b"warning: ignoring unknown working parent %s!\n") |
|
1778 | 1779 | % short(node) |
|
1779 | 1780 | ) |
|
1780 | 1781 | return self.nullid |
|
1781 | 1782 | |
|
1782 | 1783 | @storecache(narrowspec.FILENAME) |
|
1783 | 1784 | def narrowpats(self): |
|
1784 | 1785 | """matcher patterns for this repository's narrowspec |
|
1785 | 1786 | |
|
1786 | 1787 | A tuple of (includes, excludes). |
|
1787 | 1788 | """ |
|
1788 | 1789 | return narrowspec.load(self) |
|
1789 | 1790 | |
|
1790 | 1791 | @storecache(narrowspec.FILENAME) |
|
1791 | 1792 | def _storenarrowmatch(self): |
|
1792 | 1793 | if requirementsmod.NARROW_REQUIREMENT not in self.requirements: |
|
1793 | 1794 | return matchmod.always() |
|
1794 | 1795 | include, exclude = self.narrowpats |
|
1795 | 1796 | return narrowspec.match(self.root, include=include, exclude=exclude) |
|
1796 | 1797 | |
|
1797 | 1798 | @storecache(narrowspec.FILENAME) |
|
1798 | 1799 | def _narrowmatch(self): |
|
1799 | 1800 | if requirementsmod.NARROW_REQUIREMENT not in self.requirements: |
|
1800 | 1801 | return matchmod.always() |
|
1801 | 1802 | narrowspec.checkworkingcopynarrowspec(self) |
|
1802 | 1803 | include, exclude = self.narrowpats |
|
1803 | 1804 | return narrowspec.match(self.root, include=include, exclude=exclude) |
|
1804 | 1805 | |
|
1805 | 1806 | def narrowmatch(self, match=None, includeexact=False): |
|
1806 | 1807 | """matcher corresponding the the repo's narrowspec |
|
1807 | 1808 | |
|
1808 | 1809 | If `match` is given, then that will be intersected with the narrow |
|
1809 | 1810 | matcher. |
|
1810 | 1811 | |
|
1811 | 1812 | If `includeexact` is True, then any exact matches from `match` will |
|
1812 | 1813 | be included even if they're outside the narrowspec. |
|
1813 | 1814 | """ |
|
1814 | 1815 | if match: |
|
1815 | 1816 | if includeexact and not self._narrowmatch.always(): |
|
1816 | 1817 | # do not exclude explicitly-specified paths so that they can |
|
1817 | 1818 | # be warned later on |
|
1818 | 1819 | em = matchmod.exact(match.files()) |
|
1819 | 1820 | nm = matchmod.unionmatcher([self._narrowmatch, em]) |
|
1820 | 1821 | return matchmod.intersectmatchers(match, nm) |
|
1821 | 1822 | return matchmod.intersectmatchers(match, self._narrowmatch) |
|
1822 | 1823 | return self._narrowmatch |
|
1823 | 1824 | |
|
1824 | 1825 | def setnarrowpats(self, newincludes, newexcludes): |
|
1825 | 1826 | narrowspec.save(self, newincludes, newexcludes) |
|
1826 | 1827 | self.invalidate(clearfilecache=True) |
|
1827 | 1828 | |
|
1828 | 1829 | @unfilteredpropertycache |
|
1829 | 1830 | def _quick_access_changeid_null(self): |
|
1830 | 1831 | return { |
|
1831 | 1832 | b'null': (nullrev, self.nodeconstants.nullid), |
|
1832 | 1833 | nullrev: (nullrev, self.nodeconstants.nullid), |
|
1833 | 1834 | self.nullid: (nullrev, self.nullid), |
|
1834 | 1835 | } |
|
1835 | 1836 | |
|
1836 | 1837 | @unfilteredpropertycache |
|
1837 | 1838 | def _quick_access_changeid_wc(self): |
|
1838 | 1839 | # also fast path access to the working copy parents |
|
1839 | 1840 | # however, only do it for filter that ensure wc is visible. |
|
1840 | 1841 | quick = self._quick_access_changeid_null.copy() |
|
1841 | 1842 | cl = self.unfiltered().changelog |
|
1842 | 1843 | for node in self.dirstate.parents(): |
|
1843 | 1844 | if node == self.nullid: |
|
1844 | 1845 | continue |
|
1845 | 1846 | rev = cl.index.get_rev(node) |
|
1846 | 1847 | if rev is None: |
|
1847 | 1848 | # unknown working copy parent case: |
|
1848 | 1849 | # |
|
1849 | 1850 | # skip the fast path and let higher code deal with it |
|
1850 | 1851 | continue |
|
1851 | 1852 | pair = (rev, node) |
|
1852 | 1853 | quick[rev] = pair |
|
1853 | 1854 | quick[node] = pair |
|
1854 | 1855 | # also add the parents of the parents |
|
1855 | 1856 | for r in cl.parentrevs(rev): |
|
1856 | 1857 | if r == nullrev: |
|
1857 | 1858 | continue |
|
1858 | 1859 | n = cl.node(r) |
|
1859 | 1860 | pair = (r, n) |
|
1860 | 1861 | quick[r] = pair |
|
1861 | 1862 | quick[n] = pair |
|
1862 | 1863 | p1node = self.dirstate.p1() |
|
1863 | 1864 | if p1node != self.nullid: |
|
1864 | 1865 | quick[b'.'] = quick[p1node] |
|
1865 | 1866 | return quick |
|
1866 | 1867 | |
|
1867 | 1868 | @unfilteredmethod |
|
1868 | 1869 | def _quick_access_changeid_invalidate(self): |
|
1869 | 1870 | if '_quick_access_changeid_wc' in vars(self): |
|
1870 | 1871 | del self.__dict__['_quick_access_changeid_wc'] |
|
1871 | 1872 | |
|
1872 | 1873 | @property |
|
1873 | 1874 | def _quick_access_changeid(self): |
|
1874 | 1875 | """an helper dictionnary for __getitem__ calls |
|
1875 | 1876 | |
|
1876 | 1877 | This contains a list of symbol we can recognise right away without |
|
1877 | 1878 | further processing. |
|
1878 | 1879 | """ |
|
1879 | 1880 | if self.filtername in repoview.filter_has_wc: |
|
1880 | 1881 | return self._quick_access_changeid_wc |
|
1881 | 1882 | return self._quick_access_changeid_null |
|
1882 | 1883 | |
|
1883 | 1884 | def __getitem__(self, changeid): |
|
1884 | 1885 | # dealing with special cases |
|
1885 | 1886 | if changeid is None: |
|
1886 | 1887 | return context.workingctx(self) |
|
1887 | 1888 | if isinstance(changeid, context.basectx): |
|
1888 | 1889 | return changeid |
|
1889 | 1890 | |
|
1890 | 1891 | # dealing with multiple revisions |
|
1891 | 1892 | if isinstance(changeid, slice): |
|
1892 | 1893 | # wdirrev isn't contiguous so the slice shouldn't include it |
|
1893 | 1894 | return [ |
|
1894 | 1895 | self[i] |
|
1895 | 1896 | for i in range(*changeid.indices(len(self))) |
|
1896 | 1897 | if i not in self.changelog.filteredrevs |
|
1897 | 1898 | ] |
|
1898 | 1899 | |
|
1899 | 1900 | # dealing with some special values |
|
1900 | 1901 | quick_access = self._quick_access_changeid.get(changeid) |
|
1901 | 1902 | if quick_access is not None: |
|
1902 | 1903 | rev, node = quick_access |
|
1903 | 1904 | return context.changectx(self, rev, node, maybe_filtered=False) |
|
1904 | 1905 | if changeid == b'tip': |
|
1905 | 1906 | node = self.changelog.tip() |
|
1906 | 1907 | rev = self.changelog.rev(node) |
|
1907 | 1908 | return context.changectx(self, rev, node) |
|
1908 | 1909 | |
|
1909 | 1910 | # dealing with arbitrary values |
|
1910 | 1911 | try: |
|
1911 | 1912 | if isinstance(changeid, int): |
|
1912 | 1913 | node = self.changelog.node(changeid) |
|
1913 | 1914 | rev = changeid |
|
1914 | 1915 | elif changeid == b'.': |
|
1915 | 1916 | # this is a hack to delay/avoid loading obsmarkers |
|
1916 | 1917 | # when we know that '.' won't be hidden |
|
1917 | 1918 | node = self.dirstate.p1() |
|
1918 | 1919 | rev = self.unfiltered().changelog.rev(node) |
|
1919 | 1920 | elif len(changeid) == self.nodeconstants.nodelen: |
|
1920 | 1921 | try: |
|
1921 | 1922 | node = changeid |
|
1922 | 1923 | rev = self.changelog.rev(changeid) |
|
1923 | 1924 | except error.FilteredLookupError: |
|
1924 | 1925 | changeid = hex(changeid) # for the error message |
|
1925 | 1926 | raise |
|
1926 | 1927 | except LookupError: |
|
1927 | 1928 | # check if it might have come from damaged dirstate |
|
1928 | 1929 | # |
|
1929 | 1930 | # XXX we could avoid the unfiltered if we had a recognizable |
|
1930 | 1931 | # exception for filtered changeset access |
|
1931 | 1932 | if ( |
|
1932 | 1933 | self.local() |
|
1933 | 1934 | and changeid in self.unfiltered().dirstate.parents() |
|
1934 | 1935 | ): |
|
1935 | 1936 | msg = _(b"working directory has unknown parent '%s'!") |
|
1936 | 1937 | raise error.Abort(msg % short(changeid)) |
|
1937 | 1938 | changeid = hex(changeid) # for the error message |
|
1938 | 1939 | raise |
|
1939 | 1940 | |
|
1940 | 1941 | elif len(changeid) == 2 * self.nodeconstants.nodelen: |
|
1941 | 1942 | node = bin(changeid) |
|
1942 | 1943 | rev = self.changelog.rev(node) |
|
1943 | 1944 | else: |
|
1944 | 1945 | raise error.ProgrammingError( |
|
1945 | 1946 | b"unsupported changeid '%s' of type %s" |
|
1946 | 1947 | % (changeid, pycompat.bytestr(type(changeid))) |
|
1947 | 1948 | ) |
|
1948 | 1949 | |
|
1949 | 1950 | return context.changectx(self, rev, node) |
|
1950 | 1951 | |
|
1951 | 1952 | except (error.FilteredIndexError, error.FilteredLookupError): |
|
1952 | 1953 | raise error.FilteredRepoLookupError( |
|
1953 | 1954 | _(b"filtered revision '%s'") % pycompat.bytestr(changeid) |
|
1954 | 1955 | ) |
|
1955 | 1956 | except (IndexError, LookupError): |
|
1956 | 1957 | raise error.RepoLookupError( |
|
1957 | 1958 | _(b"unknown revision '%s'") % pycompat.bytestr(changeid) |
|
1958 | 1959 | ) |
|
1959 | 1960 | except error.WdirUnsupported: |
|
1960 | 1961 | return context.workingctx(self) |
|
1961 | 1962 | |
|
1962 | 1963 | def __contains__(self, changeid): |
|
1963 | 1964 | """True if the given changeid exists""" |
|
1964 | 1965 | try: |
|
1965 | 1966 | self[changeid] |
|
1966 | 1967 | return True |
|
1967 | 1968 | except error.RepoLookupError: |
|
1968 | 1969 | return False |
|
1969 | 1970 | |
|
1970 | 1971 | def __nonzero__(self): |
|
1971 | 1972 | return True |
|
1972 | 1973 | |
|
1973 | 1974 | __bool__ = __nonzero__ |
|
1974 | 1975 | |
|
1975 | 1976 | def __len__(self): |
|
1976 | 1977 | # no need to pay the cost of repoview.changelog |
|
1977 | 1978 | unfi = self.unfiltered() |
|
1978 | 1979 | return len(unfi.changelog) |
|
1979 | 1980 | |
|
1980 | 1981 | def __iter__(self): |
|
1981 | 1982 | return iter(self.changelog) |
|
1982 | 1983 | |
|
1983 | 1984 | def revs(self, expr, *args): |
|
1984 | 1985 | """Find revisions matching a revset. |
|
1985 | 1986 | |
|
1986 | 1987 | The revset is specified as a string ``expr`` that may contain |
|
1987 | 1988 | %-formatting to escape certain types. See ``revsetlang.formatspec``. |
|
1988 | 1989 | |
|
1989 | 1990 | Revset aliases from the configuration are not expanded. To expand |
|
1990 | 1991 | user aliases, consider calling ``scmutil.revrange()`` or |
|
1991 | 1992 | ``repo.anyrevs([expr], user=True)``. |
|
1992 | 1993 | |
|
1993 | 1994 | Returns a smartset.abstractsmartset, which is a list-like interface |
|
1994 | 1995 | that contains integer revisions. |
|
1995 | 1996 | """ |
|
1996 | 1997 | tree = revsetlang.spectree(expr, *args) |
|
1997 | 1998 | return revset.makematcher(tree)(self) |
|
1998 | 1999 | |
|
1999 | 2000 | def set(self, expr, *args): |
|
2000 | 2001 | """Find revisions matching a revset and emit changectx instances. |
|
2001 | 2002 | |
|
2002 | 2003 | This is a convenience wrapper around ``revs()`` that iterates the |
|
2003 | 2004 | result and is a generator of changectx instances. |
|
2004 | 2005 | |
|
2005 | 2006 | Revset aliases from the configuration are not expanded. To expand |
|
2006 | 2007 | user aliases, consider calling ``scmutil.revrange()``. |
|
2007 | 2008 | """ |
|
2008 | 2009 | for r in self.revs(expr, *args): |
|
2009 | 2010 | yield self[r] |
|
2010 | 2011 | |
|
2011 | 2012 | def anyrevs(self, specs, user=False, localalias=None): |
|
2012 | 2013 | """Find revisions matching one of the given revsets. |
|
2013 | 2014 | |
|
2014 | 2015 | Revset aliases from the configuration are not expanded by default. To |
|
2015 | 2016 | expand user aliases, specify ``user=True``. To provide some local |
|
2016 | 2017 | definitions overriding user aliases, set ``localalias`` to |
|
2017 | 2018 | ``{name: definitionstring}``. |
|
2018 | 2019 | """ |
|
2019 | 2020 | if specs == [b'null']: |
|
2020 | 2021 | return revset.baseset([nullrev]) |
|
2021 | 2022 | if specs == [b'.']: |
|
2022 | 2023 | quick_data = self._quick_access_changeid.get(b'.') |
|
2023 | 2024 | if quick_data is not None: |
|
2024 | 2025 | return revset.baseset([quick_data[0]]) |
|
2025 | 2026 | if user: |
|
2026 | 2027 | m = revset.matchany( |
|
2027 | 2028 | self.ui, |
|
2028 | 2029 | specs, |
|
2029 | 2030 | lookup=revset.lookupfn(self), |
|
2030 | 2031 | localalias=localalias, |
|
2031 | 2032 | ) |
|
2032 | 2033 | else: |
|
2033 | 2034 | m = revset.matchany(None, specs, localalias=localalias) |
|
2034 | 2035 | return m(self) |
|
2035 | 2036 | |
|
2036 | 2037 | def url(self): |
|
2037 | 2038 | return b'file:' + self.root |
|
2038 | 2039 | |
|
2039 | 2040 | def hook(self, name, throw=False, **args): |
|
2040 | 2041 | """Call a hook, passing this repo instance. |
|
2041 | 2042 | |
|
2042 | 2043 | This a convenience method to aid invoking hooks. Extensions likely |
|
2043 | 2044 | won't call this unless they have registered a custom hook or are |
|
2044 | 2045 | replacing code that is expected to call a hook. |
|
2045 | 2046 | """ |
|
2046 | 2047 | return hook.hook(self.ui, self, name, throw, **args) |
|
2047 | 2048 | |
|
2048 | 2049 | @filteredpropertycache |
|
2049 | 2050 | def _tagscache(self): |
|
2050 | 2051 | """Returns a tagscache object that contains various tags related |
|
2051 | 2052 | caches.""" |
|
2052 | 2053 | |
|
2053 | 2054 | # This simplifies its cache management by having one decorated |
|
2054 | 2055 | # function (this one) and the rest simply fetch things from it. |
|
2055 | 2056 | class tagscache: |
|
2056 | 2057 | def __init__(self): |
|
2057 | 2058 | # These two define the set of tags for this repository. tags |
|
2058 | 2059 | # maps tag name to node; tagtypes maps tag name to 'global' or |
|
2059 | 2060 | # 'local'. (Global tags are defined by .hgtags across all |
|
2060 | 2061 | # heads, and local tags are defined in .hg/localtags.) |
|
2061 | 2062 | # They constitute the in-memory cache of tags. |
|
2062 | 2063 | self.tags = self.tagtypes = None |
|
2063 | 2064 | |
|
2064 | 2065 | self.nodetagscache = self.tagslist = None |
|
2065 | 2066 | |
|
2066 | 2067 | cache = tagscache() |
|
2067 | 2068 | cache.tags, cache.tagtypes = self._findtags() |
|
2068 | 2069 | |
|
2069 | 2070 | return cache |
|
2070 | 2071 | |
|
2071 | 2072 | def tags(self): |
|
2072 | 2073 | '''return a mapping of tag to node''' |
|
2073 | 2074 | t = {} |
|
2074 | 2075 | if self.changelog.filteredrevs: |
|
2075 | 2076 | tags, tt = self._findtags() |
|
2076 | 2077 | else: |
|
2077 | 2078 | tags = self._tagscache.tags |
|
2078 | 2079 | rev = self.changelog.rev |
|
2079 | 2080 | for k, v in tags.items(): |
|
2080 | 2081 | try: |
|
2081 | 2082 | # ignore tags to unknown nodes |
|
2082 | 2083 | rev(v) |
|
2083 | 2084 | t[k] = v |
|
2084 | 2085 | except (error.LookupError, ValueError): |
|
2085 | 2086 | pass |
|
2086 | 2087 | return t |
|
2087 | 2088 | |
|
2088 | 2089 | def _findtags(self): |
|
2089 | 2090 | """Do the hard work of finding tags. Return a pair of dicts |
|
2090 | 2091 | (tags, tagtypes) where tags maps tag name to node, and tagtypes |
|
2091 | 2092 | maps tag name to a string like \'global\' or \'local\'. |
|
2092 | 2093 | Subclasses or extensions are free to add their own tags, but |
|
2093 | 2094 | should be aware that the returned dicts will be retained for the |
|
2094 | 2095 | duration of the localrepo object.""" |
|
2095 | 2096 | |
|
2096 | 2097 | # XXX what tagtype should subclasses/extensions use? Currently |
|
2097 | 2098 | # mq and bookmarks add tags, but do not set the tagtype at all. |
|
2098 | 2099 | # Should each extension invent its own tag type? Should there |
|
2099 | 2100 | # be one tagtype for all such "virtual" tags? Or is the status |
|
2100 | 2101 | # quo fine? |
|
2101 | 2102 | |
|
2102 | 2103 | # map tag name to (node, hist) |
|
2103 | 2104 | alltags = tagsmod.findglobaltags(self.ui, self) |
|
2104 | 2105 | # map tag name to tag type |
|
2105 | 2106 | tagtypes = {tag: b'global' for tag in alltags} |
|
2106 | 2107 | |
|
2107 | 2108 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) |
|
2108 | 2109 | |
|
2109 | 2110 | # Build the return dicts. Have to re-encode tag names because |
|
2110 | 2111 | # the tags module always uses UTF-8 (in order not to lose info |
|
2111 | 2112 | # writing to the cache), but the rest of Mercurial wants them in |
|
2112 | 2113 | # local encoding. |
|
2113 | 2114 | tags = {} |
|
2114 | 2115 | for (name, (node, hist)) in alltags.items(): |
|
2115 | 2116 | if node != self.nullid: |
|
2116 | 2117 | tags[encoding.tolocal(name)] = node |
|
2117 | 2118 | tags[b'tip'] = self.changelog.tip() |
|
2118 | 2119 | tagtypes = { |
|
2119 | 2120 | encoding.tolocal(name): value for (name, value) in tagtypes.items() |
|
2120 | 2121 | } |
|
2121 | 2122 | return (tags, tagtypes) |
|
2122 | 2123 | |
|
2123 | 2124 | def tagtype(self, tagname): |
|
2124 | 2125 | """ |
|
2125 | 2126 | return the type of the given tag. result can be: |
|
2126 | 2127 | |
|
2127 | 2128 | 'local' : a local tag |
|
2128 | 2129 | 'global' : a global tag |
|
2129 | 2130 | None : tag does not exist |
|
2130 | 2131 | """ |
|
2131 | 2132 | |
|
2132 | 2133 | return self._tagscache.tagtypes.get(tagname) |
|
2133 | 2134 | |
|
2134 | 2135 | def tagslist(self): |
|
2135 | 2136 | '''return a list of tags ordered by revision''' |
|
2136 | 2137 | if not self._tagscache.tagslist: |
|
2137 | 2138 | l = [] |
|
2138 | 2139 | for t, n in self.tags().items(): |
|
2139 | 2140 | l.append((self.changelog.rev(n), t, n)) |
|
2140 | 2141 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] |
|
2141 | 2142 | |
|
2142 | 2143 | return self._tagscache.tagslist |
|
2143 | 2144 | |
|
2144 | 2145 | def nodetags(self, node): |
|
2145 | 2146 | '''return the tags associated with a node''' |
|
2146 | 2147 | if not self._tagscache.nodetagscache: |
|
2147 | 2148 | nodetagscache = {} |
|
2148 | 2149 | for t, n in self._tagscache.tags.items(): |
|
2149 | 2150 | nodetagscache.setdefault(n, []).append(t) |
|
2150 | 2151 | for tags in nodetagscache.values(): |
|
2151 | 2152 | tags.sort() |
|
2152 | 2153 | self._tagscache.nodetagscache = nodetagscache |
|
2153 | 2154 | return self._tagscache.nodetagscache.get(node, []) |
|
2154 | 2155 | |
|
2155 | 2156 | def nodebookmarks(self, node): |
|
2156 | 2157 | """return the list of bookmarks pointing to the specified node""" |
|
2157 | 2158 | return self._bookmarks.names(node) |
|
2158 | 2159 | |
|
2159 | 2160 | def branchmap(self): |
|
2160 | 2161 | """returns a dictionary {branch: [branchheads]} with branchheads |
|
2161 | 2162 | ordered by increasing revision number""" |
|
2162 | 2163 | return self._branchcaches[self] |
|
2163 | 2164 | |
|
2164 | 2165 | @unfilteredmethod |
|
2165 | 2166 | def revbranchcache(self): |
|
2166 | 2167 | if not self._revbranchcache: |
|
2167 | 2168 | self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) |
|
2168 | 2169 | return self._revbranchcache |
|
2169 | 2170 | |
|
2170 | 2171 | def register_changeset(self, rev, changelogrevision): |
|
2171 | 2172 | self.revbranchcache().setdata(rev, changelogrevision) |
|
2172 | 2173 | |
|
2173 | 2174 | def branchtip(self, branch, ignoremissing=False): |
|
2174 | 2175 | """return the tip node for a given branch |
|
2175 | 2176 | |
|
2176 | 2177 | If ignoremissing is True, then this method will not raise an error. |
|
2177 | 2178 | This is helpful for callers that only expect None for a missing branch |
|
2178 | 2179 | (e.g. namespace). |
|
2179 | 2180 | |
|
2180 | 2181 | """ |
|
2181 | 2182 | try: |
|
2182 | 2183 | return self.branchmap().branchtip(branch) |
|
2183 | 2184 | except KeyError: |
|
2184 | 2185 | if not ignoremissing: |
|
2185 | 2186 | raise error.RepoLookupError(_(b"unknown branch '%s'") % branch) |
|
2186 | 2187 | else: |
|
2187 | 2188 | pass |
|
2188 | 2189 | |
|
2189 | 2190 | def lookup(self, key): |
|
2190 | 2191 | node = scmutil.revsymbol(self, key).node() |
|
2191 | 2192 | if node is None: |
|
2192 | 2193 | raise error.RepoLookupError(_(b"unknown revision '%s'") % key) |
|
2193 | 2194 | return node |
|
2194 | 2195 | |
|
2195 | 2196 | def lookupbranch(self, key): |
|
2196 | 2197 | if self.branchmap().hasbranch(key): |
|
2197 | 2198 | return key |
|
2198 | 2199 | |
|
2199 | 2200 | return scmutil.revsymbol(self, key).branch() |
|
2200 | 2201 | |
|
2201 | 2202 | def known(self, nodes): |
|
2202 | 2203 | cl = self.changelog |
|
2203 | 2204 | get_rev = cl.index.get_rev |
|
2204 | 2205 | filtered = cl.filteredrevs |
|
2205 | 2206 | result = [] |
|
2206 | 2207 | for n in nodes: |
|
2207 | 2208 | r = get_rev(n) |
|
2208 | 2209 | resp = not (r is None or r in filtered) |
|
2209 | 2210 | result.append(resp) |
|
2210 | 2211 | return result |
|
2211 | 2212 | |
|
2212 | 2213 | def local(self): |
|
2213 | 2214 | return self |
|
2214 | 2215 | |
|
2215 | 2216 | def publishing(self): |
|
2216 | 2217 | # it's safe (and desirable) to trust the publish flag unconditionally |
|
2217 | 2218 | # so that we don't finalize changes shared between users via ssh or nfs |
|
2218 | 2219 | return self.ui.configbool(b'phases', b'publish', untrusted=True) |
|
2219 | 2220 | |
|
2220 | 2221 | def cancopy(self): |
|
2221 | 2222 | # so statichttprepo's override of local() works |
|
2222 | 2223 | if not self.local(): |
|
2223 | 2224 | return False |
|
2224 | 2225 | if not self.publishing(): |
|
2225 | 2226 | return True |
|
2226 | 2227 | # if publishing we can't copy if there is filtered content |
|
2227 | 2228 | return not self.filtered(b'visible').changelog.filteredrevs |
|
2228 | 2229 | |
|
2229 | 2230 | def shared(self): |
|
2230 | 2231 | '''the type of shared repository (None if not shared)''' |
|
2231 | 2232 | if self.sharedpath != self.path: |
|
2232 | 2233 | return b'store' |
|
2233 | 2234 | return None |
|
2234 | 2235 | |
|
2235 | 2236 | def wjoin(self, f, *insidef): |
|
2236 | 2237 | return self.vfs.reljoin(self.root, f, *insidef) |
|
2237 | 2238 | |
|
2238 | 2239 | def setparents(self, p1, p2=None): |
|
2239 | 2240 | if p2 is None: |
|
2240 | 2241 | p2 = self.nullid |
|
2241 | 2242 | self[None].setparents(p1, p2) |
|
2242 | 2243 | self._quick_access_changeid_invalidate() |
|
2243 | 2244 | |
|
2244 | 2245 | def filectx(self, path, changeid=None, fileid=None, changectx=None): |
|
2245 | 2246 | """changeid must be a changeset revision, if specified. |
|
2246 | 2247 | fileid can be a file revision or node.""" |
|
2247 | 2248 | return context.filectx( |
|
2248 | 2249 | self, path, changeid, fileid, changectx=changectx |
|
2249 | 2250 | ) |
|
2250 | 2251 | |
|
2251 | 2252 | def getcwd(self): |
|
2252 | 2253 | return self.dirstate.getcwd() |
|
2253 | 2254 | |
|
2254 | 2255 | def pathto(self, f, cwd=None): |
|
2255 | 2256 | return self.dirstate.pathto(f, cwd) |
|
2256 | 2257 | |
|
2257 | 2258 | def _loadfilter(self, filter): |
|
2258 | 2259 | if filter not in self._filterpats: |
|
2259 | 2260 | l = [] |
|
2260 | 2261 | for pat, cmd in self.ui.configitems(filter): |
|
2261 | 2262 | if cmd == b'!': |
|
2262 | 2263 | continue |
|
2263 | 2264 | mf = matchmod.match(self.root, b'', [pat]) |
|
2264 | 2265 | fn = None |
|
2265 | 2266 | params = cmd |
|
2266 | 2267 | for name, filterfn in self._datafilters.items(): |
|
2267 | 2268 | if cmd.startswith(name): |
|
2268 | 2269 | fn = filterfn |
|
2269 | 2270 | params = cmd[len(name) :].lstrip() |
|
2270 | 2271 | break |
|
2271 | 2272 | if not fn: |
|
2272 | 2273 | fn = lambda s, c, **kwargs: procutil.filter(s, c) |
|
2273 | 2274 | fn.__name__ = 'commandfilter' |
|
2274 | 2275 | # Wrap old filters not supporting keyword arguments |
|
2275 | 2276 | if not pycompat.getargspec(fn)[2]: |
|
2276 | 2277 | oldfn = fn |
|
2277 | 2278 | fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c) |
|
2278 | 2279 | fn.__name__ = 'compat-' + oldfn.__name__ |
|
2279 | 2280 | l.append((mf, fn, params)) |
|
2280 | 2281 | self._filterpats[filter] = l |
|
2281 | 2282 | return self._filterpats[filter] |
|
2282 | 2283 | |
|
2283 | 2284 | def _filter(self, filterpats, filename, data): |
|
2284 | 2285 | for mf, fn, cmd in filterpats: |
|
2285 | 2286 | if mf(filename): |
|
2286 | 2287 | self.ui.debug( |
|
2287 | 2288 | b"filtering %s through %s\n" |
|
2288 | 2289 | % (filename, cmd or pycompat.sysbytes(fn.__name__)) |
|
2289 | 2290 | ) |
|
2290 | 2291 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
|
2291 | 2292 | break |
|
2292 | 2293 | |
|
2293 | 2294 | return data |
|
2294 | 2295 | |
|
2295 | 2296 | @unfilteredpropertycache |
|
2296 | 2297 | def _encodefilterpats(self): |
|
2297 | 2298 | return self._loadfilter(b'encode') |
|
2298 | 2299 | |
|
2299 | 2300 | @unfilteredpropertycache |
|
2300 | 2301 | def _decodefilterpats(self): |
|
2301 | 2302 | return self._loadfilter(b'decode') |
|
2302 | 2303 | |
|
2303 | 2304 | def adddatafilter(self, name, filter): |
|
2304 | 2305 | self._datafilters[name] = filter |
|
2305 | 2306 | |
|
2306 | 2307 | def wread(self, filename): |
|
2307 | 2308 | if self.wvfs.islink(filename): |
|
2308 | 2309 | data = self.wvfs.readlink(filename) |
|
2309 | 2310 | else: |
|
2310 | 2311 | data = self.wvfs.read(filename) |
|
2311 | 2312 | return self._filter(self._encodefilterpats, filename, data) |
|
2312 | 2313 | |
|
2313 | 2314 | def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs): |
|
2314 | 2315 | """write ``data`` into ``filename`` in the working directory |
|
2315 | 2316 | |
|
2316 | 2317 | This returns length of written (maybe decoded) data. |
|
2317 | 2318 | """ |
|
2318 | 2319 | data = self._filter(self._decodefilterpats, filename, data) |
|
2319 | 2320 | if b'l' in flags: |
|
2320 | 2321 | self.wvfs.symlink(data, filename) |
|
2321 | 2322 | else: |
|
2322 | 2323 | self.wvfs.write( |
|
2323 | 2324 | filename, data, backgroundclose=backgroundclose, **kwargs |
|
2324 | 2325 | ) |
|
2325 | 2326 | if b'x' in flags: |
|
2326 | 2327 | self.wvfs.setflags(filename, False, True) |
|
2327 | 2328 | else: |
|
2328 | 2329 | self.wvfs.setflags(filename, False, False) |
|
2329 | 2330 | return len(data) |
|
2330 | 2331 | |
|
2331 | 2332 | def wwritedata(self, filename, data): |
|
2332 | 2333 | return self._filter(self._decodefilterpats, filename, data) |
|
2333 | 2334 | |
|
2334 | 2335 | def currenttransaction(self): |
|
2335 | 2336 | """return the current transaction or None if non exists""" |
|
2336 | 2337 | if self._transref: |
|
2337 | 2338 | tr = self._transref() |
|
2338 | 2339 | else: |
|
2339 | 2340 | tr = None |
|
2340 | 2341 | |
|
2341 | 2342 | if tr and tr.running(): |
|
2342 | 2343 | return tr |
|
2343 | 2344 | return None |
|
2344 | 2345 | |
|
2345 | 2346 | def transaction(self, desc, report=None): |
|
2346 | 2347 | if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool( |
|
2347 | 2348 | b'devel', b'check-locks' |
|
2348 | 2349 | ): |
|
2349 | 2350 | if self._currentlock(self._lockref) is None: |
|
2350 | 2351 | raise error.ProgrammingError(b'transaction requires locking') |
|
2351 | 2352 | tr = self.currenttransaction() |
|
2352 | 2353 | if tr is not None: |
|
2353 | 2354 | return tr.nest(name=desc) |
|
2354 | 2355 | |
|
2355 | 2356 | # abort here if the journal already exists |
|
2356 | 2357 | if self.svfs.exists(b"journal"): |
|
2357 | 2358 | raise error.RepoError( |
|
2358 | 2359 | _(b"abandoned transaction found"), |
|
2359 | 2360 | hint=_(b"run 'hg recover' to clean up transaction"), |
|
2360 | 2361 | ) |
|
2361 | 2362 | |
|
2362 | 2363 | idbase = b"%.40f#%f" % (random.random(), time.time()) |
|
2363 | 2364 | ha = hex(hashutil.sha1(idbase).digest()) |
|
2364 | 2365 | txnid = b'TXN:' + ha |
|
2365 | 2366 | self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid) |
|
2366 | 2367 | |
|
2367 | 2368 | self._writejournal(desc) |
|
2368 | 2369 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
|
2369 | 2370 | if report: |
|
2370 | 2371 | rp = report |
|
2371 | 2372 | else: |
|
2372 | 2373 | rp = self.ui.warn |
|
2373 | 2374 | vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/ |
|
2374 | 2375 | # we must avoid cyclic reference between repo and transaction. |
|
2375 | 2376 | reporef = weakref.ref(self) |
|
2376 | 2377 | # Code to track tag movement |
|
2377 | 2378 | # |
|
2378 | 2379 | # Since tags are all handled as file content, it is actually quite hard |
|
2379 | 2380 | # to track these movement from a code perspective. So we fallback to a |
|
2380 | 2381 | # tracking at the repository level. One could envision to track changes |
|
2381 | 2382 | # to the '.hgtags' file through changegroup apply but that fails to |
|
2382 | 2383 | # cope with case where transaction expose new heads without changegroup |
|
2383 | 2384 | # being involved (eg: phase movement). |
|
2384 | 2385 | # |
|
2385 | 2386 | # For now, We gate the feature behind a flag since this likely comes |
|
2386 | 2387 | # with performance impacts. The current code run more often than needed |
|
2387 | 2388 | # and do not use caches as much as it could. The current focus is on |
|
2388 | 2389 | # the behavior of the feature so we disable it by default. The flag |
|
2389 | 2390 | # will be removed when we are happy with the performance impact. |
|
2390 | 2391 | # |
|
2391 | 2392 | # Once this feature is no longer experimental move the following |
|
2392 | 2393 | # documentation to the appropriate help section: |
|
2393 | 2394 | # |
|
2394 | 2395 | # The ``HG_TAG_MOVED`` variable will be set if the transaction touched |
|
2395 | 2396 | # tags (new or changed or deleted tags). In addition the details of |
|
2396 | 2397 | # these changes are made available in a file at: |
|
2397 | 2398 | # ``REPOROOT/.hg/changes/tags.changes``. |
|
2398 | 2399 | # Make sure you check for HG_TAG_MOVED before reading that file as it |
|
2399 | 2400 | # might exist from a previous transaction even if no tag were touched |
|
2400 | 2401 | # in this one. Changes are recorded in a line base format:: |
|
2401 | 2402 | # |
|
2402 | 2403 | # <action> <hex-node> <tag-name>\n |
|
2403 | 2404 | # |
|
2404 | 2405 | # Actions are defined as follow: |
|
2405 | 2406 | # "-R": tag is removed, |
|
2406 | 2407 | # "+A": tag is added, |
|
2407 | 2408 | # "-M": tag is moved (old value), |
|
2408 | 2409 | # "+M": tag is moved (new value), |
|
2409 | 2410 | tracktags = lambda x: None |
|
2410 | 2411 | # experimental config: experimental.hook-track-tags |
|
2411 | 2412 | shouldtracktags = self.ui.configbool( |
|
2412 | 2413 | b'experimental', b'hook-track-tags' |
|
2413 | 2414 | ) |
|
2414 | 2415 | if desc != b'strip' and shouldtracktags: |
|
2415 | 2416 | oldheads = self.changelog.headrevs() |
|
2416 | 2417 | |
|
2417 | 2418 | def tracktags(tr2): |
|
2418 | 2419 | repo = reporef() |
|
2419 | 2420 | assert repo is not None # help pytype |
|
2420 | 2421 | oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads) |
|
2421 | 2422 | newheads = repo.changelog.headrevs() |
|
2422 | 2423 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) |
|
2423 | 2424 | # notes: we compare lists here. |
|
2424 | 2425 | # As we do it only once buiding set would not be cheaper |
|
2425 | 2426 | changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes) |
|
2426 | 2427 | if changes: |
|
2427 | 2428 | tr2.hookargs[b'tag_moved'] = b'1' |
|
2428 | 2429 | with repo.vfs( |
|
2429 | 2430 | b'changes/tags.changes', b'w', atomictemp=True |
|
2430 | 2431 | ) as changesfile: |
|
2431 | 2432 | # note: we do not register the file to the transaction |
|
2432 | 2433 | # because we needs it to still exist on the transaction |
|
2433 | 2434 | # is close (for txnclose hooks) |
|
2434 | 2435 | tagsmod.writediff(changesfile, changes) |
|
2435 | 2436 | |
|
2436 | 2437 | def validate(tr2): |
|
2437 | 2438 | """will run pre-closing hooks""" |
|
2438 | 2439 | # XXX the transaction API is a bit lacking here so we take a hacky |
|
2439 | 2440 | # path for now |
|
2440 | 2441 | # |
|
2441 | 2442 | # We cannot add this as a "pending" hooks since the 'tr.hookargs' |
|
2442 | 2443 | # dict is copied before these run. In addition we needs the data |
|
2443 | 2444 | # available to in memory hooks too. |
|
2444 | 2445 | # |
|
2445 | 2446 | # Moreover, we also need to make sure this runs before txnclose |
|
2446 | 2447 | # hooks and there is no "pending" mechanism that would execute |
|
2447 | 2448 | # logic only if hooks are about to run. |
|
2448 | 2449 | # |
|
2449 | 2450 | # Fixing this limitation of the transaction is also needed to track |
|
2450 | 2451 | # other families of changes (bookmarks, phases, obsolescence). |
|
2451 | 2452 | # |
|
2452 | 2453 | # This will have to be fixed before we remove the experimental |
|
2453 | 2454 | # gating. |
|
2454 | 2455 | tracktags(tr2) |
|
2455 | 2456 | repo = reporef() |
|
2456 | 2457 | assert repo is not None # help pytype |
|
2457 | 2458 | |
|
2458 | 2459 | singleheadopt = (b'experimental', b'single-head-per-branch') |
|
2459 | 2460 | singlehead = repo.ui.configbool(*singleheadopt) |
|
2460 | 2461 | if singlehead: |
|
2461 | 2462 | singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1] |
|
2462 | 2463 | accountclosed = singleheadsub.get( |
|
2463 | 2464 | b"account-closed-heads", False |
|
2464 | 2465 | ) |
|
2465 | 2466 | if singleheadsub.get(b"public-changes-only", False): |
|
2466 | 2467 | filtername = b"immutable" |
|
2467 | 2468 | else: |
|
2468 | 2469 | filtername = b"visible" |
|
2469 | 2470 | scmutil.enforcesinglehead( |
|
2470 | 2471 | repo, tr2, desc, accountclosed, filtername |
|
2471 | 2472 | ) |
|
2472 | 2473 | if hook.hashook(repo.ui, b'pretxnclose-bookmark'): |
|
2473 | 2474 | for name, (old, new) in sorted( |
|
2474 | 2475 | tr.changes[b'bookmarks'].items() |
|
2475 | 2476 | ): |
|
2476 | 2477 | args = tr.hookargs.copy() |
|
2477 | 2478 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
2478 | 2479 | repo.hook( |
|
2479 | 2480 | b'pretxnclose-bookmark', |
|
2480 | 2481 | throw=True, |
|
2481 | 2482 | **pycompat.strkwargs(args) |
|
2482 | 2483 | ) |
|
2483 | 2484 | if hook.hashook(repo.ui, b'pretxnclose-phase'): |
|
2484 | 2485 | cl = repo.unfiltered().changelog |
|
2485 | 2486 | for revs, (old, new) in tr.changes[b'phases']: |
|
2486 | 2487 | for rev in revs: |
|
2487 | 2488 | args = tr.hookargs.copy() |
|
2488 | 2489 | node = hex(cl.node(rev)) |
|
2489 | 2490 | args.update(phases.preparehookargs(node, old, new)) |
|
2490 | 2491 | repo.hook( |
|
2491 | 2492 | b'pretxnclose-phase', |
|
2492 | 2493 | throw=True, |
|
2493 | 2494 | **pycompat.strkwargs(args) |
|
2494 | 2495 | ) |
|
2495 | 2496 | |
|
2496 | 2497 | repo.hook( |
|
2497 | 2498 | b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs) |
|
2498 | 2499 | ) |
|
2499 | 2500 | |
|
2500 | 2501 | def releasefn(tr, success): |
|
2501 | 2502 | repo = reporef() |
|
2502 | 2503 | if repo is None: |
|
2503 | 2504 | # If the repo has been GC'd (and this release function is being |
|
2504 | 2505 | # called from transaction.__del__), there's not much we can do, |
|
2505 | 2506 | # so just leave the unfinished transaction there and let the |
|
2506 | 2507 | # user run `hg recover`. |
|
2507 | 2508 | return |
|
2508 | 2509 | if success: |
|
2509 | 2510 | # this should be explicitly invoked here, because |
|
2510 | 2511 | # in-memory changes aren't written out at closing |
|
2511 | 2512 | # transaction, if tr.addfilegenerator (via |
|
2512 | 2513 | # dirstate.write or so) isn't invoked while |
|
2513 | 2514 | # transaction running |
|
2514 | 2515 | repo.dirstate.write(None) |
|
2515 | 2516 | else: |
|
2516 | 2517 | # discard all changes (including ones already written |
|
2517 | 2518 | # out) in this transaction |
|
2518 | 2519 | narrowspec.restorebackup(self, b'journal.narrowspec') |
|
2519 | 2520 | narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate') |
|
2520 | 2521 | repo.dirstate.restorebackup(None, b'journal.dirstate') |
|
2521 | 2522 | |
|
2522 | 2523 | repo.invalidate(clearfilecache=True) |
|
2523 | 2524 | |
|
2524 | 2525 | tr = transaction.transaction( |
|
2525 | 2526 | rp, |
|
2526 | 2527 | self.svfs, |
|
2527 | 2528 | vfsmap, |
|
2528 | 2529 | b"journal", |
|
2529 | 2530 | b"undo", |
|
2530 | 2531 | aftertrans(renames), |
|
2531 | 2532 | self.store.createmode, |
|
2532 | 2533 | validator=validate, |
|
2533 | 2534 | releasefn=releasefn, |
|
2534 | 2535 | checkambigfiles=_cachedfiles, |
|
2535 | 2536 | name=desc, |
|
2536 | 2537 | ) |
|
2537 | 2538 | tr.changes[b'origrepolen'] = len(self) |
|
2538 | 2539 | tr.changes[b'obsmarkers'] = set() |
|
2539 | 2540 | tr.changes[b'phases'] = [] |
|
2540 | 2541 | tr.changes[b'bookmarks'] = {} |
|
2541 | 2542 | |
|
2542 | 2543 | tr.hookargs[b'txnid'] = txnid |
|
2543 | 2544 | tr.hookargs[b'txnname'] = desc |
|
2544 | 2545 | tr.hookargs[b'changes'] = tr.changes |
|
2545 | 2546 | # note: writing the fncache only during finalize mean that the file is |
|
2546 | 2547 | # outdated when running hooks. As fncache is used for streaming clone, |
|
2547 | 2548 | # this is not expected to break anything that happen during the hooks. |
|
2548 | 2549 | tr.addfinalize(b'flush-fncache', self.store.write) |
|
2549 | 2550 | |
|
2550 | 2551 | def txnclosehook(tr2): |
|
2551 | 2552 | """To be run if transaction is successful, will schedule a hook run""" |
|
2552 | 2553 | # Don't reference tr2 in hook() so we don't hold a reference. |
|
2553 | 2554 | # This reduces memory consumption when there are multiple |
|
2554 | 2555 | # transactions per lock. This can likely go away if issue5045 |
|
2555 | 2556 | # fixes the function accumulation. |
|
2556 | 2557 | hookargs = tr2.hookargs |
|
2557 | 2558 | |
|
2558 | 2559 | def hookfunc(unused_success): |
|
2559 | 2560 | repo = reporef() |
|
2560 | 2561 | assert repo is not None # help pytype |
|
2561 | 2562 | |
|
2562 | 2563 | if hook.hashook(repo.ui, b'txnclose-bookmark'): |
|
2563 | 2564 | bmchanges = sorted(tr.changes[b'bookmarks'].items()) |
|
2564 | 2565 | for name, (old, new) in bmchanges: |
|
2565 | 2566 | args = tr.hookargs.copy() |
|
2566 | 2567 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
2567 | 2568 | repo.hook( |
|
2568 | 2569 | b'txnclose-bookmark', |
|
2569 | 2570 | throw=False, |
|
2570 | 2571 | **pycompat.strkwargs(args) |
|
2571 | 2572 | ) |
|
2572 | 2573 | |
|
2573 | 2574 | if hook.hashook(repo.ui, b'txnclose-phase'): |
|
2574 | 2575 | cl = repo.unfiltered().changelog |
|
2575 | 2576 | phasemv = sorted( |
|
2576 | 2577 | tr.changes[b'phases'], key=lambda r: r[0][0] |
|
2577 | 2578 | ) |
|
2578 | 2579 | for revs, (old, new) in phasemv: |
|
2579 | 2580 | for rev in revs: |
|
2580 | 2581 | args = tr.hookargs.copy() |
|
2581 | 2582 | node = hex(cl.node(rev)) |
|
2582 | 2583 | args.update(phases.preparehookargs(node, old, new)) |
|
2583 | 2584 | repo.hook( |
|
2584 | 2585 | b'txnclose-phase', |
|
2585 | 2586 | throw=False, |
|
2586 | 2587 | **pycompat.strkwargs(args) |
|
2587 | 2588 | ) |
|
2588 | 2589 | |
|
2589 | 2590 | repo.hook( |
|
2590 | 2591 | b'txnclose', throw=False, **pycompat.strkwargs(hookargs) |
|
2591 | 2592 | ) |
|
2592 | 2593 | |
|
2593 | 2594 | repo = reporef() |
|
2594 | 2595 | assert repo is not None # help pytype |
|
2595 | 2596 | repo._afterlock(hookfunc) |
|
2596 | 2597 | |
|
2597 | 2598 | tr.addfinalize(b'txnclose-hook', txnclosehook) |
|
2598 | 2599 | # Include a leading "-" to make it happen before the transaction summary |
|
2599 | 2600 | # reports registered via scmutil.registersummarycallback() whose names |
|
2600 | 2601 | # are 00-txnreport etc. That way, the caches will be warm when the |
|
2601 | 2602 | # callbacks run. |
|
2602 | 2603 | tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr)) |
|
2603 | 2604 | |
|
2604 | 2605 | def txnaborthook(tr2): |
|
2605 | 2606 | """To be run if transaction is aborted""" |
|
2606 | 2607 | repo = reporef() |
|
2607 | 2608 | assert repo is not None # help pytype |
|
2608 | 2609 | repo.hook( |
|
2609 | 2610 | b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs) |
|
2610 | 2611 | ) |
|
2611 | 2612 | |
|
2612 | 2613 | tr.addabort(b'txnabort-hook', txnaborthook) |
|
2613 | 2614 | # avoid eager cache invalidation. in-memory data should be identical |
|
2614 | 2615 | # to stored data if transaction has no error. |
|
2615 | 2616 | tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats) |
|
2616 | 2617 | self._transref = weakref.ref(tr) |
|
2617 | 2618 | scmutil.registersummarycallback(self, tr, desc) |
|
2618 | 2619 | return tr |
|
2619 | 2620 | |
|
2620 | 2621 | def _journalfiles(self): |
|
2621 | 2622 | return ( |
|
2622 | 2623 | (self.svfs, b'journal'), |
|
2623 | 2624 | (self.svfs, b'journal.narrowspec'), |
|
2624 | 2625 | (self.vfs, b'journal.narrowspec.dirstate'), |
|
2625 | 2626 | (self.vfs, b'journal.dirstate'), |
|
2626 | 2627 | (self.vfs, b'journal.branch'), |
|
2627 | 2628 | (self.vfs, b'journal.desc'), |
|
2628 | 2629 | (bookmarks.bookmarksvfs(self), b'journal.bookmarks'), |
|
2629 | 2630 | (self.svfs, b'journal.phaseroots'), |
|
2630 | 2631 | ) |
|
2631 | 2632 | |
|
2632 | 2633 | def undofiles(self): |
|
2633 | 2634 | return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] |
|
2634 | 2635 | |
|
2635 | 2636 | @unfilteredmethod |
|
2636 | 2637 | def _writejournal(self, desc): |
|
2637 | 2638 | self.dirstate.savebackup(None, b'journal.dirstate') |
|
2638 | 2639 | narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate') |
|
2639 | 2640 | narrowspec.savebackup(self, b'journal.narrowspec') |
|
2640 | 2641 | self.vfs.write( |
|
2641 | 2642 | b"journal.branch", encoding.fromlocal(self.dirstate.branch()) |
|
2642 | 2643 | ) |
|
2643 | 2644 | self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc)) |
|
2644 | 2645 | bookmarksvfs = bookmarks.bookmarksvfs(self) |
|
2645 | 2646 | bookmarksvfs.write( |
|
2646 | 2647 | b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks") |
|
2647 | 2648 | ) |
|
2648 | 2649 | self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots")) |
|
2649 | 2650 | |
|
2650 | 2651 | def recover(self): |
|
2651 | 2652 | with self.lock(): |
|
2652 | 2653 | if self.svfs.exists(b"journal"): |
|
2653 | 2654 | self.ui.status(_(b"rolling back interrupted transaction\n")) |
|
2654 | 2655 | vfsmap = { |
|
2655 | 2656 | b'': self.svfs, |
|
2656 | 2657 | b'plain': self.vfs, |
|
2657 | 2658 | } |
|
2658 | 2659 | transaction.rollback( |
|
2659 | 2660 | self.svfs, |
|
2660 | 2661 | vfsmap, |
|
2661 | 2662 | b"journal", |
|
2662 | 2663 | self.ui.warn, |
|
2663 | 2664 | checkambigfiles=_cachedfiles, |
|
2664 | 2665 | ) |
|
2665 | 2666 | self.invalidate() |
|
2666 | 2667 | return True |
|
2667 | 2668 | else: |
|
2668 | 2669 | self.ui.warn(_(b"no interrupted transaction available\n")) |
|
2669 | 2670 | return False |
|
2670 | 2671 | |
|
2671 | 2672 | def rollback(self, dryrun=False, force=False): |
|
2672 | 2673 | wlock = lock = dsguard = None |
|
2673 | 2674 | try: |
|
2674 | 2675 | wlock = self.wlock() |
|
2675 | 2676 | lock = self.lock() |
|
2676 | 2677 | if self.svfs.exists(b"undo"): |
|
2677 | 2678 | dsguard = dirstateguard.dirstateguard(self, b'rollback') |
|
2678 | 2679 | |
|
2679 | 2680 | return self._rollback(dryrun, force, dsguard) |
|
2680 | 2681 | else: |
|
2681 | 2682 | self.ui.warn(_(b"no rollback information available\n")) |
|
2682 | 2683 | return 1 |
|
2683 | 2684 | finally: |
|
2684 | 2685 | release(dsguard, lock, wlock) |
|
2685 | 2686 | |
|
2686 | 2687 | @unfilteredmethod # Until we get smarter cache management |
|
2687 | 2688 | def _rollback(self, dryrun, force, dsguard): |
|
2688 | 2689 | ui = self.ui |
|
2689 | 2690 | try: |
|
2690 | 2691 | args = self.vfs.read(b'undo.desc').splitlines() |
|
2691 | 2692 | (oldlen, desc, detail) = (int(args[0]), args[1], None) |
|
2692 | 2693 | if len(args) >= 3: |
|
2693 | 2694 | detail = args[2] |
|
2694 | 2695 | oldtip = oldlen - 1 |
|
2695 | 2696 | |
|
2696 | 2697 | if detail and ui.verbose: |
|
2697 | 2698 | msg = _( |
|
2698 | 2699 | b'repository tip rolled back to revision %d' |
|
2699 | 2700 | b' (undo %s: %s)\n' |
|
2700 | 2701 | ) % (oldtip, desc, detail) |
|
2701 | 2702 | else: |
|
2702 | 2703 | msg = _( |
|
2703 | 2704 | b'repository tip rolled back to revision %d (undo %s)\n' |
|
2704 | 2705 | ) % (oldtip, desc) |
|
2705 | 2706 | except IOError: |
|
2706 | 2707 | msg = _(b'rolling back unknown transaction\n') |
|
2707 | 2708 | desc = None |
|
2708 | 2709 | |
|
2709 | 2710 | if not force and self[b'.'] != self[b'tip'] and desc == b'commit': |
|
2710 | 2711 | raise error.Abort( |
|
2711 | 2712 | _( |
|
2712 | 2713 | b'rollback of last commit while not checked out ' |
|
2713 | 2714 | b'may lose data' |
|
2714 | 2715 | ), |
|
2715 | 2716 | hint=_(b'use -f to force'), |
|
2716 | 2717 | ) |
|
2717 | 2718 | |
|
2718 | 2719 | ui.status(msg) |
|
2719 | 2720 | if dryrun: |
|
2720 | 2721 | return 0 |
|
2721 | 2722 | |
|
2722 | 2723 | parents = self.dirstate.parents() |
|
2723 | 2724 | self.destroying() |
|
2724 | 2725 | vfsmap = {b'plain': self.vfs, b'': self.svfs} |
|
2725 | 2726 | transaction.rollback( |
|
2726 | 2727 | self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles |
|
2727 | 2728 | ) |
|
2728 | 2729 | bookmarksvfs = bookmarks.bookmarksvfs(self) |
|
2729 | 2730 | if bookmarksvfs.exists(b'undo.bookmarks'): |
|
2730 | 2731 | bookmarksvfs.rename( |
|
2731 | 2732 | b'undo.bookmarks', b'bookmarks', checkambig=True |
|
2732 | 2733 | ) |
|
2733 | 2734 | if self.svfs.exists(b'undo.phaseroots'): |
|
2734 | 2735 | self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True) |
|
2735 | 2736 | self.invalidate() |
|
2736 | 2737 | |
|
2737 | 2738 | has_node = self.changelog.index.has_node |
|
2738 | 2739 | parentgone = any(not has_node(p) for p in parents) |
|
2739 | 2740 | if parentgone: |
|
2740 | 2741 | # prevent dirstateguard from overwriting already restored one |
|
2741 | 2742 | dsguard.close() |
|
2742 | 2743 | |
|
2743 | 2744 | narrowspec.restorebackup(self, b'undo.narrowspec') |
|
2744 | 2745 | narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate') |
|
2745 | 2746 | self.dirstate.restorebackup(None, b'undo.dirstate') |
|
2746 | 2747 | try: |
|
2747 | 2748 | branch = self.vfs.read(b'undo.branch') |
|
2748 | 2749 | self.dirstate.setbranch(encoding.tolocal(branch)) |
|
2749 | 2750 | except IOError: |
|
2750 | 2751 | ui.warn( |
|
2751 | 2752 | _( |
|
2752 | 2753 | b'named branch could not be reset: ' |
|
2753 | 2754 | b'current branch is still \'%s\'\n' |
|
2754 | 2755 | ) |
|
2755 | 2756 | % self.dirstate.branch() |
|
2756 | 2757 | ) |
|
2757 | 2758 | |
|
2758 | 2759 | parents = tuple([p.rev() for p in self[None].parents()]) |
|
2759 | 2760 | if len(parents) > 1: |
|
2760 | 2761 | ui.status( |
|
2761 | 2762 | _( |
|
2762 | 2763 | b'working directory now based on ' |
|
2763 | 2764 | b'revisions %d and %d\n' |
|
2764 | 2765 | ) |
|
2765 | 2766 | % parents |
|
2766 | 2767 | ) |
|
2767 | 2768 | else: |
|
2768 | 2769 | ui.status( |
|
2769 | 2770 | _(b'working directory now based on revision %d\n') % parents |
|
2770 | 2771 | ) |
|
2771 | 2772 | mergestatemod.mergestate.clean(self) |
|
2772 | 2773 | |
|
2773 | 2774 | # TODO: if we know which new heads may result from this rollback, pass |
|
2774 | 2775 | # them to destroy(), which will prevent the branchhead cache from being |
|
2775 | 2776 | # invalidated. |
|
2776 | 2777 | self.destroyed() |
|
2777 | 2778 | return 0 |
|
2778 | 2779 | |
|
2779 | 2780 | def _buildcacheupdater(self, newtransaction): |
|
2780 | 2781 | """called during transaction to build the callback updating cache |
|
2781 | 2782 | |
|
2782 | 2783 | Lives on the repository to help extension who might want to augment |
|
2783 | 2784 | this logic. For this purpose, the created transaction is passed to the |
|
2784 | 2785 | method. |
|
2785 | 2786 | """ |
|
2786 | 2787 | # we must avoid cyclic reference between repo and transaction. |
|
2787 | 2788 | reporef = weakref.ref(self) |
|
2788 | 2789 | |
|
2789 | 2790 | def updater(tr): |
|
2790 | 2791 | repo = reporef() |
|
2791 | 2792 | assert repo is not None # help pytype |
|
2792 | 2793 | repo.updatecaches(tr) |
|
2793 | 2794 | |
|
2794 | 2795 | return updater |
|
2795 | 2796 | |
|
2796 | 2797 | @unfilteredmethod |
|
2797 | 2798 | def updatecaches(self, tr=None, full=False, caches=None): |
|
2798 | 2799 | """warm appropriate caches |
|
2799 | 2800 | |
|
2800 | 2801 | If this function is called after a transaction closed. The transaction |
|
2801 | 2802 | will be available in the 'tr' argument. This can be used to selectively |
|
2802 | 2803 | update caches relevant to the changes in that transaction. |
|
2803 | 2804 | |
|
2804 | 2805 | If 'full' is set, make sure all caches the function knows about have |
|
2805 | 2806 | up-to-date data. Even the ones usually loaded more lazily. |
|
2806 | 2807 | |
|
2807 | 2808 | The `full` argument can take a special "post-clone" value. In this case |
|
2808 | 2809 | the cache warming is made after a clone and of the slower cache might |
|
2809 | 2810 | be skipped, namely the `.fnodetags` one. This argument is 5.8 specific |
|
2810 | 2811 | as we plan for a cleaner way to deal with this for 5.9. |
|
2811 | 2812 | """ |
|
2812 | 2813 | if tr is not None and tr.hookargs.get(b'source') == b'strip': |
|
2813 | 2814 | # During strip, many caches are invalid but |
|
2814 | 2815 | # later call to `destroyed` will refresh them. |
|
2815 | 2816 | return |
|
2816 | 2817 | |
|
2817 | 2818 | unfi = self.unfiltered() |
|
2818 | 2819 | |
|
2819 | 2820 | if full: |
|
2820 | 2821 | msg = ( |
|
2821 | 2822 | "`full` argument for `repo.updatecaches` is deprecated\n" |
|
2822 | 2823 | "(use `caches=repository.CACHE_ALL` instead)" |
|
2823 | 2824 | ) |
|
2824 | 2825 | self.ui.deprecwarn(msg, b"5.9") |
|
2825 | 2826 | caches = repository.CACHES_ALL |
|
2826 | 2827 | if full == b"post-clone": |
|
2827 | 2828 | caches = repository.CACHES_POST_CLONE |
|
2828 | 2829 | caches = repository.CACHES_ALL |
|
2829 | 2830 | elif caches is None: |
|
2830 | 2831 | caches = repository.CACHES_DEFAULT |
|
2831 | 2832 | |
|
2832 | 2833 | if repository.CACHE_BRANCHMAP_SERVED in caches: |
|
2833 | 2834 | if tr is None or tr.changes[b'origrepolen'] < len(self): |
|
2834 | 2835 | # accessing the 'served' branchmap should refresh all the others, |
|
2835 | 2836 | self.ui.debug(b'updating the branch cache\n') |
|
2836 | 2837 | self.filtered(b'served').branchmap() |
|
2837 | 2838 | self.filtered(b'served.hidden').branchmap() |
|
2838 | 2839 | # flush all possibly delayed write. |
|
2839 | 2840 | self._branchcaches.write_delayed(self) |
|
2840 | 2841 | |
|
2841 | 2842 | if repository.CACHE_CHANGELOG_CACHE in caches: |
|
2842 | 2843 | self.changelog.update_caches(transaction=tr) |
|
2843 | 2844 | |
|
2844 | 2845 | if repository.CACHE_MANIFESTLOG_CACHE in caches: |
|
2845 | 2846 | self.manifestlog.update_caches(transaction=tr) |
|
2846 | 2847 | |
|
2847 | 2848 | if repository.CACHE_REV_BRANCH in caches: |
|
2848 | 2849 | rbc = unfi.revbranchcache() |
|
2849 | 2850 | for r in unfi.changelog: |
|
2850 | 2851 | rbc.branchinfo(r) |
|
2851 | 2852 | rbc.write() |
|
2852 | 2853 | |
|
2853 | 2854 | if repository.CACHE_FULL_MANIFEST in caches: |
|
2854 | 2855 | # ensure the working copy parents are in the manifestfulltextcache |
|
2855 | 2856 | for ctx in self[b'.'].parents(): |
|
2856 | 2857 | ctx.manifest() # accessing the manifest is enough |
|
2857 | 2858 | |
|
2858 | 2859 | if repository.CACHE_FILE_NODE_TAGS in caches: |
|
2859 | 2860 | # accessing fnode cache warms the cache |
|
2860 | 2861 | tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs()) |
|
2861 | 2862 | |
|
2862 | 2863 | if repository.CACHE_TAGS_DEFAULT in caches: |
|
2863 | 2864 | # accessing tags warm the cache |
|
2864 | 2865 | self.tags() |
|
2865 | 2866 | if repository.CACHE_TAGS_SERVED in caches: |
|
2866 | 2867 | self.filtered(b'served').tags() |
|
2867 | 2868 | |
|
2868 | 2869 | if repository.CACHE_BRANCHMAP_ALL in caches: |
|
2869 | 2870 | # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately, |
|
2870 | 2871 | # so we're forcing a write to cause these caches to be warmed up |
|
2871 | 2872 | # even if they haven't explicitly been requested yet (if they've |
|
2872 | 2873 | # never been used by hg, they won't ever have been written, even if |
|
2873 | 2874 | # they're a subset of another kind of cache that *has* been used). |
|
2874 | 2875 | for filt in repoview.filtertable.keys(): |
|
2875 | 2876 | filtered = self.filtered(filt) |
|
2876 | 2877 | filtered.branchmap().write(filtered) |
|
2877 | 2878 | |
|
2878 | 2879 | def invalidatecaches(self): |
|
2879 | 2880 | |
|
2880 | 2881 | if '_tagscache' in vars(self): |
|
2881 | 2882 | # can't use delattr on proxy |
|
2882 | 2883 | del self.__dict__['_tagscache'] |
|
2883 | 2884 | |
|
2884 | 2885 | self._branchcaches.clear() |
|
2885 | 2886 | self.invalidatevolatilesets() |
|
2886 | 2887 | self._sparsesignaturecache.clear() |
|
2887 | 2888 | |
|
2888 | 2889 | def invalidatevolatilesets(self): |
|
2889 | 2890 | self.filteredrevcache.clear() |
|
2890 | 2891 | obsolete.clearobscaches(self) |
|
2891 | 2892 | self._quick_access_changeid_invalidate() |
|
2892 | 2893 | |
|
2893 | 2894 | def invalidatedirstate(self): |
|
2894 | 2895 | """Invalidates the dirstate, causing the next call to dirstate |
|
2895 | 2896 | to check if it was modified since the last time it was read, |
|
2896 | 2897 | rereading it if it has. |
|
2897 | 2898 | |
|
2898 | 2899 | This is different to dirstate.invalidate() that it doesn't always |
|
2899 | 2900 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
2900 | 2901 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
2901 | 2902 | known good state).""" |
|
2902 | 2903 | if hasunfilteredcache(self, 'dirstate'): |
|
2903 | 2904 | for k in self.dirstate._filecache: |
|
2904 | 2905 | try: |
|
2905 | 2906 | delattr(self.dirstate, k) |
|
2906 | 2907 | except AttributeError: |
|
2907 | 2908 | pass |
|
2908 | 2909 | delattr(self.unfiltered(), 'dirstate') |
|
2909 | 2910 | |
|
2910 | 2911 | def invalidate(self, clearfilecache=False): |
|
2911 | 2912 | """Invalidates both store and non-store parts other than dirstate |
|
2912 | 2913 | |
|
2913 | 2914 | If a transaction is running, invalidation of store is omitted, |
|
2914 | 2915 | because discarding in-memory changes might cause inconsistency |
|
2915 | 2916 | (e.g. incomplete fncache causes unintentional failure, but |
|
2916 | 2917 | redundant one doesn't). |
|
2917 | 2918 | """ |
|
2918 | 2919 | unfiltered = self.unfiltered() # all file caches are stored unfiltered |
|
2919 | 2920 | for k in list(self._filecache.keys()): |
|
2920 | 2921 | # dirstate is invalidated separately in invalidatedirstate() |
|
2921 | 2922 | if k == b'dirstate': |
|
2922 | 2923 | continue |
|
2923 | 2924 | if ( |
|
2924 | 2925 | k == b'changelog' |
|
2925 | 2926 | and self.currenttransaction() |
|
2926 | 2927 | and self.changelog._delayed |
|
2927 | 2928 | ): |
|
2928 | 2929 | # The changelog object may store unwritten revisions. We don't |
|
2929 | 2930 | # want to lose them. |
|
2930 | 2931 | # TODO: Solve the problem instead of working around it. |
|
2931 | 2932 | continue |
|
2932 | 2933 | |
|
2933 | 2934 | if clearfilecache: |
|
2934 | 2935 | del self._filecache[k] |
|
2935 | 2936 | try: |
|
2936 | 2937 | delattr(unfiltered, k) |
|
2937 | 2938 | except AttributeError: |
|
2938 | 2939 | pass |
|
2939 | 2940 | self.invalidatecaches() |
|
2940 | 2941 | if not self.currenttransaction(): |
|
2941 | 2942 | # TODO: Changing contents of store outside transaction |
|
2942 | 2943 | # causes inconsistency. We should make in-memory store |
|
2943 | 2944 | # changes detectable, and abort if changed. |
|
2944 | 2945 | self.store.invalidatecaches() |
|
2945 | 2946 | |
|
2946 | 2947 | def invalidateall(self): |
|
2947 | 2948 | """Fully invalidates both store and non-store parts, causing the |
|
2948 | 2949 | subsequent operation to reread any outside changes.""" |
|
2949 | 2950 | # extension should hook this to invalidate its caches |
|
2950 | 2951 | self.invalidate() |
|
2951 | 2952 | self.invalidatedirstate() |
|
2952 | 2953 | |
|
2953 | 2954 | @unfilteredmethod |
|
2954 | 2955 | def _refreshfilecachestats(self, tr): |
|
2955 | 2956 | """Reload stats of cached files so that they are flagged as valid""" |
|
2956 | 2957 | for k, ce in self._filecache.items(): |
|
2957 | 2958 | k = pycompat.sysstr(k) |
|
2958 | 2959 | if k == 'dirstate' or k not in self.__dict__: |
|
2959 | 2960 | continue |
|
2960 | 2961 | ce.refresh() |
|
2961 | 2962 | |
|
2962 | 2963 | def _lock( |
|
2963 | 2964 | self, |
|
2964 | 2965 | vfs, |
|
2965 | 2966 | lockname, |
|
2966 | 2967 | wait, |
|
2967 | 2968 | releasefn, |
|
2968 | 2969 | acquirefn, |
|
2969 | 2970 | desc, |
|
2970 | 2971 | ): |
|
2971 | 2972 | timeout = 0 |
|
2972 | 2973 | warntimeout = 0 |
|
2973 | 2974 | if wait: |
|
2974 | 2975 | timeout = self.ui.configint(b"ui", b"timeout") |
|
2975 | 2976 | warntimeout = self.ui.configint(b"ui", b"timeout.warn") |
|
2976 | 2977 | # internal config: ui.signal-safe-lock |
|
2977 | 2978 | signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock') |
|
2978 | 2979 | |
|
2979 | 2980 | l = lockmod.trylock( |
|
2980 | 2981 | self.ui, |
|
2981 | 2982 | vfs, |
|
2982 | 2983 | lockname, |
|
2983 | 2984 | timeout, |
|
2984 | 2985 | warntimeout, |
|
2985 | 2986 | releasefn=releasefn, |
|
2986 | 2987 | acquirefn=acquirefn, |
|
2987 | 2988 | desc=desc, |
|
2988 | 2989 | signalsafe=signalsafe, |
|
2989 | 2990 | ) |
|
2990 | 2991 | return l |
|
2991 | 2992 | |
|
2992 | 2993 | def _afterlock(self, callback): |
|
2993 | 2994 | """add a callback to be run when the repository is fully unlocked |
|
2994 | 2995 | |
|
2995 | 2996 | The callback will be executed when the outermost lock is released |
|
2996 | 2997 | (with wlock being higher level than 'lock').""" |
|
2997 | 2998 | for ref in (self._wlockref, self._lockref): |
|
2998 | 2999 | l = ref and ref() |
|
2999 | 3000 | if l and l.held: |
|
3000 | 3001 | l.postrelease.append(callback) |
|
3001 | 3002 | break |
|
3002 | 3003 | else: # no lock have been found. |
|
3003 | 3004 | callback(True) |
|
3004 | 3005 | |
|
3005 | 3006 | def lock(self, wait=True): |
|
3006 | 3007 | """Lock the repository store (.hg/store) and return a weak reference |
|
3007 | 3008 | to the lock. Use this before modifying the store (e.g. committing or |
|
3008 | 3009 | stripping). If you are opening a transaction, get a lock as well.) |
|
3009 | 3010 | |
|
3010 | 3011 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
3011 | 3012 | 'wlock' first to avoid a dead-lock hazard.""" |
|
3012 | 3013 | l = self._currentlock(self._lockref) |
|
3013 | 3014 | if l is not None: |
|
3014 | 3015 | l.lock() |
|
3015 | 3016 | return l |
|
3016 | 3017 | |
|
3017 | 3018 | l = self._lock( |
|
3018 | 3019 | vfs=self.svfs, |
|
3019 | 3020 | lockname=b"lock", |
|
3020 | 3021 | wait=wait, |
|
3021 | 3022 | releasefn=None, |
|
3022 | 3023 | acquirefn=self.invalidate, |
|
3023 | 3024 | desc=_(b'repository %s') % self.origroot, |
|
3024 | 3025 | ) |
|
3025 | 3026 | self._lockref = weakref.ref(l) |
|
3026 | 3027 | return l |
|
3027 | 3028 | |
|
3028 | 3029 | def wlock(self, wait=True): |
|
3029 | 3030 | """Lock the non-store parts of the repository (everything under |
|
3030 | 3031 | .hg except .hg/store) and return a weak reference to the lock. |
|
3031 | 3032 | |
|
3032 | 3033 | Use this before modifying files in .hg. |
|
3033 | 3034 | |
|
3034 | 3035 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
3035 | 3036 | 'wlock' first to avoid a dead-lock hazard.""" |
|
3036 | 3037 | l = self._wlockref() if self._wlockref else None |
|
3037 | 3038 | if l is not None and l.held: |
|
3038 | 3039 | l.lock() |
|
3039 | 3040 | return l |
|
3040 | 3041 | |
|
3041 | 3042 | # We do not need to check for non-waiting lock acquisition. Such |
|
3042 | 3043 | # acquisition would not cause dead-lock as they would just fail. |
|
3043 | 3044 | if wait and ( |
|
3044 | 3045 | self.ui.configbool(b'devel', b'all-warnings') |
|
3045 | 3046 | or self.ui.configbool(b'devel', b'check-locks') |
|
3046 | 3047 | ): |
|
3047 | 3048 | if self._currentlock(self._lockref) is not None: |
|
3048 | 3049 | self.ui.develwarn(b'"wlock" acquired after "lock"') |
|
3049 | 3050 | |
|
3050 | 3051 | def unlock(): |
|
3051 | 3052 | if self.dirstate.pendingparentchange(): |
|
3052 | 3053 | self.dirstate.invalidate() |
|
3053 | 3054 | else: |
|
3054 | 3055 | self.dirstate.write(None) |
|
3055 | 3056 | |
|
3056 | 3057 | self._filecache[b'dirstate'].refresh() |
|
3057 | 3058 | |
|
3058 | 3059 | l = self._lock( |
|
3059 | 3060 | self.vfs, |
|
3060 | 3061 | b"wlock", |
|
3061 | 3062 | wait, |
|
3062 | 3063 | unlock, |
|
3063 | 3064 | self.invalidatedirstate, |
|
3064 | 3065 | _(b'working directory of %s') % self.origroot, |
|
3065 | 3066 | ) |
|
3066 | 3067 | self._wlockref = weakref.ref(l) |
|
3067 | 3068 | return l |
|
3068 | 3069 | |
|
3069 | 3070 | def _currentlock(self, lockref): |
|
3070 | 3071 | """Returns the lock if it's held, or None if it's not.""" |
|
3071 | 3072 | if lockref is None: |
|
3072 | 3073 | return None |
|
3073 | 3074 | l = lockref() |
|
3074 | 3075 | if l is None or not l.held: |
|
3075 | 3076 | return None |
|
3076 | 3077 | return l |
|
3077 | 3078 | |
|
3078 | 3079 | def currentwlock(self): |
|
3079 | 3080 | """Returns the wlock if it's held, or None if it's not.""" |
|
3080 | 3081 | return self._currentlock(self._wlockref) |
|
3081 | 3082 | |
|
3082 | 3083 | def checkcommitpatterns(self, wctx, match, status, fail): |
|
3083 | 3084 | """check for commit arguments that aren't committable""" |
|
3084 | 3085 | if match.isexact() or match.prefix(): |
|
3085 | 3086 | matched = set(status.modified + status.added + status.removed) |
|
3086 | 3087 | |
|
3087 | 3088 | for f in match.files(): |
|
3088 | 3089 | f = self.dirstate.normalize(f) |
|
3089 | 3090 | if f == b'.' or f in matched or f in wctx.substate: |
|
3090 | 3091 | continue |
|
3091 | 3092 | if f in status.deleted: |
|
3092 | 3093 | fail(f, _(b'file not found!')) |
|
3093 | 3094 | # Is it a directory that exists or used to exist? |
|
3094 | 3095 | if self.wvfs.isdir(f) or wctx.p1().hasdir(f): |
|
3095 | 3096 | d = f + b'/' |
|
3096 | 3097 | for mf in matched: |
|
3097 | 3098 | if mf.startswith(d): |
|
3098 | 3099 | break |
|
3099 | 3100 | else: |
|
3100 | 3101 | fail(f, _(b"no match under directory!")) |
|
3101 | 3102 | elif f not in self.dirstate: |
|
3102 | 3103 | fail(f, _(b"file not tracked!")) |
|
3103 | 3104 | |
|
3104 | 3105 | @unfilteredmethod |
|
3105 | 3106 | def commit( |
|
3106 | 3107 | self, |
|
3107 | 3108 | text=b"", |
|
3108 | 3109 | user=None, |
|
3109 | 3110 | date=None, |
|
3110 | 3111 | match=None, |
|
3111 | 3112 | force=False, |
|
3112 | 3113 | editor=None, |
|
3113 | 3114 | extra=None, |
|
3114 | 3115 | ): |
|
3115 | 3116 | """Add a new revision to current repository. |
|
3116 | 3117 | |
|
3117 | 3118 | Revision information is gathered from the working directory, |
|
3118 | 3119 | match can be used to filter the committed files. If editor is |
|
3119 | 3120 | supplied, it is called to get a commit message. |
|
3120 | 3121 | """ |
|
3121 | 3122 | if extra is None: |
|
3122 | 3123 | extra = {} |
|
3123 | 3124 | |
|
3124 | 3125 | def fail(f, msg): |
|
3125 | 3126 | raise error.InputError(b'%s: %s' % (f, msg)) |
|
3126 | 3127 | |
|
3127 | 3128 | if not match: |
|
3128 | 3129 | match = matchmod.always() |
|
3129 | 3130 | |
|
3130 | 3131 | if not force: |
|
3131 | 3132 | match.bad = fail |
|
3132 | 3133 | |
|
3133 | 3134 | # lock() for recent changelog (see issue4368) |
|
3134 | 3135 | with self.wlock(), self.lock(): |
|
3135 | 3136 | wctx = self[None] |
|
3136 | 3137 | merge = len(wctx.parents()) > 1 |
|
3137 | 3138 | |
|
3138 | 3139 | if not force and merge and not match.always(): |
|
3139 | 3140 | raise error.Abort( |
|
3140 | 3141 | _( |
|
3141 | 3142 | b'cannot partially commit a merge ' |
|
3142 | 3143 | b'(do not specify files or patterns)' |
|
3143 | 3144 | ) |
|
3144 | 3145 | ) |
|
3145 | 3146 | |
|
3146 | 3147 | status = self.status(match=match, clean=force) |
|
3147 | 3148 | if force: |
|
3148 | 3149 | status.modified.extend( |
|
3149 | 3150 | status.clean |
|
3150 | 3151 | ) # mq may commit clean files |
|
3151 | 3152 | |
|
3152 | 3153 | # check subrepos |
|
3153 | 3154 | subs, commitsubs, newstate = subrepoutil.precommit( |
|
3154 | 3155 | self.ui, wctx, status, match, force=force |
|
3155 | 3156 | ) |
|
3156 | 3157 | |
|
3157 | 3158 | # make sure all explicit patterns are matched |
|
3158 | 3159 | if not force: |
|
3159 | 3160 | self.checkcommitpatterns(wctx, match, status, fail) |
|
3160 | 3161 | |
|
3161 | 3162 | cctx = context.workingcommitctx( |
|
3162 | 3163 | self, status, text, user, date, extra |
|
3163 | 3164 | ) |
|
3164 | 3165 | |
|
3165 | 3166 | ms = mergestatemod.mergestate.read(self) |
|
3166 | 3167 | mergeutil.checkunresolved(ms) |
|
3167 | 3168 | |
|
3168 | 3169 | # internal config: ui.allowemptycommit |
|
3169 | 3170 | if cctx.isempty() and not self.ui.configbool( |
|
3170 | 3171 | b'ui', b'allowemptycommit' |
|
3171 | 3172 | ): |
|
3172 | 3173 | self.ui.debug(b'nothing to commit, clearing merge state\n') |
|
3173 | 3174 | ms.reset() |
|
3174 | 3175 | return None |
|
3175 | 3176 | |
|
3176 | 3177 | if merge and cctx.deleted(): |
|
3177 | 3178 | raise error.Abort(_(b"cannot commit merge with missing files")) |
|
3178 | 3179 | |
|
3179 | 3180 | if editor: |
|
3180 | 3181 | cctx._text = editor(self, cctx, subs) |
|
3181 | 3182 | edited = text != cctx._text |
|
3182 | 3183 | |
|
3183 | 3184 | # Save commit message in case this transaction gets rolled back |
|
3184 | 3185 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
3185 | 3186 | # the assumption that the user will use the same editor again. |
|
3186 | 3187 | msg_path = self.savecommitmessage(cctx._text) |
|
3187 | 3188 | |
|
3188 | 3189 | # commit subs and write new state |
|
3189 | 3190 | if subs: |
|
3190 | 3191 | uipathfn = scmutil.getuipathfn(self) |
|
3191 | 3192 | for s in sorted(commitsubs): |
|
3192 | 3193 | sub = wctx.sub(s) |
|
3193 | 3194 | self.ui.status( |
|
3194 | 3195 | _(b'committing subrepository %s\n') |
|
3195 | 3196 | % uipathfn(subrepoutil.subrelpath(sub)) |
|
3196 | 3197 | ) |
|
3197 | 3198 | sr = sub.commit(cctx._text, user, date) |
|
3198 | 3199 | newstate[s] = (newstate[s][0], sr) |
|
3199 | 3200 | subrepoutil.writestate(self, newstate) |
|
3200 | 3201 | |
|
3201 | 3202 | p1, p2 = self.dirstate.parents() |
|
3202 | 3203 | hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'') |
|
3203 | 3204 | try: |
|
3204 | 3205 | self.hook( |
|
3205 | 3206 | b"precommit", throw=True, parent1=hookp1, parent2=hookp2 |
|
3206 | 3207 | ) |
|
3207 | 3208 | with self.transaction(b'commit'): |
|
3208 | 3209 | ret = self.commitctx(cctx, True) |
|
3209 | 3210 | # update bookmarks, dirstate and mergestate |
|
3210 | 3211 | bookmarks.update(self, [p1, p2], ret) |
|
3211 | 3212 | cctx.markcommitted(ret) |
|
3212 | 3213 | ms.reset() |
|
3213 | 3214 | except: # re-raises |
|
3214 | 3215 | if edited: |
|
3215 | 3216 | self.ui.write( |
|
3216 | 3217 | _(b'note: commit message saved in %s\n') % msg_path |
|
3217 | 3218 | ) |
|
3218 | 3219 | self.ui.write( |
|
3219 | 3220 | _( |
|
3220 | 3221 | b"note: use 'hg commit --logfile " |
|
3221 | 3222 | b"%s --edit' to reuse it\n" |
|
3222 | 3223 | ) |
|
3223 | 3224 | % msg_path |
|
3224 | 3225 | ) |
|
3225 | 3226 | raise |
|
3226 | 3227 | |
|
3227 | 3228 | def commithook(unused_success): |
|
3228 | 3229 | # hack for command that use a temporary commit (eg: histedit) |
|
3229 | 3230 | # temporary commit got stripped before hook release |
|
3230 | 3231 | if self.changelog.hasnode(ret): |
|
3231 | 3232 | self.hook( |
|
3232 | 3233 | b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2 |
|
3233 | 3234 | ) |
|
3234 | 3235 | |
|
3235 | 3236 | self._afterlock(commithook) |
|
3236 | 3237 | return ret |
|
3237 | 3238 | |
|
3238 | 3239 | @unfilteredmethod |
|
3239 | 3240 | def commitctx(self, ctx, error=False, origctx=None): |
|
3240 | 3241 | return commit.commitctx(self, ctx, error=error, origctx=origctx) |
|
3241 | 3242 | |
|
3242 | 3243 | @unfilteredmethod |
|
3243 | 3244 | def destroying(self): |
|
3244 | 3245 | """Inform the repository that nodes are about to be destroyed. |
|
3245 | 3246 | Intended for use by strip and rollback, so there's a common |
|
3246 | 3247 | place for anything that has to be done before destroying history. |
|
3247 | 3248 | |
|
3248 | 3249 | This is mostly useful for saving state that is in memory and waiting |
|
3249 | 3250 | to be flushed when the current lock is released. Because a call to |
|
3250 | 3251 | destroyed is imminent, the repo will be invalidated causing those |
|
3251 | 3252 | changes to stay in memory (waiting for the next unlock), or vanish |
|
3252 | 3253 | completely. |
|
3253 | 3254 | """ |
|
3254 | 3255 | # When using the same lock to commit and strip, the phasecache is left |
|
3255 | 3256 | # dirty after committing. Then when we strip, the repo is invalidated, |
|
3256 | 3257 | # causing those changes to disappear. |
|
3257 | 3258 | if '_phasecache' in vars(self): |
|
3258 | 3259 | self._phasecache.write() |
|
3259 | 3260 | |
|
3260 | 3261 | @unfilteredmethod |
|
3261 | 3262 | def destroyed(self): |
|
3262 | 3263 | """Inform the repository that nodes have been destroyed. |
|
3263 | 3264 | Intended for use by strip and rollback, so there's a common |
|
3264 | 3265 | place for anything that has to be done after destroying history. |
|
3265 | 3266 | """ |
|
3266 | 3267 | # When one tries to: |
|
3267 | 3268 | # 1) destroy nodes thus calling this method (e.g. strip) |
|
3268 | 3269 | # 2) use phasecache somewhere (e.g. commit) |
|
3269 | 3270 | # |
|
3270 | 3271 | # then 2) will fail because the phasecache contains nodes that were |
|
3271 | 3272 | # removed. We can either remove phasecache from the filecache, |
|
3272 | 3273 | # causing it to reload next time it is accessed, or simply filter |
|
3273 | 3274 | # the removed nodes now and write the updated cache. |
|
3274 | 3275 | self._phasecache.filterunknown(self) |
|
3275 | 3276 | self._phasecache.write() |
|
3276 | 3277 | |
|
3277 | 3278 | # refresh all repository caches |
|
3278 | 3279 | self.updatecaches() |
|
3279 | 3280 | |
|
3280 | 3281 | # Ensure the persistent tag cache is updated. Doing it now |
|
3281 | 3282 | # means that the tag cache only has to worry about destroyed |
|
3282 | 3283 | # heads immediately after a strip/rollback. That in turn |
|
3283 | 3284 | # guarantees that "cachetip == currenttip" (comparing both rev |
|
3284 | 3285 | # and node) always means no nodes have been added or destroyed. |
|
3285 | 3286 | |
|
3286 | 3287 | # XXX this is suboptimal when qrefresh'ing: we strip the current |
|
3287 | 3288 | # head, refresh the tag cache, then immediately add a new head. |
|
3288 | 3289 | # But I think doing it this way is necessary for the "instant |
|
3289 | 3290 | # tag cache retrieval" case to work. |
|
3290 | 3291 | self.invalidate() |
|
3291 | 3292 | |
|
3292 | 3293 | def status( |
|
3293 | 3294 | self, |
|
3294 | 3295 | node1=b'.', |
|
3295 | 3296 | node2=None, |
|
3296 | 3297 | match=None, |
|
3297 | 3298 | ignored=False, |
|
3298 | 3299 | clean=False, |
|
3299 | 3300 | unknown=False, |
|
3300 | 3301 | listsubrepos=False, |
|
3301 | 3302 | ): |
|
3302 | 3303 | '''a convenience method that calls node1.status(node2)''' |
|
3303 | 3304 | return self[node1].status( |
|
3304 | 3305 | node2, match, ignored, clean, unknown, listsubrepos |
|
3305 | 3306 | ) |
|
3306 | 3307 | |
|
3307 | 3308 | def addpostdsstatus(self, ps): |
|
3308 | 3309 | """Add a callback to run within the wlock, at the point at which status |
|
3309 | 3310 | fixups happen. |
|
3310 | 3311 | |
|
3311 | 3312 | On status completion, callback(wctx, status) will be called with the |
|
3312 | 3313 | wlock held, unless the dirstate has changed from underneath or the wlock |
|
3313 | 3314 | couldn't be grabbed. |
|
3314 | 3315 | |
|
3315 | 3316 | Callbacks should not capture and use a cached copy of the dirstate -- |
|
3316 | 3317 | it might change in the meanwhile. Instead, they should access the |
|
3317 | 3318 | dirstate via wctx.repo().dirstate. |
|
3318 | 3319 | |
|
3319 | 3320 | This list is emptied out after each status run -- extensions should |
|
3320 | 3321 | make sure it adds to this list each time dirstate.status is called. |
|
3321 | 3322 | Extensions should also make sure they don't call this for statuses |
|
3322 | 3323 | that don't involve the dirstate. |
|
3323 | 3324 | """ |
|
3324 | 3325 | |
|
3325 | 3326 | # The list is located here for uniqueness reasons -- it is actually |
|
3326 | 3327 | # managed by the workingctx, but that isn't unique per-repo. |
|
3327 | 3328 | self._postdsstatus.append(ps) |
|
3328 | 3329 | |
|
3329 | 3330 | def postdsstatus(self): |
|
3330 | 3331 | """Used by workingctx to get the list of post-dirstate-status hooks.""" |
|
3331 | 3332 | return self._postdsstatus |
|
3332 | 3333 | |
|
3333 | 3334 | def clearpostdsstatus(self): |
|
3334 | 3335 | """Used by workingctx to clear post-dirstate-status hooks.""" |
|
3335 | 3336 | del self._postdsstatus[:] |
|
3336 | 3337 | |
|
3337 | 3338 | def heads(self, start=None): |
|
3338 | 3339 | if start is None: |
|
3339 | 3340 | cl = self.changelog |
|
3340 | 3341 | headrevs = reversed(cl.headrevs()) |
|
3341 | 3342 | return [cl.node(rev) for rev in headrevs] |
|
3342 | 3343 | |
|
3343 | 3344 | heads = self.changelog.heads(start) |
|
3344 | 3345 | # sort the output in rev descending order |
|
3345 | 3346 | return sorted(heads, key=self.changelog.rev, reverse=True) |
|
3346 | 3347 | |
|
3347 | 3348 | def branchheads(self, branch=None, start=None, closed=False): |
|
3348 | 3349 | """return a (possibly filtered) list of heads for the given branch |
|
3349 | 3350 | |
|
3350 | 3351 | Heads are returned in topological order, from newest to oldest. |
|
3351 | 3352 | If branch is None, use the dirstate branch. |
|
3352 | 3353 | If start is not None, return only heads reachable from start. |
|
3353 | 3354 | If closed is True, return heads that are marked as closed as well. |
|
3354 | 3355 | """ |
|
3355 | 3356 | if branch is None: |
|
3356 | 3357 | branch = self[None].branch() |
|
3357 | 3358 | branches = self.branchmap() |
|
3358 | 3359 | if not branches.hasbranch(branch): |
|
3359 | 3360 | return [] |
|
3360 | 3361 | # the cache returns heads ordered lowest to highest |
|
3361 | 3362 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
|
3362 | 3363 | if start is not None: |
|
3363 | 3364 | # filter out the heads that cannot be reached from startrev |
|
3364 | 3365 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
3365 | 3366 | bheads = [h for h in bheads if h in fbheads] |
|
3366 | 3367 | return bheads |
|
3367 | 3368 | |
|
3368 | 3369 | def branches(self, nodes): |
|
3369 | 3370 | if not nodes: |
|
3370 | 3371 | nodes = [self.changelog.tip()] |
|
3371 | 3372 | b = [] |
|
3372 | 3373 | for n in nodes: |
|
3373 | 3374 | t = n |
|
3374 | 3375 | while True: |
|
3375 | 3376 | p = self.changelog.parents(n) |
|
3376 | 3377 | if p[1] != self.nullid or p[0] == self.nullid: |
|
3377 | 3378 | b.append((t, n, p[0], p[1])) |
|
3378 | 3379 | break |
|
3379 | 3380 | n = p[0] |
|
3380 | 3381 | return b |
|
3381 | 3382 | |
|
3382 | 3383 | def between(self, pairs): |
|
3383 | 3384 | r = [] |
|
3384 | 3385 | |
|
3385 | 3386 | for top, bottom in pairs: |
|
3386 | 3387 | n, l, i = top, [], 0 |
|
3387 | 3388 | f = 1 |
|
3388 | 3389 | |
|
3389 | 3390 | while n != bottom and n != self.nullid: |
|
3390 | 3391 | p = self.changelog.parents(n)[0] |
|
3391 | 3392 | if i == f: |
|
3392 | 3393 | l.append(n) |
|
3393 | 3394 | f = f * 2 |
|
3394 | 3395 | n = p |
|
3395 | 3396 | i += 1 |
|
3396 | 3397 | |
|
3397 | 3398 | r.append(l) |
|
3398 | 3399 | |
|
3399 | 3400 | return r |
|
3400 | 3401 | |
|
3401 | 3402 | def checkpush(self, pushop): |
|
3402 | 3403 | """Extensions can override this function if additional checks have |
|
3403 | 3404 | to be performed before pushing, or call it if they override push |
|
3404 | 3405 | command. |
|
3405 | 3406 | """ |
|
3406 | 3407 | |
|
3407 | 3408 | @unfilteredpropertycache |
|
3408 | 3409 | def prepushoutgoinghooks(self): |
|
3409 | 3410 | """Return util.hooks consists of a pushop with repo, remote, outgoing |
|
3410 | 3411 | methods, which are called before pushing changesets. |
|
3411 | 3412 | """ |
|
3412 | 3413 | return util.hooks() |
|
3413 | 3414 | |
|
3414 | 3415 | def pushkey(self, namespace, key, old, new): |
|
3415 | 3416 | try: |
|
3416 | 3417 | tr = self.currenttransaction() |
|
3417 | 3418 | hookargs = {} |
|
3418 | 3419 | if tr is not None: |
|
3419 | 3420 | hookargs.update(tr.hookargs) |
|
3420 | 3421 | hookargs = pycompat.strkwargs(hookargs) |
|
3421 | 3422 | hookargs['namespace'] = namespace |
|
3422 | 3423 | hookargs['key'] = key |
|
3423 | 3424 | hookargs['old'] = old |
|
3424 | 3425 | hookargs['new'] = new |
|
3425 | 3426 | self.hook(b'prepushkey', throw=True, **hookargs) |
|
3426 | 3427 | except error.HookAbort as exc: |
|
3427 | 3428 | self.ui.write_err(_(b"pushkey-abort: %s\n") % exc) |
|
3428 | 3429 | if exc.hint: |
|
3429 | 3430 | self.ui.write_err(_(b"(%s)\n") % exc.hint) |
|
3430 | 3431 | return False |
|
3431 | 3432 | self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key)) |
|
3432 | 3433 | ret = pushkey.push(self, namespace, key, old, new) |
|
3433 | 3434 | |
|
3434 | 3435 | def runhook(unused_success): |
|
3435 | 3436 | self.hook( |
|
3436 | 3437 | b'pushkey', |
|
3437 | 3438 | namespace=namespace, |
|
3438 | 3439 | key=key, |
|
3439 | 3440 | old=old, |
|
3440 | 3441 | new=new, |
|
3441 | 3442 | ret=ret, |
|
3442 | 3443 | ) |
|
3443 | 3444 | |
|
3444 | 3445 | self._afterlock(runhook) |
|
3445 | 3446 | return ret |
|
3446 | 3447 | |
|
3447 | 3448 | def listkeys(self, namespace): |
|
3448 | 3449 | self.hook(b'prelistkeys', throw=True, namespace=namespace) |
|
3449 | 3450 | self.ui.debug(b'listing keys for "%s"\n' % namespace) |
|
3450 | 3451 | values = pushkey.list(self, namespace) |
|
3451 | 3452 | self.hook(b'listkeys', namespace=namespace, values=values) |
|
3452 | 3453 | return values |
|
3453 | 3454 | |
|
3454 | 3455 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
3455 | 3456 | '''used to test argument passing over the wire''' |
|
3456 | 3457 | return b"%s %s %s %s %s" % ( |
|
3457 | 3458 | one, |
|
3458 | 3459 | two, |
|
3459 | 3460 | pycompat.bytestr(three), |
|
3460 | 3461 | pycompat.bytestr(four), |
|
3461 | 3462 | pycompat.bytestr(five), |
|
3462 | 3463 | ) |
|
3463 | 3464 | |
|
3464 | 3465 | def savecommitmessage(self, text): |
|
3465 | 3466 | fp = self.vfs(b'last-message.txt', b'wb') |
|
3466 | 3467 | try: |
|
3467 | 3468 | fp.write(text) |
|
3468 | 3469 | finally: |
|
3469 | 3470 | fp.close() |
|
3470 | 3471 | return self.pathto(fp.name[len(self.root) + 1 :]) |
|
3471 | 3472 | |
|
3472 | 3473 | def register_wanted_sidedata(self, category): |
|
3473 | 3474 | if repository.REPO_FEATURE_SIDE_DATA not in self.features: |
|
3474 | 3475 | # Only revlogv2 repos can want sidedata. |
|
3475 | 3476 | return |
|
3476 | 3477 | self._wanted_sidedata.add(pycompat.bytestr(category)) |
|
3477 | 3478 | |
|
3478 | 3479 | def register_sidedata_computer( |
|
3479 | 3480 | self, kind, category, keys, computer, flags, replace=False |
|
3480 | 3481 | ): |
|
3481 | 3482 | if kind not in revlogconst.ALL_KINDS: |
|
3482 | 3483 | msg = _(b"unexpected revlog kind '%s'.") |
|
3483 | 3484 | raise error.ProgrammingError(msg % kind) |
|
3484 | 3485 | category = pycompat.bytestr(category) |
|
3485 | 3486 | already_registered = category in self._sidedata_computers.get(kind, []) |
|
3486 | 3487 | if already_registered and not replace: |
|
3487 | 3488 | msg = _( |
|
3488 | 3489 | b"cannot register a sidedata computer twice for category '%s'." |
|
3489 | 3490 | ) |
|
3490 | 3491 | raise error.ProgrammingError(msg % category) |
|
3491 | 3492 | if replace and not already_registered: |
|
3492 | 3493 | msg = _( |
|
3493 | 3494 | b"cannot replace a sidedata computer that isn't registered " |
|
3494 | 3495 | b"for category '%s'." |
|
3495 | 3496 | ) |
|
3496 | 3497 | raise error.ProgrammingError(msg % category) |
|
3497 | 3498 | self._sidedata_computers.setdefault(kind, {}) |
|
3498 | 3499 | self._sidedata_computers[kind][category] = (keys, computer, flags) |
|
3499 | 3500 | |
|
3500 | 3501 | |
|
3501 | 3502 | # used to avoid circular references so destructors work |
|
3502 | 3503 | def aftertrans(files): |
|
3503 | 3504 | renamefiles = [tuple(t) for t in files] |
|
3504 | 3505 | |
|
3505 | 3506 | def a(): |
|
3506 | 3507 | for vfs, src, dest in renamefiles: |
|
3507 | 3508 | # if src and dest refer to a same file, vfs.rename is a no-op, |
|
3508 | 3509 | # leaving both src and dest on disk. delete dest to make sure |
|
3509 | 3510 | # the rename couldn't be such a no-op. |
|
3510 | 3511 | vfs.tryunlink(dest) |
|
3511 | 3512 | try: |
|
3512 | 3513 | vfs.rename(src, dest) |
|
3513 | 3514 | except FileNotFoundError: # journal file does not yet exist |
|
3514 | 3515 | pass |
|
3515 | 3516 | |
|
3516 | 3517 | return a |
|
3517 | 3518 | |
|
3518 | 3519 | |
|
3519 | 3520 | def undoname(fn): |
|
3520 | 3521 | base, name = os.path.split(fn) |
|
3521 | 3522 | assert name.startswith(b'journal') |
|
3522 | 3523 | return os.path.join(base, name.replace(b'journal', b'undo', 1)) |
|
3523 | 3524 | |
|
3524 | 3525 | |
|
3525 | 3526 | def instance(ui, path, create, intents=None, createopts=None): |
|
3526 | 3527 | |
|
3527 | 3528 | # prevent cyclic import localrepo -> upgrade -> localrepo |
|
3528 | 3529 | from . import upgrade |
|
3529 | 3530 | |
|
3530 | 3531 | localpath = urlutil.urllocalpath(path) |
|
3531 | 3532 | if create: |
|
3532 | 3533 | createrepository(ui, localpath, createopts=createopts) |
|
3533 | 3534 | |
|
3534 | 3535 | def repo_maker(): |
|
3535 | 3536 | return makelocalrepository(ui, localpath, intents=intents) |
|
3536 | 3537 | |
|
3537 | 3538 | repo = repo_maker() |
|
3538 | 3539 | repo = upgrade.may_auto_upgrade(repo, repo_maker) |
|
3539 | 3540 | return repo |
|
3540 | 3541 | |
|
3541 | 3542 | |
|
3542 | 3543 | def islocal(path): |
|
3543 | 3544 | return True |
|
3544 | 3545 | |
|
3545 | 3546 | |
|
3546 | 3547 | def defaultcreateopts(ui, createopts=None): |
|
3547 | 3548 | """Populate the default creation options for a repository. |
|
3548 | 3549 | |
|
3549 | 3550 | A dictionary of explicitly requested creation options can be passed |
|
3550 | 3551 | in. Missing keys will be populated. |
|
3551 | 3552 | """ |
|
3552 | 3553 | createopts = dict(createopts or {}) |
|
3553 | 3554 | |
|
3554 | 3555 | if b'backend' not in createopts: |
|
3555 | 3556 | # experimental config: storage.new-repo-backend |
|
3556 | 3557 | createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend') |
|
3557 | 3558 | |
|
3558 | 3559 | return createopts |
|
3559 | 3560 | |
|
3560 | 3561 | |
|
3561 | 3562 | def clone_requirements(ui, createopts, srcrepo): |
|
3562 | 3563 | """clone the requirements of a local repo for a local clone |
|
3563 | 3564 | |
|
3564 | 3565 | The store requirements are unchanged while the working copy requirements |
|
3565 | 3566 | depends on the configuration |
|
3566 | 3567 | """ |
|
3567 | 3568 | target_requirements = set() |
|
3568 | 3569 | if not srcrepo.requirements: |
|
3569 | 3570 | # this is a legacy revlog "v0" repository, we cannot do anything fancy |
|
3570 | 3571 | # with it. |
|
3571 | 3572 | return target_requirements |
|
3572 | 3573 | createopts = defaultcreateopts(ui, createopts=createopts) |
|
3573 | 3574 | for r in newreporequirements(ui, createopts): |
|
3574 | 3575 | if r in requirementsmod.WORKING_DIR_REQUIREMENTS: |
|
3575 | 3576 | target_requirements.add(r) |
|
3576 | 3577 | |
|
3577 | 3578 | for r in srcrepo.requirements: |
|
3578 | 3579 | if r not in requirementsmod.WORKING_DIR_REQUIREMENTS: |
|
3579 | 3580 | target_requirements.add(r) |
|
3580 | 3581 | return target_requirements |
|
3581 | 3582 | |
|
3582 | 3583 | |
|
3583 | 3584 | def newreporequirements(ui, createopts): |
|
3584 | 3585 | """Determine the set of requirements for a new local repository. |
|
3585 | 3586 | |
|
3586 | 3587 | Extensions can wrap this function to specify custom requirements for |
|
3587 | 3588 | new repositories. |
|
3588 | 3589 | """ |
|
3589 | 3590 | |
|
3590 | 3591 | if b'backend' not in createopts: |
|
3591 | 3592 | raise error.ProgrammingError( |
|
3592 | 3593 | b'backend key not present in createopts; ' |
|
3593 | 3594 | b'was defaultcreateopts() called?' |
|
3594 | 3595 | ) |
|
3595 | 3596 | |
|
3596 | 3597 | if createopts[b'backend'] != b'revlogv1': |
|
3597 | 3598 | raise error.Abort( |
|
3598 | 3599 | _( |
|
3599 | 3600 | b'unable to determine repository requirements for ' |
|
3600 | 3601 | b'storage backend: %s' |
|
3601 | 3602 | ) |
|
3602 | 3603 | % createopts[b'backend'] |
|
3603 | 3604 | ) |
|
3604 | 3605 | |
|
3605 | 3606 | requirements = {requirementsmod.REVLOGV1_REQUIREMENT} |
|
3606 | 3607 | if ui.configbool(b'format', b'usestore'): |
|
3607 | 3608 | requirements.add(requirementsmod.STORE_REQUIREMENT) |
|
3608 | 3609 | if ui.configbool(b'format', b'usefncache'): |
|
3609 | 3610 | requirements.add(requirementsmod.FNCACHE_REQUIREMENT) |
|
3610 | 3611 | if ui.configbool(b'format', b'dotencode'): |
|
3611 | 3612 | requirements.add(requirementsmod.DOTENCODE_REQUIREMENT) |
|
3612 | 3613 | |
|
3613 | 3614 | compengines = ui.configlist(b'format', b'revlog-compression') |
|
3614 | 3615 | for compengine in compengines: |
|
3615 | 3616 | if compengine in util.compengines: |
|
3616 | 3617 | engine = util.compengines[compengine] |
|
3617 | 3618 | if engine.available() and engine.revlogheader(): |
|
3618 | 3619 | break |
|
3619 | 3620 | else: |
|
3620 | 3621 | raise error.Abort( |
|
3621 | 3622 | _( |
|
3622 | 3623 | b'compression engines %s defined by ' |
|
3623 | 3624 | b'format.revlog-compression not available' |
|
3624 | 3625 | ) |
|
3625 | 3626 | % b', '.join(b'"%s"' % e for e in compengines), |
|
3626 | 3627 | hint=_( |
|
3627 | 3628 | b'run "hg debuginstall" to list available ' |
|
3628 | 3629 | b'compression engines' |
|
3629 | 3630 | ), |
|
3630 | 3631 | ) |
|
3631 | 3632 | |
|
3632 | 3633 | # zlib is the historical default and doesn't need an explicit requirement. |
|
3633 | 3634 | if compengine == b'zstd': |
|
3634 | 3635 | requirements.add(b'revlog-compression-zstd') |
|
3635 | 3636 | elif compengine != b'zlib': |
|
3636 | 3637 | requirements.add(b'exp-compression-%s' % compengine) |
|
3637 | 3638 | |
|
3638 | 3639 | if scmutil.gdinitconfig(ui): |
|
3639 | 3640 | requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT) |
|
3640 | 3641 | if ui.configbool(b'format', b'sparse-revlog'): |
|
3641 | 3642 | requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT) |
|
3642 | 3643 | |
|
3643 | 3644 | # experimental config: format.use-dirstate-v2 |
|
3644 | 3645 | # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py` |
|
3645 | 3646 | if ui.configbool(b'format', b'use-dirstate-v2'): |
|
3646 | 3647 | requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT) |
|
3647 | 3648 | |
|
3648 | 3649 | # experimental config: format.exp-use-copies-side-data-changeset |
|
3649 | 3650 | if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'): |
|
3650 | 3651 | requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT) |
|
3651 | 3652 | requirements.add(requirementsmod.COPIESSDC_REQUIREMENT) |
|
3652 | 3653 | if ui.configbool(b'experimental', b'treemanifest'): |
|
3653 | 3654 | requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT) |
|
3654 | 3655 | |
|
3655 | 3656 | changelogv2 = ui.config(b'format', b'exp-use-changelog-v2') |
|
3656 | 3657 | if changelogv2 == b'enable-unstable-format-and-corrupt-my-data': |
|
3657 | 3658 | requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT) |
|
3658 | 3659 | |
|
3659 | 3660 | revlogv2 = ui.config(b'experimental', b'revlogv2') |
|
3660 | 3661 | if revlogv2 == b'enable-unstable-format-and-corrupt-my-data': |
|
3661 | 3662 | requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT) |
|
3662 | 3663 | requirements.add(requirementsmod.REVLOGV2_REQUIREMENT) |
|
3663 | 3664 | # experimental config: format.internal-phase |
|
3664 | 3665 | if ui.configbool(b'format', b'internal-phase'): |
|
3665 | 3666 | requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT) |
|
3666 | 3667 | |
|
3668 | # experimental config: format.exp-archived-phase | |
|
3669 | if ui.configbool(b'format', b'exp-archived-phase'): | |
|
3670 | requirements.add(requirementsmod.ARCHIVED_PHASE_REQUIREMENT) | |
|
3671 | ||
|
3667 | 3672 | if createopts.get(b'narrowfiles'): |
|
3668 | 3673 | requirements.add(requirementsmod.NARROW_REQUIREMENT) |
|
3669 | 3674 | |
|
3670 | 3675 | if createopts.get(b'lfs'): |
|
3671 | 3676 | requirements.add(b'lfs') |
|
3672 | 3677 | |
|
3673 | 3678 | if ui.configbool(b'format', b'bookmarks-in-store'): |
|
3674 | 3679 | requirements.add(requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT) |
|
3675 | 3680 | |
|
3676 | 3681 | if ui.configbool(b'format', b'use-persistent-nodemap'): |
|
3677 | 3682 | requirements.add(requirementsmod.NODEMAP_REQUIREMENT) |
|
3678 | 3683 | |
|
3679 | 3684 | # if share-safe is enabled, let's create the new repository with the new |
|
3680 | 3685 | # requirement |
|
3681 | 3686 | if ui.configbool(b'format', b'use-share-safe'): |
|
3682 | 3687 | requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
3683 | 3688 | |
|
3684 | 3689 | # if we are creating a share-repoΒΉ we have to handle requirement |
|
3685 | 3690 | # differently. |
|
3686 | 3691 | # |
|
3687 | 3692 | # [1] (i.e. reusing the store from another repository, just having a |
|
3688 | 3693 | # working copy) |
|
3689 | 3694 | if b'sharedrepo' in createopts: |
|
3690 | 3695 | source_requirements = set(createopts[b'sharedrepo'].requirements) |
|
3691 | 3696 | |
|
3692 | 3697 | if requirementsmod.SHARESAFE_REQUIREMENT not in source_requirements: |
|
3693 | 3698 | # share to an old school repository, we have to copy the |
|
3694 | 3699 | # requirements and hope for the best. |
|
3695 | 3700 | requirements = source_requirements |
|
3696 | 3701 | else: |
|
3697 | 3702 | # We have control on the working copy only, so "copy" the non |
|
3698 | 3703 | # working copy part over, ignoring previous logic. |
|
3699 | 3704 | to_drop = set() |
|
3700 | 3705 | for req in requirements: |
|
3701 | 3706 | if req in requirementsmod.WORKING_DIR_REQUIREMENTS: |
|
3702 | 3707 | continue |
|
3703 | 3708 | if req in source_requirements: |
|
3704 | 3709 | continue |
|
3705 | 3710 | to_drop.add(req) |
|
3706 | 3711 | requirements -= to_drop |
|
3707 | 3712 | requirements |= source_requirements |
|
3708 | 3713 | |
|
3709 | 3714 | if createopts.get(b'sharedrelative'): |
|
3710 | 3715 | requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT) |
|
3711 | 3716 | else: |
|
3712 | 3717 | requirements.add(requirementsmod.SHARED_REQUIREMENT) |
|
3713 | 3718 | |
|
3714 | 3719 | if ui.configbool(b'format', b'use-dirstate-tracked-hint'): |
|
3715 | 3720 | version = ui.configint(b'format', b'use-dirstate-tracked-hint.version') |
|
3716 | 3721 | msg = _("ignoring unknown tracked key version: %d\n") |
|
3717 | 3722 | hint = _("see `hg help config.format.use-dirstate-tracked-hint-version") |
|
3718 | 3723 | if version != 1: |
|
3719 | 3724 | ui.warn(msg % version, hint=hint) |
|
3720 | 3725 | else: |
|
3721 | 3726 | requirements.add(requirementsmod.DIRSTATE_TRACKED_HINT_V1) |
|
3722 | 3727 | |
|
3723 | 3728 | return requirements |
|
3724 | 3729 | |
|
3725 | 3730 | |
|
3726 | 3731 | def checkrequirementscompat(ui, requirements): |
|
3727 | 3732 | """Checks compatibility of repository requirements enabled and disabled. |
|
3728 | 3733 | |
|
3729 | 3734 | Returns a set of requirements which needs to be dropped because dependend |
|
3730 | 3735 | requirements are not enabled. Also warns users about it""" |
|
3731 | 3736 | |
|
3732 | 3737 | dropped = set() |
|
3733 | 3738 | |
|
3734 | 3739 | if requirementsmod.STORE_REQUIREMENT not in requirements: |
|
3735 | 3740 | if requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT in requirements: |
|
3736 | 3741 | ui.warn( |
|
3737 | 3742 | _( |
|
3738 | 3743 | b'ignoring enabled \'format.bookmarks-in-store\' config ' |
|
3739 | 3744 | b'beacuse it is incompatible with disabled ' |
|
3740 | 3745 | b'\'format.usestore\' config\n' |
|
3741 | 3746 | ) |
|
3742 | 3747 | ) |
|
3743 | 3748 | dropped.add(requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT) |
|
3744 | 3749 | |
|
3745 | 3750 | if ( |
|
3746 | 3751 | requirementsmod.SHARED_REQUIREMENT in requirements |
|
3747 | 3752 | or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements |
|
3748 | 3753 | ): |
|
3749 | 3754 | raise error.Abort( |
|
3750 | 3755 | _( |
|
3751 | 3756 | b"cannot create shared repository as source was created" |
|
3752 | 3757 | b" with 'format.usestore' config disabled" |
|
3753 | 3758 | ) |
|
3754 | 3759 | ) |
|
3755 | 3760 | |
|
3756 | 3761 | if requirementsmod.SHARESAFE_REQUIREMENT in requirements: |
|
3757 | 3762 | if ui.hasconfig(b'format', b'use-share-safe'): |
|
3758 | 3763 | msg = _( |
|
3759 | 3764 | b"ignoring enabled 'format.use-share-safe' config because " |
|
3760 | 3765 | b"it is incompatible with disabled 'format.usestore'" |
|
3761 | 3766 | b" config\n" |
|
3762 | 3767 | ) |
|
3763 | 3768 | ui.warn(msg) |
|
3764 | 3769 | dropped.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
3765 | 3770 | |
|
3766 | 3771 | return dropped |
|
3767 | 3772 | |
|
3768 | 3773 | |
|
3769 | 3774 | def filterknowncreateopts(ui, createopts): |
|
3770 | 3775 | """Filters a dict of repo creation options against options that are known. |
|
3771 | 3776 | |
|
3772 | 3777 | Receives a dict of repo creation options and returns a dict of those |
|
3773 | 3778 | options that we don't know how to handle. |
|
3774 | 3779 | |
|
3775 | 3780 | This function is called as part of repository creation. If the |
|
3776 | 3781 | returned dict contains any items, repository creation will not |
|
3777 | 3782 | be allowed, as it means there was a request to create a repository |
|
3778 | 3783 | with options not recognized by loaded code. |
|
3779 | 3784 | |
|
3780 | 3785 | Extensions can wrap this function to filter out creation options |
|
3781 | 3786 | they know how to handle. |
|
3782 | 3787 | """ |
|
3783 | 3788 | known = { |
|
3784 | 3789 | b'backend', |
|
3785 | 3790 | b'lfs', |
|
3786 | 3791 | b'narrowfiles', |
|
3787 | 3792 | b'sharedrepo', |
|
3788 | 3793 | b'sharedrelative', |
|
3789 | 3794 | b'shareditems', |
|
3790 | 3795 | b'shallowfilestore', |
|
3791 | 3796 | } |
|
3792 | 3797 | |
|
3793 | 3798 | return {k: v for k, v in createopts.items() if k not in known} |
|
3794 | 3799 | |
|
3795 | 3800 | |
|
3796 | 3801 | def createrepository(ui, path, createopts=None, requirements=None): |
|
3797 | 3802 | """Create a new repository in a vfs. |
|
3798 | 3803 | |
|
3799 | 3804 | ``path`` path to the new repo's working directory. |
|
3800 | 3805 | ``createopts`` options for the new repository. |
|
3801 | 3806 | ``requirement`` predefined set of requirements. |
|
3802 | 3807 | (incompatible with ``createopts``) |
|
3803 | 3808 | |
|
3804 | 3809 | The following keys for ``createopts`` are recognized: |
|
3805 | 3810 | |
|
3806 | 3811 | backend |
|
3807 | 3812 | The storage backend to use. |
|
3808 | 3813 | lfs |
|
3809 | 3814 | Repository will be created with ``lfs`` requirement. The lfs extension |
|
3810 | 3815 | will automatically be loaded when the repository is accessed. |
|
3811 | 3816 | narrowfiles |
|
3812 | 3817 | Set up repository to support narrow file storage. |
|
3813 | 3818 | sharedrepo |
|
3814 | 3819 | Repository object from which storage should be shared. |
|
3815 | 3820 | sharedrelative |
|
3816 | 3821 | Boolean indicating if the path to the shared repo should be |
|
3817 | 3822 | stored as relative. By default, the pointer to the "parent" repo |
|
3818 | 3823 | is stored as an absolute path. |
|
3819 | 3824 | shareditems |
|
3820 | 3825 | Set of items to share to the new repository (in addition to storage). |
|
3821 | 3826 | shallowfilestore |
|
3822 | 3827 | Indicates that storage for files should be shallow (not all ancestor |
|
3823 | 3828 | revisions are known). |
|
3824 | 3829 | """ |
|
3825 | 3830 | |
|
3826 | 3831 | if requirements is not None: |
|
3827 | 3832 | if createopts is not None: |
|
3828 | 3833 | msg = b'cannot specify both createopts and requirements' |
|
3829 | 3834 | raise error.ProgrammingError(msg) |
|
3830 | 3835 | createopts = {} |
|
3831 | 3836 | else: |
|
3832 | 3837 | createopts = defaultcreateopts(ui, createopts=createopts) |
|
3833 | 3838 | |
|
3834 | 3839 | unknownopts = filterknowncreateopts(ui, createopts) |
|
3835 | 3840 | |
|
3836 | 3841 | if not isinstance(unknownopts, dict): |
|
3837 | 3842 | raise error.ProgrammingError( |
|
3838 | 3843 | b'filterknowncreateopts() did not return a dict' |
|
3839 | 3844 | ) |
|
3840 | 3845 | |
|
3841 | 3846 | if unknownopts: |
|
3842 | 3847 | raise error.Abort( |
|
3843 | 3848 | _( |
|
3844 | 3849 | b'unable to create repository because of unknown ' |
|
3845 | 3850 | b'creation option: %s' |
|
3846 | 3851 | ) |
|
3847 | 3852 | % b', '.join(sorted(unknownopts)), |
|
3848 | 3853 | hint=_(b'is a required extension not loaded?'), |
|
3849 | 3854 | ) |
|
3850 | 3855 | |
|
3851 | 3856 | requirements = newreporequirements(ui, createopts=createopts) |
|
3852 | 3857 | requirements -= checkrequirementscompat(ui, requirements) |
|
3853 | 3858 | |
|
3854 | 3859 | wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
|
3855 | 3860 | |
|
3856 | 3861 | hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg')) |
|
3857 | 3862 | if hgvfs.exists(): |
|
3858 | 3863 | raise error.RepoError(_(b'repository %s already exists') % path) |
|
3859 | 3864 | |
|
3860 | 3865 | if b'sharedrepo' in createopts: |
|
3861 | 3866 | sharedpath = createopts[b'sharedrepo'].sharedpath |
|
3862 | 3867 | |
|
3863 | 3868 | if createopts.get(b'sharedrelative'): |
|
3864 | 3869 | try: |
|
3865 | 3870 | sharedpath = os.path.relpath(sharedpath, hgvfs.base) |
|
3866 | 3871 | sharedpath = util.pconvert(sharedpath) |
|
3867 | 3872 | except (IOError, ValueError) as e: |
|
3868 | 3873 | # ValueError is raised on Windows if the drive letters differ |
|
3869 | 3874 | # on each path. |
|
3870 | 3875 | raise error.Abort( |
|
3871 | 3876 | _(b'cannot calculate relative path'), |
|
3872 | 3877 | hint=stringutil.forcebytestr(e), |
|
3873 | 3878 | ) |
|
3874 | 3879 | |
|
3875 | 3880 | if not wdirvfs.exists(): |
|
3876 | 3881 | wdirvfs.makedirs() |
|
3877 | 3882 | |
|
3878 | 3883 | hgvfs.makedir(notindexed=True) |
|
3879 | 3884 | if b'sharedrepo' not in createopts: |
|
3880 | 3885 | hgvfs.mkdir(b'cache') |
|
3881 | 3886 | hgvfs.mkdir(b'wcache') |
|
3882 | 3887 | |
|
3883 | 3888 | has_store = requirementsmod.STORE_REQUIREMENT in requirements |
|
3884 | 3889 | if has_store and b'sharedrepo' not in createopts: |
|
3885 | 3890 | hgvfs.mkdir(b'store') |
|
3886 | 3891 | |
|
3887 | 3892 | # We create an invalid changelog outside the store so very old |
|
3888 | 3893 | # Mercurial versions (which didn't know about the requirements |
|
3889 | 3894 | # file) encounter an error on reading the changelog. This |
|
3890 | 3895 | # effectively locks out old clients and prevents them from |
|
3891 | 3896 | # mucking with a repo in an unknown format. |
|
3892 | 3897 | # |
|
3893 | 3898 | # The revlog header has version 65535, which won't be recognized by |
|
3894 | 3899 | # such old clients. |
|
3895 | 3900 | hgvfs.append( |
|
3896 | 3901 | b'00changelog.i', |
|
3897 | 3902 | b'\0\0\xFF\xFF dummy changelog to prevent using the old repo ' |
|
3898 | 3903 | b'layout', |
|
3899 | 3904 | ) |
|
3900 | 3905 | |
|
3901 | 3906 | # Filter the requirements into working copy and store ones |
|
3902 | 3907 | wcreq, storereq = scmutil.filterrequirements(requirements) |
|
3903 | 3908 | # write working copy ones |
|
3904 | 3909 | scmutil.writerequires(hgvfs, wcreq) |
|
3905 | 3910 | # If there are store requirements and the current repository |
|
3906 | 3911 | # is not a shared one, write stored requirements |
|
3907 | 3912 | # For new shared repository, we don't need to write the store |
|
3908 | 3913 | # requirements as they are already present in store requires |
|
3909 | 3914 | if storereq and b'sharedrepo' not in createopts: |
|
3910 | 3915 | storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True) |
|
3911 | 3916 | scmutil.writerequires(storevfs, storereq) |
|
3912 | 3917 | |
|
3913 | 3918 | # Write out file telling readers where to find the shared store. |
|
3914 | 3919 | if b'sharedrepo' in createopts: |
|
3915 | 3920 | hgvfs.write(b'sharedpath', sharedpath) |
|
3916 | 3921 | |
|
3917 | 3922 | if createopts.get(b'shareditems'): |
|
3918 | 3923 | shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n' |
|
3919 | 3924 | hgvfs.write(b'shared', shared) |
|
3920 | 3925 | |
|
3921 | 3926 | |
|
3922 | 3927 | def poisonrepository(repo): |
|
3923 | 3928 | """Poison a repository instance so it can no longer be used.""" |
|
3924 | 3929 | # Perform any cleanup on the instance. |
|
3925 | 3930 | repo.close() |
|
3926 | 3931 | |
|
3927 | 3932 | # Our strategy is to replace the type of the object with one that |
|
3928 | 3933 | # has all attribute lookups result in error. |
|
3929 | 3934 | # |
|
3930 | 3935 | # But we have to allow the close() method because some constructors |
|
3931 | 3936 | # of repos call close() on repo references. |
|
3932 | 3937 | class poisonedrepository: |
|
3933 | 3938 | def __getattribute__(self, item): |
|
3934 | 3939 | if item == 'close': |
|
3935 | 3940 | return object.__getattribute__(self, item) |
|
3936 | 3941 | |
|
3937 | 3942 | raise error.ProgrammingError( |
|
3938 | 3943 | b'repo instances should not be used after unshare' |
|
3939 | 3944 | ) |
|
3940 | 3945 | |
|
3941 | 3946 | def close(self): |
|
3942 | 3947 | pass |
|
3943 | 3948 | |
|
3944 | 3949 | # We may have a repoview, which intercepts __setattr__. So be sure |
|
3945 | 3950 | # we operate at the lowest level possible. |
|
3946 | 3951 | object.__setattr__(repo, '__class__', poisonedrepository) |
@@ -1,979 +1,979 b'' | |||
|
1 | 1 | """ Mercurial phases support code |
|
2 | 2 | |
|
3 | 3 | --- |
|
4 | 4 | |
|
5 | 5 | Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
|
6 | 6 | Logilab SA <contact@logilab.fr> |
|
7 | 7 | Augie Fackler <durin42@gmail.com> |
|
8 | 8 | |
|
9 | 9 | This software may be used and distributed according to the terms |
|
10 | 10 | of the GNU General Public License version 2 or any later version. |
|
11 | 11 | |
|
12 | 12 | --- |
|
13 | 13 | |
|
14 | 14 | This module implements most phase logic in mercurial. |
|
15 | 15 | |
|
16 | 16 | |
|
17 | 17 | Basic Concept |
|
18 | 18 | ============= |
|
19 | 19 | |
|
20 | 20 | A 'changeset phase' is an indicator that tells us how a changeset is |
|
21 | 21 | manipulated and communicated. The details of each phase is described |
|
22 | 22 | below, here we describe the properties they have in common. |
|
23 | 23 | |
|
24 | 24 | Like bookmarks, phases are not stored in history and thus are not |
|
25 | 25 | permanent and leave no audit trail. |
|
26 | 26 | |
|
27 | 27 | First, no changeset can be in two phases at once. Phases are ordered, |
|
28 | 28 | so they can be considered from lowest to highest. The default, lowest |
|
29 | 29 | phase is 'public' - this is the normal phase of existing changesets. A |
|
30 | 30 | child changeset can not be in a lower phase than its parents. |
|
31 | 31 | |
|
32 | 32 | These phases share a hierarchy of traits: |
|
33 | 33 | |
|
34 | 34 | immutable shared |
|
35 | 35 | public: X X |
|
36 | 36 | draft: X |
|
37 | 37 | secret: |
|
38 | 38 | |
|
39 | 39 | Local commits are draft by default. |
|
40 | 40 | |
|
41 | 41 | Phase Movement and Exchange |
|
42 | 42 | =========================== |
|
43 | 43 | |
|
44 | 44 | Phase data is exchanged by pushkey on pull and push. Some servers have |
|
45 | 45 | a publish option set, we call such a server a "publishing server". |
|
46 | 46 | Pushing a draft changeset to a publishing server changes the phase to |
|
47 | 47 | public. |
|
48 | 48 | |
|
49 | 49 | A small list of fact/rules define the exchange of phase: |
|
50 | 50 | |
|
51 | 51 | * old client never changes server states |
|
52 | 52 | * pull never changes server states |
|
53 | 53 | * publish and old server changesets are seen as public by client |
|
54 | 54 | * any secret changeset seen in another repository is lowered to at |
|
55 | 55 | least draft |
|
56 | 56 | |
|
57 | 57 | Here is the final table summing up the 49 possible use cases of phase |
|
58 | 58 | exchange: |
|
59 | 59 | |
|
60 | 60 | server |
|
61 | 61 | old publish non-publish |
|
62 | 62 | N X N D P N D P |
|
63 | 63 | old client |
|
64 | 64 | pull |
|
65 | 65 | N - X/X - X/D X/P - X/D X/P |
|
66 | 66 | X - X/X - X/D X/P - X/D X/P |
|
67 | 67 | push |
|
68 | 68 | X X/X X/X X/P X/P X/P X/D X/D X/P |
|
69 | 69 | new client |
|
70 | 70 | pull |
|
71 | 71 | N - P/X - P/D P/P - D/D P/P |
|
72 | 72 | D - P/X - P/D P/P - D/D P/P |
|
73 | 73 | P - P/X - P/D P/P - P/D P/P |
|
74 | 74 | push |
|
75 | 75 | D P/X P/X P/P P/P P/P D/D D/D P/P |
|
76 | 76 | P P/X P/X P/P P/P P/P P/P P/P P/P |
|
77 | 77 | |
|
78 | 78 | Legend: |
|
79 | 79 | |
|
80 | 80 | A/B = final state on client / state on server |
|
81 | 81 | |
|
82 | 82 | * N = new/not present, |
|
83 | 83 | * P = public, |
|
84 | 84 | * D = draft, |
|
85 | 85 | * X = not tracked (i.e., the old client or server has no internal |
|
86 | 86 | way of recording the phase.) |
|
87 | 87 | |
|
88 | 88 | passive = only pushes |
|
89 | 89 | |
|
90 | 90 | |
|
91 | 91 | A cell here can be read like this: |
|
92 | 92 | |
|
93 | 93 | "When a new client pushes a draft changeset (D) to a publishing |
|
94 | 94 | server where it's not present (N), it's marked public on both |
|
95 | 95 | sides (P/P)." |
|
96 | 96 | |
|
97 | 97 | Note: old client behave as a publishing server with draft only content |
|
98 | 98 | - other people see it as public |
|
99 | 99 | - content is pushed as draft |
|
100 | 100 | |
|
101 | 101 | """ |
|
102 | 102 | |
|
103 | 103 | |
|
104 | 104 | import struct |
|
105 | 105 | |
|
106 | 106 | from .i18n import _ |
|
107 | 107 | from .node import ( |
|
108 | 108 | bin, |
|
109 | 109 | hex, |
|
110 | 110 | nullrev, |
|
111 | 111 | short, |
|
112 | 112 | wdirrev, |
|
113 | 113 | ) |
|
114 | 114 | from .pycompat import ( |
|
115 | 115 | getattr, |
|
116 | 116 | setattr, |
|
117 | 117 | ) |
|
118 | 118 | from . import ( |
|
119 | 119 | error, |
|
120 | 120 | pycompat, |
|
121 | 121 | requirements, |
|
122 | 122 | smartset, |
|
123 | 123 | txnutil, |
|
124 | 124 | util, |
|
125 | 125 | ) |
|
126 | 126 | |
|
127 | 127 | if pycompat.TYPE_CHECKING: |
|
128 | 128 | from typing import ( |
|
129 | 129 | Any, |
|
130 | 130 | Callable, |
|
131 | 131 | Dict, |
|
132 | 132 | Iterable, |
|
133 | 133 | List, |
|
134 | 134 | Optional, |
|
135 | 135 | Set, |
|
136 | 136 | Tuple, |
|
137 | 137 | ) |
|
138 | 138 | from . import ( |
|
139 | 139 | localrepo, |
|
140 | 140 | ui as uimod, |
|
141 | 141 | ) |
|
142 | 142 | |
|
143 | 143 | Phaseroots = Dict[int, Set[bytes]] |
|
144 | 144 | Phasedefaults = List[ |
|
145 | 145 | Callable[[localrepo.localrepository, Phaseroots], Phaseroots] |
|
146 | 146 | ] |
|
147 | 147 | |
|
148 | 148 | |
|
149 | 149 | _fphasesentry = struct.Struct(b'>i20s') |
|
150 | 150 | |
|
151 | 151 | # record phase index |
|
152 | 152 | public, draft, secret = range(3) # type: int |
|
153 | 153 | archived = 32 # non-continuous for compatibility |
|
154 | 154 | internal = 96 # non-continuous for compatibility |
|
155 | 155 | allphases = (public, draft, secret, archived, internal) |
|
156 | 156 | trackedphases = (draft, secret, archived, internal) |
|
157 | 157 | # record phase names |
|
158 | 158 | cmdphasenames = [b'public', b'draft', b'secret'] # known to `hg phase` command |
|
159 | 159 | phasenames = dict(enumerate(cmdphasenames)) |
|
160 | 160 | phasenames[archived] = b'archived' |
|
161 | 161 | phasenames[internal] = b'internal' |
|
162 | 162 | # map phase name to phase number |
|
163 | 163 | phasenumber = {name: phase for phase, name in phasenames.items()} |
|
164 | 164 | # like phasenumber, but also include maps for the numeric and binary |
|
165 | 165 | # phase number to the phase number |
|
166 | 166 | phasenumber2 = phasenumber.copy() |
|
167 | 167 | phasenumber2.update({phase: phase for phase in phasenames}) |
|
168 | 168 | phasenumber2.update({b'%i' % phase: phase for phase in phasenames}) |
|
169 | 169 | # record phase property |
|
170 | 170 | mutablephases = (draft, secret, archived, internal) |
|
171 | 171 | remotehiddenphases = (secret, archived, internal) |
|
172 | 172 | localhiddenphases = (internal, archived) |
|
173 | 173 | |
|
174 | 174 | |
|
175 | 175 | def supportinternal(repo): |
|
176 | 176 | # type: (localrepo.localrepository) -> bool |
|
177 | 177 | """True if the internal phase can be used on a repository""" |
|
178 | 178 | return requirements.INTERNAL_PHASE_REQUIREMENT in repo.requirements |
|
179 | 179 | |
|
180 | 180 | |
|
181 | 181 | def supportarchived(repo): |
|
182 | 182 | # type: (localrepo.localrepository) -> bool |
|
183 | 183 | """True if the archived phase can be used on a repository""" |
|
184 |
return requirements. |
|
|
184 | return requirements.ARCHIVED_PHASE_REQUIREMENT in repo.requirements | |
|
185 | 185 | |
|
186 | 186 | |
|
187 | 187 | def _readroots(repo, phasedefaults=None): |
|
188 | 188 | # type: (localrepo.localrepository, Optional[Phasedefaults]) -> Tuple[Phaseroots, bool] |
|
189 | 189 | """Read phase roots from disk |
|
190 | 190 | |
|
191 | 191 | phasedefaults is a list of fn(repo, roots) callable, which are |
|
192 | 192 | executed if the phase roots file does not exist. When phases are |
|
193 | 193 | being initialized on an existing repository, this could be used to |
|
194 | 194 | set selected changesets phase to something else than public. |
|
195 | 195 | |
|
196 | 196 | Return (roots, dirty) where dirty is true if roots differ from |
|
197 | 197 | what is being stored. |
|
198 | 198 | """ |
|
199 | 199 | repo = repo.unfiltered() |
|
200 | 200 | dirty = False |
|
201 | 201 | roots = {i: set() for i in allphases} |
|
202 | 202 | try: |
|
203 | 203 | f, pending = txnutil.trypending(repo.root, repo.svfs, b'phaseroots') |
|
204 | 204 | try: |
|
205 | 205 | for line in f: |
|
206 | 206 | phase, nh = line.split() |
|
207 | 207 | roots[int(phase)].add(bin(nh)) |
|
208 | 208 | finally: |
|
209 | 209 | f.close() |
|
210 | 210 | except FileNotFoundError: |
|
211 | 211 | if phasedefaults: |
|
212 | 212 | for f in phasedefaults: |
|
213 | 213 | roots = f(repo, roots) |
|
214 | 214 | dirty = True |
|
215 | 215 | return roots, dirty |
|
216 | 216 | |
|
217 | 217 | |
|
218 | 218 | def binaryencode(phasemapping): |
|
219 | 219 | # type: (Dict[int, List[bytes]]) -> bytes |
|
220 | 220 | """encode a 'phase -> nodes' mapping into a binary stream |
|
221 | 221 | |
|
222 | 222 | The revision lists are encoded as (phase, root) pairs. |
|
223 | 223 | """ |
|
224 | 224 | binarydata = [] |
|
225 | 225 | for phase, nodes in phasemapping.items(): |
|
226 | 226 | for head in nodes: |
|
227 | 227 | binarydata.append(_fphasesentry.pack(phase, head)) |
|
228 | 228 | return b''.join(binarydata) |
|
229 | 229 | |
|
230 | 230 | |
|
231 | 231 | def binarydecode(stream): |
|
232 | 232 | # type: (...) -> Dict[int, List[bytes]] |
|
233 | 233 | """decode a binary stream into a 'phase -> nodes' mapping |
|
234 | 234 | |
|
235 | 235 | The (phase, root) pairs are turned back into a dictionary with |
|
236 | 236 | the phase as index and the aggregated roots of that phase as value.""" |
|
237 | 237 | headsbyphase = {i: [] for i in allphases} |
|
238 | 238 | entrysize = _fphasesentry.size |
|
239 | 239 | while True: |
|
240 | 240 | entry = stream.read(entrysize) |
|
241 | 241 | if len(entry) < entrysize: |
|
242 | 242 | if entry: |
|
243 | 243 | raise error.Abort(_(b'bad phase-heads stream')) |
|
244 | 244 | break |
|
245 | 245 | phase, node = _fphasesentry.unpack(entry) |
|
246 | 246 | headsbyphase[phase].append(node) |
|
247 | 247 | return headsbyphase |
|
248 | 248 | |
|
249 | 249 | |
|
250 | 250 | def _sortedrange_insert(data, idx, rev, t): |
|
251 | 251 | merge_before = False |
|
252 | 252 | if idx: |
|
253 | 253 | r1, t1 = data[idx - 1] |
|
254 | 254 | merge_before = r1[-1] + 1 == rev and t1 == t |
|
255 | 255 | merge_after = False |
|
256 | 256 | if idx < len(data): |
|
257 | 257 | r2, t2 = data[idx] |
|
258 | 258 | merge_after = r2[0] == rev + 1 and t2 == t |
|
259 | 259 | |
|
260 | 260 | if merge_before and merge_after: |
|
261 | 261 | data[idx - 1] = (range(r1[0], r2[-1] + 1), t) |
|
262 | 262 | data.pop(idx) |
|
263 | 263 | elif merge_before: |
|
264 | 264 | data[idx - 1] = (range(r1[0], rev + 1), t) |
|
265 | 265 | elif merge_after: |
|
266 | 266 | data[idx] = (range(rev, r2[-1] + 1), t) |
|
267 | 267 | else: |
|
268 | 268 | data.insert(idx, (range(rev, rev + 1), t)) |
|
269 | 269 | |
|
270 | 270 | |
|
271 | 271 | def _sortedrange_split(data, idx, rev, t): |
|
272 | 272 | r1, t1 = data[idx] |
|
273 | 273 | if t == t1: |
|
274 | 274 | return |
|
275 | 275 | t = (t1[0], t[1]) |
|
276 | 276 | if len(r1) == 1: |
|
277 | 277 | data.pop(idx) |
|
278 | 278 | _sortedrange_insert(data, idx, rev, t) |
|
279 | 279 | elif r1[0] == rev: |
|
280 | 280 | data[idx] = (range(rev + 1, r1[-1] + 1), t1) |
|
281 | 281 | _sortedrange_insert(data, idx, rev, t) |
|
282 | 282 | elif r1[-1] == rev: |
|
283 | 283 | data[idx] = (range(r1[0], rev), t1) |
|
284 | 284 | _sortedrange_insert(data, idx + 1, rev, t) |
|
285 | 285 | else: |
|
286 | 286 | data[idx : idx + 1] = [ |
|
287 | 287 | (range(r1[0], rev), t1), |
|
288 | 288 | (range(rev, rev + 1), t), |
|
289 | 289 | (range(rev + 1, r1[-1] + 1), t1), |
|
290 | 290 | ] |
|
291 | 291 | |
|
292 | 292 | |
|
293 | 293 | def _trackphasechange(data, rev, old, new): |
|
294 | 294 | """add a phase move to the <data> list of ranges |
|
295 | 295 | |
|
296 | 296 | If data is None, nothing happens. |
|
297 | 297 | """ |
|
298 | 298 | if data is None: |
|
299 | 299 | return |
|
300 | 300 | |
|
301 | 301 | # If data is empty, create a one-revision range and done |
|
302 | 302 | if not data: |
|
303 | 303 | data.insert(0, (range(rev, rev + 1), (old, new))) |
|
304 | 304 | return |
|
305 | 305 | |
|
306 | 306 | low = 0 |
|
307 | 307 | high = len(data) |
|
308 | 308 | t = (old, new) |
|
309 | 309 | while low < high: |
|
310 | 310 | mid = (low + high) // 2 |
|
311 | 311 | revs = data[mid][0] |
|
312 | 312 | revs_low = revs[0] |
|
313 | 313 | revs_high = revs[-1] |
|
314 | 314 | |
|
315 | 315 | if rev >= revs_low and rev <= revs_high: |
|
316 | 316 | _sortedrange_split(data, mid, rev, t) |
|
317 | 317 | return |
|
318 | 318 | |
|
319 | 319 | if revs_low == rev + 1: |
|
320 | 320 | if mid and data[mid - 1][0][-1] == rev: |
|
321 | 321 | _sortedrange_split(data, mid - 1, rev, t) |
|
322 | 322 | else: |
|
323 | 323 | _sortedrange_insert(data, mid, rev, t) |
|
324 | 324 | return |
|
325 | 325 | |
|
326 | 326 | if revs_high == rev - 1: |
|
327 | 327 | if mid + 1 < len(data) and data[mid + 1][0][0] == rev: |
|
328 | 328 | _sortedrange_split(data, mid + 1, rev, t) |
|
329 | 329 | else: |
|
330 | 330 | _sortedrange_insert(data, mid + 1, rev, t) |
|
331 | 331 | return |
|
332 | 332 | |
|
333 | 333 | if revs_low > rev: |
|
334 | 334 | high = mid |
|
335 | 335 | else: |
|
336 | 336 | low = mid + 1 |
|
337 | 337 | |
|
338 | 338 | if low == len(data): |
|
339 | 339 | data.append((range(rev, rev + 1), t)) |
|
340 | 340 | return |
|
341 | 341 | |
|
342 | 342 | r1, t1 = data[low] |
|
343 | 343 | if r1[0] > rev: |
|
344 | 344 | data.insert(low, (range(rev, rev + 1), t)) |
|
345 | 345 | else: |
|
346 | 346 | data.insert(low + 1, (range(rev, rev + 1), t)) |
|
347 | 347 | |
|
348 | 348 | |
|
349 | 349 | class phasecache: |
|
350 | 350 | def __init__(self, repo, phasedefaults, _load=True): |
|
351 | 351 | # type: (localrepo.localrepository, Optional[Phasedefaults], bool) -> None |
|
352 | 352 | if _load: |
|
353 | 353 | # Cheap trick to allow shallow-copy without copy module |
|
354 | 354 | self.phaseroots, self.dirty = _readroots(repo, phasedefaults) |
|
355 | 355 | self._loadedrevslen = 0 |
|
356 | 356 | self._phasesets = None |
|
357 | 357 | self.filterunknown(repo) |
|
358 | 358 | self.opener = repo.svfs |
|
359 | 359 | |
|
360 | 360 | def hasnonpublicphases(self, repo): |
|
361 | 361 | # type: (localrepo.localrepository) -> bool |
|
362 | 362 | """detect if there are revisions with non-public phase""" |
|
363 | 363 | repo = repo.unfiltered() |
|
364 | 364 | cl = repo.changelog |
|
365 | 365 | if len(cl) >= self._loadedrevslen: |
|
366 | 366 | self.invalidate() |
|
367 | 367 | self.loadphaserevs(repo) |
|
368 | 368 | return any( |
|
369 | 369 | revs for phase, revs in self.phaseroots.items() if phase != public |
|
370 | 370 | ) |
|
371 | 371 | |
|
372 | 372 | def nonpublicphaseroots(self, repo): |
|
373 | 373 | # type: (localrepo.localrepository) -> Set[bytes] |
|
374 | 374 | """returns the roots of all non-public phases |
|
375 | 375 | |
|
376 | 376 | The roots are not minimized, so if the secret revisions are |
|
377 | 377 | descendants of draft revisions, their roots will still be present. |
|
378 | 378 | """ |
|
379 | 379 | repo = repo.unfiltered() |
|
380 | 380 | cl = repo.changelog |
|
381 | 381 | if len(cl) >= self._loadedrevslen: |
|
382 | 382 | self.invalidate() |
|
383 | 383 | self.loadphaserevs(repo) |
|
384 | 384 | return set().union( |
|
385 | 385 | *[ |
|
386 | 386 | revs |
|
387 | 387 | for phase, revs in self.phaseroots.items() |
|
388 | 388 | if phase != public |
|
389 | 389 | ] |
|
390 | 390 | ) |
|
391 | 391 | |
|
392 | 392 | def getrevset(self, repo, phases, subset=None): |
|
393 | 393 | # type: (localrepo.localrepository, Iterable[int], Optional[Any]) -> Any |
|
394 | 394 | # TODO: finish typing this |
|
395 | 395 | """return a smartset for the given phases""" |
|
396 | 396 | self.loadphaserevs(repo) # ensure phase's sets are loaded |
|
397 | 397 | phases = set(phases) |
|
398 | 398 | publicphase = public in phases |
|
399 | 399 | |
|
400 | 400 | if publicphase: |
|
401 | 401 | # In this case, phases keeps all the *other* phases. |
|
402 | 402 | phases = set(allphases).difference(phases) |
|
403 | 403 | if not phases: |
|
404 | 404 | return smartset.fullreposet(repo) |
|
405 | 405 | |
|
406 | 406 | # fast path: _phasesets contains the interesting sets, |
|
407 | 407 | # might only need a union and post-filtering. |
|
408 | 408 | revsneedscopy = False |
|
409 | 409 | if len(phases) == 1: |
|
410 | 410 | [p] = phases |
|
411 | 411 | revs = self._phasesets[p] |
|
412 | 412 | revsneedscopy = True # Don't modify _phasesets |
|
413 | 413 | else: |
|
414 | 414 | # revs has the revisions in all *other* phases. |
|
415 | 415 | revs = set.union(*[self._phasesets[p] for p in phases]) |
|
416 | 416 | |
|
417 | 417 | def _addwdir(wdirsubset, wdirrevs): |
|
418 | 418 | if wdirrev in wdirsubset and repo[None].phase() in phases: |
|
419 | 419 | if revsneedscopy: |
|
420 | 420 | wdirrevs = wdirrevs.copy() |
|
421 | 421 | # The working dir would never be in the # cache, but it was in |
|
422 | 422 | # the subset being filtered for its phase (or filtered out, |
|
423 | 423 | # depending on publicphase), so add it to the output to be |
|
424 | 424 | # included (or filtered out). |
|
425 | 425 | wdirrevs.add(wdirrev) |
|
426 | 426 | return wdirrevs |
|
427 | 427 | |
|
428 | 428 | if not publicphase: |
|
429 | 429 | if repo.changelog.filteredrevs: |
|
430 | 430 | revs = revs - repo.changelog.filteredrevs |
|
431 | 431 | |
|
432 | 432 | if subset is None: |
|
433 | 433 | return smartset.baseset(revs) |
|
434 | 434 | else: |
|
435 | 435 | revs = _addwdir(subset, revs) |
|
436 | 436 | return subset & smartset.baseset(revs) |
|
437 | 437 | else: |
|
438 | 438 | if subset is None: |
|
439 | 439 | subset = smartset.fullreposet(repo) |
|
440 | 440 | |
|
441 | 441 | revs = _addwdir(subset, revs) |
|
442 | 442 | |
|
443 | 443 | if not revs: |
|
444 | 444 | return subset |
|
445 | 445 | return subset.filter(lambda r: r not in revs) |
|
446 | 446 | |
|
447 | 447 | def copy(self): |
|
448 | 448 | # Shallow copy meant to ensure isolation in |
|
449 | 449 | # advance/retractboundary(), nothing more. |
|
450 | 450 | ph = self.__class__(None, None, _load=False) |
|
451 | 451 | ph.phaseroots = self.phaseroots.copy() |
|
452 | 452 | ph.dirty = self.dirty |
|
453 | 453 | ph.opener = self.opener |
|
454 | 454 | ph._loadedrevslen = self._loadedrevslen |
|
455 | 455 | ph._phasesets = self._phasesets |
|
456 | 456 | return ph |
|
457 | 457 | |
|
458 | 458 | def replace(self, phcache): |
|
459 | 459 | """replace all values in 'self' with content of phcache""" |
|
460 | 460 | for a in ( |
|
461 | 461 | b'phaseroots', |
|
462 | 462 | b'dirty', |
|
463 | 463 | b'opener', |
|
464 | 464 | b'_loadedrevslen', |
|
465 | 465 | b'_phasesets', |
|
466 | 466 | ): |
|
467 | 467 | setattr(self, a, getattr(phcache, a)) |
|
468 | 468 | |
|
469 | 469 | def _getphaserevsnative(self, repo): |
|
470 | 470 | repo = repo.unfiltered() |
|
471 | 471 | return repo.changelog.computephases(self.phaseroots) |
|
472 | 472 | |
|
473 | 473 | def _computephaserevspure(self, repo): |
|
474 | 474 | repo = repo.unfiltered() |
|
475 | 475 | cl = repo.changelog |
|
476 | 476 | self._phasesets = {phase: set() for phase in allphases} |
|
477 | 477 | lowerroots = set() |
|
478 | 478 | for phase in reversed(trackedphases): |
|
479 | 479 | roots = pycompat.maplist(cl.rev, self.phaseroots[phase]) |
|
480 | 480 | if roots: |
|
481 | 481 | ps = set(cl.descendants(roots)) |
|
482 | 482 | for root in roots: |
|
483 | 483 | ps.add(root) |
|
484 | 484 | ps.difference_update(lowerroots) |
|
485 | 485 | lowerroots.update(ps) |
|
486 | 486 | self._phasesets[phase] = ps |
|
487 | 487 | self._loadedrevslen = len(cl) |
|
488 | 488 | |
|
489 | 489 | def loadphaserevs(self, repo): |
|
490 | 490 | # type: (localrepo.localrepository) -> None |
|
491 | 491 | """ensure phase information is loaded in the object""" |
|
492 | 492 | if self._phasesets is None: |
|
493 | 493 | try: |
|
494 | 494 | res = self._getphaserevsnative(repo) |
|
495 | 495 | self._loadedrevslen, self._phasesets = res |
|
496 | 496 | except AttributeError: |
|
497 | 497 | self._computephaserevspure(repo) |
|
498 | 498 | |
|
499 | 499 | def invalidate(self): |
|
500 | 500 | self._loadedrevslen = 0 |
|
501 | 501 | self._phasesets = None |
|
502 | 502 | |
|
503 | 503 | def phase(self, repo, rev): |
|
504 | 504 | # type: (localrepo.localrepository, int) -> int |
|
505 | 505 | # We need a repo argument here to be able to build _phasesets |
|
506 | 506 | # if necessary. The repository instance is not stored in |
|
507 | 507 | # phasecache to avoid reference cycles. The changelog instance |
|
508 | 508 | # is not stored because it is a filecache() property and can |
|
509 | 509 | # be replaced without us being notified. |
|
510 | 510 | if rev == nullrev: |
|
511 | 511 | return public |
|
512 | 512 | if rev < nullrev: |
|
513 | 513 | raise ValueError(_(b'cannot lookup negative revision')) |
|
514 | 514 | if rev >= self._loadedrevslen: |
|
515 | 515 | self.invalidate() |
|
516 | 516 | self.loadphaserevs(repo) |
|
517 | 517 | for phase in trackedphases: |
|
518 | 518 | if rev in self._phasesets[phase]: |
|
519 | 519 | return phase |
|
520 | 520 | return public |
|
521 | 521 | |
|
522 | 522 | def write(self): |
|
523 | 523 | if not self.dirty: |
|
524 | 524 | return |
|
525 | 525 | f = self.opener(b'phaseroots', b'w', atomictemp=True, checkambig=True) |
|
526 | 526 | try: |
|
527 | 527 | self._write(f) |
|
528 | 528 | finally: |
|
529 | 529 | f.close() |
|
530 | 530 | |
|
531 | 531 | def _write(self, fp): |
|
532 | 532 | for phase, roots in self.phaseroots.items(): |
|
533 | 533 | for h in sorted(roots): |
|
534 | 534 | fp.write(b'%i %s\n' % (phase, hex(h))) |
|
535 | 535 | self.dirty = False |
|
536 | 536 | |
|
537 | 537 | def _updateroots(self, phase, newroots, tr): |
|
538 | 538 | self.phaseroots[phase] = newroots |
|
539 | 539 | self.invalidate() |
|
540 | 540 | self.dirty = True |
|
541 | 541 | |
|
542 | 542 | tr.addfilegenerator(b'phase', (b'phaseroots',), self._write) |
|
543 | 543 | tr.hookargs[b'phases_moved'] = b'1' |
|
544 | 544 | |
|
545 | 545 | def registernew(self, repo, tr, targetphase, revs): |
|
546 | 546 | repo = repo.unfiltered() |
|
547 | 547 | self._retractboundary(repo, tr, targetphase, [], revs=revs) |
|
548 | 548 | if tr is not None and b'phases' in tr.changes: |
|
549 | 549 | phasetracking = tr.changes[b'phases'] |
|
550 | 550 | phase = self.phase |
|
551 | 551 | for rev in sorted(revs): |
|
552 | 552 | revphase = phase(repo, rev) |
|
553 | 553 | _trackphasechange(phasetracking, rev, None, revphase) |
|
554 | 554 | repo.invalidatevolatilesets() |
|
555 | 555 | |
|
556 | 556 | def advanceboundary( |
|
557 | 557 | self, repo, tr, targetphase, nodes, revs=None, dryrun=None |
|
558 | 558 | ): |
|
559 | 559 | """Set all 'nodes' to phase 'targetphase' |
|
560 | 560 | |
|
561 | 561 | Nodes with a phase lower than 'targetphase' are not affected. |
|
562 | 562 | |
|
563 | 563 | If dryrun is True, no actions will be performed |
|
564 | 564 | |
|
565 | 565 | Returns a set of revs whose phase is changed or should be changed |
|
566 | 566 | """ |
|
567 | 567 | # Be careful to preserve shallow-copied values: do not update |
|
568 | 568 | # phaseroots values, replace them. |
|
569 | 569 | if revs is None: |
|
570 | 570 | revs = [] |
|
571 | 571 | if tr is None: |
|
572 | 572 | phasetracking = None |
|
573 | 573 | else: |
|
574 | 574 | phasetracking = tr.changes.get(b'phases') |
|
575 | 575 | |
|
576 | 576 | repo = repo.unfiltered() |
|
577 | 577 | revs = [repo[n].rev() for n in nodes] + [r for r in revs] |
|
578 | 578 | |
|
579 | 579 | changes = set() # set of revisions to be changed |
|
580 | 580 | delroots = [] # set of root deleted by this path |
|
581 | 581 | for phase in (phase for phase in allphases if phase > targetphase): |
|
582 | 582 | # filter nodes that are not in a compatible phase already |
|
583 | 583 | revs = [rev for rev in revs if self.phase(repo, rev) >= phase] |
|
584 | 584 | if not revs: |
|
585 | 585 | break # no roots to move anymore |
|
586 | 586 | |
|
587 | 587 | olds = self.phaseroots[phase] |
|
588 | 588 | |
|
589 | 589 | affected = repo.revs(b'%ln::%ld', olds, revs) |
|
590 | 590 | changes.update(affected) |
|
591 | 591 | if dryrun: |
|
592 | 592 | continue |
|
593 | 593 | for r in affected: |
|
594 | 594 | _trackphasechange( |
|
595 | 595 | phasetracking, r, self.phase(repo, r), targetphase |
|
596 | 596 | ) |
|
597 | 597 | |
|
598 | 598 | roots = { |
|
599 | 599 | ctx.node() |
|
600 | 600 | for ctx in repo.set(b'roots((%ln::) - %ld)', olds, affected) |
|
601 | 601 | } |
|
602 | 602 | if olds != roots: |
|
603 | 603 | self._updateroots(phase, roots, tr) |
|
604 | 604 | # some roots may need to be declared for lower phases |
|
605 | 605 | delroots.extend(olds - roots) |
|
606 | 606 | if not dryrun: |
|
607 | 607 | # declare deleted root in the target phase |
|
608 | 608 | if targetphase != 0: |
|
609 | 609 | self._retractboundary(repo, tr, targetphase, delroots) |
|
610 | 610 | repo.invalidatevolatilesets() |
|
611 | 611 | return changes |
|
612 | 612 | |
|
613 | 613 | def retractboundary(self, repo, tr, targetphase, nodes): |
|
614 | 614 | oldroots = { |
|
615 | 615 | phase: revs |
|
616 | 616 | for phase, revs in self.phaseroots.items() |
|
617 | 617 | if phase <= targetphase |
|
618 | 618 | } |
|
619 | 619 | if tr is None: |
|
620 | 620 | phasetracking = None |
|
621 | 621 | else: |
|
622 | 622 | phasetracking = tr.changes.get(b'phases') |
|
623 | 623 | repo = repo.unfiltered() |
|
624 | 624 | if ( |
|
625 | 625 | self._retractboundary(repo, tr, targetphase, nodes) |
|
626 | 626 | and phasetracking is not None |
|
627 | 627 | ): |
|
628 | 628 | |
|
629 | 629 | # find the affected revisions |
|
630 | 630 | new = self.phaseroots[targetphase] |
|
631 | 631 | old = oldroots[targetphase] |
|
632 | 632 | affected = set(repo.revs(b'(%ln::) - (%ln::)', new, old)) |
|
633 | 633 | |
|
634 | 634 | # find the phase of the affected revision |
|
635 | 635 | for phase in range(targetphase, -1, -1): |
|
636 | 636 | if phase: |
|
637 | 637 | roots = oldroots.get(phase, []) |
|
638 | 638 | revs = set(repo.revs(b'%ln::%ld', roots, affected)) |
|
639 | 639 | affected -= revs |
|
640 | 640 | else: # public phase |
|
641 | 641 | revs = affected |
|
642 | 642 | for r in sorted(revs): |
|
643 | 643 | _trackphasechange(phasetracking, r, phase, targetphase) |
|
644 | 644 | repo.invalidatevolatilesets() |
|
645 | 645 | |
|
646 | 646 | def _retractboundary(self, repo, tr, targetphase, nodes, revs=None): |
|
647 | 647 | # Be careful to preserve shallow-copied values: do not update |
|
648 | 648 | # phaseroots values, replace them. |
|
649 | 649 | if revs is None: |
|
650 | 650 | revs = [] |
|
651 | 651 | if ( |
|
652 | 652 | targetphase == internal |
|
653 | 653 | and not supportinternal(repo) |
|
654 | 654 | or targetphase == archived |
|
655 | 655 | and not supportarchived(repo) |
|
656 | 656 | ): |
|
657 | 657 | name = phasenames[targetphase] |
|
658 | 658 | msg = b'this repository does not support the %s phase' % name |
|
659 | 659 | raise error.ProgrammingError(msg) |
|
660 | 660 | |
|
661 | 661 | repo = repo.unfiltered() |
|
662 | 662 | torev = repo.changelog.rev |
|
663 | 663 | tonode = repo.changelog.node |
|
664 | 664 | currentroots = {torev(node) for node in self.phaseroots[targetphase]} |
|
665 | 665 | finalroots = oldroots = set(currentroots) |
|
666 | 666 | newroots = [torev(node) for node in nodes] + [r for r in revs] |
|
667 | 667 | newroots = [ |
|
668 | 668 | rev for rev in newroots if self.phase(repo, rev) < targetphase |
|
669 | 669 | ] |
|
670 | 670 | |
|
671 | 671 | if newroots: |
|
672 | 672 | if nullrev in newroots: |
|
673 | 673 | raise error.Abort(_(b'cannot change null revision phase')) |
|
674 | 674 | currentroots.update(newroots) |
|
675 | 675 | |
|
676 | 676 | # Only compute new roots for revs above the roots that are being |
|
677 | 677 | # retracted. |
|
678 | 678 | minnewroot = min(newroots) |
|
679 | 679 | aboveroots = [rev for rev in currentroots if rev >= minnewroot] |
|
680 | 680 | updatedroots = repo.revs(b'roots(%ld::)', aboveroots) |
|
681 | 681 | |
|
682 | 682 | finalroots = {rev for rev in currentroots if rev < minnewroot} |
|
683 | 683 | finalroots.update(updatedroots) |
|
684 | 684 | if finalroots != oldroots: |
|
685 | 685 | self._updateroots( |
|
686 | 686 | targetphase, {tonode(rev) for rev in finalroots}, tr |
|
687 | 687 | ) |
|
688 | 688 | return True |
|
689 | 689 | return False |
|
690 | 690 | |
|
691 | 691 | def filterunknown(self, repo): |
|
692 | 692 | # type: (localrepo.localrepository) -> None |
|
693 | 693 | """remove unknown nodes from the phase boundary |
|
694 | 694 | |
|
695 | 695 | Nothing is lost as unknown nodes only hold data for their descendants. |
|
696 | 696 | """ |
|
697 | 697 | filtered = False |
|
698 | 698 | has_node = repo.changelog.index.has_node # to filter unknown nodes |
|
699 | 699 | for phase, nodes in self.phaseroots.items(): |
|
700 | 700 | missing = sorted(node for node in nodes if not has_node(node)) |
|
701 | 701 | if missing: |
|
702 | 702 | for mnode in missing: |
|
703 | 703 | repo.ui.debug( |
|
704 | 704 | b'removing unknown node %s from %i-phase boundary\n' |
|
705 | 705 | % (short(mnode), phase) |
|
706 | 706 | ) |
|
707 | 707 | nodes.symmetric_difference_update(missing) |
|
708 | 708 | filtered = True |
|
709 | 709 | if filtered: |
|
710 | 710 | self.dirty = True |
|
711 | 711 | # filterunknown is called by repo.destroyed, we may have no changes in |
|
712 | 712 | # root but _phasesets contents is certainly invalid (or at least we |
|
713 | 713 | # have not proper way to check that). related to issue 3858. |
|
714 | 714 | # |
|
715 | 715 | # The other caller is __init__ that have no _phasesets initialized |
|
716 | 716 | # anyway. If this change we should consider adding a dedicated |
|
717 | 717 | # "destroyed" function to phasecache or a proper cache key mechanism |
|
718 | 718 | # (see branchmap one) |
|
719 | 719 | self.invalidate() |
|
720 | 720 | |
|
721 | 721 | |
|
722 | 722 | def advanceboundary(repo, tr, targetphase, nodes, revs=None, dryrun=None): |
|
723 | 723 | """Add nodes to a phase changing other nodes phases if necessary. |
|
724 | 724 | |
|
725 | 725 | This function move boundary *forward* this means that all nodes |
|
726 | 726 | are set in the target phase or kept in a *lower* phase. |
|
727 | 727 | |
|
728 | 728 | Simplify boundary to contains phase roots only. |
|
729 | 729 | |
|
730 | 730 | If dryrun is True, no actions will be performed |
|
731 | 731 | |
|
732 | 732 | Returns a set of revs whose phase is changed or should be changed |
|
733 | 733 | """ |
|
734 | 734 | if revs is None: |
|
735 | 735 | revs = [] |
|
736 | 736 | phcache = repo._phasecache.copy() |
|
737 | 737 | changes = phcache.advanceboundary( |
|
738 | 738 | repo, tr, targetphase, nodes, revs=revs, dryrun=dryrun |
|
739 | 739 | ) |
|
740 | 740 | if not dryrun: |
|
741 | 741 | repo._phasecache.replace(phcache) |
|
742 | 742 | return changes |
|
743 | 743 | |
|
744 | 744 | |
|
745 | 745 | def retractboundary(repo, tr, targetphase, nodes): |
|
746 | 746 | """Set nodes back to a phase changing other nodes phases if |
|
747 | 747 | necessary. |
|
748 | 748 | |
|
749 | 749 | This function move boundary *backward* this means that all nodes |
|
750 | 750 | are set in the target phase or kept in a *higher* phase. |
|
751 | 751 | |
|
752 | 752 | Simplify boundary to contains phase roots only.""" |
|
753 | 753 | phcache = repo._phasecache.copy() |
|
754 | 754 | phcache.retractboundary(repo, tr, targetphase, nodes) |
|
755 | 755 | repo._phasecache.replace(phcache) |
|
756 | 756 | |
|
757 | 757 | |
|
758 | 758 | def registernew(repo, tr, targetphase, revs): |
|
759 | 759 | """register a new revision and its phase |
|
760 | 760 | |
|
761 | 761 | Code adding revisions to the repository should use this function to |
|
762 | 762 | set new changeset in their target phase (or higher). |
|
763 | 763 | """ |
|
764 | 764 | phcache = repo._phasecache.copy() |
|
765 | 765 | phcache.registernew(repo, tr, targetphase, revs) |
|
766 | 766 | repo._phasecache.replace(phcache) |
|
767 | 767 | |
|
768 | 768 | |
|
769 | 769 | def listphases(repo): |
|
770 | 770 | # type: (localrepo.localrepository) -> Dict[bytes, bytes] |
|
771 | 771 | """List phases root for serialization over pushkey""" |
|
772 | 772 | # Use ordered dictionary so behavior is deterministic. |
|
773 | 773 | keys = util.sortdict() |
|
774 | 774 | value = b'%i' % draft |
|
775 | 775 | cl = repo.unfiltered().changelog |
|
776 | 776 | for root in repo._phasecache.phaseroots[draft]: |
|
777 | 777 | if repo._phasecache.phase(repo, cl.rev(root)) <= draft: |
|
778 | 778 | keys[hex(root)] = value |
|
779 | 779 | |
|
780 | 780 | if repo.publishing(): |
|
781 | 781 | # Add an extra data to let remote know we are a publishing |
|
782 | 782 | # repo. Publishing repo can't just pretend they are old repo. |
|
783 | 783 | # When pushing to a publishing repo, the client still need to |
|
784 | 784 | # push phase boundary |
|
785 | 785 | # |
|
786 | 786 | # Push do not only push changeset. It also push phase data. |
|
787 | 787 | # New phase data may apply to common changeset which won't be |
|
788 | 788 | # push (as they are common). Here is a very simple example: |
|
789 | 789 | # |
|
790 | 790 | # 1) repo A push changeset X as draft to repo B |
|
791 | 791 | # 2) repo B make changeset X public |
|
792 | 792 | # 3) repo B push to repo A. X is not pushed but the data that |
|
793 | 793 | # X as now public should |
|
794 | 794 | # |
|
795 | 795 | # The server can't handle it on it's own as it has no idea of |
|
796 | 796 | # client phase data. |
|
797 | 797 | keys[b'publishing'] = b'True' |
|
798 | 798 | return keys |
|
799 | 799 | |
|
800 | 800 | |
|
801 | 801 | def pushphase(repo, nhex, oldphasestr, newphasestr): |
|
802 | 802 | # type: (localrepo.localrepository, bytes, bytes, bytes) -> bool |
|
803 | 803 | """List phases root for serialization over pushkey""" |
|
804 | 804 | repo = repo.unfiltered() |
|
805 | 805 | with repo.lock(): |
|
806 | 806 | currentphase = repo[nhex].phase() |
|
807 | 807 | newphase = abs(int(newphasestr)) # let's avoid negative index surprise |
|
808 | 808 | oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise |
|
809 | 809 | if currentphase == oldphase and newphase < oldphase: |
|
810 | 810 | with repo.transaction(b'pushkey-phase') as tr: |
|
811 | 811 | advanceboundary(repo, tr, newphase, [bin(nhex)]) |
|
812 | 812 | return True |
|
813 | 813 | elif currentphase == newphase: |
|
814 | 814 | # raced, but got correct result |
|
815 | 815 | return True |
|
816 | 816 | else: |
|
817 | 817 | return False |
|
818 | 818 | |
|
819 | 819 | |
|
820 | 820 | def subsetphaseheads(repo, subset): |
|
821 | 821 | """Finds the phase heads for a subset of a history |
|
822 | 822 | |
|
823 | 823 | Returns a list indexed by phase number where each item is a list of phase |
|
824 | 824 | head nodes. |
|
825 | 825 | """ |
|
826 | 826 | cl = repo.changelog |
|
827 | 827 | |
|
828 | 828 | headsbyphase = {i: [] for i in allphases} |
|
829 | 829 | # No need to keep track of secret phase; any heads in the subset that |
|
830 | 830 | # are not mentioned are implicitly secret. |
|
831 | 831 | for phase in allphases[:secret]: |
|
832 | 832 | revset = b"heads(%%ln & %s())" % phasenames[phase] |
|
833 | 833 | headsbyphase[phase] = [cl.node(r) for r in repo.revs(revset, subset)] |
|
834 | 834 | return headsbyphase |
|
835 | 835 | |
|
836 | 836 | |
|
837 | 837 | def updatephases(repo, trgetter, headsbyphase): |
|
838 | 838 | """Updates the repo with the given phase heads""" |
|
839 | 839 | # Now advance phase boundaries of all phases |
|
840 | 840 | # |
|
841 | 841 | # run the update (and fetch transaction) only if there are actually things |
|
842 | 842 | # to update. This avoid creating empty transaction during no-op operation. |
|
843 | 843 | |
|
844 | 844 | for phase in allphases: |
|
845 | 845 | revset = b'%ln - _phase(%s)' |
|
846 | 846 | heads = [c.node() for c in repo.set(revset, headsbyphase[phase], phase)] |
|
847 | 847 | if heads: |
|
848 | 848 | advanceboundary(repo, trgetter(), phase, heads) |
|
849 | 849 | |
|
850 | 850 | |
|
851 | 851 | def analyzeremotephases(repo, subset, roots): |
|
852 | 852 | """Compute phases heads and root in a subset of node from root dict |
|
853 | 853 | |
|
854 | 854 | * subset is heads of the subset |
|
855 | 855 | * roots is {<nodeid> => phase} mapping. key and value are string. |
|
856 | 856 | |
|
857 | 857 | Accept unknown element input |
|
858 | 858 | """ |
|
859 | 859 | repo = repo.unfiltered() |
|
860 | 860 | # build list from dictionary |
|
861 | 861 | draftroots = [] |
|
862 | 862 | has_node = repo.changelog.index.has_node # to filter unknown nodes |
|
863 | 863 | for nhex, phase in roots.items(): |
|
864 | 864 | if nhex == b'publishing': # ignore data related to publish option |
|
865 | 865 | continue |
|
866 | 866 | node = bin(nhex) |
|
867 | 867 | phase = int(phase) |
|
868 | 868 | if phase == public: |
|
869 | 869 | if node != repo.nullid: |
|
870 | 870 | repo.ui.warn( |
|
871 | 871 | _( |
|
872 | 872 | b'ignoring inconsistent public root' |
|
873 | 873 | b' from remote: %s\n' |
|
874 | 874 | ) |
|
875 | 875 | % nhex |
|
876 | 876 | ) |
|
877 | 877 | elif phase == draft: |
|
878 | 878 | if has_node(node): |
|
879 | 879 | draftroots.append(node) |
|
880 | 880 | else: |
|
881 | 881 | repo.ui.warn( |
|
882 | 882 | _(b'ignoring unexpected root from remote: %i %s\n') |
|
883 | 883 | % (phase, nhex) |
|
884 | 884 | ) |
|
885 | 885 | # compute heads |
|
886 | 886 | publicheads = newheads(repo, subset, draftroots) |
|
887 | 887 | return publicheads, draftroots |
|
888 | 888 | |
|
889 | 889 | |
|
890 | 890 | class remotephasessummary: |
|
891 | 891 | """summarize phase information on the remote side |
|
892 | 892 | |
|
893 | 893 | :publishing: True is the remote is publishing |
|
894 | 894 | :publicheads: list of remote public phase heads (nodes) |
|
895 | 895 | :draftheads: list of remote draft phase heads (nodes) |
|
896 | 896 | :draftroots: list of remote draft phase root (nodes) |
|
897 | 897 | """ |
|
898 | 898 | |
|
899 | 899 | def __init__(self, repo, remotesubset, remoteroots): |
|
900 | 900 | unfi = repo.unfiltered() |
|
901 | 901 | self._allremoteroots = remoteroots |
|
902 | 902 | |
|
903 | 903 | self.publishing = remoteroots.get(b'publishing', False) |
|
904 | 904 | |
|
905 | 905 | ana = analyzeremotephases(repo, remotesubset, remoteroots) |
|
906 | 906 | self.publicheads, self.draftroots = ana |
|
907 | 907 | # Get the list of all "heads" revs draft on remote |
|
908 | 908 | dheads = unfi.set(b'heads(%ln::%ln)', self.draftroots, remotesubset) |
|
909 | 909 | self.draftheads = [c.node() for c in dheads] |
|
910 | 910 | |
|
911 | 911 | |
|
912 | 912 | def newheads(repo, heads, roots): |
|
913 | 913 | """compute new head of a subset minus another |
|
914 | 914 | |
|
915 | 915 | * `heads`: define the first subset |
|
916 | 916 | * `roots`: define the second we subtract from the first""" |
|
917 | 917 | # prevent an import cycle |
|
918 | 918 | # phases > dagop > patch > copies > scmutil > obsolete > obsutil > phases |
|
919 | 919 | from . import dagop |
|
920 | 920 | |
|
921 | 921 | repo = repo.unfiltered() |
|
922 | 922 | cl = repo.changelog |
|
923 | 923 | rev = cl.index.get_rev |
|
924 | 924 | if not roots: |
|
925 | 925 | return heads |
|
926 | 926 | if not heads or heads == [repo.nullid]: |
|
927 | 927 | return [] |
|
928 | 928 | # The logic operated on revisions, convert arguments early for convenience |
|
929 | 929 | new_heads = {rev(n) for n in heads if n != repo.nullid} |
|
930 | 930 | roots = [rev(n) for n in roots] |
|
931 | 931 | # compute the area we need to remove |
|
932 | 932 | affected_zone = repo.revs(b"(%ld::%ld)", roots, new_heads) |
|
933 | 933 | # heads in the area are no longer heads |
|
934 | 934 | new_heads.difference_update(affected_zone) |
|
935 | 935 | # revisions in the area have children outside of it, |
|
936 | 936 | # They might be new heads |
|
937 | 937 | candidates = repo.revs( |
|
938 | 938 | b"parents(%ld + (%ld and merge())) and not null", roots, affected_zone |
|
939 | 939 | ) |
|
940 | 940 | candidates -= affected_zone |
|
941 | 941 | if new_heads or candidates: |
|
942 | 942 | # remove candidate that are ancestors of other heads |
|
943 | 943 | new_heads.update(candidates) |
|
944 | 944 | prunestart = repo.revs(b"parents(%ld) and not null", new_heads) |
|
945 | 945 | pruned = dagop.reachableroots(repo, candidates, prunestart) |
|
946 | 946 | new_heads.difference_update(pruned) |
|
947 | 947 | |
|
948 | 948 | return pycompat.maplist(cl.node, sorted(new_heads)) |
|
949 | 949 | |
|
950 | 950 | |
|
951 | 951 | def newcommitphase(ui): |
|
952 | 952 | # type: (uimod.ui) -> int |
|
953 | 953 | """helper to get the target phase of new commit |
|
954 | 954 | |
|
955 | 955 | Handle all possible values for the phases.new-commit options. |
|
956 | 956 | |
|
957 | 957 | """ |
|
958 | 958 | v = ui.config(b'phases', b'new-commit') |
|
959 | 959 | try: |
|
960 | 960 | return phasenumber2[v] |
|
961 | 961 | except KeyError: |
|
962 | 962 | raise error.ConfigError( |
|
963 | 963 | _(b"phases.new-commit: not a valid phase name ('%s')") % v |
|
964 | 964 | ) |
|
965 | 965 | |
|
966 | 966 | |
|
967 | 967 | def hassecret(repo): |
|
968 | 968 | # type: (localrepo.localrepository) -> bool |
|
969 | 969 | """utility function that check if a repo have any secret changeset.""" |
|
970 | 970 | return bool(repo._phasecache.phaseroots[secret]) |
|
971 | 971 | |
|
972 | 972 | |
|
973 | 973 | def preparehookargs(node, old, new): |
|
974 | 974 | # type: (bytes, Optional[int], Optional[int]) -> Dict[bytes, bytes] |
|
975 | 975 | if old is None: |
|
976 | 976 | old = b'' |
|
977 | 977 | else: |
|
978 | 978 | old = phasenames[old] |
|
979 | 979 | return {b'node': node, b'oldphase': old, b'phase': phasenames[new]} |
@@ -1,120 +1,125 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 | |
|
9 | 9 | # obsolete experimental requirements: |
|
10 | 10 | # - manifestv2: An experimental new manifest format that allowed |
|
11 | 11 | # for stem compression of long paths. Experiment ended up not |
|
12 | 12 | # being successful (repository sizes went up due to worse delta |
|
13 | 13 | # chains), and the code was deleted in 4.6. |
|
14 | 14 | |
|
15 | 15 | GENERALDELTA_REQUIREMENT = b'generaldelta' |
|
16 | 16 | DOTENCODE_REQUIREMENT = b'dotencode' |
|
17 | 17 | STORE_REQUIREMENT = b'store' |
|
18 | 18 | FNCACHE_REQUIREMENT = b'fncache' |
|
19 | 19 | |
|
20 | 20 | DIRSTATE_TRACKED_HINT_V1 = b'dirstate-tracked-key-v1' |
|
21 | 21 | DIRSTATE_V2_REQUIREMENT = b'dirstate-v2' |
|
22 | 22 | |
|
23 | 23 | # When narrowing is finalized and no longer subject to format changes, |
|
24 | 24 | # we should move this to just "narrow" or similar. |
|
25 | 25 | NARROW_REQUIREMENT = b'narrowhg-experimental' |
|
26 | 26 | |
|
27 | 27 | # Enables sparse working directory usage |
|
28 | 28 | SPARSE_REQUIREMENT = b'exp-sparse' |
|
29 | 29 | |
|
30 | 30 | # Enables the internal phase which is used to hide changesets instead |
|
31 | 31 | # of stripping them |
|
32 | 32 | INTERNAL_PHASE_REQUIREMENT = b'internal-phase' |
|
33 | 33 | |
|
34 | # Enables the internal phase which is used to hide changesets instead | |
|
35 | # of stripping them | |
|
36 | ARCHIVED_PHASE_REQUIREMENT = b'exp-archived-phase' | |
|
37 | ||
|
34 | 38 | # Stores manifest in Tree structure |
|
35 | 39 | TREEMANIFEST_REQUIREMENT = b'treemanifest' |
|
36 | 40 | |
|
37 | 41 | REVLOGV1_REQUIREMENT = b'revlogv1' |
|
38 | 42 | |
|
39 | 43 | # allow using ZSTD as compression engine for revlog content |
|
40 | 44 | REVLOG_COMPRESSION_ZSTD = b'revlog-compression-zstd' |
|
41 | 45 | |
|
42 | 46 | # Increment the sub-version when the revlog v2 format changes to lock out old |
|
43 | 47 | # clients. |
|
44 | 48 | CHANGELOGV2_REQUIREMENT = b'exp-changelog-v2' |
|
45 | 49 | |
|
46 | 50 | # Increment the sub-version when the revlog v2 format changes to lock out old |
|
47 | 51 | # clients. |
|
48 | 52 | REVLOGV2_REQUIREMENT = b'exp-revlogv2.2' |
|
49 | 53 | |
|
50 | 54 | # A repository with the sparserevlog feature will have delta chains that |
|
51 | 55 | # can spread over a larger span. Sparse reading cuts these large spans into |
|
52 | 56 | # pieces, so that each piece isn't too big. |
|
53 | 57 | # Without the sparserevlog capability, reading from the repository could use |
|
54 | 58 | # huge amounts of memory, because the whole span would be read at once, |
|
55 | 59 | # including all the intermediate revisions that aren't pertinent for the chain. |
|
56 | 60 | # This is why once a repository has enabled sparse-read, it becomes required. |
|
57 | 61 | SPARSEREVLOG_REQUIREMENT = b'sparserevlog' |
|
58 | 62 | |
|
59 | 63 | # A repository with the the copies-sidedata-changeset requirement will store |
|
60 | 64 | # copies related information in changeset's sidedata. |
|
61 | 65 | COPIESSDC_REQUIREMENT = b'exp-copies-sidedata-changeset' |
|
62 | 66 | |
|
63 | 67 | # The repository use persistent nodemap for the changelog and the manifest. |
|
64 | 68 | NODEMAP_REQUIREMENT = b'persistent-nodemap' |
|
65 | 69 | |
|
66 | 70 | # Denotes that the current repository is a share |
|
67 | 71 | SHARED_REQUIREMENT = b'shared' |
|
68 | 72 | |
|
69 | 73 | # Denotes that current repository is a share and the shared source path is |
|
70 | 74 | # relative to the current repository root path |
|
71 | 75 | RELATIVE_SHARED_REQUIREMENT = b'relshared' |
|
72 | 76 | |
|
73 | 77 | # A repository with share implemented safely. The repository has different |
|
74 | 78 | # store and working copy requirements i.e. both `.hg/requires` and |
|
75 | 79 | # `.hg/store/requires` are present. |
|
76 | 80 | SHARESAFE_REQUIREMENT = b'share-safe' |
|
77 | 81 | |
|
78 | 82 | # Bookmarks must be stored in the `store` part of the repository and will be |
|
79 | 83 | # share accross shares |
|
80 | 84 | BOOKMARKS_IN_STORE_REQUIREMENT = b'bookmarksinstore' |
|
81 | 85 | |
|
82 | 86 | # List of requirements which are working directory specific |
|
83 | 87 | # These requirements cannot be shared between repositories if they |
|
84 | 88 | # share the same store |
|
85 | 89 | # * sparse is a working directory specific functionality and hence working |
|
86 | 90 | # directory specific requirement |
|
87 | 91 | # * SHARED_REQUIREMENT and RELATIVE_SHARED_REQUIREMENT are requirements which |
|
88 | 92 | # represents that the current working copy/repository shares store of another |
|
89 | 93 | # repo. Hence both of them should be stored in working copy |
|
90 | 94 | # * SHARESAFE_REQUIREMENT needs to be stored in working dir to mark that rest of |
|
91 | 95 | # the requirements are stored in store's requires |
|
92 | 96 | # * DIRSTATE_V2_REQUIREMENT affects .hg/dirstate, of which there is one per |
|
93 | 97 | # working directory. |
|
94 | 98 | WORKING_DIR_REQUIREMENTS = { |
|
95 | 99 | SPARSE_REQUIREMENT, |
|
96 | 100 | SHARED_REQUIREMENT, |
|
97 | 101 | RELATIVE_SHARED_REQUIREMENT, |
|
98 | 102 | SHARESAFE_REQUIREMENT, |
|
99 | 103 | DIRSTATE_TRACKED_HINT_V1, |
|
100 | 104 | DIRSTATE_V2_REQUIREMENT, |
|
101 | 105 | } |
|
102 | 106 | |
|
103 | 107 | # List of requirement that impact "stream-clone" (and hardlink clone) and |
|
104 | 108 | # cannot be changed in such cases. |
|
105 | 109 | # |
|
106 | 110 | # requirements not in this list are safe to be altered during stream-clone. |
|
107 | 111 | # |
|
108 | 112 | # note: the list is currently inherited from previous code and miss some relevant requirement while containing some irrelevant ones. |
|
109 | 113 | STREAM_FIXED_REQUIREMENTS = { |
|
114 | ARCHIVED_PHASE_REQUIREMENT, | |
|
110 | 115 | BOOKMARKS_IN_STORE_REQUIREMENT, |
|
111 | 116 | CHANGELOGV2_REQUIREMENT, |
|
112 | 117 | COPIESSDC_REQUIREMENT, |
|
113 | 118 | GENERALDELTA_REQUIREMENT, |
|
114 | 119 | INTERNAL_PHASE_REQUIREMENT, |
|
115 | 120 | REVLOG_COMPRESSION_ZSTD, |
|
116 | 121 | REVLOGV1_REQUIREMENT, |
|
117 | 122 | REVLOGV2_REQUIREMENT, |
|
118 | 123 | SPARSEREVLOG_REQUIREMENT, |
|
119 | 124 | TREEMANIFEST_REQUIREMENT, |
|
120 | 125 | } |
@@ -1,143 +1,143 b'' | |||
|
1 | 1 | ========================================================= |
|
2 | 2 | Test features and behaviors related to the archived phase |
|
3 | 3 | ========================================================= |
|
4 | 4 | |
|
5 | 5 | $ cat << EOF >> $HGRCPATH |
|
6 | 6 | > [format] |
|
7 |
> |
|
|
7 | > exp-archived-phase=yes | |
|
8 | 8 | > [extensions] |
|
9 | 9 | > strip= |
|
10 | 10 | > [experimental] |
|
11 | 11 | > EOF |
|
12 | 12 | |
|
13 | 13 | $ hg init repo |
|
14 | 14 | $ cd repo |
|
15 | 15 | $ echo root > a |
|
16 | 16 | $ hg add a |
|
17 | 17 | $ hg ci -m 'root' |
|
18 | 18 | |
|
19 | 19 | Test that bundle can unarchive a changeset |
|
20 | 20 | ------------------------------------------ |
|
21 | 21 | |
|
22 | 22 | $ echo foo >> a |
|
23 | 23 | $ hg st |
|
24 | 24 | M a |
|
25 | 25 | $ hg ci -m 'unbundletesting' |
|
26 | 26 | $ hg log -G |
|
27 | 27 | @ changeset: 1:883aadbbf309 |
|
28 | 28 | | tag: tip |
|
29 | 29 | | user: test |
|
30 | 30 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
31 | 31 | | summary: unbundletesting |
|
32 | 32 | | |
|
33 | 33 | o changeset: 0:c1863a3840c6 |
|
34 | 34 | user: test |
|
35 | 35 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
36 | 36 | summary: root |
|
37 | 37 | |
|
38 | 38 | $ hg strip --soft --rev '.' |
|
39 | 39 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
40 | 40 | saved backup bundle to $TESTTMP/repo/.hg/strip-backup/883aadbbf309-efc55adc-backup.hg |
|
41 | 41 | $ hg log -G |
|
42 | 42 | @ changeset: 0:c1863a3840c6 |
|
43 | 43 | tag: tip |
|
44 | 44 | user: test |
|
45 | 45 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
46 | 46 | summary: root |
|
47 | 47 | |
|
48 | 48 | $ hg log -G --hidden |
|
49 | 49 | o changeset: 1:883aadbbf309 |
|
50 | 50 | | tag: tip |
|
51 | 51 | | user: test |
|
52 | 52 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
53 | 53 | | summary: unbundletesting |
|
54 | 54 | | |
|
55 | 55 | @ changeset: 0:c1863a3840c6 |
|
56 | 56 | user: test |
|
57 | 57 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
58 | 58 | summary: root |
|
59 | 59 | |
|
60 | 60 | $ hg unbundle .hg/strip-backup/883aadbbf309-efc55adc-backup.hg |
|
61 | 61 | adding changesets |
|
62 | 62 | adding manifests |
|
63 | 63 | adding file changes |
|
64 | 64 | added 0 changesets with 0 changes to 1 files |
|
65 | 65 | (run 'hg update' to get a working copy) |
|
66 | 66 | $ hg log -G |
|
67 | 67 | o changeset: 1:883aadbbf309 |
|
68 | 68 | | tag: tip |
|
69 | 69 | | user: test |
|
70 | 70 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
71 | 71 | | summary: unbundletesting |
|
72 | 72 | | |
|
73 | 73 | @ changeset: 0:c1863a3840c6 |
|
74 | 74 | user: test |
|
75 | 75 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
76 | 76 | summary: root |
|
77 | 77 | |
|
78 | 78 | |
|
79 | 79 | Test that history rewriting command can use the archived phase when allowed to |
|
80 | 80 | ------------------------------------------------------------------------------ |
|
81 | 81 | |
|
82 | 82 | $ hg up 'desc(unbundletesting)' |
|
83 | 83 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
84 | 84 | $ echo bar >> a |
|
85 | 85 | $ hg commit --amend --config experimental.cleanup-as-archived=yes |
|
86 | 86 | $ hg log -G |
|
87 | 87 | @ changeset: 2:d1e73e428f29 |
|
88 | 88 | | tag: tip |
|
89 | 89 | | parent: 0:c1863a3840c6 |
|
90 | 90 | | user: test |
|
91 | 91 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
92 | 92 | | summary: unbundletesting |
|
93 | 93 | | |
|
94 | 94 | o changeset: 0:c1863a3840c6 |
|
95 | 95 | user: test |
|
96 | 96 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
97 | 97 | summary: root |
|
98 | 98 | |
|
99 | 99 | $ hg log -G --hidden |
|
100 | 100 | @ changeset: 2:d1e73e428f29 |
|
101 | 101 | | tag: tip |
|
102 | 102 | | parent: 0:c1863a3840c6 |
|
103 | 103 | | user: test |
|
104 | 104 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
105 | 105 | | summary: unbundletesting |
|
106 | 106 | | |
|
107 | 107 | | o changeset: 1:883aadbbf309 |
|
108 | 108 | |/ user: test |
|
109 | 109 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
110 | 110 | | summary: unbundletesting |
|
111 | 111 | | |
|
112 | 112 | o changeset: 0:c1863a3840c6 |
|
113 | 113 | user: test |
|
114 | 114 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
115 | 115 | summary: root |
|
116 | 116 | |
|
117 | 117 | $ ls -1 .hg/strip-backup/ |
|
118 | 118 | 883aadbbf309-efc55adc-amend.hg |
|
119 | 119 | 883aadbbf309-efc55adc-backup.hg |
|
120 | 120 | $ hg unbundle .hg/strip-backup/883aadbbf309*amend.hg |
|
121 | 121 | adding changesets |
|
122 | 122 | adding manifests |
|
123 | 123 | adding file changes |
|
124 | 124 | added 0 changesets with 0 changes to 1 files |
|
125 | 125 | (run 'hg update' to get a working copy) |
|
126 | 126 | $ hg log -G |
|
127 | 127 | @ changeset: 2:d1e73e428f29 |
|
128 | 128 | | tag: tip |
|
129 | 129 | | parent: 0:c1863a3840c6 |
|
130 | 130 | | user: test |
|
131 | 131 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
132 | 132 | | summary: unbundletesting |
|
133 | 133 | | |
|
134 | 134 | | o changeset: 1:883aadbbf309 |
|
135 | 135 | |/ user: test |
|
136 | 136 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
137 | 137 | | summary: unbundletesting |
|
138 | 138 | | |
|
139 | 139 | o changeset: 0:c1863a3840c6 |
|
140 | 140 | user: test |
|
141 | 141 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
142 | 142 | summary: root |
|
143 | 143 |
@@ -1,1042 +1,1049 b'' | |||
|
1 | 1 | $ cat > $TESTTMP/hook.sh << 'EOF' |
|
2 | 2 | > echo "test-hook-close-phase: $HG_NODE: $HG_OLDPHASE -> $HG_PHASE" |
|
3 | 3 | > EOF |
|
4 | 4 | |
|
5 | 5 | $ cat >> $HGRCPATH << EOF |
|
6 | 6 | > [extensions] |
|
7 | 7 | > phasereport=$TESTDIR/testlib/ext-phase-report.py |
|
8 | 8 | > [hooks] |
|
9 | 9 | > txnclose-phase.test = sh $TESTTMP/hook.sh |
|
10 | 10 | > EOF |
|
11 | 11 | |
|
12 | 12 | $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; } |
|
13 | 13 | $ mkcommit() { |
|
14 | 14 | > echo "$1" > "$1" |
|
15 | 15 | > hg add "$1" |
|
16 | 16 | > message="$1" |
|
17 | 17 | > shift |
|
18 | 18 | > hg ci -m "$message" $* |
|
19 | 19 | > } |
|
20 | 20 | |
|
21 | 21 | $ hg init initialrepo |
|
22 | 22 | $ cd initialrepo |
|
23 | 23 | |
|
24 | 24 | Cannot change null revision phase |
|
25 | 25 | |
|
26 | 26 | $ hg phase --force --secret null |
|
27 | 27 | abort: cannot change null revision phase |
|
28 | 28 | [255] |
|
29 | 29 | $ hg phase null |
|
30 | 30 | -1: public |
|
31 | 31 | |
|
32 | 32 | $ mkcommit A |
|
33 | 33 | test-debug-phase: new rev 0: x -> 1 |
|
34 | 34 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> draft |
|
35 | 35 | |
|
36 | 36 | New commit are draft by default |
|
37 | 37 | |
|
38 | 38 | $ hglog |
|
39 | 39 | 0 1 A |
|
40 | 40 | |
|
41 | 41 | Following commit are draft too |
|
42 | 42 | |
|
43 | 43 | $ mkcommit B |
|
44 | 44 | test-debug-phase: new rev 1: x -> 1 |
|
45 | 45 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> draft |
|
46 | 46 | |
|
47 | 47 | $ hglog |
|
48 | 48 | 1 1 B |
|
49 | 49 | 0 1 A |
|
50 | 50 | |
|
51 | 51 | Working directory phase is secret when its parent is secret. |
|
52 | 52 | |
|
53 | 53 | $ hg phase --force --secret . |
|
54 | 54 | test-debug-phase: move rev 0: 1 -> 2 |
|
55 | 55 | test-debug-phase: move rev 1: 1 -> 2 |
|
56 | 56 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: draft -> secret |
|
57 | 57 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> secret |
|
58 | 58 | $ hg log -r 'wdir()' -T '{phase}\n' |
|
59 | 59 | secret |
|
60 | 60 | $ hg log -r 'wdir() and public()' -T '{phase}\n' |
|
61 | 61 | $ hg log -r 'wdir() and draft()' -T '{phase}\n' |
|
62 | 62 | $ hg log -r 'wdir() and secret()' -T '{phase}\n' |
|
63 | 63 | secret |
|
64 | 64 | |
|
65 | 65 | Working directory phase is draft when its parent is draft. |
|
66 | 66 | |
|
67 | 67 | $ hg phase --draft . |
|
68 | 68 | test-debug-phase: move rev 1: 2 -> 1 |
|
69 | 69 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: secret -> draft |
|
70 | 70 | $ hg log -r 'wdir()' -T '{phase}\n' |
|
71 | 71 | draft |
|
72 | 72 | $ hg log -r 'wdir() and public()' -T '{phase}\n' |
|
73 | 73 | $ hg log -r 'wdir() and draft()' -T '{phase}\n' |
|
74 | 74 | draft |
|
75 | 75 | $ hg log -r 'wdir() and secret()' -T '{phase}\n' |
|
76 | 76 | |
|
77 | 77 | Working directory phase is secret when a new commit will be created as secret, |
|
78 | 78 | even if the parent is draft. |
|
79 | 79 | |
|
80 | 80 | $ hg log -r 'wdir() and secret()' -T '{phase}\n' \ |
|
81 | 81 | > --config phases.new-commit='secret' |
|
82 | 82 | secret |
|
83 | 83 | |
|
84 | 84 | Working directory phase is draft when its parent is public. |
|
85 | 85 | |
|
86 | 86 | $ hg phase --public . |
|
87 | 87 | test-debug-phase: move rev 0: 1 -> 0 |
|
88 | 88 | test-debug-phase: move rev 1: 1 -> 0 |
|
89 | 89 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: draft -> public |
|
90 | 90 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> public |
|
91 | 91 | $ hg log -r 'wdir()' -T '{phase}\n' |
|
92 | 92 | draft |
|
93 | 93 | $ hg log -r 'wdir() and public()' -T '{phase}\n' |
|
94 | 94 | $ hg log -r 'wdir() and draft()' -T '{phase}\n' |
|
95 | 95 | draft |
|
96 | 96 | $ hg log -r 'wdir() and secret()' -T '{phase}\n' |
|
97 | 97 | $ hg log -r 'wdir() and secret()' -T '{phase}\n' \ |
|
98 | 98 | > --config phases.new-commit='secret' |
|
99 | 99 | secret |
|
100 | 100 | |
|
101 | 101 | Draft commit are properly created over public one: |
|
102 | 102 | |
|
103 | 103 | $ hg phase |
|
104 | 104 | 1: public |
|
105 | 105 | $ hglog |
|
106 | 106 | 1 0 B |
|
107 | 107 | 0 0 A |
|
108 | 108 | |
|
109 | 109 | $ mkcommit C |
|
110 | 110 | test-debug-phase: new rev 2: x -> 1 |
|
111 | 111 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> draft |
|
112 | 112 | $ mkcommit D |
|
113 | 113 | test-debug-phase: new rev 3: x -> 1 |
|
114 | 114 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> draft |
|
115 | 115 | |
|
116 | 116 | $ hglog |
|
117 | 117 | 3 1 D |
|
118 | 118 | 2 1 C |
|
119 | 119 | 1 0 B |
|
120 | 120 | 0 0 A |
|
121 | 121 | |
|
122 | 122 | Test creating changeset as secret |
|
123 | 123 | |
|
124 | 124 | $ mkcommit E --config phases.new-commit='secret' |
|
125 | 125 | test-debug-phase: new rev 4: x -> 2 |
|
126 | 126 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: -> secret |
|
127 | 127 | $ hglog |
|
128 | 128 | 4 2 E |
|
129 | 129 | 3 1 D |
|
130 | 130 | 2 1 C |
|
131 | 131 | 1 0 B |
|
132 | 132 | 0 0 A |
|
133 | 133 | |
|
134 | 134 | Test the secret property is inherited |
|
135 | 135 | |
|
136 | 136 | $ mkcommit H |
|
137 | 137 | test-debug-phase: new rev 5: x -> 2 |
|
138 | 138 | test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> secret |
|
139 | 139 | $ hglog |
|
140 | 140 | 5 2 H |
|
141 | 141 | 4 2 E |
|
142 | 142 | 3 1 D |
|
143 | 143 | 2 1 C |
|
144 | 144 | 1 0 B |
|
145 | 145 | 0 0 A |
|
146 | 146 | |
|
147 | 147 | Even on merge |
|
148 | 148 | |
|
149 | 149 | $ hg up -q 1 |
|
150 | 150 | $ mkcommit "B'" |
|
151 | 151 | test-debug-phase: new rev 6: x -> 1 |
|
152 | 152 | created new head |
|
153 | 153 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> draft |
|
154 | 154 | $ hglog |
|
155 | 155 | 6 1 B' |
|
156 | 156 | 5 2 H |
|
157 | 157 | 4 2 E |
|
158 | 158 | 3 1 D |
|
159 | 159 | 2 1 C |
|
160 | 160 | 1 0 B |
|
161 | 161 | 0 0 A |
|
162 | 162 | $ hg merge 4 # E |
|
163 | 163 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
164 | 164 | (branch merge, don't forget to commit) |
|
165 | 165 | $ hg phase |
|
166 | 166 | 6: draft |
|
167 | 167 | 4: secret |
|
168 | 168 | $ hg ci -m "merge B' and E" |
|
169 | 169 | test-debug-phase: new rev 7: x -> 2 |
|
170 | 170 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: -> secret |
|
171 | 171 | |
|
172 | 172 | $ hglog |
|
173 | 173 | 7 2 merge B' and E |
|
174 | 174 | 6 1 B' |
|
175 | 175 | 5 2 H |
|
176 | 176 | 4 2 E |
|
177 | 177 | 3 1 D |
|
178 | 178 | 2 1 C |
|
179 | 179 | 1 0 B |
|
180 | 180 | 0 0 A |
|
181 | 181 | |
|
182 | 182 | Test secret changeset are not pushed |
|
183 | 183 | |
|
184 | 184 | $ hg init ../push-dest |
|
185 | 185 | $ cat > ../push-dest/.hg/hgrc << EOF |
|
186 | 186 | > [phases] |
|
187 | 187 | > publish=False |
|
188 | 188 | > EOF |
|
189 | 189 | $ hg outgoing ../push-dest --template='{rev} {phase} {desc|firstline}\n' |
|
190 | 190 | comparing with ../push-dest |
|
191 | 191 | searching for changes |
|
192 | 192 | 0 public A |
|
193 | 193 | 1 public B |
|
194 | 194 | 2 draft C |
|
195 | 195 | 3 draft D |
|
196 | 196 | 6 draft B' |
|
197 | 197 | $ hg outgoing -r 'branch(default)' ../push-dest --template='{rev} {phase} {desc|firstline}\n' |
|
198 | 198 | comparing with ../push-dest |
|
199 | 199 | searching for changes |
|
200 | 200 | 0 public A |
|
201 | 201 | 1 public B |
|
202 | 202 | 2 draft C |
|
203 | 203 | 3 draft D |
|
204 | 204 | 6 draft B' |
|
205 | 205 | |
|
206 | 206 | $ hg push ../push-dest -f # force because we push multiple heads |
|
207 | 207 | pushing to ../push-dest |
|
208 | 208 | searching for changes |
|
209 | 209 | adding changesets |
|
210 | 210 | adding manifests |
|
211 | 211 | adding file changes |
|
212 | 212 | added 5 changesets with 5 changes to 5 files (+1 heads) |
|
213 | 213 | test-debug-phase: new rev 0: x -> 0 |
|
214 | 214 | test-debug-phase: new rev 1: x -> 0 |
|
215 | 215 | test-debug-phase: new rev 2: x -> 1 |
|
216 | 216 | test-debug-phase: new rev 3: x -> 1 |
|
217 | 217 | test-debug-phase: new rev 4: x -> 1 |
|
218 | 218 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> public |
|
219 | 219 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> public |
|
220 | 220 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> draft |
|
221 | 221 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> draft |
|
222 | 222 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> draft |
|
223 | 223 | $ hglog |
|
224 | 224 | 7 2 merge B' and E |
|
225 | 225 | 6 1 B' |
|
226 | 226 | 5 2 H |
|
227 | 227 | 4 2 E |
|
228 | 228 | 3 1 D |
|
229 | 229 | 2 1 C |
|
230 | 230 | 1 0 B |
|
231 | 231 | 0 0 A |
|
232 | 232 | $ cd ../push-dest |
|
233 | 233 | $ hglog |
|
234 | 234 | 4 1 B' |
|
235 | 235 | 3 1 D |
|
236 | 236 | 2 1 C |
|
237 | 237 | 1 0 B |
|
238 | 238 | 0 0 A |
|
239 | 239 | |
|
240 | 240 | (Issue3303) |
|
241 | 241 | Check that remote secret changeset are ignore when checking creation of remote heads |
|
242 | 242 | |
|
243 | 243 | We add a secret head into the push destination. This secret head shadows a |
|
244 | 244 | visible shared between the initial repo and the push destination. |
|
245 | 245 | |
|
246 | 246 | $ hg up -q 4 # B' |
|
247 | 247 | $ mkcommit Z --config phases.new-commit=secret |
|
248 | 248 | test-debug-phase: new rev 5: x -> 2 |
|
249 | 249 | test-hook-close-phase: 2713879da13d6eea1ff22b442a5a87cb31a7ce6a: -> secret |
|
250 | 250 | $ hg phase . |
|
251 | 251 | 5: secret |
|
252 | 252 | |
|
253 | 253 | We now try to push a new public changeset that descend from the common public |
|
254 | 254 | head shadowed by the remote secret head. |
|
255 | 255 | |
|
256 | 256 | $ cd ../initialrepo |
|
257 | 257 | $ hg up -q 6 #B' |
|
258 | 258 | $ mkcommit I |
|
259 | 259 | test-debug-phase: new rev 8: x -> 1 |
|
260 | 260 | created new head |
|
261 | 261 | test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061: -> draft |
|
262 | 262 | $ hg push ../push-dest |
|
263 | 263 | pushing to ../push-dest |
|
264 | 264 | searching for changes |
|
265 | 265 | adding changesets |
|
266 | 266 | adding manifests |
|
267 | 267 | adding file changes |
|
268 | 268 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
269 | 269 | test-debug-phase: new rev 6: x -> 1 |
|
270 | 270 | test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061: -> draft |
|
271 | 271 | |
|
272 | 272 | :note: The "(+1 heads)" is wrong as we do not had any visible head |
|
273 | 273 | |
|
274 | 274 | check that branch cache with "served" filter are properly computed and stored |
|
275 | 275 | |
|
276 | 276 | $ ls ../push-dest/.hg/cache/branch2* |
|
277 | 277 | ../push-dest/.hg/cache/branch2-base |
|
278 | 278 | ../push-dest/.hg/cache/branch2-served |
|
279 | 279 | $ cat ../push-dest/.hg/cache/branch2-served |
|
280 | 280 | 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722 |
|
281 | 281 | b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default |
|
282 | 282 | 6d6770faffce199f1fddd1cf87f6f026138cf061 o default |
|
283 | 283 | $ hg heads -R ../push-dest --template '{rev}:{node} {phase}\n' #update visible cache too |
|
284 | 284 | 6:6d6770faffce199f1fddd1cf87f6f026138cf061 draft |
|
285 | 285 | 5:2713879da13d6eea1ff22b442a5a87cb31a7ce6a secret |
|
286 | 286 | 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e draft |
|
287 | 287 | $ ls ../push-dest/.hg/cache/branch2* |
|
288 | 288 | ../push-dest/.hg/cache/branch2-base |
|
289 | 289 | ../push-dest/.hg/cache/branch2-served |
|
290 | 290 | ../push-dest/.hg/cache/branch2-visible |
|
291 | 291 | $ cat ../push-dest/.hg/cache/branch2-served |
|
292 | 292 | 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722 |
|
293 | 293 | b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default |
|
294 | 294 | 6d6770faffce199f1fddd1cf87f6f026138cf061 o default |
|
295 | 295 | $ cat ../push-dest/.hg/cache/branch2-visible |
|
296 | 296 | 6d6770faffce199f1fddd1cf87f6f026138cf061 6 |
|
297 | 297 | b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e o default |
|
298 | 298 | 2713879da13d6eea1ff22b442a5a87cb31a7ce6a o default |
|
299 | 299 | 6d6770faffce199f1fddd1cf87f6f026138cf061 o default |
|
300 | 300 | |
|
301 | 301 | |
|
302 | 302 | Restore condition prior extra insertion. |
|
303 | 303 | $ hg -q --config extensions.mq= strip . |
|
304 | 304 | $ hg up -q 7 |
|
305 | 305 | $ cd .. |
|
306 | 306 | |
|
307 | 307 | Test secret changeset are not pull |
|
308 | 308 | |
|
309 | 309 | $ hg init pull-dest |
|
310 | 310 | $ cd pull-dest |
|
311 | 311 | $ hg pull ../initialrepo |
|
312 | 312 | pulling from ../initialrepo |
|
313 | 313 | requesting all changes |
|
314 | 314 | adding changesets |
|
315 | 315 | adding manifests |
|
316 | 316 | adding file changes |
|
317 | 317 | added 5 changesets with 5 changes to 5 files (+1 heads) |
|
318 | 318 | new changesets 4a2df7238c3b:cf9fe039dfd6 |
|
319 | 319 | test-debug-phase: new rev 0: x -> 0 |
|
320 | 320 | test-debug-phase: new rev 1: x -> 0 |
|
321 | 321 | test-debug-phase: new rev 2: x -> 0 |
|
322 | 322 | test-debug-phase: new rev 3: x -> 0 |
|
323 | 323 | test-debug-phase: new rev 4: x -> 0 |
|
324 | 324 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> public |
|
325 | 325 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> public |
|
326 | 326 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> public |
|
327 | 327 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> public |
|
328 | 328 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> public |
|
329 | 329 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
330 | 330 | $ hglog |
|
331 | 331 | 4 0 B' |
|
332 | 332 | 3 0 D |
|
333 | 333 | 2 0 C |
|
334 | 334 | 1 0 B |
|
335 | 335 | 0 0 A |
|
336 | 336 | $ cd .. |
|
337 | 337 | |
|
338 | 338 | But secret can still be bundled explicitly |
|
339 | 339 | |
|
340 | 340 | $ cd initialrepo |
|
341 | 341 | $ hg bundle --base '4^' -r 'children(4)' ../secret-bundle.hg |
|
342 | 342 | 4 changesets found |
|
343 | 343 | $ cd .. |
|
344 | 344 | |
|
345 | 345 | Test secret changeset are not cloned |
|
346 | 346 | (during local clone) |
|
347 | 347 | |
|
348 | 348 | $ hg clone -qU initialrepo clone-dest |
|
349 | 349 | test-debug-phase: new rev 0: x -> 0 |
|
350 | 350 | test-debug-phase: new rev 1: x -> 0 |
|
351 | 351 | test-debug-phase: new rev 2: x -> 0 |
|
352 | 352 | test-debug-phase: new rev 3: x -> 0 |
|
353 | 353 | test-debug-phase: new rev 4: x -> 0 |
|
354 | 354 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> public |
|
355 | 355 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> public |
|
356 | 356 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> public |
|
357 | 357 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> public |
|
358 | 358 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> public |
|
359 | 359 | $ hglog -R clone-dest |
|
360 | 360 | 4 0 B' |
|
361 | 361 | 3 0 D |
|
362 | 362 | 2 0 C |
|
363 | 363 | 1 0 B |
|
364 | 364 | 0 0 A |
|
365 | 365 | |
|
366 | 366 | Test summary |
|
367 | 367 | |
|
368 | 368 | $ hg summary -R clone-dest --verbose |
|
369 | 369 | parent: -1:000000000000 (no revision checked out) |
|
370 | 370 | branch: default |
|
371 | 371 | commit: (clean) |
|
372 | 372 | update: 5 new changesets (update) |
|
373 | 373 | $ hg summary -R initialrepo |
|
374 | 374 | parent: 7:17a481b3bccb tip |
|
375 | 375 | merge B' and E |
|
376 | 376 | branch: default |
|
377 | 377 | commit: (clean) (secret) |
|
378 | 378 | update: 1 new changesets, 2 branch heads (merge) |
|
379 | 379 | phases: 3 draft, 3 secret |
|
380 | 380 | $ hg summary -R initialrepo --quiet |
|
381 | 381 | parent: 7:17a481b3bccb tip |
|
382 | 382 | update: 1 new changesets, 2 branch heads (merge) |
|
383 | 383 | |
|
384 | 384 | Test revset |
|
385 | 385 | |
|
386 | 386 | $ cd initialrepo |
|
387 | 387 | $ hglog -r 'public()' |
|
388 | 388 | 0 0 A |
|
389 | 389 | 1 0 B |
|
390 | 390 | $ hglog -r 'draft()' |
|
391 | 391 | 2 1 C |
|
392 | 392 | 3 1 D |
|
393 | 393 | 6 1 B' |
|
394 | 394 | $ hglog -r 'secret()' |
|
395 | 395 | 4 2 E |
|
396 | 396 | 5 2 H |
|
397 | 397 | 7 2 merge B' and E |
|
398 | 398 | |
|
399 | 399 | test that phase are displayed in log at debug level |
|
400 | 400 | |
|
401 | 401 | $ hg log --debug |
|
402 | 402 | changeset: 7:17a481b3bccb796c0521ae97903d81c52bfee4af |
|
403 | 403 | tag: tip |
|
404 | 404 | phase: secret |
|
405 | 405 | parent: 6:cf9fe039dfd67e829edf6522a45de057b5c86519 |
|
406 | 406 | parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
407 | 407 | manifest: 7:5e724ffacba267b2ab726c91fc8b650710deaaa8 |
|
408 | 408 | user: test |
|
409 | 409 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
410 | 410 | extra: branch=default |
|
411 | 411 | description: |
|
412 | 412 | merge B' and E |
|
413 | 413 | |
|
414 | 414 | |
|
415 | 415 | changeset: 6:cf9fe039dfd67e829edf6522a45de057b5c86519 |
|
416 | 416 | phase: draft |
|
417 | 417 | parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
418 | 418 | parent: -1:0000000000000000000000000000000000000000 |
|
419 | 419 | manifest: 6:ab8bfef2392903058bf4ebb9e7746e8d7026b27a |
|
420 | 420 | user: test |
|
421 | 421 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
422 | 422 | files+: B' |
|
423 | 423 | extra: branch=default |
|
424 | 424 | description: |
|
425 | 425 | B' |
|
426 | 426 | |
|
427 | 427 | |
|
428 | 428 | changeset: 5:a030c6be5127abc010fcbff1851536552e6951a8 |
|
429 | 429 | phase: secret |
|
430 | 430 | parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
431 | 431 | parent: -1:0000000000000000000000000000000000000000 |
|
432 | 432 | manifest: 5:5c710aa854874fe3d5fa7192e77bdb314cc08b5a |
|
433 | 433 | user: test |
|
434 | 434 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
435 | 435 | files+: H |
|
436 | 436 | extra: branch=default |
|
437 | 437 | description: |
|
438 | 438 | H |
|
439 | 439 | |
|
440 | 440 | |
|
441 | 441 | changeset: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
442 | 442 | phase: secret |
|
443 | 443 | parent: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e |
|
444 | 444 | parent: -1:0000000000000000000000000000000000000000 |
|
445 | 445 | manifest: 4:7173fd1c27119750b959e3a0f47ed78abe75d6dc |
|
446 | 446 | user: test |
|
447 | 447 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
448 | 448 | files+: E |
|
449 | 449 | extra: branch=default |
|
450 | 450 | description: |
|
451 | 451 | E |
|
452 | 452 | |
|
453 | 453 | |
|
454 | 454 | changeset: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e |
|
455 | 455 | phase: draft |
|
456 | 456 | parent: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757 |
|
457 | 457 | parent: -1:0000000000000000000000000000000000000000 |
|
458 | 458 | manifest: 3:6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c |
|
459 | 459 | user: test |
|
460 | 460 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
461 | 461 | files+: D |
|
462 | 462 | extra: branch=default |
|
463 | 463 | description: |
|
464 | 464 | D |
|
465 | 465 | |
|
466 | 466 | |
|
467 | 467 | changeset: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757 |
|
468 | 468 | phase: draft |
|
469 | 469 | parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
470 | 470 | parent: -1:0000000000000000000000000000000000000000 |
|
471 | 471 | manifest: 2:66a5a01817fdf5239c273802b5b7618d051c89e4 |
|
472 | 472 | user: test |
|
473 | 473 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
474 | 474 | files+: C |
|
475 | 475 | extra: branch=default |
|
476 | 476 | description: |
|
477 | 477 | C |
|
478 | 478 | |
|
479 | 479 | |
|
480 | 480 | changeset: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
481 | 481 | phase: public |
|
482 | 482 | parent: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256 |
|
483 | 483 | parent: -1:0000000000000000000000000000000000000000 |
|
484 | 484 | manifest: 1:cb5cbbc1bfbf24cc34b9e8c16914e9caa2d2a7fd |
|
485 | 485 | user: test |
|
486 | 486 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
487 | 487 | files+: B |
|
488 | 488 | extra: branch=default |
|
489 | 489 | description: |
|
490 | 490 | B |
|
491 | 491 | |
|
492 | 492 | |
|
493 | 493 | changeset: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256 |
|
494 | 494 | phase: public |
|
495 | 495 | parent: -1:0000000000000000000000000000000000000000 |
|
496 | 496 | parent: -1:0000000000000000000000000000000000000000 |
|
497 | 497 | manifest: 0:007d8c9d88841325f5c6b06371b35b4e8a2b1a83 |
|
498 | 498 | user: test |
|
499 | 499 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
500 | 500 | files+: A |
|
501 | 501 | extra: branch=default |
|
502 | 502 | description: |
|
503 | 503 | A |
|
504 | 504 | |
|
505 | 505 | |
|
506 | 506 | |
|
507 | 507 | |
|
508 | 508 | (Issue3707) |
|
509 | 509 | test invalid phase name |
|
510 | 510 | |
|
511 | 511 | $ mkcommit I --config phases.new-commit='babar' |
|
512 | 512 | transaction abort! |
|
513 | 513 | rollback completed |
|
514 | 514 | config error: phases.new-commit: not a valid phase name ('babar') |
|
515 | 515 | [30] |
|
516 | 516 | Test phase command |
|
517 | 517 | =================== |
|
518 | 518 | |
|
519 | 519 | initial picture |
|
520 | 520 | |
|
521 | 521 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
522 | 522 | @ 7 secret merge B' and E |
|
523 | 523 | |\ |
|
524 | 524 | | o 6 draft B' |
|
525 | 525 | | | |
|
526 | 526 | +---o 5 secret H |
|
527 | 527 | | | |
|
528 | 528 | o | 4 secret E |
|
529 | 529 | | | |
|
530 | 530 | o | 3 draft D |
|
531 | 531 | | | |
|
532 | 532 | o | 2 draft C |
|
533 | 533 | |/ |
|
534 | 534 | o 1 public B |
|
535 | 535 | | |
|
536 | 536 | o 0 public A |
|
537 | 537 | |
|
538 | 538 | |
|
539 | 539 | display changesets phase |
|
540 | 540 | |
|
541 | 541 | (mixing -r and plain rev specification) |
|
542 | 542 | |
|
543 | 543 | $ hg phase 1::4 -r 7 |
|
544 | 544 | 1: public |
|
545 | 545 | 2: draft |
|
546 | 546 | 3: draft |
|
547 | 547 | 4: secret |
|
548 | 548 | 7: secret |
|
549 | 549 | |
|
550 | 550 | |
|
551 | 551 | move changeset forward |
|
552 | 552 | |
|
553 | 553 | (with -r option) |
|
554 | 554 | |
|
555 | 555 | $ hg phase --public -r 2 |
|
556 | 556 | test-debug-phase: move rev 2: 1 -> 0 |
|
557 | 557 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: draft -> public |
|
558 | 558 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
559 | 559 | @ 7 secret merge B' and E |
|
560 | 560 | |\ |
|
561 | 561 | | o 6 draft B' |
|
562 | 562 | | | |
|
563 | 563 | +---o 5 secret H |
|
564 | 564 | | | |
|
565 | 565 | o | 4 secret E |
|
566 | 566 | | | |
|
567 | 567 | o | 3 draft D |
|
568 | 568 | | | |
|
569 | 569 | o | 2 public C |
|
570 | 570 | |/ |
|
571 | 571 | o 1 public B |
|
572 | 572 | | |
|
573 | 573 | o 0 public A |
|
574 | 574 | |
|
575 | 575 | |
|
576 | 576 | move changeset backward |
|
577 | 577 | |
|
578 | 578 | (without -r option) |
|
579 | 579 | |
|
580 | 580 | $ hg phase --draft --force 2 |
|
581 | 581 | test-debug-phase: move rev 2: 0 -> 1 |
|
582 | 582 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: public -> draft |
|
583 | 583 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
584 | 584 | @ 7 secret merge B' and E |
|
585 | 585 | |\ |
|
586 | 586 | | o 6 draft B' |
|
587 | 587 | | | |
|
588 | 588 | +---o 5 secret H |
|
589 | 589 | | | |
|
590 | 590 | o | 4 secret E |
|
591 | 591 | | | |
|
592 | 592 | o | 3 draft D |
|
593 | 593 | | | |
|
594 | 594 | o | 2 draft C |
|
595 | 595 | |/ |
|
596 | 596 | o 1 public B |
|
597 | 597 | | |
|
598 | 598 | o 0 public A |
|
599 | 599 | |
|
600 | 600 | |
|
601 | 601 | move changeset forward and backward |
|
602 | 602 | |
|
603 | 603 | $ hg phase --draft --force 1::4 |
|
604 | 604 | test-debug-phase: move rev 1: 0 -> 1 |
|
605 | 605 | test-debug-phase: move rev 4: 2 -> 1 |
|
606 | 606 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: public -> draft |
|
607 | 607 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: secret -> draft |
|
608 | 608 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
609 | 609 | @ 7 secret merge B' and E |
|
610 | 610 | |\ |
|
611 | 611 | | o 6 draft B' |
|
612 | 612 | | | |
|
613 | 613 | +---o 5 secret H |
|
614 | 614 | | | |
|
615 | 615 | o | 4 draft E |
|
616 | 616 | | | |
|
617 | 617 | o | 3 draft D |
|
618 | 618 | | | |
|
619 | 619 | o | 2 draft C |
|
620 | 620 | |/ |
|
621 | 621 | o 1 draft B |
|
622 | 622 | | |
|
623 | 623 | o 0 public A |
|
624 | 624 | |
|
625 | 625 | test partial failure |
|
626 | 626 | |
|
627 | 627 | $ hg phase --public 7 |
|
628 | 628 | test-debug-phase: move rev 1: 1 -> 0 |
|
629 | 629 | test-debug-phase: move rev 2: 1 -> 0 |
|
630 | 630 | test-debug-phase: move rev 3: 1 -> 0 |
|
631 | 631 | test-debug-phase: move rev 4: 1 -> 0 |
|
632 | 632 | test-debug-phase: move rev 6: 1 -> 0 |
|
633 | 633 | test-debug-phase: move rev 7: 2 -> 0 |
|
634 | 634 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: draft -> public |
|
635 | 635 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: draft -> public |
|
636 | 636 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: draft -> public |
|
637 | 637 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: draft -> public |
|
638 | 638 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: draft -> public |
|
639 | 639 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: secret -> public |
|
640 | 640 | $ hg phase --draft '5 or 7' |
|
641 | 641 | test-debug-phase: move rev 5: 2 -> 1 |
|
642 | 642 | test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: secret -> draft |
|
643 | 643 | cannot move 1 changesets to a higher phase, use --force |
|
644 | 644 | phase changed for 1 changesets |
|
645 | 645 | [1] |
|
646 | 646 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
647 | 647 | @ 7 public merge B' and E |
|
648 | 648 | |\ |
|
649 | 649 | | o 6 public B' |
|
650 | 650 | | | |
|
651 | 651 | +---o 5 draft H |
|
652 | 652 | | | |
|
653 | 653 | o | 4 public E |
|
654 | 654 | | | |
|
655 | 655 | o | 3 public D |
|
656 | 656 | | | |
|
657 | 657 | o | 2 public C |
|
658 | 658 | |/ |
|
659 | 659 | o 1 public B |
|
660 | 660 | | |
|
661 | 661 | o 0 public A |
|
662 | 662 | |
|
663 | 663 | |
|
664 | 664 | test complete failure |
|
665 | 665 | |
|
666 | 666 | $ hg phase --draft 7 |
|
667 | 667 | cannot move 1 changesets to a higher phase, use --force |
|
668 | 668 | no phases changed |
|
669 | 669 | [1] |
|
670 | 670 | |
|
671 | 671 | $ cd .. |
|
672 | 672 | |
|
673 | 673 | test hidden changeset are not cloned as public (issue3935) |
|
674 | 674 | |
|
675 | 675 | $ cd initialrepo |
|
676 | 676 | |
|
677 | 677 | (enabling evolution) |
|
678 | 678 | $ cat >> $HGRCPATH << EOF |
|
679 | 679 | > [experimental] |
|
680 | 680 | > evolution.createmarkers=True |
|
681 | 681 | > EOF |
|
682 | 682 | |
|
683 | 683 | (making a changeset hidden; H in that case) |
|
684 | 684 | $ hg debugobsolete `hg id --debug -r 5` |
|
685 | 685 | 1 new obsolescence markers |
|
686 | 686 | obsoleted 1 changesets |
|
687 | 687 | |
|
688 | 688 | $ cd .. |
|
689 | 689 | $ hg clone initialrepo clonewithobs |
|
690 | 690 | requesting all changes |
|
691 | 691 | adding changesets |
|
692 | 692 | adding manifests |
|
693 | 693 | adding file changes |
|
694 | 694 | added 7 changesets with 6 changes to 6 files |
|
695 | 695 | new changesets 4a2df7238c3b:17a481b3bccb |
|
696 | 696 | test-debug-phase: new rev 0: x -> 0 |
|
697 | 697 | test-debug-phase: new rev 1: x -> 0 |
|
698 | 698 | test-debug-phase: new rev 2: x -> 0 |
|
699 | 699 | test-debug-phase: new rev 3: x -> 0 |
|
700 | 700 | test-debug-phase: new rev 4: x -> 0 |
|
701 | 701 | test-debug-phase: new rev 5: x -> 0 |
|
702 | 702 | test-debug-phase: new rev 6: x -> 0 |
|
703 | 703 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> public |
|
704 | 704 | test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> public |
|
705 | 705 | test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> public |
|
706 | 706 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> public |
|
707 | 707 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: -> public |
|
708 | 708 | test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> public |
|
709 | 709 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: -> public |
|
710 | 710 | updating to branch default |
|
711 | 711 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
712 | 712 | $ cd clonewithobs |
|
713 | 713 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
714 | 714 | @ 6 public merge B' and E |
|
715 | 715 | |\ |
|
716 | 716 | | o 5 public B' |
|
717 | 717 | | | |
|
718 | 718 | o | 4 public E |
|
719 | 719 | | | |
|
720 | 720 | o | 3 public D |
|
721 | 721 | | | |
|
722 | 722 | o | 2 public C |
|
723 | 723 | |/ |
|
724 | 724 | o 1 public B |
|
725 | 725 | | |
|
726 | 726 | o 0 public A |
|
727 | 727 | |
|
728 | 728 | |
|
729 | 729 | test verify repo containing hidden changesets, which should not abort just |
|
730 | 730 | because repo.cancopy() is False |
|
731 | 731 | |
|
732 | 732 | $ cd ../initialrepo |
|
733 | 733 | $ hg verify |
|
734 | 734 | checking changesets |
|
735 | 735 | checking manifests |
|
736 | 736 | crosschecking files in changesets and manifests |
|
737 | 737 | checking files |
|
738 | 738 | checked 8 changesets with 7 changes to 7 files |
|
739 | 739 | |
|
740 | 740 | $ cd .. |
|
741 | 741 | |
|
742 | 742 | check whether HG_PENDING makes pending changes only in related |
|
743 | 743 | repositories visible to an external hook. |
|
744 | 744 | |
|
745 | 745 | (emulate a transaction running concurrently by copied |
|
746 | 746 | .hg/phaseroots.pending in subsequent test) |
|
747 | 747 | |
|
748 | 748 | $ cat > $TESTTMP/savepending.sh <<EOF |
|
749 | 749 | > cp .hg/store/phaseroots.pending .hg/store/phaseroots.pending.saved |
|
750 | 750 | > exit 1 # to avoid changing phase for subsequent tests |
|
751 | 751 | > EOF |
|
752 | 752 | $ cd push-dest |
|
753 | 753 | $ hg phase 6 |
|
754 | 754 | 6: draft |
|
755 | 755 | $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" phase -f -s 6 |
|
756 | 756 | transaction abort! |
|
757 | 757 | rollback completed |
|
758 | 758 | abort: pretxnclose hook exited with status 1 |
|
759 | 759 | [40] |
|
760 | 760 | $ cp .hg/store/phaseroots.pending.saved .hg/store/phaseroots.pending |
|
761 | 761 | |
|
762 | 762 | (check (in)visibility of phaseroot while transaction running in repo) |
|
763 | 763 | |
|
764 | 764 | $ cat > $TESTTMP/checkpending.sh <<EOF |
|
765 | 765 | > echo '@initialrepo' |
|
766 | 766 | > hg -R "$TESTTMP/initialrepo" phase 7 |
|
767 | 767 | > echo '@push-dest' |
|
768 | 768 | > hg -R "$TESTTMP/push-dest" phase 6 |
|
769 | 769 | > exit 1 # to avoid changing phase for subsequent tests |
|
770 | 770 | > EOF |
|
771 | 771 | $ cd ../initialrepo |
|
772 | 772 | $ hg phase 7 |
|
773 | 773 | 7: public |
|
774 | 774 | $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" phase -f -s 7 |
|
775 | 775 | @initialrepo |
|
776 | 776 | 7: secret |
|
777 | 777 | @push-dest |
|
778 | 778 | 6: draft |
|
779 | 779 | transaction abort! |
|
780 | 780 | rollback completed |
|
781 | 781 | abort: pretxnclose hook exited with status 1 |
|
782 | 782 | [40] |
|
783 | 783 | |
|
784 | 784 | Check that pretxnclose-phase hook can control phase movement |
|
785 | 785 | |
|
786 | 786 | $ hg phase --force b3325c91a4d9 --secret |
|
787 | 787 | test-debug-phase: move rev 3: 0 -> 2 |
|
788 | 788 | test-debug-phase: move rev 4: 0 -> 2 |
|
789 | 789 | test-debug-phase: move rev 5: 1 -> 2 |
|
790 | 790 | test-debug-phase: move rev 7: 0 -> 2 |
|
791 | 791 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: public -> secret |
|
792 | 792 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: public -> secret |
|
793 | 793 | test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: draft -> secret |
|
794 | 794 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: public -> secret |
|
795 | 795 | $ hg log -G -T phases |
|
796 | 796 | @ changeset: 7:17a481b3bccb |
|
797 | 797 | |\ tag: tip |
|
798 | 798 | | | phase: secret |
|
799 | 799 | | | parent: 6:cf9fe039dfd6 |
|
800 | 800 | | | parent: 4:a603bfb5a83e |
|
801 | 801 | | | user: test |
|
802 | 802 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
803 | 803 | | | summary: merge B' and E |
|
804 | 804 | | | |
|
805 | 805 | | o changeset: 6:cf9fe039dfd6 |
|
806 | 806 | | | phase: public |
|
807 | 807 | | | parent: 1:27547f69f254 |
|
808 | 808 | | | user: test |
|
809 | 809 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
810 | 810 | | | summary: B' |
|
811 | 811 | | | |
|
812 | 812 | o | changeset: 4:a603bfb5a83e |
|
813 | 813 | | | phase: secret |
|
814 | 814 | | | user: test |
|
815 | 815 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
816 | 816 | | | summary: E |
|
817 | 817 | | | |
|
818 | 818 | o | changeset: 3:b3325c91a4d9 |
|
819 | 819 | | | phase: secret |
|
820 | 820 | | | user: test |
|
821 | 821 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
822 | 822 | | | summary: D |
|
823 | 823 | | | |
|
824 | 824 | o | changeset: 2:f838bfaca5c7 |
|
825 | 825 | |/ phase: public |
|
826 | 826 | | user: test |
|
827 | 827 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
828 | 828 | | summary: C |
|
829 | 829 | | |
|
830 | 830 | o changeset: 1:27547f69f254 |
|
831 | 831 | | phase: public |
|
832 | 832 | | user: test |
|
833 | 833 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
834 | 834 | | summary: B |
|
835 | 835 | | |
|
836 | 836 | o changeset: 0:4a2df7238c3b |
|
837 | 837 | phase: public |
|
838 | 838 | user: test |
|
839 | 839 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
840 | 840 | summary: A |
|
841 | 841 | |
|
842 | 842 | |
|
843 | 843 | Install a hook that prevent b3325c91a4d9 to become public |
|
844 | 844 | |
|
845 | 845 | $ cat >> .hg/hgrc << EOF |
|
846 | 846 | > [hooks] |
|
847 | 847 | > pretxnclose-phase.nopublish_D = sh -c "(echo \$HG_NODE| grep -v b3325c91a4d9>/dev/null) || [ 'public' != \$HG_PHASE ]" |
|
848 | 848 | > EOF |
|
849 | 849 | |
|
850 | 850 | Try various actions. only the draft move should succeed |
|
851 | 851 | |
|
852 | 852 | $ hg phase --public b3325c91a4d9 |
|
853 | 853 | transaction abort! |
|
854 | 854 | rollback completed |
|
855 | 855 | abort: pretxnclose-phase.nopublish_D hook exited with status 1 |
|
856 | 856 | [40] |
|
857 | 857 | $ hg phase --public a603bfb5a83e |
|
858 | 858 | transaction abort! |
|
859 | 859 | rollback completed |
|
860 | 860 | abort: pretxnclose-phase.nopublish_D hook exited with status 1 |
|
861 | 861 | [40] |
|
862 | 862 | $ hg phase --draft 17a481b3bccb |
|
863 | 863 | test-debug-phase: move rev 3: 2 -> 1 |
|
864 | 864 | test-debug-phase: move rev 4: 2 -> 1 |
|
865 | 865 | test-debug-phase: move rev 7: 2 -> 1 |
|
866 | 866 | test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: secret -> draft |
|
867 | 867 | test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: secret -> draft |
|
868 | 868 | test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: secret -> draft |
|
869 | 869 | $ hg phase --public 17a481b3bccb |
|
870 | 870 | transaction abort! |
|
871 | 871 | rollback completed |
|
872 | 872 | abort: pretxnclose-phase.nopublish_D hook exited with status 1 |
|
873 | 873 | [40] |
|
874 | 874 | |
|
875 | 875 | $ cd .. |
|
876 | 876 | |
|
877 | 877 | Test for the "internal" phase |
|
878 | 878 | ============================= |
|
879 | 879 | |
|
880 | 880 | Check we deny its usage on older repository |
|
881 | 881 | |
|
882 | 882 | $ hg init no-internal-phase --config format.internal-phase=no |
|
883 | 883 | $ cd no-internal-phase |
|
884 | 884 | $ hg debugrequires | grep internal-phase |
|
885 | 885 | [1] |
|
886 | 886 | $ echo X > X |
|
887 | 887 | $ hg add X |
|
888 | 888 | $ hg status |
|
889 | 889 | A X |
|
890 | 890 | $ hg --config "phases.new-commit=internal" commit -m "my test internal commit" 2>&1 | grep ProgrammingError |
|
891 | 891 | ** ProgrammingError: this repository does not support the internal phase |
|
892 | 892 | raise error.ProgrammingError(msg) (no-pyoxidizer !) |
|
893 | 893 | *ProgrammingError: this repository does not support the internal phase (glob) |
|
894 | 894 | $ hg --config "phases.new-commit=archived" commit -m "my test archived commit" 2>&1 | grep ProgrammingError |
|
895 | 895 | ** ProgrammingError: this repository does not support the archived phase |
|
896 | 896 | raise error.ProgrammingError(msg) (no-pyoxidizer !) |
|
897 | 897 | *ProgrammingError: this repository does not support the archived phase (glob) |
|
898 | 898 | |
|
899 | 899 | $ cd .. |
|
900 | 900 | |
|
901 | 901 | Check it works fine with repository that supports it. |
|
902 | 902 | |
|
903 | 903 | $ hg init internal-phase --config format.internal-phase=yes |
|
904 | 904 | $ cd internal-phase |
|
905 | 905 | $ hg debugrequires | grep internal-phase |
|
906 | 906 | internal-phase |
|
907 | 907 | $ mkcommit A |
|
908 | 908 | test-debug-phase: new rev 0: x -> 1 |
|
909 | 909 | test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> draft |
|
910 | 910 | |
|
911 | 911 | Commit an internal changesets |
|
912 | 912 | |
|
913 | 913 | $ echo B > B |
|
914 | 914 | $ hg add B |
|
915 | 915 | $ hg status |
|
916 | 916 | A B |
|
917 | 917 | $ hg --config "phases.new-commit=internal" commit -m "my test internal commit" |
|
918 | 918 | test-debug-phase: new rev 1: x -> 96 |
|
919 | 919 | test-hook-close-phase: c01c42dffc7f81223397e99652a0703f83e1c5ea: -> internal |
|
920 | 920 | |
|
921 | 921 | The changeset is a working parent descendant. |
|
922 | 922 | Per the usual visibility rules, it is made visible. |
|
923 | 923 | |
|
924 | 924 | $ hg log -G -l 3 |
|
925 | 925 | @ changeset: 1:c01c42dffc7f |
|
926 | 926 | | tag: tip |
|
927 | 927 | | user: test |
|
928 | 928 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
929 | 929 | | summary: my test internal commit |
|
930 | 930 | | |
|
931 | 931 | o changeset: 0:4a2df7238c3b |
|
932 | 932 | user: test |
|
933 | 933 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
934 | 934 | summary: A |
|
935 | 935 | |
|
936 | 936 | |
|
937 | 937 | Commit is hidden as expected |
|
938 | 938 | |
|
939 | 939 | $ hg up 0 |
|
940 | 940 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
941 | 941 | $ hg log -G |
|
942 | 942 | @ changeset: 0:4a2df7238c3b |
|
943 | 943 | tag: tip |
|
944 | 944 | user: test |
|
945 | 945 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
946 | 946 | summary: A |
|
947 | 947 | |
|
948 | 948 | |
|
949 | 949 | Test for archived phase |
|
950 | 950 | ----------------------- |
|
951 | 951 | |
|
952 | 952 | Commit an archived changesets |
|
953 | 953 | |
|
954 | $ cd .. | |
|
955 | $ hg clone --quiet --pull internal-phase archived-phase \ | |
|
956 | > --config format.exp-archived-phase=yes \ | |
|
957 | > --config extensions.phasereport='!' \ | |
|
958 | > --config hooks.txnclose-phase.test= | |
|
959 | ||
|
960 | $ cd archived-phase | |
|
961 | ||
|
954 | 962 | $ echo B > B |
|
955 | 963 | $ hg add B |
|
956 | 964 | $ hg status |
|
957 | 965 | A B |
|
958 | 966 | $ hg --config "phases.new-commit=archived" commit -m "my test archived commit" |
|
959 |
test-debug-phase: new rev |
|
|
967 | test-debug-phase: new rev 1: x -> 32 | |
|
960 | 968 | test-hook-close-phase: 8df5997c3361518f733d1ae67cd3adb9b0eaf125: -> archived |
|
961 | 969 | |
|
962 | 970 | The changeset is a working parent descendant. |
|
963 | 971 | Per the usual visibility rules, it is made visible. |
|
964 | 972 | |
|
965 | 973 | $ hg log -G -l 3 |
|
966 |
@ changeset: |
|
|
974 | @ changeset: 1:8df5997c3361 | |
|
967 | 975 | | tag: tip |
|
968 | | parent: 0:4a2df7238c3b | |
|
969 | 976 | | user: test |
|
970 | 977 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
971 | 978 | | summary: my test archived commit |
|
972 | 979 | | |
|
973 | 980 | o changeset: 0:4a2df7238c3b |
|
974 | 981 | user: test |
|
975 | 982 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
976 | 983 | summary: A |
|
977 | 984 | |
|
978 | 985 | |
|
979 | 986 | Commit is hidden as expected |
|
980 | 987 | |
|
981 | 988 | $ hg up 0 |
|
982 | 989 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
983 | 990 | $ hg log -G |
|
984 | 991 | @ changeset: 0:4a2df7238c3b |
|
985 | 992 | tag: tip |
|
986 | 993 | user: test |
|
987 | 994 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
988 | 995 | summary: A |
|
989 | 996 | |
|
990 | 997 | $ cd .. |
|
991 | 998 | |
|
992 | 999 | Recommitting an exact match of a public commit shouldn't change it to |
|
993 | 1000 | draft: |
|
994 | 1001 | |
|
995 | 1002 | $ cd initialrepo |
|
996 | 1003 | $ hg phase -r 2 |
|
997 | 1004 | 2: public |
|
998 | 1005 | $ hg up -C 1 |
|
999 | 1006 | 0 files updated, 0 files merged, 4 files removed, 0 files unresolved |
|
1000 | 1007 | $ mkcommit C |
|
1001 | 1008 | warning: commit already existed in the repository! |
|
1002 | 1009 | $ hg phase -r 2 |
|
1003 | 1010 | 2: public |
|
1004 | 1011 | |
|
1005 | 1012 | Same, but for secret: |
|
1006 | 1013 | |
|
1007 | 1014 | $ hg up 7 |
|
1008 | 1015 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1009 | 1016 | $ mkcommit F -s |
|
1010 | 1017 | test-debug-phase: new rev 8: x -> 2 |
|
1011 | 1018 | test-hook-close-phase: de414268ec5ce2330c590b942fbb5ff0b0ca1a0a: -> secret |
|
1012 | 1019 | $ hg up 7 |
|
1013 | 1020 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1014 | 1021 | $ hg phase |
|
1015 | 1022 | 7: draft |
|
1016 | 1023 | $ mkcommit F |
|
1017 | 1024 | test-debug-phase: new rev 8: x -> 2 |
|
1018 | 1025 | warning: commit already existed in the repository! |
|
1019 | 1026 | test-hook-close-phase: de414268ec5ce2330c590b942fbb5ff0b0ca1a0a: -> secret |
|
1020 | 1027 | $ hg phase -r tip |
|
1021 | 1028 | 8: secret |
|
1022 | 1029 | |
|
1023 | 1030 | But what about obsoleted changesets? |
|
1024 | 1031 | |
|
1025 | 1032 | $ hg up 4 |
|
1026 | 1033 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
1027 | 1034 | $ mkcommit H |
|
1028 | 1035 | test-debug-phase: new rev 5: x -> 2 |
|
1029 | 1036 | warning: commit already existed in the repository! |
|
1030 | 1037 | test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> secret |
|
1031 | 1038 | $ hg phase -r 5 |
|
1032 | 1039 | 5: secret |
|
1033 | 1040 | $ hg par |
|
1034 | 1041 | changeset: 5:a030c6be5127 |
|
1035 | 1042 | user: test |
|
1036 | 1043 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1037 | 1044 | obsolete: pruned |
|
1038 | 1045 | summary: H |
|
1039 | 1046 | |
|
1040 | 1047 | $ hg up tip |
|
1041 | 1048 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1042 | 1049 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now