Mercurial > hg-stable
changeset 33510:07b556d1b74e
bookmark: split out target computation from 'deletedivergent'
We want to use applychanges in order to unify bookmark movement. We need a way
to compute divergence deletion without actually removing them.
We split the function in two in this patch while we migrate the existing users
of this code on next patches.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 10 Jul 2017 19:08:17 +0200 |
parents | a3acacbd0ff3 |
children | 9689239d7c2b |
files | mercurial/bookmarks.py |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Mon Jul 10 17:48:33 2017 +0200 +++ b/mercurial/bookmarks.py Mon Jul 10 19:08:17 2017 +0200 @@ -294,7 +294,17 @@ '''Delete divergent versions of bm on nodes in deletefrom. Return True if at least one bookmark was deleted, False otherwise.''' - deleted = False + bms = divergent2delete(repo, deletefrom, bm) + marks = repo._bookmarks + for b in bms: + del marks[b] + return bool(bms) + +def divergent2delete(repo, deletefrom, bm): + """find divergent versions of bm on nodes in deletefrom. + + the list of bookmark to delete.""" + todelete = [] marks = repo._bookmarks divergent = [b for b in marks if b.split('@', 1)[0] == bm.split('@', 1)[0]] for mark in divergent: @@ -303,9 +313,8 @@ continue if mark and marks[mark] in deletefrom: if mark != bm: - del marks[mark] - deleted = True - return deleted + todelete.append(mark) + return todelete def headsforactive(repo): """Given a repo with an active bookmark, return divergent bookmark nodes.