push: use --create instead of --force to create a new remote bookmark

This commit is contained in:
Ryan McElroy 2015-11-05 16:44:14 -08:00
parent 8c08a32b9a
commit 50019c91c8
3 changed files with 16 additions and 12 deletions

View File

@ -59,10 +59,12 @@ def expush(orig, repo, remote, *args, **kwargs):
return res
def expushop(orig, pushop, repo, remote, force=False, revs=None,
newbranch=False, bookmarks=(), to=None, delete=None, **kwargs):
newbranch=False, bookmarks=(), to=None, delete=None,
create=False, **kwargs):
orig(pushop, repo, remote, force, revs, newbranch, bookmarks)
pushop.to = to
pushop.delete = delete
pushop.create = create
def expull(orig, repo, remote, *args, **kwargs):
res = orig(repo, remote, *args, **kwargs)
@ -522,6 +524,7 @@ def extsetup(ui):
(branchcmd, ('', 'remote', None, 'show only remote branches')),
(pushcmd, ('t', 'to', '', 'push revs to this bookmark', 'BOOKMARK')),
(pushcmd, ('d', 'delete', '', 'delete remote bookmark', 'BOOKMARK')),
(pushcmd, ('', 'create', None, 'create a new remote bookmark')),
]
def afterload(loaded):
@ -602,13 +605,13 @@ def expushdiscoverybookmarks(pushop):
bookmark = pushop.bookmarks[0]
rev = pushop.revs[0]
# allow new bookmark only if force is True
# allow new bookmark only if --create is specified
old = ''
if bookmark in remotemarks:
old = remotemarks[bookmark]
elif not force:
msg = _('not creating new bookmark')
hint = _('use --force to create a new bookmark')
elif not pushop.create:
msg = _('not creating new remote bookmark')
hint = _('use --create to create a new bookmark')
raise util.Abort(msg, hint=hint)
# allow non-ff only if force is True
@ -679,6 +682,7 @@ def expushcmd(orig, ui, repo, dest=None, **opts):
opargs = {
'delete': opts.get('delete'),
'to': opts.get('to'),
'create': opts.get('create'),
}
if opargs['delete']:

View File

@ -29,7 +29,7 @@ Test that anonymous heads are disallowed by default
Create a remote bookmark
$ hg push --to @ -f
$ hg push --to @ --create
pushing rev cb9a9f314b8b to destination ssh://user@dummy/repo1 bookmark @
searching for changes
remote: adding changesets
@ -172,8 +172,8 @@ Test traditional push with subrepo
$ hg push --to @
pushing rev 296c645d2a63 to destination ssh://user@dummy/repo1 bookmark @
searching for changes
abort: not creating new bookmark
(use --force to create a new bookmark)
abort: not creating new remote bookmark
(use --create to create a new bookmark)
[255]
$ hg push -B @
pushing to ssh://user@dummy/repo1

View File

@ -83,15 +83,15 @@ Test that --to limits other options
abort: do not specify --to/-t and --branch/-b at the same time
[255]
Test that --force is required to create new bookmarks
Test that --create is required to create new bookmarks
$ hg push --to @
pushing rev 1846eede8b68 to destination $TESTTMP/repo1 bookmark @
searching for changes
abort: not creating new bookmark
(use --force to create a new bookmark)
abort: not creating new remote bookmark
(use --create to create a new bookmark)
[255]
$ hg push --to @ -f
$ hg push --to @ --create
pushing rev 1846eede8b68 to destination $TESTTMP/repo1 bookmark @
searching for changes
adding changesets