Mercurial > hg
comparison mercurial/copies.py @ 30208:87a7c0d403ff
copies: improve assertions during copy recombination
- Make sure there is nothing to recombine in non-graftlike scenarios
- More pythonic assert syntax
author | Gábor Stefanik <gabor.stefanik@nng.com> |
---|---|
date | Tue, 18 Oct 2016 02:09:08 +0200 |
parents | 1894c830ee74 |
children | 69ffbbe73dd0 |
comparison
equal
deleted
inserted
replaced
30207:abe723002509 | 30208:87a7c0d403ff |
---|---|
445 if bothnew: | 445 if bothnew: |
446 repo.ui.debug(" unmatched files new in both:\n %s\n" | 446 repo.ui.debug(" unmatched files new in both:\n %s\n" |
447 % "\n ".join(bothnew)) | 447 % "\n ".join(bothnew)) |
448 bothdiverge = {} | 448 bothdiverge = {} |
449 bothincompletediverge = {} | 449 bothincompletediverge = {} |
450 remainder = {} | |
450 both1 = {'copy': {}, | 451 both1 = {'copy': {}, |
451 'fullcopy': {}, | 452 'fullcopy': {}, |
452 'incomplete': {}, | 453 'incomplete': {}, |
453 'diverge': bothdiverge, | 454 'diverge': bothdiverge, |
454 'incompletediverge': bothincompletediverge | 455 'incompletediverge': bothincompletediverge |
461 } | 462 } |
462 for f in bothnew: | 463 for f in bothnew: |
463 _checkcopies(c1, f, m1, m2, base, tca, dirtyc1, limit, both1) | 464 _checkcopies(c1, f, m1, m2, base, tca, dirtyc1, limit, both1) |
464 _checkcopies(c2, f, m2, m1, base, tca, dirtyc2, limit, both2) | 465 _checkcopies(c2, f, m2, m1, base, tca, dirtyc2, limit, both2) |
465 if dirtyc1: | 466 if dirtyc1: |
466 assert both2['incomplete'] == {} | 467 # incomplete copies may only be found on the "dirty" side for bothnew |
468 assert not both2['incomplete'] | |
467 remainder = _combinecopies({}, both1['incomplete'], copy, bothdiverge, | 469 remainder = _combinecopies({}, both1['incomplete'], copy, bothdiverge, |
468 bothincompletediverge) | 470 bothincompletediverge) |
469 else: | 471 elif dirtyc2: |
470 assert both1['incomplete'] == {} | 472 assert not both1['incomplete'] |
471 remainder = _combinecopies({}, both2['incomplete'], copy, bothdiverge, | 473 remainder = _combinecopies({}, both2['incomplete'], copy, bothdiverge, |
472 bothincompletediverge) | 474 bothincompletediverge) |
475 else: | |
476 # incomplete copies and divergences can't happen outside grafts | |
477 assert not both1['incomplete'] | |
478 assert not both2['incomplete'] | |
479 assert not bothincompletediverge | |
473 for f in remainder: | 480 for f in remainder: |
474 assert f not in bothdiverge | 481 assert f not in bothdiverge |
475 ic = remainder[f] | 482 ic = remainder[f] |
476 if ic[0] in (m1 if dirtyc1 else m2): | 483 if ic[0] in (m1 if dirtyc1 else m2): |
477 # backed-out rename on one side, but watch out for deleted files | 484 # backed-out rename on one side, but watch out for deleted files |