equal
deleted
inserted
replaced
44 |
44 |
45 import collections |
45 import collections |
46 import random |
46 import random |
47 |
47 |
48 from .i18n import _ |
48 from .i18n import _ |
49 from .node import ( |
49 from .node import nullrev |
50 nullid, |
|
51 nullrev, |
|
52 ) |
|
53 from . import ( |
50 from . import ( |
54 error, |
51 error, |
55 policy, |
52 policy, |
56 util, |
53 util, |
57 ) |
54 ) |
389 |
386 |
390 if audit is not None: |
387 if audit is not None: |
391 audit[b'total-roundtrips'] = 1 |
388 audit[b'total-roundtrips'] = 1 |
392 |
389 |
393 if cl.tiprev() == nullrev: |
390 if cl.tiprev() == nullrev: |
394 if srvheadhashes != [nullid]: |
391 if srvheadhashes != [cl.nullid]: |
395 return [nullid], True, srvheadhashes |
392 return [cl.nullid], True, srvheadhashes |
396 return [nullid], False, [] |
393 return [cl.nullid], False, [] |
397 else: |
394 else: |
398 # we still need the remote head for the function return |
395 # we still need the remote head for the function return |
399 with remote.commandexecutor() as e: |
396 with remote.commandexecutor() as e: |
400 fheads = e.callcommand(b'heads', {}) |
397 fheads = e.callcommand(b'heads', {}) |
401 srvheadhashes = fheads.result() |
398 srvheadhashes = fheads.result() |
404 # compatibility reasons) |
401 # compatibility reasons) |
405 ui.status(_(b"searching for changes\n")) |
402 ui.status(_(b"searching for changes\n")) |
406 |
403 |
407 knownsrvheads = [] # revnos of remote heads that are known locally |
404 knownsrvheads = [] # revnos of remote heads that are known locally |
408 for node in srvheadhashes: |
405 for node in srvheadhashes: |
409 if node == nullid: |
406 if node == cl.nullid: |
410 continue |
407 continue |
411 |
408 |
412 try: |
409 try: |
413 knownsrvheads.append(clrev(node)) |
410 knownsrvheads.append(clrev(node)) |
414 # Catches unknown and filtered nodes. |
411 # Catches unknown and filtered nodes. |
501 ui.log(b'discovery', msg, len(result), len(missing), roundtrips, elapsed) |
498 ui.log(b'discovery', msg, len(result), len(missing), roundtrips, elapsed) |
502 |
499 |
503 if audit is not None: |
500 if audit is not None: |
504 audit[b'total-roundtrips'] = roundtrips |
501 audit[b'total-roundtrips'] = roundtrips |
505 |
502 |
506 if not result and srvheadhashes != [nullid]: |
503 if not result and srvheadhashes != [cl.nullid]: |
507 if abortwhenunrelated: |
504 if abortwhenunrelated: |
508 raise error.Abort(_(b"repository is unrelated")) |
505 raise error.Abort(_(b"repository is unrelated")) |
509 else: |
506 else: |
510 ui.warn(_(b"warning: repository is unrelated\n")) |
507 ui.warn(_(b"warning: repository is unrelated\n")) |
511 return ( |
508 return ( |
512 {nullid}, |
509 {cl.nullid}, |
513 True, |
510 True, |
514 srvheadhashes, |
511 srvheadhashes, |
515 ) |
512 ) |
516 |
513 |
517 anyincoming = srvheadhashes != [nullid] |
514 anyincoming = srvheadhashes != [cl.nullid] |
518 result = {clnode(r) for r in result} |
515 result = {clnode(r) for r in result} |
519 return result, anyincoming, srvheadhashes |
516 return result, anyincoming, srvheadhashes |