Mercurial > hg
changeset 20184:a14d93b2fb1b
bookmarks: allow push -B to create a new remote head (issue2372)
Push is currently allowed to create a new head if there is a remote
bookmark that will be updated to point to the new head. If the
bookmark is not known remotely then push aborts, even if a -B argument
is about to push the bookmark. This change allows push to continue in
this case. This does not require a wireproto force.
author | Stephen Lee <sphen.lee@gmail.com> |
---|---|
date | Mon, 11 Nov 2013 21:16:54 +1100 |
parents | de7e6c489412 |
children | 7d4219512823 |
files | mercurial/commands.py mercurial/discovery.py mercurial/localrepo.py tests/test-bookmarks-pushpull.t |
diffstat | 4 files changed, 26 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Nov 21 15:46:49 2013 -0500 +++ b/mercurial/commands.py Mon Nov 11 21:16:54 2013 +1100 @@ -4677,6 +4677,7 @@ """ if opts.get('bookmark'): + ui.setconfig('bookmarks', 'pushing', opts['bookmark']) for b in opts['bookmark']: # translate -B options to -r so changesets get pushed if b in repo._bookmarks:
--- a/mercurial/discovery.py Thu Nov 21 15:46:49 2013 -0500 +++ b/mercurial/discovery.py Mon Nov 11 21:16:54 2013 +1100 @@ -219,7 +219,8 @@ unsynced = inc and set([None]) or set() return {None: (oldheads, newheads, unsynced)} -def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False): +def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False, + newbookmarks=[]): """Check that a push won't add any outgoing head raise Abort error and display ui message as needed. @@ -259,6 +260,9 @@ lctx, rctx = repo[bm], repo[rnode] if bookmarks.validdest(repo, rctx, lctx): bookmarkedheads.add(lctx.node()) + else: + if bm in newbookmarks: + bookmarkedheads.add(repo[bm].node()) # 3. Check for new heads. # If there are more heads after the push than before, a suitable
--- a/mercurial/localrepo.py Thu Nov 21 15:46:49 2013 -0500 +++ b/mercurial/localrepo.py Mon Nov 11 21:16:54 2013 +1100 @@ -1867,9 +1867,10 @@ raise util.Abort(_(mst) % (ctx.troubles()[0], ctx)) + newbm = self.ui.configlist('bookmarks', 'pushing') discovery.checkheads(unfi, remote, outgoing, remoteheads, newbranch, - bool(inc)) + bool(inc), newbm) # TODO: get bundlecaps from remote bundlecaps = None
--- a/tests/test-bookmarks-pushpull.t Thu Nov 21 15:46:49 2013 -0500 +++ b/tests/test-bookmarks-pushpull.t Mon Nov 11 21:16:54 2013 +1100 @@ -424,4 +424,22 @@ remote: added 1 changesets with 1 changes to 1 files exporting bookmark add-foo +pushing a new bookmark on a new head does not require -f if -B is specified + + $ hg up -q X + $ hg book W + $ echo c5 > f2 + $ hg ci -Am5 + created new head + $ hg push -B W + pushing to http://localhost:$HGPORT/ + searching for changes + remote: adding changesets + remote: adding manifests + remote: adding file changes + remote: added 1 changesets with 1 changes to 1 files (+1 heads) + exporting bookmark W + $ hg -R ../b id -r W + cc978a373a53 tip W + $ cd ..