Mercurial > public > mercurial-scm > hg
comparison mercurial/exchange.py @ 36938:8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
This will help extensions to alter the behavior as they see fit.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 09 Mar 2018 15:53:41 +0100 |
parents | cc51b6a07869 |
children | c0e90df1ab1e |
comparison
equal
deleted
inserted
replaced
36937:cc51b6a07869 | 36938:8fd9b56e8d7c |
---|---|
622 def hexifycompbookmarks(bookmarks): | 622 def hexifycompbookmarks(bookmarks): |
623 return [(b, safehex(scid), safehex(dcid)) | 623 return [(b, safehex(scid), safehex(dcid)) |
624 for (b, scid, dcid) in bookmarks] | 624 for (b, scid, dcid) in bookmarks] |
625 | 625 |
626 comp = [hexifycompbookmarks(marks) for marks in comp] | 626 comp = [hexifycompbookmarks(marks) for marks in comp] |
627 return _processcompared(pushop, ancestors, explicit, remotebookmark, comp) | |
628 | |
629 def _processcompared(pushop, pushed, explicit, remotebms, comp): | |
630 """take decision on bookmark to pull from the remote bookmark | |
631 | |
632 Exist to help extensions who want to alter this behavior. | |
633 """ | |
627 addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp | 634 addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp |
635 | |
636 repo = pushop.repo | |
628 | 637 |
629 for b, scid, dcid in advsrc: | 638 for b, scid, dcid in advsrc: |
630 if b in explicit: | 639 if b in explicit: |
631 explicit.remove(b) | 640 explicit.remove(b) |
632 if not ancestors or repo[scid].rev() in ancestors: | 641 if not pushed or repo[scid].rev() in pushed: |
633 pushop.outbookmarks.append((b, dcid, scid)) | 642 pushop.outbookmarks.append((b, dcid, scid)) |
634 # search added bookmark | 643 # search added bookmark |
635 for b, scid, dcid in addsrc: | 644 for b, scid, dcid in addsrc: |
636 if b in explicit: | 645 if b in explicit: |
637 explicit.remove(b) | 646 explicit.remove(b) |
653 explicit.remove(b) | 662 explicit.remove(b) |
654 | 663 |
655 if explicit: | 664 if explicit: |
656 explicit = sorted(explicit) | 665 explicit = sorted(explicit) |
657 # we should probably list all of them | 666 # we should probably list all of them |
658 ui.warn(_('bookmark %s does not exist on the local ' | 667 pushop.ui.warn(_('bookmark %s does not exist on the local ' |
659 'or remote repository!\n') % explicit[0]) | 668 'or remote repository!\n') % explicit[0]) |
660 pushop.bkresult = 2 | 669 pushop.bkresult = 2 |
661 | 670 |
662 pushop.outbookmarks.sort() | 671 pushop.outbookmarks.sort() |
663 | 672 |
664 def _pushcheckoutgoing(pushop): | 673 def _pushcheckoutgoing(pushop): |