mercurial/setdiscovery.py
changeset 46110 d90f439ff19f
parent 45942 89a2afe31e82
child 46299 397e39ad0174
equal deleted inserted replaced
46109:2f357d053df2 46110:d90f439ff19f
   289     initialsamplesize=100,
   289     initialsamplesize=100,
   290     fullsamplesize=200,
   290     fullsamplesize=200,
   291     abortwhenunrelated=True,
   291     abortwhenunrelated=True,
   292     ancestorsof=None,
   292     ancestorsof=None,
   293     samplegrowth=1.05,
   293     samplegrowth=1.05,
       
   294     audit=None,
   294 ):
   295 ):
   295     """Return a tuple (common, anyincoming, remoteheads) used to identify
   296     """Return a tuple (common, anyincoming, remoteheads) used to identify
   296     missing nodes from or in remote.
   297     missing nodes from or in remote.
       
   298 
       
   299     The audit argument is an optional dictionnary that a caller can pass. it
       
   300     will be updated with extra data about the discovery, this is useful for
       
   301     debug.
   297     """
   302     """
   298     start = util.timer()
   303     start = util.timer()
   299 
   304 
   300     roundtrips = 0
   305     roundtrips = 0
   301     cl = local.changelog
   306     cl = local.changelog
   376                 b'nodes': [clnode(r) for r in sample],
   381                 b'nodes': [clnode(r) for r in sample],
   377             },
   382             },
   378         )
   383         )
   379 
   384 
   380     srvheadhashes, yesno = fheads.result(), fknown.result()
   385     srvheadhashes, yesno = fheads.result(), fknown.result()
       
   386 
       
   387     if audit is not None:
       
   388         audit[b'total-roundtrips'] = 1
   381 
   389 
   382     if cl.tip() == nullid:
   390     if cl.tip() == nullid:
   383         if srvheadhashes != [nullid]:
   391         if srvheadhashes != [nullid]:
   384             return [nullid], True, srvheadhashes
   392             return [nullid], True, srvheadhashes
   385         return [nullid], False, []
   393         return [nullid], False, []
   471         b' %d roundtrips in %.4fs\n'
   479         b' %d roundtrips in %.4fs\n'
   472     )
   480     )
   473     missing = set(result) - set(knownsrvheads)
   481     missing = set(result) - set(knownsrvheads)
   474     ui.log(b'discovery', msg, len(result), len(missing), roundtrips, elapsed)
   482     ui.log(b'discovery', msg, len(result), len(missing), roundtrips, elapsed)
   475 
   483 
       
   484     if audit is not None:
       
   485         audit[b'total-roundtrips'] = roundtrips
       
   486 
   476     if not result and srvheadhashes != [nullid]:
   487     if not result and srvheadhashes != [nullid]:
   477         if abortwhenunrelated:
   488         if abortwhenunrelated:
   478             raise error.Abort(_(b"repository is unrelated"))
   489             raise error.Abort(_(b"repository is unrelated"))
   479         else:
   490         else:
   480             ui.warn(_(b"warning: repository is unrelated\n"))
   491             ui.warn(_(b"warning: repository is unrelated\n"))