Mercurial > hg-stable
comparison mercurial/obsolete.py @ 18069:f84e731cbd20
obsolete: drop successors sets which are subset of another one
If both "(B,)" and "(B, C)" are successors set of "A", "(B,)" is dropped.
We won't be interrested in detection such divergence scenario.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Sat, 10 Nov 2012 01:56:59 +0100 |
parents | 4bec77e62c00 |
children | af632936d3d9 |
comparison
equal
deleted
inserted
replaced
18068:4bec77e62c00 | 18069:f84e731cbd20 |
---|---|
556 # | 556 # |
557 # Within a marker, a successor may have divergent successors | 557 # Within a marker, a successor may have divergent successors |
558 # sets. In such a case, the marker will contribute multiple | 558 # sets. In such a case, the marker will contribute multiple |
559 # divergent successors sets. If multiple successors have | 559 # divergent successors sets. If multiple successors have |
560 # divergents successors sets, a cartesian product is used. | 560 # divergents successors sets, a cartesian product is used. |
561 # | |
562 # At the end we post-process successors sets to remove | |
563 # duplicated entry and successors set that are strict subset of | |
564 # another one. | |
561 succssets = [] | 565 succssets = [] |
562 for mark in succmarkers[current]: | 566 for mark in succmarkers[current]: |
563 # successors sets contributed by this marker | 567 # successors sets contributed by this marker |
564 markss = [[]] | 568 markss = [[]] |
565 for suc in mark[1]: | 569 for suc in mark[1]: |
570 # cardinal product with previous successors | |
566 productresult = [] | 571 productresult = [] |
567 for prefix in markss: | 572 for prefix in markss: |
568 for suffix in cache[suc]: | 573 for suffix in cache[suc]: |
569 newss = list(prefix) | 574 newss = list(prefix) |
570 for part in suffix: | 575 for part in suffix: |
573 if part not in newss: | 578 if part not in newss: |
574 newss.append(part) | 579 newss.append(part) |
575 productresult.append(newss) | 580 productresult.append(newss) |
576 markss = productresult | 581 markss = productresult |
577 succssets.extend(markss) | 582 succssets.extend(markss) |
578 cache[current] = list(set(tuple(r) for r in succssets if r)) | 583 # remove duplicated and subset |
584 seen = [] | |
585 final = [] | |
586 candidate = sorted(((set(s), s) for s in succssets if s), | |
587 key=lambda x: len(x[1]), reverse=True) | |
588 for setversion, listversion in candidate: | |
589 for seenset in seen: | |
590 if setversion.issubset(seenset): | |
591 break | |
592 else: | |
593 final.append(listversion) | |
594 seen.append(setversion) | |
595 final.reverse() # put small successors set first | |
596 cache[current] = final | |
579 return cache[initialnode] | 597 return cache[initialnode] |
580 | 598 |
581 def _knownrevs(repo, nodes): | 599 def _knownrevs(repo, nodes): |
582 """yield revision numbers of known nodes passed in parameters | 600 """yield revision numbers of known nodes passed in parameters |
583 | 601 |