Patchwork D6939: sidedata: apply basic but tight security around exchange

login
register
mail settings
Submitter phabricator
Date Oct. 2, 2019, 4:09 a.m.
Message ID <49bb64c93c17739966c026fa400513ba@localhost.localdomain>
Download mbox | patch
Permalink /patch/41925/
State Not Applicable
Headers show

Comments

phabricator - Oct. 2, 2019, 4:09 a.m.
marmoute updated this revision to Diff 16771.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6939?vs=16742&id=16771

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6939/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6939

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/exchange.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -919,6 +919,8 @@ 
         cgpart.addparam('version', version)
     if 'treemanifest' in pushop.repo.requirements:
         cgpart.addparam('treemanifest', '1')
+    if 'exp-sidedata-flag' in pushop.repo.requirements:
+        cgpart.addparam('exp-sidedata', '1')
     def handlereply(op):
         """extract addchangegroup returns from server reply"""
         cgreplies = op.records.getreplies(cgpart.id)
@@ -2211,6 +2213,9 @@ 
     if 'treemanifest' in repo.requirements:
         part.addparam('treemanifest', '1')
 
+    if 'exp-sidedata-flag' in repo.requirements:
+        part.addparam('exp-sidedata', '1')
+
     if (kwargs.get(r'narrow', False) and kwargs.get(r'narrow_acl', False)
         and (include or exclude)):
         # this is mandatory because otherwise ACL clients won't work
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1606,6 +1606,8 @@ 
         if opts.get('phases') and repo.revs('%ln and secret()',
                                             outgoing.missingheads):
             part.addparam('targetphase', '%d' % phases.secret, mandatory=False)
+        if 'exp-sidedata-flag' in repo.requirements:
+            part.addparam('exp-sidedata', '1')
 
     if opts.get('streamv2', False):
         addpartbundlestream2(bundler, repo, stream=True)
@@ -1802,8 +1804,8 @@ 
         result = -1 + changedheads
     return result
 
-@parthandler('changegroup', ('version', 'nbchanges', 'treemanifest',
-                             'targetphase'))
+@parthandler('changegroup', ('version', 'nbchanges', 'exp-sidedata',
+                             'treemanifest', 'targetphase'))
 def handlechangegroup(op, inpart):
     """apply a changegroup part on the repo
 
@@ -1831,6 +1833,14 @@ 
         op.repo.svfs.options = localrepo.resolvestorevfsoptions(
             op.repo.ui, op.repo.requirements, op.repo.features)
         op.repo._writerequirements()
+
+    bundlesidedata = bool('exp-sidedata' in inpart.params)
+    reposidedata = bool('exp-sidedata-flag' in op.repo.requirements)
+    if reposidedata and not bundlesidedata:
+        msg = "repository is using sidedata but the bundle source do not"
+        hint = 'this is currently unsupported'
+        raise error.Abort(msg, hint=hint)
+
     extrakwargs = {}
     targetphase = inpart.params.get('targetphase')
     if targetphase is not None:
@@ -2329,5 +2339,7 @@ 
         part.addparam('version', cgversion)
         if 'treemanifest' in repo.requirements:
             part.addparam('treemanifest', '1')
+        if 'exp-sidedata-flag' in repo.requirements:
+            part.addparam('sidedata', '1')
 
     return bundler