Skip to content
Snippets Groups Projects
Commit 741d94aa authored by Sean Farley's avatar Sean Farley
Browse files

bookmarks: resolve divergent bookmarks when moving active bookmark forward

This patch resolves divergent bookmarks between the current active bookmark
MARK and the new destination. This situation can arise when pulling new
changesets, abandoning your current changesets actively bookmarked with MARK
via strip, and then doing a bare update. The non-divergent but active bookmark
MARK is then moved to a common ancestor of the new changesets and the abandoned
changesets.

Test coverage is added.
parent 26c51e87
No related branches found
No related tags found
No related merge requests found
......@@ -171,6 +171,7 @@
return deleted
def update(repo, parents, node):
deletefrom = parents
marks = repo._bookmarks
update = False
cur = repo._bookmarkcurrent
......@@ -180,7 +181,11 @@
if marks[cur] in parents:
old = repo[marks[cur]]
new = repo[node]
divs = [repo[b] for b in marks
if b.split('@', 1)[0] == cur.split('@', 1)[0]]
anc = repo.changelog.ancestors([new.rev()])
deletefrom = [b.node() for b in divs if b.rev() in anc or b == new]
if old.descendant(new):
marks[cur] = new.node()
update = True
......@@ -183,8 +188,8 @@
if old.descendant(new):
marks[cur] = new.node()
update = True
if deletedivergent(repo, parents, cur):
if deletedivergent(repo, deletefrom, cur):
update = True
if update:
......
......@@ -133,8 +133,8 @@
X 0:719295282060
Z 0:719295282060
bare update moves the active bookmark forward
bare update moves the active bookmark forward and clear the divergent bookmarks
$ echo a > a
$ hg ci -Am1
adding a
......@@ -137,8 +137,12 @@
$ echo a > a
$ hg ci -Am1
adding a
$ echo b >> a
$ hg ci -Am2
$ hg bookmark X@1 -r 1
$ hg bookmark X@2 -r 2
$ hg update X
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg bookmarks
* X 0:719295282060
......@@ -141,9 +145,11 @@
$ hg update X
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg bookmarks
* X 0:719295282060
X@1 1:cc586d725fbe
X@2 2:49e1c4e84c58
Z 0:719295282060
$ hg update
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
updating bookmark X
$ hg bookmarks
......@@ -145,9 +151,9 @@
Z 0:719295282060
$ hg update
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
updating bookmark X
$ hg bookmarks
* X 1:cc586d725fbe
* X 2:49e1c4e84c58
Z 0:719295282060
test deleting .hg/bookmarks.current when explicitly updating
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment