diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5074,11 +5074,10 @@ def push(ui, repo, dest=None, **opts): result = not pushop.cgresult - if opts.get('bookmark'): - bresult = bookmarks.pushtoremote(ui, repo, other, opts['bookmark']) - if bresult == 2: + if pushop.bkresult is not None: + if pushop.bkresult == 2: result = 2 - elif not result and bresult: + elif not result and pushop.bkresult: result = 2 return result diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -216,6 +216,10 @@ def push(repo, remote, force=False, revs if locallock is not None: locallock.release() + if pushop.bookmarks: + pushop.bkresult = bookmod.pushtoremote(repo.ui, repo, remote, + pushop.bookmarks) + return pushop # list of steps to perform discovery before push