[PATCH sprint]: bookmarks: add 'hg push -B .' as a shorthand for pushing the active bookmark issue(4917)
Uri Baghin
coneko at fb.com
Sun Oct 25 17:01:43 UTC 2015
# HG changeset patch
# User Uri Baghin <coneko at fb.com>
# Date 1445788353 0
# Sun Oct 25 15:52:33 2015 +0000
# Node ID 6782d5b9ef0f85904067535d441a1c3381ff3a1f
# Parent 58a309e9cf80d74d96e8c56cb95be20a4b130092
bookmarks: add 'hg push -B .' as a shorthand for pushing the active bookmark issue(4917)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5370,7 +5370,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.
@@ -5380,6 +5381,20 @@
if opts.get('bookmark'):
ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
+ activebookmark = repo._activebookmark
+ if '.' in opts['bookmark'] and activebookmark is None:
+ raise error.Abort(_('no bookmark is active'),
+ hint=_('do not specify \'.\' in bookmarks'))
+
+ def expandactivebookmark(b):
+ if b == '.':
+ return activebookmark
+ else:
+ return b
+
+ opts.update([(
+ 'bookmark',
+ [expandactivebookmark(x) for x in opts['bookmark']])])
for b in opts['bookmark']:
# translate -B options to -r so changesets get pushed
if b in repo._bookmarks:
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 @@
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
More information about the Mercurial-devel
mailing list