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

login
register
mail settings
Submitter phabricator
Date Oct. 9, 2019, 4:47 p.m.
Message ID <492982e4dee1d6aba3efc367051167d7@localhost.localdomain>
Download mbox | patch
Permalink /patch/42147/
State Not Applicable
Headers show

Comments

phabricator - Oct. 9, 2019, 4:47 p.m.
Closed by commit rHGc17a63eb5d4c: sidedata: apply basic but tight security around exchange (authored by marmoute).
marmoute marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

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

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: indygreg, martinvonz, mercurial-devel

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1049,6 +1049,8 @@ 
         cgpart.addparam(b'version', version)
     if b'treemanifest' in pushop.repo.requirements:
         cgpart.addparam(b'treemanifest', b'1')
+    if b'exp-sidedata-flag' in pushop.repo.requirements:
+        cgpart.addparam(b'exp-sidedata', b'1')
 
     def handlereply(op):
         """extract addchangegroup returns from server reply"""
@@ -2511,6 +2513,9 @@ 
     if b'treemanifest' in repo.requirements:
         part.addparam(b'treemanifest', b'1')
 
+    if b'exp-sidedata-flag' in repo.requirements:
+        part.addparam(b'exp-sidedata', b'1')
+
     if (
         kwargs.get(r'narrow', False)
         and kwargs.get(r'narrow_acl', False)
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1711,6 +1711,8 @@ 
             part.addparam(
                 b'targetphase', b'%d' % phases.secret, mandatory=False
             )
+        if b'exp-sidedata-flag' in repo.requirements:
+            part.addparam(b'exp-sidedata', b'1')
 
     if opts.get(b'streamv2', False):
         addpartbundlestream2(bundler, repo, stream=True)
@@ -1930,7 +1932,14 @@ 
 
 
 @parthandler(
-    b'changegroup', (b'version', b'nbchanges', b'treemanifest', b'targetphase')
+    b'changegroup',
+    (
+        b'version',
+        b'nbchanges',
+        b'exp-sidedata',
+        b'treemanifest',
+        b'targetphase',
+    ),
 )
 def handlechangegroup(op, inpart):
     """apply a changegroup part on the repo
@@ -1965,6 +1974,14 @@ 
             op.repo.ui, op.repo.requirements, op.repo.features
         )
         op.repo._writerequirements()
+
+    bundlesidedata = bool(b'exp-sidedata' in inpart.params)
+    reposidedata = bool(b'exp-sidedata-flag' in op.repo.requirements)
+    if reposidedata and not bundlesidedata:
+        msg = b"repository is using sidedata but the bundle source do not"
+        hint = b'this is currently unsupported'
+        raise error.Abort(msg, hint=hint)
+
     extrakwargs = {}
     targetphase = inpart.params.get(b'targetphase')
     if targetphase is not None:
@@ -2551,5 +2568,7 @@ 
         part.addparam(b'version', cgversion)
         if b'treemanifest' in repo.requirements:
             part.addparam(b'treemanifest', b'1')
+        if b'exp-sidedata-flag' in repo.requirements:
+            part.addparam(b'exp-sidedata', b'1')
 
     return bundler