##// END OF EJS Templates
setdiscover: allow to ignore part of the local graph...
Boris Feld -
r35305:f77121b6 default
parent child Browse files
Show More
@@ -154,8 +154,9 b' class revlogbaseddag(basedag):'
154 class revlogdag(revlogbaseddag):
154 class revlogdag(revlogbaseddag):
155 '''dag interface to a revlog'''
155 '''dag interface to a revlog'''
156
156
157 def __init__(self, revlog):
157 def __init__(self, revlog, localsubset=None):
158 revlogbaseddag.__init__(self, revlog, set(revlog))
158 revlogbaseddag.__init__(self, revlog, set(revlog))
159 self._heads = localsubset
159
160
160 def _getheads(self):
161 def _getheads(self):
161 return [r for r in self._revlog.headrevs() if r != nullrev]
162 return [r for r in self._revlog.headrevs() if r != nullrev]
@@ -734,6 +734,7 b' def debugstate(ui, repo, **opts):'
734 [('', 'old', None, _('use old-style discovery')),
734 [('', 'old', None, _('use old-style discovery')),
735 ('', 'nonheads', None,
735 ('', 'nonheads', None,
736 _('use old-style discovery with non-heads included')),
736 _('use old-style discovery with non-heads included')),
737 ('', 'rev', [], 'restrict discovery to this set of revs'),
737 ] + cmdutil.remoteopts,
738 ] + cmdutil.remoteopts,
738 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
739 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
739 def debugdiscovery(ui, repo, remoteurl="default", **opts):
740 def debugdiscovery(ui, repo, remoteurl="default", **opts):
@@ -747,11 +748,8 b' def debugdiscovery(ui, repo, remoteurl="'
747 # make sure tests are repeatable
748 # make sure tests are repeatable
748 random.seed(12323)
749 random.seed(12323)
749
750
750 def doit(localheads, remoteheads, remote=remote):
751 def doit(pushedrevs, remoteheads, remote=remote):
751 if opts.get('old'):
752 if opts.get('old'):
752 if localheads:
753 raise error.Abort('cannot use localheads with old style '
754 'discovery')
755 if not util.safehasattr(remote, 'branches'):
753 if not util.safehasattr(remote, 'branches'):
756 # enable in-client legacy support
754 # enable in-client legacy support
757 remote = localrepo.locallegacypeer(remote.local())
755 remote = localrepo.locallegacypeer(remote.local())
@@ -765,7 +763,12 b' def debugdiscovery(ui, repo, remoteurl="'
765 all = dag.ancestorset(dag.internalizeall(common))
763 all = dag.ancestorset(dag.internalizeall(common))
766 common = dag.externalizeall(dag.headsetofconnecteds(all))
764 common = dag.externalizeall(dag.headsetofconnecteds(all))
767 else:
765 else:
768 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
766 nodes = None
767 if pushedrevs:
768 revs = scmutil.revrange(repo, pushedrevs)
769 nodes = [repo[r].node() for r in revs]
770 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote,
771 ancestorsof=nodes)
769 common = set(common)
772 common = set(common)
770 rheads = set(hds)
773 rheads = set(hds)
771 lheads = set(repo.heads())
774 lheads = set(repo.heads())
@@ -794,7 +797,7 b' def debugdiscovery(ui, repo, remoteurl="'
794 else:
797 else:
795 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
798 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
796 opts.get('remote_head'))
799 opts.get('remote_head'))
797 localrevs = opts.get('local_head')
800 localrevs = opts.get('rev')
798 doit(localrevs, remoterevs)
801 doit(localrevs, remoterevs)
799
802
800 @command('debugextensions', cmdutil.formatteropts, [], norepo=True)
803 @command('debugextensions', cmdutil.formatteropts, [], norepo=True)
@@ -133,7 +133,8 b' def _limitsample(sample, desiredlen):'
133 def findcommonheads(ui, local, remote,
133 def findcommonheads(ui, local, remote,
134 initialsamplesize=100,
134 initialsamplesize=100,
135 fullsamplesize=200,
135 fullsamplesize=200,
136 abortwhenunrelated=True):
136 abortwhenunrelated=True,
137 ancestorsof=None):
137 '''Return a tuple (common, anyincoming, remoteheads) used to identify
138 '''Return a tuple (common, anyincoming, remoteheads) used to identify
138 missing nodes from or in remote.
139 missing nodes from or in remote.
139 '''
140 '''
@@ -141,7 +142,11 b' def findcommonheads(ui, local, remote,'
141
142
142 roundtrips = 0
143 roundtrips = 0
143 cl = local.changelog
144 cl = local.changelog
144 dag = dagutil.revlogdag(cl)
145 localsubset = None
146 if ancestorsof is not None:
147 rev = local.changelog.rev
148 localsubset = [rev(n) for n in ancestorsof]
149 dag = dagutil.revlogdag(cl, localsubset=localsubset)
145
150
146 # early exit if we know all the specified remote heads already
151 # early exit if we know all the specified remote heads already
147 ui.debug("query 1; heads\n")
152 ui.debug("query 1; heads\n")
@@ -261,7 +261,7 b' Show all commands + options'
261 debugdate: extended
261 debugdate: extended
262 debugdeltachain: changelog, manifest, dir, template
262 debugdeltachain: changelog, manifest, dir, template
263 debugdirstate: nodates, datesort
263 debugdirstate: nodates, datesort
264 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
264 debugdiscovery: old, nonheads, rev, ssh, remotecmd, insecure
265 debugextensions: template
265 debugextensions: template
266 debugfileset: rev
266 debugfileset: rev
267 debugfsinfo:
267 debugfsinfo:
@@ -16,11 +16,17 b' Function to test discovery between two r'
16 > echo "% -- a -> b set"
16 > echo "% -- a -> b set"
17 > hg -R a debugdiscovery b --verbose --debug --config progress.debug=true
17 > hg -R a debugdiscovery b --verbose --debug --config progress.debug=true
18 > echo
18 > echo
19 > echo "% -- a -> b set (tip only)"
20 > hg -R a debugdiscovery b --verbose --debug --config progress.debug=true --rev tip
21 > echo
19 > echo "% -- b -> a tree"
22 > echo "% -- b -> a tree"
20 > hg -R b debugdiscovery a --verbose --old
23 > hg -R b debugdiscovery a --verbose --old
21 > echo
24 > echo
22 > echo "% -- b -> a set"
25 > echo "% -- b -> a set"
23 > hg -R b debugdiscovery a --verbose --debug --config progress.debug=true
26 > hg -R b debugdiscovery a --verbose --debug --config progress.debug=true
27 > echo
28 > echo "% -- b -> a set (tip only)"
29 > hg -R b debugdiscovery a --verbose --debug --config progress.debug=true --rev tip
24 > cd ..
30 > cd ..
25 > }
31 > }
26
32
@@ -48,6 +54,13 b' Small superset:'
48 common heads: 01241442b3c2 b5714e113bc0
54 common heads: 01241442b3c2 b5714e113bc0
49 local is subset
55 local is subset
50
56
57 % -- a -> b set (tip only)
58 comparing with b
59 query 1; heads
60 searching for changes
61 all local heads known remotely
62 common heads: b5714e113bc0
63
51 % -- b -> a tree
64 % -- b -> a tree
52 comparing with a
65 comparing with a
53 searching for changes
66 searching for changes
@@ -62,6 +75,14 b' Small superset:'
62 all remote heads known locally
75 all remote heads known locally
63 common heads: 01241442b3c2 b5714e113bc0
76 common heads: 01241442b3c2 b5714e113bc0
64 remote is subset
77 remote is subset
78
79 % -- b -> a set (tip only)
80 comparing with a
81 query 1; heads
82 searching for changes
83 all remote heads known locally
84 common heads: 01241442b3c2 b5714e113bc0
85 remote is subset
65
86
66
87
67 Many new:
88 Many new:
@@ -86,6 +107,16 b' Many new:'
86 2 total queries in *.????s (glob)
107 2 total queries in *.????s (glob)
87 common heads: bebd167eb94d
108 common heads: bebd167eb94d
88
109
110 % -- a -> b set (tip only)
111 comparing with b
112 query 1; heads
113 searching for changes
114 taking quick initial sample
115 searching: 2 queries
116 query 2; still undecided: 31, sample size is: 31
117 2 total queries in *.????s (glob)
118 common heads: 66f7d451a68b
119
89 % -- b -> a tree
120 % -- b -> a tree
90 comparing with a
121 comparing with a
91 searching for changes
122 searching for changes
@@ -101,6 +132,16 b' Many new:'
101 query 2; still undecided: 2, sample size is: 2
132 query 2; still undecided: 2, sample size is: 2
102 2 total queries in *.????s (glob)
133 2 total queries in *.????s (glob)
103 common heads: bebd167eb94d
134 common heads: bebd167eb94d
135
136 % -- b -> a set (tip only)
137 comparing with a
138 query 1; heads
139 searching for changes
140 taking initial sample
141 searching: 2 queries
142 query 2; still undecided: 2, sample size is: 2
143 2 total queries in *.????s (glob)
144 common heads: bebd167eb94d
104
145
105 Both sides many new with stub:
146 Both sides many new with stub:
106
147
@@ -124,6 +165,16 b' Both sides many new with stub:'
124 2 total queries in *.????s (glob)
165 2 total queries in *.????s (glob)
125 common heads: 2dc09a01254d
166 common heads: 2dc09a01254d
126
167
168 % -- a -> b set (tip only)
169 comparing with b
170 query 1; heads
171 searching for changes
172 taking quick initial sample
173 searching: 2 queries
174 query 2; still undecided: 31, sample size is: 31
175 2 total queries in *.????s (glob)
176 common heads: 66f7d451a68b
177
127 % -- b -> a tree
178 % -- b -> a tree
128 comparing with a
179 comparing with a
129 searching for changes
180 searching for changes
@@ -139,6 +190,16 b' Both sides many new with stub:'
139 query 2; still undecided: 29, sample size is: 29
190 query 2; still undecided: 29, sample size is: 29
140 2 total queries in *.????s (glob)
191 2 total queries in *.????s (glob)
141 common heads: 2dc09a01254d
192 common heads: 2dc09a01254d
193
194 % -- b -> a set (tip only)
195 comparing with a
196 query 1; heads
197 searching for changes
198 taking initial sample
199 searching: 2 queries
200 query 2; still undecided: 29, sample size is: 29
201 2 total queries in *.????s (glob)
202 common heads: 2dc09a01254d
142
203
143
204
144 Both many new:
205 Both many new:
@@ -163,6 +224,16 b' Both many new:'
163 2 total queries in *.????s (glob)
224 2 total queries in *.????s (glob)
164 common heads: 66f7d451a68b
225 common heads: 66f7d451a68b
165
226
227 % -- a -> b set (tip only)
228 comparing with b
229 query 1; heads
230 searching for changes
231 taking quick initial sample
232 searching: 2 queries
233 query 2; still undecided: 31, sample size is: 31
234 2 total queries in *.????s (glob)
235 common heads: 66f7d451a68b
236
166 % -- b -> a tree
237 % -- b -> a tree
167 comparing with a
238 comparing with a
168 searching for changes
239 searching for changes
@@ -178,6 +249,16 b' Both many new:'
178 query 2; still undecided: 31, sample size is: 31
249 query 2; still undecided: 31, sample size is: 31
179 2 total queries in *.????s (glob)
250 2 total queries in *.????s (glob)
180 common heads: 66f7d451a68b
251 common heads: 66f7d451a68b
252
253 % -- b -> a set (tip only)
254 comparing with a
255 query 1; heads
256 searching for changes
257 taking quick initial sample
258 searching: 2 queries
259 query 2; still undecided: 31, sample size is: 31
260 2 total queries in *.????s (glob)
261 common heads: 66f7d451a68b
181
262
182
263
183 Both many new skewed:
264 Both many new skewed:
@@ -202,6 +283,16 b' Both many new skewed:'
202 2 total queries in *.????s (glob)
283 2 total queries in *.????s (glob)
203 common heads: 66f7d451a68b
284 common heads: 66f7d451a68b
204
285
286 % -- a -> b set (tip only)
287 comparing with b
288 query 1; heads
289 searching for changes
290 taking quick initial sample
291 searching: 2 queries
292 query 2; still undecided: 51, sample size is: 51
293 2 total queries in *.????s (glob)
294 common heads: 66f7d451a68b
295
205 % -- b -> a tree
296 % -- b -> a tree
206 comparing with a
297 comparing with a
207 searching for changes
298 searching for changes
@@ -217,6 +308,16 b' Both many new skewed:'
217 query 2; still undecided: 31, sample size is: 31
308 query 2; still undecided: 31, sample size is: 31
218 2 total queries in *.????s (glob)
309 2 total queries in *.????s (glob)
219 common heads: 66f7d451a68b
310 common heads: 66f7d451a68b
311
312 % -- b -> a set (tip only)
313 comparing with a
314 query 1; heads
315 searching for changes
316 taking quick initial sample
317 searching: 2 queries
318 query 2; still undecided: 31, sample size is: 31
319 2 total queries in *.????s (glob)
320 common heads: 66f7d451a68b
220
321
221
322
222 Both many new on top of long history:
323 Both many new on top of long history:
@@ -244,6 +345,19 b' Both many new on top of long history:'
244 3 total queries in *.????s (glob)
345 3 total queries in *.????s (glob)
245 common heads: 7ead0cba2838
346 common heads: 7ead0cba2838
246
347
348 % -- a -> b set (tip only)
349 comparing with b
350 query 1; heads
351 searching for changes
352 taking quick initial sample
353 searching: 2 queries
354 query 2; still undecided: 1049, sample size is: 11
355 sampling from both directions
356 searching: 3 queries
357 query 3; still undecided: 31, sample size is: 31
358 3 total queries in *.????s (glob)
359 common heads: 7ead0cba2838
360
247 % -- b -> a tree
361 % -- b -> a tree
248 comparing with a
362 comparing with a
249 searching for changes
363 searching for changes
@@ -262,6 +376,19 b' Both many new on top of long history:'
262 query 3; still undecided: 15, sample size is: 15
376 query 3; still undecided: 15, sample size is: 15
263 3 total queries in *.????s (glob)
377 3 total queries in *.????s (glob)
264 common heads: 7ead0cba2838
378 common heads: 7ead0cba2838
379
380 % -- b -> a set (tip only)
381 comparing with a
382 query 1; heads
383 searching for changes
384 taking quick initial sample
385 searching: 2 queries
386 query 2; still undecided: 1029, sample size is: 11
387 sampling from both directions
388 searching: 3 queries
389 query 3; still undecided: 15, sample size is: 15
390 3 total queries in *.????s (glob)
391 common heads: 7ead0cba2838
265
392
266
393
267 One with >200 heads, which used to use up all of the sample:
394 One with >200 heads, which used to use up all of the sample:
@@ -327,6 +454,18 b' One with >200 heads, which used to use u'
327 query 6; still undecided: \d+, sample size is: \d+ (re)
454 query 6; still undecided: \d+, sample size is: \d+ (re)
328 6 total queries in *.????s (glob)
455 6 total queries in *.????s (glob)
329 common heads: 3ee37d65064a
456 common heads: 3ee37d65064a
457 $ hg -R a debugdiscovery b --debug --verbose --config progress.debug=true --rev tip
458 comparing with b
459 query 1; heads
460 searching for changes
461 taking quick initial sample
462 searching: 2 queries
463 query 2; still undecided: 303, sample size is: 9
464 sampling from both directions
465 searching: 3 queries
466 query 3; still undecided: 3, sample size is: 3
467 3 total queries in *.????s (glob)
468 common heads: 3ee37d65064a
330
469
331 Test actual protocol when pulling one new head in addition to common heads
470 Test actual protocol when pulling one new head in addition to common heads
332
471
General Comments 0
You need to be logged in to leave comments. Login now