##// END OF EJS Templates
discovery: avoid discovery when local graph is a subset of remote...
Peter Arrenbrecht -
r13742:7abab875 default
parent child Browse files
Show More
@@ -548,8 +548,8 b' def transplant(ui, repo, *revs, **opts):'
548 548 if source:
549 549 sourcerepo = ui.expandpath(source)
550 550 source = hg.repository(ui, sourcerepo)
551 source, incoming, bundle = bundlerepo.getremotechanges(ui, repo, source,
552 force=True)
551 source, common, incoming, bundle = bundlerepo.getremotechanges(ui, repo,
552 source, force=True)
553 553 else:
554 554 source = repo
555 555
@@ -286,15 +286,17 b' def instance(ui, path, create):'
286 286 repopath, bundlename = parentpath, path
287 287 return bundlerepository(ui, repopath, bundlename)
288 288
289 def getremotechanges(ui, repo, other, revs=None, bundlename=None, force=False):
290 tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force)
289 def getremotechanges(ui, repo, other, revs=None, bundlename=None,
290 force=False, usecommon=False):
291 tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force,
292 commononly=usecommon)
291 293 common, incoming, rheads = tmp
292 294 if not incoming:
293 295 try:
294 296 os.unlink(bundlename)
295 297 except:
296 298 pass
297 return other, None, None
299 return other, None, None, None
298 300
299 301 bundle = None
300 302 if bundlename or not other.local():
@@ -303,7 +305,9 b' def getremotechanges(ui, repo, other, re'
303 305 if revs is None and other.capable('changegroupsubset'):
304 306 revs = rheads
305 307
306 if revs is None:
308 if usecommon:
309 cg = other.getbundle('incoming', common=common, heads=revs)
310 elif revs is None:
307 311 cg = other.changegroup(incoming, "incoming")
308 312 else:
309 313 cg = other.changegroupsubset(incoming, revs, 'incoming')
@@ -315,5 +319,5 b' def getremotechanges(ui, repo, other, re'
315 319 if not other.local():
316 320 # use the created uncompressed bundlerepo
317 321 other = bundlerepository(ui, repo.root, fname)
318 return (other, incoming, bundle)
322 return (other, common, incoming, bundle)
319 323
@@ -9,9 +9,10 b' from node import nullid, short'
9 9 from i18n import _
10 10 import util, error
11 11
12 def findcommonincoming(repo, remote, heads=None, force=False):
13 """Return a tuple (common, missing roots, heads) used to identify
14 missing nodes from remote.
12 def findcommonincoming(repo, remote, heads=None, force=False, commononly=False):
13 """Return a tuple (common, missing, heads) used to identify missing nodes
14 from remote. "missing" is either a boolean indicating if any nodes are missing
15 (when commononly=True), or else a list of the root nodes of the missing set.
15 16
16 17 If a list of heads is specified, return only nodes which are heads
17 18 or ancestors of these heads.
@@ -36,6 +37,13 b' def findcommonincoming(repo, remote, hea'
36 37 # and start by examining the heads
37 38 repo.ui.status(_("searching for changes\n"))
38 39
40 if commononly:
41 myheads = repo.heads()
42 known = remote.known(myheads)
43 if util.all(known):
44 hasincoming = set(heads).difference(set(myheads)) and True
45 return myheads, hasincoming, heads
46
39 47 unknown = []
40 48 for h in heads:
41 49 if h not in m:
@@ -436,14 +436,19 b' def _incoming(displaychlist, subreporecu'
436 436
437 437 if revs:
438 438 revs = [other.lookup(rev) for rev in revs]
439 other, incoming, bundle = bundlerepo.getremotechanges(ui, repo, other, revs,
440 opts["bundle"], opts["force"])
441 if incoming is None:
439 usecommon = other.capable('getbundle')
440 other, common, incoming, bundle = bundlerepo.getremotechanges(ui, repo, other,
441 revs, opts["bundle"], opts["force"],
442 usecommon=usecommon)
443 if not incoming:
442 444 ui.status(_("no changes found\n"))
443 445 return subreporecurse()
444 446
445 447 try:
446 chlist = other.changelog.nodesbetween(incoming, revs)[0]
448 if usecommon:
449 chlist = other.changelog.findmissing(common, revs)
450 else:
451 chlist = other.changelog.nodesbetween(incoming, revs)[0]
447 452 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
448 453
449 454 # XXX once graphlog extension makes it into core,
@@ -1325,20 +1325,24 b' class localrepository(repo.repository):'
1325 1325 def pull(self, remote, heads=None, force=False):
1326 1326 lock = self.lock()
1327 1327 try:
1328 usecommon = remote.capable('getbundle')
1328 1329 tmp = discovery.findcommonincoming(self, remote, heads=heads,
1329 force=force)
1330 force=force, commononly=usecommon)
1330 1331 common, fetch, rheads = tmp
1331 1332 if not fetch:
1332 1333 self.ui.status(_("no changes found\n"))
1333 1334 result = 0
1334 1335 else:
1335 if heads is None and fetch == [nullid]:
1336 if heads is None and list(common) == [nullid]:
1336 1337 self.ui.status(_("requesting all changes\n"))
1337 1338 elif heads is None and remote.capable('changegroupsubset'):
1338 1339 # issue1320, avoid a race if remote changed after discovery
1339 1340 heads = rheads
1340 1341
1341 if heads is None:
1342 if usecommon:
1343 cg = remote.getbundle('pull', common=common,
1344 heads=heads or rheads)
1345 elif heads is None:
1342 1346 cg = remote.changegroup(fetch, 'pull')
1343 1347 elif not remote.capable('changegroupsubset'):
1344 1348 raise util.Abort(_("partial pull cannot be done because "
@@ -17,6 +17,7 b' dirstate'
17 17 pulling from ../a
18 18 searching for changes
19 19 warning: repository is unrelated
20 requesting all changes
20 21 adding changesets
21 22 adding manifests
22 23 adding file changes
@@ -66,6 +67,7 b' create test repos'
66 67 pulling from ../repob
67 68 searching for changes
68 69 warning: repository is unrelated
70 requesting all changes
69 71 adding changesets
70 72 adding manifests
71 73 adding file changes
@@ -28,6 +28,7 b''
28 28 pulling from ../b
29 29 searching for changes
30 30 warning: repository is unrelated
31 requesting all changes
31 32 adding changesets
32 33 adding manifests
33 34 adding file changes
@@ -214,7 +214,7 b' clone remote via stream'
214 214 adding changesets
215 215 adding manifests
216 216 adding file changes
217 added 1 changesets with 0 changes to 1 files (+1 heads)
217 added 1 changesets with 0 changes to 0 files (+1 heads)
218 218 (run 'hg heads' to see heads, 'hg merge' to merge)
219 219 $ hg verify
220 220 checking changesets
@@ -238,7 +238,7 b' clone remote via stream'
238 238 adding changesets
239 239 adding manifests
240 240 adding file changes
241 added 2 changesets with 0 changes to 1 files (+1 heads)
241 added 2 changesets with 0 changes to 0 files (+1 heads)
242 242 (run 'hg heads' to see heads, 'hg merge' to merge)
243 243 $ hg verify
244 244 checking changesets
@@ -103,18 +103,18 b' do not use the proxy if it is in the no '
103 103 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
104 104 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
105 105 * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
106 * - - [*] "GET http://localhost:$HGPORT/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
106 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - - (glob)
107 107 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
108 108 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
109 109 * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
110 * - - [*] "GET http://localhost:$HGPORT/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
110 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - - (glob)
111 111 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
112 112 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
113 113 * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
114 * - - [*] "GET http://localhost:$HGPORT/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
114 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - - (glob)
115 115 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
116 116 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
117 117 * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
118 * - - [*] "GET http://localhost:$HGPORT/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - - (glob)
118 * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - - (glob)
119 119 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
120 120
@@ -29,6 +29,7 b' check that {1} syntax works'
29 29 comparing with parts://localhost
30 30 sending heads command
31 31 searching for changes
32 sending known command
32 33 no changes found
33 34 [1]
34 35
@@ -232,7 +232,7 b' clone remote via stream'
232 232 adding changesets
233 233 adding manifests
234 234 adding file changes
235 added 1 changesets with 0 changes to 1 files (+1 heads)
235 added 1 changesets with 0 changes to 0 files (+1 heads)
236 236 (run 'hg heads' to see heads, 'hg merge' to merge)
237 237 $ hg verify
238 238 checking changesets
@@ -256,7 +256,7 b' clone remote via stream'
256 256 adding changesets
257 257 adding manifests
258 258 adding file changes
259 added 2 changesets with 0 changes to 1 files (+1 heads)
259 added 2 changesets with 0 changes to 0 files (+1 heads)
260 260 (run 'hg heads' to see heads, 'hg merge' to merge)
261 261 $ hg verify
262 262 checking changesets
@@ -23,6 +23,7 b''
23 23 pulling from ../a
24 24 searching for changes
25 25 warning: repository is unrelated
26 requesting all changes
26 27 adding changesets
27 28 adding manifests
28 29 adding file changes
General Comments 0
You need to be logged in to leave comments. Login now