##// END OF EJS Templates
bookmarks: allow push -B to create a new remote head (issue2372)...
Stephen Lee -
r20184:a14d93b2 default
parent child Browse files
Show More
@@ -4677,6 +4677,7 b' def push(ui, repo, dest=None, **opts):'
4677 """
4677 """
4678
4678
4679 if opts.get('bookmark'):
4679 if opts.get('bookmark'):
4680 ui.setconfig('bookmarks', 'pushing', opts['bookmark'])
4680 for b in opts['bookmark']:
4681 for b in opts['bookmark']:
4681 # translate -B options to -r so changesets get pushed
4682 # translate -B options to -r so changesets get pushed
4682 if b in repo._bookmarks:
4683 if b in repo._bookmarks:
@@ -219,7 +219,8 b' def _oldheadssummary(repo, remoteheads, '
219 unsynced = inc and set([None]) or set()
219 unsynced = inc and set([None]) or set()
220 return {None: (oldheads, newheads, unsynced)}
220 return {None: (oldheads, newheads, unsynced)}
221
221
222 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False):
222 def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False,
223 newbookmarks=[]):
223 """Check that a push won't add any outgoing head
224 """Check that a push won't add any outgoing head
224
225
225 raise Abort error and display ui message as needed.
226 raise Abort error and display ui message as needed.
@@ -259,6 +260,9 b' def checkheads(repo, remote, outgoing, r'
259 lctx, rctx = repo[bm], repo[rnode]
260 lctx, rctx = repo[bm], repo[rnode]
260 if bookmarks.validdest(repo, rctx, lctx):
261 if bookmarks.validdest(repo, rctx, lctx):
261 bookmarkedheads.add(lctx.node())
262 bookmarkedheads.add(lctx.node())
263 else:
264 if bm in newbookmarks:
265 bookmarkedheads.add(repo[bm].node())
262
266
263 # 3. Check for new heads.
267 # 3. Check for new heads.
264 # If there are more heads after the push than before, a suitable
268 # If there are more heads after the push than before, a suitable
@@ -1867,9 +1867,10 b' class localrepository(object):'
1867 raise util.Abort(_(mst)
1867 raise util.Abort(_(mst)
1868 % (ctx.troubles()[0],
1868 % (ctx.troubles()[0],
1869 ctx))
1869 ctx))
1870 newbm = self.ui.configlist('bookmarks', 'pushing')
1870 discovery.checkheads(unfi, remote, outgoing,
1871 discovery.checkheads(unfi, remote, outgoing,
1871 remoteheads, newbranch,
1872 remoteheads, newbranch,
1872 bool(inc))
1873 bool(inc), newbm)
1873
1874
1874 # TODO: get bundlecaps from remote
1875 # TODO: get bundlecaps from remote
1875 bundlecaps = None
1876 bundlecaps = None
@@ -424,4 +424,22 b' of this test.'
424 remote: added 1 changesets with 1 changes to 1 files
424 remote: added 1 changesets with 1 changes to 1 files
425 exporting bookmark add-foo
425 exporting bookmark add-foo
426
426
427 pushing a new bookmark on a new head does not require -f if -B is specified
428
429 $ hg up -q X
430 $ hg book W
431 $ echo c5 > f2
432 $ hg ci -Am5
433 created new head
434 $ hg push -B W
435 pushing to http://localhost:$HGPORT/
436 searching for changes
437 remote: adding changesets
438 remote: adding manifests
439 remote: adding file changes
440 remote: added 1 changesets with 1 changes to 1 files (+1 heads)
441 exporting bookmark W
442 $ hg -R ../b id -r W
443 cc978a373a53 tip W
444
427 $ cd ..
445 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now