Mercurial > hg
changeset 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 | f9dfb56ed6e8 |
children | 934a79697c36 |
files | mercurial/exchange.py tests/test-clonebundles.t |
diffstat | 2 files changed, 22 insertions(+), 1 deletions(-) [+] |
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]
--- a/tests/test-clonebundles.t Fri Dec 13 16:49:05 2019 +0100 +++ b/tests/test-clonebundles.t Wed Jan 22 12:11:35 2020 -0500 @@ -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