##// END OF EJS Templates
setdiscovery: batch heads and known(ownheads)...
Peter Arrenbrecht -
r14624:f03c82d1 default
parent child Browse files
Show More
@@ -91,15 +91,27 b' def findcommonheads(ui, local, remote,'
91 roundtrips = 0
91 roundtrips = 0
92 cl = local.changelog
92 cl = local.changelog
93 dag = dagutil.revlogdag(cl)
93 dag = dagutil.revlogdag(cl)
94 nodes = dag.nodeset()
95
94
96 # early exit if we know all the specified server heads already
95 # early exit if we know all the specified remote heads already
97 ui.debug("query 1; heads\n")
96 ui.debug("query 1; heads\n")
98 roundtrips += 1
97 roundtrips += 1
98 ownheads = dag.heads()
99 sample = ownheads
100 if remote.local():
101 # stopgap until we have a proper localpeer that supports batch()
99 srvheadhashes = remote.heads()
102 srvheadhashes = remote.heads()
100
103 yesno = remote.known(dag.externalizeall(sample))
101 ## TODO We might want to request an additional random sample of the server's
104 elif remote.capable('batch'):
102 ## nodes batched with the heads query here.
105 batch = remote.batch()
106 srvheadhashesref = batch.heads()
107 yesnoref = batch.known(dag.externalizeall(sample))
108 batch.submit()
109 srvheadhashes = srvheadhashesref.value
110 yesno = yesnoref.value
111 else:
112 # compatibitity with pre-batch, but post-known remotes during 1.9 devel
113 srvheadhashes = remote.heads()
114 sample = []
103
115
104 if cl.tip() == nullid:
116 if cl.tip() == nullid:
105 if srvheadhashes != [nullid]:
117 if srvheadhashes != [nullid]:
@@ -115,32 +127,24 b' def findcommonheads(ui, local, remote,'
115 ui.note("all remote heads known locally\n")
127 ui.note("all remote heads known locally\n")
116 return (srvheadhashes, False, srvheadhashes,)
128 return (srvheadhashes, False, srvheadhashes,)
117
129
130 if sample and util.all(yesno):
131 ui.note("all local heads known remotely\n")
132 ownheadhashes = dag.externalizeall(ownheads)
133 return (ownheadhashes, True, srvheadhashes,)
134
118 # full blown discovery
135 # full blown discovery
119 undecided = nodes # own nodes where I don't know if the server knows them
136 undecided = dag.nodeset() # own nodes where I don't know if remote knows them
120 common = set() # own nodes I know we both know
137 common = set() # own nodes I know we both know
121 missing = set() # own nodes I know the server lacks
138 missing = set() # own nodes I know remote lacks
122
139
123 # treat remote heads as a first implicit sample response
140 # treat remote heads (and maybe own heads) as a first implicit sample response
124 common.update(dag.ancestorset(srvheads))
141 common.update(dag.ancestorset(srvheads))
125 undecided.difference_update(common)
142 undecided.difference_update(common)
126 # use cheapish initial sample
127 if common:
128 ui.debug("taking initial sample\n")
129 sample = _takefullsample(dag, undecided, size=fullsamplesize)
130 else:
131 ui.debug("taking quick initial sample\n")
132 sample = _takequicksample(dag, nodes, size=initialsamplesize,
133 initial=True)
134
143
135 roundtrips += 1
144 full = False
136 ui.progress(_('searching'), roundtrips, unit=_('queries'))
145 while undecided:
137 ui.debug("query %i; still undecided: %i, sample size is: %i\n"
138 % (roundtrips, len(undecided), len(sample)))
139 # indices between sample and externalized version must match
140 sample = list(sample)
141 yesno = remote.known(dag.externalizeall(sample))
142
146
143 while undecided:
147 if sample:
144 commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
148 commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
145 common.update(dag.ancestorset(commoninsample, common))
149 common.update(dag.ancestorset(commoninsample, common))
146
150
@@ -153,8 +157,18 b' def findcommonheads(ui, local, remote,'
153 if not undecided:
157 if not undecided:
154 break
158 break
155
159
160 if full:
156 ui.note("sampling from both directions\n")
161 ui.note("sampling from both directions\n")
157 sample = _takefullsample(dag, undecided, size=fullsamplesize)
162 sample = _takefullsample(dag, undecided, size=fullsamplesize)
163 elif common:
164 # use cheapish initial sample
165 ui.debug("taking initial sample\n")
166 sample = _takefullsample(dag, undecided, size=fullsamplesize)
167 else:
168 # use even cheaper initial sample
169 ui.debug("taking quick initial sample\n")
170 sample = _takequicksample(dag, undecided, size=initialsamplesize,
171 initial=True)
158
172
159 roundtrips += 1
173 roundtrips += 1
160 ui.progress(_('searching'), roundtrips, unit=_('queries'))
174 ui.progress(_('searching'), roundtrips, unit=_('queries'))
@@ -163,6 +177,7 b' def findcommonheads(ui, local, remote,'
163 # indices between sample and externalized version must match
177 # indices between sample and externalized version must match
164 sample = list(sample)
178 sample = list(sample)
165 yesno = remote.known(dag.externalizeall(sample))
179 yesno = remote.known(dag.externalizeall(sample))
180 full = True
166
181
167 result = dag.headsetofconnecteds(common)
182 result = dag.headsetofconnecteds(common)
168 ui.progress(_('searching'), None)
183 ui.progress(_('searching'), None)
@@ -102,19 +102,19 b' do not use the proxy if it is in the no '
102 * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - (glob)
102 * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - (glob)
103 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
103 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
104 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
104 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
105 * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
105 * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob)
106 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
106 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
107 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
107 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
108 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
108 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
109 * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
109 * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob)
110 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
110 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
111 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
111 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
112 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
112 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
113 * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
113 * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob)
114 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
114 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
115 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
115 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
116 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
116 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
117 * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
117 * - - [*] "GET http://localhost:$HGPORT/?cmd=batch HTTP/1.1" - - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D (glob)
118 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
118 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
119 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
119 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
120
120
@@ -35,7 +35,7 b''
35 searching for changes
35 searching for changes
36 taking quick initial sample
36 taking quick initial sample
37 searching: 2 queries
37 searching: 2 queries
38 query 2; still undecided: 2, sample size is: 2
38 query 2; still undecided: 1, sample size is: 1
39 2 total queries
39 2 total queries
40 new remote heads on branch 'default'
40 new remote heads on branch 'default'
41 new remote head 1e108cc5548c
41 new remote head 1e108cc5548c
@@ -28,7 +28,7 b' check that {1} syntax works'
28 sending capabilities command
28 sending capabilities command
29 comparing with parts://localhost/
29 comparing with parts://localhost/
30 query 1; heads
30 query 1; heads
31 sending heads command
31 sending batch command
32 searching for changes
32 searching for changes
33 all remote heads known locally
33 all remote heads known locally
34 no changes found
34 no changes found
@@ -44,10 +44,7 b' Small superset:'
44 comparing with b
44 comparing with b
45 query 1; heads
45 query 1; heads
46 searching for changes
46 searching for changes
47 taking initial sample
47 all local heads known remotely
48 searching: 2 queries
49 query 2; still undecided: 4, sample size is: 4
50 2 total queries
51 common heads: b5714e113bc0 01241442b3c2
48 common heads: b5714e113bc0 01241442b3c2
52 local is subset
49 local is subset
53
50
@@ -83,9 +80,9 b' Many new:'
83 comparing with b
80 comparing with b
84 query 1; heads
81 query 1; heads
85 searching for changes
82 searching for changes
86 taking quick initial sample
83 taking initial sample
87 searching: 2 queries
84 searching: 2 queries
88 query 2; still undecided: 35, sample size is: 35
85 query 2; still undecided: 29, sample size is: 29
89 2 total queries
86 2 total queries
90 common heads: bebd167eb94d
87 common heads: bebd167eb94d
91
88
@@ -101,7 +98,7 b' Many new:'
101 searching for changes
98 searching for changes
102 taking initial sample
99 taking initial sample
103 searching: 2 queries
100 searching: 2 queries
104 query 2; still undecided: 3, sample size is: 3
101 query 2; still undecided: 2, sample size is: 2
105 2 total queries
102 2 total queries
106 common heads: bebd167eb94d
103 common heads: bebd167eb94d
107
104
@@ -122,9 +119,9 b' Both sides many new with stub:'
122 comparing with b
119 comparing with b
123 query 1; heads
120 query 1; heads
124 searching for changes
121 searching for changes
125 taking quick initial sample
122 taking initial sample
126 searching: 2 queries
123 searching: 2 queries
127 query 2; still undecided: 34, sample size is: 34
124 query 2; still undecided: 29, sample size is: 29
128 2 total queries
125 2 total queries
129 common heads: 2dc09a01254d
126 common heads: 2dc09a01254d
130
127
@@ -140,7 +137,7 b' Both sides many new with stub:'
140 searching for changes
137 searching for changes
141 taking initial sample
138 taking initial sample
142 searching: 2 queries
139 searching: 2 queries
143 query 2; still undecided: 30, sample size is: 30
140 query 2; still undecided: 29, sample size is: 29
144 2 total queries
141 2 total queries
145 common heads: 2dc09a01254d
142 common heads: 2dc09a01254d
146
143
@@ -163,7 +160,7 b' Both many new:'
163 searching for changes
160 searching for changes
164 taking quick initial sample
161 taking quick initial sample
165 searching: 2 queries
162 searching: 2 queries
166 query 2; still undecided: 32, sample size is: 32
163 query 2; still undecided: 31, sample size is: 31
167 2 total queries
164 2 total queries
168 common heads: 66f7d451a68b
165 common heads: 66f7d451a68b
169
166
@@ -179,7 +176,7 b' Both many new:'
179 searching for changes
176 searching for changes
180 taking quick initial sample
177 taking quick initial sample
181 searching: 2 queries
178 searching: 2 queries
182 query 2; still undecided: 32, sample size is: 32
179 query 2; still undecided: 31, sample size is: 31
183 2 total queries
180 2 total queries
184 common heads: 66f7d451a68b
181 common heads: 66f7d451a68b
185
182
@@ -202,7 +199,7 b' Both many new skewed:'
202 searching for changes
199 searching for changes
203 taking quick initial sample
200 taking quick initial sample
204 searching: 2 queries
201 searching: 2 queries
205 query 2; still undecided: 52, sample size is: 52
202 query 2; still undecided: 51, sample size is: 51
206 2 total queries
203 2 total queries
207 common heads: 66f7d451a68b
204 common heads: 66f7d451a68b
208
205
@@ -218,7 +215,7 b' Both many new skewed:'
218 searching for changes
215 searching for changes
219 taking quick initial sample
216 taking quick initial sample
220 searching: 2 queries
217 searching: 2 queries
221 query 2; still undecided: 32, sample size is: 32
218 query 2; still undecided: 31, sample size is: 31
222 2 total queries
219 2 total queries
223 common heads: 66f7d451a68b
220 common heads: 66f7d451a68b
224
221
@@ -241,7 +238,7 b' Both many new on top of long history:'
241 searching for changes
238 searching for changes
242 taking quick initial sample
239 taking quick initial sample
243 searching: 2 queries
240 searching: 2 queries
244 query 2; still undecided: 1050, sample size is: 11
241 query 2; still undecided: 1049, sample size is: 11
245 sampling from both directions
242 sampling from both directions
246 searching: 3 queries
243 searching: 3 queries
247 query 3; still undecided: 31, sample size is: 31
244 query 3; still undecided: 31, sample size is: 31
@@ -260,7 +257,7 b' Both many new on top of long history:'
260 searching for changes
257 searching for changes
261 taking quick initial sample
258 taking quick initial sample
262 searching: 2 queries
259 searching: 2 queries
263 query 2; still undecided: 1030, sample size is: 11
260 query 2; still undecided: 1029, sample size is: 11
264 sampling from both directions
261 sampling from both directions
265 searching: 3 queries
262 searching: 3 queries
266 query 3; still undecided: 16, sample size is: 16
263 query 3; still undecided: 16, sample size is: 16
General Comments 0
You need to be logged in to leave comments. Login now