Show More
@@ -452,44 +452,30 b' def mergecopies(repo, c1, c2, base):' | |||
|
452 | 452 | |
|
453 | 453 | ```other changed <file> which local deleted``` |
|
454 | 454 | |
|
455 | Returns five dicts: "copy", "movewithdir", "diverge", "renamedelete" and | |
|
456 | "dirmove". | |
|
455 | Returns a tuple where: | |
|
457 | 456 | |
|
458 | "copy" is a mapping from destination name -> source name, | |
|
459 | where source is in c1 and destination is in c2 or vice-versa. | |
|
460 | ||
|
461 | "movewithdir" is a mapping from source name -> destination name, | |
|
462 | where the file at source present in one context but not the other | |
|
463 | needs to be moved to destination by the merge process, because the | |
|
464 | other context moved the directory it is in. | |
|
457 | "branch_copies" an instance of branch_copies. | |
|
465 | 458 | |
|
466 | 459 | "diverge" is a mapping of source name -> list of destination names |
|
467 | 460 | for divergent renames. |
|
468 | 461 | |
|
469 | "renamedelete" is a mapping of source name -> list of destination | |
|
470 | names for files deleted in c1 that were renamed in c2 or vice-versa. | |
|
471 | ||
|
472 | "dirmove" is a mapping of detected source dir -> destination dir renames. | |
|
473 | This is needed for handling changes to new files previously grafted into | |
|
474 | renamed directories. | |
|
475 | ||
|
476 | 462 | This function calls different copytracing algorithms based on config. |
|
477 | 463 | """ |
|
478 | 464 | # avoid silly behavior for update from empty dir |
|
479 | 465 | if not c1 or not c2 or c1 == c2: |
|
480 | return {}, {}, {}, {}, {} | |
|
466 | return branch_copies(), {} | |
|
481 | 467 | |
|
482 | 468 | narrowmatch = c1.repo().narrowmatch() |
|
483 | 469 | |
|
484 | 470 | # avoid silly behavior for parent -> working dir |
|
485 | 471 | if c2.node() is None and c1.node() == repo.dirstate.p1(): |
|
486 |
return _dirstatecopies(repo, narrowmatch) |
|
|
472 | return branch_copies(_dirstatecopies(repo, narrowmatch)), {} | |
|
487 | 473 | |
|
488 | 474 | copytracing = repo.ui.config(b'experimental', b'copytrace') |
|
489 | 475 | if stringutil.parsebool(copytracing) is False: |
|
490 | 476 | # stringutil.parsebool() returns None when it is unable to parse the |
|
491 | 477 | # value, so we should rely on making sure copytracing is on such cases |
|
492 | return {}, {}, {}, {}, {} | |
|
478 | return branch_copies(), {} | |
|
493 | 479 | |
|
494 | 480 | if usechangesetcentricalgo(repo): |
|
495 | 481 | # The heuristics don't make sense when we need changeset-centric algos |
@@ -548,6 +534,34 b' def _checksinglesidecopies(' | |||
|
548 | 534 | copy[dst] = src |
|
549 | 535 | |
|
550 | 536 | |
|
537 | class branch_copies(object): | |
|
538 | """Information about copies made on one side of a merge/graft. | |
|
539 | ||
|
540 | "copy" is a mapping from destination name -> source name, | |
|
541 | where source is in c1 and destination is in c2 or vice-versa. | |
|
542 | ||
|
543 | "movewithdir" is a mapping from source name -> destination name, | |
|
544 | where the file at source present in one context but not the other | |
|
545 | needs to be moved to destination by the merge process, because the | |
|
546 | other context moved the directory it is in. | |
|
547 | ||
|
548 | "renamedelete" is a mapping of source name -> list of destination | |
|
549 | names for files deleted in c1 that were renamed in c2 or vice-versa. | |
|
550 | ||
|
551 | "dirmove" is a mapping of detected source dir -> destination dir renames. | |
|
552 | This is needed for handling changes to new files previously grafted into | |
|
553 | renamed directories. | |
|
554 | """ | |
|
555 | ||
|
556 | def __init__( | |
|
557 | self, copy=None, renamedelete=None, dirmove=None, movewithdir=None | |
|
558 | ): | |
|
559 | self.copy = {} if copy is None else copy | |
|
560 | self.renamedelete = {} if renamedelete is None else renamedelete | |
|
561 | self.dirmove = {} if dirmove is None else dirmove | |
|
562 | self.movewithdir = {} if movewithdir is None else movewithdir | |
|
563 | ||
|
564 | ||
|
551 | 565 | def _fullcopytracing(repo, c1, c2, base): |
|
552 | 566 | """ The full copytracing algorithm which finds all the new files that were |
|
553 | 567 | added from merge base up to the top commit and for each file it checks if |
@@ -564,7 +578,7 b' def _fullcopytracing(repo, c1, c2, base)' | |||
|
564 | 578 | copies2 = pathcopies(base, c2) |
|
565 | 579 | |
|
566 | 580 | if not (copies1 or copies2): |
|
567 | return {}, {}, {}, {}, {} | |
|
581 | return branch_copies(), {} | |
|
568 | 582 | |
|
569 | 583 | inversecopies1 = {} |
|
570 | 584 | inversecopies2 = {} |
@@ -672,7 +686,7 b' def _fullcopytracing(repo, c1, c2, base)' | |||
|
672 | 686 | movewithdir1.update(movewithdir2) |
|
673 | 687 | dirmove1.update(dirmove2) |
|
674 | 688 | |
|
675 | return copy1, movewithdir1, diverge, renamedelete1, dirmove1 | |
|
689 | return branch_copies(copy1, renamedelete1, dirmove1, movewithdir1), diverge | |
|
676 | 690 | |
|
677 | 691 | |
|
678 | 692 | def _dir_renames(repo, ctx, copy, fullcopy, addedfiles): |
@@ -846,7 +860,7 b' def _heuristicscopytracing(repo, c1, c2,' | |||
|
846 | 860 | # of upstream copytracing |
|
847 | 861 | copies[candidate] = f |
|
848 | 862 | |
|
849 |
return copies |
|
|
863 | return branch_copies(copies), {} | |
|
850 | 864 | |
|
851 | 865 | |
|
852 | 866 | def _related(f1, f2): |
@@ -1264,8 +1264,11 b' def manifestmerge(' | |||
|
1264 | 1264 | |
|
1265 | 1265 | copy, movewithdir, diverge, renamedelete, dirmove = {}, {}, {}, {}, {} |
|
1266 | 1266 | if followcopies: |
|
1267 |
|
|
|
1268 | copy, movewithdir, diverge, renamedelete, dirmove = ret | |
|
1267 | branch_copies, diverge = copies.mergecopies(repo, wctx, p2, pa) | |
|
1268 | copy = branch_copies.copy | |
|
1269 | renamedelete = branch_copies.renamedelete | |
|
1270 | dirmove = branch_copies.dirmove | |
|
1271 | movewithdir = branch_copies.movewithdir | |
|
1269 | 1272 | |
|
1270 | 1273 | boolbm = pycompat.bytestr(bool(branchmerge)) |
|
1271 | 1274 | boolf = pycompat.bytestr(bool(force)) |
General Comments 0
You need to be logged in to leave comments.
Login now