Mercurial > hg
changeset 22651:b901645a8784
push: gather all bookmark decisions together
The discovery phases for bookmarks now use the list of explicitly pushed bookmarks
to do addition, removal and overwriting.
Tests are impacted because this reduces the amount of listkeys calls issued, removes
some duplicated messages and improves the accuracy of some messages.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 27 Sep 2014 20:51:53 -0700 |
parents | 36952c91e6c3 |
children | 15bc5ea297f5 |
files | mercurial/exchange.py tests/test-bookmarks-pushpull.t tests/test-bundle2.t tests/test-hook.t |
diffstat | 4 files changed, 32 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/exchange.py Fri Sep 26 18:33:11 2014 -0700 +++ b/mercurial/exchange.py Sat Sep 27 20:51:53 2014 -0700 @@ -226,10 +226,6 @@ if locallock is not None: locallock.release() - if pushop.bookmarks: - pushop.bkresult = bookmod.pushtoremote(repo.ui, repo, remote, - pushop.bookmarks) - return pushop # list of steps to perform discovery before push @@ -334,11 +330,40 @@ ancestors = repo.changelog.ancestors(revnums, inclusive=True) remotebookmark = remote.listkeys('bookmarks') + explicit = set(pushop.bookmarks) + comp = bookmod.compare(repo, repo._bookmarks, remotebookmark, srchex=hex) addsrc, adddst, advsrc, advdst, diverge, differ, invalid = comp for b, scid, dcid in advsrc: + if b in explicit: + explicit.remove(b) if not ancestors or repo[scid].rev() in ancestors: pushop.outbookmarks.append((b, dcid, scid)) + # search added bookmark + for b, scid, dcid in addsrc: + if b in explicit: + explicit.remove(b) + pushop.outbookmarks.append((b, '', scid)) + # search for overwritten bookmark + for b, scid, dcid in advdst + diverge + differ: + if b in explicit: + explicit.remove(b) + pushop.outbookmarks.append((b, dcid, scid)) + # search for bookmark to delete + for b, scid, dcid in adddst: + if b in explicit: + explicit.remove(b) + # treat as "deleted locally" + pushop.outbookmarks.append((b, dcid, '')) + + if explicit: + explicit = sorted(explicit) + # we should probably list all of them + ui.warn(_('bookmark %s does not exist on the local ' + 'or remote repository!\n') % explicit[0]) + pushop.bkresult = 2 + + pushop.outbookmarks.sort() def _pushcheckoutgoing(pushop): outgoing = pushop.outgoing
--- a/tests/test-bookmarks-pushpull.t Fri Sep 26 18:33:11 2014 -0700 +++ b/tests/test-bookmarks-pushpull.t Sat Sep 27 20:51:53 2014 -0700 @@ -99,8 +99,8 @@ $ hg push -B badname ../a pushing to ../a searching for changes + bookmark badname does not exist on the local or remote repository! no changes found - bookmark badname does not exist on the local or remote repository! [2] $ hg pull -B anotherbadname ../a pulling from ../a @@ -356,7 +356,7 @@ pushing to http://localhost:$HGPORT/ searching for changes no changes found - exporting bookmark Z + updating bookmark Z [1] $ hg book -d Z $ hg in -B http://localhost:$HGPORT/
--- a/tests/test-bundle2.t Fri Sep 26 18:33:11 2014 -0700 +++ b/tests/test-bundle2.t Sat Sep 27 20:51:53 2014 -0700 @@ -881,7 +881,6 @@ remote: added 1 changesets with 0 changes to 0 files (-1 heads) remote: 1 new obsolescence markers updating bookmark book_eea1 - exporting bookmark book_eea1 $ hg -R other log -G o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G |\ @@ -950,7 +949,6 @@ remote: added 1 changesets with 1 changes to 1 files remote: 1 new obsolescence markers updating bookmark book_5fdd - exporting bookmark book_5fdd $ hg -R other log -G o 6:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_5fdd C | @@ -989,7 +987,6 @@ remote: added 1 changesets with 1 changes to 1 files remote: 1 new obsolescence markers updating bookmark book_32af - exporting bookmark book_32af $ cat other-error.log Check final content.
--- a/tests/test-hook.t Fri Sep 26 18:33:11 2014 -0700 +++ b/tests/test-hook.t Sat Sep 27 20:51:53 2014 -0700 @@ -183,8 +183,8 @@ pushing to ../a searching for changes no changes found + pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1 exporting bookmark foo - pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1 [1] $ cd ../a @@ -215,8 +215,6 @@ listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} no changes found listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'} - listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'} - exporting bookmark baz prepushkey.forbid hook: HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 abort: prepushkey hook exited with status 1 [255]