discovery: properly exclude locally known but filtered heads
The conditional was a bit too narrow and produced buggy result when a node was
present in both common and heads (because it pleased the discovery) and it was
locally known but filtered.
This resulted in buggy getbundle request and server side crash.
--- a/mercurial/exchange.py Fri Jan 30 21:40:30 2015 +0000
+++ b/mercurial/exchange.py Fri Jan 30 21:11:02 2015 +0000
@@ -946,8 +946,9 @@
scommon = set(common)
filteredrheads = []
for n in rheads:
- if n in nm and n not in scommon:
- common.append(n)
+ if n in nm:
+ if n not in scommon:
+ common.append(n)
else:
filteredrheads.append(n)
if not filteredrheads:
--- a/tests/test-treediscovery.t Fri Jan 30 21:40:30 2015 +0000
+++ b/tests/test-treediscovery.t Fri Jan 30 21:11:02 2015 +0000
@@ -520,7 +520,7 @@
"GET /?cmd=heads HTTP/1.1" 200 -
"GET /?cmd=branches HTTP/1.1" 200 - x-hgarg-1:nodes=d8f638ac69e9ae8dea4f09f11d696546a912d961
"GET /?cmd=between HTTP/1.1" 200 - x-hgarg-1:pairs=d8f638ac69e9ae8dea4f09f11d696546a912d961-d57206cc072a18317c1e381fb60aa31bd3401785
- "GET /?cmd=changegroupsubset HTTP/1.1" 200 - x-hgarg-1:bases=d8f638ac69e9ae8dea4f09f11d696546a912d961&heads=d8f638ac69e9ae8dea4f09f11d696546a912d961+2c8d5d5ec612be65cdfdeac78b7662ab1696324a
+ "GET /?cmd=changegroupsubset HTTP/1.1" 200 - x-hgarg-1:bases=d8f638ac69e9ae8dea4f09f11d696546a912d961&heads=d8f638ac69e9ae8dea4f09f11d696546a912d961
"GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
"GET /?cmd=capabilities HTTP/1.1" 200 -
"GET /?cmd=heads HTTP/1.1" 200 -