##// END OF EJS Templates
changelogv2: `copies-side-data` now implies `changelogv2`...
marmoute -
r48039:a0738175 default
parent child Browse files
Show More
@@ -1,3781 +1,3780 b''
1 1 # localrepo.py - read/write repository class for mercurial
2 2 #
3 3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import errno
11 11 import functools
12 12 import os
13 13 import random
14 14 import sys
15 15 import time
16 16 import weakref
17 17
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 mixedrepostorecache(_basefilecache):
148 148 """filecache for a mix files in .hg/store and outside"""
149 149
150 150 def __init__(self, *pathsandlocations):
151 151 # scmutil.filecache only uses the path for passing back into our
152 152 # join(), so we can safely pass a list of paths and locations
153 153 super(mixedrepostorecache, self).__init__(*pathsandlocations)
154 154 _cachedfiles.update(pathsandlocations)
155 155
156 156 def join(self, obj, fnameandlocation):
157 157 fname, location = fnameandlocation
158 158 if location == b'plain':
159 159 return obj.vfs.join(fname)
160 160 else:
161 161 if location != b'':
162 162 raise error.ProgrammingError(
163 163 b'unexpected location: %s' % location
164 164 )
165 165 return obj.sjoin(fname)
166 166
167 167
168 168 def isfilecached(repo, name):
169 169 """check if a repo has already cached "name" filecache-ed property
170 170
171 171 This returns (cachedobj-or-None, iscached) tuple.
172 172 """
173 173 cacheentry = repo.unfiltered()._filecache.get(name, None)
174 174 if not cacheentry:
175 175 return None, False
176 176 return cacheentry.obj, True
177 177
178 178
179 179 class unfilteredpropertycache(util.propertycache):
180 180 """propertycache that apply to unfiltered repo only"""
181 181
182 182 def __get__(self, repo, type=None):
183 183 unfi = repo.unfiltered()
184 184 if unfi is repo:
185 185 return super(unfilteredpropertycache, self).__get__(unfi)
186 186 return getattr(unfi, self.name)
187 187
188 188
189 189 class filteredpropertycache(util.propertycache):
190 190 """propertycache that must take filtering in account"""
191 191
192 192 def cachevalue(self, obj, value):
193 193 object.__setattr__(obj, self.name, value)
194 194
195 195
196 196 def hasunfilteredcache(repo, name):
197 197 """check if a repo has an unfilteredpropertycache value for <name>"""
198 198 return name in vars(repo.unfiltered())
199 199
200 200
201 201 def unfilteredmethod(orig):
202 202 """decorate method that always need to be run on unfiltered version"""
203 203
204 204 @functools.wraps(orig)
205 205 def wrapper(repo, *args, **kwargs):
206 206 return orig(repo.unfiltered(), *args, **kwargs)
207 207
208 208 return wrapper
209 209
210 210
211 211 moderncaps = {
212 212 b'lookup',
213 213 b'branchmap',
214 214 b'pushkey',
215 215 b'known',
216 216 b'getbundle',
217 217 b'unbundle',
218 218 }
219 219 legacycaps = moderncaps.union({b'changegroupsubset'})
220 220
221 221
222 222 @interfaceutil.implementer(repository.ipeercommandexecutor)
223 223 class localcommandexecutor(object):
224 224 def __init__(self, peer):
225 225 self._peer = peer
226 226 self._sent = False
227 227 self._closed = False
228 228
229 229 def __enter__(self):
230 230 return self
231 231
232 232 def __exit__(self, exctype, excvalue, exctb):
233 233 self.close()
234 234
235 235 def callcommand(self, command, args):
236 236 if self._sent:
237 237 raise error.ProgrammingError(
238 238 b'callcommand() cannot be used after sendcommands()'
239 239 )
240 240
241 241 if self._closed:
242 242 raise error.ProgrammingError(
243 243 b'callcommand() cannot be used after close()'
244 244 )
245 245
246 246 # We don't need to support anything fancy. Just call the named
247 247 # method on the peer and return a resolved future.
248 248 fn = getattr(self._peer, pycompat.sysstr(command))
249 249
250 250 f = pycompat.futures.Future()
251 251
252 252 try:
253 253 result = fn(**pycompat.strkwargs(args))
254 254 except Exception:
255 255 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
256 256 else:
257 257 f.set_result(result)
258 258
259 259 return f
260 260
261 261 def sendcommands(self):
262 262 self._sent = True
263 263
264 264 def close(self):
265 265 self._closed = True
266 266
267 267
268 268 @interfaceutil.implementer(repository.ipeercommands)
269 269 class localpeer(repository.peer):
270 270 '''peer for a local repo; reflects only the most recent API'''
271 271
272 272 def __init__(self, repo, caps=None):
273 273 super(localpeer, self).__init__()
274 274
275 275 if caps is None:
276 276 caps = moderncaps.copy()
277 277 self._repo = repo.filtered(b'served')
278 278 self.ui = repo.ui
279 279
280 280 if repo._wanted_sidedata:
281 281 formatted = bundle2.format_remote_wanted_sidedata(repo)
282 282 caps.add(b'exp-wanted-sidedata=' + formatted)
283 283
284 284 self._caps = repo._restrictcapabilities(caps)
285 285
286 286 # Begin of _basepeer interface.
287 287
288 288 def url(self):
289 289 return self._repo.url()
290 290
291 291 def local(self):
292 292 return self._repo
293 293
294 294 def peer(self):
295 295 return self
296 296
297 297 def canpush(self):
298 298 return True
299 299
300 300 def close(self):
301 301 self._repo.close()
302 302
303 303 # End of _basepeer interface.
304 304
305 305 # Begin of _basewirecommands interface.
306 306
307 307 def branchmap(self):
308 308 return self._repo.branchmap()
309 309
310 310 def capabilities(self):
311 311 return self._caps
312 312
313 313 def clonebundles(self):
314 314 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
315 315
316 316 def debugwireargs(self, one, two, three=None, four=None, five=None):
317 317 """Used to test argument passing over the wire"""
318 318 return b"%s %s %s %s %s" % (
319 319 one,
320 320 two,
321 321 pycompat.bytestr(three),
322 322 pycompat.bytestr(four),
323 323 pycompat.bytestr(five),
324 324 )
325 325
326 326 def getbundle(
327 327 self,
328 328 source,
329 329 heads=None,
330 330 common=None,
331 331 bundlecaps=None,
332 332 remote_sidedata=None,
333 333 **kwargs
334 334 ):
335 335 chunks = exchange.getbundlechunks(
336 336 self._repo,
337 337 source,
338 338 heads=heads,
339 339 common=common,
340 340 bundlecaps=bundlecaps,
341 341 remote_sidedata=remote_sidedata,
342 342 **kwargs
343 343 )[1]
344 344 cb = util.chunkbuffer(chunks)
345 345
346 346 if exchange.bundle2requested(bundlecaps):
347 347 # When requesting a bundle2, getbundle returns a stream to make the
348 348 # wire level function happier. We need to build a proper object
349 349 # from it in local peer.
350 350 return bundle2.getunbundler(self.ui, cb)
351 351 else:
352 352 return changegroup.getunbundler(b'01', cb, None)
353 353
354 354 def heads(self):
355 355 return self._repo.heads()
356 356
357 357 def known(self, nodes):
358 358 return self._repo.known(nodes)
359 359
360 360 def listkeys(self, namespace):
361 361 return self._repo.listkeys(namespace)
362 362
363 363 def lookup(self, key):
364 364 return self._repo.lookup(key)
365 365
366 366 def pushkey(self, namespace, key, old, new):
367 367 return self._repo.pushkey(namespace, key, old, new)
368 368
369 369 def stream_out(self):
370 370 raise error.Abort(_(b'cannot perform stream clone against local peer'))
371 371
372 372 def unbundle(self, bundle, heads, url):
373 373 """apply a bundle on a repo
374 374
375 375 This function handles the repo locking itself."""
376 376 try:
377 377 try:
378 378 bundle = exchange.readbundle(self.ui, bundle, None)
379 379 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
380 380 if util.safehasattr(ret, b'getchunks'):
381 381 # This is a bundle20 object, turn it into an unbundler.
382 382 # This little dance should be dropped eventually when the
383 383 # API is finally improved.
384 384 stream = util.chunkbuffer(ret.getchunks())
385 385 ret = bundle2.getunbundler(self.ui, stream)
386 386 return ret
387 387 except Exception as exc:
388 388 # If the exception contains output salvaged from a bundle2
389 389 # reply, we need to make sure it is printed before continuing
390 390 # to fail. So we build a bundle2 with such output and consume
391 391 # it directly.
392 392 #
393 393 # This is not very elegant but allows a "simple" solution for
394 394 # issue4594
395 395 output = getattr(exc, '_bundle2salvagedoutput', ())
396 396 if output:
397 397 bundler = bundle2.bundle20(self._repo.ui)
398 398 for out in output:
399 399 bundler.addpart(out)
400 400 stream = util.chunkbuffer(bundler.getchunks())
401 401 b = bundle2.getunbundler(self.ui, stream)
402 402 bundle2.processbundle(self._repo, b)
403 403 raise
404 404 except error.PushRaced as exc:
405 405 raise error.ResponseError(
406 406 _(b'push failed:'), stringutil.forcebytestr(exc)
407 407 )
408 408
409 409 # End of _basewirecommands interface.
410 410
411 411 # Begin of peer interface.
412 412
413 413 def commandexecutor(self):
414 414 return localcommandexecutor(self)
415 415
416 416 # End of peer interface.
417 417
418 418
419 419 @interfaceutil.implementer(repository.ipeerlegacycommands)
420 420 class locallegacypeer(localpeer):
421 421 """peer extension which implements legacy methods too; used for tests with
422 422 restricted capabilities"""
423 423
424 424 def __init__(self, repo):
425 425 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
426 426
427 427 # Begin of baselegacywirecommands interface.
428 428
429 429 def between(self, pairs):
430 430 return self._repo.between(pairs)
431 431
432 432 def branches(self, nodes):
433 433 return self._repo.branches(nodes)
434 434
435 435 def changegroup(self, nodes, source):
436 436 outgoing = discovery.outgoing(
437 437 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
438 438 )
439 439 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
440 440
441 441 def changegroupsubset(self, bases, heads, source):
442 442 outgoing = discovery.outgoing(
443 443 self._repo, missingroots=bases, ancestorsof=heads
444 444 )
445 445 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
446 446
447 447 # End of baselegacywirecommands interface.
448 448
449 449
450 450 # Functions receiving (ui, features) that extensions can register to impact
451 451 # the ability to load repositories with custom requirements. Only
452 452 # functions defined in loaded extensions are called.
453 453 #
454 454 # The function receives a set of requirement strings that the repository
455 455 # is capable of opening. Functions will typically add elements to the
456 456 # set to reflect that the extension knows how to handle that requirements.
457 457 featuresetupfuncs = set()
458 458
459 459
460 460 def _getsharedvfs(hgvfs, requirements):
461 461 """returns the vfs object pointing to root of shared source
462 462 repo for a shared repository
463 463
464 464 hgvfs is vfs pointing at .hg/ of current repo (shared one)
465 465 requirements is a set of requirements of current repo (shared one)
466 466 """
467 467 # The ``shared`` or ``relshared`` requirements indicate the
468 468 # store lives in the path contained in the ``.hg/sharedpath`` file.
469 469 # This is an absolute path for ``shared`` and relative to
470 470 # ``.hg/`` for ``relshared``.
471 471 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
472 472 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
473 473 sharedpath = util.normpath(hgvfs.join(sharedpath))
474 474
475 475 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
476 476
477 477 if not sharedvfs.exists():
478 478 raise error.RepoError(
479 479 _(b'.hg/sharedpath points to nonexistent directory %s')
480 480 % sharedvfs.base
481 481 )
482 482 return sharedvfs
483 483
484 484
485 485 def _readrequires(vfs, allowmissing):
486 486 """reads the require file present at root of this vfs
487 487 and return a set of requirements
488 488
489 489 If allowmissing is True, we suppress ENOENT if raised"""
490 490 # requires file contains a newline-delimited list of
491 491 # features/capabilities the opener (us) must have in order to use
492 492 # the repository. This file was introduced in Mercurial 0.9.2,
493 493 # which means very old repositories may not have one. We assume
494 494 # a missing file translates to no requirements.
495 495 try:
496 496 requirements = set(vfs.read(b'requires').splitlines())
497 497 except IOError as e:
498 498 if not (allowmissing and e.errno == errno.ENOENT):
499 499 raise
500 500 requirements = set()
501 501 return requirements
502 502
503 503
504 504 def makelocalrepository(baseui, path, intents=None):
505 505 """Create a local repository object.
506 506
507 507 Given arguments needed to construct a local repository, this function
508 508 performs various early repository loading functionality (such as
509 509 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
510 510 the repository can be opened, derives a type suitable for representing
511 511 that repository, and returns an instance of it.
512 512
513 513 The returned object conforms to the ``repository.completelocalrepository``
514 514 interface.
515 515
516 516 The repository type is derived by calling a series of factory functions
517 517 for each aspect/interface of the final repository. These are defined by
518 518 ``REPO_INTERFACES``.
519 519
520 520 Each factory function is called to produce a type implementing a specific
521 521 interface. The cumulative list of returned types will be combined into a
522 522 new type and that type will be instantiated to represent the local
523 523 repository.
524 524
525 525 The factory functions each receive various state that may be consulted
526 526 as part of deriving a type.
527 527
528 528 Extensions should wrap these factory functions to customize repository type
529 529 creation. Note that an extension's wrapped function may be called even if
530 530 that extension is not loaded for the repo being constructed. Extensions
531 531 should check if their ``__name__`` appears in the
532 532 ``extensionmodulenames`` set passed to the factory function and no-op if
533 533 not.
534 534 """
535 535 ui = baseui.copy()
536 536 # Prevent copying repo configuration.
537 537 ui.copy = baseui.copy
538 538
539 539 # Working directory VFS rooted at repository root.
540 540 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
541 541
542 542 # Main VFS for .hg/ directory.
543 543 hgpath = wdirvfs.join(b'.hg')
544 544 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
545 545 # Whether this repository is shared one or not
546 546 shared = False
547 547 # If this repository is shared, vfs pointing to shared repo
548 548 sharedvfs = None
549 549
550 550 # The .hg/ path should exist and should be a directory. All other
551 551 # cases are errors.
552 552 if not hgvfs.isdir():
553 553 try:
554 554 hgvfs.stat()
555 555 except OSError as e:
556 556 if e.errno != errno.ENOENT:
557 557 raise
558 558 except ValueError as e:
559 559 # Can be raised on Python 3.8 when path is invalid.
560 560 raise error.Abort(
561 561 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
562 562 )
563 563
564 564 raise error.RepoError(_(b'repository %s not found') % path)
565 565
566 566 requirements = _readrequires(hgvfs, True)
567 567 shared = (
568 568 requirementsmod.SHARED_REQUIREMENT in requirements
569 569 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
570 570 )
571 571 storevfs = None
572 572 if shared:
573 573 # This is a shared repo
574 574 sharedvfs = _getsharedvfs(hgvfs, requirements)
575 575 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
576 576 else:
577 577 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
578 578
579 579 # if .hg/requires contains the sharesafe requirement, it means
580 580 # there exists a `.hg/store/requires` too and we should read it
581 581 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
582 582 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
583 583 # is not present, refer checkrequirementscompat() for that
584 584 #
585 585 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
586 586 # repository was shared the old way. We check the share source .hg/requires
587 587 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
588 588 # to be reshared
589 589 hint = _(b"see `hg help config.format.use-share-safe` for more information")
590 590 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
591 591
592 592 if (
593 593 shared
594 594 and requirementsmod.SHARESAFE_REQUIREMENT
595 595 not in _readrequires(sharedvfs, True)
596 596 ):
597 597 mismatch_warn = ui.configbool(
598 598 b'share', b'safe-mismatch.source-not-safe.warn'
599 599 )
600 600 mismatch_config = ui.config(
601 601 b'share', b'safe-mismatch.source-not-safe'
602 602 )
603 603 if mismatch_config in (
604 604 b'downgrade-allow',
605 605 b'allow',
606 606 b'downgrade-abort',
607 607 ):
608 608 # prevent cyclic import localrepo -> upgrade -> localrepo
609 609 from . import upgrade
610 610
611 611 upgrade.downgrade_share_to_non_safe(
612 612 ui,
613 613 hgvfs,
614 614 sharedvfs,
615 615 requirements,
616 616 mismatch_config,
617 617 mismatch_warn,
618 618 )
619 619 elif mismatch_config == b'abort':
620 620 raise error.Abort(
621 621 _(b"share source does not support share-safe requirement"),
622 622 hint=hint,
623 623 )
624 624 else:
625 625 raise error.Abort(
626 626 _(
627 627 b"share-safe mismatch with source.\nUnrecognized"
628 628 b" value '%s' of `share.safe-mismatch.source-not-safe`"
629 629 b" set."
630 630 )
631 631 % mismatch_config,
632 632 hint=hint,
633 633 )
634 634 else:
635 635 requirements |= _readrequires(storevfs, False)
636 636 elif shared:
637 637 sourcerequires = _readrequires(sharedvfs, False)
638 638 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
639 639 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
640 640 mismatch_warn = ui.configbool(
641 641 b'share', b'safe-mismatch.source-safe.warn'
642 642 )
643 643 if mismatch_config in (
644 644 b'upgrade-allow',
645 645 b'allow',
646 646 b'upgrade-abort',
647 647 ):
648 648 # prevent cyclic import localrepo -> upgrade -> localrepo
649 649 from . import upgrade
650 650
651 651 upgrade.upgrade_share_to_safe(
652 652 ui,
653 653 hgvfs,
654 654 storevfs,
655 655 requirements,
656 656 mismatch_config,
657 657 mismatch_warn,
658 658 )
659 659 elif mismatch_config == b'abort':
660 660 raise error.Abort(
661 661 _(
662 662 b'version mismatch: source uses share-safe'
663 663 b' functionality while the current share does not'
664 664 ),
665 665 hint=hint,
666 666 )
667 667 else:
668 668 raise error.Abort(
669 669 _(
670 670 b"share-safe mismatch with source.\nUnrecognized"
671 671 b" value '%s' of `share.safe-mismatch.source-safe` set."
672 672 )
673 673 % mismatch_config,
674 674 hint=hint,
675 675 )
676 676
677 677 # The .hg/hgrc file may load extensions or contain config options
678 678 # that influence repository construction. Attempt to load it and
679 679 # process any new extensions that it may have pulled in.
680 680 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
681 681 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
682 682 extensions.loadall(ui)
683 683 extensions.populateui(ui)
684 684
685 685 # Set of module names of extensions loaded for this repository.
686 686 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
687 687
688 688 supportedrequirements = gathersupportedrequirements(ui)
689 689
690 690 # We first validate the requirements are known.
691 691 ensurerequirementsrecognized(requirements, supportedrequirements)
692 692
693 693 # Then we validate that the known set is reasonable to use together.
694 694 ensurerequirementscompatible(ui, requirements)
695 695
696 696 # TODO there are unhandled edge cases related to opening repositories with
697 697 # shared storage. If storage is shared, we should also test for requirements
698 698 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
699 699 # that repo, as that repo may load extensions needed to open it. This is a
700 700 # bit complicated because we don't want the other hgrc to overwrite settings
701 701 # in this hgrc.
702 702 #
703 703 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
704 704 # file when sharing repos. But if a requirement is added after the share is
705 705 # performed, thereby introducing a new requirement for the opener, we may
706 706 # will not see that and could encounter a run-time error interacting with
707 707 # that shared store since it has an unknown-to-us requirement.
708 708
709 709 # At this point, we know we should be capable of opening the repository.
710 710 # Now get on with doing that.
711 711
712 712 features = set()
713 713
714 714 # The "store" part of the repository holds versioned data. How it is
715 715 # accessed is determined by various requirements. If `shared` or
716 716 # `relshared` requirements are present, this indicates current repository
717 717 # is a share and store exists in path mentioned in `.hg/sharedpath`
718 718 if shared:
719 719 storebasepath = sharedvfs.base
720 720 cachepath = sharedvfs.join(b'cache')
721 721 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
722 722 else:
723 723 storebasepath = hgvfs.base
724 724 cachepath = hgvfs.join(b'cache')
725 725 wcachepath = hgvfs.join(b'wcache')
726 726
727 727 # The store has changed over time and the exact layout is dictated by
728 728 # requirements. The store interface abstracts differences across all
729 729 # of them.
730 730 store = makestore(
731 731 requirements,
732 732 storebasepath,
733 733 lambda base: vfsmod.vfs(base, cacheaudited=True),
734 734 )
735 735 hgvfs.createmode = store.createmode
736 736
737 737 storevfs = store.vfs
738 738 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
739 739
740 740 if (
741 741 requirementsmod.REVLOGV2_REQUIREMENT in requirements
742 742 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
743 743 ):
744 744 features.add(repository.REPO_FEATURE_SIDE_DATA)
745 745 # the revlogv2 docket introduced race condition that we need to fix
746 746 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
747 747
748 748 # The cache vfs is used to manage cache files.
749 749 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
750 750 cachevfs.createmode = store.createmode
751 751 # The cache vfs is used to manage cache files related to the working copy
752 752 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
753 753 wcachevfs.createmode = store.createmode
754 754
755 755 # Now resolve the type for the repository object. We do this by repeatedly
756 756 # calling a factory function to produces types for specific aspects of the
757 757 # repo's operation. The aggregate returned types are used as base classes
758 758 # for a dynamically-derived type, which will represent our new repository.
759 759
760 760 bases = []
761 761 extrastate = {}
762 762
763 763 for iface, fn in REPO_INTERFACES:
764 764 # We pass all potentially useful state to give extensions tons of
765 765 # flexibility.
766 766 typ = fn()(
767 767 ui=ui,
768 768 intents=intents,
769 769 requirements=requirements,
770 770 features=features,
771 771 wdirvfs=wdirvfs,
772 772 hgvfs=hgvfs,
773 773 store=store,
774 774 storevfs=storevfs,
775 775 storeoptions=storevfs.options,
776 776 cachevfs=cachevfs,
777 777 wcachevfs=wcachevfs,
778 778 extensionmodulenames=extensionmodulenames,
779 779 extrastate=extrastate,
780 780 baseclasses=bases,
781 781 )
782 782
783 783 if not isinstance(typ, type):
784 784 raise error.ProgrammingError(
785 785 b'unable to construct type for %s' % iface
786 786 )
787 787
788 788 bases.append(typ)
789 789
790 790 # type() allows you to use characters in type names that wouldn't be
791 791 # recognized as Python symbols in source code. We abuse that to add
792 792 # rich information about our constructed repo.
793 793 name = pycompat.sysstr(
794 794 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
795 795 )
796 796
797 797 cls = type(name, tuple(bases), {})
798 798
799 799 return cls(
800 800 baseui=baseui,
801 801 ui=ui,
802 802 origroot=path,
803 803 wdirvfs=wdirvfs,
804 804 hgvfs=hgvfs,
805 805 requirements=requirements,
806 806 supportedrequirements=supportedrequirements,
807 807 sharedpath=storebasepath,
808 808 store=store,
809 809 cachevfs=cachevfs,
810 810 wcachevfs=wcachevfs,
811 811 features=features,
812 812 intents=intents,
813 813 )
814 814
815 815
816 816 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
817 817 """Load hgrc files/content into a ui instance.
818 818
819 819 This is called during repository opening to load any additional
820 820 config files or settings relevant to the current repository.
821 821
822 822 Returns a bool indicating whether any additional configs were loaded.
823 823
824 824 Extensions should monkeypatch this function to modify how per-repo
825 825 configs are loaded. For example, an extension may wish to pull in
826 826 configs from alternate files or sources.
827 827
828 828 sharedvfs is vfs object pointing to source repo if the current one is a
829 829 shared one
830 830 """
831 831 if not rcutil.use_repo_hgrc():
832 832 return False
833 833
834 834 ret = False
835 835 # first load config from shared source if we has to
836 836 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
837 837 try:
838 838 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
839 839 ret = True
840 840 except IOError:
841 841 pass
842 842
843 843 try:
844 844 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
845 845 ret = True
846 846 except IOError:
847 847 pass
848 848
849 849 try:
850 850 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
851 851 ret = True
852 852 except IOError:
853 853 pass
854 854
855 855 return ret
856 856
857 857
858 858 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
859 859 """Perform additional actions after .hg/hgrc is loaded.
860 860
861 861 This function is called during repository loading immediately after
862 862 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
863 863
864 864 The function can be used to validate configs, automatically add
865 865 options (including extensions) based on requirements, etc.
866 866 """
867 867
868 868 # Map of requirements to list of extensions to load automatically when
869 869 # requirement is present.
870 870 autoextensions = {
871 871 b'git': [b'git'],
872 872 b'largefiles': [b'largefiles'],
873 873 b'lfs': [b'lfs'],
874 874 }
875 875
876 876 for requirement, names in sorted(autoextensions.items()):
877 877 if requirement not in requirements:
878 878 continue
879 879
880 880 for name in names:
881 881 if not ui.hasconfig(b'extensions', name):
882 882 ui.setconfig(b'extensions', name, b'', source=b'autoload')
883 883
884 884
885 885 def gathersupportedrequirements(ui):
886 886 """Determine the complete set of recognized requirements."""
887 887 # Start with all requirements supported by this file.
888 888 supported = set(localrepository._basesupported)
889 889
890 890 # Execute ``featuresetupfuncs`` entries if they belong to an extension
891 891 # relevant to this ui instance.
892 892 modules = {m.__name__ for n, m in extensions.extensions(ui)}
893 893
894 894 for fn in featuresetupfuncs:
895 895 if fn.__module__ in modules:
896 896 fn(ui, supported)
897 897
898 898 # Add derived requirements from registered compression engines.
899 899 for name in util.compengines:
900 900 engine = util.compengines[name]
901 901 if engine.available() and engine.revlogheader():
902 902 supported.add(b'exp-compression-%s' % name)
903 903 if engine.name() == b'zstd':
904 904 supported.add(b'revlog-compression-zstd')
905 905
906 906 return supported
907 907
908 908
909 909 def ensurerequirementsrecognized(requirements, supported):
910 910 """Validate that a set of local requirements is recognized.
911 911
912 912 Receives a set of requirements. Raises an ``error.RepoError`` if there
913 913 exists any requirement in that set that currently loaded code doesn't
914 914 recognize.
915 915
916 916 Returns a set of supported requirements.
917 917 """
918 918 missing = set()
919 919
920 920 for requirement in requirements:
921 921 if requirement in supported:
922 922 continue
923 923
924 924 if not requirement or not requirement[0:1].isalnum():
925 925 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
926 926
927 927 missing.add(requirement)
928 928
929 929 if missing:
930 930 raise error.RequirementError(
931 931 _(b'repository requires features unknown to this Mercurial: %s')
932 932 % b' '.join(sorted(missing)),
933 933 hint=_(
934 934 b'see https://mercurial-scm.org/wiki/MissingRequirement '
935 935 b'for more information'
936 936 ),
937 937 )
938 938
939 939
940 940 def ensurerequirementscompatible(ui, requirements):
941 941 """Validates that a set of recognized requirements is mutually compatible.
942 942
943 943 Some requirements may not be compatible with others or require
944 944 config options that aren't enabled. This function is called during
945 945 repository opening to ensure that the set of requirements needed
946 946 to open a repository is sane and compatible with config options.
947 947
948 948 Extensions can monkeypatch this function to perform additional
949 949 checking.
950 950
951 951 ``error.RepoError`` should be raised on failure.
952 952 """
953 953 if (
954 954 requirementsmod.SPARSE_REQUIREMENT in requirements
955 955 and not sparse.enabled
956 956 ):
957 957 raise error.RepoError(
958 958 _(
959 959 b'repository is using sparse feature but '
960 960 b'sparse is not enabled; enable the '
961 961 b'"sparse" extensions to access'
962 962 )
963 963 )
964 964
965 965
966 966 def makestore(requirements, path, vfstype):
967 967 """Construct a storage object for a repository."""
968 968 if requirementsmod.STORE_REQUIREMENT in requirements:
969 969 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
970 970 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
971 971 return storemod.fncachestore(path, vfstype, dotencode)
972 972
973 973 return storemod.encodedstore(path, vfstype)
974 974
975 975 return storemod.basicstore(path, vfstype)
976 976
977 977
978 978 def resolvestorevfsoptions(ui, requirements, features):
979 979 """Resolve the options to pass to the store vfs opener.
980 980
981 981 The returned dict is used to influence behavior of the storage layer.
982 982 """
983 983 options = {}
984 984
985 985 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
986 986 options[b'treemanifest'] = True
987 987
988 988 # experimental config: format.manifestcachesize
989 989 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
990 990 if manifestcachesize is not None:
991 991 options[b'manifestcachesize'] = manifestcachesize
992 992
993 993 # In the absence of another requirement superseding a revlog-related
994 994 # requirement, we have to assume the repo is using revlog version 0.
995 995 # This revlog format is super old and we don't bother trying to parse
996 996 # opener options for it because those options wouldn't do anything
997 997 # meaningful on such old repos.
998 998 if (
999 999 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1000 1000 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1001 1001 ):
1002 1002 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1003 1003 else: # explicitly mark repo as using revlogv0
1004 1004 options[b'revlogv0'] = True
1005 1005
1006 1006 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1007 1007 options[b'copies-storage'] = b'changeset-sidedata'
1008 1008 else:
1009 1009 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1010 1010 copiesextramode = (b'changeset-only', b'compatibility')
1011 1011 if writecopiesto in copiesextramode:
1012 1012 options[b'copies-storage'] = b'extra'
1013 1013
1014 1014 return options
1015 1015
1016 1016
1017 1017 def resolverevlogstorevfsoptions(ui, requirements, features):
1018 1018 """Resolve opener options specific to revlogs."""
1019 1019
1020 1020 options = {}
1021 1021 options[b'flagprocessors'] = {}
1022 1022
1023 1023 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1024 1024 options[b'revlogv1'] = True
1025 1025 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1026 1026 options[b'revlogv2'] = True
1027 1027 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1028 1028 options[b'changelogv2'] = True
1029 1029
1030 1030 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1031 1031 options[b'generaldelta'] = True
1032 1032
1033 1033 # experimental config: format.chunkcachesize
1034 1034 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1035 1035 if chunkcachesize is not None:
1036 1036 options[b'chunkcachesize'] = chunkcachesize
1037 1037
1038 1038 deltabothparents = ui.configbool(
1039 1039 b'storage', b'revlog.optimize-delta-parent-choice'
1040 1040 )
1041 1041 options[b'deltabothparents'] = deltabothparents
1042 1042
1043 1043 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1044 1044 lazydeltabase = False
1045 1045 if lazydelta:
1046 1046 lazydeltabase = ui.configbool(
1047 1047 b'storage', b'revlog.reuse-external-delta-parent'
1048 1048 )
1049 1049 if lazydeltabase is None:
1050 1050 lazydeltabase = not scmutil.gddeltaconfig(ui)
1051 1051 options[b'lazydelta'] = lazydelta
1052 1052 options[b'lazydeltabase'] = lazydeltabase
1053 1053
1054 1054 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1055 1055 if 0 <= chainspan:
1056 1056 options[b'maxdeltachainspan'] = chainspan
1057 1057
1058 1058 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1059 1059 if mmapindexthreshold is not None:
1060 1060 options[b'mmapindexthreshold'] = mmapindexthreshold
1061 1061
1062 1062 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1063 1063 srdensitythres = float(
1064 1064 ui.config(b'experimental', b'sparse-read.density-threshold')
1065 1065 )
1066 1066 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1067 1067 options[b'with-sparse-read'] = withsparseread
1068 1068 options[b'sparse-read-density-threshold'] = srdensitythres
1069 1069 options[b'sparse-read-min-gap-size'] = srmingapsize
1070 1070
1071 1071 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1072 1072 options[b'sparse-revlog'] = sparserevlog
1073 1073 if sparserevlog:
1074 1074 options[b'generaldelta'] = True
1075 1075
1076 1076 maxchainlen = None
1077 1077 if sparserevlog:
1078 1078 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1079 1079 # experimental config: format.maxchainlen
1080 1080 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1081 1081 if maxchainlen is not None:
1082 1082 options[b'maxchainlen'] = maxchainlen
1083 1083
1084 1084 for r in requirements:
1085 1085 # we allow multiple compression engine requirement to co-exist because
1086 1086 # strickly speaking, revlog seems to support mixed compression style.
1087 1087 #
1088 1088 # The compression used for new entries will be "the last one"
1089 1089 prefix = r.startswith
1090 1090 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1091 1091 options[b'compengine'] = r.split(b'-', 2)[2]
1092 1092
1093 1093 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1094 1094 if options[b'zlib.level'] is not None:
1095 1095 if not (0 <= options[b'zlib.level'] <= 9):
1096 1096 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1097 1097 raise error.Abort(msg % options[b'zlib.level'])
1098 1098 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1099 1099 if options[b'zstd.level'] is not None:
1100 1100 if not (0 <= options[b'zstd.level'] <= 22):
1101 1101 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1102 1102 raise error.Abort(msg % options[b'zstd.level'])
1103 1103
1104 1104 if requirementsmod.NARROW_REQUIREMENT in requirements:
1105 1105 options[b'enableellipsis'] = True
1106 1106
1107 1107 if ui.configbool(b'experimental', b'rust.index'):
1108 1108 options[b'rust.index'] = True
1109 1109 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1110 1110 slow_path = ui.config(
1111 1111 b'storage', b'revlog.persistent-nodemap.slow-path'
1112 1112 )
1113 1113 if slow_path not in (b'allow', b'warn', b'abort'):
1114 1114 default = ui.config_default(
1115 1115 b'storage', b'revlog.persistent-nodemap.slow-path'
1116 1116 )
1117 1117 msg = _(
1118 1118 b'unknown value for config '
1119 1119 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1120 1120 )
1121 1121 ui.warn(msg % slow_path)
1122 1122 if not ui.quiet:
1123 1123 ui.warn(_(b'falling back to default value: %s\n') % default)
1124 1124 slow_path = default
1125 1125
1126 1126 msg = _(
1127 1127 b"accessing `persistent-nodemap` repository without associated "
1128 1128 b"fast implementation."
1129 1129 )
1130 1130 hint = _(
1131 1131 b"check `hg help config.format.use-persistent-nodemap` "
1132 1132 b"for details"
1133 1133 )
1134 1134 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1135 1135 if slow_path == b'warn':
1136 1136 msg = b"warning: " + msg + b'\n'
1137 1137 ui.warn(msg)
1138 1138 if not ui.quiet:
1139 1139 hint = b'(' + hint + b')\n'
1140 1140 ui.warn(hint)
1141 1141 if slow_path == b'abort':
1142 1142 raise error.Abort(msg, hint=hint)
1143 1143 options[b'persistent-nodemap'] = True
1144 1144 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1145 1145 options[b'persistent-nodemap.mmap'] = True
1146 1146 if ui.configbool(b'devel', b'persistent-nodemap'):
1147 1147 options[b'devel-force-nodemap'] = True
1148 1148
1149 1149 return options
1150 1150
1151 1151
1152 1152 def makemain(**kwargs):
1153 1153 """Produce a type conforming to ``ilocalrepositorymain``."""
1154 1154 return localrepository
1155 1155
1156 1156
1157 1157 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1158 1158 class revlogfilestorage(object):
1159 1159 """File storage when using revlogs."""
1160 1160
1161 1161 def file(self, path):
1162 1162 if path.startswith(b'/'):
1163 1163 path = path[1:]
1164 1164
1165 1165 return filelog.filelog(self.svfs, path)
1166 1166
1167 1167
1168 1168 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1169 1169 class revlognarrowfilestorage(object):
1170 1170 """File storage when using revlogs and narrow files."""
1171 1171
1172 1172 def file(self, path):
1173 1173 if path.startswith(b'/'):
1174 1174 path = path[1:]
1175 1175
1176 1176 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1177 1177
1178 1178
1179 1179 def makefilestorage(requirements, features, **kwargs):
1180 1180 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1181 1181 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1182 1182 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1183 1183
1184 1184 if requirementsmod.NARROW_REQUIREMENT in requirements:
1185 1185 return revlognarrowfilestorage
1186 1186 else:
1187 1187 return revlogfilestorage
1188 1188
1189 1189
1190 1190 # List of repository interfaces and factory functions for them. Each
1191 1191 # will be called in order during ``makelocalrepository()`` to iteratively
1192 1192 # derive the final type for a local repository instance. We capture the
1193 1193 # function as a lambda so we don't hold a reference and the module-level
1194 1194 # functions can be wrapped.
1195 1195 REPO_INTERFACES = [
1196 1196 (repository.ilocalrepositorymain, lambda: makemain),
1197 1197 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1198 1198 ]
1199 1199
1200 1200
1201 1201 @interfaceutil.implementer(repository.ilocalrepositorymain)
1202 1202 class localrepository(object):
1203 1203 """Main class for representing local repositories.
1204 1204
1205 1205 All local repositories are instances of this class.
1206 1206
1207 1207 Constructed on its own, instances of this class are not usable as
1208 1208 repository objects. To obtain a usable repository object, call
1209 1209 ``hg.repository()``, ``localrepo.instance()``, or
1210 1210 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1211 1211 ``instance()`` adds support for creating new repositories.
1212 1212 ``hg.repository()`` adds more extension integration, including calling
1213 1213 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1214 1214 used.
1215 1215 """
1216 1216
1217 1217 # obsolete experimental requirements:
1218 1218 # - manifestv2: An experimental new manifest format that allowed
1219 1219 # for stem compression of long paths. Experiment ended up not
1220 1220 # being successful (repository sizes went up due to worse delta
1221 1221 # chains), and the code was deleted in 4.6.
1222 1222 supportedformats = {
1223 1223 requirementsmod.REVLOGV1_REQUIREMENT,
1224 1224 requirementsmod.GENERALDELTA_REQUIREMENT,
1225 1225 requirementsmod.TREEMANIFEST_REQUIREMENT,
1226 1226 requirementsmod.COPIESSDC_REQUIREMENT,
1227 1227 requirementsmod.REVLOGV2_REQUIREMENT,
1228 1228 requirementsmod.CHANGELOGV2_REQUIREMENT,
1229 1229 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1230 1230 requirementsmod.NODEMAP_REQUIREMENT,
1231 1231 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1232 1232 requirementsmod.SHARESAFE_REQUIREMENT,
1233 1233 }
1234 1234 _basesupported = supportedformats | {
1235 1235 requirementsmod.STORE_REQUIREMENT,
1236 1236 requirementsmod.FNCACHE_REQUIREMENT,
1237 1237 requirementsmod.SHARED_REQUIREMENT,
1238 1238 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1239 1239 requirementsmod.DOTENCODE_REQUIREMENT,
1240 1240 requirementsmod.SPARSE_REQUIREMENT,
1241 1241 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1242 1242 }
1243 1243
1244 1244 # list of prefix for file which can be written without 'wlock'
1245 1245 # Extensions should extend this list when needed
1246 1246 _wlockfreeprefix = {
1247 1247 # We migh consider requiring 'wlock' for the next
1248 1248 # two, but pretty much all the existing code assume
1249 1249 # wlock is not needed so we keep them excluded for
1250 1250 # now.
1251 1251 b'hgrc',
1252 1252 b'requires',
1253 1253 # XXX cache is a complicatged business someone
1254 1254 # should investigate this in depth at some point
1255 1255 b'cache/',
1256 1256 # XXX shouldn't be dirstate covered by the wlock?
1257 1257 b'dirstate',
1258 1258 # XXX bisect was still a bit too messy at the time
1259 1259 # this changeset was introduced. Someone should fix
1260 1260 # the remainig bit and drop this line
1261 1261 b'bisect.state',
1262 1262 }
1263 1263
1264 1264 def __init__(
1265 1265 self,
1266 1266 baseui,
1267 1267 ui,
1268 1268 origroot,
1269 1269 wdirvfs,
1270 1270 hgvfs,
1271 1271 requirements,
1272 1272 supportedrequirements,
1273 1273 sharedpath,
1274 1274 store,
1275 1275 cachevfs,
1276 1276 wcachevfs,
1277 1277 features,
1278 1278 intents=None,
1279 1279 ):
1280 1280 """Create a new local repository instance.
1281 1281
1282 1282 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1283 1283 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1284 1284 object.
1285 1285
1286 1286 Arguments:
1287 1287
1288 1288 baseui
1289 1289 ``ui.ui`` instance that ``ui`` argument was based off of.
1290 1290
1291 1291 ui
1292 1292 ``ui.ui`` instance for use by the repository.
1293 1293
1294 1294 origroot
1295 1295 ``bytes`` path to working directory root of this repository.
1296 1296
1297 1297 wdirvfs
1298 1298 ``vfs.vfs`` rooted at the working directory.
1299 1299
1300 1300 hgvfs
1301 1301 ``vfs.vfs`` rooted at .hg/
1302 1302
1303 1303 requirements
1304 1304 ``set`` of bytestrings representing repository opening requirements.
1305 1305
1306 1306 supportedrequirements
1307 1307 ``set`` of bytestrings representing repository requirements that we
1308 1308 know how to open. May be a supetset of ``requirements``.
1309 1309
1310 1310 sharedpath
1311 1311 ``bytes`` Defining path to storage base directory. Points to a
1312 1312 ``.hg/`` directory somewhere.
1313 1313
1314 1314 store
1315 1315 ``store.basicstore`` (or derived) instance providing access to
1316 1316 versioned storage.
1317 1317
1318 1318 cachevfs
1319 1319 ``vfs.vfs`` used for cache files.
1320 1320
1321 1321 wcachevfs
1322 1322 ``vfs.vfs`` used for cache files related to the working copy.
1323 1323
1324 1324 features
1325 1325 ``set`` of bytestrings defining features/capabilities of this
1326 1326 instance.
1327 1327
1328 1328 intents
1329 1329 ``set`` of system strings indicating what this repo will be used
1330 1330 for.
1331 1331 """
1332 1332 self.baseui = baseui
1333 1333 self.ui = ui
1334 1334 self.origroot = origroot
1335 1335 # vfs rooted at working directory.
1336 1336 self.wvfs = wdirvfs
1337 1337 self.root = wdirvfs.base
1338 1338 # vfs rooted at .hg/. Used to access most non-store paths.
1339 1339 self.vfs = hgvfs
1340 1340 self.path = hgvfs.base
1341 1341 self.requirements = requirements
1342 1342 self.nodeconstants = sha1nodeconstants
1343 1343 self.nullid = self.nodeconstants.nullid
1344 1344 self.supported = supportedrequirements
1345 1345 self.sharedpath = sharedpath
1346 1346 self.store = store
1347 1347 self.cachevfs = cachevfs
1348 1348 self.wcachevfs = wcachevfs
1349 1349 self.features = features
1350 1350
1351 1351 self.filtername = None
1352 1352
1353 1353 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1354 1354 b'devel', b'check-locks'
1355 1355 ):
1356 1356 self.vfs.audit = self._getvfsward(self.vfs.audit)
1357 1357 # A list of callback to shape the phase if no data were found.
1358 1358 # Callback are in the form: func(repo, roots) --> processed root.
1359 1359 # This list it to be filled by extension during repo setup
1360 1360 self._phasedefaults = []
1361 1361
1362 1362 color.setup(self.ui)
1363 1363
1364 1364 self.spath = self.store.path
1365 1365 self.svfs = self.store.vfs
1366 1366 self.sjoin = self.store.join
1367 1367 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1368 1368 b'devel', b'check-locks'
1369 1369 ):
1370 1370 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1371 1371 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1372 1372 else: # standard vfs
1373 1373 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1374 1374
1375 1375 self._dirstatevalidatewarned = False
1376 1376
1377 1377 self._branchcaches = branchmap.BranchMapCache()
1378 1378 self._revbranchcache = None
1379 1379 self._filterpats = {}
1380 1380 self._datafilters = {}
1381 1381 self._transref = self._lockref = self._wlockref = None
1382 1382
1383 1383 # A cache for various files under .hg/ that tracks file changes,
1384 1384 # (used by the filecache decorator)
1385 1385 #
1386 1386 # Maps a property name to its util.filecacheentry
1387 1387 self._filecache = {}
1388 1388
1389 1389 # hold sets of revision to be filtered
1390 1390 # should be cleared when something might have changed the filter value:
1391 1391 # - new changesets,
1392 1392 # - phase change,
1393 1393 # - new obsolescence marker,
1394 1394 # - working directory parent change,
1395 1395 # - bookmark changes
1396 1396 self.filteredrevcache = {}
1397 1397
1398 1398 # post-dirstate-status hooks
1399 1399 self._postdsstatus = []
1400 1400
1401 1401 # generic mapping between names and nodes
1402 1402 self.names = namespaces.namespaces()
1403 1403
1404 1404 # Key to signature value.
1405 1405 self._sparsesignaturecache = {}
1406 1406 # Signature to cached matcher instance.
1407 1407 self._sparsematchercache = {}
1408 1408
1409 1409 self._extrafilterid = repoview.extrafilter(ui)
1410 1410
1411 1411 self.filecopiesmode = None
1412 1412 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1413 1413 self.filecopiesmode = b'changeset-sidedata'
1414 1414
1415 1415 self._wanted_sidedata = set()
1416 1416 self._sidedata_computers = {}
1417 1417 sidedatamod.set_sidedata_spec_for_repo(self)
1418 1418
1419 1419 def _getvfsward(self, origfunc):
1420 1420 """build a ward for self.vfs"""
1421 1421 rref = weakref.ref(self)
1422 1422
1423 1423 def checkvfs(path, mode=None):
1424 1424 ret = origfunc(path, mode=mode)
1425 1425 repo = rref()
1426 1426 if (
1427 1427 repo is None
1428 1428 or not util.safehasattr(repo, b'_wlockref')
1429 1429 or not util.safehasattr(repo, b'_lockref')
1430 1430 ):
1431 1431 return
1432 1432 if mode in (None, b'r', b'rb'):
1433 1433 return
1434 1434 if path.startswith(repo.path):
1435 1435 # truncate name relative to the repository (.hg)
1436 1436 path = path[len(repo.path) + 1 :]
1437 1437 if path.startswith(b'cache/'):
1438 1438 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1439 1439 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1440 1440 # path prefixes covered by 'lock'
1441 1441 vfs_path_prefixes = (
1442 1442 b'journal.',
1443 1443 b'undo.',
1444 1444 b'strip-backup/',
1445 1445 b'cache/',
1446 1446 )
1447 1447 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1448 1448 if repo._currentlock(repo._lockref) is None:
1449 1449 repo.ui.develwarn(
1450 1450 b'write with no lock: "%s"' % path,
1451 1451 stacklevel=3,
1452 1452 config=b'check-locks',
1453 1453 )
1454 1454 elif repo._currentlock(repo._wlockref) is None:
1455 1455 # rest of vfs files are covered by 'wlock'
1456 1456 #
1457 1457 # exclude special files
1458 1458 for prefix in self._wlockfreeprefix:
1459 1459 if path.startswith(prefix):
1460 1460 return
1461 1461 repo.ui.develwarn(
1462 1462 b'write with no wlock: "%s"' % path,
1463 1463 stacklevel=3,
1464 1464 config=b'check-locks',
1465 1465 )
1466 1466 return ret
1467 1467
1468 1468 return checkvfs
1469 1469
1470 1470 def _getsvfsward(self, origfunc):
1471 1471 """build a ward for self.svfs"""
1472 1472 rref = weakref.ref(self)
1473 1473
1474 1474 def checksvfs(path, mode=None):
1475 1475 ret = origfunc(path, mode=mode)
1476 1476 repo = rref()
1477 1477 if repo is None or not util.safehasattr(repo, b'_lockref'):
1478 1478 return
1479 1479 if mode in (None, b'r', b'rb'):
1480 1480 return
1481 1481 if path.startswith(repo.sharedpath):
1482 1482 # truncate name relative to the repository (.hg)
1483 1483 path = path[len(repo.sharedpath) + 1 :]
1484 1484 if repo._currentlock(repo._lockref) is None:
1485 1485 repo.ui.develwarn(
1486 1486 b'write with no lock: "%s"' % path, stacklevel=4
1487 1487 )
1488 1488 return ret
1489 1489
1490 1490 return checksvfs
1491 1491
1492 1492 def close(self):
1493 1493 self._writecaches()
1494 1494
1495 1495 def _writecaches(self):
1496 1496 if self._revbranchcache:
1497 1497 self._revbranchcache.write()
1498 1498
1499 1499 def _restrictcapabilities(self, caps):
1500 1500 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1501 1501 caps = set(caps)
1502 1502 capsblob = bundle2.encodecaps(
1503 1503 bundle2.getrepocaps(self, role=b'client')
1504 1504 )
1505 1505 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1506 1506 if self.ui.configbool(b'experimental', b'narrow'):
1507 1507 caps.add(wireprototypes.NARROWCAP)
1508 1508 return caps
1509 1509
1510 1510 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1511 1511 # self -> auditor -> self._checknested -> self
1512 1512
1513 1513 @property
1514 1514 def auditor(self):
1515 1515 # This is only used by context.workingctx.match in order to
1516 1516 # detect files in subrepos.
1517 1517 return pathutil.pathauditor(self.root, callback=self._checknested)
1518 1518
1519 1519 @property
1520 1520 def nofsauditor(self):
1521 1521 # This is only used by context.basectx.match in order to detect
1522 1522 # files in subrepos.
1523 1523 return pathutil.pathauditor(
1524 1524 self.root, callback=self._checknested, realfs=False, cached=True
1525 1525 )
1526 1526
1527 1527 def _checknested(self, path):
1528 1528 """Determine if path is a legal nested repository."""
1529 1529 if not path.startswith(self.root):
1530 1530 return False
1531 1531 subpath = path[len(self.root) + 1 :]
1532 1532 normsubpath = util.pconvert(subpath)
1533 1533
1534 1534 # XXX: Checking against the current working copy is wrong in
1535 1535 # the sense that it can reject things like
1536 1536 #
1537 1537 # $ hg cat -r 10 sub/x.txt
1538 1538 #
1539 1539 # if sub/ is no longer a subrepository in the working copy
1540 1540 # parent revision.
1541 1541 #
1542 1542 # However, it can of course also allow things that would have
1543 1543 # been rejected before, such as the above cat command if sub/
1544 1544 # is a subrepository now, but was a normal directory before.
1545 1545 # The old path auditor would have rejected by mistake since it
1546 1546 # panics when it sees sub/.hg/.
1547 1547 #
1548 1548 # All in all, checking against the working copy seems sensible
1549 1549 # since we want to prevent access to nested repositories on
1550 1550 # the filesystem *now*.
1551 1551 ctx = self[None]
1552 1552 parts = util.splitpath(subpath)
1553 1553 while parts:
1554 1554 prefix = b'/'.join(parts)
1555 1555 if prefix in ctx.substate:
1556 1556 if prefix == normsubpath:
1557 1557 return True
1558 1558 else:
1559 1559 sub = ctx.sub(prefix)
1560 1560 return sub.checknested(subpath[len(prefix) + 1 :])
1561 1561 else:
1562 1562 parts.pop()
1563 1563 return False
1564 1564
1565 1565 def peer(self):
1566 1566 return localpeer(self) # not cached to avoid reference cycle
1567 1567
1568 1568 def unfiltered(self):
1569 1569 """Return unfiltered version of the repository
1570 1570
1571 1571 Intended to be overwritten by filtered repo."""
1572 1572 return self
1573 1573
1574 1574 def filtered(self, name, visibilityexceptions=None):
1575 1575 """Return a filtered version of a repository
1576 1576
1577 1577 The `name` parameter is the identifier of the requested view. This
1578 1578 will return a repoview object set "exactly" to the specified view.
1579 1579
1580 1580 This function does not apply recursive filtering to a repository. For
1581 1581 example calling `repo.filtered("served")` will return a repoview using
1582 1582 the "served" view, regardless of the initial view used by `repo`.
1583 1583
1584 1584 In other word, there is always only one level of `repoview` "filtering".
1585 1585 """
1586 1586 if self._extrafilterid is not None and b'%' not in name:
1587 1587 name = name + b'%' + self._extrafilterid
1588 1588
1589 1589 cls = repoview.newtype(self.unfiltered().__class__)
1590 1590 return cls(self, name, visibilityexceptions)
1591 1591
1592 1592 @mixedrepostorecache(
1593 1593 (b'bookmarks', b'plain'),
1594 1594 (b'bookmarks.current', b'plain'),
1595 1595 (b'bookmarks', b''),
1596 1596 (b'00changelog.i', b''),
1597 1597 )
1598 1598 def _bookmarks(self):
1599 1599 # Since the multiple files involved in the transaction cannot be
1600 1600 # written atomically (with current repository format), there is a race
1601 1601 # condition here.
1602 1602 #
1603 1603 # 1) changelog content A is read
1604 1604 # 2) outside transaction update changelog to content B
1605 1605 # 3) outside transaction update bookmark file referring to content B
1606 1606 # 4) bookmarks file content is read and filtered against changelog-A
1607 1607 #
1608 1608 # When this happens, bookmarks against nodes missing from A are dropped.
1609 1609 #
1610 1610 # Having this happening during read is not great, but it become worse
1611 1611 # when this happen during write because the bookmarks to the "unknown"
1612 1612 # nodes will be dropped for good. However, writes happen within locks.
1613 1613 # This locking makes it possible to have a race free consistent read.
1614 1614 # For this purpose data read from disc before locking are
1615 1615 # "invalidated" right after the locks are taken. This invalidations are
1616 1616 # "light", the `filecache` mechanism keep the data in memory and will
1617 1617 # reuse them if the underlying files did not changed. Not parsing the
1618 1618 # same data multiple times helps performances.
1619 1619 #
1620 1620 # Unfortunately in the case describe above, the files tracked by the
1621 1621 # bookmarks file cache might not have changed, but the in-memory
1622 1622 # content is still "wrong" because we used an older changelog content
1623 1623 # to process the on-disk data. So after locking, the changelog would be
1624 1624 # refreshed but `_bookmarks` would be preserved.
1625 1625 # Adding `00changelog.i` to the list of tracked file is not
1626 1626 # enough, because at the time we build the content for `_bookmarks` in
1627 1627 # (4), the changelog file has already diverged from the content used
1628 1628 # for loading `changelog` in (1)
1629 1629 #
1630 1630 # To prevent the issue, we force the changelog to be explicitly
1631 1631 # reloaded while computing `_bookmarks`. The data race can still happen
1632 1632 # without the lock (with a narrower window), but it would no longer go
1633 1633 # undetected during the lock time refresh.
1634 1634 #
1635 1635 # The new schedule is as follow
1636 1636 #
1637 1637 # 1) filecache logic detect that `_bookmarks` needs to be computed
1638 1638 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1639 1639 # 3) We force `changelog` filecache to be tested
1640 1640 # 4) cachestat for `changelog` are captured (for changelog)
1641 1641 # 5) `_bookmarks` is computed and cached
1642 1642 #
1643 1643 # The step in (3) ensure we have a changelog at least as recent as the
1644 1644 # cache stat computed in (1). As a result at locking time:
1645 1645 # * if the changelog did not changed since (1) -> we can reuse the data
1646 1646 # * otherwise -> the bookmarks get refreshed.
1647 1647 self._refreshchangelog()
1648 1648 return bookmarks.bmstore(self)
1649 1649
1650 1650 def _refreshchangelog(self):
1651 1651 """make sure the in memory changelog match the on-disk one"""
1652 1652 if 'changelog' in vars(self) and self.currenttransaction() is None:
1653 1653 del self.changelog
1654 1654
1655 1655 @property
1656 1656 def _activebookmark(self):
1657 1657 return self._bookmarks.active
1658 1658
1659 1659 # _phasesets depend on changelog. what we need is to call
1660 1660 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1661 1661 # can't be easily expressed in filecache mechanism.
1662 1662 @storecache(b'phaseroots', b'00changelog.i')
1663 1663 def _phasecache(self):
1664 1664 return phases.phasecache(self, self._phasedefaults)
1665 1665
1666 1666 @storecache(b'obsstore')
1667 1667 def obsstore(self):
1668 1668 return obsolete.makestore(self.ui, self)
1669 1669
1670 1670 @storecache(b'00changelog.i')
1671 1671 def changelog(self):
1672 1672 # load dirstate before changelog to avoid race see issue6303
1673 1673 self.dirstate.prefetch_parents()
1674 1674 return self.store.changelog(
1675 1675 txnutil.mayhavepending(self.root),
1676 1676 concurrencychecker=revlogchecker.get_checker(self.ui, b'changelog'),
1677 1677 )
1678 1678
1679 1679 @storecache(b'00manifest.i')
1680 1680 def manifestlog(self):
1681 1681 return self.store.manifestlog(self, self._storenarrowmatch)
1682 1682
1683 1683 @repofilecache(b'dirstate')
1684 1684 def dirstate(self):
1685 1685 return self._makedirstate()
1686 1686
1687 1687 def _makedirstate(self):
1688 1688 """Extension point for wrapping the dirstate per-repo."""
1689 1689 sparsematchfn = lambda: sparse.matcher(self)
1690 1690
1691 1691 return dirstate.dirstate(
1692 1692 self.vfs,
1693 1693 self.ui,
1694 1694 self.root,
1695 1695 self._dirstatevalidate,
1696 1696 sparsematchfn,
1697 1697 self.nodeconstants,
1698 1698 )
1699 1699
1700 1700 def _dirstatevalidate(self, node):
1701 1701 try:
1702 1702 self.changelog.rev(node)
1703 1703 return node
1704 1704 except error.LookupError:
1705 1705 if not self._dirstatevalidatewarned:
1706 1706 self._dirstatevalidatewarned = True
1707 1707 self.ui.warn(
1708 1708 _(b"warning: ignoring unknown working parent %s!\n")
1709 1709 % short(node)
1710 1710 )
1711 1711 return self.nullid
1712 1712
1713 1713 @storecache(narrowspec.FILENAME)
1714 1714 def narrowpats(self):
1715 1715 """matcher patterns for this repository's narrowspec
1716 1716
1717 1717 A tuple of (includes, excludes).
1718 1718 """
1719 1719 return narrowspec.load(self)
1720 1720
1721 1721 @storecache(narrowspec.FILENAME)
1722 1722 def _storenarrowmatch(self):
1723 1723 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1724 1724 return matchmod.always()
1725 1725 include, exclude = self.narrowpats
1726 1726 return narrowspec.match(self.root, include=include, exclude=exclude)
1727 1727
1728 1728 @storecache(narrowspec.FILENAME)
1729 1729 def _narrowmatch(self):
1730 1730 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1731 1731 return matchmod.always()
1732 1732 narrowspec.checkworkingcopynarrowspec(self)
1733 1733 include, exclude = self.narrowpats
1734 1734 return narrowspec.match(self.root, include=include, exclude=exclude)
1735 1735
1736 1736 def narrowmatch(self, match=None, includeexact=False):
1737 1737 """matcher corresponding the the repo's narrowspec
1738 1738
1739 1739 If `match` is given, then that will be intersected with the narrow
1740 1740 matcher.
1741 1741
1742 1742 If `includeexact` is True, then any exact matches from `match` will
1743 1743 be included even if they're outside the narrowspec.
1744 1744 """
1745 1745 if match:
1746 1746 if includeexact and not self._narrowmatch.always():
1747 1747 # do not exclude explicitly-specified paths so that they can
1748 1748 # be warned later on
1749 1749 em = matchmod.exact(match.files())
1750 1750 nm = matchmod.unionmatcher([self._narrowmatch, em])
1751 1751 return matchmod.intersectmatchers(match, nm)
1752 1752 return matchmod.intersectmatchers(match, self._narrowmatch)
1753 1753 return self._narrowmatch
1754 1754
1755 1755 def setnarrowpats(self, newincludes, newexcludes):
1756 1756 narrowspec.save(self, newincludes, newexcludes)
1757 1757 self.invalidate(clearfilecache=True)
1758 1758
1759 1759 @unfilteredpropertycache
1760 1760 def _quick_access_changeid_null(self):
1761 1761 return {
1762 1762 b'null': (nullrev, self.nodeconstants.nullid),
1763 1763 nullrev: (nullrev, self.nodeconstants.nullid),
1764 1764 self.nullid: (nullrev, self.nullid),
1765 1765 }
1766 1766
1767 1767 @unfilteredpropertycache
1768 1768 def _quick_access_changeid_wc(self):
1769 1769 # also fast path access to the working copy parents
1770 1770 # however, only do it for filter that ensure wc is visible.
1771 1771 quick = self._quick_access_changeid_null.copy()
1772 1772 cl = self.unfiltered().changelog
1773 1773 for node in self.dirstate.parents():
1774 1774 if node == self.nullid:
1775 1775 continue
1776 1776 rev = cl.index.get_rev(node)
1777 1777 if rev is None:
1778 1778 # unknown working copy parent case:
1779 1779 #
1780 1780 # skip the fast path and let higher code deal with it
1781 1781 continue
1782 1782 pair = (rev, node)
1783 1783 quick[rev] = pair
1784 1784 quick[node] = pair
1785 1785 # also add the parents of the parents
1786 1786 for r in cl.parentrevs(rev):
1787 1787 if r == nullrev:
1788 1788 continue
1789 1789 n = cl.node(r)
1790 1790 pair = (r, n)
1791 1791 quick[r] = pair
1792 1792 quick[n] = pair
1793 1793 p1node = self.dirstate.p1()
1794 1794 if p1node != self.nullid:
1795 1795 quick[b'.'] = quick[p1node]
1796 1796 return quick
1797 1797
1798 1798 @unfilteredmethod
1799 1799 def _quick_access_changeid_invalidate(self):
1800 1800 if '_quick_access_changeid_wc' in vars(self):
1801 1801 del self.__dict__['_quick_access_changeid_wc']
1802 1802
1803 1803 @property
1804 1804 def _quick_access_changeid(self):
1805 1805 """an helper dictionnary for __getitem__ calls
1806 1806
1807 1807 This contains a list of symbol we can recognise right away without
1808 1808 further processing.
1809 1809 """
1810 1810 if self.filtername in repoview.filter_has_wc:
1811 1811 return self._quick_access_changeid_wc
1812 1812 return self._quick_access_changeid_null
1813 1813
1814 1814 def __getitem__(self, changeid):
1815 1815 # dealing with special cases
1816 1816 if changeid is None:
1817 1817 return context.workingctx(self)
1818 1818 if isinstance(changeid, context.basectx):
1819 1819 return changeid
1820 1820
1821 1821 # dealing with multiple revisions
1822 1822 if isinstance(changeid, slice):
1823 1823 # wdirrev isn't contiguous so the slice shouldn't include it
1824 1824 return [
1825 1825 self[i]
1826 1826 for i in pycompat.xrange(*changeid.indices(len(self)))
1827 1827 if i not in self.changelog.filteredrevs
1828 1828 ]
1829 1829
1830 1830 # dealing with some special values
1831 1831 quick_access = self._quick_access_changeid.get(changeid)
1832 1832 if quick_access is not None:
1833 1833 rev, node = quick_access
1834 1834 return context.changectx(self, rev, node, maybe_filtered=False)
1835 1835 if changeid == b'tip':
1836 1836 node = self.changelog.tip()
1837 1837 rev = self.changelog.rev(node)
1838 1838 return context.changectx(self, rev, node)
1839 1839
1840 1840 # dealing with arbitrary values
1841 1841 try:
1842 1842 if isinstance(changeid, int):
1843 1843 node = self.changelog.node(changeid)
1844 1844 rev = changeid
1845 1845 elif changeid == b'.':
1846 1846 # this is a hack to delay/avoid loading obsmarkers
1847 1847 # when we know that '.' won't be hidden
1848 1848 node = self.dirstate.p1()
1849 1849 rev = self.unfiltered().changelog.rev(node)
1850 1850 elif len(changeid) == self.nodeconstants.nodelen:
1851 1851 try:
1852 1852 node = changeid
1853 1853 rev = self.changelog.rev(changeid)
1854 1854 except error.FilteredLookupError:
1855 1855 changeid = hex(changeid) # for the error message
1856 1856 raise
1857 1857 except LookupError:
1858 1858 # check if it might have come from damaged dirstate
1859 1859 #
1860 1860 # XXX we could avoid the unfiltered if we had a recognizable
1861 1861 # exception for filtered changeset access
1862 1862 if (
1863 1863 self.local()
1864 1864 and changeid in self.unfiltered().dirstate.parents()
1865 1865 ):
1866 1866 msg = _(b"working directory has unknown parent '%s'!")
1867 1867 raise error.Abort(msg % short(changeid))
1868 1868 changeid = hex(changeid) # for the error message
1869 1869 raise
1870 1870
1871 1871 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1872 1872 node = bin(changeid)
1873 1873 rev = self.changelog.rev(node)
1874 1874 else:
1875 1875 raise error.ProgrammingError(
1876 1876 b"unsupported changeid '%s' of type %s"
1877 1877 % (changeid, pycompat.bytestr(type(changeid)))
1878 1878 )
1879 1879
1880 1880 return context.changectx(self, rev, node)
1881 1881
1882 1882 except (error.FilteredIndexError, error.FilteredLookupError):
1883 1883 raise error.FilteredRepoLookupError(
1884 1884 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1885 1885 )
1886 1886 except (IndexError, LookupError):
1887 1887 raise error.RepoLookupError(
1888 1888 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1889 1889 )
1890 1890 except error.WdirUnsupported:
1891 1891 return context.workingctx(self)
1892 1892
1893 1893 def __contains__(self, changeid):
1894 1894 """True if the given changeid exists"""
1895 1895 try:
1896 1896 self[changeid]
1897 1897 return True
1898 1898 except error.RepoLookupError:
1899 1899 return False
1900 1900
1901 1901 def __nonzero__(self):
1902 1902 return True
1903 1903
1904 1904 __bool__ = __nonzero__
1905 1905
1906 1906 def __len__(self):
1907 1907 # no need to pay the cost of repoview.changelog
1908 1908 unfi = self.unfiltered()
1909 1909 return len(unfi.changelog)
1910 1910
1911 1911 def __iter__(self):
1912 1912 return iter(self.changelog)
1913 1913
1914 1914 def revs(self, expr, *args):
1915 1915 """Find revisions matching a revset.
1916 1916
1917 1917 The revset is specified as a string ``expr`` that may contain
1918 1918 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1919 1919
1920 1920 Revset aliases from the configuration are not expanded. To expand
1921 1921 user aliases, consider calling ``scmutil.revrange()`` or
1922 1922 ``repo.anyrevs([expr], user=True)``.
1923 1923
1924 1924 Returns a smartset.abstractsmartset, which is a list-like interface
1925 1925 that contains integer revisions.
1926 1926 """
1927 1927 tree = revsetlang.spectree(expr, *args)
1928 1928 return revset.makematcher(tree)(self)
1929 1929
1930 1930 def set(self, expr, *args):
1931 1931 """Find revisions matching a revset and emit changectx instances.
1932 1932
1933 1933 This is a convenience wrapper around ``revs()`` that iterates the
1934 1934 result and is a generator of changectx instances.
1935 1935
1936 1936 Revset aliases from the configuration are not expanded. To expand
1937 1937 user aliases, consider calling ``scmutil.revrange()``.
1938 1938 """
1939 1939 for r in self.revs(expr, *args):
1940 1940 yield self[r]
1941 1941
1942 1942 def anyrevs(self, specs, user=False, localalias=None):
1943 1943 """Find revisions matching one of the given revsets.
1944 1944
1945 1945 Revset aliases from the configuration are not expanded by default. To
1946 1946 expand user aliases, specify ``user=True``. To provide some local
1947 1947 definitions overriding user aliases, set ``localalias`` to
1948 1948 ``{name: definitionstring}``.
1949 1949 """
1950 1950 if specs == [b'null']:
1951 1951 return revset.baseset([nullrev])
1952 1952 if specs == [b'.']:
1953 1953 quick_data = self._quick_access_changeid.get(b'.')
1954 1954 if quick_data is not None:
1955 1955 return revset.baseset([quick_data[0]])
1956 1956 if user:
1957 1957 m = revset.matchany(
1958 1958 self.ui,
1959 1959 specs,
1960 1960 lookup=revset.lookupfn(self),
1961 1961 localalias=localalias,
1962 1962 )
1963 1963 else:
1964 1964 m = revset.matchany(None, specs, localalias=localalias)
1965 1965 return m(self)
1966 1966
1967 1967 def url(self):
1968 1968 return b'file:' + self.root
1969 1969
1970 1970 def hook(self, name, throw=False, **args):
1971 1971 """Call a hook, passing this repo instance.
1972 1972
1973 1973 This a convenience method to aid invoking hooks. Extensions likely
1974 1974 won't call this unless they have registered a custom hook or are
1975 1975 replacing code that is expected to call a hook.
1976 1976 """
1977 1977 return hook.hook(self.ui, self, name, throw, **args)
1978 1978
1979 1979 @filteredpropertycache
1980 1980 def _tagscache(self):
1981 1981 """Returns a tagscache object that contains various tags related
1982 1982 caches."""
1983 1983
1984 1984 # This simplifies its cache management by having one decorated
1985 1985 # function (this one) and the rest simply fetch things from it.
1986 1986 class tagscache(object):
1987 1987 def __init__(self):
1988 1988 # These two define the set of tags for this repository. tags
1989 1989 # maps tag name to node; tagtypes maps tag name to 'global' or
1990 1990 # 'local'. (Global tags are defined by .hgtags across all
1991 1991 # heads, and local tags are defined in .hg/localtags.)
1992 1992 # They constitute the in-memory cache of tags.
1993 1993 self.tags = self.tagtypes = None
1994 1994
1995 1995 self.nodetagscache = self.tagslist = None
1996 1996
1997 1997 cache = tagscache()
1998 1998 cache.tags, cache.tagtypes = self._findtags()
1999 1999
2000 2000 return cache
2001 2001
2002 2002 def tags(self):
2003 2003 '''return a mapping of tag to node'''
2004 2004 t = {}
2005 2005 if self.changelog.filteredrevs:
2006 2006 tags, tt = self._findtags()
2007 2007 else:
2008 2008 tags = self._tagscache.tags
2009 2009 rev = self.changelog.rev
2010 2010 for k, v in pycompat.iteritems(tags):
2011 2011 try:
2012 2012 # ignore tags to unknown nodes
2013 2013 rev(v)
2014 2014 t[k] = v
2015 2015 except (error.LookupError, ValueError):
2016 2016 pass
2017 2017 return t
2018 2018
2019 2019 def _findtags(self):
2020 2020 """Do the hard work of finding tags. Return a pair of dicts
2021 2021 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2022 2022 maps tag name to a string like \'global\' or \'local\'.
2023 2023 Subclasses or extensions are free to add their own tags, but
2024 2024 should be aware that the returned dicts will be retained for the
2025 2025 duration of the localrepo object."""
2026 2026
2027 2027 # XXX what tagtype should subclasses/extensions use? Currently
2028 2028 # mq and bookmarks add tags, but do not set the tagtype at all.
2029 2029 # Should each extension invent its own tag type? Should there
2030 2030 # be one tagtype for all such "virtual" tags? Or is the status
2031 2031 # quo fine?
2032 2032
2033 2033 # map tag name to (node, hist)
2034 2034 alltags = tagsmod.findglobaltags(self.ui, self)
2035 2035 # map tag name to tag type
2036 2036 tagtypes = {tag: b'global' for tag in alltags}
2037 2037
2038 2038 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2039 2039
2040 2040 # Build the return dicts. Have to re-encode tag names because
2041 2041 # the tags module always uses UTF-8 (in order not to lose info
2042 2042 # writing to the cache), but the rest of Mercurial wants them in
2043 2043 # local encoding.
2044 2044 tags = {}
2045 2045 for (name, (node, hist)) in pycompat.iteritems(alltags):
2046 2046 if node != self.nullid:
2047 2047 tags[encoding.tolocal(name)] = node
2048 2048 tags[b'tip'] = self.changelog.tip()
2049 2049 tagtypes = {
2050 2050 encoding.tolocal(name): value
2051 2051 for (name, value) in pycompat.iteritems(tagtypes)
2052 2052 }
2053 2053 return (tags, tagtypes)
2054 2054
2055 2055 def tagtype(self, tagname):
2056 2056 """
2057 2057 return the type of the given tag. result can be:
2058 2058
2059 2059 'local' : a local tag
2060 2060 'global' : a global tag
2061 2061 None : tag does not exist
2062 2062 """
2063 2063
2064 2064 return self._tagscache.tagtypes.get(tagname)
2065 2065
2066 2066 def tagslist(self):
2067 2067 '''return a list of tags ordered by revision'''
2068 2068 if not self._tagscache.tagslist:
2069 2069 l = []
2070 2070 for t, n in pycompat.iteritems(self.tags()):
2071 2071 l.append((self.changelog.rev(n), t, n))
2072 2072 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2073 2073
2074 2074 return self._tagscache.tagslist
2075 2075
2076 2076 def nodetags(self, node):
2077 2077 '''return the tags associated with a node'''
2078 2078 if not self._tagscache.nodetagscache:
2079 2079 nodetagscache = {}
2080 2080 for t, n in pycompat.iteritems(self._tagscache.tags):
2081 2081 nodetagscache.setdefault(n, []).append(t)
2082 2082 for tags in pycompat.itervalues(nodetagscache):
2083 2083 tags.sort()
2084 2084 self._tagscache.nodetagscache = nodetagscache
2085 2085 return self._tagscache.nodetagscache.get(node, [])
2086 2086
2087 2087 def nodebookmarks(self, node):
2088 2088 """return the list of bookmarks pointing to the specified node"""
2089 2089 return self._bookmarks.names(node)
2090 2090
2091 2091 def branchmap(self):
2092 2092 """returns a dictionary {branch: [branchheads]} with branchheads
2093 2093 ordered by increasing revision number"""
2094 2094 return self._branchcaches[self]
2095 2095
2096 2096 @unfilteredmethod
2097 2097 def revbranchcache(self):
2098 2098 if not self._revbranchcache:
2099 2099 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2100 2100 return self._revbranchcache
2101 2101
2102 2102 def register_changeset(self, rev, changelogrevision):
2103 2103 self.revbranchcache().setdata(rev, changelogrevision)
2104 2104
2105 2105 def branchtip(self, branch, ignoremissing=False):
2106 2106 """return the tip node for a given branch
2107 2107
2108 2108 If ignoremissing is True, then this method will not raise an error.
2109 2109 This is helpful for callers that only expect None for a missing branch
2110 2110 (e.g. namespace).
2111 2111
2112 2112 """
2113 2113 try:
2114 2114 return self.branchmap().branchtip(branch)
2115 2115 except KeyError:
2116 2116 if not ignoremissing:
2117 2117 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2118 2118 else:
2119 2119 pass
2120 2120
2121 2121 def lookup(self, key):
2122 2122 node = scmutil.revsymbol(self, key).node()
2123 2123 if node is None:
2124 2124 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2125 2125 return node
2126 2126
2127 2127 def lookupbranch(self, key):
2128 2128 if self.branchmap().hasbranch(key):
2129 2129 return key
2130 2130
2131 2131 return scmutil.revsymbol(self, key).branch()
2132 2132
2133 2133 def known(self, nodes):
2134 2134 cl = self.changelog
2135 2135 get_rev = cl.index.get_rev
2136 2136 filtered = cl.filteredrevs
2137 2137 result = []
2138 2138 for n in nodes:
2139 2139 r = get_rev(n)
2140 2140 resp = not (r is None or r in filtered)
2141 2141 result.append(resp)
2142 2142 return result
2143 2143
2144 2144 def local(self):
2145 2145 return self
2146 2146
2147 2147 def publishing(self):
2148 2148 # it's safe (and desirable) to trust the publish flag unconditionally
2149 2149 # so that we don't finalize changes shared between users via ssh or nfs
2150 2150 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2151 2151
2152 2152 def cancopy(self):
2153 2153 # so statichttprepo's override of local() works
2154 2154 if not self.local():
2155 2155 return False
2156 2156 if not self.publishing():
2157 2157 return True
2158 2158 # if publishing we can't copy if there is filtered content
2159 2159 return not self.filtered(b'visible').changelog.filteredrevs
2160 2160
2161 2161 def shared(self):
2162 2162 '''the type of shared repository (None if not shared)'''
2163 2163 if self.sharedpath != self.path:
2164 2164 return b'store'
2165 2165 return None
2166 2166
2167 2167 def wjoin(self, f, *insidef):
2168 2168 return self.vfs.reljoin(self.root, f, *insidef)
2169 2169
2170 2170 def setparents(self, p1, p2=None):
2171 2171 if p2 is None:
2172 2172 p2 = self.nullid
2173 2173 self[None].setparents(p1, p2)
2174 2174 self._quick_access_changeid_invalidate()
2175 2175
2176 2176 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2177 2177 """changeid must be a changeset revision, if specified.
2178 2178 fileid can be a file revision or node."""
2179 2179 return context.filectx(
2180 2180 self, path, changeid, fileid, changectx=changectx
2181 2181 )
2182 2182
2183 2183 def getcwd(self):
2184 2184 return self.dirstate.getcwd()
2185 2185
2186 2186 def pathto(self, f, cwd=None):
2187 2187 return self.dirstate.pathto(f, cwd)
2188 2188
2189 2189 def _loadfilter(self, filter):
2190 2190 if filter not in self._filterpats:
2191 2191 l = []
2192 2192 for pat, cmd in self.ui.configitems(filter):
2193 2193 if cmd == b'!':
2194 2194 continue
2195 2195 mf = matchmod.match(self.root, b'', [pat])
2196 2196 fn = None
2197 2197 params = cmd
2198 2198 for name, filterfn in pycompat.iteritems(self._datafilters):
2199 2199 if cmd.startswith(name):
2200 2200 fn = filterfn
2201 2201 params = cmd[len(name) :].lstrip()
2202 2202 break
2203 2203 if not fn:
2204 2204 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2205 2205 fn.__name__ = 'commandfilter'
2206 2206 # Wrap old filters not supporting keyword arguments
2207 2207 if not pycompat.getargspec(fn)[2]:
2208 2208 oldfn = fn
2209 2209 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2210 2210 fn.__name__ = 'compat-' + oldfn.__name__
2211 2211 l.append((mf, fn, params))
2212 2212 self._filterpats[filter] = l
2213 2213 return self._filterpats[filter]
2214 2214
2215 2215 def _filter(self, filterpats, filename, data):
2216 2216 for mf, fn, cmd in filterpats:
2217 2217 if mf(filename):
2218 2218 self.ui.debug(
2219 2219 b"filtering %s through %s\n"
2220 2220 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2221 2221 )
2222 2222 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2223 2223 break
2224 2224
2225 2225 return data
2226 2226
2227 2227 @unfilteredpropertycache
2228 2228 def _encodefilterpats(self):
2229 2229 return self._loadfilter(b'encode')
2230 2230
2231 2231 @unfilteredpropertycache
2232 2232 def _decodefilterpats(self):
2233 2233 return self._loadfilter(b'decode')
2234 2234
2235 2235 def adddatafilter(self, name, filter):
2236 2236 self._datafilters[name] = filter
2237 2237
2238 2238 def wread(self, filename):
2239 2239 if self.wvfs.islink(filename):
2240 2240 data = self.wvfs.readlink(filename)
2241 2241 else:
2242 2242 data = self.wvfs.read(filename)
2243 2243 return self._filter(self._encodefilterpats, filename, data)
2244 2244
2245 2245 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2246 2246 """write ``data`` into ``filename`` in the working directory
2247 2247
2248 2248 This returns length of written (maybe decoded) data.
2249 2249 """
2250 2250 data = self._filter(self._decodefilterpats, filename, data)
2251 2251 if b'l' in flags:
2252 2252 self.wvfs.symlink(data, filename)
2253 2253 else:
2254 2254 self.wvfs.write(
2255 2255 filename, data, backgroundclose=backgroundclose, **kwargs
2256 2256 )
2257 2257 if b'x' in flags:
2258 2258 self.wvfs.setflags(filename, False, True)
2259 2259 else:
2260 2260 self.wvfs.setflags(filename, False, False)
2261 2261 return len(data)
2262 2262
2263 2263 def wwritedata(self, filename, data):
2264 2264 return self._filter(self._decodefilterpats, filename, data)
2265 2265
2266 2266 def currenttransaction(self):
2267 2267 """return the current transaction or None if non exists"""
2268 2268 if self._transref:
2269 2269 tr = self._transref()
2270 2270 else:
2271 2271 tr = None
2272 2272
2273 2273 if tr and tr.running():
2274 2274 return tr
2275 2275 return None
2276 2276
2277 2277 def transaction(self, desc, report=None):
2278 2278 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2279 2279 b'devel', b'check-locks'
2280 2280 ):
2281 2281 if self._currentlock(self._lockref) is None:
2282 2282 raise error.ProgrammingError(b'transaction requires locking')
2283 2283 tr = self.currenttransaction()
2284 2284 if tr is not None:
2285 2285 return tr.nest(name=desc)
2286 2286
2287 2287 # abort here if the journal already exists
2288 2288 if self.svfs.exists(b"journal"):
2289 2289 raise error.RepoError(
2290 2290 _(b"abandoned transaction found"),
2291 2291 hint=_(b"run 'hg recover' to clean up transaction"),
2292 2292 )
2293 2293
2294 2294 idbase = b"%.40f#%f" % (random.random(), time.time())
2295 2295 ha = hex(hashutil.sha1(idbase).digest())
2296 2296 txnid = b'TXN:' + ha
2297 2297 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2298 2298
2299 2299 self._writejournal(desc)
2300 2300 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2301 2301 if report:
2302 2302 rp = report
2303 2303 else:
2304 2304 rp = self.ui.warn
2305 2305 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2306 2306 # we must avoid cyclic reference between repo and transaction.
2307 2307 reporef = weakref.ref(self)
2308 2308 # Code to track tag movement
2309 2309 #
2310 2310 # Since tags are all handled as file content, it is actually quite hard
2311 2311 # to track these movement from a code perspective. So we fallback to a
2312 2312 # tracking at the repository level. One could envision to track changes
2313 2313 # to the '.hgtags' file through changegroup apply but that fails to
2314 2314 # cope with case where transaction expose new heads without changegroup
2315 2315 # being involved (eg: phase movement).
2316 2316 #
2317 2317 # For now, We gate the feature behind a flag since this likely comes
2318 2318 # with performance impacts. The current code run more often than needed
2319 2319 # and do not use caches as much as it could. The current focus is on
2320 2320 # the behavior of the feature so we disable it by default. The flag
2321 2321 # will be removed when we are happy with the performance impact.
2322 2322 #
2323 2323 # Once this feature is no longer experimental move the following
2324 2324 # documentation to the appropriate help section:
2325 2325 #
2326 2326 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2327 2327 # tags (new or changed or deleted tags). In addition the details of
2328 2328 # these changes are made available in a file at:
2329 2329 # ``REPOROOT/.hg/changes/tags.changes``.
2330 2330 # Make sure you check for HG_TAG_MOVED before reading that file as it
2331 2331 # might exist from a previous transaction even if no tag were touched
2332 2332 # in this one. Changes are recorded in a line base format::
2333 2333 #
2334 2334 # <action> <hex-node> <tag-name>\n
2335 2335 #
2336 2336 # Actions are defined as follow:
2337 2337 # "-R": tag is removed,
2338 2338 # "+A": tag is added,
2339 2339 # "-M": tag is moved (old value),
2340 2340 # "+M": tag is moved (new value),
2341 2341 tracktags = lambda x: None
2342 2342 # experimental config: experimental.hook-track-tags
2343 2343 shouldtracktags = self.ui.configbool(
2344 2344 b'experimental', b'hook-track-tags'
2345 2345 )
2346 2346 if desc != b'strip' and shouldtracktags:
2347 2347 oldheads = self.changelog.headrevs()
2348 2348
2349 2349 def tracktags(tr2):
2350 2350 repo = reporef()
2351 2351 assert repo is not None # help pytype
2352 2352 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2353 2353 newheads = repo.changelog.headrevs()
2354 2354 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2355 2355 # notes: we compare lists here.
2356 2356 # As we do it only once buiding set would not be cheaper
2357 2357 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2358 2358 if changes:
2359 2359 tr2.hookargs[b'tag_moved'] = b'1'
2360 2360 with repo.vfs(
2361 2361 b'changes/tags.changes', b'w', atomictemp=True
2362 2362 ) as changesfile:
2363 2363 # note: we do not register the file to the transaction
2364 2364 # because we needs it to still exist on the transaction
2365 2365 # is close (for txnclose hooks)
2366 2366 tagsmod.writediff(changesfile, changes)
2367 2367
2368 2368 def validate(tr2):
2369 2369 """will run pre-closing hooks"""
2370 2370 # XXX the transaction API is a bit lacking here so we take a hacky
2371 2371 # path for now
2372 2372 #
2373 2373 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2374 2374 # dict is copied before these run. In addition we needs the data
2375 2375 # available to in memory hooks too.
2376 2376 #
2377 2377 # Moreover, we also need to make sure this runs before txnclose
2378 2378 # hooks and there is no "pending" mechanism that would execute
2379 2379 # logic only if hooks are about to run.
2380 2380 #
2381 2381 # Fixing this limitation of the transaction is also needed to track
2382 2382 # other families of changes (bookmarks, phases, obsolescence).
2383 2383 #
2384 2384 # This will have to be fixed before we remove the experimental
2385 2385 # gating.
2386 2386 tracktags(tr2)
2387 2387 repo = reporef()
2388 2388 assert repo is not None # help pytype
2389 2389
2390 2390 singleheadopt = (b'experimental', b'single-head-per-branch')
2391 2391 singlehead = repo.ui.configbool(*singleheadopt)
2392 2392 if singlehead:
2393 2393 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2394 2394 accountclosed = singleheadsub.get(
2395 2395 b"account-closed-heads", False
2396 2396 )
2397 2397 if singleheadsub.get(b"public-changes-only", False):
2398 2398 filtername = b"immutable"
2399 2399 else:
2400 2400 filtername = b"visible"
2401 2401 scmutil.enforcesinglehead(
2402 2402 repo, tr2, desc, accountclosed, filtername
2403 2403 )
2404 2404 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2405 2405 for name, (old, new) in sorted(
2406 2406 tr.changes[b'bookmarks'].items()
2407 2407 ):
2408 2408 args = tr.hookargs.copy()
2409 2409 args.update(bookmarks.preparehookargs(name, old, new))
2410 2410 repo.hook(
2411 2411 b'pretxnclose-bookmark',
2412 2412 throw=True,
2413 2413 **pycompat.strkwargs(args)
2414 2414 )
2415 2415 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2416 2416 cl = repo.unfiltered().changelog
2417 2417 for revs, (old, new) in tr.changes[b'phases']:
2418 2418 for rev in revs:
2419 2419 args = tr.hookargs.copy()
2420 2420 node = hex(cl.node(rev))
2421 2421 args.update(phases.preparehookargs(node, old, new))
2422 2422 repo.hook(
2423 2423 b'pretxnclose-phase',
2424 2424 throw=True,
2425 2425 **pycompat.strkwargs(args)
2426 2426 )
2427 2427
2428 2428 repo.hook(
2429 2429 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2430 2430 )
2431 2431
2432 2432 def releasefn(tr, success):
2433 2433 repo = reporef()
2434 2434 if repo is None:
2435 2435 # If the repo has been GC'd (and this release function is being
2436 2436 # called from transaction.__del__), there's not much we can do,
2437 2437 # so just leave the unfinished transaction there and let the
2438 2438 # user run `hg recover`.
2439 2439 return
2440 2440 if success:
2441 2441 # this should be explicitly invoked here, because
2442 2442 # in-memory changes aren't written out at closing
2443 2443 # transaction, if tr.addfilegenerator (via
2444 2444 # dirstate.write or so) isn't invoked while
2445 2445 # transaction running
2446 2446 repo.dirstate.write(None)
2447 2447 else:
2448 2448 # discard all changes (including ones already written
2449 2449 # out) in this transaction
2450 2450 narrowspec.restorebackup(self, b'journal.narrowspec')
2451 2451 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2452 2452 repo.dirstate.restorebackup(None, b'journal.dirstate')
2453 2453
2454 2454 repo.invalidate(clearfilecache=True)
2455 2455
2456 2456 tr = transaction.transaction(
2457 2457 rp,
2458 2458 self.svfs,
2459 2459 vfsmap,
2460 2460 b"journal",
2461 2461 b"undo",
2462 2462 aftertrans(renames),
2463 2463 self.store.createmode,
2464 2464 validator=validate,
2465 2465 releasefn=releasefn,
2466 2466 checkambigfiles=_cachedfiles,
2467 2467 name=desc,
2468 2468 )
2469 2469 tr.changes[b'origrepolen'] = len(self)
2470 2470 tr.changes[b'obsmarkers'] = set()
2471 2471 tr.changes[b'phases'] = []
2472 2472 tr.changes[b'bookmarks'] = {}
2473 2473
2474 2474 tr.hookargs[b'txnid'] = txnid
2475 2475 tr.hookargs[b'txnname'] = desc
2476 2476 tr.hookargs[b'changes'] = tr.changes
2477 2477 # note: writing the fncache only during finalize mean that the file is
2478 2478 # outdated when running hooks. As fncache is used for streaming clone,
2479 2479 # this is not expected to break anything that happen during the hooks.
2480 2480 tr.addfinalize(b'flush-fncache', self.store.write)
2481 2481
2482 2482 def txnclosehook(tr2):
2483 2483 """To be run if transaction is successful, will schedule a hook run"""
2484 2484 # Don't reference tr2 in hook() so we don't hold a reference.
2485 2485 # This reduces memory consumption when there are multiple
2486 2486 # transactions per lock. This can likely go away if issue5045
2487 2487 # fixes the function accumulation.
2488 2488 hookargs = tr2.hookargs
2489 2489
2490 2490 def hookfunc(unused_success):
2491 2491 repo = reporef()
2492 2492 assert repo is not None # help pytype
2493 2493
2494 2494 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2495 2495 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2496 2496 for name, (old, new) in bmchanges:
2497 2497 args = tr.hookargs.copy()
2498 2498 args.update(bookmarks.preparehookargs(name, old, new))
2499 2499 repo.hook(
2500 2500 b'txnclose-bookmark',
2501 2501 throw=False,
2502 2502 **pycompat.strkwargs(args)
2503 2503 )
2504 2504
2505 2505 if hook.hashook(repo.ui, b'txnclose-phase'):
2506 2506 cl = repo.unfiltered().changelog
2507 2507 phasemv = sorted(
2508 2508 tr.changes[b'phases'], key=lambda r: r[0][0]
2509 2509 )
2510 2510 for revs, (old, new) in phasemv:
2511 2511 for rev in revs:
2512 2512 args = tr.hookargs.copy()
2513 2513 node = hex(cl.node(rev))
2514 2514 args.update(phases.preparehookargs(node, old, new))
2515 2515 repo.hook(
2516 2516 b'txnclose-phase',
2517 2517 throw=False,
2518 2518 **pycompat.strkwargs(args)
2519 2519 )
2520 2520
2521 2521 repo.hook(
2522 2522 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2523 2523 )
2524 2524
2525 2525 repo = reporef()
2526 2526 assert repo is not None # help pytype
2527 2527 repo._afterlock(hookfunc)
2528 2528
2529 2529 tr.addfinalize(b'txnclose-hook', txnclosehook)
2530 2530 # Include a leading "-" to make it happen before the transaction summary
2531 2531 # reports registered via scmutil.registersummarycallback() whose names
2532 2532 # are 00-txnreport etc. That way, the caches will be warm when the
2533 2533 # callbacks run.
2534 2534 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2535 2535
2536 2536 def txnaborthook(tr2):
2537 2537 """To be run if transaction is aborted"""
2538 2538 repo = reporef()
2539 2539 assert repo is not None # help pytype
2540 2540 repo.hook(
2541 2541 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2542 2542 )
2543 2543
2544 2544 tr.addabort(b'txnabort-hook', txnaborthook)
2545 2545 # avoid eager cache invalidation. in-memory data should be identical
2546 2546 # to stored data if transaction has no error.
2547 2547 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2548 2548 self._transref = weakref.ref(tr)
2549 2549 scmutil.registersummarycallback(self, tr, desc)
2550 2550 return tr
2551 2551
2552 2552 def _journalfiles(self):
2553 2553 return (
2554 2554 (self.svfs, b'journal'),
2555 2555 (self.svfs, b'journal.narrowspec'),
2556 2556 (self.vfs, b'journal.narrowspec.dirstate'),
2557 2557 (self.vfs, b'journal.dirstate'),
2558 2558 (self.vfs, b'journal.branch'),
2559 2559 (self.vfs, b'journal.desc'),
2560 2560 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2561 2561 (self.svfs, b'journal.phaseroots'),
2562 2562 )
2563 2563
2564 2564 def undofiles(self):
2565 2565 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2566 2566
2567 2567 @unfilteredmethod
2568 2568 def _writejournal(self, desc):
2569 2569 self.dirstate.savebackup(None, b'journal.dirstate')
2570 2570 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2571 2571 narrowspec.savebackup(self, b'journal.narrowspec')
2572 2572 self.vfs.write(
2573 2573 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2574 2574 )
2575 2575 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2576 2576 bookmarksvfs = bookmarks.bookmarksvfs(self)
2577 2577 bookmarksvfs.write(
2578 2578 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2579 2579 )
2580 2580 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2581 2581
2582 2582 def recover(self):
2583 2583 with self.lock():
2584 2584 if self.svfs.exists(b"journal"):
2585 2585 self.ui.status(_(b"rolling back interrupted transaction\n"))
2586 2586 vfsmap = {
2587 2587 b'': self.svfs,
2588 2588 b'plain': self.vfs,
2589 2589 }
2590 2590 transaction.rollback(
2591 2591 self.svfs,
2592 2592 vfsmap,
2593 2593 b"journal",
2594 2594 self.ui.warn,
2595 2595 checkambigfiles=_cachedfiles,
2596 2596 )
2597 2597 self.invalidate()
2598 2598 return True
2599 2599 else:
2600 2600 self.ui.warn(_(b"no interrupted transaction available\n"))
2601 2601 return False
2602 2602
2603 2603 def rollback(self, dryrun=False, force=False):
2604 2604 wlock = lock = dsguard = None
2605 2605 try:
2606 2606 wlock = self.wlock()
2607 2607 lock = self.lock()
2608 2608 if self.svfs.exists(b"undo"):
2609 2609 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2610 2610
2611 2611 return self._rollback(dryrun, force, dsguard)
2612 2612 else:
2613 2613 self.ui.warn(_(b"no rollback information available\n"))
2614 2614 return 1
2615 2615 finally:
2616 2616 release(dsguard, lock, wlock)
2617 2617
2618 2618 @unfilteredmethod # Until we get smarter cache management
2619 2619 def _rollback(self, dryrun, force, dsguard):
2620 2620 ui = self.ui
2621 2621 try:
2622 2622 args = self.vfs.read(b'undo.desc').splitlines()
2623 2623 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2624 2624 if len(args) >= 3:
2625 2625 detail = args[2]
2626 2626 oldtip = oldlen - 1
2627 2627
2628 2628 if detail and ui.verbose:
2629 2629 msg = _(
2630 2630 b'repository tip rolled back to revision %d'
2631 2631 b' (undo %s: %s)\n'
2632 2632 ) % (oldtip, desc, detail)
2633 2633 else:
2634 2634 msg = _(
2635 2635 b'repository tip rolled back to revision %d (undo %s)\n'
2636 2636 ) % (oldtip, desc)
2637 2637 except IOError:
2638 2638 msg = _(b'rolling back unknown transaction\n')
2639 2639 desc = None
2640 2640
2641 2641 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2642 2642 raise error.Abort(
2643 2643 _(
2644 2644 b'rollback of last commit while not checked out '
2645 2645 b'may lose data'
2646 2646 ),
2647 2647 hint=_(b'use -f to force'),
2648 2648 )
2649 2649
2650 2650 ui.status(msg)
2651 2651 if dryrun:
2652 2652 return 0
2653 2653
2654 2654 parents = self.dirstate.parents()
2655 2655 self.destroying()
2656 2656 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2657 2657 transaction.rollback(
2658 2658 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2659 2659 )
2660 2660 bookmarksvfs = bookmarks.bookmarksvfs(self)
2661 2661 if bookmarksvfs.exists(b'undo.bookmarks'):
2662 2662 bookmarksvfs.rename(
2663 2663 b'undo.bookmarks', b'bookmarks', checkambig=True
2664 2664 )
2665 2665 if self.svfs.exists(b'undo.phaseroots'):
2666 2666 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2667 2667 self.invalidate()
2668 2668
2669 2669 has_node = self.changelog.index.has_node
2670 2670 parentgone = any(not has_node(p) for p in parents)
2671 2671 if parentgone:
2672 2672 # prevent dirstateguard from overwriting already restored one
2673 2673 dsguard.close()
2674 2674
2675 2675 narrowspec.restorebackup(self, b'undo.narrowspec')
2676 2676 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2677 2677 self.dirstate.restorebackup(None, b'undo.dirstate')
2678 2678 try:
2679 2679 branch = self.vfs.read(b'undo.branch')
2680 2680 self.dirstate.setbranch(encoding.tolocal(branch))
2681 2681 except IOError:
2682 2682 ui.warn(
2683 2683 _(
2684 2684 b'named branch could not be reset: '
2685 2685 b'current branch is still \'%s\'\n'
2686 2686 )
2687 2687 % self.dirstate.branch()
2688 2688 )
2689 2689
2690 2690 parents = tuple([p.rev() for p in self[None].parents()])
2691 2691 if len(parents) > 1:
2692 2692 ui.status(
2693 2693 _(
2694 2694 b'working directory now based on '
2695 2695 b'revisions %d and %d\n'
2696 2696 )
2697 2697 % parents
2698 2698 )
2699 2699 else:
2700 2700 ui.status(
2701 2701 _(b'working directory now based on revision %d\n') % parents
2702 2702 )
2703 2703 mergestatemod.mergestate.clean(self)
2704 2704
2705 2705 # TODO: if we know which new heads may result from this rollback, pass
2706 2706 # them to destroy(), which will prevent the branchhead cache from being
2707 2707 # invalidated.
2708 2708 self.destroyed()
2709 2709 return 0
2710 2710
2711 2711 def _buildcacheupdater(self, newtransaction):
2712 2712 """called during transaction to build the callback updating cache
2713 2713
2714 2714 Lives on the repository to help extension who might want to augment
2715 2715 this logic. For this purpose, the created transaction is passed to the
2716 2716 method.
2717 2717 """
2718 2718 # we must avoid cyclic reference between repo and transaction.
2719 2719 reporef = weakref.ref(self)
2720 2720
2721 2721 def updater(tr):
2722 2722 repo = reporef()
2723 2723 assert repo is not None # help pytype
2724 2724 repo.updatecaches(tr)
2725 2725
2726 2726 return updater
2727 2727
2728 2728 @unfilteredmethod
2729 2729 def updatecaches(self, tr=None, full=False):
2730 2730 """warm appropriate caches
2731 2731
2732 2732 If this function is called after a transaction closed. The transaction
2733 2733 will be available in the 'tr' argument. This can be used to selectively
2734 2734 update caches relevant to the changes in that transaction.
2735 2735
2736 2736 If 'full' is set, make sure all caches the function knows about have
2737 2737 up-to-date data. Even the ones usually loaded more lazily.
2738 2738
2739 2739 The `full` argument can take a special "post-clone" value. In this case
2740 2740 the cache warming is made after a clone and of the slower cache might
2741 2741 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2742 2742 as we plan for a cleaner way to deal with this for 5.9.
2743 2743 """
2744 2744 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2745 2745 # During strip, many caches are invalid but
2746 2746 # later call to `destroyed` will refresh them.
2747 2747 return
2748 2748
2749 2749 if tr is None or tr.changes[b'origrepolen'] < len(self):
2750 2750 # accessing the 'served' branchmap should refresh all the others,
2751 2751 self.ui.debug(b'updating the branch cache\n')
2752 2752 self.filtered(b'served').branchmap()
2753 2753 self.filtered(b'served.hidden').branchmap()
2754 2754
2755 2755 if full:
2756 2756 unfi = self.unfiltered()
2757 2757
2758 2758 self.changelog.update_caches(transaction=tr)
2759 2759 self.manifestlog.update_caches(transaction=tr)
2760 2760
2761 2761 rbc = unfi.revbranchcache()
2762 2762 for r in unfi.changelog:
2763 2763 rbc.branchinfo(r)
2764 2764 rbc.write()
2765 2765
2766 2766 # ensure the working copy parents are in the manifestfulltextcache
2767 2767 for ctx in self[b'.'].parents():
2768 2768 ctx.manifest() # accessing the manifest is enough
2769 2769
2770 2770 if not full == b"post-clone":
2771 2771 # accessing fnode cache warms the cache
2772 2772 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2773 2773 # accessing tags warm the cache
2774 2774 self.tags()
2775 2775 self.filtered(b'served').tags()
2776 2776
2777 2777 # The `full` arg is documented as updating even the lazily-loaded
2778 2778 # caches immediately, so we're forcing a write to cause these caches
2779 2779 # to be warmed up even if they haven't explicitly been requested
2780 2780 # yet (if they've never been used by hg, they won't ever have been
2781 2781 # written, even if they're a subset of another kind of cache that
2782 2782 # *has* been used).
2783 2783 for filt in repoview.filtertable.keys():
2784 2784 filtered = self.filtered(filt)
2785 2785 filtered.branchmap().write(filtered)
2786 2786
2787 2787 def invalidatecaches(self):
2788 2788
2789 2789 if '_tagscache' in vars(self):
2790 2790 # can't use delattr on proxy
2791 2791 del self.__dict__['_tagscache']
2792 2792
2793 2793 self._branchcaches.clear()
2794 2794 self.invalidatevolatilesets()
2795 2795 self._sparsesignaturecache.clear()
2796 2796
2797 2797 def invalidatevolatilesets(self):
2798 2798 self.filteredrevcache.clear()
2799 2799 obsolete.clearobscaches(self)
2800 2800 self._quick_access_changeid_invalidate()
2801 2801
2802 2802 def invalidatedirstate(self):
2803 2803 """Invalidates the dirstate, causing the next call to dirstate
2804 2804 to check if it was modified since the last time it was read,
2805 2805 rereading it if it has.
2806 2806
2807 2807 This is different to dirstate.invalidate() that it doesn't always
2808 2808 rereads the dirstate. Use dirstate.invalidate() if you want to
2809 2809 explicitly read the dirstate again (i.e. restoring it to a previous
2810 2810 known good state)."""
2811 2811 if hasunfilteredcache(self, 'dirstate'):
2812 2812 for k in self.dirstate._filecache:
2813 2813 try:
2814 2814 delattr(self.dirstate, k)
2815 2815 except AttributeError:
2816 2816 pass
2817 2817 delattr(self.unfiltered(), 'dirstate')
2818 2818
2819 2819 def invalidate(self, clearfilecache=False):
2820 2820 """Invalidates both store and non-store parts other than dirstate
2821 2821
2822 2822 If a transaction is running, invalidation of store is omitted,
2823 2823 because discarding in-memory changes might cause inconsistency
2824 2824 (e.g. incomplete fncache causes unintentional failure, but
2825 2825 redundant one doesn't).
2826 2826 """
2827 2827 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2828 2828 for k in list(self._filecache.keys()):
2829 2829 # dirstate is invalidated separately in invalidatedirstate()
2830 2830 if k == b'dirstate':
2831 2831 continue
2832 2832 if (
2833 2833 k == b'changelog'
2834 2834 and self.currenttransaction()
2835 2835 and self.changelog._delayed
2836 2836 ):
2837 2837 # The changelog object may store unwritten revisions. We don't
2838 2838 # want to lose them.
2839 2839 # TODO: Solve the problem instead of working around it.
2840 2840 continue
2841 2841
2842 2842 if clearfilecache:
2843 2843 del self._filecache[k]
2844 2844 try:
2845 2845 delattr(unfiltered, k)
2846 2846 except AttributeError:
2847 2847 pass
2848 2848 self.invalidatecaches()
2849 2849 if not self.currenttransaction():
2850 2850 # TODO: Changing contents of store outside transaction
2851 2851 # causes inconsistency. We should make in-memory store
2852 2852 # changes detectable, and abort if changed.
2853 2853 self.store.invalidatecaches()
2854 2854
2855 2855 def invalidateall(self):
2856 2856 """Fully invalidates both store and non-store parts, causing the
2857 2857 subsequent operation to reread any outside changes."""
2858 2858 # extension should hook this to invalidate its caches
2859 2859 self.invalidate()
2860 2860 self.invalidatedirstate()
2861 2861
2862 2862 @unfilteredmethod
2863 2863 def _refreshfilecachestats(self, tr):
2864 2864 """Reload stats of cached files so that they are flagged as valid"""
2865 2865 for k, ce in self._filecache.items():
2866 2866 k = pycompat.sysstr(k)
2867 2867 if k == 'dirstate' or k not in self.__dict__:
2868 2868 continue
2869 2869 ce.refresh()
2870 2870
2871 2871 def _lock(
2872 2872 self,
2873 2873 vfs,
2874 2874 lockname,
2875 2875 wait,
2876 2876 releasefn,
2877 2877 acquirefn,
2878 2878 desc,
2879 2879 ):
2880 2880 timeout = 0
2881 2881 warntimeout = 0
2882 2882 if wait:
2883 2883 timeout = self.ui.configint(b"ui", b"timeout")
2884 2884 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2885 2885 # internal config: ui.signal-safe-lock
2886 2886 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2887 2887
2888 2888 l = lockmod.trylock(
2889 2889 self.ui,
2890 2890 vfs,
2891 2891 lockname,
2892 2892 timeout,
2893 2893 warntimeout,
2894 2894 releasefn=releasefn,
2895 2895 acquirefn=acquirefn,
2896 2896 desc=desc,
2897 2897 signalsafe=signalsafe,
2898 2898 )
2899 2899 return l
2900 2900
2901 2901 def _afterlock(self, callback):
2902 2902 """add a callback to be run when the repository is fully unlocked
2903 2903
2904 2904 The callback will be executed when the outermost lock is released
2905 2905 (with wlock being higher level than 'lock')."""
2906 2906 for ref in (self._wlockref, self._lockref):
2907 2907 l = ref and ref()
2908 2908 if l and l.held:
2909 2909 l.postrelease.append(callback)
2910 2910 break
2911 2911 else: # no lock have been found.
2912 2912 callback(True)
2913 2913
2914 2914 def lock(self, wait=True):
2915 2915 """Lock the repository store (.hg/store) and return a weak reference
2916 2916 to the lock. Use this before modifying the store (e.g. committing or
2917 2917 stripping). If you are opening a transaction, get a lock as well.)
2918 2918
2919 2919 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2920 2920 'wlock' first to avoid a dead-lock hazard."""
2921 2921 l = self._currentlock(self._lockref)
2922 2922 if l is not None:
2923 2923 l.lock()
2924 2924 return l
2925 2925
2926 2926 l = self._lock(
2927 2927 vfs=self.svfs,
2928 2928 lockname=b"lock",
2929 2929 wait=wait,
2930 2930 releasefn=None,
2931 2931 acquirefn=self.invalidate,
2932 2932 desc=_(b'repository %s') % self.origroot,
2933 2933 )
2934 2934 self._lockref = weakref.ref(l)
2935 2935 return l
2936 2936
2937 2937 def wlock(self, wait=True):
2938 2938 """Lock the non-store parts of the repository (everything under
2939 2939 .hg except .hg/store) and return a weak reference to the lock.
2940 2940
2941 2941 Use this before modifying files in .hg.
2942 2942
2943 2943 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2944 2944 'wlock' first to avoid a dead-lock hazard."""
2945 2945 l = self._wlockref() if self._wlockref else None
2946 2946 if l is not None and l.held:
2947 2947 l.lock()
2948 2948 return l
2949 2949
2950 2950 # We do not need to check for non-waiting lock acquisition. Such
2951 2951 # acquisition would not cause dead-lock as they would just fail.
2952 2952 if wait and (
2953 2953 self.ui.configbool(b'devel', b'all-warnings')
2954 2954 or self.ui.configbool(b'devel', b'check-locks')
2955 2955 ):
2956 2956 if self._currentlock(self._lockref) is not None:
2957 2957 self.ui.develwarn(b'"wlock" acquired after "lock"')
2958 2958
2959 2959 def unlock():
2960 2960 if self.dirstate.pendingparentchange():
2961 2961 self.dirstate.invalidate()
2962 2962 else:
2963 2963 self.dirstate.write(None)
2964 2964
2965 2965 self._filecache[b'dirstate'].refresh()
2966 2966
2967 2967 l = self._lock(
2968 2968 self.vfs,
2969 2969 b"wlock",
2970 2970 wait,
2971 2971 unlock,
2972 2972 self.invalidatedirstate,
2973 2973 _(b'working directory of %s') % self.origroot,
2974 2974 )
2975 2975 self._wlockref = weakref.ref(l)
2976 2976 return l
2977 2977
2978 2978 def _currentlock(self, lockref):
2979 2979 """Returns the lock if it's held, or None if it's not."""
2980 2980 if lockref is None:
2981 2981 return None
2982 2982 l = lockref()
2983 2983 if l is None or not l.held:
2984 2984 return None
2985 2985 return l
2986 2986
2987 2987 def currentwlock(self):
2988 2988 """Returns the wlock if it's held, or None if it's not."""
2989 2989 return self._currentlock(self._wlockref)
2990 2990
2991 2991 def checkcommitpatterns(self, wctx, match, status, fail):
2992 2992 """check for commit arguments that aren't committable"""
2993 2993 if match.isexact() or match.prefix():
2994 2994 matched = set(status.modified + status.added + status.removed)
2995 2995
2996 2996 for f in match.files():
2997 2997 f = self.dirstate.normalize(f)
2998 2998 if f == b'.' or f in matched or f in wctx.substate:
2999 2999 continue
3000 3000 if f in status.deleted:
3001 3001 fail(f, _(b'file not found!'))
3002 3002 # Is it a directory that exists or used to exist?
3003 3003 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3004 3004 d = f + b'/'
3005 3005 for mf in matched:
3006 3006 if mf.startswith(d):
3007 3007 break
3008 3008 else:
3009 3009 fail(f, _(b"no match under directory!"))
3010 3010 elif f not in self.dirstate:
3011 3011 fail(f, _(b"file not tracked!"))
3012 3012
3013 3013 @unfilteredmethod
3014 3014 def commit(
3015 3015 self,
3016 3016 text=b"",
3017 3017 user=None,
3018 3018 date=None,
3019 3019 match=None,
3020 3020 force=False,
3021 3021 editor=None,
3022 3022 extra=None,
3023 3023 ):
3024 3024 """Add a new revision to current repository.
3025 3025
3026 3026 Revision information is gathered from the working directory,
3027 3027 match can be used to filter the committed files. If editor is
3028 3028 supplied, it is called to get a commit message.
3029 3029 """
3030 3030 if extra is None:
3031 3031 extra = {}
3032 3032
3033 3033 def fail(f, msg):
3034 3034 raise error.InputError(b'%s: %s' % (f, msg))
3035 3035
3036 3036 if not match:
3037 3037 match = matchmod.always()
3038 3038
3039 3039 if not force:
3040 3040 match.bad = fail
3041 3041
3042 3042 # lock() for recent changelog (see issue4368)
3043 3043 with self.wlock(), self.lock():
3044 3044 wctx = self[None]
3045 3045 merge = len(wctx.parents()) > 1
3046 3046
3047 3047 if not force and merge and not match.always():
3048 3048 raise error.Abort(
3049 3049 _(
3050 3050 b'cannot partially commit a merge '
3051 3051 b'(do not specify files or patterns)'
3052 3052 )
3053 3053 )
3054 3054
3055 3055 status = self.status(match=match, clean=force)
3056 3056 if force:
3057 3057 status.modified.extend(
3058 3058 status.clean
3059 3059 ) # mq may commit clean files
3060 3060
3061 3061 # check subrepos
3062 3062 subs, commitsubs, newstate = subrepoutil.precommit(
3063 3063 self.ui, wctx, status, match, force=force
3064 3064 )
3065 3065
3066 3066 # make sure all explicit patterns are matched
3067 3067 if not force:
3068 3068 self.checkcommitpatterns(wctx, match, status, fail)
3069 3069
3070 3070 cctx = context.workingcommitctx(
3071 3071 self, status, text, user, date, extra
3072 3072 )
3073 3073
3074 3074 ms = mergestatemod.mergestate.read(self)
3075 3075 mergeutil.checkunresolved(ms)
3076 3076
3077 3077 # internal config: ui.allowemptycommit
3078 3078 if cctx.isempty() and not self.ui.configbool(
3079 3079 b'ui', b'allowemptycommit'
3080 3080 ):
3081 3081 self.ui.debug(b'nothing to commit, clearing merge state\n')
3082 3082 ms.reset()
3083 3083 return None
3084 3084
3085 3085 if merge and cctx.deleted():
3086 3086 raise error.Abort(_(b"cannot commit merge with missing files"))
3087 3087
3088 3088 if editor:
3089 3089 cctx._text = editor(self, cctx, subs)
3090 3090 edited = text != cctx._text
3091 3091
3092 3092 # Save commit message in case this transaction gets rolled back
3093 3093 # (e.g. by a pretxncommit hook). Leave the content alone on
3094 3094 # the assumption that the user will use the same editor again.
3095 3095 msgfn = self.savecommitmessage(cctx._text)
3096 3096
3097 3097 # commit subs and write new state
3098 3098 if subs:
3099 3099 uipathfn = scmutil.getuipathfn(self)
3100 3100 for s in sorted(commitsubs):
3101 3101 sub = wctx.sub(s)
3102 3102 self.ui.status(
3103 3103 _(b'committing subrepository %s\n')
3104 3104 % uipathfn(subrepoutil.subrelpath(sub))
3105 3105 )
3106 3106 sr = sub.commit(cctx._text, user, date)
3107 3107 newstate[s] = (newstate[s][0], sr)
3108 3108 subrepoutil.writestate(self, newstate)
3109 3109
3110 3110 p1, p2 = self.dirstate.parents()
3111 3111 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3112 3112 try:
3113 3113 self.hook(
3114 3114 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3115 3115 )
3116 3116 with self.transaction(b'commit'):
3117 3117 ret = self.commitctx(cctx, True)
3118 3118 # update bookmarks, dirstate and mergestate
3119 3119 bookmarks.update(self, [p1, p2], ret)
3120 3120 cctx.markcommitted(ret)
3121 3121 ms.reset()
3122 3122 except: # re-raises
3123 3123 if edited:
3124 3124 self.ui.write(
3125 3125 _(b'note: commit message saved in %s\n') % msgfn
3126 3126 )
3127 3127 self.ui.write(
3128 3128 _(
3129 3129 b"note: use 'hg commit --logfile "
3130 3130 b".hg/last-message.txt --edit' to reuse it\n"
3131 3131 )
3132 3132 )
3133 3133 raise
3134 3134
3135 3135 def commithook(unused_success):
3136 3136 # hack for command that use a temporary commit (eg: histedit)
3137 3137 # temporary commit got stripped before hook release
3138 3138 if self.changelog.hasnode(ret):
3139 3139 self.hook(
3140 3140 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3141 3141 )
3142 3142
3143 3143 self._afterlock(commithook)
3144 3144 return ret
3145 3145
3146 3146 @unfilteredmethod
3147 3147 def commitctx(self, ctx, error=False, origctx=None):
3148 3148 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3149 3149
3150 3150 @unfilteredmethod
3151 3151 def destroying(self):
3152 3152 """Inform the repository that nodes are about to be destroyed.
3153 3153 Intended for use by strip and rollback, so there's a common
3154 3154 place for anything that has to be done before destroying history.
3155 3155
3156 3156 This is mostly useful for saving state that is in memory and waiting
3157 3157 to be flushed when the current lock is released. Because a call to
3158 3158 destroyed is imminent, the repo will be invalidated causing those
3159 3159 changes to stay in memory (waiting for the next unlock), or vanish
3160 3160 completely.
3161 3161 """
3162 3162 # When using the same lock to commit and strip, the phasecache is left
3163 3163 # dirty after committing. Then when we strip, the repo is invalidated,
3164 3164 # causing those changes to disappear.
3165 3165 if '_phasecache' in vars(self):
3166 3166 self._phasecache.write()
3167 3167
3168 3168 @unfilteredmethod
3169 3169 def destroyed(self):
3170 3170 """Inform the repository that nodes have been destroyed.
3171 3171 Intended for use by strip and rollback, so there's a common
3172 3172 place for anything that has to be done after destroying history.
3173 3173 """
3174 3174 # When one tries to:
3175 3175 # 1) destroy nodes thus calling this method (e.g. strip)
3176 3176 # 2) use phasecache somewhere (e.g. commit)
3177 3177 #
3178 3178 # then 2) will fail because the phasecache contains nodes that were
3179 3179 # removed. We can either remove phasecache from the filecache,
3180 3180 # causing it to reload next time it is accessed, or simply filter
3181 3181 # the removed nodes now and write the updated cache.
3182 3182 self._phasecache.filterunknown(self)
3183 3183 self._phasecache.write()
3184 3184
3185 3185 # refresh all repository caches
3186 3186 self.updatecaches()
3187 3187
3188 3188 # Ensure the persistent tag cache is updated. Doing it now
3189 3189 # means that the tag cache only has to worry about destroyed
3190 3190 # heads immediately after a strip/rollback. That in turn
3191 3191 # guarantees that "cachetip == currenttip" (comparing both rev
3192 3192 # and node) always means no nodes have been added or destroyed.
3193 3193
3194 3194 # XXX this is suboptimal when qrefresh'ing: we strip the current
3195 3195 # head, refresh the tag cache, then immediately add a new head.
3196 3196 # But I think doing it this way is necessary for the "instant
3197 3197 # tag cache retrieval" case to work.
3198 3198 self.invalidate()
3199 3199
3200 3200 def status(
3201 3201 self,
3202 3202 node1=b'.',
3203 3203 node2=None,
3204 3204 match=None,
3205 3205 ignored=False,
3206 3206 clean=False,
3207 3207 unknown=False,
3208 3208 listsubrepos=False,
3209 3209 ):
3210 3210 '''a convenience method that calls node1.status(node2)'''
3211 3211 return self[node1].status(
3212 3212 node2, match, ignored, clean, unknown, listsubrepos
3213 3213 )
3214 3214
3215 3215 def addpostdsstatus(self, ps):
3216 3216 """Add a callback to run within the wlock, at the point at which status
3217 3217 fixups happen.
3218 3218
3219 3219 On status completion, callback(wctx, status) will be called with the
3220 3220 wlock held, unless the dirstate has changed from underneath or the wlock
3221 3221 couldn't be grabbed.
3222 3222
3223 3223 Callbacks should not capture and use a cached copy of the dirstate --
3224 3224 it might change in the meanwhile. Instead, they should access the
3225 3225 dirstate via wctx.repo().dirstate.
3226 3226
3227 3227 This list is emptied out after each status run -- extensions should
3228 3228 make sure it adds to this list each time dirstate.status is called.
3229 3229 Extensions should also make sure they don't call this for statuses
3230 3230 that don't involve the dirstate.
3231 3231 """
3232 3232
3233 3233 # The list is located here for uniqueness reasons -- it is actually
3234 3234 # managed by the workingctx, but that isn't unique per-repo.
3235 3235 self._postdsstatus.append(ps)
3236 3236
3237 3237 def postdsstatus(self):
3238 3238 """Used by workingctx to get the list of post-dirstate-status hooks."""
3239 3239 return self._postdsstatus
3240 3240
3241 3241 def clearpostdsstatus(self):
3242 3242 """Used by workingctx to clear post-dirstate-status hooks."""
3243 3243 del self._postdsstatus[:]
3244 3244
3245 3245 def heads(self, start=None):
3246 3246 if start is None:
3247 3247 cl = self.changelog
3248 3248 headrevs = reversed(cl.headrevs())
3249 3249 return [cl.node(rev) for rev in headrevs]
3250 3250
3251 3251 heads = self.changelog.heads(start)
3252 3252 # sort the output in rev descending order
3253 3253 return sorted(heads, key=self.changelog.rev, reverse=True)
3254 3254
3255 3255 def branchheads(self, branch=None, start=None, closed=False):
3256 3256 """return a (possibly filtered) list of heads for the given branch
3257 3257
3258 3258 Heads are returned in topological order, from newest to oldest.
3259 3259 If branch is None, use the dirstate branch.
3260 3260 If start is not None, return only heads reachable from start.
3261 3261 If closed is True, return heads that are marked as closed as well.
3262 3262 """
3263 3263 if branch is None:
3264 3264 branch = self[None].branch()
3265 3265 branches = self.branchmap()
3266 3266 if not branches.hasbranch(branch):
3267 3267 return []
3268 3268 # the cache returns heads ordered lowest to highest
3269 3269 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3270 3270 if start is not None:
3271 3271 # filter out the heads that cannot be reached from startrev
3272 3272 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3273 3273 bheads = [h for h in bheads if h in fbheads]
3274 3274 return bheads
3275 3275
3276 3276 def branches(self, nodes):
3277 3277 if not nodes:
3278 3278 nodes = [self.changelog.tip()]
3279 3279 b = []
3280 3280 for n in nodes:
3281 3281 t = n
3282 3282 while True:
3283 3283 p = self.changelog.parents(n)
3284 3284 if p[1] != self.nullid or p[0] == self.nullid:
3285 3285 b.append((t, n, p[0], p[1]))
3286 3286 break
3287 3287 n = p[0]
3288 3288 return b
3289 3289
3290 3290 def between(self, pairs):
3291 3291 r = []
3292 3292
3293 3293 for top, bottom in pairs:
3294 3294 n, l, i = top, [], 0
3295 3295 f = 1
3296 3296
3297 3297 while n != bottom and n != self.nullid:
3298 3298 p = self.changelog.parents(n)[0]
3299 3299 if i == f:
3300 3300 l.append(n)
3301 3301 f = f * 2
3302 3302 n = p
3303 3303 i += 1
3304 3304
3305 3305 r.append(l)
3306 3306
3307 3307 return r
3308 3308
3309 3309 def checkpush(self, pushop):
3310 3310 """Extensions can override this function if additional checks have
3311 3311 to be performed before pushing, or call it if they override push
3312 3312 command.
3313 3313 """
3314 3314
3315 3315 @unfilteredpropertycache
3316 3316 def prepushoutgoinghooks(self):
3317 3317 """Return util.hooks consists of a pushop with repo, remote, outgoing
3318 3318 methods, which are called before pushing changesets.
3319 3319 """
3320 3320 return util.hooks()
3321 3321
3322 3322 def pushkey(self, namespace, key, old, new):
3323 3323 try:
3324 3324 tr = self.currenttransaction()
3325 3325 hookargs = {}
3326 3326 if tr is not None:
3327 3327 hookargs.update(tr.hookargs)
3328 3328 hookargs = pycompat.strkwargs(hookargs)
3329 3329 hookargs['namespace'] = namespace
3330 3330 hookargs['key'] = key
3331 3331 hookargs['old'] = old
3332 3332 hookargs['new'] = new
3333 3333 self.hook(b'prepushkey', throw=True, **hookargs)
3334 3334 except error.HookAbort as exc:
3335 3335 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3336 3336 if exc.hint:
3337 3337 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3338 3338 return False
3339 3339 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3340 3340 ret = pushkey.push(self, namespace, key, old, new)
3341 3341
3342 3342 def runhook(unused_success):
3343 3343 self.hook(
3344 3344 b'pushkey',
3345 3345 namespace=namespace,
3346 3346 key=key,
3347 3347 old=old,
3348 3348 new=new,
3349 3349 ret=ret,
3350 3350 )
3351 3351
3352 3352 self._afterlock(runhook)
3353 3353 return ret
3354 3354
3355 3355 def listkeys(self, namespace):
3356 3356 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3357 3357 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3358 3358 values = pushkey.list(self, namespace)
3359 3359 self.hook(b'listkeys', namespace=namespace, values=values)
3360 3360 return values
3361 3361
3362 3362 def debugwireargs(self, one, two, three=None, four=None, five=None):
3363 3363 '''used to test argument passing over the wire'''
3364 3364 return b"%s %s %s %s %s" % (
3365 3365 one,
3366 3366 two,
3367 3367 pycompat.bytestr(three),
3368 3368 pycompat.bytestr(four),
3369 3369 pycompat.bytestr(five),
3370 3370 )
3371 3371
3372 3372 def savecommitmessage(self, text):
3373 3373 fp = self.vfs(b'last-message.txt', b'wb')
3374 3374 try:
3375 3375 fp.write(text)
3376 3376 finally:
3377 3377 fp.close()
3378 3378 return self.pathto(fp.name[len(self.root) + 1 :])
3379 3379
3380 3380 def register_wanted_sidedata(self, category):
3381 3381 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3382 3382 # Only revlogv2 repos can want sidedata.
3383 3383 return
3384 3384 self._wanted_sidedata.add(pycompat.bytestr(category))
3385 3385
3386 3386 def register_sidedata_computer(
3387 3387 self, kind, category, keys, computer, flags, replace=False
3388 3388 ):
3389 3389 if kind not in revlogconst.ALL_KINDS:
3390 3390 msg = _(b"unexpected revlog kind '%s'.")
3391 3391 raise error.ProgrammingError(msg % kind)
3392 3392 category = pycompat.bytestr(category)
3393 3393 already_registered = category in self._sidedata_computers.get(kind, [])
3394 3394 if already_registered and not replace:
3395 3395 msg = _(
3396 3396 b"cannot register a sidedata computer twice for category '%s'."
3397 3397 )
3398 3398 raise error.ProgrammingError(msg % category)
3399 3399 if replace and not already_registered:
3400 3400 msg = _(
3401 3401 b"cannot replace a sidedata computer that isn't registered "
3402 3402 b"for category '%s'."
3403 3403 )
3404 3404 raise error.ProgrammingError(msg % category)
3405 3405 self._sidedata_computers.setdefault(kind, {})
3406 3406 self._sidedata_computers[kind][category] = (keys, computer, flags)
3407 3407
3408 3408
3409 3409 # used to avoid circular references so destructors work
3410 3410 def aftertrans(files):
3411 3411 renamefiles = [tuple(t) for t in files]
3412 3412
3413 3413 def a():
3414 3414 for vfs, src, dest in renamefiles:
3415 3415 # if src and dest refer to a same file, vfs.rename is a no-op,
3416 3416 # leaving both src and dest on disk. delete dest to make sure
3417 3417 # the rename couldn't be such a no-op.
3418 3418 vfs.tryunlink(dest)
3419 3419 try:
3420 3420 vfs.rename(src, dest)
3421 3421 except OSError: # journal file does not yet exist
3422 3422 pass
3423 3423
3424 3424 return a
3425 3425
3426 3426
3427 3427 def undoname(fn):
3428 3428 base, name = os.path.split(fn)
3429 3429 assert name.startswith(b'journal')
3430 3430 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3431 3431
3432 3432
3433 3433 def instance(ui, path, create, intents=None, createopts=None):
3434 3434 localpath = urlutil.urllocalpath(path)
3435 3435 if create:
3436 3436 createrepository(ui, localpath, createopts=createopts)
3437 3437
3438 3438 return makelocalrepository(ui, localpath, intents=intents)
3439 3439
3440 3440
3441 3441 def islocal(path):
3442 3442 return True
3443 3443
3444 3444
3445 3445 def defaultcreateopts(ui, createopts=None):
3446 3446 """Populate the default creation options for a repository.
3447 3447
3448 3448 A dictionary of explicitly requested creation options can be passed
3449 3449 in. Missing keys will be populated.
3450 3450 """
3451 3451 createopts = dict(createopts or {})
3452 3452
3453 3453 if b'backend' not in createopts:
3454 3454 # experimental config: storage.new-repo-backend
3455 3455 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3456 3456
3457 3457 return createopts
3458 3458
3459 3459
3460 3460 def newreporequirements(ui, createopts):
3461 3461 """Determine the set of requirements for a new local repository.
3462 3462
3463 3463 Extensions can wrap this function to specify custom requirements for
3464 3464 new repositories.
3465 3465 """
3466 3466 # If the repo is being created from a shared repository, we copy
3467 3467 # its requirements.
3468 3468 if b'sharedrepo' in createopts:
3469 3469 requirements = set(createopts[b'sharedrepo'].requirements)
3470 3470 if createopts.get(b'sharedrelative'):
3471 3471 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3472 3472 else:
3473 3473 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3474 3474
3475 3475 return requirements
3476 3476
3477 3477 if b'backend' not in createopts:
3478 3478 raise error.ProgrammingError(
3479 3479 b'backend key not present in createopts; '
3480 3480 b'was defaultcreateopts() called?'
3481 3481 )
3482 3482
3483 3483 if createopts[b'backend'] != b'revlogv1':
3484 3484 raise error.Abort(
3485 3485 _(
3486 3486 b'unable to determine repository requirements for '
3487 3487 b'storage backend: %s'
3488 3488 )
3489 3489 % createopts[b'backend']
3490 3490 )
3491 3491
3492 3492 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3493 3493 if ui.configbool(b'format', b'usestore'):
3494 3494 requirements.add(requirementsmod.STORE_REQUIREMENT)
3495 3495 if ui.configbool(b'format', b'usefncache'):
3496 3496 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3497 3497 if ui.configbool(b'format', b'dotencode'):
3498 3498 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3499 3499
3500 3500 compengines = ui.configlist(b'format', b'revlog-compression')
3501 3501 for compengine in compengines:
3502 3502 if compengine in util.compengines:
3503 3503 engine = util.compengines[compengine]
3504 3504 if engine.available() and engine.revlogheader():
3505 3505 break
3506 3506 else:
3507 3507 raise error.Abort(
3508 3508 _(
3509 3509 b'compression engines %s defined by '
3510 3510 b'format.revlog-compression not available'
3511 3511 )
3512 3512 % b', '.join(b'"%s"' % e for e in compengines),
3513 3513 hint=_(
3514 3514 b'run "hg debuginstall" to list available '
3515 3515 b'compression engines'
3516 3516 ),
3517 3517 )
3518 3518
3519 3519 # zlib is the historical default and doesn't need an explicit requirement.
3520 3520 if compengine == b'zstd':
3521 3521 requirements.add(b'revlog-compression-zstd')
3522 3522 elif compengine != b'zlib':
3523 3523 requirements.add(b'exp-compression-%s' % compengine)
3524 3524
3525 3525 if scmutil.gdinitconfig(ui):
3526 3526 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3527 3527 if ui.configbool(b'format', b'sparse-revlog'):
3528 3528 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3529 3529
3530 3530 # experimental config: format.exp-use-copies-side-data-changeset
3531 3531 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3532 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3533 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3532 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3534 3533 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3535 3534 if ui.configbool(b'experimental', b'treemanifest'):
3536 3535 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3537 3536
3538 3537 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3539 3538 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3540 3539 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3541 3540
3542 3541 revlogv2 = ui.config(b'experimental', b'revlogv2')
3543 3542 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3544 3543 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3545 3544 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3546 3545 # experimental config: format.internal-phase
3547 3546 if ui.configbool(b'format', b'internal-phase'):
3548 3547 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3549 3548
3550 3549 if createopts.get(b'narrowfiles'):
3551 3550 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3552 3551
3553 3552 if createopts.get(b'lfs'):
3554 3553 requirements.add(b'lfs')
3555 3554
3556 3555 if ui.configbool(b'format', b'bookmarks-in-store'):
3557 3556 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3558 3557
3559 3558 if ui.configbool(b'format', b'use-persistent-nodemap'):
3560 3559 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3561 3560
3562 3561 # if share-safe is enabled, let's create the new repository with the new
3563 3562 # requirement
3564 3563 if ui.configbool(b'format', b'use-share-safe'):
3565 3564 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3566 3565
3567 3566 return requirements
3568 3567
3569 3568
3570 3569 def checkrequirementscompat(ui, requirements):
3571 3570 """Checks compatibility of repository requirements enabled and disabled.
3572 3571
3573 3572 Returns a set of requirements which needs to be dropped because dependend
3574 3573 requirements are not enabled. Also warns users about it"""
3575 3574
3576 3575 dropped = set()
3577 3576
3578 3577 if requirementsmod.STORE_REQUIREMENT not in requirements:
3579 3578 if bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3580 3579 ui.warn(
3581 3580 _(
3582 3581 b'ignoring enabled \'format.bookmarks-in-store\' config '
3583 3582 b'beacuse it is incompatible with disabled '
3584 3583 b'\'format.usestore\' config\n'
3585 3584 )
3586 3585 )
3587 3586 dropped.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT)
3588 3587
3589 3588 if (
3590 3589 requirementsmod.SHARED_REQUIREMENT in requirements
3591 3590 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3592 3591 ):
3593 3592 raise error.Abort(
3594 3593 _(
3595 3594 b"cannot create shared repository as source was created"
3596 3595 b" with 'format.usestore' config disabled"
3597 3596 )
3598 3597 )
3599 3598
3600 3599 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3601 3600 ui.warn(
3602 3601 _(
3603 3602 b"ignoring enabled 'format.use-share-safe' config because "
3604 3603 b"it is incompatible with disabled 'format.usestore'"
3605 3604 b" config\n"
3606 3605 )
3607 3606 )
3608 3607 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3609 3608
3610 3609 return dropped
3611 3610
3612 3611
3613 3612 def filterknowncreateopts(ui, createopts):
3614 3613 """Filters a dict of repo creation options against options that are known.
3615 3614
3616 3615 Receives a dict of repo creation options and returns a dict of those
3617 3616 options that we don't know how to handle.
3618 3617
3619 3618 This function is called as part of repository creation. If the
3620 3619 returned dict contains any items, repository creation will not
3621 3620 be allowed, as it means there was a request to create a repository
3622 3621 with options not recognized by loaded code.
3623 3622
3624 3623 Extensions can wrap this function to filter out creation options
3625 3624 they know how to handle.
3626 3625 """
3627 3626 known = {
3628 3627 b'backend',
3629 3628 b'lfs',
3630 3629 b'narrowfiles',
3631 3630 b'sharedrepo',
3632 3631 b'sharedrelative',
3633 3632 b'shareditems',
3634 3633 b'shallowfilestore',
3635 3634 }
3636 3635
3637 3636 return {k: v for k, v in createopts.items() if k not in known}
3638 3637
3639 3638
3640 3639 def createrepository(ui, path, createopts=None):
3641 3640 """Create a new repository in a vfs.
3642 3641
3643 3642 ``path`` path to the new repo's working directory.
3644 3643 ``createopts`` options for the new repository.
3645 3644
3646 3645 The following keys for ``createopts`` are recognized:
3647 3646
3648 3647 backend
3649 3648 The storage backend to use.
3650 3649 lfs
3651 3650 Repository will be created with ``lfs`` requirement. The lfs extension
3652 3651 will automatically be loaded when the repository is accessed.
3653 3652 narrowfiles
3654 3653 Set up repository to support narrow file storage.
3655 3654 sharedrepo
3656 3655 Repository object from which storage should be shared.
3657 3656 sharedrelative
3658 3657 Boolean indicating if the path to the shared repo should be
3659 3658 stored as relative. By default, the pointer to the "parent" repo
3660 3659 is stored as an absolute path.
3661 3660 shareditems
3662 3661 Set of items to share to the new repository (in addition to storage).
3663 3662 shallowfilestore
3664 3663 Indicates that storage for files should be shallow (not all ancestor
3665 3664 revisions are known).
3666 3665 """
3667 3666 createopts = defaultcreateopts(ui, createopts=createopts)
3668 3667
3669 3668 unknownopts = filterknowncreateopts(ui, createopts)
3670 3669
3671 3670 if not isinstance(unknownopts, dict):
3672 3671 raise error.ProgrammingError(
3673 3672 b'filterknowncreateopts() did not return a dict'
3674 3673 )
3675 3674
3676 3675 if unknownopts:
3677 3676 raise error.Abort(
3678 3677 _(
3679 3678 b'unable to create repository because of unknown '
3680 3679 b'creation option: %s'
3681 3680 )
3682 3681 % b', '.join(sorted(unknownopts)),
3683 3682 hint=_(b'is a required extension not loaded?'),
3684 3683 )
3685 3684
3686 3685 requirements = newreporequirements(ui, createopts=createopts)
3687 3686 requirements -= checkrequirementscompat(ui, requirements)
3688 3687
3689 3688 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3690 3689
3691 3690 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3692 3691 if hgvfs.exists():
3693 3692 raise error.RepoError(_(b'repository %s already exists') % path)
3694 3693
3695 3694 if b'sharedrepo' in createopts:
3696 3695 sharedpath = createopts[b'sharedrepo'].sharedpath
3697 3696
3698 3697 if createopts.get(b'sharedrelative'):
3699 3698 try:
3700 3699 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3701 3700 sharedpath = util.pconvert(sharedpath)
3702 3701 except (IOError, ValueError) as e:
3703 3702 # ValueError is raised on Windows if the drive letters differ
3704 3703 # on each path.
3705 3704 raise error.Abort(
3706 3705 _(b'cannot calculate relative path'),
3707 3706 hint=stringutil.forcebytestr(e),
3708 3707 )
3709 3708
3710 3709 if not wdirvfs.exists():
3711 3710 wdirvfs.makedirs()
3712 3711
3713 3712 hgvfs.makedir(notindexed=True)
3714 3713 if b'sharedrepo' not in createopts:
3715 3714 hgvfs.mkdir(b'cache')
3716 3715 hgvfs.mkdir(b'wcache')
3717 3716
3718 3717 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3719 3718 if has_store and b'sharedrepo' not in createopts:
3720 3719 hgvfs.mkdir(b'store')
3721 3720
3722 3721 # We create an invalid changelog outside the store so very old
3723 3722 # Mercurial versions (which didn't know about the requirements
3724 3723 # file) encounter an error on reading the changelog. This
3725 3724 # effectively locks out old clients and prevents them from
3726 3725 # mucking with a repo in an unknown format.
3727 3726 #
3728 3727 # The revlog header has version 65535, which won't be recognized by
3729 3728 # such old clients.
3730 3729 hgvfs.append(
3731 3730 b'00changelog.i',
3732 3731 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3733 3732 b'layout',
3734 3733 )
3735 3734
3736 3735 # Filter the requirements into working copy and store ones
3737 3736 wcreq, storereq = scmutil.filterrequirements(requirements)
3738 3737 # write working copy ones
3739 3738 scmutil.writerequires(hgvfs, wcreq)
3740 3739 # If there are store requirements and the current repository
3741 3740 # is not a shared one, write stored requirements
3742 3741 # For new shared repository, we don't need to write the store
3743 3742 # requirements as they are already present in store requires
3744 3743 if storereq and b'sharedrepo' not in createopts:
3745 3744 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3746 3745 scmutil.writerequires(storevfs, storereq)
3747 3746
3748 3747 # Write out file telling readers where to find the shared store.
3749 3748 if b'sharedrepo' in createopts:
3750 3749 hgvfs.write(b'sharedpath', sharedpath)
3751 3750
3752 3751 if createopts.get(b'shareditems'):
3753 3752 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3754 3753 hgvfs.write(b'shared', shared)
3755 3754
3756 3755
3757 3756 def poisonrepository(repo):
3758 3757 """Poison a repository instance so it can no longer be used."""
3759 3758 # Perform any cleanup on the instance.
3760 3759 repo.close()
3761 3760
3762 3761 # Our strategy is to replace the type of the object with one that
3763 3762 # has all attribute lookups result in error.
3764 3763 #
3765 3764 # But we have to allow the close() method because some constructors
3766 3765 # of repos call close() on repo references.
3767 3766 class poisonedrepository(object):
3768 3767 def __getattribute__(self, item):
3769 3768 if item == 'close':
3770 3769 return object.__getattribute__(self, item)
3771 3770
3772 3771 raise error.ProgrammingError(
3773 3772 b'repo instances should not be used after unshare'
3774 3773 )
3775 3774
3776 3775 def close(self):
3777 3776 pass
3778 3777
3779 3778 # We may have a repoview, which intercepts __setattr__. So be sure
3780 3779 # we operate at the lowest level possible.
3781 3780 object.__setattr__(repo, '__class__', poisonedrepository)
@@ -1,3874 +1,3872 b''
1 1 #testcases filelog compatibility changeset sidedata upgraded upgraded-parallel pull push pull-upgrade push-upgrade
2 2
3 3 =====================================================
4 4 Test Copy tracing for chain of copies involving merge
5 5 =====================================================
6 6
7 7 This test files covers copies/rename case for a chains of commit where merges
8 8 are involved. It cheks we do not have unwanted update of behavior and that the
9 9 different options to retrieve copies behave correctly.
10 10
11 11
12 12 Setup
13 13 =====
14 14
15 15 use git diff to see rename
16 16
17 17 $ cat << EOF >> ./no-linkrev
18 18 > #!$PYTHON
19 19 > # filter out linkrev part of the debugindex command
20 20 > import sys
21 21 > for line in sys.stdin:
22 22 > if " linkrev " in line:
23 23 > print(line.rstrip())
24 24 > else:
25 25 > l = "%s *%s" % (line[:6], line[14:].rstrip())
26 26 > print(l)
27 27 > EOF
28 28
29 29 $ cat << EOF >> $HGRCPATH
30 30 > [diff]
31 31 > git=yes
32 32 > [command-templates]
33 33 > log={desc}\n
34 34 > EOF
35 35
36 36 #if compatibility
37 37 $ cat >> $HGRCPATH << EOF
38 38 > [experimental]
39 39 > copies.read-from = compatibility
40 40 > EOF
41 41 #endif
42 42
43 43 #if changeset
44 44 $ cat >> $HGRCPATH << EOF
45 45 > [experimental]
46 46 > copies.read-from = changeset-only
47 47 > copies.write-to = changeset-only
48 48 > EOF
49 49 #endif
50 50
51 51 #if sidedata
52 52 $ cat >> $HGRCPATH << EOF
53 53 > [format]
54 54 > exp-use-copies-side-data-changeset = yes
55 55 > EOF
56 56 #endif
57 57
58 58 #if pull
59 59 $ cat >> $HGRCPATH << EOF
60 60 > [format]
61 61 > exp-use-copies-side-data-changeset = yes
62 62 > EOF
63 63 #endif
64 64
65 65 #if push
66 66 $ cat >> $HGRCPATH << EOF
67 67 > [format]
68 68 > exp-use-copies-side-data-changeset = yes
69 69 > EOF
70 70 #endif
71 71
72 72 #if pull-upgrade
73 73 $ cat >> $HGRCPATH << EOF
74 74 > [format]
75 75 > exp-use-copies-side-data-changeset = no
76 76 > [experimental]
77 77 > changegroup4 = yes
78 78 > EOF
79 79 #endif
80 80
81 81 #if push-upgrade
82 82 $ cat >> $HGRCPATH << EOF
83 83 > [format]
84 84 > exp-use-copies-side-data-changeset = no
85 85 > [experimental]
86 86 > changegroup4 = yes
87 87 > EOF
88 88 #endif
89 89
90 90 $ cat > same-content.txt << EOF
91 91 > Here is some content that will be the same accros multiple file.
92 92 >
93 93 > This is done on purpose so that we end up in some merge situation, were the
94 94 > resulting content is the same as in the parent(s), but a new filenodes still
95 95 > need to be created to record some file history information (especially
96 96 > about copies).
97 97 > EOF
98 98
99 99 $ hg init repo-chain
100 100 $ cd repo-chain
101 101
102 102 Add some linear rename initialy
103 103
104 104 $ cp ../same-content.txt a
105 105 $ cp ../same-content.txt b
106 106 $ cp ../same-content.txt h
107 107 $ echo "original content for P" > p
108 108 $ echo "original content for Q" > q
109 109 $ echo "original content for R" > r
110 110 $ hg ci -Am 'i-0 initial commit: a b h p q r'
111 111 adding a
112 112 adding b
113 113 adding h
114 114 adding p
115 115 adding q
116 116 adding r
117 117 $ hg mv a c
118 118 $ hg mv p s
119 119 $ hg ci -Am 'i-1: a -move-> c, p -move-> s'
120 120 $ hg mv c d
121 121 $ hg mv s t
122 122 $ hg ci -Am 'i-2: c -move-> d, s -move-> t'
123 123 $ hg log -G
124 124 @ i-2: c -move-> d, s -move-> t
125 125 |
126 126 o i-1: a -move-> c, p -move-> s
127 127 |
128 128 o i-0 initial commit: a b h p q r
129 129
130 130
131 131 And having another branch with renames on the other side
132 132
133 133 $ hg mv d e
134 134 $ hg ci -Am 'a-1: d -move-> e'
135 135 $ hg mv e f
136 136 $ hg ci -Am 'a-2: e -move-> f'
137 137 $ hg log -G --rev '::.'
138 138 @ a-2: e -move-> f
139 139 |
140 140 o a-1: d -move-> e
141 141 |
142 142 o i-2: c -move-> d, s -move-> t
143 143 |
144 144 o i-1: a -move-> c, p -move-> s
145 145 |
146 146 o i-0 initial commit: a b h p q r
147 147
148 148
149 149 Have a branching with nothing on one side
150 150
151 151 $ hg up 'desc("i-2")'
152 152 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
153 153 $ echo foo > b
154 154 $ hg ci -m 'b-1: b update'
155 155 created new head
156 156 $ hg log -G --rev '::.'
157 157 @ b-1: b update
158 158 |
159 159 o i-2: c -move-> d, s -move-> t
160 160 |
161 161 o i-1: a -move-> c, p -move-> s
162 162 |
163 163 o i-0 initial commit: a b h p q r
164 164
165 165
166 166 Create a branch that delete a file previous renamed
167 167
168 168 $ hg up 'desc("i-2")'
169 169 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
170 170 $ hg rm d
171 171 $ hg ci -m 'c-1 delete d'
172 172 created new head
173 173 $ hg log -G --rev '::.'
174 174 @ c-1 delete d
175 175 |
176 176 o i-2: c -move-> d, s -move-> t
177 177 |
178 178 o i-1: a -move-> c, p -move-> s
179 179 |
180 180 o i-0 initial commit: a b h p q r
181 181
182 182
183 183 Create a branch that delete a file previous renamed and recreate it
184 184
185 185 $ hg up 'desc("i-2")'
186 186 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
187 187 $ hg rm d
188 188 $ hg ci -m 'd-1 delete d'
189 189 created new head
190 190 $ echo bar > d
191 191 $ hg add d
192 192 $ hg ci -m 'd-2 re-add d'
193 193 $ hg log -G --rev '::.'
194 194 @ d-2 re-add d
195 195 |
196 196 o d-1 delete d
197 197 |
198 198 o i-2: c -move-> d, s -move-> t
199 199 |
200 200 o i-1: a -move-> c, p -move-> s
201 201 |
202 202 o i-0 initial commit: a b h p q r
203 203
204 204
205 205 Having another branch renaming a different file to the same filename as another
206 206
207 207 $ hg up 'desc("i-2")'
208 208 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
209 209 $ hg mv b g
210 210 $ hg ci -m 'e-1 b -move-> g'
211 211 created new head
212 212 $ hg mv g f
213 213 $ hg ci -m 'e-2 g -move-> f'
214 214 $ hg log -G --rev '::.'
215 215 @ e-2 g -move-> f
216 216 |
217 217 o e-1 b -move-> g
218 218 |
219 219 o i-2: c -move-> d, s -move-> t
220 220 |
221 221 o i-1: a -move-> c, p -move-> s
222 222 |
223 223 o i-0 initial commit: a b h p q r
224 224
225 225 $ hg up -q null
226 226
227 227 Having a branch similar to the 'a' one, but moving the 'p' file around.
228 228
229 229 $ hg up 'desc("i-2")'
230 230 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
231 231 $ hg mv t u
232 232 $ hg ci -Am 'p-1: t -move-> u'
233 233 created new head
234 234 $ hg mv u v
235 235 $ hg ci -Am 'p-2: u -move-> v'
236 236 $ hg log -G --rev '::.'
237 237 @ p-2: u -move-> v
238 238 |
239 239 o p-1: t -move-> u
240 240 |
241 241 o i-2: c -move-> d, s -move-> t
242 242 |
243 243 o i-1: a -move-> c, p -move-> s
244 244 |
245 245 o i-0 initial commit: a b h p q r
246 246
247 247 $ hg up -q null
248 248
249 249 Having another branch renaming a different file to the same filename as another
250 250
251 251 $ hg up 'desc("i-2")'
252 252 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
253 253 $ hg mv r w
254 254 $ hg ci -m 'q-1 r -move-> w'
255 255 created new head
256 256 $ hg mv w v
257 257 $ hg ci -m 'q-2 w -move-> v'
258 258 $ hg log -G --rev '::.'
259 259 @ q-2 w -move-> v
260 260 |
261 261 o q-1 r -move-> w
262 262 |
263 263 o i-2: c -move-> d, s -move-> t
264 264 |
265 265 o i-1: a -move-> c, p -move-> s
266 266 |
267 267 o i-0 initial commit: a b h p q r
268 268
269 269 $ hg up -q null
270 270
271 271 Setup all merge
272 272 ===============
273 273
274 274 This is done beforehand to validate that the upgrade process creates valid copy
275 275 information.
276 276
277 277 merging with unrelated change does not interfere with the renames
278 278 ---------------------------------------------------------------
279 279
280 280 - rename on one side
281 281 - unrelated change on the other side
282 282
283 283 $ case_desc="simple merge - A side: multiple renames, B side: unrelated update"
284 284
285 285 $ hg up 'desc("b-1")'
286 286 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
287 287 $ hg merge 'desc("a-2")'
288 288 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
289 289 (branch merge, don't forget to commit)
290 290 $ hg ci -m "mBAm-0 $case_desc - one way"
291 291 $ hg up 'desc("a-2")'
292 292 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
293 293 $ hg merge 'desc("b-1")'
294 294 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
295 295 (branch merge, don't forget to commit)
296 296 $ hg ci -m "mABm-0 $case_desc - the other way"
297 297 created new head
298 298 $ hg log -G --rev '::(desc("mABm")+desc("mBAm"))'
299 299 @ mABm-0 simple merge - A side: multiple renames, B side: unrelated update - the other way
300 300 |\
301 301 +---o mBAm-0 simple merge - A side: multiple renames, B side: unrelated update - one way
302 302 | |/
303 303 | o b-1: b update
304 304 | |
305 305 o | a-2: e -move-> f
306 306 | |
307 307 o | a-1: d -move-> e
308 308 |/
309 309 o i-2: c -move-> d, s -move-> t
310 310 |
311 311 o i-1: a -move-> c, p -move-> s
312 312 |
313 313 o i-0 initial commit: a b h p q r
314 314
315 315
316 316
317 317 merging with the side having a delete
318 318 -------------------------------------
319 319
320 320 case summary:
321 321 - one with change to an unrelated file
322 322 - one deleting the change
323 323 and recreate an unrelated file after the merge
324 324
325 325 $ case_desc="simple merge - C side: delete a file with copies history , B side: unrelated update"
326 326
327 327 $ hg up 'desc("b-1")'
328 328 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
329 329 $ hg merge 'desc("c-1")'
330 330 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
331 331 (branch merge, don't forget to commit)
332 332 $ hg ci -m "mBCm-0 $case_desc - one way"
333 333 $ echo bar > d
334 334 $ hg add d
335 335 $ hg ci -m 'mBCm-1 re-add d'
336 336 $ hg up 'desc("c-1")'
337 337 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
338 338 $ hg merge 'desc("b-1")'
339 339 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
340 340 (branch merge, don't forget to commit)
341 341 $ hg ci -m "mCBm-0 $case_desc - the other way"
342 342 created new head
343 343 $ echo bar > d
344 344 $ hg add d
345 345 $ hg ci -m 'mCBm-1 re-add d'
346 346 $ hg log -G --rev '::(desc("mCBm")+desc("mBCm"))'
347 347 @ mCBm-1 re-add d
348 348 |
349 349 o mCBm-0 simple merge - C side: delete a file with copies history , B side: unrelated update - the other way
350 350 |\
351 351 | | o mBCm-1 re-add d
352 352 | | |
353 353 +---o mBCm-0 simple merge - C side: delete a file with copies history , B side: unrelated update - one way
354 354 | |/
355 355 | o c-1 delete d
356 356 | |
357 357 o | b-1: b update
358 358 |/
359 359 o i-2: c -move-> d, s -move-> t
360 360 |
361 361 o i-1: a -move-> c, p -move-> s
362 362 |
363 363 o i-0 initial commit: a b h p q r
364 364
365 365
366 366 Comparing with a merge re-adding the file afterward
367 367 ---------------------------------------------------
368 368
369 369 Merge:
370 370 - one with change to an unrelated file
371 371 - one deleting and recreating the change
372 372
373 373 $ case_desc="simple merge - B side: unrelated update, D side: delete and recreate a file (with different content)"
374 374
375 375 $ hg up 'desc("b-1")'
376 376 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
377 377 $ hg merge 'desc("d-2")'
378 378 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
379 379 (branch merge, don't forget to commit)
380 380 $ hg ci -m "mBDm-0 $case_desc - one way"
381 381 $ hg up 'desc("d-2")'
382 382 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
383 383 $ hg merge 'desc("b-1")'
384 384 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
385 385 (branch merge, don't forget to commit)
386 386 $ hg ci -m "mDBm-0 $case_desc - the other way"
387 387 created new head
388 388 $ hg log -G --rev '::(desc("mDBm")+desc("mBDm"))'
389 389 @ mDBm-0 simple merge - B side: unrelated update, D side: delete and recreate a file (with different content) - the other way
390 390 |\
391 391 +---o mBDm-0 simple merge - B side: unrelated update, D side: delete and recreate a file (with different content) - one way
392 392 | |/
393 393 | o d-2 re-add d
394 394 | |
395 395 | o d-1 delete d
396 396 | |
397 397 o | b-1: b update
398 398 |/
399 399 o i-2: c -move-> d, s -move-> t
400 400 |
401 401 o i-1: a -move-> c, p -move-> s
402 402 |
403 403 o i-0 initial commit: a b h p q r
404 404
405 405
406 406
407 407 Comparing with a merge with colliding rename
408 408 --------------------------------------------
409 409
410 410 Subcase: new copy information on both side
411 411 ``````````````````````````````````````````
412 412
413 413 - the "e-" branch renaming b to f (through 'g')
414 414 - the "a-" branch renaming d to f (through e)
415 415
416 416 $ case_desc="merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f)"
417 417
418 418 $ hg up 'desc("a-2")'
419 419 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
420 420 $ hg merge 'desc("e-2")'
421 421 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
422 422 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
423 423 (branch merge, don't forget to commit)
424 424 $ hg ci -m "mAEm-0 $case_desc - one way"
425 425 $ hg up 'desc("e-2")'
426 426 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-changeset !)
427 427 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (changeset !)
428 428 $ hg merge 'desc("a-2")'
429 429 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
430 430 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
431 431 (branch merge, don't forget to commit)
432 432 $ hg ci -m "mEAm-0 $case_desc - the other way"
433 433 created new head
434 434 $ hg log -G --rev '::(desc("mAEm")+desc("mEAm"))'
435 435 @ mEAm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - the other way
436 436 |\
437 437 +---o mAEm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - one way
438 438 | |/
439 439 | o e-2 g -move-> f
440 440 | |
441 441 | o e-1 b -move-> g
442 442 | |
443 443 o | a-2: e -move-> f
444 444 | |
445 445 o | a-1: d -move-> e
446 446 |/
447 447 o i-2: c -move-> d, s -move-> t
448 448 |
449 449 o i-1: a -move-> c, p -move-> s
450 450 |
451 451 o i-0 initial commit: a b h p q r
452 452
453 453
454 454 Subcase: new copy information on both side with an actual merge happening
455 455 `````````````````````````````````````````````````````````````````````````
456 456
457 457 - the "p-" branch renaming 't' to 'v' (through 'u')
458 458 - the "q-" branch renaming 'r' to 'v' (through 'w')
459 459
460 460 $ case_desc="merge with copies info on both side - P side: rename t to v, Q side: r to v, (different content)"
461 461
462 462 $ hg up 'desc("p-2")'
463 463 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
464 464 $ hg merge 'desc("q-2")' --tool ':union'
465 465 merging v
466 466 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
467 467 (branch merge, don't forget to commit)
468 468 $ hg ci -m "mPQm-0 $case_desc - one way"
469 469 $ hg up 'desc("q-2")'
470 470 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
471 471 $ hg merge 'desc("p-2")' --tool ':union'
472 472 merging v
473 473 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
474 474 (branch merge, don't forget to commit)
475 475 $ hg ci -m "mQPm-0 $case_desc - the other way"
476 476 created new head
477 477 $ hg log -G --rev '::(desc("mAEm")+desc("mEAm"))'
478 478 o mEAm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - the other way
479 479 |\
480 480 +---o mAEm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - one way
481 481 | |/
482 482 | o e-2 g -move-> f
483 483 | |
484 484 | o e-1 b -move-> g
485 485 | |
486 486 o | a-2: e -move-> f
487 487 | |
488 488 o | a-1: d -move-> e
489 489 |/
490 490 o i-2: c -move-> d, s -move-> t
491 491 |
492 492 o i-1: a -move-> c, p -move-> s
493 493 |
494 494 o i-0 initial commit: a b h p q r
495 495
496 496
497 497 Subcase: existing copy information overwritten on one branch
498 498 ````````````````````````````````````````````````````````````
499 499
500 500 Merge:
501 501 - one with change to an unrelated file (b)
502 502 - one overwriting a file (d) with a rename (from h to i to d)
503 503
504 504 $ case_desc="simple merge - B side: unrelated change, F side: overwrite d with a copy (from h->i->d)"
505 505
506 506 $ hg up 'desc("i-2")'
507 507 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
508 508 $ hg mv h i
509 509 $ hg commit -m "f-1: rename h -> i"
510 510 created new head
511 511 $ hg mv --force i d
512 512 $ hg commit -m "f-2: rename i -> d"
513 513 $ hg debugindex d | "$PYTHON" ../no-linkrev
514 514 rev linkrev nodeid p1 p2
515 515 0 * d8252ab2e760 000000000000 000000000000 (no-changeset !)
516 516 0 * ae258f702dfe 000000000000 000000000000 (changeset !)
517 517 1 * b004912a8510 000000000000 000000000000
518 518 2 * 7b79e2fe0c89 000000000000 000000000000 (no-changeset !)
519 519 $ hg up 'desc("b-1")'
520 520 3 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-changeset !)
521 521 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (changeset !)
522 522 $ hg merge 'desc("f-2")'
523 523 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
524 524 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
525 525 (branch merge, don't forget to commit)
526 526 $ hg ci -m "mBFm-0 $case_desc - one way"
527 527 $ hg up 'desc("f-2")'
528 528 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
529 529 $ hg merge 'desc("b-1")'
530 530 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
531 531 (branch merge, don't forget to commit)
532 532 $ hg ci -m "mFBm-0 $case_desc - the other way"
533 533 created new head
534 534 $ hg up null --quiet
535 535 $ hg log -G --rev '::(desc("mBFm")+desc("mFBm"))'
536 536 o mFBm-0 simple merge - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - the other way
537 537 |\
538 538 +---o mBFm-0 simple merge - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - one way
539 539 | |/
540 540 | o f-2: rename i -> d
541 541 | |
542 542 | o f-1: rename h -> i
543 543 | |
544 544 o | b-1: b update
545 545 |/
546 546 o i-2: c -move-> d, s -move-> t
547 547 |
548 548 o i-1: a -move-> c, p -move-> s
549 549 |
550 550 o i-0 initial commit: a b h p q r
551 551
552 552
553 553 Subcase: existing copy information overwritten on one branch, with different content)
554 554 `````````````````````````````````````````````````````````````````````````````````````
555 555
556 556 Merge:
557 557 - one with change to an unrelated file (b)
558 558 - one overwriting a file (t) with a rename (from r to x to t), v content is not the same as on the other branch
559 559
560 560 $ case_desc="simple merge - B side: unrelated change, R side: overwrite d with a copy (from r->x->t) different content"
561 561
562 562 $ hg up 'desc("i-2")'
563 563 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
564 564 $ hg mv r x
565 565 $ hg commit -m "r-1: rename r -> x"
566 566 created new head
567 567 $ hg mv --force x t
568 568 $ hg commit -m "r-2: rename t -> x"
569 569 $ hg debugindex t | "$PYTHON" ../no-linkrev
570 570 rev linkrev nodeid p1 p2
571 571 0 * d74efbf65309 000000000000 000000000000 (no-changeset !)
572 572 1 * 02a930b9d7ad 000000000000 000000000000 (no-changeset !)
573 573 0 * 5aed6a8dbff0 000000000000 000000000000 (changeset !)
574 574 1 * a38b2fa17021 000000000000 000000000000 (changeset !)
575 575 $ hg up 'desc("b-1")'
576 576 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
577 577 $ hg merge 'desc("r-2")'
578 578 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
579 579 (branch merge, don't forget to commit)
580 580 $ hg ci -m "mBRm-0 $case_desc - one way"
581 581 $ hg up 'desc("r-2")'
582 582 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
583 583 $ hg merge 'desc("b-1")'
584 584 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
585 585 (branch merge, don't forget to commit)
586 586 $ hg ci -m "mRBm-0 $case_desc - the other way"
587 587 created new head
588 588 $ hg up null --quiet
589 589 $ hg log -G --rev '::(desc("mBRm")+desc("mRBm"))'
590 590 o mRBm-0 simple merge - B side: unrelated change, R side: overwrite d with a copy (from r->x->t) different content - the other way
591 591 |\
592 592 +---o mBRm-0 simple merge - B side: unrelated change, R side: overwrite d with a copy (from r->x->t) different content - one way
593 593 | |/
594 594 | o r-2: rename t -> x
595 595 | |
596 596 | o r-1: rename r -> x
597 597 | |
598 598 o | b-1: b update
599 599 |/
600 600 o i-2: c -move-> d, s -move-> t
601 601 |
602 602 o i-1: a -move-> c, p -move-> s
603 603 |
604 604 o i-0 initial commit: a b h p q r
605 605
606 606
607 607
608 608 Subcase: reset of the copy history on one side
609 609 ``````````````````````````````````````````````
610 610
611 611 Merge:
612 612 - one with change to a file
613 613 - one deleting and recreating the file
614 614
615 615 Unlike in the 'BD/DB' cases, an actual merge happened here. So we should
616 616 consider history and rename on both branch of the merge.
617 617
618 618 $ case_desc="actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content"
619 619
620 620 $ hg up 'desc("i-2")'
621 621 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
622 622 $ echo "some update" >> d
623 623 $ hg commit -m "g-1: update d"
624 624 created new head
625 625 $ hg up 'desc("d-2")'
626 626 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
627 627 $ hg merge 'desc("g-1")' --tool :union
628 628 merging d
629 629 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
630 630 (branch merge, don't forget to commit)
631 631 $ hg ci -m "mDGm-0 $case_desc - one way"
632 632 $ hg up 'desc("g-1")'
633 633 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
634 634 $ hg merge 'desc("d-2")' --tool :union
635 635 merging d
636 636 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
637 637 (branch merge, don't forget to commit)
638 638 $ hg ci -m "mGDm-0 $case_desc - the other way"
639 639 created new head
640 640 $ hg log -G --rev '::(desc("mDGm")+desc("mGDm"))'
641 641 @ mGDm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - the other way
642 642 |\
643 643 +---o mDGm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - one way
644 644 | |/
645 645 | o g-1: update d
646 646 | |
647 647 o | d-2 re-add d
648 648 | |
649 649 o | d-1 delete d
650 650 |/
651 651 o i-2: c -move-> d, s -move-> t
652 652 |
653 653 o i-1: a -move-> c, p -move-> s
654 654 |
655 655 o i-0 initial commit: a b h p q r
656 656
657 657
658 658 Subcase: merging a change to a file with a "copy overwrite" to that file from another branch
659 659 ````````````````````````````````````````````````````````````````````````````````````````````
660 660
661 661 Merge:
662 662 - one with change to a file (d)
663 663 - one overwriting that file with a rename (from h to i, to d)
664 664
665 665 This case is similar to BF/FB, but an actual merge happens, so both side of the
666 666 history are relevant.
667 667
668 668 Note:
669 669 | In this case, the merge get conflicting information since on one side we have
670 670 | "a -> c -> d". and one the other one we have "h -> i -> d".
671 671 |
672 672 | The current code arbitrarily pick one side
673 673
674 674 $ case_desc="merge - G side: content change, F side: copy overwrite, no content change"
675 675
676 676 $ hg up 'desc("f-2")'
677 677 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
678 678 $ hg merge 'desc("g-1")' --tool :union
679 679 merging d (no-changeset !)
680 680 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (no-changeset !)
681 681 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (changeset !)
682 682 (branch merge, don't forget to commit)
683 683 $ hg ci -m "mFGm-0 $case_desc - one way"
684 684 created new head
685 685 $ hg up 'desc("g-1")'
686 686 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-changeset !)
687 687 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (changeset !)
688 688 $ hg merge 'desc("f-2")' --tool :union
689 689 merging d (no-changeset !)
690 690 0 files updated, 1 files merged, 1 files removed, 0 files unresolved (no-changeset !)
691 691 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
692 692 (branch merge, don't forget to commit)
693 693 $ hg ci -m "mGFm-0 $case_desc - the other way"
694 694 created new head
695 695 $ hg log -G --rev '::(desc("mGFm")+desc("mFGm"))'
696 696 @ mGFm-0 merge - G side: content change, F side: copy overwrite, no content change - the other way
697 697 |\
698 698 +---o mFGm-0 merge - G side: content change, F side: copy overwrite, no content change - one way
699 699 | |/
700 700 | o g-1: update d
701 701 | |
702 702 o | f-2: rename i -> d
703 703 | |
704 704 o | f-1: rename h -> i
705 705 |/
706 706 o i-2: c -move-> d, s -move-> t
707 707 |
708 708 o i-1: a -move-> c, p -move-> s
709 709 |
710 710 o i-0 initial commit: a b h p q r
711 711
712 712
713 713
714 714 Comparing with merging with a deletion (and keeping the file)
715 715 -------------------------------------------------------------
716 716
717 717 Merge:
718 718 - one removing a file (d)
719 719 - one updating that file
720 720 - the merge keep the modified version of the file (canceling the delete)
721 721
722 722 In this case, the file keep on living after the merge. So we should not drop its
723 723 copy tracing chain.
724 724
725 725 $ case_desc="merge updated/deleted - revive the file (updated content)"
726 726
727 727 $ hg up 'desc("c-1")'
728 728 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
729 729 $ hg merge 'desc("g-1")'
730 730 file 'd' was deleted in local [working copy] but was modified in other [merge rev].
731 731 You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
732 732 What do you want to do? u
733 733 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
734 734 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
735 735 [1]
736 736 $ hg resolve -t :other d
737 737 (no more unresolved files)
738 738 $ hg ci -m "mCGm-0 $case_desc - one way"
739 739 created new head
740 740
741 741 $ hg up 'desc("g-1")'
742 742 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
743 743 $ hg merge 'desc("c-1")'
744 744 file 'd' was deleted in other [merge rev] but was modified in local [working copy].
745 745 You can use (c)hanged version, (d)elete, or leave (u)nresolved.
746 746 What do you want to do? u
747 747 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
748 748 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
749 749 [1]
750 750 $ hg resolve -t :local d
751 751 (no more unresolved files)
752 752 $ hg ci -m "mGCm-0 $case_desc - the other way"
753 753 created new head
754 754
755 755 $ hg log -G --rev '::(desc("mCGm")+desc("mGCm"))'
756 756 @ mGCm-0 merge updated/deleted - revive the file (updated content) - the other way
757 757 |\
758 758 +---o mCGm-0 merge updated/deleted - revive the file (updated content) - one way
759 759 | |/
760 760 | o g-1: update d
761 761 | |
762 762 o | c-1 delete d
763 763 |/
764 764 o i-2: c -move-> d, s -move-> t
765 765 |
766 766 o i-1: a -move-> c, p -move-> s
767 767 |
768 768 o i-0 initial commit: a b h p q r
769 769
770 770
771 771
772 772
773 773 Comparing with merge restoring an untouched deleted file
774 774 --------------------------------------------------------
775 775
776 776 Merge:
777 777 - one removing a file (d)
778 778 - one leaving the file untouched
779 779 - the merge actively restore the file to the same content.
780 780
781 781 In this case, the file keep on living after the merge. So we should not drop its
782 782 copy tracing chain.
783 783
784 784 $ case_desc="merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge)"
785 785
786 786 $ hg up 'desc("c-1")'
787 787 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
788 788 $ hg merge 'desc("b-1")'
789 789 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
790 790 (branch merge, don't forget to commit)
791 791 $ hg revert --rev 'desc("b-1")' d
792 792 $ hg ci -m "mCB-revert-m-0 $case_desc - one way"
793 793 created new head
794 794
795 795 $ hg up 'desc("b-1")'
796 796 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
797 797 $ hg merge 'desc("c-1")'
798 798 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
799 799 (branch merge, don't forget to commit)
800 800 $ hg revert --rev 'desc("b-1")' d
801 801 $ hg ci -m "mBC-revert-m-0 $case_desc - the other way"
802 802 created new head
803 803
804 804 $ hg log -G --rev '::(desc("mCB-revert-m")+desc("mBC-revert-m"))'
805 805 @ mBC-revert-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - the other way
806 806 |\
807 807 +---o mCB-revert-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - one way
808 808 | |/
809 809 | o c-1 delete d
810 810 | |
811 811 o | b-1: b update
812 812 |/
813 813 o i-2: c -move-> d, s -move-> t
814 814 |
815 815 o i-1: a -move-> c, p -move-> s
816 816 |
817 817 o i-0 initial commit: a b h p q r
818 818
819 819
820 820
821 821 $ hg up null --quiet
822 822
823 823 Merging a branch where a rename was deleted with a branch where the same file was renamed
824 824 ------------------------------------------------------------------------------------------
825 825
826 826 Create a "conflicting" merge where `d` get removed on one branch before its
827 827 rename information actually conflict with the other branch.
828 828
829 829 (the copy information from the branch that was not deleted should win).
830 830
831 831 $ case_desc="simple merge - C side: d is the results of renames then deleted, H side: d is result of another rename (same content as the other branch)"
832 832
833 833 $ hg up 'desc("i-0")'
834 834 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
835 835 $ hg mv b d
836 836 $ hg ci -m "h-1: b -(move)-> d"
837 837 created new head
838 838
839 839 $ hg up 'desc("c-1")'
840 840 2 files updated, 0 files merged, 3 files removed, 0 files unresolved
841 841 $ hg merge 'desc("h-1")'
842 842 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
843 843 (branch merge, don't forget to commit)
844 844 $ hg ci -m "mCH-delete-before-conflict-m-0 $case_desc - one way"
845 845
846 846 $ hg up 'desc("h-1")'
847 847 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
848 848 $ hg merge 'desc("c-1")'
849 849 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
850 850 (branch merge, don't forget to commit)
851 851 $ hg ci -m "mHC-delete-before-conflict-m-0 $case_desc - the other way"
852 852 created new head
853 853 $ hg log -G --rev '::(desc("mCH-delete-before-conflict-m")+desc("mHC-delete-before-conflict-m"))'
854 854 @ mHC-delete-before-conflict-m-0 simple merge - C side: d is the results of renames then deleted, H side: d is result of another rename (same content as the other branch) - the other way
855 855 |\
856 856 +---o mCH-delete-before-conflict-m-0 simple merge - C side: d is the results of renames then deleted, H side: d is result of another rename (same content as the other branch) - one way
857 857 | |/
858 858 | o h-1: b -(move)-> d
859 859 | |
860 860 o | c-1 delete d
861 861 | |
862 862 o | i-2: c -move-> d, s -move-> t
863 863 | |
864 864 o | i-1: a -move-> c, p -move-> s
865 865 |/
866 866 o i-0 initial commit: a b h p q r
867 867
868 868
869 869 Variant of previous with extra changes introduced by the merge
870 870 --------------------------------------------------------------
871 871
872 872 Multiple cases above explicitely test cases where content are the same on both side during merge. In this section we will introduce variants for theses cases where new change are introduced to these file content during the merges.
873 873
874 874
875 875 Subcase: merge has same initial content on both side, but merge introduced a change
876 876 ```````````````````````````````````````````````````````````````````````````````````
877 877
878 878 Same as `mAEm` and `mEAm` but with extra change to the file before commiting
879 879
880 880 - the "e-" branch renaming b to f (through 'g')
881 881 - the "a-" branch renaming d to f (through e)
882 882
883 883 $ case_desc="merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent)"
884 884
885 885 $ hg up 'desc("a-2")'
886 886 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
887 887 $ hg merge 'desc("e-2")'
888 888 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
889 889 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
890 890 (branch merge, don't forget to commit)
891 891 $ echo "content change for mAE-change-m" > f
892 892 $ hg ci -m "mAE-change-m-0 $case_desc - one way"
893 893 created new head
894 894 $ hg up 'desc("e-2")'
895 895 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
896 896 $ hg merge 'desc("a-2")'
897 897 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
898 898 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
899 899 (branch merge, don't forget to commit)
900 900 $ echo "content change for mEA-change-m" > f
901 901 $ hg ci -m "mEA-change-m-0 $case_desc - the other way"
902 902 created new head
903 903 $ hg log -G --rev '::(desc("mAE-change-m")+desc("mEA-change-m"))'
904 904 @ mEA-change-m-0 merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent) - the other way
905 905 |\
906 906 +---o mAE-change-m-0 merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent) - one way
907 907 | |/
908 908 | o e-2 g -move-> f
909 909 | |
910 910 | o e-1 b -move-> g
911 911 | |
912 912 o | a-2: e -move-> f
913 913 | |
914 914 o | a-1: d -move-> e
915 915 |/
916 916 o i-2: c -move-> d, s -move-> t
917 917 |
918 918 o i-1: a -move-> c, p -move-> s
919 919 |
920 920 o i-0 initial commit: a b h p q r
921 921
922 922
923 923 Subcase: merge overwrite common copy information, but with extra change during the merge
924 924 ````````````````````````````````````````````````````````````````````````````````````````
925 925
926 926 Merge:
927 927 - one with change to an unrelated file (b)
928 928 - one overwriting a file (d) with a rename (from h to i to d)
929 929 - the merge update f content
930 930
931 931 $ case_desc="merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d)"
932 932
933 933 $ hg up 'desc("f-2")'
934 934 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
935 935 #if no-changeset
936 936 $ hg debugindex d | "$PYTHON" ../no-linkrev
937 937 rev linkrev nodeid p1 p2
938 938 0 * d8252ab2e760 000000000000 000000000000
939 939 1 * b004912a8510 000000000000 000000000000
940 940 2 * 7b79e2fe0c89 000000000000 000000000000
941 941 3 * 17ec97e60577 d8252ab2e760 000000000000
942 942 4 * 06dabf50734c b004912a8510 17ec97e60577
943 943 5 * 19c0e3924691 17ec97e60577 b004912a8510
944 944 6 * 89c873a01d97 7b79e2fe0c89 17ec97e60577
945 945 7 * d55cb4e9ef57 000000000000 000000000000
946 946 #else
947 947 $ hg debugindex d | "$PYTHON" ../no-linkrev
948 948 rev linkrev nodeid p1 p2
949 949 0 * ae258f702dfe 000000000000 000000000000
950 950 1 * b004912a8510 000000000000 000000000000
951 951 2 * 5cce88bf349f ae258f702dfe 000000000000
952 952 3 * cc269dd788c8 b004912a8510 5cce88bf349f
953 953 4 * 51c91a115080 5cce88bf349f b004912a8510
954 954 #endif
955 955 $ hg up 'desc("b-1")'
956 956 3 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-changeset !)
957 957 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (changeset !)
958 958 $ hg merge 'desc("f-2")'
959 959 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
960 960 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
961 961 (branch merge, don't forget to commit)
962 962 $ echo "extra-change to (formelly h) during the merge" > d
963 963 $ hg ci -m "mBF-change-m-0 $case_desc - one way"
964 964 created new head
965 965 $ hg manifest --rev . --debug | grep " d"
966 966 1c334238bd42ec85c6a0d83fd1b2a898a6a3215d 644 d (no-changeset !)
967 967 cea2d99c0fde64672ef61953786fdff34f16e230 644 d (changeset !)
968 968
969 969 $ hg up 'desc("f-2")'
970 970 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
971 971 $ hg merge 'desc("b-1")'
972 972 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
973 973 (branch merge, don't forget to commit)
974 974 $ echo "extra-change to (formelly h) during the merge" > d
975 975 $ hg ci -m "mFB-change-m-0 $case_desc - the other way"
976 976 created new head
977 977 $ hg manifest --rev . --debug | grep " d"
978 978 1c334238bd42ec85c6a0d83fd1b2a898a6a3215d 644 d (no-changeset !)
979 979 cea2d99c0fde64672ef61953786fdff34f16e230 644 d (changeset !)
980 980 #if no-changeset
981 981 $ hg debugindex d | "$PYTHON" ../no-linkrev
982 982 rev linkrev nodeid p1 p2
983 983 0 * d8252ab2e760 000000000000 000000000000
984 984 1 * b004912a8510 000000000000 000000000000
985 985 2 * 7b79e2fe0c89 000000000000 000000000000
986 986 3 * 17ec97e60577 d8252ab2e760 000000000000
987 987 4 * 06dabf50734c b004912a8510 17ec97e60577
988 988 5 * 19c0e3924691 17ec97e60577 b004912a8510
989 989 6 * 89c873a01d97 7b79e2fe0c89 17ec97e60577
990 990 7 * d55cb4e9ef57 000000000000 000000000000
991 991 8 * 1c334238bd42 7b79e2fe0c89 000000000000
992 992 #else
993 993 $ hg debugindex d | "$PYTHON" ../no-linkrev
994 994 rev linkrev nodeid p1 p2
995 995 0 * ae258f702dfe 000000000000 000000000000
996 996 1 * b004912a8510 000000000000 000000000000
997 997 2 * 5cce88bf349f ae258f702dfe 000000000000
998 998 3 * cc269dd788c8 b004912a8510 5cce88bf349f
999 999 4 * 51c91a115080 5cce88bf349f b004912a8510
1000 1000 5 * cea2d99c0fde ae258f702dfe 000000000000
1001 1001 #endif
1002 1002 $ hg log -G --rev '::(desc("mBF-change-m")+desc("mFB-change-m"))'
1003 1003 @ mFB-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - the other way
1004 1004 |\
1005 1005 +---o mBF-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - one way
1006 1006 | |/
1007 1007 | o f-2: rename i -> d
1008 1008 | |
1009 1009 | o f-1: rename h -> i
1010 1010 | |
1011 1011 o | b-1: b update
1012 1012 |/
1013 1013 o i-2: c -move-> d, s -move-> t
1014 1014 |
1015 1015 o i-1: a -move-> c, p -move-> s
1016 1016 |
1017 1017 o i-0 initial commit: a b h p q r
1018 1018
1019 1019
1020 1020 Subcase: restoring and untouched deleted file, while touching it
1021 1021 ````````````````````````````````````````````````````````````````
1022 1022
1023 1023 Merge:
1024 1024 - one removing a file (d)
1025 1025 - one leaving the file untouched
1026 1026 - the merge actively restore the file to the same content.
1027 1027
1028 1028 In this case, the file keep on living after the merge. So we should not drop its
1029 1029 copy tracing chain.
1030 1030
1031 1031 $ case_desc="merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge)"
1032 1032
1033 1033 $ hg up 'desc("c-1")'
1034 1034 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1035 1035 $ hg merge 'desc("b-1")'
1036 1036 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1037 1037 (branch merge, don't forget to commit)
1038 1038 $ hg revert --rev 'desc("b-1")' d
1039 1039 $ echo "new content for d after the revert" > d
1040 1040 $ hg ci -m "mCB-change-m-0 $case_desc - one way"
1041 1041 created new head
1042 1042 $ hg manifest --rev . --debug | grep " d"
1043 1043 e333780c17752a3b0dd15e3ad48aa4e5c745f621 644 d (no-changeset !)
1044 1044 4b540a18ad699234b2b2aa18cb69555ac9c4b1df 644 d (changeset !)
1045 1045
1046 1046 $ hg up 'desc("b-1")'
1047 1047 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1048 1048 $ hg merge 'desc("c-1")'
1049 1049 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1050 1050 (branch merge, don't forget to commit)
1051 1051 $ hg revert --rev 'desc("b-1")' d
1052 1052 $ echo "new content for d after the revert" > d
1053 1053 $ hg ci -m "mBC-change-m-0 $case_desc - the other way"
1054 1054 created new head
1055 1055 $ hg manifest --rev . --debug | grep " d"
1056 1056 e333780c17752a3b0dd15e3ad48aa4e5c745f621 644 d (no-changeset !)
1057 1057 4b540a18ad699234b2b2aa18cb69555ac9c4b1df 644 d (changeset !)
1058 1058
1059 1059
1060 1060 $ hg up null --quiet
1061 1061 $ hg log -G --rev '::(desc("mCB-change-m")+desc("mBC-change-m"))'
1062 1062 o mBC-change-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - the other way
1063 1063 |\
1064 1064 +---o mCB-change-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - one way
1065 1065 | |/
1066 1066 | o c-1 delete d
1067 1067 | |
1068 1068 o | b-1: b update
1069 1069 |/
1070 1070 o i-2: c -move-> d, s -move-> t
1071 1071 |
1072 1072 o i-1: a -move-> c, p -move-> s
1073 1073 |
1074 1074 o i-0 initial commit: a b h p q r
1075 1075
1076 1076
1077 1077 Decision from previous merge are properly chained with later merge
1078 1078 ------------------------------------------------------------------
1079 1079
1080 1080 Subcase: chaining conflicting rename resolution
1081 1081 ```````````````````````````````````````````````
1082 1082
1083 1083 The "mAEm" and "mEAm" case create a rename tracking conflict on file 'f'. We
1084 1084 add more change on the respective branch and merge again. These second merge
1085 1085 does not involve the file 'f' and the arbitration done within "mAEm" and "mEA"
1086 1086 about that file should stay unchanged.
1087 1087
1088 1088 We also touch J during some of the merge to check for unrelated change to new file during merge.
1089 1089
1090 1090 $ case_desc="chained merges (conflict -> simple) - same content everywhere"
1091 1091
1092 1092 (extra unrelated changes)
1093 1093
1094 1094 $ hg up 'desc("a-2")'
1095 1095 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
1096 1096 $ echo j > unrelated-j
1097 1097 $ hg add unrelated-j
1098 1098 $ hg ci -m 'j-1: unrelated changes (based on the "a" series of changes)'
1099 1099 created new head
1100 1100
1101 1101 $ hg up 'desc("e-2")'
1102 1102 2 files updated, 0 files merged, 2 files removed, 0 files unresolved (no-changeset !)
1103 1103 1 files updated, 0 files merged, 2 files removed, 0 files unresolved (changeset !)
1104 1104 $ echo k > unrelated-k
1105 1105 $ hg add unrelated-k
1106 1106 $ hg ci -m 'k-1: unrelated changes (based on "e" changes)'
1107 1107 created new head
1108 1108
1109 1109 (merge variant 1)
1110 1110
1111 1111 $ hg up 'desc("mAEm")'
1112 1112 1 files updated, 0 files merged, 2 files removed, 0 files unresolved (no-changeset !)
1113 1113 0 files updated, 0 files merged, 2 files removed, 0 files unresolved (changeset !)
1114 1114 $ hg merge 'desc("k-1")'
1115 1115 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1116 1116 (branch merge, don't forget to commit)
1117 1117 $ hg ci -m "mAE,Km: $case_desc"
1118 1118
1119 1119 (merge variant 2)
1120 1120
1121 1121 $ hg up 'desc("k-1")'
1122 1122 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-changeset !)
1123 1123 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (changeset !)
1124 1124
1125 1125 $ hg merge 'desc("mAEm")'
1126 1126 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
1127 1127 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
1128 1128 (branch merge, don't forget to commit)
1129 1129 $ hg ci -m "mK,AEm: $case_desc"
1130 1130 created new head
1131 1131
1132 1132 (merge variant 3)
1133 1133
1134 1134 $ hg up 'desc("mEAm")'
1135 1135 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1136 1136 $ hg merge 'desc("j-1")'
1137 1137 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1138 1138 (branch merge, don't forget to commit)
1139 1139 $ echo jj > unrelated-j
1140 1140 $ hg ci -m "mEA,Jm: $case_desc"
1141 1141
1142 1142 (merge variant 4)
1143 1143
1144 1144 $ hg up 'desc("j-1")'
1145 1145 3 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-changeset !)
1146 1146 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (changeset !)
1147 1147 $ hg merge 'desc("mEAm")'
1148 1148 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
1149 1149 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
1150 1150 (branch merge, don't forget to commit)
1151 1151 $ echo jj > unrelated-j
1152 1152 $ hg ci -m "mJ,EAm: $case_desc"
1153 1153 created new head
1154 1154
1155 1155
1156 1156 $ hg log -G --rev '::(desc("mAE,Km") + desc("mK,AEm") + desc("mEA,Jm") + desc("mJ,EAm"))'
1157 1157 @ mJ,EAm: chained merges (conflict -> simple) - same content everywhere
1158 1158 |\
1159 1159 +---o mEA,Jm: chained merges (conflict -> simple) - same content everywhere
1160 1160 | |/
1161 1161 | | o mK,AEm: chained merges (conflict -> simple) - same content everywhere
1162 1162 | | |\
1163 1163 | | +---o mAE,Km: chained merges (conflict -> simple) - same content everywhere
1164 1164 | | | |/
1165 1165 | | | o k-1: unrelated changes (based on "e" changes)
1166 1166 | | | |
1167 1167 | o | | j-1: unrelated changes (based on the "a" series of changes)
1168 1168 | | | |
1169 1169 o-----+ mEAm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - the other way
1170 1170 |/ / /
1171 1171 | o / mAEm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - one way
1172 1172 |/|/
1173 1173 | o e-2 g -move-> f
1174 1174 | |
1175 1175 | o e-1 b -move-> g
1176 1176 | |
1177 1177 o | a-2: e -move-> f
1178 1178 | |
1179 1179 o | a-1: d -move-> e
1180 1180 |/
1181 1181 o i-2: c -move-> d, s -move-> t
1182 1182 |
1183 1183 o i-1: a -move-> c, p -move-> s
1184 1184 |
1185 1185 o i-0 initial commit: a b h p q r
1186 1186
1187 1187
1188 1188 Subcase: chaining conflicting rename resolution, with actual merging happening
1189 1189 ``````````````````````````````````````````````````````````````````````````````
1190 1190
1191 1191 The "mPQm" and "mQPm" case create a rename tracking conflict on file 't'. We
1192 1192 add more change on the respective branch and merge again. These second merge
1193 1193 does not involve the file 't' and the arbitration done within "mPQm" and "mQP"
1194 1194 about that file should stay unchanged.
1195 1195
1196 1196 $ case_desc="chained merges (conflict -> simple) - different content"
1197 1197
1198 1198 (extra unrelated changes)
1199 1199
1200 1200 $ hg up 'desc("p-2")'
1201 1201 3 files updated, 0 files merged, 3 files removed, 0 files unresolved
1202 1202 $ echo s > unrelated-s
1203 1203 $ hg add unrelated-s
1204 1204 $ hg ci -m 's-1: unrelated changes (based on the "p" series of changes)'
1205 1205 created new head
1206 1206
1207 1207 $ hg up 'desc("q-2")'
1208 1208 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
1209 1209 $ echo t > unrelated-t
1210 1210 $ hg add unrelated-t
1211 1211 $ hg ci -m 't-1: unrelated changes (based on "q" changes)'
1212 1212 created new head
1213 1213
1214 1214 (merge variant 1)
1215 1215
1216 1216 $ hg up 'desc("mPQm")'
1217 1217 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
1218 1218 $ hg merge 'desc("t-1")'
1219 1219 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1220 1220 (branch merge, don't forget to commit)
1221 1221 $ hg ci -m "mPQ,Tm: $case_desc"
1222 1222
1223 1223 (merge variant 2)
1224 1224
1225 1225 $ hg up 'desc("t-1")'
1226 1226 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1227 1227
1228 1228 $ hg merge 'desc("mPQm")'
1229 1229 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1230 1230 (branch merge, don't forget to commit)
1231 1231 $ hg ci -m "mT,PQm: $case_desc"
1232 1232 created new head
1233 1233
1234 1234 (merge variant 3)
1235 1235
1236 1236 $ hg up 'desc("mQPm")'
1237 1237 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1238 1238 $ hg merge 'desc("s-1")'
1239 1239 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1240 1240 (branch merge, don't forget to commit)
1241 1241 $ hg ci -m "mQP,Sm: $case_desc"
1242 1242
1243 1243 (merge variant 4)
1244 1244
1245 1245 $ hg up 'desc("s-1")'
1246 1246 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1247 1247 $ hg merge 'desc("mQPm")'
1248 1248 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1249 1249 (branch merge, don't forget to commit)
1250 1250 $ hg ci -m "mS,QPm: $case_desc"
1251 1251 created new head
1252 1252 $ hg up null --quiet
1253 1253
1254 1254
1255 1255 $ hg log -G --rev '::(desc("mPQ,Tm") + desc("mT,PQm") + desc("mQP,Sm") + desc("mS,QPm"))'
1256 1256 o mS,QPm: chained merges (conflict -> simple) - different content
1257 1257 |\
1258 1258 +---o mQP,Sm: chained merges (conflict -> simple) - different content
1259 1259 | |/
1260 1260 | | o mT,PQm: chained merges (conflict -> simple) - different content
1261 1261 | | |\
1262 1262 | | +---o mPQ,Tm: chained merges (conflict -> simple) - different content
1263 1263 | | | |/
1264 1264 | | | o t-1: unrelated changes (based on "q" changes)
1265 1265 | | | |
1266 1266 | o | | s-1: unrelated changes (based on the "p" series of changes)
1267 1267 | | | |
1268 1268 o-----+ mQPm-0 merge with copies info on both side - P side: rename t to v, Q side: r to v, (different content) - the other way
1269 1269 |/ / /
1270 1270 | o / mPQm-0 merge with copies info on both side - P side: rename t to v, Q side: r to v, (different content) - one way
1271 1271 |/|/
1272 1272 | o q-2 w -move-> v
1273 1273 | |
1274 1274 | o q-1 r -move-> w
1275 1275 | |
1276 1276 o | p-2: u -move-> v
1277 1277 | |
1278 1278 o | p-1: t -move-> u
1279 1279 |/
1280 1280 o i-2: c -move-> d, s -move-> t
1281 1281 |
1282 1282 o i-1: a -move-> c, p -move-> s
1283 1283 |
1284 1284 o i-0 initial commit: a b h p q r
1285 1285
1286 1286
1287 1287 Subcase: chaining salvage information during a merge
1288 1288 ````````````````````````````````````````````````````
1289 1289
1290 1290 We add more change on the branch were the file was deleted. merging again
1291 1291 should preserve the fact eh file was salvaged.
1292 1292
1293 1293 $ case_desc="chained merges (salvaged -> simple) - same content (when the file exists)"
1294 1294
1295 1295 (creating the change)
1296 1296
1297 1297 $ hg up 'desc("c-1")'
1298 1298 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
1299 1299 $ echo l > unrelated-l
1300 1300 $ hg add unrelated-l
1301 1301 $ hg ci -m 'l-1: unrelated changes (based on "c" changes)'
1302 1302 created new head
1303 1303
1304 1304 (Merge variant 1)
1305 1305
1306 1306 $ hg up 'desc("mBC-revert-m")'
1307 1307 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1308 1308 $ hg merge 'desc("l-1")'
1309 1309 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1310 1310 (branch merge, don't forget to commit)
1311 1311 $ hg ci -m "mBC+revert,Lm: $case_desc"
1312 1312
1313 1313 (Merge variant 2)
1314 1314
1315 1315 $ hg up 'desc("mCB-revert-m")'
1316 1316 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1317 1317 $ hg merge 'desc("l-1")'
1318 1318 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1319 1319 (branch merge, don't forget to commit)
1320 1320 $ hg ci -m "mCB+revert,Lm: $case_desc"
1321 1321
1322 1322 (Merge variant 3)
1323 1323
1324 1324 $ hg up 'desc("l-1")'
1325 1325 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1326 1326
1327 1327 $ hg merge 'desc("mBC-revert-m")'
1328 1328 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1329 1329 (branch merge, don't forget to commit)
1330 1330 $ hg ci -m "mL,BC+revertm: $case_desc"
1331 1331 created new head
1332 1332
1333 1333 (Merge variant 4)
1334 1334
1335 1335 $ hg up 'desc("l-1")'
1336 1336 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1337 1337
1338 1338 $ hg merge 'desc("mCB-revert-m")'
1339 1339 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1340 1340 (branch merge, don't forget to commit)
1341 1341 $ hg ci -m "mL,CB+revertm: $case_desc"
1342 1342 created new head
1343 1343
1344 1344 $ hg log -G --rev '::(desc("mBC+revert,Lm") + desc("mCB+revert,Lm") + desc("mL,BC+revertm") + desc("mL,CB+revertm"))'
1345 1345 @ mL,CB+revertm: chained merges (salvaged -> simple) - same content (when the file exists)
1346 1346 |\
1347 1347 | | o mL,BC+revertm: chained merges (salvaged -> simple) - same content (when the file exists)
1348 1348 | |/|
1349 1349 +-+---o mCB+revert,Lm: chained merges (salvaged -> simple) - same content (when the file exists)
1350 1350 | | |
1351 1351 | +---o mBC+revert,Lm: chained merges (salvaged -> simple) - same content (when the file exists)
1352 1352 | | |/
1353 1353 | o | l-1: unrelated changes (based on "c" changes)
1354 1354 | | |
1355 1355 | | o mBC-revert-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - the other way
1356 1356 | |/|
1357 1357 o---+ mCB-revert-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - one way
1358 1358 |/ /
1359 1359 o | c-1 delete d
1360 1360 | |
1361 1361 | o b-1: b update
1362 1362 |/
1363 1363 o i-2: c -move-> d, s -move-> t
1364 1364 |
1365 1365 o i-1: a -move-> c, p -move-> s
1366 1366 |
1367 1367 o i-0 initial commit: a b h p q r
1368 1368
1369 1369
1370 1370
1371 1371 Subcase: chaining "merged" information during a merge
1372 1372 ``````````````````````````````````````````````````````
1373 1373
1374 1374 When a non-rename change are merged with a copy overwrite, the merge pick the copy source from (p1) as the reference. We should preserve this information in subsequent merges.
1375 1375
1376 1376 $ case_desc="chained merges (copy-overwrite -> simple) - same content"
1377 1377
1378 1378 (extra unrelated changes)
1379 1379
1380 1380 $ hg up 'desc("f-2")'
1381 1381 2 files updated, 0 files merged, 2 files removed, 0 files unresolved (no-changeset !)
1382 1382 1 files updated, 0 files merged, 2 files removed, 0 files unresolved (changeset !)
1383 1383 $ echo n > unrelated-n
1384 1384 $ hg add unrelated-n
1385 1385 $ hg ci -m 'n-1: unrelated changes (based on the "f" series of changes)'
1386 1386 created new head
1387 1387
1388 1388 $ hg up 'desc("g-1")'
1389 1389 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1390 1390 $ echo o > unrelated-o
1391 1391 $ hg add unrelated-o
1392 1392 $ hg ci -m 'o-1: unrelated changes (based on "g" changes)'
1393 1393 created new head
1394 1394
1395 1395 (merge variant 1)
1396 1396
1397 1397 $ hg up 'desc("mFGm")'
1398 1398 1 files updated, 0 files merged, 2 files removed, 0 files unresolved (no-changeset !)
1399 1399 0 files updated, 0 files merged, 2 files removed, 0 files unresolved (changeset !)
1400 1400 $ hg merge 'desc("o-1")'
1401 1401 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1402 1402 (branch merge, don't forget to commit)
1403 1403 $ hg ci -m "mFG,Om: $case_desc"
1404 1404
1405 1405 (merge variant 2)
1406 1406
1407 1407 $ hg up 'desc("o-1")'
1408 1408 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-changeset !)
1409 1409 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (changeset !)
1410 1410 $ hg merge 'desc("FGm")'
1411 1411 1 files updated, 0 files merged, 1 files removed, 0 files unresolved (no-changeset !)
1412 1412 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (changeset !)
1413 1413 (branch merge, don't forget to commit)
1414 1414 $ hg ci -m "mO,FGm: $case_desc"
1415 1415 created new head
1416 1416
1417 1417 (merge variant 3)
1418 1418
1419 1419 $ hg up 'desc("mGFm")'
1420 1420 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1421 1421 $ hg merge 'desc("n-1")'
1422 1422 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1423 1423 (branch merge, don't forget to commit)
1424 1424 $ hg ci -m "mGF,Nm: $case_desc"
1425 1425
1426 1426 (merge variant 4)
1427 1427
1428 1428 $ hg up 'desc("n-1")'
1429 1429 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1430 1430 $ hg merge 'desc("mGFm")'
1431 1431 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1432 1432 (branch merge, don't forget to commit)
1433 1433 $ hg ci -m "mN,GFm: $case_desc"
1434 1434 created new head
1435 1435
1436 1436 $ hg log -G --rev '::(desc("mFG,Om") + desc("mO,FGm") + desc("mGF,Nm") + desc("mN,GFm"))'
1437 1437 @ mN,GFm: chained merges (copy-overwrite -> simple) - same content
1438 1438 |\
1439 1439 +---o mGF,Nm: chained merges (copy-overwrite -> simple) - same content
1440 1440 | |/
1441 1441 | | o mO,FGm: chained merges (copy-overwrite -> simple) - same content
1442 1442 | | |\
1443 1443 | | +---o mFG,Om: chained merges (copy-overwrite -> simple) - same content
1444 1444 | | | |/
1445 1445 | | | o o-1: unrelated changes (based on "g" changes)
1446 1446 | | | |
1447 1447 | o | | n-1: unrelated changes (based on the "f" series of changes)
1448 1448 | | | |
1449 1449 o-----+ mGFm-0 merge - G side: content change, F side: copy overwrite, no content change - the other way
1450 1450 |/ / /
1451 1451 | o / mFGm-0 merge - G side: content change, F side: copy overwrite, no content change - one way
1452 1452 |/|/
1453 1453 | o g-1: update d
1454 1454 | |
1455 1455 o | f-2: rename i -> d
1456 1456 | |
1457 1457 o | f-1: rename h -> i
1458 1458 |/
1459 1459 o i-2: c -move-> d, s -move-> t
1460 1460 |
1461 1461 o i-1: a -move-> c, p -move-> s
1462 1462 |
1463 1463 o i-0 initial commit: a b h p q r
1464 1464
1465 1465
1466 1466 Subcase: chaining conflicting rename resolution, with extra change during the merge
1467 1467 ```````````````````````````````````````````````````````````````````````````````````
1468 1468
1469 1469 The "mEA-change-m-0" and "mAE-change-m-0" case create a rename tracking conflict on file 'f'. We
1470 1470 add more change on the respective branch and merge again. These second merge
1471 1471 does not involve the file 'f' and the arbitration done within "mAEm" and "mEA"
1472 1472 about that file should stay unchanged.
1473 1473
1474 1474 $ case_desc="chained merges (conflict+change -> simple) - same content on both branch in the initial merge"
1475 1475
1476 1476
1477 1477 (merge variant 1)
1478 1478
1479 1479 $ hg up 'desc("mAE-change-m")'
1480 1480 2 files updated, 0 files merged, 3 files removed, 0 files unresolved
1481 1481 $ hg merge 'desc("k-1")'
1482 1482 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1483 1483 (branch merge, don't forget to commit)
1484 1484 $ hg ci -m "mAE-change,Km: $case_desc"
1485 1485
1486 1486 (merge variant 2)
1487 1487
1488 1488 $ hg up 'desc("k-1")'
1489 1489 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1490 1490
1491 1491 $ hg merge 'desc("mAE-change-m")'
1492 1492 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1493 1493 (branch merge, don't forget to commit)
1494 1494 $ hg ci -m "mK,AE-change-m: $case_desc"
1495 1495 created new head
1496 1496
1497 1497 (merge variant 3)
1498 1498
1499 1499 $ hg up 'desc("mEA-change-m")'
1500 1500 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1501 1501 $ hg merge 'desc("j-1")'
1502 1502 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1503 1503 (branch merge, don't forget to commit)
1504 1504 $ hg ci -m "mEA-change,Jm: $case_desc"
1505 1505
1506 1506 (merge variant 4)
1507 1507
1508 1508 $ hg up 'desc("j-1")'
1509 1509 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1510 1510 $ hg merge 'desc("mEA-change-m")'
1511 1511 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1512 1512 (branch merge, don't forget to commit)
1513 1513 $ hg ci -m "mJ,EA-change-m: $case_desc"
1514 1514 created new head
1515 1515
1516 1516
1517 1517 $ hg log -G --rev '::(desc("mAE-change,Km") + desc("mK,AE-change-m") + desc("mEA-change,Jm") + desc("mJ,EA-change-m"))'
1518 1518 @ mJ,EA-change-m: chained merges (conflict+change -> simple) - same content on both branch in the initial merge
1519 1519 |\
1520 1520 +---o mEA-change,Jm: chained merges (conflict+change -> simple) - same content on both branch in the initial merge
1521 1521 | |/
1522 1522 | | o mK,AE-change-m: chained merges (conflict+change -> simple) - same content on both branch in the initial merge
1523 1523 | | |\
1524 1524 | | +---o mAE-change,Km: chained merges (conflict+change -> simple) - same content on both branch in the initial merge
1525 1525 | | | |/
1526 1526 | | | o k-1: unrelated changes (based on "e" changes)
1527 1527 | | | |
1528 1528 | o | | j-1: unrelated changes (based on the "a" series of changes)
1529 1529 | | | |
1530 1530 o-----+ mEA-change-m-0 merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent) - the other way
1531 1531 |/ / /
1532 1532 | o / mAE-change-m-0 merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent) - one way
1533 1533 |/|/
1534 1534 | o e-2 g -move-> f
1535 1535 | |
1536 1536 | o e-1 b -move-> g
1537 1537 | |
1538 1538 o | a-2: e -move-> f
1539 1539 | |
1540 1540 o | a-1: d -move-> e
1541 1541 |/
1542 1542 o i-2: c -move-> d, s -move-> t
1543 1543 |
1544 1544 o i-1: a -move-> c, p -move-> s
1545 1545 |
1546 1546 o i-0 initial commit: a b h p q r
1547 1547
1548 1548
1549 1549 Summary of all created cases
1550 1550 ----------------------------
1551 1551
1552 1552 $ hg up --quiet null
1553 1553
1554 1554 (This exists to help keeping a compact list of the various cases we have built)
1555 1555
1556 1556 $ hg log -T '{desc|firstline}\n'| sort
1557 1557 a-1: d -move-> e
1558 1558 a-2: e -move-> f
1559 1559 b-1: b update
1560 1560 c-1 delete d
1561 1561 d-1 delete d
1562 1562 d-2 re-add d
1563 1563 e-1 b -move-> g
1564 1564 e-2 g -move-> f
1565 1565 f-1: rename h -> i
1566 1566 f-2: rename i -> d
1567 1567 g-1: update d
1568 1568 h-1: b -(move)-> d
1569 1569 i-0 initial commit: a b h p q r
1570 1570 i-1: a -move-> c, p -move-> s
1571 1571 i-2: c -move-> d, s -move-> t
1572 1572 j-1: unrelated changes (based on the "a" series of changes)
1573 1573 k-1: unrelated changes (based on "e" changes)
1574 1574 l-1: unrelated changes (based on "c" changes)
1575 1575 mABm-0 simple merge - A side: multiple renames, B side: unrelated update - the other way
1576 1576 mAE,Km: chained merges (conflict -> simple) - same content everywhere
1577 1577 mAE-change,Km: chained merges (conflict+change -> simple) - same content on both branch in the initial merge
1578 1578 mAE-change-m-0 merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent) - one way
1579 1579 mAEm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - one way
1580 1580 mBAm-0 simple merge - A side: multiple renames, B side: unrelated update - one way
1581 1581 mBC+revert,Lm: chained merges (salvaged -> simple) - same content (when the file exists)
1582 1582 mBC-change-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - the other way
1583 1583 mBC-revert-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - the other way
1584 1584 mBCm-0 simple merge - C side: delete a file with copies history , B side: unrelated update - one way
1585 1585 mBCm-1 re-add d
1586 1586 mBDm-0 simple merge - B side: unrelated update, D side: delete and recreate a file (with different content) - one way
1587 1587 mBF-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - one way
1588 1588 mBFm-0 simple merge - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - one way
1589 1589 mBRm-0 simple merge - B side: unrelated change, R side: overwrite d with a copy (from r->x->t) different content - one way
1590 1590 mCB+revert,Lm: chained merges (salvaged -> simple) - same content (when the file exists)
1591 1591 mCB-change-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - one way
1592 1592 mCB-revert-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - one way
1593 1593 mCBm-0 simple merge - C side: delete a file with copies history , B side: unrelated update - the other way
1594 1594 mCBm-1 re-add d
1595 1595 mCGm-0 merge updated/deleted - revive the file (updated content) - one way
1596 1596 mCH-delete-before-conflict-m-0 simple merge - C side: d is the results of renames then deleted, H side: d is result of another rename (same content as the other branch) - one way
1597 1597 mDBm-0 simple merge - B side: unrelated update, D side: delete and recreate a file (with different content) - the other way
1598 1598 mDGm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - one way
1599 1599 mEA,Jm: chained merges (conflict -> simple) - same content everywhere
1600 1600 mEA-change,Jm: chained merges (conflict+change -> simple) - same content on both branch in the initial merge
1601 1601 mEA-change-m-0 merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent) - the other way
1602 1602 mEAm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - the other way
1603 1603 mFB-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - the other way
1604 1604 mFBm-0 simple merge - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - the other way
1605 1605 mFG,Om: chained merges (copy-overwrite -> simple) - same content
1606 1606 mFGm-0 merge - G side: content change, F side: copy overwrite, no content change - one way
1607 1607 mGCm-0 merge updated/deleted - revive the file (updated content) - the other way
1608 1608 mGDm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - the other way
1609 1609 mGF,Nm: chained merges (copy-overwrite -> simple) - same content
1610 1610 mGFm-0 merge - G side: content change, F side: copy overwrite, no content change - the other way
1611 1611 mHC-delete-before-conflict-m-0 simple merge - C side: d is the results of renames then deleted, H side: d is result of another rename (same content as the other branch) - the other way
1612 1612 mJ,EA-change-m: chained merges (conflict+change -> simple) - same content on both branch in the initial merge
1613 1613 mJ,EAm: chained merges (conflict -> simple) - same content everywhere
1614 1614 mK,AE-change-m: chained merges (conflict+change -> simple) - same content on both branch in the initial merge
1615 1615 mK,AEm: chained merges (conflict -> simple) - same content everywhere
1616 1616 mL,BC+revertm: chained merges (salvaged -> simple) - same content (when the file exists)
1617 1617 mL,CB+revertm: chained merges (salvaged -> simple) - same content (when the file exists)
1618 1618 mN,GFm: chained merges (copy-overwrite -> simple) - same content
1619 1619 mO,FGm: chained merges (copy-overwrite -> simple) - same content
1620 1620 mPQ,Tm: chained merges (conflict -> simple) - different content
1621 1621 mPQm-0 merge with copies info on both side - P side: rename t to v, Q side: r to v, (different content) - one way
1622 1622 mQP,Sm: chained merges (conflict -> simple) - different content
1623 1623 mQPm-0 merge with copies info on both side - P side: rename t to v, Q side: r to v, (different content) - the other way
1624 1624 mRBm-0 simple merge - B side: unrelated change, R side: overwrite d with a copy (from r->x->t) different content - the other way
1625 1625 mS,QPm: chained merges (conflict -> simple) - different content
1626 1626 mT,PQm: chained merges (conflict -> simple) - different content
1627 1627 n-1: unrelated changes (based on the "f" series of changes)
1628 1628 o-1: unrelated changes (based on "g" changes)
1629 1629 p-1: t -move-> u
1630 1630 p-2: u -move-> v
1631 1631 q-1 r -move-> w
1632 1632 q-2 w -move-> v
1633 1633 r-1: rename r -> x
1634 1634 r-2: rename t -> x
1635 1635 s-1: unrelated changes (based on the "p" series of changes)
1636 1636 t-1: unrelated changes (based on "q" changes)
1637 1637
1638 1638
1639 1639 Test that sidedata computations during upgrades are correct
1640 1640 ===========================================================
1641 1641
1642 1642 We upgrade a repository that is not using sidedata (the filelog case) and
1643 1643 check that the same side data have been generated as if they were computed at
1644 1644 commit time.
1645 1645
1646 1646
1647 1647 #if upgraded
1648 1648 $ cat >> $HGRCPATH << EOF
1649 1649 > [format]
1650 1650 > exp-use-copies-side-data-changeset = yes
1651 1651 > EOF
1652 1652 $ hg debugformat -v
1653 1653 format-variant repo config default
1654 1654 fncache: yes yes yes
1655 1655 dotencode: yes yes yes
1656 1656 generaldelta: yes yes yes
1657 1657 share-safe: no no no
1658 1658 sparserevlog: yes yes yes
1659 1659 persistent-nodemap: no no no (no-rust !)
1660 1660 persistent-nodemap: yes yes no (rust !)
1661 1661 copies-sdc: no yes no
1662 revlog-v2: no yes no
1663 changelog-v2: no no no
1662 revlog-v2: no no no
1663 changelog-v2: no yes no
1664 1664 plain-cl-delta: yes yes yes
1665 1665 compression: * (glob)
1666 1666 compression-level: default default default
1667 1667 $ hg debugupgraderepo --run --quiet
1668 1668 upgrade will perform the following actions:
1669 1669
1670 1670 requirements
1671 1671 preserved: * (glob)
1672 removed: revlogv1
1673 added: exp-copies-sidedata-changeset, exp-revlogv2.2
1672 added: exp-changelog-v2, exp-copies-sidedata-changeset
1674 1673
1675 1674 processed revlogs:
1676 1675 - all-filelogs
1677 1676 - changelog
1678 1677 - manifest
1679 1678
1680 1679 #endif
1681 1680
1682 1681 #if upgraded-parallel
1683 1682 $ cat >> $HGRCPATH << EOF
1684 1683 > [format]
1685 1684 > exp-use-copies-side-data-changeset = yes
1686 1685 > [experimental]
1687 1686 > worker.repository-upgrade=yes
1688 1687 > [worker]
1689 1688 > enabled=yes
1690 1689 > numcpus=8
1691 1690 > EOF
1692 1691 $ hg debugformat -v
1693 1692 format-variant repo config default
1694 1693 fncache: yes yes yes
1695 1694 dotencode: yes yes yes
1696 1695 generaldelta: yes yes yes
1697 1696 share-safe: no no no
1698 1697 sparserevlog: yes yes yes
1699 1698 persistent-nodemap: no no no (no-rust !)
1700 1699 persistent-nodemap: yes yes no (rust !)
1701 1700 copies-sdc: no yes no
1702 revlog-v2: no yes no
1703 changelog-v2: no no no
1701 revlog-v2: no no no
1702 changelog-v2: no yes no
1704 1703 plain-cl-delta: yes yes yes
1705 1704 compression: * (glob)
1706 1705 compression-level: default default default
1707 1706 $ hg debugupgraderepo --run --quiet
1708 1707 upgrade will perform the following actions:
1709 1708
1710 1709 requirements
1711 1710 preserved: * (glob)
1712 removed: revlogv1
1713 added: exp-copies-sidedata-changeset, exp-revlogv2.2
1711 added: exp-changelog-v2, exp-copies-sidedata-changeset
1714 1712
1715 1713 processed revlogs:
1716 1714 - all-filelogs
1717 1715 - changelog
1718 1716 - manifest
1719 1717
1720 1718 #endif
1721 1719
1722 1720 #if pull
1723 1721 $ cd ..
1724 1722 $ mv repo-chain repo-source
1725 1723 $ hg init repo-chain
1726 1724 $ cd repo-chain
1727 1725 $ hg pull ../repo-source
1728 1726 pulling from ../repo-source
1729 1727 requesting all changes
1730 1728 adding changesets
1731 1729 adding manifests
1732 1730 adding file changes
1733 1731 added 80 changesets with 44 changes to 25 files (+39 heads)
1734 1732 new changesets a3a31bbefea6:908ce9259ffa
1735 1733 (run 'hg heads' to see heads, 'hg merge' to merge)
1736 1734 #endif
1737 1735
1738 1736 #if pull-upgrade
1739 1737 $ cat >> $HGRCPATH << EOF
1740 1738 > [format]
1741 1739 > exp-use-copies-side-data-changeset = yes
1742 1740 > [experimental]
1743 1741 > changegroup4 = yes
1744 1742 > EOF
1745 1743 $ cd ..
1746 1744 $ mv repo-chain repo-source
1747 1745 $ hg init repo-chain
1748 1746 $ cd repo-chain
1749 1747 $ hg pull ../repo-source
1750 1748 pulling from ../repo-source
1751 1749 requesting all changes
1752 1750 adding changesets
1753 1751 adding manifests
1754 1752 adding file changes
1755 1753 added 80 changesets with 44 changes to 25 files (+39 heads)
1756 1754 new changesets a3a31bbefea6:908ce9259ffa
1757 1755 (run 'hg heads' to see heads, 'hg merge' to merge)
1758 1756 #endif
1759 1757
1760 1758 #if push
1761 1759 $ cd ..
1762 1760 $ mv repo-chain repo-source
1763 1761 $ hg init repo-chain
1764 1762 $ cd repo-source
1765 1763 $ hg push ../repo-chain
1766 1764 pushing to ../repo-chain
1767 1765 searching for changes
1768 1766 adding changesets
1769 1767 adding manifests
1770 1768 adding file changes
1771 1769 added 80 changesets with 44 changes to 25 files (+39 heads)
1772 1770 $ cd ../repo-chain
1773 1771 #endif
1774 1772
1775 1773 #if push-upgrade
1776 1774 $ cat >> $HGRCPATH << EOF
1777 1775 > [format]
1778 1776 > exp-use-copies-side-data-changeset = yes
1779 1777 > [experimental]
1780 1778 > changegroup4 = yes
1781 1779 > EOF
1782 1780 $ cd ..
1783 1781 $ mv repo-chain repo-source
1784 1782 $ hg init repo-chain
1785 1783 $ cd repo-source
1786 1784 $ hg push ../repo-chain
1787 1785 pushing to ../repo-chain
1788 1786 searching for changes
1789 1787 adding changesets
1790 1788 adding manifests
1791 1789 adding file changes
1792 1790 added 80 changesets with 44 changes to 25 files (+39 heads)
1793 1791 $ cd ../repo-chain
1794 1792 #endif
1795 1793
1796 1794 #if no-compatibility no-filelog no-changeset
1797 1795
1798 1796 $ hg debugchangedfiles --compute 0
1799 1797 added : a, ;
1800 1798 added : b, ;
1801 1799 added : h, ;
1802 1800 added : p, ;
1803 1801 added : q, ;
1804 1802 added : r, ;
1805 1803
1806 1804 $ for rev in `hg log --rev 'all()' -T '{rev}\n'`; do
1807 1805 > case_id=`hg log -r $rev -T '{word(0, desc, ":")}\n'`
1808 1806 > echo "##### revision \"$case_id\" #####"
1809 1807 > hg debugsidedata -c -v -- $rev
1810 1808 > hg debugchangedfiles $rev
1811 1809 > done
1812 1810 ##### revision "i-0 initial commit" #####
1813 1811 1 sidedata entries
1814 1812 entry-0014 size 64
1815 1813 '\x00\x00\x00\x06\x04\x00\x00\x00\x01\x00\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00\x00\x04\x00\x00\x00\x03\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x00\x04\x00\x00\x00\x06\x00\x00\x00\x00abhpqr'
1816 1814 added : a, ;
1817 1815 added : b, ;
1818 1816 added : h, ;
1819 1817 added : p, ;
1820 1818 added : q, ;
1821 1819 added : r, ;
1822 1820 ##### revision "i-1" #####
1823 1821 1 sidedata entries
1824 1822 entry-0014 size 44
1825 1823 '\x00\x00\x00\x04\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00\x0c\x00\x00\x00\x03\x00\x00\x00\x00\x06\x00\x00\x00\x04\x00\x00\x00\x02acps'
1826 1824 removed : a, ;
1827 1825 added p1: c, a;
1828 1826 removed : p, ;
1829 1827 added p1: s, p;
1830 1828 ##### revision "i-2" #####
1831 1829 1 sidedata entries
1832 1830 entry-0014 size 44
1833 1831 '\x00\x00\x00\x04\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00\x0c\x00\x00\x00\x03\x00\x00\x00\x00\x06\x00\x00\x00\x04\x00\x00\x00\x02cdst'
1834 1832 removed : c, ;
1835 1833 added p1: d, c;
1836 1834 removed : s, ;
1837 1835 added p1: t, s;
1838 1836 ##### revision "a-1" #####
1839 1837 1 sidedata entries
1840 1838 entry-0014 size 24
1841 1839 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00de'
1842 1840 removed : d, ;
1843 1841 added p1: e, d;
1844 1842 ##### revision "a-2" #####
1845 1843 1 sidedata entries
1846 1844 entry-0014 size 24
1847 1845 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00ef'
1848 1846 removed : e, ;
1849 1847 added p1: f, e;
1850 1848 ##### revision "b-1" #####
1851 1849 1 sidedata entries
1852 1850 entry-0014 size 14
1853 1851 '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00b'
1854 1852 touched : b, ;
1855 1853 ##### revision "c-1 delete d" #####
1856 1854 1 sidedata entries
1857 1855 entry-0014 size 14
1858 1856 '\x00\x00\x00\x01\x0c\x00\x00\x00\x01\x00\x00\x00\x00d'
1859 1857 removed : d, ;
1860 1858 ##### revision "d-1 delete d" #####
1861 1859 1 sidedata entries
1862 1860 entry-0014 size 14
1863 1861 '\x00\x00\x00\x01\x0c\x00\x00\x00\x01\x00\x00\x00\x00d'
1864 1862 removed : d, ;
1865 1863 ##### revision "d-2 re-add d" #####
1866 1864 1 sidedata entries
1867 1865 entry-0014 size 14
1868 1866 '\x00\x00\x00\x01\x04\x00\x00\x00\x01\x00\x00\x00\x00d'
1869 1867 added : d, ;
1870 1868 ##### revision "e-1 b -move-> g" #####
1871 1869 1 sidedata entries
1872 1870 entry-0014 size 24
1873 1871 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00bg'
1874 1872 removed : b, ;
1875 1873 added p1: g, b;
1876 1874 ##### revision "e-2 g -move-> f" #####
1877 1875 1 sidedata entries
1878 1876 entry-0014 size 24
1879 1877 '\x00\x00\x00\x02\x06\x00\x00\x00\x01\x00\x00\x00\x01\x0c\x00\x00\x00\x02\x00\x00\x00\x00fg'
1880 1878 added p1: f, g;
1881 1879 removed : g, ;
1882 1880 ##### revision "p-1" #####
1883 1881 1 sidedata entries
1884 1882 entry-0014 size 24
1885 1883 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00tu'
1886 1884 removed : t, ;
1887 1885 added p1: u, t;
1888 1886 ##### revision "p-2" #####
1889 1887 1 sidedata entries
1890 1888 entry-0014 size 24
1891 1889 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00uv'
1892 1890 removed : u, ;
1893 1891 added p1: v, u;
1894 1892 ##### revision "q-1 r -move-> w" #####
1895 1893 1 sidedata entries
1896 1894 entry-0014 size 24
1897 1895 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00rw'
1898 1896 removed : r, ;
1899 1897 added p1: w, r;
1900 1898 ##### revision "q-2 w -move-> v" #####
1901 1899 1 sidedata entries
1902 1900 entry-0014 size 24
1903 1901 '\x00\x00\x00\x02\x06\x00\x00\x00\x01\x00\x00\x00\x01\x0c\x00\x00\x00\x02\x00\x00\x00\x00vw'
1904 1902 added p1: v, w;
1905 1903 removed : w, ;
1906 1904 ##### revision "mBAm-0 simple merge - A side" #####
1907 1905 1 sidedata entries
1908 1906 entry-0014 size 4
1909 1907 '\x00\x00\x00\x00'
1910 1908 ##### revision "mABm-0 simple merge - A side" #####
1911 1909 1 sidedata entries
1912 1910 entry-0014 size 4
1913 1911 '\x00\x00\x00\x00'
1914 1912 ##### revision "mBCm-0 simple merge - C side" #####
1915 1913 1 sidedata entries
1916 1914 entry-0014 size 4
1917 1915 '\x00\x00\x00\x00'
1918 1916 ##### revision "mBCm-1 re-add d" #####
1919 1917 1 sidedata entries
1920 1918 entry-0014 size 14
1921 1919 '\x00\x00\x00\x01\x04\x00\x00\x00\x01\x00\x00\x00\x00d'
1922 1920 added : d, ;
1923 1921 ##### revision "mCBm-0 simple merge - C side" #####
1924 1922 1 sidedata entries
1925 1923 entry-0014 size 4
1926 1924 '\x00\x00\x00\x00'
1927 1925 ##### revision "mCBm-1 re-add d" #####
1928 1926 1 sidedata entries
1929 1927 entry-0014 size 14
1930 1928 '\x00\x00\x00\x01\x04\x00\x00\x00\x01\x00\x00\x00\x00d'
1931 1929 added : d, ;
1932 1930 ##### revision "mBDm-0 simple merge - B side" #####
1933 1931 1 sidedata entries
1934 1932 entry-0014 size 4
1935 1933 '\x00\x00\x00\x00'
1936 1934 ##### revision "mDBm-0 simple merge - B side" #####
1937 1935 1 sidedata entries
1938 1936 entry-0014 size 4
1939 1937 '\x00\x00\x00\x00'
1940 1938 ##### revision "mAEm-0 merge with copies info on both side - A side" #####
1941 1939 1 sidedata entries
1942 1940 entry-0014 size 14
1943 1941 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00f'
1944 1942 merged : f, ;
1945 1943 ##### revision "mEAm-0 merge with copies info on both side - A side" #####
1946 1944 1 sidedata entries
1947 1945 entry-0014 size 14
1948 1946 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00f'
1949 1947 merged : f, ;
1950 1948 ##### revision "mPQm-0 merge with copies info on both side - P side" #####
1951 1949 1 sidedata entries
1952 1950 entry-0014 size 14
1953 1951 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00v'
1954 1952 merged : v, ;
1955 1953 ##### revision "mQPm-0 merge with copies info on both side - P side" #####
1956 1954 1 sidedata entries
1957 1955 entry-0014 size 14
1958 1956 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00v'
1959 1957 merged : v, ;
1960 1958 ##### revision "f-1" #####
1961 1959 1 sidedata entries
1962 1960 entry-0014 size 24
1963 1961 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00hi'
1964 1962 removed : h, ;
1965 1963 added p1: i, h;
1966 1964 ##### revision "f-2" #####
1967 1965 1 sidedata entries
1968 1966 entry-0014 size 24
1969 1967 '\x00\x00\x00\x02\x16\x00\x00\x00\x01\x00\x00\x00\x01\x0c\x00\x00\x00\x02\x00\x00\x00\x00di'
1970 1968 touched p1: d, i;
1971 1969 removed : i, ;
1972 1970 ##### revision "mBFm-0 simple merge - B side" #####
1973 1971 1 sidedata entries
1974 1972 entry-0014 size 4
1975 1973 '\x00\x00\x00\x00'
1976 1974 ##### revision "mFBm-0 simple merge - B side" #####
1977 1975 1 sidedata entries
1978 1976 entry-0014 size 4
1979 1977 '\x00\x00\x00\x00'
1980 1978 ##### revision "r-1" #####
1981 1979 1 sidedata entries
1982 1980 entry-0014 size 24
1983 1981 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00rx'
1984 1982 removed : r, ;
1985 1983 added p1: x, r;
1986 1984 ##### revision "r-2" #####
1987 1985 1 sidedata entries
1988 1986 entry-0014 size 24
1989 1987 '\x00\x00\x00\x02\x16\x00\x00\x00\x01\x00\x00\x00\x01\x0c\x00\x00\x00\x02\x00\x00\x00\x00tx'
1990 1988 touched p1: t, x;
1991 1989 removed : x, ;
1992 1990 ##### revision "mBRm-0 simple merge - B side" #####
1993 1991 1 sidedata entries
1994 1992 entry-0014 size 4
1995 1993 '\x00\x00\x00\x00'
1996 1994 ##### revision "mRBm-0 simple merge - B side" #####
1997 1995 1 sidedata entries
1998 1996 entry-0014 size 4
1999 1997 '\x00\x00\x00\x00'
2000 1998 ##### revision "g-1" #####
2001 1999 1 sidedata entries
2002 2000 entry-0014 size 14
2003 2001 '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00d'
2004 2002 touched : d, ;
2005 2003 ##### revision "mDGm-0 actual content merge, copies on one side - D side" #####
2006 2004 1 sidedata entries
2007 2005 entry-0014 size 14
2008 2006 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d'
2009 2007 merged : d, ;
2010 2008 ##### revision "mGDm-0 actual content merge, copies on one side - D side" #####
2011 2009 1 sidedata entries
2012 2010 entry-0014 size 14
2013 2011 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d'
2014 2012 merged : d, ;
2015 2013 ##### revision "mFGm-0 merge - G side" #####
2016 2014 1 sidedata entries
2017 2015 entry-0014 size 14
2018 2016 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d'
2019 2017 merged : d, ;
2020 2018 ##### revision "mGFm-0 merge - G side" #####
2021 2019 1 sidedata entries
2022 2020 entry-0014 size 14
2023 2021 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00d'
2024 2022 merged : d, ;
2025 2023 ##### revision "mCGm-0 merge updated/deleted - revive the file (updated content) - one way" #####
2026 2024 1 sidedata entries
2027 2025 entry-0014 size 14
2028 2026 '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d'
2029 2027 salvaged : d, ;
2030 2028 ##### revision "mGCm-0 merge updated/deleted - revive the file (updated content) - the other way" #####
2031 2029 1 sidedata entries
2032 2030 entry-0014 size 14
2033 2031 '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d'
2034 2032 salvaged : d, ;
2035 2033 ##### revision "mCB-revert-m-0 merge explicitely revive deleted file - B side" #####
2036 2034 1 sidedata entries
2037 2035 entry-0014 size 14
2038 2036 '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d'
2039 2037 salvaged : d, ;
2040 2038 ##### revision "mBC-revert-m-0 merge explicitely revive deleted file - B side" #####
2041 2039 1 sidedata entries
2042 2040 entry-0014 size 14
2043 2041 '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d'
2044 2042 salvaged : d, ;
2045 2043 ##### revision "h-1" #####
2046 2044 1 sidedata entries
2047 2045 entry-0014 size 24
2048 2046 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00bd'
2049 2047 removed : b, ;
2050 2048 added p1: d, b;
2051 2049 ##### revision "mCH-delete-before-conflict-m-0 simple merge - C side" #####
2052 2050 1 sidedata entries
2053 2051 entry-0014 size 4
2054 2052 '\x00\x00\x00\x00'
2055 2053 ##### revision "mHC-delete-before-conflict-m-0 simple merge - C side" #####
2056 2054 1 sidedata entries
2057 2055 entry-0014 size 4
2058 2056 '\x00\x00\x00\x00'
2059 2057 ##### revision "mAE-change-m-0 merge with file update and copies info on both side - A side" #####
2060 2058 1 sidedata entries
2061 2059 entry-0014 size 14
2062 2060 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00f'
2063 2061 merged : f, ;
2064 2062 ##### revision "mEA-change-m-0 merge with file update and copies info on both side - A side" #####
2065 2063 1 sidedata entries
2066 2064 entry-0014 size 14
2067 2065 '\x00\x00\x00\x01\x08\x00\x00\x00\x01\x00\x00\x00\x00f'
2068 2066 merged : f, ;
2069 2067 ##### revision "mBF-change-m-0 merge with extra change - B side" #####
2070 2068 1 sidedata entries
2071 2069 entry-0014 size 14
2072 2070 '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00d'
2073 2071 touched : d, ;
2074 2072 ##### revision "mFB-change-m-0 merge with extra change - B side" #####
2075 2073 1 sidedata entries
2076 2074 entry-0014 size 14
2077 2075 '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00d'
2078 2076 touched : d, ;
2079 2077 ##### revision "mCB-change-m-0 merge explicitely revive deleted file - B side" #####
2080 2078 1 sidedata entries
2081 2079 entry-0014 size 14
2082 2080 '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d'
2083 2081 salvaged : d, ;
2084 2082 ##### revision "mBC-change-m-0 merge explicitely revive deleted file - B side" #####
2085 2083 1 sidedata entries
2086 2084 entry-0014 size 14
2087 2085 '\x00\x00\x00\x01\x10\x00\x00\x00\x01\x00\x00\x00\x00d'
2088 2086 salvaged : d, ;
2089 2087 ##### revision "j-1" #####
2090 2088 1 sidedata entries
2091 2089 entry-0014 size 24
2092 2090 '\x00\x00\x00\x01\x04\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j'
2093 2091 added : unrelated-j, ;
2094 2092 ##### revision "k-1" #####
2095 2093 1 sidedata entries
2096 2094 entry-0014 size 24
2097 2095 '\x00\x00\x00\x01\x04\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-k'
2098 2096 added : unrelated-k, ;
2099 2097 ##### revision "mAE,Km" #####
2100 2098 1 sidedata entries
2101 2099 entry-0014 size 4
2102 2100 '\x00\x00\x00\x00'
2103 2101 ##### revision "mK,AEm" #####
2104 2102 1 sidedata entries
2105 2103 entry-0014 size 4
2106 2104 '\x00\x00\x00\x00'
2107 2105 ##### revision "mEA,Jm" #####
2108 2106 1 sidedata entries
2109 2107 entry-0014 size 24
2110 2108 '\x00\x00\x00\x01\x14\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j'
2111 2109 touched : unrelated-j, ;
2112 2110 ##### revision "mJ,EAm" #####
2113 2111 1 sidedata entries
2114 2112 entry-0014 size 24
2115 2113 '\x00\x00\x00\x01\x14\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-j'
2116 2114 touched : unrelated-j, ;
2117 2115 ##### revision "s-1" #####
2118 2116 1 sidedata entries
2119 2117 entry-0014 size 24
2120 2118 '\x00\x00\x00\x01\x04\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-s'
2121 2119 added : unrelated-s, ;
2122 2120 ##### revision "t-1" #####
2123 2121 1 sidedata entries
2124 2122 entry-0014 size 24
2125 2123 '\x00\x00\x00\x01\x04\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-t'
2126 2124 added : unrelated-t, ;
2127 2125 ##### revision "mPQ,Tm" #####
2128 2126 1 sidedata entries
2129 2127 entry-0014 size 4
2130 2128 '\x00\x00\x00\x00'
2131 2129 ##### revision "mT,PQm" #####
2132 2130 1 sidedata entries
2133 2131 entry-0014 size 4
2134 2132 '\x00\x00\x00\x00'
2135 2133 ##### revision "mQP,Sm" #####
2136 2134 1 sidedata entries
2137 2135 entry-0014 size 4
2138 2136 '\x00\x00\x00\x00'
2139 2137 ##### revision "mS,QPm" #####
2140 2138 1 sidedata entries
2141 2139 entry-0014 size 4
2142 2140 '\x00\x00\x00\x00'
2143 2141 ##### revision "l-1" #####
2144 2142 1 sidedata entries
2145 2143 entry-0014 size 24
2146 2144 '\x00\x00\x00\x01\x04\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-l'
2147 2145 added : unrelated-l, ;
2148 2146 ##### revision "mBC+revert,Lm" #####
2149 2147 1 sidedata entries
2150 2148 entry-0014 size 4
2151 2149 '\x00\x00\x00\x00'
2152 2150 ##### revision "mCB+revert,Lm" #####
2153 2151 1 sidedata entries
2154 2152 entry-0014 size 4
2155 2153 '\x00\x00\x00\x00'
2156 2154 ##### revision "mL,BC+revertm" #####
2157 2155 1 sidedata entries
2158 2156 entry-0014 size 4
2159 2157 '\x00\x00\x00\x00'
2160 2158 ##### revision "mL,CB+revertm" #####
2161 2159 1 sidedata entries
2162 2160 entry-0014 size 4
2163 2161 '\x00\x00\x00\x00'
2164 2162 ##### revision "n-1" #####
2165 2163 1 sidedata entries
2166 2164 entry-0014 size 24
2167 2165 '\x00\x00\x00\x01\x04\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-n'
2168 2166 added : unrelated-n, ;
2169 2167 ##### revision "o-1" #####
2170 2168 1 sidedata entries
2171 2169 entry-0014 size 24
2172 2170 '\x00\x00\x00\x01\x04\x00\x00\x00\x0b\x00\x00\x00\x00unrelated-o'
2173 2171 added : unrelated-o, ;
2174 2172 ##### revision "mFG,Om" #####
2175 2173 1 sidedata entries
2176 2174 entry-0014 size 4
2177 2175 '\x00\x00\x00\x00'
2178 2176 ##### revision "mO,FGm" #####
2179 2177 1 sidedata entries
2180 2178 entry-0014 size 4
2181 2179 '\x00\x00\x00\x00'
2182 2180 ##### revision "mGF,Nm" #####
2183 2181 1 sidedata entries
2184 2182 entry-0014 size 4
2185 2183 '\x00\x00\x00\x00'
2186 2184 ##### revision "mN,GFm" #####
2187 2185 1 sidedata entries
2188 2186 entry-0014 size 4
2189 2187 '\x00\x00\x00\x00'
2190 2188 ##### revision "mAE-change,Km" #####
2191 2189 1 sidedata entries
2192 2190 entry-0014 size 4
2193 2191 '\x00\x00\x00\x00'
2194 2192 ##### revision "mK,AE-change-m" #####
2195 2193 1 sidedata entries
2196 2194 entry-0014 size 4
2197 2195 '\x00\x00\x00\x00'
2198 2196 ##### revision "mEA-change,Jm" #####
2199 2197 1 sidedata entries
2200 2198 entry-0014 size 4
2201 2199 '\x00\x00\x00\x00'
2202 2200 ##### revision "mJ,EA-change-m" #####
2203 2201 1 sidedata entries
2204 2202 entry-0014 size 4
2205 2203 '\x00\x00\x00\x00'
2206 2204
2207 2205 #endif
2208 2206
2209 2207
2210 2208 Test copy information chaining
2211 2209 ==============================
2212 2210
2213 2211 Check that matching only affect the destination and not intermediate path
2214 2212 -------------------------------------------------------------------------
2215 2213
2216 2214 The two status call should give the same value for f
2217 2215
2218 2216 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("a-2")'
2219 2217 A f
2220 2218 a
2221 2219 A t
2222 2220 p
2223 2221 R a
2224 2222 R p
2225 2223 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("a-2")' f
2226 2224 A f
2227 2225 a (no-changeset no-compatibility !)
2228 2226
2229 2227 merging with unrelated change does not interfere with the renames
2230 2228 ---------------------------------------------------------------
2231 2229
2232 2230 - rename on one side
2233 2231 - unrelated change on the other side
2234 2232
2235 2233 $ hg log -G --rev '::(desc("mABm")+desc("mBAm"))'
2236 2234 o mABm-0 simple merge - A side: multiple renames, B side: unrelated update - the other way
2237 2235 |\
2238 2236 +---o mBAm-0 simple merge - A side: multiple renames, B side: unrelated update - one way
2239 2237 | |/
2240 2238 | o b-1: b update
2241 2239 | |
2242 2240 o | a-2: e -move-> f
2243 2241 | |
2244 2242 o | a-1: d -move-> e
2245 2243 |/
2246 2244 o i-2: c -move-> d, s -move-> t
2247 2245 |
2248 2246 o i-1: a -move-> c, p -move-> s
2249 2247 |
2250 2248 o i-0 initial commit: a b h p q r
2251 2249
2252 2250
2253 2251 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mABm")'
2254 2252 A f
2255 2253 d
2256 2254 R d
2257 2255 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBAm")'
2258 2256 A f
2259 2257 d
2260 2258 R d
2261 2259 $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mABm")'
2262 2260 M b
2263 2261 $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mBAm")'
2264 2262 M b
2265 2263 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mABm")'
2266 2264 M b
2267 2265 A f
2268 2266 d
2269 2267 R d
2270 2268 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBAm")'
2271 2269 M b
2272 2270 A f
2273 2271 d
2274 2272 R d
2275 2273 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mABm")'
2276 2274 M b
2277 2275 A f
2278 2276 a
2279 2277 A t
2280 2278 p
2281 2279 R a
2282 2280 R p
2283 2281 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBAm")'
2284 2282 M b
2285 2283 A f
2286 2284 a
2287 2285 A t
2288 2286 p
2289 2287 R a
2290 2288 R p
2291 2289
2292 2290 merging with the side having a delete
2293 2291 -------------------------------------
2294 2292
2295 2293 case summary:
2296 2294 - one with change to an unrelated file
2297 2295 - one deleting the change
2298 2296 and recreate an unrelated file after the merge
2299 2297
2300 2298 $ hg log -G --rev '::(desc("mCBm")+desc("mBCm"))'
2301 2299 o mCBm-1 re-add d
2302 2300 |
2303 2301 o mCBm-0 simple merge - C side: delete a file with copies history , B side: unrelated update - the other way
2304 2302 |\
2305 2303 | | o mBCm-1 re-add d
2306 2304 | | |
2307 2305 +---o mBCm-0 simple merge - C side: delete a file with copies history , B side: unrelated update - one way
2308 2306 | |/
2309 2307 | o c-1 delete d
2310 2308 | |
2311 2309 o | b-1: b update
2312 2310 |/
2313 2311 o i-2: c -move-> d, s -move-> t
2314 2312 |
2315 2313 o i-1: a -move-> c, p -move-> s
2316 2314 |
2317 2315 o i-0 initial commit: a b h p q r
2318 2316
2319 2317 - comparing from the merge
2320 2318
2321 2319 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBCm-0")'
2322 2320 R d
2323 2321 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mCBm-0")'
2324 2322 R d
2325 2323 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mBCm-0")'
2326 2324 M b
2327 2325 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCBm-0")'
2328 2326 M b
2329 2327 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBCm-0")'
2330 2328 M b
2331 2329 R d
2332 2330 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mCBm-0")'
2333 2331 M b
2334 2332 R d
2335 2333 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBCm-0")'
2336 2334 M b
2337 2335 A t
2338 2336 p
2339 2337 R a
2340 2338 R p
2341 2339 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCBm-0")'
2342 2340 M b
2343 2341 A t
2344 2342 p
2345 2343 R a
2346 2344 R p
2347 2345
2348 2346 - comparing with the merge children re-adding the file
2349 2347
2350 2348 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBCm-1")'
2351 2349 M d
2352 2350 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mCBm-1")'
2353 2351 M d
2354 2352 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mBCm-1")'
2355 2353 M b
2356 2354 A d
2357 2355 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCBm-1")'
2358 2356 M b
2359 2357 A d
2360 2358 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBCm-1")'
2361 2359 M b
2362 2360 M d
2363 2361 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mCBm-1")'
2364 2362 M b
2365 2363 M d
2366 2364 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBCm-1")'
2367 2365 M b
2368 2366 A d
2369 2367 A t
2370 2368 p
2371 2369 R a
2372 2370 R p
2373 2371 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCBm-1")'
2374 2372 M b
2375 2373 A d
2376 2374 A t
2377 2375 p
2378 2376 R a
2379 2377 R p
2380 2378
2381 2379 Comparing with a merge re-adding the file afterward
2382 2380 ---------------------------------------------------
2383 2381
2384 2382 Merge:
2385 2383 - one with change to an unrelated file
2386 2384 - one deleting and recreating the change
2387 2385
2388 2386 $ hg log -G --rev '::(desc("mDBm")+desc("mBDm"))'
2389 2387 o mDBm-0 simple merge - B side: unrelated update, D side: delete and recreate a file (with different content) - the other way
2390 2388 |\
2391 2389 +---o mBDm-0 simple merge - B side: unrelated update, D side: delete and recreate a file (with different content) - one way
2392 2390 | |/
2393 2391 | o d-2 re-add d
2394 2392 | |
2395 2393 | o d-1 delete d
2396 2394 | |
2397 2395 o | b-1: b update
2398 2396 |/
2399 2397 o i-2: c -move-> d, s -move-> t
2400 2398 |
2401 2399 o i-1: a -move-> c, p -move-> s
2402 2400 |
2403 2401 o i-0 initial commit: a b h p q r
2404 2402
2405 2403 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBDm-0")'
2406 2404 M d
2407 2405 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mDBm-0")'
2408 2406 M d
2409 2407 $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mBDm-0")'
2410 2408 M b
2411 2409 $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mDBm-0")'
2412 2410 M b
2413 2411 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mBDm-0")'
2414 2412 M b
2415 2413 M d
2416 2414 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mDBm-0")'
2417 2415 M b
2418 2416 M d
2419 2417
2420 2418 The bugs makes recorded copy is different depending of where we started the merge from since
2421 2419
2422 2420 $ hg manifest --debug --rev 'desc("mBDm-0")' | grep '644 d'
2423 2421 b004912a8510032a0350a74daa2803dadfb00e12 644 d
2424 2422 $ hg manifest --debug --rev 'desc("mDBm-0")' | grep '644 d'
2425 2423 b004912a8510032a0350a74daa2803dadfb00e12 644 d
2426 2424
2427 2425 $ hg manifest --debug --rev 'desc("d-2")' | grep '644 d'
2428 2426 b004912a8510032a0350a74daa2803dadfb00e12 644 d
2429 2427 $ hg manifest --debug --rev 'desc("b-1")' | grep '644 d'
2430 2428 d8252ab2e760b0d4e5288fd44cbd15a0fa567e16 644 d (no-changeset !)
2431 2429 ae258f702dfeca05bf9b6a22a97a4b5645570f11 644 d (changeset !)
2432 2430 $ hg debugindex d | head -n 4 | "$PYTHON" ../no-linkrev
2433 2431 rev linkrev nodeid p1 p2
2434 2432 0 * d8252ab2e760 000000000000 000000000000 (no-changeset !)
2435 2433 0 * ae258f702dfe 000000000000 000000000000 (changeset !)
2436 2434 1 * b004912a8510 000000000000 000000000000
2437 2435 2 * 7b79e2fe0c89 000000000000 000000000000 (no-changeset !)
2438 2436 2 * 5cce88bf349f ae258f702dfe 000000000000 (changeset !)
2439 2437
2440 2438 Log output should not include a merge commit as it did not happen
2441 2439
2442 2440 $ hg log -Gfr 'desc("mBDm-0")' d
2443 2441 o d-2 re-add d
2444 2442 |
2445 2443 ~
2446 2444
2447 2445 $ hg log -Gfr 'desc("mDBm-0")' d
2448 2446 o d-2 re-add d
2449 2447 |
2450 2448 ~
2451 2449
2452 2450 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBDm-0")'
2453 2451 M b
2454 2452 A d
2455 2453 A t
2456 2454 p
2457 2455 R a
2458 2456 R p
2459 2457 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mDBm-0")'
2460 2458 M b
2461 2459 A d
2462 2460 A t
2463 2461 p
2464 2462 R a
2465 2463 R p
2466 2464
2467 2465
2468 2466 Comparing with a merge with colliding rename
2469 2467 --------------------------------------------
2470 2468
2471 2469 Subcase: new copy information on both side
2472 2470 ``````````````````````````````````````````
2473 2471
2474 2472 - the "e-" branch renaming b to f (through 'g')
2475 2473 - the "a-" branch renaming d to f (through e)
2476 2474
2477 2475 $ hg log -G --rev '::(desc("mAEm")+desc("mEAm"))'
2478 2476 o mEAm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - the other way
2479 2477 |\
2480 2478 +---o mAEm-0 merge with copies info on both side - A side: rename d to f, E side: b to f, (same content for f) - one way
2481 2479 | |/
2482 2480 | o e-2 g -move-> f
2483 2481 | |
2484 2482 | o e-1 b -move-> g
2485 2483 | |
2486 2484 o | a-2: e -move-> f
2487 2485 | |
2488 2486 o | a-1: d -move-> e
2489 2487 |/
2490 2488 o i-2: c -move-> d, s -move-> t
2491 2489 |
2492 2490 o i-1: a -move-> c, p -move-> s
2493 2491 |
2494 2492 o i-0 initial commit: a b h p q r
2495 2493
2496 2494 #if no-changeset
2497 2495 $ hg manifest --debug --rev 'desc("mAEm-0")' | grep '644 f'
2498 2496 2ff93c643948464ee1f871867910ae43a45b0bea 644 f
2499 2497 $ hg manifest --debug --rev 'desc("mEAm-0")' | grep '644 f'
2500 2498 2ff93c643948464ee1f871867910ae43a45b0bea 644 f
2501 2499 $ hg manifest --debug --rev 'desc("a-2")' | grep '644 f'
2502 2500 b76eb76580df486c3d51d63c5c210d4dd43a8ac7 644 f
2503 2501 $ hg manifest --debug --rev 'desc("e-2")' | grep '644 f'
2504 2502 e8825b386367b29fec957283a80bb47b47483fe1 644 f
2505 2503 $ hg debugindex f | "$PYTHON" ../no-linkrev
2506 2504 rev linkrev nodeid p1 p2
2507 2505 0 * b76eb76580df 000000000000 000000000000
2508 2506 1 * e8825b386367 000000000000 000000000000
2509 2507 2 * 2ff93c643948 b76eb76580df e8825b386367
2510 2508 3 * 2f649fba7eb2 b76eb76580df e8825b386367
2511 2509 4 * 774e7c1637d5 e8825b386367 b76eb76580df
2512 2510 #else
2513 2511 $ hg manifest --debug --rev 'desc("mAEm-0")' | grep '644 f'
2514 2512 ae258f702dfeca05bf9b6a22a97a4b5645570f11 644 f
2515 2513 $ hg manifest --debug --rev 'desc("mEAm-0")' | grep '644 f'
2516 2514 ae258f702dfeca05bf9b6a22a97a4b5645570f11 644 f
2517 2515 $ hg manifest --debug --rev 'desc("a-2")' | grep '644 f'
2518 2516 ae258f702dfeca05bf9b6a22a97a4b5645570f11 644 f
2519 2517 $ hg manifest --debug --rev 'desc("e-2")' | grep '644 f'
2520 2518 ae258f702dfeca05bf9b6a22a97a4b5645570f11 644 f
2521 2519 $ hg debugindex f | "$PYTHON" ../no-linkrev
2522 2520 rev linkrev nodeid p1 p2
2523 2521 0 * ae258f702dfe 000000000000 000000000000
2524 2522 1 * d3613c1ec831 ae258f702dfe 000000000000
2525 2523 2 * 05e03c868bbc ae258f702dfe 000000000000
2526 2524 #endif
2527 2525
2528 2526 # Here the filelog based implementation is not looking at the rename
2529 2527 # information (because the file exist on both side). However the changelog
2530 2528 # based on works fine. We have different output.
2531 2529
2532 2530 $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mAEm-0")'
2533 2531 M f (no-changeset !)
2534 2532 b (no-filelog no-changeset !)
2535 2533 R b
2536 2534 $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mEAm-0")'
2537 2535 M f (no-changeset !)
2538 2536 b (no-filelog no-changeset !)
2539 2537 R b
2540 2538 $ hg status --copies --rev 'desc("e-2")' --rev 'desc("mAEm-0")'
2541 2539 M f (no-changeset !)
2542 2540 d (no-filelog no-changeset !)
2543 2541 R d
2544 2542 $ hg status --copies --rev 'desc("e-2")' --rev 'desc("mEAm-0")'
2545 2543 M f (no-changeset !)
2546 2544 d (no-filelog no-changeset !)
2547 2545 R d
2548 2546 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("a-2")'
2549 2547 A f
2550 2548 d
2551 2549 R d
2552 2550 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("e-2")'
2553 2551 A f
2554 2552 b
2555 2553 R b
2556 2554
2557 2555 # From here, we run status against revision where both source file exists.
2558 2556 #
2559 2557 # The filelog based implementation picks an arbitrary side based on revision
2560 2558 # numbers. So the same side "wins" whatever the parents order is. This is
2561 2559 # sub-optimal because depending on revision numbers means the result can be
2562 2560 # different from one repository to the next.
2563 2561 #
2564 2562 # The changeset based algorithm use the parent order to break tie on conflicting
2565 2563 # information and will have a different order depending on who is p1 and p2.
2566 2564 # That order is stable accross repositories. (data from p1 prevails)
2567 2565
2568 2566 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mAEm-0")'
2569 2567 A f
2570 2568 d
2571 2569 R b
2572 2570 R d
2573 2571 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mEAm-0")'
2574 2572 A f
2575 2573 d (filelog !)
2576 2574 b (no-filelog !)
2577 2575 R b
2578 2576 R d
2579 2577 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAEm-0")'
2580 2578 A f
2581 2579 a
2582 2580 A t
2583 2581 p
2584 2582 R a
2585 2583 R b
2586 2584 R p
2587 2585 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEAm-0")'
2588 2586 A f
2589 2587 a (filelog !)
2590 2588 b (no-filelog !)
2591 2589 A t
2592 2590 p
2593 2591 R a
2594 2592 R b
2595 2593 R p
2596 2594
2597 2595
2598 2596 Subcase: existing copy information overwritten on one branch
2599 2597 ````````````````````````````````````````````````````````````
2600 2598
2601 2599 Note:
2602 2600 | In this case, one of the merge wrongly record a merge while there is none.
2603 2601 | This lead to bad copy tracing information to be dug up.
2604 2602
2605 2603
2606 2604 Merge:
2607 2605 - one with change to an unrelated file (b)
2608 2606 - one overwriting a file (d) with a rename (from h to i to d)
2609 2607
2610 2608 $ hg log -G --rev '::(desc("mBFm")+desc("mFBm"))'
2611 2609 o mFBm-0 simple merge - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - the other way
2612 2610 |\
2613 2611 +---o mBFm-0 simple merge - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - one way
2614 2612 | |/
2615 2613 | o f-2: rename i -> d
2616 2614 | |
2617 2615 | o f-1: rename h -> i
2618 2616 | |
2619 2617 o | b-1: b update
2620 2618 |/
2621 2619 o i-2: c -move-> d, s -move-> t
2622 2620 |
2623 2621 o i-1: a -move-> c, p -move-> s
2624 2622 |
2625 2623 o i-0 initial commit: a b h p q r
2626 2624
2627 2625 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBFm-0")'
2628 2626 M b
2629 2627 A d
2630 2628 h
2631 2629 A t
2632 2630 p
2633 2631 R a
2634 2632 R h
2635 2633 R p
2636 2634 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFBm-0")'
2637 2635 M b
2638 2636 A d
2639 2637 h
2640 2638 A t
2641 2639 p
2642 2640 R a
2643 2641 R h
2644 2642 R p
2645 2643 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBFm-0")'
2646 2644 M d (no-changeset !)
2647 2645 h (no-filelog no-changeset !)
2648 2646 R h
2649 2647 $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mBFm-0")'
2650 2648 M b
2651 2649 $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mBFm-0")'
2652 2650 M b
2653 2651 M d (no-changeset !)
2654 2652 i (no-filelog no-changeset !)
2655 2653 R i
2656 2654 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mFBm-0")'
2657 2655 M d (no-changeset !)
2658 2656 h (no-filelog no-changeset !)
2659 2657 R h
2660 2658 $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mFBm-0")'
2661 2659 M b
2662 2660 $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mFBm-0")'
2663 2661 M b
2664 2662 M d (no-changeset !)
2665 2663 i (no-filelog no-changeset !)
2666 2664 R i
2667 2665
2668 2666 #if no-changeset
2669 2667 $ hg log -Gfr 'desc("mBFm-0")' d
2670 2668 o f-2: rename i -> d
2671 2669 |
2672 2670 o f-1: rename h -> i
2673 2671 :
2674 2672 o i-0 initial commit: a b h p q r
2675 2673
2676 2674 #else
2677 2675 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
2678 2676 $ hg log -Gfr 'desc("mBFm-0")' d
2679 2677 o i-2: c -move-> d, s -move-> t
2680 2678 |
2681 2679 ~
2682 2680 #endif
2683 2681
2684 2682 #if no-changeset
2685 2683 $ hg log -Gfr 'desc("mFBm-0")' d
2686 2684 o f-2: rename i -> d
2687 2685 |
2688 2686 o f-1: rename h -> i
2689 2687 :
2690 2688 o i-0 initial commit: a b h p q r
2691 2689
2692 2690 #else
2693 2691 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
2694 2692 $ hg log -Gfr 'desc("mFBm-0")' d
2695 2693 o i-2: c -move-> d, s -move-> t
2696 2694 |
2697 2695 ~
2698 2696 #endif
2699 2697
2700 2698
2701 2699 Subcase: existing copy information overwritten on one branch, with different content)
2702 2700 `````````````````````````````````````````````````````````````````````````````````````
2703 2701
2704 2702 Merge:
2705 2703 - one with change to an unrelated file (b)
2706 2704 - one overwriting a file (t) with a rename (from r to x to t), v content is not the same as on the other branch
2707 2705
2708 2706 $ hg log -G --rev '::(desc("mBRm")+desc("mRBm"))'
2709 2707 o mRBm-0 simple merge - B side: unrelated change, R side: overwrite d with a copy (from r->x->t) different content - the other way
2710 2708 |\
2711 2709 +---o mBRm-0 simple merge - B side: unrelated change, R side: overwrite d with a copy (from r->x->t) different content - one way
2712 2710 | |/
2713 2711 | o r-2: rename t -> x
2714 2712 | |
2715 2713 | o r-1: rename r -> x
2716 2714 | |
2717 2715 o | b-1: b update
2718 2716 |/
2719 2717 o i-2: c -move-> d, s -move-> t
2720 2718 |
2721 2719 o i-1: a -move-> c, p -move-> s
2722 2720 |
2723 2721 o i-0 initial commit: a b h p q r
2724 2722
2725 2723 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBRm-0")'
2726 2724 M b
2727 2725 A d
2728 2726 a
2729 2727 A t
2730 2728 r
2731 2729 R a
2732 2730 R p
2733 2731 R r
2734 2732 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mRBm-0")'
2735 2733 M b
2736 2734 A d
2737 2735 a
2738 2736 A t
2739 2737 r
2740 2738 R a
2741 2739 R p
2742 2740 R r
2743 2741 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBRm-0")'
2744 2742 M t
2745 2743 r (no-filelog !)
2746 2744 R r
2747 2745 $ hg status --copies --rev 'desc("r-2")' --rev 'desc("mBRm-0")'
2748 2746 M b
2749 2747 $ hg status --copies --rev 'desc("r-1")' --rev 'desc("mBRm-0")'
2750 2748 M b
2751 2749 M t
2752 2750 x (no-filelog !)
2753 2751 R x
2754 2752 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mRBm-0")'
2755 2753 M t
2756 2754 r (no-filelog !)
2757 2755 R r
2758 2756 $ hg status --copies --rev 'desc("r-2")' --rev 'desc("mRBm-0")'
2759 2757 M b
2760 2758 $ hg status --copies --rev 'desc("r-1")' --rev 'desc("mRBm-0")'
2761 2759 M b
2762 2760 M t
2763 2761 x (no-filelog !)
2764 2762 R x
2765 2763
2766 2764 #if no-changeset
2767 2765 $ hg log -Gfr 'desc("mBRm-0")' d
2768 2766 o i-2: c -move-> d, s -move-> t
2769 2767 |
2770 2768 o i-1: a -move-> c, p -move-> s
2771 2769 |
2772 2770 o i-0 initial commit: a b h p q r
2773 2771
2774 2772 #else
2775 2773 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
2776 2774 $ hg log -Gfr 'desc("mBRm-0")' d
2777 2775 o i-2: c -move-> d, s -move-> t
2778 2776 |
2779 2777 ~
2780 2778 #endif
2781 2779
2782 2780 #if no-changeset
2783 2781 $ hg log -Gfr 'desc("mRBm-0")' d
2784 2782 o i-2: c -move-> d, s -move-> t
2785 2783 |
2786 2784 o i-1: a -move-> c, p -move-> s
2787 2785 |
2788 2786 o i-0 initial commit: a b h p q r
2789 2787
2790 2788 #else
2791 2789 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
2792 2790 $ hg log -Gfr 'desc("mRBm-0")' d
2793 2791 o i-2: c -move-> d, s -move-> t
2794 2792 |
2795 2793 ~
2796 2794 #endif
2797 2795
2798 2796 Subcase: reset of the copy history on one side
2799 2797 ``````````````````````````````````````````````
2800 2798
2801 2799 Merge:
2802 2800 - one with change to a file
2803 2801 - one deleting and recreating the file
2804 2802
2805 2803 Unlike in the 'BD/DB' cases, an actual merge happened here. So we should
2806 2804 consider history and rename on both branch of the merge.
2807 2805
2808 2806 $ hg log -G --rev '::(desc("mDGm")+desc("mGDm"))'
2809 2807 o mGDm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - the other way
2810 2808 |\
2811 2809 +---o mDGm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - one way
2812 2810 | |/
2813 2811 | o g-1: update d
2814 2812 | |
2815 2813 o | d-2 re-add d
2816 2814 | |
2817 2815 o | d-1 delete d
2818 2816 |/
2819 2817 o i-2: c -move-> d, s -move-> t
2820 2818 |
2821 2819 o i-1: a -move-> c, p -move-> s
2822 2820 |
2823 2821 o i-0 initial commit: a b h p q r
2824 2822
2825 2823 One side of the merge have a long history with rename. The other side of the
2826 2824 merge point to a new file with a smaller history. Each side is "valid".
2827 2825
2828 2826 (and again the filelog based algorithm only explore one, with a pick based on
2829 2827 revision numbers)
2830 2828
2831 2829 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mDGm-0")'
2832 2830 A d
2833 2831 a (filelog !)
2834 2832 A t
2835 2833 p
2836 2834 R a
2837 2835 R p
2838 2836 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGDm-0")'
2839 2837 A d
2840 2838 a
2841 2839 A t
2842 2840 p
2843 2841 R a
2844 2842 R p
2845 2843 $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mDGm-0")'
2846 2844 M d
2847 2845 $ hg status --copies --rev 'desc("d-2")' --rev 'desc("mGDm-0")'
2848 2846 M d
2849 2847 $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mDGm-0")'
2850 2848 M d
2851 2849 $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mGDm-0")'
2852 2850 M d
2853 2851
2854 2852 #if no-changeset
2855 2853 $ hg log -Gfr 'desc("mDGm-0")' d
2856 2854 o mDGm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - one way
2857 2855 |\
2858 2856 | o g-1: update d
2859 2857 | |
2860 2858 o | d-2 re-add d
2861 2859 |/
2862 2860 o i-2: c -move-> d, s -move-> t
2863 2861 |
2864 2862 o i-1: a -move-> c, p -move-> s
2865 2863 |
2866 2864 o i-0 initial commit: a b h p q r
2867 2865
2868 2866 #else
2869 2867 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
2870 2868 $ hg log -Gfr 'desc("mDGm-0")' d
2871 2869 o mDGm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - one way
2872 2870 |\
2873 2871 | o g-1: update d
2874 2872 | |
2875 2873 o | d-2 re-add d
2876 2874 |/
2877 2875 o i-2: c -move-> d, s -move-> t
2878 2876 |
2879 2877 ~
2880 2878 #endif
2881 2879
2882 2880
2883 2881 #if no-changeset
2884 2882 $ hg log -Gfr 'desc("mDGm-0")' d
2885 2883 o mDGm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - one way
2886 2884 |\
2887 2885 | o g-1: update d
2888 2886 | |
2889 2887 o | d-2 re-add d
2890 2888 |/
2891 2889 o i-2: c -move-> d, s -move-> t
2892 2890 |
2893 2891 o i-1: a -move-> c, p -move-> s
2894 2892 |
2895 2893 o i-0 initial commit: a b h p q r
2896 2894
2897 2895 #else
2898 2896 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
2899 2897 $ hg log -Gfr 'desc("mDGm-0")' d
2900 2898 o mDGm-0 actual content merge, copies on one side - D side: delete and re-add (different content), G side: update content - one way
2901 2899 |\
2902 2900 | o g-1: update d
2903 2901 | |
2904 2902 o | d-2 re-add d
2905 2903 |/
2906 2904 o i-2: c -move-> d, s -move-> t
2907 2905 |
2908 2906 ~
2909 2907 #endif
2910 2908
2911 2909 Subcase: merging a change to a file with a "copy overwrite" to that file from another branch
2912 2910 ````````````````````````````````````````````````````````````````````````````````````````````
2913 2911
2914 2912 Merge:
2915 2913 - one with change to a file (d)
2916 2914 - one overwriting that file with a rename (from h to i, to d)
2917 2915
2918 2916 This case is similar to BF/FB, but an actual merge happens, so both side of the
2919 2917 history are relevant.
2920 2918
2921 2919
2922 2920 $ hg log -G --rev '::(desc("mGFm")+desc("mFGm"))'
2923 2921 o mGFm-0 merge - G side: content change, F side: copy overwrite, no content change - the other way
2924 2922 |\
2925 2923 +---o mFGm-0 merge - G side: content change, F side: copy overwrite, no content change - one way
2926 2924 | |/
2927 2925 | o g-1: update d
2928 2926 | |
2929 2927 o | f-2: rename i -> d
2930 2928 | |
2931 2929 o | f-1: rename h -> i
2932 2930 |/
2933 2931 o i-2: c -move-> d, s -move-> t
2934 2932 |
2935 2933 o i-1: a -move-> c, p -move-> s
2936 2934 |
2937 2935 o i-0 initial commit: a b h p q r
2938 2936
2939 2937
2940 2938 Note:
2941 2939 | In this case, the merge get conflicting information since on one side we have
2942 2940 | "a -> c -> d". and one the other one we have "h -> i -> d".
2943 2941 |
2944 2942 | The current code arbitrarily pick one side depending the ordering of the merged hash:
2945 2943
2946 2944 In this case, the file hash from "f-2" is lower, so it will be `p1` of the resulting filenode its copy tracing information will win (and trace back to "h"):
2947 2945
2948 2946 Details on this hash ordering pick:
2949 2947
2950 2948 $ hg manifest --debug 'desc("g-1")' | egrep 'd$'
2951 2949 17ec97e605773eb44a117d1136b3849bcdc1924f 644 d (no-changeset !)
2952 2950 5cce88bf349f7c742bb440f2c53f81db9c294279 644 d (changeset !)
2953 2951 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("g-1")' d
2954 2952 A d
2955 2953 a (no-changeset no-compatibility !)
2956 2954
2957 2955 $ hg manifest --debug 'desc("f-2")' | egrep 'd$'
2958 2956 7b79e2fe0c8924e0e598a82f048a7b024afa4d96 644 d (no-changeset !)
2959 2957 ae258f702dfeca05bf9b6a22a97a4b5645570f11 644 d (changeset !)
2960 2958 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("f-2")' d
2961 2959 A d
2962 2960 h (no-changeset no-compatibility !)
2963 2961
2964 2962 Copy tracing data on the resulting merge:
2965 2963
2966 2964 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFGm-0")'
2967 2965 A d
2968 2966 h (no-filelog !)
2969 2967 a (filelog !)
2970 2968 A t
2971 2969 p
2972 2970 R a
2973 2971 R h
2974 2972 R p
2975 2973 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGFm-0")'
2976 2974 A d
2977 2975 a (no-changeset !)
2978 2976 h (changeset !)
2979 2977 A t
2980 2978 p
2981 2979 R a
2982 2980 R h
2983 2981 R p
2984 2982 $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mFGm-0")'
2985 2983 M d
2986 2984 $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mGFm-0")'
2987 2985 M d
2988 2986 $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mFGm-0")'
2989 2987 M d
2990 2988 i (no-filelog !)
2991 2989 R i
2992 2990 $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mGFm-0")'
2993 2991 M d
2994 2992 i (no-filelog !)
2995 2993 R i
2996 2994 $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mFGm-0")'
2997 2995 M d (no-changeset !)
2998 2996 h (no-filelog no-changeset !)
2999 2997 R h
3000 2998 $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mGFm-0")'
3001 2999 M d (no-changeset !)
3002 3000 h (no-filelog no-changeset !)
3003 3001 R h
3004 3002
3005 3003 #if no-changeset
3006 3004 $ hg log -Gfr 'desc("mFGm-0")' d
3007 3005 o mFGm-0 merge - G side: content change, F side: copy overwrite, no content change - one way
3008 3006 |\
3009 3007 | o g-1: update d
3010 3008 | |
3011 3009 o | f-2: rename i -> d
3012 3010 | |
3013 3011 o | f-1: rename h -> i
3014 3012 |/
3015 3013 o i-2: c -move-> d, s -move-> t
3016 3014 |
3017 3015 o i-1: a -move-> c, p -move-> s
3018 3016 |
3019 3017 o i-0 initial commit: a b h p q r
3020 3018
3021 3019 #else
3022 3020 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
3023 3021 $ hg log -Gfr 'desc("mFGm-0")' d
3024 3022 o g-1: update d
3025 3023 |
3026 3024 o i-2: c -move-> d, s -move-> t
3027 3025 |
3028 3026 ~
3029 3027 #endif
3030 3028
3031 3029 #if no-changeset
3032 3030 $ hg log -Gfr 'desc("mGFm-0")' d
3033 3031 o mGFm-0 merge - G side: content change, F side: copy overwrite, no content change - the other way
3034 3032 |\
3035 3033 | o g-1: update d
3036 3034 | |
3037 3035 o | f-2: rename i -> d
3038 3036 | |
3039 3037 o | f-1: rename h -> i
3040 3038 |/
3041 3039 o i-2: c -move-> d, s -move-> t
3042 3040 |
3043 3041 o i-1: a -move-> c, p -move-> s
3044 3042 |
3045 3043 o i-0 initial commit: a b h p q r
3046 3044
3047 3045 #else
3048 3046 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
3049 3047 $ hg log -Gfr 'desc("mGFm-0")' d
3050 3048 o g-1: update d
3051 3049 |
3052 3050 o i-2: c -move-> d, s -move-> t
3053 3051 |
3054 3052 ~
3055 3053 #endif
3056 3054
3057 3055 Subcase: new copy information on both side with an actual merge happening
3058 3056 `````````````````````````````````````````````````````````````````````````
3059 3057
3060 3058 - the "p-" branch renaming 't' to 'v' (through 'u')
3061 3059 - the "q-" branch renaming 'r' to 'v' (through 'w')
3062 3060
3063 3061
3064 3062 $ hg log -G --rev '::(desc("mPQm")+desc("mQPm"))'
3065 3063 o mQPm-0 merge with copies info on both side - P side: rename t to v, Q side: r to v, (different content) - the other way
3066 3064 |\
3067 3065 +---o mPQm-0 merge with copies info on both side - P side: rename t to v, Q side: r to v, (different content) - one way
3068 3066 | |/
3069 3067 | o q-2 w -move-> v
3070 3068 | |
3071 3069 | o q-1 r -move-> w
3072 3070 | |
3073 3071 o | p-2: u -move-> v
3074 3072 | |
3075 3073 o | p-1: t -move-> u
3076 3074 |/
3077 3075 o i-2: c -move-> d, s -move-> t
3078 3076 |
3079 3077 o i-1: a -move-> c, p -move-> s
3080 3078 |
3081 3079 o i-0 initial commit: a b h p q r
3082 3080
3083 3081
3084 3082 #if no-changeset
3085 3083 $ hg manifest --debug --rev 'desc("mPQm-0")' | grep '644 v'
3086 3084 0946c662ef16e4e67397fd717389eb6693d41749 644 v
3087 3085 $ hg manifest --debug --rev 'desc("mQPm-0")' | grep '644 v'
3088 3086 0db3aad7fcc1ec27fab57060e327b9e864ea0cc9 644 v
3089 3087 $ hg manifest --debug --rev 'desc("p-2")' | grep '644 v'
3090 3088 3f91841cd75cadc9a1f1b4e7c1aa6d411f76032e 644 v
3091 3089 $ hg manifest --debug --rev 'desc("q-2")' | grep '644 v'
3092 3090 c43c088b811fd27983c0a9aadf44f3343cd4cd7e 644 v
3093 3091 $ hg debugindex v | "$PYTHON" ../no-linkrev
3094 3092 rev linkrev nodeid p1 p2
3095 3093 0 * 3f91841cd75c 000000000000 000000000000
3096 3094 1 * c43c088b811f 000000000000 000000000000
3097 3095 2 * 0946c662ef16 3f91841cd75c c43c088b811f
3098 3096 3 * 0db3aad7fcc1 c43c088b811f 3f91841cd75c
3099 3097 #else
3100 3098 $ hg manifest --debug --rev 'desc("mPQm-0")' | grep '644 v'
3101 3099 65fde9f6e4d4da23b3f610e07b53673ea9541d75 644 v
3102 3100 $ hg manifest --debug --rev 'desc("mQPm-0")' | grep '644 v'
3103 3101 a098dda6413aecf154eefc976afc38b295acb7e5 644 v
3104 3102 $ hg manifest --debug --rev 'desc("p-2")' | grep '644 v'
3105 3103 5aed6a8dbff0301328c08360d24354d3d064cf0d 644 v
3106 3104 $ hg manifest --debug --rev 'desc("q-2")' | grep '644 v'
3107 3105 a38b2fa170219750dac9bc7d19df831f213ba708 644 v
3108 3106 $ hg debugindex v | "$PYTHON" ../no-linkrev
3109 3107 rev linkrev nodeid p1 p2
3110 3108 0 * 5aed6a8dbff0 000000000000 000000000000
3111 3109 1 * a38b2fa17021 000000000000 000000000000
3112 3110 2 * 65fde9f6e4d4 5aed6a8dbff0 a38b2fa17021
3113 3111 3 * a098dda6413a a38b2fa17021 5aed6a8dbff0
3114 3112 #endif
3115 3113
3116 3114 # Here the filelog based implementation is not looking at the rename
3117 3115 # information (because the file exist on both side). However the changelog
3118 3116 # based on works fine. We have different output.
3119 3117
3120 3118 $ hg status --copies --rev 'desc("p-2")' --rev 'desc("mPQm-0")'
3121 3119 M v
3122 3120 r (no-filelog !)
3123 3121 R r
3124 3122 $ hg status --copies --rev 'desc("p-2")' --rev 'desc("mQPm-0")'
3125 3123 M v
3126 3124 r (no-filelog !)
3127 3125 R r
3128 3126 $ hg status --copies --rev 'desc("q-2")' --rev 'desc("mPQm-0")'
3129 3127 M v
3130 3128 t (no-filelog !)
3131 3129 R t
3132 3130 $ hg status --copies --rev 'desc("q-2")' --rev 'desc("mQPm-0")'
3133 3131 M v
3134 3132 t (no-filelog !)
3135 3133 R t
3136 3134 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("p-2")'
3137 3135 A v
3138 3136 t
3139 3137 R t
3140 3138 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("q-2")'
3141 3139 A v
3142 3140 r
3143 3141 R r
3144 3142
3145 3143 # From here, we run status against revision where both source file exists.
3146 3144 #
3147 3145 # The filelog based implementation picks an arbitrary side based on revision
3148 3146 # numbers. So the same side "wins" whatever the parents order is. This is
3149 3147 # sub-optimal because depending on revision numbers means the result can be
3150 3148 # different from one repository to the next.
3151 3149 #
3152 3150 # The changeset based algorithm use the parent order to break tie on conflicting
3153 3151 # information and will have a different order depending on who is p1 and p2.
3154 3152 # That order is stable accross repositories. (data from p1 prevails)
3155 3153
3156 3154 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mPQm-0")'
3157 3155 A v
3158 3156 t
3159 3157 R r
3160 3158 R t
3161 3159 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mQPm-0")'
3162 3160 A v
3163 3161 t (filelog !)
3164 3162 r (no-filelog !)
3165 3163 R r
3166 3164 R t
3167 3165 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mPQm-0")'
3168 3166 A d
3169 3167 a
3170 3168 A v
3171 3169 r (filelog !)
3172 3170 p (no-filelog !)
3173 3171 R a
3174 3172 R p
3175 3173 R r
3176 3174 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mQPm-0")'
3177 3175 A d
3178 3176 a
3179 3177 A v
3180 3178 r
3181 3179 R a
3182 3180 R p
3183 3181 R r
3184 3182
3185 3183
3186 3184 Comparing with merging with a deletion (and keeping the file)
3187 3185 -------------------------------------------------------------
3188 3186
3189 3187 Merge:
3190 3188 - one removing a file (d)
3191 3189 - one updating that file
3192 3190 - the merge keep the modified version of the file (canceling the delete)
3193 3191
3194 3192 In this case, the file keep on living after the merge. So we should not drop its
3195 3193 copy tracing chain.
3196 3194
3197 3195 $ hg log -G --rev '::(desc("mCGm")+desc("mGCm"))'
3198 3196 o mGCm-0 merge updated/deleted - revive the file (updated content) - the other way
3199 3197 |\
3200 3198 +---o mCGm-0 merge updated/deleted - revive the file (updated content) - one way
3201 3199 | |/
3202 3200 | o g-1: update d
3203 3201 | |
3204 3202 o | c-1 delete d
3205 3203 |/
3206 3204 o i-2: c -move-> d, s -move-> t
3207 3205 |
3208 3206 o i-1: a -move-> c, p -move-> s
3209 3207 |
3210 3208 o i-0 initial commit: a b h p q r
3211 3209
3212 3210
3213 3211 'a' is the copy source of 'd'
3214 3212
3215 3213 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCGm-0")'
3216 3214 A d
3217 3215 a (no-compatibility no-changeset !)
3218 3216 A t
3219 3217 p
3220 3218 R a
3221 3219 R p
3222 3220 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGCm-0")'
3223 3221 A d
3224 3222 a (no-compatibility no-changeset !)
3225 3223 A t
3226 3224 p
3227 3225 R a
3228 3226 R p
3229 3227 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCGm-0")'
3230 3228 A d
3231 3229 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mGCm-0")'
3232 3230 A d
3233 3231 $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mCGm-0")'
3234 3232 $ hg status --copies --rev 'desc("g-1")' --rev 'desc("mGCm-0")'
3235 3233
3236 3234
3237 3235 Comparing with merge restoring an untouched deleted file
3238 3236 --------------------------------------------------------
3239 3237
3240 3238 Merge:
3241 3239 - one removing a file (d)
3242 3240 - one leaving the file untouched
3243 3241 - the merge actively restore the file to the same content.
3244 3242
3245 3243 In this case, the file keep on living after the merge. So we should not drop its
3246 3244 copy tracing chain.
3247 3245
3248 3246 $ hg log -G --rev '::(desc("mCB-revert-m")+desc("mBC-revert-m"))'
3249 3247 o mBC-revert-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - the other way
3250 3248 |\
3251 3249 +---o mCB-revert-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - one way
3252 3250 | |/
3253 3251 | o c-1 delete d
3254 3252 | |
3255 3253 o | b-1: b update
3256 3254 |/
3257 3255 o i-2: c -move-> d, s -move-> t
3258 3256 |
3259 3257 o i-1: a -move-> c, p -move-> s
3260 3258 |
3261 3259 o i-0 initial commit: a b h p q r
3262 3260
3263 3261
3264 3262 'a' is the the copy source of 'd'
3265 3263
3266 3264 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCB-revert-m-0")'
3267 3265 M b
3268 3266 A d
3269 3267 a (no-compatibility no-changeset !)
3270 3268 A t
3271 3269 p
3272 3270 R a
3273 3271 R p
3274 3272 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBC-revert-m-0")'
3275 3273 M b
3276 3274 A d
3277 3275 a (no-compatibility no-changeset !)
3278 3276 A t
3279 3277 p
3280 3278 R a
3281 3279 R p
3282 3280 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCB-revert-m-0")'
3283 3281 M b
3284 3282 A d
3285 3283 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mBC-revert-m-0")'
3286 3284 M b
3287 3285 A d
3288 3286 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mCB-revert-m-0")'
3289 3287 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBC-revert-m-0")'
3290 3288
3291 3289
3292 3290 Merging a branch where a rename was deleted with a branch where the same file was renamed
3293 3291 ------------------------------------------------------------------------------------------
3294 3292
3295 3293 Create a "conflicting" merge where `d` get removed on one branch before its
3296 3294 rename information actually conflict with the other branch.
3297 3295
3298 3296 (the copy information from the branch that was not deleted should win).
3299 3297
3300 3298 $ hg log -G --rev '::(desc("mCH-delete-before-conflict-m")+desc("mHC-delete-before-conflict-m"))'
3301 3299 o mHC-delete-before-conflict-m-0 simple merge - C side: d is the results of renames then deleted, H side: d is result of another rename (same content as the other branch) - the other way
3302 3300 |\
3303 3301 +---o mCH-delete-before-conflict-m-0 simple merge - C side: d is the results of renames then deleted, H side: d is result of another rename (same content as the other branch) - one way
3304 3302 | |/
3305 3303 | o h-1: b -(move)-> d
3306 3304 | |
3307 3305 o | c-1 delete d
3308 3306 | |
3309 3307 o | i-2: c -move-> d, s -move-> t
3310 3308 | |
3311 3309 o | i-1: a -move-> c, p -move-> s
3312 3310 |/
3313 3311 o i-0 initial commit: a b h p q r
3314 3312
3315 3313
3316 3314 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCH-delete-before-conflict-m")'
3317 3315 A d
3318 3316 b (no-compatibility no-changeset !)
3319 3317 A t
3320 3318 p
3321 3319 R a
3322 3320 R b
3323 3321 R p
3324 3322 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mHC-delete-before-conflict-m")'
3325 3323 A d
3326 3324 b
3327 3325 A t
3328 3326 p
3329 3327 R a
3330 3328 R b
3331 3329 R p
3332 3330 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCH-delete-before-conflict-m")'
3333 3331 A d
3334 3332 b
3335 3333 R b
3336 3334 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mHC-delete-before-conflict-m")'
3337 3335 A d
3338 3336 b
3339 3337 R b
3340 3338 $ hg status --copies --rev 'desc("h-1")' --rev 'desc("mCH-delete-before-conflict-m")'
3341 3339 A t
3342 3340 p
3343 3341 R a
3344 3342 R p
3345 3343 $ hg status --copies --rev 'desc("h-1")' --rev 'desc("mHC-delete-before-conflict-m")'
3346 3344 A t
3347 3345 p
3348 3346 R a
3349 3347 R p
3350 3348
3351 3349 Variant of previous with extra changes introduced by the merge
3352 3350 --------------------------------------------------------------
3353 3351
3354 3352 (see case declaration for details)
3355 3353
3356 3354 Subcase: merge has same initial content on both side, but merge introduced a change
3357 3355 ```````````````````````````````````````````````````````````````````````````````````
3358 3356
3359 3357 - the "e-" branch renaming b to f (through 'g')
3360 3358 - the "a-" branch renaming d to f (through e)
3361 3359 - the merge add new change to b
3362 3360
3363 3361 $ hg log -G --rev '::(desc("mAE-change-m")+desc("mEA-change-m"))'
3364 3362 o mEA-change-m-0 merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent) - the other way
3365 3363 |\
3366 3364 +---o mAE-change-m-0 merge with file update and copies info on both side - A side: rename d to f, E side: b to f, (same content for f in parent) - one way
3367 3365 | |/
3368 3366 | o e-2 g -move-> f
3369 3367 | |
3370 3368 | o e-1 b -move-> g
3371 3369 | |
3372 3370 o | a-2: e -move-> f
3373 3371 | |
3374 3372 o | a-1: d -move-> e
3375 3373 |/
3376 3374 o i-2: c -move-> d, s -move-> t
3377 3375 |
3378 3376 o i-1: a -move-> c, p -move-> s
3379 3377 |
3380 3378 o i-0 initial commit: a b h p q r
3381 3379
3382 3380 #if no-changeset
3383 3381 $ hg manifest --debug --rev 'desc("mAE-change-m-0")' | grep '644 f'
3384 3382 2f649fba7eb284e720d02b61f0546fcef694c045 644 f
3385 3383 $ hg manifest --debug --rev 'desc("mEA-change-m-0")' | grep '644 f'
3386 3384 774e7c1637d536b99e2d8ef16fd731f87a82bd09 644 f
3387 3385 $ hg manifest --debug --rev 'desc("a-2")' | grep '644 f'
3388 3386 b76eb76580df486c3d51d63c5c210d4dd43a8ac7 644 f
3389 3387 $ hg manifest --debug --rev 'desc("e-2")' | grep '644 f'
3390 3388 e8825b386367b29fec957283a80bb47b47483fe1 644 f
3391 3389 $ hg debugindex f | "$PYTHON" ../no-linkrev
3392 3390 rev linkrev nodeid p1 p2
3393 3391 0 * b76eb76580df 000000000000 000000000000
3394 3392 1 * e8825b386367 000000000000 000000000000
3395 3393 2 * 2ff93c643948 b76eb76580df e8825b386367
3396 3394 3 * 2f649fba7eb2 b76eb76580df e8825b386367
3397 3395 4 * 774e7c1637d5 e8825b386367 b76eb76580df
3398 3396 #else
3399 3397 $ hg manifest --debug --rev 'desc("mAE-change-m-0")' | grep '644 f'
3400 3398 d3613c1ec8310a812ac4268fd853ac576b6caea5 644 f
3401 3399 $ hg manifest --debug --rev 'desc("mEA-change-m-0")' | grep '644 f'
3402 3400 05e03c868bbcab4a649cb33a238d7aa07398a469 644 f
3403 3401 $ hg manifest --debug --rev 'desc("a-2")' | grep '644 f'
3404 3402 ae258f702dfeca05bf9b6a22a97a4b5645570f11 644 f
3405 3403 $ hg manifest --debug --rev 'desc("e-2")' | grep '644 f'
3406 3404 ae258f702dfeca05bf9b6a22a97a4b5645570f11 644 f
3407 3405 $ hg debugindex f | "$PYTHON" ../no-linkrev
3408 3406 rev linkrev nodeid p1 p2
3409 3407 0 * ae258f702dfe 000000000000 000000000000
3410 3408 1 * d3613c1ec831 ae258f702dfe 000000000000
3411 3409 2 * 05e03c868bbc ae258f702dfe 000000000000
3412 3410 #endif
3413 3411
3414 3412 # Here the filelog based implementation is not looking at the rename
3415 3413 # information (because the file exist on both side). However the changelog
3416 3414 # based on works fine. We have different output.
3417 3415
3418 3416 $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mAE-change-m-0")'
3419 3417 M f
3420 3418 b (no-filelog !)
3421 3419 R b
3422 3420 $ hg status --copies --rev 'desc("a-2")' --rev 'desc("mEA-change-m-0")'
3423 3421 M f
3424 3422 b (no-filelog !)
3425 3423 R b
3426 3424 $ hg status --copies --rev 'desc("e-2")' --rev 'desc("mAE-change-m-0")'
3427 3425 M f
3428 3426 d (no-filelog !)
3429 3427 R d
3430 3428 $ hg status --copies --rev 'desc("e-2")' --rev 'desc("mEA-change-m-0")'
3431 3429 M f
3432 3430 d (no-filelog !)
3433 3431 R d
3434 3432 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("a-2")'
3435 3433 A f
3436 3434 d
3437 3435 R d
3438 3436 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("e-2")'
3439 3437 A f
3440 3438 b
3441 3439 R b
3442 3440
3443 3441 # From here, we run status against revision where both source file exists.
3444 3442 #
3445 3443 # The filelog based implementation picks an arbitrary side based on revision
3446 3444 # numbers. So the same side "wins" whatever the parents order is. This is
3447 3445 # sub-optimal because depending on revision numbers means the result can be
3448 3446 # different from one repository to the next.
3449 3447 #
3450 3448 # The changeset based algorithm use the parent order to break tie on conflicting
3451 3449 # information and will have a different order depending on who is p1 and p2.
3452 3450 # That order is stable accross repositories. (data from p1 prevails)
3453 3451
3454 3452 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mAE-change-m-0")'
3455 3453 A f
3456 3454 d
3457 3455 R b
3458 3456 R d
3459 3457 $ hg status --copies --rev 'desc("i-2")' --rev 'desc("mEA-change-m-0")'
3460 3458 A f
3461 3459 d (filelog !)
3462 3460 b (no-filelog !)
3463 3461 R b
3464 3462 R d
3465 3463 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAE-change-m-0")'
3466 3464 A f
3467 3465 a
3468 3466 A t
3469 3467 p
3470 3468 R a
3471 3469 R b
3472 3470 R p
3473 3471 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEA-change-m-0")'
3474 3472 A f
3475 3473 a (filelog !)
3476 3474 b (no-filelog !)
3477 3475 A t
3478 3476 p
3479 3477 R a
3480 3478 R b
3481 3479 R p
3482 3480
3483 3481
3484 3482 Subcase: merge overwrite common copy information, but with extra change during the merge
3485 3483 ```````````````````````````````````````````````````````````````````````````````````
3486 3484
3487 3485 Merge:
3488 3486 - one with change to an unrelated file (b)
3489 3487 - one overwriting a file (d) with a rename (from h to i to d)
3490 3488
3491 3489 $ hg log -G --rev '::(desc("mBF-change-m")+desc("mFB-change-m"))'
3492 3490 o mFB-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - the other way
3493 3491 |\
3494 3492 +---o mBF-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - one way
3495 3493 | |/
3496 3494 | o f-2: rename i -> d
3497 3495 | |
3498 3496 | o f-1: rename h -> i
3499 3497 | |
3500 3498 o | b-1: b update
3501 3499 |/
3502 3500 o i-2: c -move-> d, s -move-> t
3503 3501 |
3504 3502 o i-1: a -move-> c, p -move-> s
3505 3503 |
3506 3504 o i-0 initial commit: a b h p q r
3507 3505
3508 3506 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBF-change-m-0")'
3509 3507 M b
3510 3508 A d
3511 3509 h
3512 3510 A t
3513 3511 p
3514 3512 R a
3515 3513 R h
3516 3514 R p
3517 3515 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFB-change-m-0")'
3518 3516 M b
3519 3517 A d
3520 3518 h
3521 3519 A t
3522 3520 p
3523 3521 R a
3524 3522 R h
3525 3523 R p
3526 3524 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBF-change-m-0")'
3527 3525 M d
3528 3526 h (no-filelog !)
3529 3527 R h
3530 3528 $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mBF-change-m-0")'
3531 3529 M b
3532 3530 M d
3533 3531 $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mBF-change-m-0")'
3534 3532 M b
3535 3533 M d
3536 3534 i (no-filelog !)
3537 3535 R i
3538 3536 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mFB-change-m-0")'
3539 3537 M d
3540 3538 h (no-filelog !)
3541 3539 R h
3542 3540 $ hg status --copies --rev 'desc("f-2")' --rev 'desc("mFB-change-m-0")'
3543 3541 M b
3544 3542 M d
3545 3543 $ hg status --copies --rev 'desc("f-1")' --rev 'desc("mFB-change-m-0")'
3546 3544 M b
3547 3545 M d
3548 3546 i (no-filelog !)
3549 3547 R i
3550 3548
3551 3549 #if no-changeset
3552 3550 $ hg log -Gfr 'desc("mBF-change-m-0")' d
3553 3551 o mBF-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - one way
3554 3552 |\
3555 3553 o : f-2: rename i -> d
3556 3554 | :
3557 3555 o : f-1: rename h -> i
3558 3556 :/
3559 3557 o i-0 initial commit: a b h p q r
3560 3558
3561 3559 #else
3562 3560 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
3563 3561 $ hg log -Gfr 'desc("mBF-change-m-0")' d
3564 3562 o mBF-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - one way
3565 3563 :
3566 3564 o i-2: c -move-> d, s -move-> t
3567 3565 |
3568 3566 ~
3569 3567 #endif
3570 3568
3571 3569 #if no-changeset
3572 3570 $ hg log -Gfr 'desc("mFB-change-m-0")' d
3573 3571 o mFB-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - the other way
3574 3572 |\
3575 3573 o : f-2: rename i -> d
3576 3574 | :
3577 3575 o : f-1: rename h -> i
3578 3576 :/
3579 3577 o i-0 initial commit: a b h p q r
3580 3578
3581 3579 #else
3582 3580 BROKEN: `hg log --follow <file>` relies on filelog metadata to work
3583 3581 $ hg log -Gfr 'desc("mFB-change-m-0")' d
3584 3582 o mFB-change-m-0 merge with extra change - B side: unrelated change, F side: overwrite d with a copy (from h->i->d) - the other way
3585 3583 :
3586 3584 o i-2: c -move-> d, s -move-> t
3587 3585 |
3588 3586 ~
3589 3587 #endif
3590 3588
3591 3589
3592 3590 Subcase: restoring and untouched deleted file, while touching it
3593 3591 ````````````````````````````````````````````````````````````````
3594 3592
3595 3593 Merge:
3596 3594 - one removing a file (d)
3597 3595 - one leaving the file untouched
3598 3596 - the merge actively restore the file to the same content.
3599 3597
3600 3598 In this case, the file keep on living after the merge. So we should not drop its
3601 3599 copy tracing chain.
3602 3600
3603 3601 $ hg log -G --rev '::(desc("mCB-change-m")+desc("mBC-change-m"))'
3604 3602 o mBC-change-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - the other way
3605 3603 |\
3606 3604 +---o mCB-change-m-0 merge explicitely revive deleted file - B side: unrelated change, C side: delete d (restored by merge) - one way
3607 3605 | |/
3608 3606 | o c-1 delete d
3609 3607 | |
3610 3608 o | b-1: b update
3611 3609 |/
3612 3610 o i-2: c -move-> d, s -move-> t
3613 3611 |
3614 3612 o i-1: a -move-> c, p -move-> s
3615 3613 |
3616 3614 o i-0 initial commit: a b h p q r
3617 3615
3618 3616
3619 3617 'a' is the the copy source of 'd'
3620 3618
3621 3619 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCB-change-m-0")'
3622 3620 M b
3623 3621 A d
3624 3622 a (no-compatibility no-changeset !)
3625 3623 A t
3626 3624 p
3627 3625 R a
3628 3626 R p
3629 3627 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBC-change-m-0")'
3630 3628 M b
3631 3629 A d
3632 3630 a (no-compatibility no-changeset !)
3633 3631 A t
3634 3632 p
3635 3633 R a
3636 3634 R p
3637 3635 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCB-change-m-0")'
3638 3636 M b
3639 3637 A d
3640 3638 $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mBC-change-m-0")'
3641 3639 M b
3642 3640 A d
3643 3641 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mCB-change-m-0")'
3644 3642 M d
3645 3643 $ hg status --copies --rev 'desc("b-1")' --rev 'desc("mBC-change-m-0")'
3646 3644 M d
3647 3645
3648 3646
3649 3647 Decision from previous merge are properly chained with later merge
3650 3648 ------------------------------------------------------------------
3651 3649
3652 3650
3653 3651 Subcase: chaining conflicting rename resolution
3654 3652 ```````````````````````````````````````````````
3655 3653
3656 3654 The "mAEm" and "mEAm" case create a rename tracking conflict on file 'f'. We
3657 3655 add more change on the respective branch and merge again. These second merge
3658 3656 does not involve the file 'f' and the arbitration done within "mAEm" and "mEA"
3659 3657 about that file should stay unchanged.
3660 3658
3661 3659 The result from mAEm is the same for the subsequent merge:
3662 3660
3663 3661 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAEm")' f
3664 3662 A f
3665 3663 a (no-changeset no-compatibility !)
3666 3664
3667 3665 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAE,Km")' f
3668 3666 A f
3669 3667 a (no-changeset no-compatibility !)
3670 3668
3671 3669 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mK,AEm")' f
3672 3670 A f
3673 3671 a (no-changeset no-compatibility !)
3674 3672
3675 3673
3676 3674 The result from mEAm is the same for the subsequent merge:
3677 3675
3678 3676 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEAm")' f
3679 3677 A f
3680 3678 a (filelog !)
3681 3679 b (no-changeset no-compatibility no-filelog !)
3682 3680
3683 3681 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEA,Jm")' f
3684 3682 A f
3685 3683 a (filelog !)
3686 3684 b (no-changeset no-compatibility no-filelog !)
3687 3685
3688 3686 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mJ,EAm")' f
3689 3687 A f
3690 3688 a (filelog !)
3691 3689 b (no-changeset no-compatibility no-filelog !)
3692 3690
3693 3691 Subcase: chaining conflicting rename resolution
3694 3692 ```````````````````````````````````````````````
3695 3693
3696 3694 The "mPQm" and "mQPm" case create a rename tracking conflict on file 'v'. We
3697 3695 add more change on the respective branch and merge again. These second merge
3698 3696 does not involve the file 'v' and the arbitration done within "mPQm" and "mQP"
3699 3697 about that file should stay unchanged.
3700 3698
3701 3699 The result from mPQm is the same for the subsequent merge:
3702 3700
3703 3701 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mPQm")' v
3704 3702 A v
3705 3703 r (filelog !)
3706 3704 p (no-changeset no-compatibility no-filelog !)
3707 3705
3708 3706 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mPQ,Tm")' v
3709 3707 A v
3710 3708 r (filelog !)
3711 3709 p (no-changeset no-compatibility no-filelog !)
3712 3710
3713 3711 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mT,PQm")' v
3714 3712 A v
3715 3713 r (filelog !)
3716 3714 p (no-changeset no-compatibility no-filelog !)
3717 3715
3718 3716 The result from mQPm is the same for the subsequent merge:
3719 3717
3720 3718 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mQPm")' v
3721 3719 A v
3722 3720 r (no-changeset no-compatibility !)
3723 3721
3724 3722 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mQP,Sm")' v
3725 3723 A v
3726 3724 r (no-changeset no-compatibility !)
3727 3725
3728 3726 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mS,QPm")' v
3729 3727 A v
3730 3728 r (filelog !)
3731 3729 r (no-changeset no-compatibility no-filelog !)
3732 3730
3733 3731
3734 3732 Subcase: chaining salvage information during a merge
3735 3733 ````````````````````````````````````````````````````
3736 3734
3737 3735 We add more change on the branch were the file was deleted. merging again
3738 3736 should preserve the fact eh file was salvaged.
3739 3737
3740 3738 reference output:
3741 3739
3742 3740 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCB-revert-m-0")'
3743 3741 M b
3744 3742 A d
3745 3743 a (no-changeset no-compatibility !)
3746 3744 A t
3747 3745 p
3748 3746 R a
3749 3747 R p
3750 3748 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBC-revert-m-0")'
3751 3749 M b
3752 3750 A d
3753 3751 a (no-changeset no-compatibility !)
3754 3752 A t
3755 3753 p
3756 3754 R a
3757 3755 R p
3758 3756
3759 3757 chained output
3760 3758 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBC+revert,Lm")'
3761 3759 M b
3762 3760 A d
3763 3761 a (no-changeset no-compatibility !)
3764 3762 A t
3765 3763 p
3766 3764 A unrelated-l
3767 3765 R a
3768 3766 R p
3769 3767 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCB+revert,Lm")'
3770 3768 M b
3771 3769 A d
3772 3770 a (no-changeset no-compatibility !)
3773 3771 A t
3774 3772 p
3775 3773 A unrelated-l
3776 3774 R a
3777 3775 R p
3778 3776 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mL,BC+revertm")'
3779 3777 M b
3780 3778 A d
3781 3779 a (no-changeset no-compatibility !)
3782 3780 A t
3783 3781 p
3784 3782 A unrelated-l
3785 3783 R a
3786 3784 R p
3787 3785 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mL,CB+revertm")'
3788 3786 M b
3789 3787 A d
3790 3788 a (no-changeset no-compatibility !)
3791 3789 A t
3792 3790 p
3793 3791 A unrelated-l
3794 3792 R a
3795 3793 R p
3796 3794
3797 3795 Subcase: chaining "merged" information during a merge
3798 3796 ``````````````````````````````````````````````````````
3799 3797
3800 3798 When a non-rename change are merged with a copy overwrite, the merge pick the copy source from (p1) as the reference. We should preserve this information in subsequent merges.
3801 3799
3802 3800
3803 3801 reference output:
3804 3802
3805 3803 (for details about the filelog pick, check the mFGm/mGFm case)
3806 3804
3807 3805 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFGm")' d
3808 3806 A d
3809 3807 a (filelog !)
3810 3808 h (no-changeset no-compatibility no-filelog !)
3811 3809 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGFm")' d
3812 3810 A d
3813 3811 a (filelog !)
3814 3812 a (no-changeset no-compatibility no-filelog !)
3815 3813
3816 3814 Chained output
3817 3815
3818 3816 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mO,FGm")' d
3819 3817 A d
3820 3818 a (filelog !)
3821 3819 h (no-changeset no-compatibility no-filelog !)
3822 3820 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mFG,Om")' d
3823 3821 A d
3824 3822 a (filelog !)
3825 3823 h (no-changeset no-compatibility no-filelog !)
3826 3824
3827 3825
3828 3826 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGF,Nm")' d
3829 3827 A d
3830 3828 a (no-changeset no-compatibility !)
3831 3829 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mN,GFm")' d
3832 3830 A d
3833 3831 a (no-changeset no-compatibility !)
3834 3832
3835 3833
3836 3834 Subcase: chaining conflicting rename resolution, with extra change during the merge
3837 3835 ```````````````````````````````````````````````````````````````````````````````````
3838 3836
3839 3837 The "mAEm" and "mEAm" case create a rename tracking conflict on file 'f'. We
3840 3838 add more change on the respective branch and merge again. These second merge
3841 3839 does not involve the file 'f' and the arbitration done within "mAEm" and "mEA"
3842 3840 about that file should stay unchanged.
3843 3841
3844 3842 The result from mAEm is the same for the subsequent merge:
3845 3843
3846 3844 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAE-change-m")' f
3847 3845 A f
3848 3846 a (no-changeset no-compatibility !)
3849 3847
3850 3848 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mAE-change,Km")' f
3851 3849 A f
3852 3850 a (no-changeset no-compatibility !)
3853 3851
3854 3852 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mK,AE-change-m")' f
3855 3853 A f
3856 3854 a (no-changeset no-compatibility !)
3857 3855
3858 3856
3859 3857 The result from mEAm is the same for the subsequent merge:
3860 3858
3861 3859 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEA-change-m")' f
3862 3860 A f
3863 3861 a (filelog !)
3864 3862 b (no-changeset no-compatibility no-filelog !)
3865 3863
3866 3864 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mEA-change,Jm")' f
3867 3865 A f
3868 3866 a (filelog !)
3869 3867 b (no-changeset no-compatibility no-filelog !)
3870 3868
3871 3869 $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mJ,EA-change-m")' f
3872 3870 A f
3873 3871 a (filelog !)
3874 3872 b (no-changeset no-compatibility no-filelog !)
@@ -1,509 +1,509 b''
1 1 #testcases extra sidedata
2 2
3 3 #if extra
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [experimental]
6 6 > copies.write-to=changeset-only
7 7 > copies.read-from=changeset-only
8 8 > [alias]
9 9 > changesetcopies = log -r . -T 'files: {files}
10 10 > {extras % "{ifcontains("files", key, "{key}: {value}\n")}"}
11 11 > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}'
12 12 > EOF
13 13 #endif
14 14
15 15 #if sidedata
16 16 $ cat >> $HGRCPATH << EOF
17 17 > [format]
18 18 > exp-use-copies-side-data-changeset = yes
19 19 > EOF
20 20 #endif
21 21
22 22 $ cat >> $HGRCPATH << EOF
23 23 > [alias]
24 24 > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}'
25 25 > [extensions]
26 26 > rebase =
27 27 > split =
28 28 > EOF
29 29
30 30 Check that copies are recorded correctly
31 31
32 32 $ hg init repo
33 33 $ cd repo
34 34 #if sidedata
35 35 $ hg debugformat -v
36 36 format-variant repo config default
37 37 fncache: yes yes yes
38 38 dotencode: yes yes yes
39 39 generaldelta: yes yes yes
40 40 share-safe: no no no
41 41 sparserevlog: yes yes yes
42 42 persistent-nodemap: no no no (no-rust !)
43 43 persistent-nodemap: yes yes no (rust !)
44 44 copies-sdc: yes yes no
45 revlog-v2: yes yes no
46 changelog-v2: no no no
45 revlog-v2: no no no
46 changelog-v2: yes yes no
47 47 plain-cl-delta: yes yes yes
48 48 compression: zlib zlib zlib (no-zstd !)
49 49 compression: zstd zstd zstd (zstd !)
50 50 compression-level: default default default
51 51 #else
52 52 $ hg debugformat -v
53 53 format-variant repo config default
54 54 fncache: yes yes yes
55 55 dotencode: yes yes yes
56 56 generaldelta: yes yes yes
57 57 share-safe: no no no
58 58 sparserevlog: yes yes yes
59 59 persistent-nodemap: no no no (no-rust !)
60 60 persistent-nodemap: yes yes no (rust !)
61 61 copies-sdc: no no no
62 62 revlog-v2: no no no
63 63 changelog-v2: no no no
64 64 plain-cl-delta: yes yes yes
65 65 compression: zlib zlib zlib (no-zstd !)
66 66 compression: zstd zstd zstd (zstd !)
67 67 compression-level: default default default
68 68 #endif
69 69 $ echo a > a
70 70 $ hg add a
71 71 $ hg ci -m initial
72 72 $ hg cp a b
73 73 $ hg cp a c
74 74 $ hg cp a d
75 75 $ hg ci -m 'copy a to b, c, and d'
76 76
77 77 #if extra
78 78
79 79 $ hg changesetcopies
80 80 files: b c d
81 81 filesadded: 0
82 82 1
83 83 2
84 84
85 85 p1copies: 0\x00a (esc)
86 86 1\x00a (esc)
87 87 2\x00a (esc)
88 88 #else
89 89 $ hg debugsidedata -c -v -- -1
90 90 1 sidedata entries
91 91 entry-0014 size 44
92 92 '\x00\x00\x00\x04\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00\x06\x00\x00\x00\x03\x00\x00\x00\x00\x06\x00\x00\x00\x04\x00\x00\x00\x00abcd'
93 93 #endif
94 94
95 95 $ hg showcopies
96 96 a -> b
97 97 a -> c
98 98 a -> d
99 99
100 100 #if extra
101 101
102 102 $ hg showcopies --config experimental.copies.read-from=compatibility
103 103 a -> b
104 104 a -> c
105 105 a -> d
106 106 $ hg showcopies --config experimental.copies.read-from=filelog-only
107 107
108 108 #endif
109 109
110 110 Check that renames are recorded correctly
111 111
112 112 $ hg mv b b2
113 113 $ hg ci -m 'rename b to b2'
114 114
115 115 #if extra
116 116
117 117 $ hg changesetcopies
118 118 files: b b2
119 119 filesadded: 1
120 120 filesremoved: 0
121 121
122 122 p1copies: 1\x00b (esc)
123 123
124 124 #else
125 125 $ hg debugsidedata -c -v -- -1
126 126 1 sidedata entries
127 127 entry-0014 size 25
128 128 '\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x03\x00\x00\x00\x00bb2'
129 129 #endif
130 130
131 131 $ hg showcopies
132 132 b -> b2
133 133
134 134
135 135 Rename onto existing file. This should get recorded in the changeset files list and in the extras,
136 136 even though there is no filelog entry.
137 137
138 138 $ hg cp b2 c --force
139 139 $ hg st --copies
140 140 M c
141 141 b2
142 142
143 143 #if extra
144 144
145 145 $ hg debugindex c
146 146 rev linkrev nodeid p1 p2
147 147 0 1 b789fdd96dc2 000000000000 000000000000
148 148
149 149 #else
150 150
151 151 $ hg debugindex c
152 152 rev linkrev nodeid p1 p2
153 153 0 1 37d9b5d994ea 000000000000 000000000000
154 154
155 155 #endif
156 156
157 157
158 158 $ hg ci -m 'move b onto d'
159 159
160 160 #if extra
161 161
162 162 $ hg changesetcopies
163 163 files: c
164 164
165 165 p1copies: 0\x00b2 (esc)
166 166
167 167 #else
168 168 $ hg debugsidedata -c -v -- -1
169 169 1 sidedata entries
170 170 entry-0014 size 25
171 171 '\x00\x00\x00\x02\x00\x00\x00\x00\x02\x00\x00\x00\x00\x16\x00\x00\x00\x03\x00\x00\x00\x00b2c'
172 172 #endif
173 173
174 174 $ hg showcopies
175 175 b2 -> c
176 176
177 177 #if extra
178 178
179 179 $ hg debugindex c
180 180 rev linkrev nodeid p1 p2
181 181 0 1 b789fdd96dc2 000000000000 000000000000
182 182
183 183 #else
184 184
185 185 $ hg debugindex c
186 186 rev linkrev nodeid p1 p2
187 187 0 1 37d9b5d994ea 000000000000 000000000000
188 188 1 3 029625640347 000000000000 000000000000
189 189
190 190 #endif
191 191
192 192 Create a merge commit with copying done during merge.
193 193
194 194 $ hg co 0
195 195 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
196 196 $ hg cp a e
197 197 $ hg cp a f
198 198 $ hg ci -m 'copy a to e and f'
199 199 created new head
200 200 $ hg merge 3
201 201 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
202 202 (branch merge, don't forget to commit)
203 203 File 'a' exists on both sides, so 'g' could be recorded as being from p1 or p2, but we currently
204 204 always record it as being from p1
205 205 $ hg cp a g
206 206 File 'd' exists only in p2, so 'h' should be from p2
207 207 $ hg cp d h
208 208 File 'f' exists only in p1, so 'i' should be from p1
209 209 $ hg cp f i
210 210 $ hg ci -m 'merge'
211 211
212 212 #if extra
213 213
214 214 $ hg changesetcopies
215 215 files: g h i
216 216 filesadded: 0
217 217 1
218 218 2
219 219
220 220 p1copies: 0\x00a (esc)
221 221 2\x00f (esc)
222 222 p2copies: 1\x00d (esc)
223 223
224 224 #else
225 225 $ hg debugsidedata -c -v -- -1
226 226 1 sidedata entries
227 227 entry-0014 size 64
228 228 '\x00\x00\x00\x06\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x06\x00\x00\x00\x04\x00\x00\x00\x00\x07\x00\x00\x00\x05\x00\x00\x00\x01\x06\x00\x00\x00\x06\x00\x00\x00\x02adfghi'
229 229 #endif
230 230
231 231 $ hg showcopies
232 232 a -> g
233 233 d -> h
234 234 f -> i
235 235
236 236 Test writing to both changeset and filelog
237 237
238 238 $ hg cp a j
239 239 #if extra
240 240 $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility
241 241 $ hg changesetcopies
242 242 files: j
243 243 filesadded: 0
244 244 filesremoved:
245 245
246 246 p1copies: 0\x00a (esc)
247 247 p2copies:
248 248 #else
249 249 $ hg ci -m 'copy a to j'
250 250 $ hg debugsidedata -c -v -- -1
251 251 1 sidedata entries
252 252 entry-0014 size 24
253 253 '\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00aj'
254 254 #endif
255 255 $ hg debugdata j 0
256 256 \x01 (esc)
257 257 copy: a
258 258 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
259 259 \x01 (esc)
260 260 a
261 261 $ hg showcopies
262 262 a -> j
263 263 $ hg showcopies --config experimental.copies.read-from=compatibility
264 264 a -> j
265 265 $ hg showcopies --config experimental.copies.read-from=filelog-only
266 266 a -> j
267 267 Existing copy information in the changeset gets removed on amend and writing
268 268 copy information on to the filelog
269 269 #if extra
270 270 $ hg ci --amend -m 'copy a to j, v2' \
271 271 > --config experimental.copies.write-to=filelog-only
272 272 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
273 273 $ hg changesetcopies
274 274 files: j
275 275
276 276 #else
277 277 $ hg ci --amend -m 'copy a to j, v2'
278 278 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
279 279 $ hg debugsidedata -c -v -- -1
280 280 1 sidedata entries
281 281 entry-0014 size 24
282 282 '\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00aj'
283 283 #endif
284 284 $ hg showcopies --config experimental.copies.read-from=filelog-only
285 285 a -> j
286 286 The entries should be written to extras even if they're empty (so the client
287 287 won't have to fall back to reading from filelogs)
288 288 $ echo x >> j
289 289 #if extra
290 290 $ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility
291 291 $ hg changesetcopies
292 292 files: j
293 293 filesadded:
294 294 filesremoved:
295 295
296 296 p1copies:
297 297 p2copies:
298 298 #else
299 299 $ hg ci -m 'modify j'
300 300 $ hg debugsidedata -c -v -- -1
301 301 1 sidedata entries
302 302 entry-0014 size 14
303 303 '\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00j'
304 304 #endif
305 305
306 306 Test writing only to filelog
307 307
308 308 $ hg cp a k
309 309 #if extra
310 310 $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only
311 311
312 312 $ hg changesetcopies
313 313 files: k
314 314
315 315 #else
316 316 $ hg ci -m 'copy a to k'
317 317 $ hg debugsidedata -c -v -- -1
318 318 1 sidedata entries
319 319 entry-0014 size 24
320 320 '\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00ak'
321 321 #endif
322 322
323 323 $ hg debugdata k 0
324 324 \x01 (esc)
325 325 copy: a
326 326 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
327 327 \x01 (esc)
328 328 a
329 329 #if extra
330 330 $ hg showcopies
331 331
332 332 $ hg showcopies --config experimental.copies.read-from=compatibility
333 333 a -> k
334 334 $ hg showcopies --config experimental.copies.read-from=filelog-only
335 335 a -> k
336 336 #else
337 337 $ hg showcopies
338 338 a -> k
339 339 #endif
340 340
341 341 $ cd ..
342 342
343 343 Test rebasing a commit with copy information
344 344
345 345 $ hg init rebase-rename
346 346 $ cd rebase-rename
347 347 $ echo a > a
348 348 $ hg ci -Aqm 'add a'
349 349 $ echo a2 > a
350 350 $ hg ci -m 'modify a'
351 351 $ hg co -q 0
352 352 $ hg mv a b
353 353 $ hg ci -qm 'rename a to b'
354 354 Not only do we want this to run in-memory, it shouldn't fall back to
355 355 on-disk merge (no conflicts), so we force it to be in-memory
356 356 with no fallback.
357 357 $ hg rebase -d 1 --config rebase.experimental.inmemory=yes --config devel.rebase.force-in-memory-merge=yes
358 358 rebasing 2:* tip "rename a to b" (glob)
359 359 merging a and b to b
360 360 saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/*-*-rebase.hg (glob)
361 361 $ hg st --change . --copies
362 362 A b
363 363 a
364 364 R a
365 365 $ cd ..
366 366
367 367 Test splitting a commit
368 368
369 369 $ hg init split
370 370 $ cd split
371 371 $ echo a > a
372 372 $ echo b > b
373 373 $ hg ci -Aqm 'add a and b'
374 374 $ echo a2 > a
375 375 $ hg mv b c
376 376 $ hg ci -m 'modify a, move b to c'
377 377 $ hg --config ui.interactive=yes split <<EOF
378 378 > y
379 379 > y
380 380 > n
381 381 > y
382 382 > EOF
383 383 diff --git a/a b/a
384 384 1 hunks, 1 lines changed
385 385 examine changes to 'a'?
386 386 (enter ? for help) [Ynesfdaq?] y
387 387
388 388 @@ -1,1 +1,1 @@
389 389 -a
390 390 +a2
391 391 record this change to 'a'?
392 392 (enter ? for help) [Ynesfdaq?] y
393 393
394 394 diff --git a/b b/c
395 395 rename from b
396 396 rename to c
397 397 examine changes to 'b' and 'c'?
398 398 (enter ? for help) [Ynesfdaq?] n
399 399
400 400 created new head
401 401 diff --git a/b b/c
402 402 rename from b
403 403 rename to c
404 404 examine changes to 'b' and 'c'?
405 405 (enter ? for help) [Ynesfdaq?] y
406 406
407 407 saved backup bundle to $TESTTMP/split/.hg/strip-backup/*-*-split.hg (glob)
408 408 $ cd ..
409 409
410 410 Test committing half a rename
411 411
412 412 $ hg init partial
413 413 $ cd partial
414 414 $ echo a > a
415 415 $ hg ci -Aqm 'add a'
416 416 $ hg mv a b
417 417 $ hg ci -m 'remove a' a
418 418
419 419 #if sidedata
420 420
421 421 Test upgrading/downgrading to sidedata storage
422 422 ==============================================
423 423
424 424 downgrading
425 425
426 426 $ hg debugformat -v
427 427 format-variant repo config default
428 428 fncache: yes yes yes
429 429 dotencode: yes yes yes
430 430 generaldelta: yes yes yes
431 431 share-safe: no no no
432 432 sparserevlog: yes yes yes
433 433 persistent-nodemap: no no no (no-rust !)
434 434 persistent-nodemap: yes yes no (rust !)
435 435 copies-sdc: yes yes no
436 revlog-v2: yes yes no
437 changelog-v2: no no no
436 revlog-v2: no no no
437 changelog-v2: yes yes no
438 438 plain-cl-delta: yes yes yes
439 439 compression: zlib zlib zlib (no-zstd !)
440 440 compression: zstd zstd zstd (zstd !)
441 441 compression-level: default default default
442 442 $ hg debugsidedata -c -- 0
443 443 1 sidedata entries
444 444 entry-0014 size 14
445 445 $ hg debugsidedata -c -- 1
446 446 1 sidedata entries
447 447 entry-0014 size 14
448 448 $ hg debugsidedata -m -- 0
449 449 $ cat << EOF > .hg/hgrc
450 450 > [format]
451 451 > exp-use-copies-side-data-changeset = no
452 452 > [experimental]
453 453 > revlogv2 = enable-unstable-format-and-corrupt-my-data
454 454 > EOF
455 455 $ hg debugupgraderepo --run --quiet --no-backup > /dev/null
456 456 $ hg debugformat -v
457 457 format-variant repo config default
458 458 fncache: yes yes yes
459 459 dotencode: yes yes yes
460 460 generaldelta: yes yes yes
461 461 share-safe: no no no
462 462 sparserevlog: yes yes yes
463 463 persistent-nodemap: no no no (no-rust !)
464 464 persistent-nodemap: yes yes no (rust !)
465 465 copies-sdc: no no no
466 466 revlog-v2: yes yes no
467 467 changelog-v2: no no no
468 468 plain-cl-delta: yes yes yes
469 469 compression: zlib zlib zlib (no-zstd !)
470 470 compression: zstd zstd zstd (zstd !)
471 471 compression-level: default default default
472 472 $ hg debugsidedata -c -- 0
473 473 $ hg debugsidedata -c -- 1
474 474 $ hg debugsidedata -m -- 0
475 475
476 476 upgrading
477 477
478 478 $ cat << EOF > .hg/hgrc
479 479 > [format]
480 480 > exp-use-copies-side-data-changeset = yes
481 481 > EOF
482 482 $ hg debugupgraderepo --run --quiet --no-backup > /dev/null
483 483 $ hg debugformat -v
484 484 format-variant repo config default
485 485 fncache: yes yes yes
486 486 dotencode: yes yes yes
487 487 generaldelta: yes yes yes
488 488 share-safe: no no no
489 489 sparserevlog: yes yes yes
490 490 persistent-nodemap: no no no (no-rust !)
491 491 persistent-nodemap: yes yes no (rust !)
492 492 copies-sdc: yes yes no
493 revlog-v2: yes yes no
494 changelog-v2: no no no
493 revlog-v2: no no no
494 changelog-v2: yes yes no
495 495 plain-cl-delta: yes yes yes
496 496 compression: zlib zlib zlib (no-zstd !)
497 497 compression: zstd zstd zstd (zstd !)
498 498 compression-level: default default default
499 499 $ hg debugsidedata -c -- 0
500 500 1 sidedata entries
501 501 entry-0014 size 14
502 502 $ hg debugsidedata -c -- 1
503 503 1 sidedata entries
504 504 entry-0014 size 14
505 505 $ hg debugsidedata -m -- 0
506 506
507 507 #endif
508 508
509 509 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now