streamclone: abort when client needs to handle obsmarkers, but doesn't
authorAnton Shestakov <av6@dwimlabs.net>
Fri, 05 Oct 2018 23:40:12 +0800
changeset 53133 4ab6e7b4fe8ac60873b4eeb3d26a5efd0e38b204
parent 53132 0ac794e0e285cd02bcb8576d0ae30f092abf91e0
child 53134 db0dba2d157da7be9ef9364d9562f36da956af70
push id1065
push usergszorc@mozilla.com
push dateWed, 31 Oct 2018 02:06:22 +0000
streamclone: abort when client needs to handle obsmarkers, but doesn't When client doesn't have any of obsolescence markers exchange capabilities, then it's safe to say it can't handle obsmarkers. However, if it understands even one format version, then stream clones are fine -- client can use "obsmarkers" bundle2 part.
mercurial/bundle2.py
tests/test-clone-uncompressed.t
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1695,17 +1695,20 @@ def addpartbundlestream2(bundler, repo, 
                                       'stream-narrow-clones')
 
     if (includepats or excludepats) and not narrowstream:
         raise error.Abort(_('server does not support narrow stream clones'))
 
     includeobsmarkers = False
     if repo.obsstore:
         remoteversions = obsmarkersversion(bundler.capabilities)
-        if repo.obsstore._version in remoteversions:
+        if not remoteversions:
+            raise error.Abort(_('server has obsolescence markers, but client '
+                                'cannot receive them via stream clone'))
+        elif repo.obsstore._version in remoteversions:
             includeobsmarkers = True
 
     filecount, bytecount, it = streamclone.generatev2(repo, includepats,
                                                       excludepats,
                                                       includeobsmarkers)
     requirements = _formatrequirementsspec(repo.requirements)
     part = bundler.newpart('stream2', data=it)
     part.addparam('bytecount', '%d' % bytecount, mandatory=True)
--- a/tests/test-clone-uncompressed.t
+++ b/tests/test-clone-uncompressed.t
@@ -551,11 +551,17 @@ Clone non-publishing with obsolescence
   1035 files to transfer, 97.1 KB of data
   transferred 97.1 KB in * seconds (* */sec) (glob)
   $ hg -R with-obsolescence log -T '{rev}: {phase}\n'
   1: draft
   0: draft
   $ hg debugobsolete -R with-obsolescence
   50382b884f66690b7045cac93a540cba4d4c906f 0 {c17445101a72edac06facd130d14808dfbd5c7c2} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
 
+  $ hg clone -U --stream --config experimental.evolution=0 http://localhost:$HGPORT with-obsolescence-no-evolution
+  streaming all changes
+  remote: abort: server has obsolescence markers, but client cannot receive them via stream clone
+  abort: pull failed on remote
+  [255]
+
   $ killdaemons.py
 
 #endif