##// END OF EJS Templates
protocol: use changegroupsubset() if possible (issue1389)...
Benoit Boissinot -
r7415:6163ef93 default
parent child Browse files
Show More
@@ -461,13 +461,16 b' def transplant(ui, repo, *revs, **opts):'
461 def getremotechanges(repo, url):
461 def getremotechanges(repo, url):
462 sourcerepo = ui.expandpath(url)
462 sourcerepo = ui.expandpath(url)
463 source = hg.repository(ui, sourcerepo)
463 source = hg.repository(ui, sourcerepo)
464 incoming = repo.findincoming(source, force=True)
464 common, incoming, rheads = repo.findcommonincoming(source, force=True)
465 if not incoming:
465 if not incoming:
466 return (source, None, None)
466 return (source, None, None)
467
467
468 bundle = None
468 bundle = None
469 if not source.local():
469 if not source.local():
470 cg = source.changegroup(incoming, 'incoming')
470 if source.capable('changegroupsubset'):
471 cg = source.changegroupsubset(incoming, rheads, 'incoming')
472 else:
473 cg = source.changegroup(incoming, 'incoming')
471 bundle = changegroup.writebundle(cg, None, 'HG10UN')
474 bundle = changegroup.writebundle(cg, None, 'HG10UN')
472 source = bundlerepo.bundlerepository(ui, repo.root, bundle)
475 source = bundlerepo.bundlerepository(ui, repo.root, bundle)
473
476
@@ -1700,7 +1700,8 b' def incoming(ui, repo, source="default",'
1700 ui.status(_('comparing with %s\n') % url.hidepassword(source))
1700 ui.status(_('comparing with %s\n') % url.hidepassword(source))
1701 if revs:
1701 if revs:
1702 revs = [other.lookup(rev) for rev in revs]
1702 revs = [other.lookup(rev) for rev in revs]
1703 incoming = repo.findincoming(other, heads=revs, force=opts["force"])
1703 common, incoming, rheads = repo.findcommonincoming(other, heads=revs,
1704 force=opts["force"])
1704 if not incoming:
1705 if not incoming:
1705 try:
1706 try:
1706 os.unlink(opts["bundle"])
1707 os.unlink(opts["bundle"])
@@ -1714,6 +1715,10 b' def incoming(ui, repo, source="default",'
1714 fname = opts["bundle"]
1715 fname = opts["bundle"]
1715 if fname or not other.local():
1716 if fname or not other.local():
1716 # create a bundle (uncompressed if other repo is not local)
1717 # create a bundle (uncompressed if other repo is not local)
1718
1719 if revs is None and other.capable('changegroupsubset'):
1720 revs = rheads
1721
1717 if revs is None:
1722 if revs is None:
1718 cg = other.changegroup(incoming, "incoming")
1723 cg = other.changegroup(incoming, "incoming")
1719 else:
1724 else:
@@ -1266,6 +1266,22 b' class localrepository(repo.repository):'
1266 (and so we know that the rest of the nodes are missing in remote, see
1266 (and so we know that the rest of the nodes are missing in remote, see
1267 outgoing)
1267 outgoing)
1268 """
1268 """
1269 return self.findcommonincoming(remote, base, heads, force)[1]
1270
1271 def findcommonincoming(self, remote, base=None, heads=None, force=False):
1272 """Return a tuple (common, missing roots, heads) used to identify
1273 missing nodes from remote.
1274
1275 If base dict is specified, assume that these nodes and their parents
1276 exist on the remote side and that no child of a node of base exists
1277 in both remote and self.
1278 Furthermore base will be updated to include the nodes that exists
1279 in self and remote but no children exists in self and remote.
1280 If a list of heads is specified, return only nodes which are heads
1281 or ancestors of these heads.
1282
1283 All the ancestors of base are in self and in remote.
1284 """
1269 m = self.changelog.nodemap
1285 m = self.changelog.nodemap
1270 search = []
1286 search = []
1271 fetch = {}
1287 fetch = {}
@@ -1280,8 +1296,8 b' class localrepository(repo.repository):'
1280 if self.changelog.tip() == nullid:
1296 if self.changelog.tip() == nullid:
1281 base[nullid] = 1
1297 base[nullid] = 1
1282 if heads != [nullid]:
1298 if heads != [nullid]:
1283 return [nullid]
1299 return [nullid], [nullid], list(heads)
1284 return []
1300 return [nullid], [], []
1285
1301
1286 # assume we're closer to the tip than the root
1302 # assume we're closer to the tip than the root
1287 # and start by examining the heads
1303 # and start by examining the heads
@@ -1294,8 +1310,9 b' class localrepository(repo.repository):'
1294 else:
1310 else:
1295 base[h] = 1
1311 base[h] = 1
1296
1312
1313 heads = unknown
1297 if not unknown:
1314 if not unknown:
1298 return []
1315 return base.keys(), [], []
1299
1316
1300 req = dict.fromkeys(unknown)
1317 req = dict.fromkeys(unknown)
1301 reqcnt = 0
1318 reqcnt = 0
@@ -1390,7 +1407,7 b' class localrepository(repo.repository):'
1390
1407
1391 self.ui.debug(_("%d total queries\n") % reqcnt)
1408 self.ui.debug(_("%d total queries\n") % reqcnt)
1392
1409
1393 return fetch.keys()
1410 return base.keys(), fetch.keys(), heads
1394
1411
1395 def findoutgoing(self, remote, base=None, heads=None, force=False):
1412 def findoutgoing(self, remote, base=None, heads=None, force=False):
1396 """Return list of nodes that are roots of subsets not in remote
1413 """Return list of nodes that are roots of subsets not in remote
@@ -1443,7 +1460,8 b' class localrepository(repo.repository):'
1443 def pull(self, remote, heads=None, force=False):
1460 def pull(self, remote, heads=None, force=False):
1444 lock = self.lock()
1461 lock = self.lock()
1445 try:
1462 try:
1446 fetch = self.findincoming(remote, heads=heads, force=force)
1463 common, fetch, rheads = self.findcommonincoming(remote, heads=heads,
1464 force=force)
1447 if fetch == [nullid]:
1465 if fetch == [nullid]:
1448 self.ui.status(_("requesting all changes\n"))
1466 self.ui.status(_("requesting all changes\n"))
1449
1467
@@ -1451,10 +1469,13 b' class localrepository(repo.repository):'
1451 self.ui.status(_("no changes found\n"))
1469 self.ui.status(_("no changes found\n"))
1452 return 0
1470 return 0
1453
1471
1472 if heads is None and remote.capable('changegroupsubset'):
1473 heads = rheads
1474
1454 if heads is None:
1475 if heads is None:
1455 cg = remote.changegroup(fetch, 'pull')
1476 cg = remote.changegroup(fetch, 'pull')
1456 else:
1477 else:
1457 if 'changegroupsubset' not in remote.capabilities:
1478 if not remote.capable('changegroupsubset'):
1458 raise util.Abort(_("Partial pull cannot be done because other repository doesn't support changegroupsubset."))
1479 raise util.Abort(_("Partial pull cannot be done because other repository doesn't support changegroupsubset."))
1459 cg = remote.changegroupsubset(fetch, heads, 'pull')
1480 cg = remote.changegroupsubset(fetch, heads, 'pull')
1460 return self.addchangegroup(cg, 'pull', remote.url())
1481 return self.addchangegroup(cg, 'pull', remote.url())
@@ -100,7 +100,7 b' searching for changes'
100 adding changesets
100 adding changesets
101 adding manifests
101 adding manifests
102 adding file changes
102 adding file changes
103 added 1 changesets with 1 changes to 2 files
103 added 1 changesets with 1 changes to 1 files
104 % parent should be 2 (no automatic update)
104 % parent should be 2 (no automatic update)
105 2
105 2
106
106
@@ -62,13 +62,17 b' XXX "GET http://localhost:/?cmd=capabili'
62 XXX "GET http://localhost:/?cmd=stream_out HTTP/1.1" - -
62 XXX "GET http://localhost:/?cmd=stream_out HTTP/1.1" - -
63 XXX "GET http://localhost:/?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" - -
63 XXX "GET http://localhost:/?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" - -
64 XXX "GET http://localhost:/?cmd=heads HTTP/1.1" - -
64 XXX "GET http://localhost:/?cmd=heads HTTP/1.1" - -
65 XXX "GET http://localhost:/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - -
65 XXX "GET http://localhost:/?cmd=capabilities HTTP/1.1" - -
66 XXX "GET http://localhost:/?bases=0000000000000000000000000000000000000000&cmd=changegroupsubset&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - -
66 XXX "GET http://localhost:/?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" - -
67 XXX "GET http://localhost:/?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" - -
67 XXX "GET http://localhost:/?cmd=heads HTTP/1.1" - -
68 XXX "GET http://localhost:/?cmd=heads HTTP/1.1" - -
68 XXX "GET http://localhost:/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - -
69 XXX "GET http://localhost:/?cmd=capabilities HTTP/1.1" - -
70 XXX "GET http://localhost:/?bases=0000000000000000000000000000000000000000&cmd=changegroupsubset&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - -
69 XXX "GET http://localhost:/?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" - -
71 XXX "GET http://localhost:/?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" - -
70 XXX "GET http://localhost:/?cmd=heads HTTP/1.1" - -
72 XXX "GET http://localhost:/?cmd=heads HTTP/1.1" - -
71 XXX "GET http://localhost:/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - -
73 XXX "GET http://localhost:/?cmd=capabilities HTTP/1.1" - -
74 XXX "GET http://localhost:/?bases=0000000000000000000000000000000000000000&cmd=changegroupsubset&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - -
72 XXX "GET http://localhost:/?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" - -
75 XXX "GET http://localhost:/?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between HTTP/1.1" - -
73 XXX "GET http://localhost:/?cmd=heads HTTP/1.1" - -
76 XXX "GET http://localhost:/?cmd=heads HTTP/1.1" - -
74 XXX "GET http://localhost:/?cmd=changegroup&roots=0000000000000000000000000000000000000000 HTTP/1.1" - -
77 XXX "GET http://localhost:/?cmd=capabilities HTTP/1.1" - -
78 XXX "GET http://localhost:/?bases=0000000000000000000000000000000000000000&cmd=changegroupsubset&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - -
General Comments 0
You need to be logged in to leave comments. Login now