comparison mercurial/bundlerepo.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 d747774ca9da
children e574207e3bcd
comparison
equal deleted inserted replaced
13741:b51bf961b3cb 13742:7abab875e647
284 repopath, bundlename = s 284 repopath, bundlename = s
285 else: 285 else:
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():
301 # create a bundle (uncompressed if other repo is not local) 303 # create a bundle (uncompressed if other repo is not local)
302 304
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')
310 bundletype = other.local() and "HG10BZ" or "HG10UN" 314 bundletype = other.local() and "HG10BZ" or "HG10UN"
311 fname = bundle = changegroup.writebundle(cg, bundlename, bundletype) 315 fname = bundle = changegroup.writebundle(cg, bundlename, bundletype)
313 if bundlename: 317 if bundlename:
314 bundle = None 318 bundle = None
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