##// END OF EJS Templates
cleanupnodes: trust caller when "moves" is not None...
Martin von Zweigbergk -
r40890:b7823bd5 default
parent child Browse files
Show More
@@ -901,32 +901,33 b' def cleanupnodes(repo, replacements, ope'
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 = {}
General Comments 0
You need to be logged in to leave comments. Login now