# HG changeset patch # User Pierre-Yves David # Date 1488895857 -3600 # Node ID ebbce3be91425f1b918f1a37031f7bbb07c55e23 # Parent 92c2a54f98eeca8b702986c84deaa4600415d28b pull: also issue warning for old mercurial version diff -r 92c2a54f98ee -r ebbce3be9142 hgext3rd/evolve/obsexchange.py --- a/hgext3rd/evolve/obsexchange.py Tue Mar 07 15:04:58 2017 +0100 +++ b/hgext3rd/evolve/obsexchange.py Tue Mar 07 15:10:57 2017 +0100 @@ -61,45 +61,6 @@ kwargs['evo_obscommon'] = common return ret -@eh.wrapfunction(exchange, '_pullobsolete') -def _pullobsolete(orig, pullop): - if not obsolete.isenabled(pullop.repo, obsolete.exchangeopt): - return None - if 'obsmarkers' in pullop.stepsdone: - return None - wirepull = pullop.remote.capable('_evoext_pullobsmarkers_0') - if not wirepull: - return orig(pullop) - if 'obsolete' not in pullop.remote.listkeys('namespaces'): - return None # remote opted out of obsolescence marker exchange - tr = None - ui = pullop.repo.ui - boundaries = obsdiscovery._buildpullobsmarkersboundaries(pullop) - if not set(boundaries['heads']) - set(boundaries['common']): - obsexcmsg(ui, "nothing to pull\n") - return None - - obsexcmsg(ui, "pull obsolescence markers\n", True) - new = 0 - - if wirepull: - obsdata = pullop.remote.evoext_pullobsmarkers_0(**boundaries) - obsdata = obsdata.read() - if len(obsdata) > 5: - msg = "merging obsolescence markers (%i bytes)\n" % len(obsdata) - obsexcmsg(ui, msg) - tr = pullop.gettransaction() - old = len(pullop.repo.obsstore._all) - pullop.repo.obsstore.mergemarkers(tr, obsdata) - new = len(pullop.repo.obsstore._all) - old - obsexcmsg(ui, "%i obsolescence markers added\n" % new, True) - else: - obsexcmsg(ui, "no unknown remote markers\n") - obsexcmsg(ui, "DONE\n") - if new: - pullop.repo.invalidatevolatilesets() - return tr - ############################################### ### Support for old legacy exchange methods ### ############################################### @@ -233,6 +194,52 @@ data = obsfile.read() serveronly._pushobsmarkers(peer._repo, data) +# compat-code: _pullobsolete +# +# the _pullobsolete function is a core function used to exchange +# obsmarker with repository that does not support bundle2 + +@eh.wrapfunction(exchange, '_pullobsolete') +def _pullobsolete(orig, pullop): + if not obsolete.isenabled(pullop.repo, obsolete.exchangeopt): + return None + if 'obsmarkers' in pullop.stepsdone: + return None + wirepull = pullop.remote.capable('_evoext_pullobsmarkers_0') + if not wirepull: + return orig(pullop) + tr = None + ui = pullop.repo.ui + boundaries = obsdiscovery._buildpullobsmarkersboundaries(pullop) + if not set(boundaries['heads']) - set(boundaries['common']): + obsexcmsg(ui, "nothing to pull\n") + return None + + obsexcmsg(ui, "pull obsolescence markers\n", True) + new = 0 + + msg = ('the remote repository use years old versions of Mercurial and evolve\n' + 'pulling obsmarker using legacy method\n') + ui.warn(msg) + ui.warn('(please upgrade your server)\n') + + obsdata = pullop.remote.evoext_pullobsmarkers_0(**boundaries) + obsdata = obsdata.read() + if len(obsdata) > 5: + msg = "merging obsolescence markers (%i bytes)\n" % len(obsdata) + obsexcmsg(ui, msg) + tr = pullop.gettransaction() + old = len(pullop.repo.obsstore._all) + pullop.repo.obsstore.mergemarkers(tr, obsdata) + new = len(pullop.repo.obsstore._all) - old + obsexcmsg(ui, "%i obsolescence markers added\n" % new, True) + else: + obsexcmsg(ui, "no unknown remote markers\n") + obsexcmsg(ui, "DONE\n") + if new: + pullop.repo.invalidatevolatilesets() + return tr + @eh.addattr(wireproto.wirepeer, 'evoext_pullobsmarkers_0') def client_pullobsmarkers(self, heads=None, common=None): self.requirecap('_evoext_pullobsmarkers_0', _('look up remote obsmarkers')) diff -r 92c2a54f98ee -r ebbce3be9142 tests/test-simple4server.t --- a/tests/test-simple4server.t Tue Mar 07 15:04:58 2017 +0100 +++ b/tests/test-simple4server.t Tue Mar 07 15:10:57 2017 +0100 @@ -73,6 +73,9 @@ adding file changes added 2 changesets with 2 changes to 2 files pull obsolescence markers + the remote repository use years old versions of Mercurial and evolve + pulling obsmarker using legacy method + (please upgrade your server) (run 'hg update' to get a working copy) $ cat ../errors.log $ hg push -R ../other @@ -132,6 +135,9 @@ adding file changes added 1 changesets with 1 changes to [12] files \(\+1 heads\) (re) pull obsolescence markers + the remote repository use years old versions of Mercurial and evolve + pulling obsmarker using legacy method + (please upgrade your server) 2 obsolescence markers added (run 'hg heads' to see heads) $ cat ../errors.log