--- a/mercurial/bookmarks.py Sat Feb 20 15:56:44 2016 -0800
+++ b/mercurial/bookmarks.py Fri Feb 19 22:28:09 2016 +0100
@@ -182,6 +182,11 @@
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
--- a/mercurial/commands.py Sat Feb 20 15:56:44 2016 -0800
+++ b/mercurial/commands.py Fri Feb 19 22:28:09 2016 +0100
@@ -5708,7 +5708,8 @@
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 @@
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:
--- a/mercurial/exchange.py Sat Feb 20 15:56:44 2016 -0800
+++ b/mercurial/exchange.py Fri Feb 19 22:28:09 2016 +0100
@@ -576,7 +576,8 @@
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
--- a/tests/test-bookmarks-pushpull.t Sat Feb 20 15:56:44 2016 -0800
+++ b/tests/test-bookmarks-pushpull.t Fri Feb 19 22:28:09 2016 +0100
@@ -103,6 +103,29 @@
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