[PATCH 2 of 3 stable v2] discovery: limit 'all local heads known remotely' to 'all' (issue4438)

Mads Kiilerich mads at kiilerich.com
Wed Nov 5 11:38:13 CST 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1415208853 -3600
#      Wed Nov 05 18:34:13 2014 +0100
# Branch stable
# Node ID a78d927d6b904d3afc1d1358e4b851985054b336
# Parent  e0d9986516e06dc2b9cd8288c461d434b8a5f8dd
discovery: limit 'all local heads known remotely' to 'all' (issue4438)

3ef893520a85 made it possible that the initial head check didn't include all
heads. Other code assumed first check included all heads and would take a quick
exit if they all were common.

Instead, skip the early exit if there is more heads than fits in the initial round.

The randomness in the discovery protocol made this problem hard to
reproduce. The test mocks random.sample to make sure we hit the problem every
time.

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -165,7 +165,7 @@ def findcommonheads(ui, local, remote,
         ui.debug("all remote heads known locally\n")
         return (srvheadhashes, False, srvheadhashes,)
 
-    if sample and util.all(yesno):
+    if sample and len(ownheads) <= initialsamplesize and util.all(yesno):
         ui.note(_("all local heads known remotely\n"))
         ownheadhashes = dag.externalizeall(ownheads)
         return (ownheadhashes, True, srvheadhashes,)
diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t
--- a/tests/test-setdiscovery.t
+++ b/tests/test-setdiscovery.t
@@ -393,6 +393,5 @@ Full initialsamplesize of samples is alr
   $ hg -R t0 outgoing t1 -T'{rev} '
   comparing with t1
   searching for changes
-  no changes found
-  [1]
+  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)
   $ cd ..


More information about the Mercurial-devel mailing list