diff --git a/mercurial/commands.py b/mercurial/commands.py
index c33d9217e99df21528432b4324010fdc394ae7ea_bWVyY3VyaWFsL2NvbW1hbmRzLnB5..2ca325ea57fa13909e28cc2caeae3c73e60693f8_bWVyY3VyaWFsL2NvbW1hbmRzLnB5 100644
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -836,6 +836,8 @@
                     bookmarks.deletedivergent(repo, [target], mark)
                     return
 
+                # consider successor changesets as well
+                foreground = obsolete.foreground(repo, [marks[mark]])
                 deletefrom = [b for b in divs
                               if repo[b].rev() in anc or b == target]
                 bookmarks.deletedivergent(repo, deletefrom, mark)
@@ -839,7 +841,7 @@
                 deletefrom = [b for b in divs
                               if repo[b].rev() in anc or b == target]
                 bookmarks.deletedivergent(repo, deletefrom, mark)
-                if bmctx.rev() in anc:
+                if bmctx.rev() in anc or target in foreground:
                     ui.status(_("moving bookmark '%s' forward from %s\n") %
                               (mark, short(bmctx.node())))
                     return
diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
index c33d9217e99df21528432b4324010fdc394ae7ea_dGVzdHMvdGVzdC11cGRhdGUtYnJhbmNoZXMudA==..2ca325ea57fa13909e28cc2caeae3c73e60693f8_dGVzdHMvdGVzdC11cGRhdGUtYnJhbmNoZXMudA== 100644
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -206,6 +206,7 @@
   |/
   o  0:60829823a42a 0
   
+  $ hg book bm -r 3
   $ hg status
   M foo
 
@@ -218,7 +219,9 @@
   $ hg debugobsolete 6efa171f091b00a3c35edc15d48c52a498929953 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
   $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa d047485b3896813b2a624e86201983520f003206
 
-Test that 5 is detected as a valid destination from 3
+Test that 5 is detected as a valid destination from 3 and also accepts moving
+the bookmark (issue4015)
+
   $ hg up --quiet --hidden 3
   $ hg up 5
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -222,6 +225,10 @@
   $ hg up --quiet --hidden 3
   $ hg up 5
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg book bm
+  moving bookmark 'bm' forward from 6efa171f091b
+  $ hg bookmarks
+   * bm                        5:ff252e8273df
 
 Test that 5 is detected as a valid destination from 1
   $ hg up --quiet 0          # we should be able to update to 3 directly