Mercurial > public > mercurial-scm > hg-stable
diff mercurial/exchange.py @ 22239:0688010ee38f
push: move bookmark discovery with other discovery steps
The discovery of necessary bookmark updates is now done within the "discovery
phase". This opens the door to the inclusion of bookmarks in a unified bundle2
push.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 15 Aug 2014 18:39:39 -0700 |
parents | c894fdff56d1 |
children | d092f4b68fb6 |
line wrap: on
line diff
--- a/mercurial/exchange.py Fri Aug 15 18:02:54 2014 -0700 +++ b/mercurial/exchange.py Fri Aug 15 18:39:39 2014 -0700 @@ -83,6 +83,8 @@ self.fallbackoutdatedphases = None # outgoing obsmarkers self.outobsmarkers = set() + # outgoing bookmarks + self.outbookmarks = [] @util.propertycache def futureheads(self): @@ -280,6 +282,24 @@ def _pushdiscoveryobsmarkers(pushop): pushop.outobsmarkers = pushop.repo.obsstore +@pushdiscovery('bookmarks') +def _pushdiscoverybookmarks(pushop): + ui = pushop.ui + repo = pushop.repo.unfiltered() + remote = pushop.remote + ui.debug("checking for updated bookmarks\n") + ancestors = () + if pushop.revs: + revnums = map(repo.changelog.rev, pushop.revs) + ancestors = repo.changelog.ancestors(revnums, inclusive=True) + remotebookmark = remote.listkeys('bookmarks') + + comp = bookmarks.compare(repo, repo._bookmarks, remotebookmark, srchex=hex) + (addsrc, adddst, advsrc, advdst, diverge, differ, invalid) = comp + for b, scid, dcid in advsrc: + if not ancestors or repo[scid].rev() in ancestors: + pushop.outbookmarks.append((b, dcid, scid)) + def _pushcheckoutgoing(pushop): outgoing = pushop.outgoing unfi = pushop.repo.unfiltered() @@ -616,20 +636,9 @@ if pushop.ret == 0: return ui = pushop.ui - repo = pushop.repo.unfiltered() remote = pushop.remote - ui.debug("checking for updated bookmarks\n") - ancestors = () - if pushop.revs: - revnums = map(repo.changelog.rev, pushop.revs) - ancestors = repo.changelog.ancestors(revnums, inclusive=True) - remotebookmark = remote.listkeys('bookmarks') - comp = bookmarks.compare(repo, repo._bookmarks, remotebookmark, srchex=hex) - (addsrc, adddst, advsrc, advdst, diverge, differ, invalid) = comp - for b, scid, dcid in advsrc: - if ancestors and repo[scid].rev() not in ancestors: - continue - if remote.pushkey('bookmarks', b, dcid, scid): + for b, old, new in pushop.outbookmarks: + if remote.pushkey('bookmarks', b, old, new): ui.status(_("updating bookmark %s\n") % b) else: ui.warn(_('updating bookmark %s failed!\n') % b)