449 ui.write(("internal: %s %s\n") % d) |
455 ui.write(("internal: %s %s\n") % d) |
450 ui.write(("standard: %s\n") % util.datestr(d)) |
456 ui.write(("standard: %s\n") % util.datestr(d)) |
451 if range: |
457 if range: |
452 m = util.matchdate(range) |
458 m = util.matchdate(range) |
453 ui.write(("match: %s\n") % m(d[0])) |
459 ui.write(("match: %s\n") % m(d[0])) |
|
460 |
|
461 @command('debugdiscovery', |
|
462 [('', 'old', None, _('use old-style discovery')), |
|
463 ('', 'nonheads', None, |
|
464 _('use old-style discovery with non-heads included')), |
|
465 ] + commands.remoteopts, |
|
466 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]')) |
|
467 def debugdiscovery(ui, repo, remoteurl="default", **opts): |
|
468 """runs the changeset discovery protocol in isolation""" |
|
469 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), |
|
470 opts.get('branch')) |
|
471 remote = hg.peer(repo, opts, remoteurl) |
|
472 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) |
|
473 |
|
474 # make sure tests are repeatable |
|
475 random.seed(12323) |
|
476 |
|
477 def doit(localheads, remoteheads, remote=remote): |
|
478 if opts.get('old'): |
|
479 if localheads: |
|
480 raise error.Abort('cannot use localheads with old style ' |
|
481 'discovery') |
|
482 if not util.safehasattr(remote, 'branches'): |
|
483 # enable in-client legacy support |
|
484 remote = localrepo.locallegacypeer(remote.local()) |
|
485 common, _in, hds = treediscovery.findcommonincoming(repo, remote, |
|
486 force=True) |
|
487 common = set(common) |
|
488 if not opts.get('nonheads'): |
|
489 ui.write(("unpruned common: %s\n") % |
|
490 " ".join(sorted(short(n) for n in common))) |
|
491 dag = dagutil.revlogdag(repo.changelog) |
|
492 all = dag.ancestorset(dag.internalizeall(common)) |
|
493 common = dag.externalizeall(dag.headsetofconnecteds(all)) |
|
494 else: |
|
495 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote) |
|
496 common = set(common) |
|
497 rheads = set(hds) |
|
498 lheads = set(repo.heads()) |
|
499 ui.write(("common heads: %s\n") % |
|
500 " ".join(sorted(short(n) for n in common))) |
|
501 if lheads <= common: |
|
502 ui.write(("local is subset\n")) |
|
503 elif rheads <= common: |
|
504 ui.write(("remote is subset\n")) |
|
505 |
|
506 serverlogs = opts.get('serverlog') |
|
507 if serverlogs: |
|
508 for filename in serverlogs: |
|
509 with open(filename, 'r') as logfile: |
|
510 line = logfile.readline() |
|
511 while line: |
|
512 parts = line.strip().split(';') |
|
513 op = parts[1] |
|
514 if op == 'cg': |
|
515 pass |
|
516 elif op == 'cgss': |
|
517 doit(parts[2].split(' '), parts[3].split(' ')) |
|
518 elif op == 'unb': |
|
519 doit(parts[3].split(' '), parts[2].split(' ')) |
|
520 line = logfile.readline() |
|
521 else: |
|
522 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, |
|
523 opts.get('remote_head')) |
|
524 localrevs = opts.get('local_head') |
|
525 doit(localrevs, remoterevs) |