Patchwork [3,of,3,stable,v2] discovery: indices between sample and yesno must match (issue4438)

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 5, 2014, 5:38 p.m.
Message ID <39d81557e992665e7692.1415209094@ssl.google-analytics.com>
Download mbox | patch
Permalink /patch/6586/
State Accepted
Commit 73cfaa34865061744250a63ed01e970ad7a4bf3d
Headers show

Comments

Mads Kiilerich - Nov. 5, 2014, 5:38 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1415209084 -3600
#      Wed Nov 05 18:38:04 2014 +0100
# Branch stable
# Node ID 39d81557e992665e7692149d2d88e6f2814003a3
# Parent  a78d927d6b904d3afc1d1358e4b851985054b336
discovery: indices between sample and yesno must match (issue4438)

3ef893520a85 changed 'sample' from a list to a set. The iteration order was
thus undefined and the yesno indices were not stable.

To solve this, repeat the listification and comment from elsewhere in the code.

The randomness in the discovery protocol and set iteration order made this
problem hard to reproduce ... and once reproduced, it reproduced in random
ways. Now, with the problem solved, it always ends up with the right result,
even when using randomness in the discovery process.

Patch

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -134,6 +134,8 @@  def findcommonheads(ui, local, remote,
     roundtrips += 1
     ownheads = dag.heads()
     sample = _limitsample(ownheads, initialsamplesize)
+    # indices between sample and externalized version must match
+    sample = list(sample)
     if remote.local():
         # stopgap until we have a proper localpeer that supports batch()
         srvheadhashes = remote.heads()
diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
--- a/tests/test-setdiscovery.t
+++ b/tests/test-setdiscovery.t
@@ -369,12 +369,12 @@  Issue 4438 - test coverage for 3ef893520
   $ for i in `seq 101`; do hg -R t0 up -qr null; hg -R t0 branch -q c$i; hg -R t0 ci -qmc$i; done
   $ hg -R t1 branch -q o2 && hg -R t1 ci -qmo2
 
-Set iteration order can cause wrong and unstable results:
+Set iteration order could cause wrong and unstable results:
 
   $ hg -R t0 outgoing t1 -T'{rev} '
   comparing with t1
   searching for changes
-  * (glob)
+  101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201  (no-eol)
 
 Full initialsamplesize of samples is already common: