diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -182,6 +182,11 @@ class bmstore(dict): fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) self._clean = True + def expandname(self, bname): + if bname == '.': + return self.active + return bname + def _readactive(repo, marks): """ Get the active bookmark. We can have an active bookmark that updates diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5708,7 +5708,8 @@ def push(ui, repo, dest=None, **opts): If -B/--bookmark is used, the specified bookmarked revision, its ancestors, and the bookmark will be pushed to the remote - repository. + repository. Specifying ``.`` is equivalent to specifying the active + bookmark's name. Please see :hg:`help urls` for important details about ``ssh://`` URLs. If DESTINATION is omitted, a default path will be used. @@ -5720,6 +5721,7 @@ def push(ui, repo, dest=None, **opts): ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push') for b in opts['bookmark']: # translate -B options to -r so changesets get pushed + b = repo._bookmarks.expandname(b) if b in repo._bookmarks: opts.setdefault('rev', []).append(b) else: diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -576,7 +576,8 @@ def _pushdiscoverybookmarks(pushop): ancestors = repo.changelog.ancestors(revnums, inclusive=True) remotebookmark = remote.listkeys('bookmarks') - explicit = set(pushop.bookmarks) + explicit = set([repo._bookmarks.expandname(bookmark) + for bookmark in pushop.bookmarks]) comp = bookmod.compare(repo, repo._bookmarks, remotebookmark, srchex=hex) addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t --- a/tests/test-bookmarks-pushpull.t +++ b/tests/test-bookmarks-pushpull.t @@ -103,6 +103,29 @@ delete a remote bookmark deleting remote bookmark W [1] +export the active bookmark + + $ hg bookmark V + $ hg push -B . ../a + pushing to ../a + searching for changes + no changes found + exporting bookmark V + [1] + +delete the bookmark + + $ hg book -d V + $ hg push -B V ../a + pushing to ../a + searching for changes + no changes found + deleting remote bookmark V + [1] + $ hg up foobar + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark foobar) + push/pull name that doesn't exist $ hg push -B badname ../a