Patchwork D7969: exchange: check the `ui.clonebundleprefers` form while processing (issue6257)

login
register
mail settings
Submitter phabricator
Date Feb. 7, 2020, 9:38 p.m.
Message ID <d263edf4b13c050a3a1984580335d796@localhost.localdomain>
Download mbox | patch
Permalink /patch/45038/
State Not Applicable
Headers show

Comments

phabricator - Feb. 7, 2020, 9:38 p.m.
Closed by commit rHG5fb0592f90e7: exchange: check the `ui.clonebundleprefers` form while processing (issue6257) (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7969?vs=19984&id=20001

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

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

AFFECTED FILES
  mercurial/exchange.py
  tests/test-clonebundles.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
--- a/tests/test-clonebundles.t
+++ b/tests/test-clonebundles.t
@@ -455,6 +455,19 @@ 
   no changes found
   2 local changesets published
 
+Test a bad attribute list
+
+  $ hg --config ui.clonebundleprefers=bad clone -U http://localhost:$HGPORT bad-input
+  abort: invalid ui.clonebundleprefers item: bad
+  (each comma separated item should be key=value pairs)
+  [255]
+  $ hg --config ui.clonebundleprefers=key=val,bad,key2=val2 clone \
+  >    -U http://localhost:$HGPORT bad-input
+  abort: invalid ui.clonebundleprefers item: bad
+  (each comma separated item should be key=value pairs)
+  [255]
+
+
 Test interaction between clone bundles and --stream
 
 A manifest with just a gzip bundle
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -3068,7 +3068,15 @@ 
     if not prefers:
         return list(entries)
 
-    prefers = [p.split(b'=', 1) for p in prefers]
+    def _split(p):
+        if b'=' not in p:
+            hint = _(b"each comma separated item should be key=value pairs")
+            raise error.Abort(
+                _(b"invalid ui.clonebundleprefers item: %s") % p, hint=hint
+            )
+        return p.split(b'=', 1)
+
+    prefers = [_split(p) for p in prefers]
 
     items = sorted(clonebundleentry(v, prefers) for v in entries)
     return [i.value for i in items]