comparison mercurial/localrepo.py @ 13742:7abab875e647

discovery: avoid discovery when local graph is a subset of remote Immediately sends local's heads to the server to check whether the server knows them all. If it does, we can call getbundle immediately. Interesting test output changes are: - added 1 changesets with 0 changes to 1 files (+1 heads) + added 1 changesets with 0 changes to 0 files (+1 heads) -> The new getbundle() actually fixes a bug vs. changegroupsubset() in that it no longer returns unnecessary files when file revs are reused. warning: repository is unrelated + requesting all changes -> The new use of common instead of bases correctly indicates that an unrelated pull gets all changes from the server.
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Wed, 23 Mar 2011 16:06:55 +0100
parents b51bf961b3cb
children 9131724c3f4b
comparison
equal deleted inserted replaced
13741:b51bf961b3cb 13742:7abab875e647
1323 return r 1323 return r
1324 1324
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 "
1345 "other repository doesn't support " 1349 "other repository doesn't support "
1346 "changegroupsubset.")) 1350 "changegroupsubset."))