Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/scmutil.py @ 40873:b7823bd59b07
cleanupnodes: trust caller when "moves" is not None
If "moves" (indicating how to move bookmarks) is None, we fill it out
based on "replacements" (indicating which obsmarkers to add). If
"moves" is not None, we would still add items based on
"replacements". This makes it impossible to pass "moves={}" and not
move bookmarks, which surprised me. The only caller that currently
passes a value for "moves" was the rebase extension and there we were
already adding bookmark moves corresponding to obsmarker additions, so
it should not be impacted.
Differential Revision: https://phab.mercurial-scm.org/D5391
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 21 Mar 2018 16:46:28 -0700 |
parents | 65591a513b9c |
children | a714eee1ac28 |
comparison
equal
deleted
inserted
replaced
40872:236af7cfa4c3 | 40873:b7823bd59b07 |
---|---|
899 if not isinstance(key, tuple): | 899 if not isinstance(key, tuple): |
900 key = (key,) | 900 key = (key,) |
901 repls[key] = value | 901 repls[key] = value |
902 replacements = repls | 902 replacements = repls |
903 | 903 |
904 # Unfiltered repo is needed since nodes in replacements might be hidden. | |
905 unfi = repo.unfiltered() | |
906 | |
904 # Calculate bookmark movements | 907 # Calculate bookmark movements |
905 if moves is None: | 908 if moves is None: |
906 moves = {} | 909 moves = {} |
907 # Unfiltered repo is needed since nodes in replacements might be hidden. | 910 for oldnodes, newnodes in replacements.items(): |
908 unfi = repo.unfiltered() | 911 for oldnode in oldnodes: |
909 for oldnodes, newnodes in replacements.items(): | 912 if oldnode in moves: |
910 for oldnode in oldnodes: | 913 continue |
911 if oldnode in moves: | 914 if len(newnodes) > 1: |
912 continue | 915 # usually a split, take the one with biggest rev number |
913 if len(newnodes) > 1: | 916 newnode = next(unfi.set('max(%ln)', newnodes)).node() |
914 # usually a split, take the one with biggest rev number | 917 elif len(newnodes) == 0: |
915 newnode = next(unfi.set('max(%ln)', newnodes)).node() | 918 # move bookmark backwards |
916 elif len(newnodes) == 0: | 919 allreplaced = [] |
917 # move bookmark backwards | 920 for rep in replacements: |
918 allreplaced = [] | 921 allreplaced.extend(rep) |
919 for rep in replacements: | 922 roots = list(unfi.set('max((::%n) - %ln)', oldnode, |
920 allreplaced.extend(rep) | 923 allreplaced)) |
921 roots = list(unfi.set('max((::%n) - %ln)', oldnode, | 924 if roots: |
922 allreplaced)) | 925 newnode = roots[0].node() |
923 if roots: | 926 else: |
924 newnode = roots[0].node() | 927 newnode = nullid |
925 else: | 928 else: |
926 newnode = nullid | 929 newnode = newnodes[0] |
927 else: | 930 moves[oldnode] = newnode |
928 newnode = newnodes[0] | |
929 moves[oldnode] = newnode | |
930 | 931 |
931 allnewnodes = [n for ns in replacements.values() for n in ns] | 932 allnewnodes = [n for ns in replacements.values() for n in ns] |
932 toretract = {} | 933 toretract = {} |
933 toadvance = {} | 934 toadvance = {} |
934 if fixphase: | 935 if fixphase: |