# HG changeset patch # User David Soria Parra # Date 1336850890 -7200 # Node ID a270ec977ba69039c748cdcc34ca19d8f7487828 # Parent c2d9ef43ff6ca0a40020d53cd7456c84dd2f1bb9 bookmarks: delete divergent bookmarks on merge diff -r c2d9ef43ff6c -r a270ec977ba6 mercurial/bookmarks.py --- a/mercurial/bookmarks.py Sun May 13 13:18:06 2012 +0200 +++ b/mercurial/bookmarks.py Sat May 12 21:28:10 2012 +0200 @@ -150,13 +150,20 @@ def update(repo, parents, node): marks = repo._bookmarks update = False - mark = repo._bookmarkcurrent - if mark and marks[mark] in parents: - old = repo[marks[mark]] - new = repo[node] - if new in old.descendants(): - marks[mark] = new.node() - update = True + cur = repo._bookmarkcurrent + if not cur: + return False + + toupdate = [b for b in marks if b.split('@', 1)[0] == cur.split('@', 1)[0]] + for mark in toupdate: + if mark and marks[mark] in parents: + old = repo[marks[mark]] + new = repo[node] + if new in old.descendants() and mark == cur: + marks[cur] = new.node() + update = True + if mark != cur: + del marks[mark] if update: repo._writebookmarks(marks) return update diff -r c2d9ef43ff6c -r a270ec977ba6 mercurial/localrepo.py --- a/mercurial/localrepo.py Sun May 13 13:18:06 2012 +0200 +++ b/mercurial/localrepo.py Sat May 12 21:28:10 2012 +0200 @@ -1187,7 +1187,7 @@ raise # update bookmarks, dirstate and mergestate - bookmarks.update(self, p1, ret) + bookmarks.update(self, [p1, p2], ret) for f in changes[0] + changes[1]: self.dirstate.normal(f) for f in changes[2]: diff -r c2d9ef43ff6c -r a270ec977ba6 tests/test-bookmarks-merge.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-bookmarks-merge.t Sat May 12 21:28:10 2012 +0200 @@ -0,0 +1,31 @@ +# init + + $ hg init + $ echo a > a + $ hg add a + $ hg commit -m'a' + $ echo b > b + $ hg add b + $ hg commit -m'b' + $ hg up -C 0 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo c > c + $ hg add c + $ hg commit -m'c' + created new head + +# test merging of diverged bookmarks + $ hg bookmark -r 1 "c@diverge" + $ hg bookmark -r 1 b + $ hg bookmark c + $ hg bookmarks + b 1:d2ae7f538514 + * c 2:d36c0562f908 + c@diverge 1:d2ae7f538514 + $ hg merge "c@diverge" + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + $ hg commit -m'merge' + $ hg bookmarks + b 1:d2ae7f538514 + * c 3:b8f96cf4688b