Mercurial > hg
comparison mercurial/copies.py @ 44162:baf3fe2977cc
copies: move early return in mergecopies() earlier
It wasn't obvious that the early return happened only when there are
no copies. That is the case, however, because if `fullcopy` is empty,
then so is `copies1` and `copies2`, and then so is `inversecopies1`
and `inversecopies2`, and then so is `allsources`, and then so is
`copy`, `diverge` and `renamedelete`.
By moving the early return earlier, we also avoid calculating the set
of added files from the base to each side.
Differential Revision: https://phab.mercurial-scm.org/D7975
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 22 Jan 2020 15:20:12 -0800 |
parents | 06e7e7652ac0 |
children | 782e0d9c3b74 |
comparison
equal
deleted
inserted
replaced
44161:d7622fdec3b5 | 44162:baf3fe2977cc |
---|---|
561 mb = base.manifest() | 561 mb = base.manifest() |
562 | 562 |
563 copies1 = pathcopies(base, c1) | 563 copies1 = pathcopies(base, c1) |
564 copies2 = pathcopies(base, c2) | 564 copies2 = pathcopies(base, c2) |
565 | 565 |
566 if not (copies1 or copies2): | |
567 return {}, {}, {}, {}, {} | |
568 | |
566 inversecopies1 = {} | 569 inversecopies1 = {} |
567 inversecopies2 = {} | 570 inversecopies2 = {} |
568 for dst, src in copies1.items(): | 571 for dst, src in copies1.items(): |
569 inversecopies1.setdefault(src, []).append(dst) | 572 inversecopies1.setdefault(src, []).append(dst) |
570 for dst, src in copies2.items(): | 573 for dst, src in copies2.items(): |
630 if u2: | 633 if u2: |
631 repo.ui.debug(b"%s:\n %s\n" % (header % b'other', b"\n ".join(u2))) | 634 repo.ui.debug(b"%s:\n %s\n" % (header % b'other', b"\n ".join(u2))) |
632 | 635 |
633 fullcopy = copies1.copy() | 636 fullcopy = copies1.copy() |
634 fullcopy.update(copies2) | 637 fullcopy.update(copies2) |
635 if not fullcopy: | |
636 return copy, {}, diverge, renamedelete, {} | |
637 | 638 |
638 if repo.ui.debugflag: | 639 if repo.ui.debugflag: |
639 repo.ui.debug( | 640 repo.ui.debug( |
640 b" all copies found (* = to merge, ! = divergent, " | 641 b" all copies found (* = to merge, ! = divergent, " |
641 b"% = renamed and deleted):\n" | 642 b"% = renamed and deleted):\n" |