Patchwork [2,of,2] streamclone: abort when client needs to handle obsmarkers, but doesn't

login
register
mail settings
Submitter Anton Shestakov
Date Oct. 10, 2018, 11:11 a.m.
Message ID <916e5b41f1749c6bc842.1539169882@neuro>
Download mbox | patch
Permalink /patch/35600/
State Superseded
Headers show

Comments

Anton Shestakov - Oct. 10, 2018, 11:11 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1538754012 -28800
#      Fri Oct 05 23:40:12 2018 +0800
# Node ID 916e5b41f1749c6bc842e8db2c0affe04d86bf59
# Parent  f4183e8094c8f06ebb007b5e0b03a618f288c8d6
# EXP-Topic stream-obsmarkers
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.

I'm not sure about the wording of the abort message. I'd like it to be both
technically accurate and understandable to the users, obviously, but it's
tricky since evolution is an experimental concept and evolve extension is not
in core. Suggestions appreciated.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1690,7 +1690,12 @@  def addpartbundlestream2(bundler, repo, 
     includeobsmarkers = False
     if repo.obsstore:
         remoteversions = obsmarkersversion(bundler.capabilities)
-        if repo.obsstore._version in remoteversions:
+        if not remoteversions:
+            msg = _('server has obsolescence markers, '
+                    'but client cannot receive them')
+            hint = _('either enable evolution or clone without --stream')
+            raise error.Abort(msg, hint=hint)
+        elif repo.obsstore._version in remoteversions:
             includeobsmarkers = True
     filecount, bytecount, it = streamclone.generatev2(repo, includeobsmarkers)
     requirements = _formatrequirementsspec(repo.requirements)
diff --git a/tests/test-clone-uncompressed.t b/tests/test-clone-uncompressed.t
--- a/tests/test-clone-uncompressed.t
+++ b/tests/test-clone-uncompressed.t
@@ -556,6 +556,13 @@  Clone non-publishing with obsolescence
   $ 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
+  abort: pull failed on remote
+  (either enable evolution or clone without --stream)
+  [255]
+
   $ killdaemons.py
 
 #endif