hgext/histedit.py
changeset 33346 7aa5160bdbf5
parent 33345 4192694b4844
child 33347 dc318f93bd77
equal deleted inserted replaced
33345:4192694b4844 33346:7aa5160bdbf5
  1539         r = state.repo.changelog.rev
  1539         r = state.repo.changelog.rev
  1540         newtopmost = state.repo[sorted(final, key=r)[0]].p1().node()
  1540         newtopmost = state.repo[sorted(final, key=r)[0]].p1().node()
  1541 
  1541 
  1542     return final, tmpnodes, new, newtopmost
  1542     return final, tmpnodes, new, newtopmost
  1543 
  1543 
       
  1544 def movetopmostbookmarks(repo, oldtopmost, newtopmost):
       
  1545     """Move bookmark from oldtopmost to newly created topmost
       
  1546 
       
  1547     This is arguably a feature and we may only want that for the active
       
  1548     bookmark. But the behavior is kept compatible with the old version for now.
       
  1549     """
       
  1550     if not oldtopmost or not newtopmost:
       
  1551         return
       
  1552     oldbmarks = repo.nodebookmarks(oldtopmost)
       
  1553     if oldbmarks:
       
  1554         with repo.lock(), repo.transaction('histedit') as tr:
       
  1555             marks = repo._bookmarks
       
  1556             for name in oldbmarks:
       
  1557                 marks[name] = newtopmost
       
  1558             marks.recordchange(tr)
       
  1559 
  1544 def movebookmarks(ui, repo, mapping, oldtopmost, newtopmost):
  1560 def movebookmarks(ui, repo, mapping, oldtopmost, newtopmost):
  1545     """Move bookmark from old to newly created node"""
  1561     """Move bookmark from old to newly created node"""
  1546     if not mapping:
  1562     if not mapping:
  1547         # if nothing got rewritten there is not purpose for this function
  1563         # if nothing got rewritten there is not purpose for this function
  1548         return
  1564         return
       
  1565     movetopmostbookmarks(repo, oldtopmost, newtopmost)
  1549     moves = []
  1566     moves = []
  1550     for bk, old in sorted(repo._bookmarks.iteritems()):
  1567     for bk, old in sorted(repo._bookmarks.iteritems()):
  1551         if old == oldtopmost:
       
  1552             # special case ensure bookmark stay on tip.
       
  1553             #
       
  1554             # This is arguably a feature and we may only want that for the
       
  1555             # active bookmark. But the behavior is kept compatible with the old
       
  1556             # version for now.
       
  1557             moves.append((bk, newtopmost))
       
  1558             continue
       
  1559         base = old
  1568         base = old
  1560         new = mapping.get(base, None)
  1569         new = mapping.get(base, None)
  1561         if new is None:
  1570         if new is None:
  1562             continue
  1571             continue
  1563         while not new:
  1572         while not new: