##// 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 if source:
548 if source:
549 sourcerepo = ui.expandpath(source)
549 sourcerepo = ui.expandpath(source)
550 source = hg.repository(ui, sourcerepo)
550 source = hg.repository(ui, sourcerepo)
551 source, incoming, bundle = bundlerepo.getremotechanges(ui, repo, source,
551 source, common, incoming, bundle = bundlerepo.getremotechanges(ui, repo,
552 force=True)
552 source, force=True)
553 else:
553 else:
554 source = repo
554 source = repo
555
555
@@ -286,15 +286,17 b' def instance(ui, path, create):'
286 repopath, bundlename = parentpath, path
286 repopath, bundlename = parentpath, path
287 return bundlerepository(ui, repopath, bundlename)
287 return bundlerepository(ui, repopath, bundlename)
288
288
289 def getremotechanges(ui, repo, other, revs=None, bundlename=None, force=False):
289 def getremotechanges(ui, repo, other, revs=None, bundlename=None,
290 tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force)
290 force=False, usecommon=False):
291 tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force,
292 commononly=usecommon)
291 common, incoming, rheads = tmp
293 common, incoming, rheads = tmp
292 if not incoming:
294 if not incoming:
293 try:
295 try:
294 os.unlink(bundlename)
296 os.unlink(bundlename)
295 except:
297 except:
296 pass
298 pass
297 return other, None, None
299 return other, None, None, None
298
300
299 bundle = None
301 bundle = None
300 if bundlename or not other.local():
302 if bundlename or not other.local():
@@ -303,7 +305,9 b' def getremotechanges(ui, repo, other, re'
303 if revs is None and other.capable('changegroupsubset'):
305 if revs is None and other.capable('changegroupsubset'):
304 revs = rheads
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 cg = other.changegroup(incoming, "incoming")
311 cg = other.changegroup(incoming, "incoming")
308 else:
312 else:
309 cg = other.changegroupsubset(incoming, revs, 'incoming')
313 cg = other.changegroupsubset(incoming, revs, 'incoming')
@@ -315,5 +319,5 b' def getremotechanges(ui, repo, other, re'
315 if not other.local():
319 if not other.local():
316 # use the created uncompressed bundlerepo
320 # use the created uncompressed bundlerepo
317 other = bundlerepository(ui, repo.root, fname)
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 from i18n import _
9 from i18n import _
10 import util, error
10 import util, error
11
11
12 def findcommonincoming(repo, remote, heads=None, force=False):
12 def findcommonincoming(repo, remote, heads=None, force=False, commononly=False):
13 """Return a tuple (common, missing roots, heads) used to identify
13 """Return a tuple (common, missing, heads) used to identify missing nodes
14 missing nodes from remote.
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 If a list of heads is specified, return only nodes which are heads
17 If a list of heads is specified, return only nodes which are heads
17 or ancestors of these heads.
18 or ancestors of these heads.
@@ -36,6 +37,13 b' def findcommonincoming(repo, remote, hea'
36 # and start by examining the heads
37 # and start by examining the heads
37 repo.ui.status(_("searching for changes\n"))
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 unknown = []
47 unknown = []
40 for h in heads:
48 for h in heads:
41 if h not in m:
49 if h not in m:
@@ -436,14 +436,19 b' def _incoming(displaychlist, subreporecu'
436
436
437 if revs:
437 if revs:
438 revs = [other.lookup(rev) for rev in revs]
438 revs = [other.lookup(rev) for rev in revs]
439 other, incoming, bundle = bundlerepo.getremotechanges(ui, repo, other, revs,
439 usecommon = other.capable('getbundle')
440 opts["bundle"], opts["force"])
440 other, common, incoming, bundle = bundlerepo.getremotechanges(ui, repo, other,
441 if incoming is None:
441 revs, opts["bundle"], opts["force"],
442 usecommon=usecommon)
443 if not incoming:
442 ui.status(_("no changes found\n"))
444 ui.status(_("no changes found\n"))
443 return subreporecurse()
445 return subreporecurse()
444
446
445 try:
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 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
452 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
448
453
449 # XXX once graphlog extension makes it into core,
454 # XXX once graphlog extension makes it into core,
@@ -1325,20 +1325,24 b' class localrepository(repo.repository):'
1325 def pull(self, remote, heads=None, force=False):
1325 def pull(self, remote, heads=None, force=False):
1326 lock = self.lock()
1326 lock = self.lock()
1327 try:
1327 try:
1328 usecommon = remote.capable('getbundle')
1328 tmp = discovery.findcommonincoming(self, remote, heads=heads,
1329 tmp = discovery.findcommonincoming(self, remote, heads=heads,
1329 force=force)
1330 force=force, commononly=usecommon)
1330 common, fetch, rheads = tmp
1331 common, fetch, rheads = tmp
1331 if not fetch:
1332 if not fetch:
1332 self.ui.status(_("no changes found\n"))
1333 self.ui.status(_("no changes found\n"))
1333 result = 0
1334 result = 0
1334 else:
1335 else:
1335 if heads is None and fetch == [nullid]:
1336 if heads is None and list(common) == [nullid]:
1336 self.ui.status(_("requesting all changes\n"))
1337 self.ui.status(_("requesting all changes\n"))
1337 elif heads is None and remote.capable('changegroupsubset'):
1338 elif heads is None and remote.capable('changegroupsubset'):
1338 # issue1320, avoid a race if remote changed after discovery
1339 # issue1320, avoid a race if remote changed after discovery
1339 heads = rheads
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 cg = remote.changegroup(fetch, 'pull')
1346 cg = remote.changegroup(fetch, 'pull')
1343 elif not remote.capable('changegroupsubset'):
1347 elif not remote.capable('changegroupsubset'):
1344 raise util.Abort(_("partial pull cannot be done because "
1348 raise util.Abort(_("partial pull cannot be done because "
@@ -17,6 +17,7 b' dirstate'
17 pulling from ../a
17 pulling from ../a
18 searching for changes
18 searching for changes
19 warning: repository is unrelated
19 warning: repository is unrelated
20 requesting all changes
20 adding changesets
21 adding changesets
21 adding manifests
22 adding manifests
22 adding file changes
23 adding file changes
@@ -66,6 +67,7 b' create test repos'
66 pulling from ../repob
67 pulling from ../repob
67 searching for changes
68 searching for changes
68 warning: repository is unrelated
69 warning: repository is unrelated
70 requesting all changes
69 adding changesets
71 adding changesets
70 adding manifests
72 adding manifests
71 adding file changes
73 adding file changes
@@ -28,6 +28,7 b''
28 pulling from ../b
28 pulling from ../b
29 searching for changes
29 searching for changes
30 warning: repository is unrelated
30 warning: repository is unrelated
31 requesting all changes
31 adding changesets
32 adding changesets
32 adding manifests
33 adding manifests
33 adding file changes
34 adding file changes
@@ -214,7 +214,7 b' clone remote via stream'
214 adding changesets
214 adding changesets
215 adding manifests
215 adding manifests
216 adding file changes
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 (run 'hg heads' to see heads, 'hg merge' to merge)
218 (run 'hg heads' to see heads, 'hg merge' to merge)
219 $ hg verify
219 $ hg verify
220 checking changesets
220 checking changesets
@@ -238,7 +238,7 b' clone remote via stream'
238 adding changesets
238 adding changesets
239 adding manifests
239 adding manifests
240 adding file changes
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 (run 'hg heads' to see heads, 'hg merge' to merge)
242 (run 'hg heads' to see heads, 'hg merge' to merge)
243 $ hg verify
243 $ hg verify
244 checking changesets
244 checking changesets
@@ -103,18 +103,18 b' do not use the proxy if it is in the no '
103 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
103 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (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=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 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
107 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (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=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 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
111 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (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=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 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
115 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (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=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 * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob)
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 comparing with parts://localhost
29 comparing with parts://localhost
30 sending heads command
30 sending heads command
31 searching for changes
31 searching for changes
32 sending known command
32 no changes found
33 no changes found
33 [1]
34 [1]
34
35
@@ -232,7 +232,7 b' clone remote via stream'
232 adding changesets
232 adding changesets
233 adding manifests
233 adding manifests
234 adding file changes
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 (run 'hg heads' to see heads, 'hg merge' to merge)
236 (run 'hg heads' to see heads, 'hg merge' to merge)
237 $ hg verify
237 $ hg verify
238 checking changesets
238 checking changesets
@@ -256,7 +256,7 b' clone remote via stream'
256 adding changesets
256 adding changesets
257 adding manifests
257 adding manifests
258 adding file changes
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 (run 'hg heads' to see heads, 'hg merge' to merge)
260 (run 'hg heads' to see heads, 'hg merge' to merge)
261 $ hg verify
261 $ hg verify
262 checking changesets
262 checking changesets
@@ -23,6 +23,7 b''
23 pulling from ../a
23 pulling from ../a
24 searching for changes
24 searching for changes
25 warning: repository is unrelated
25 warning: repository is unrelated
26 requesting all changes
26 adding changesets
27 adding changesets
27 adding manifests
28 adding manifests
28 adding file changes
29 adding file changes
General Comments 0
You need to be logged in to leave comments. Login now