diff mercurial/exchange.py @ 44282:877805928f85

exchange: check the `ui.clonebundleprefers` form while processing (issue6257) Otherwise the clone command will emit a long stacktrace if there is no `=` character. Differential Revision: https://phab.mercurial-scm.org/D7969
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 22 Jan 2020 12:11:35 -0500
parents a61287a95dc3
children 8407031f195f
line wrap: on
line diff
--- a/mercurial/exchange.py	Fri Dec 13 16:49:05 2019 +0100
+++ b/mercurial/exchange.py	Wed Jan 22 12:11:35 2020 -0500
@@ -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]