Mercurial > hg
comparison mercurial/commands.py @ 14164:cb98fed52495
discovery: add new set-based discovery
Adds a new discovery method based on repeatedly sampling the still
undecided subset of the local node graph to determine the set of nodes
common to both the client and the server.
For small differences between client and server, it uses about the same
or slightly fewer roundtrips than the old tree-based discovery. For
larger differences, it typically reduces the number of roundtrips
drastically (from 150 to 4, for instance).
The old discovery code now lives in treediscovery.py, the new code is
in setdiscovery.py.
Still missing is a hook for extensions to contribute nodes to the
initial sample. For instance, Augie's remotebranches could contribute
the last known state of the server's heads.
Credits for the actual sampler and computing common heads instead of
bases go to Benoit Boissinot.
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Mon, 02 May 2011 19:21:30 +0200 |
parents | 38184a72d793 |
children | 135e244776f0 |
comparison
equal
deleted
inserted
replaced
14163:38184a72d793 | 14164:cb98fed52495 |
---|---|
13 import patch, help, url, encoding, templatekw, discovery | 13 import patch, help, url, encoding, templatekw, discovery |
14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server | 14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server |
15 import merge as mergemod | 15 import merge as mergemod |
16 import minirst, revset, templatefilters | 16 import minirst, revset, templatefilters |
17 import dagparser, context, simplemerge | 17 import dagparser, context, simplemerge |
18 import random, setdiscovery, treediscovery, dagutil | |
18 | 19 |
19 # Commands start here, listed alphabetically | 20 # Commands start here, listed alphabetically |
20 | 21 |
21 def add(ui, repo, *pats, **opts): | 22 def add(ui, repo, *pats, **opts): |
22 """add the specified files on the next commit | 23 """add the specified files on the next commit |
1468 ignore = repo.dirstate._ignore | 1469 ignore = repo.dirstate._ignore |
1469 if hasattr(ignore, 'includepat'): | 1470 if hasattr(ignore, 'includepat'): |
1470 ui.write("%s\n" % ignore.includepat) | 1471 ui.write("%s\n" % ignore.includepat) |
1471 else: | 1472 else: |
1472 raise util.Abort(_("no ignore patterns found")) | 1473 raise util.Abort(_("no ignore patterns found")) |
1474 | |
1475 def debugdiscovery(ui, repo, remoteurl="default", **opts): | |
1476 """runs the changeset discovery protocol in isolation""" | |
1477 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), opts.get('branch')) | |
1478 remote = hg.repository(hg.remoteui(repo, opts), remoteurl) | |
1479 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl)) | |
1480 | |
1481 # make sure tests are repeatable | |
1482 random.seed(12323) | |
1483 | |
1484 def doit(localheads, remoteheads): | |
1485 if opts.get('old'): | |
1486 if localheads: | |
1487 raise util.Abort('cannot use localheads with old style discovery') | |
1488 common, _in, hds = treediscovery.findcommonincoming(repo, remote, | |
1489 force=True) | |
1490 common = set(common) | |
1491 if not opts.get('nonheads'): | |
1492 ui.write("unpruned common: %s\n" % " ".join([short(n) | |
1493 for n in common])) | |
1494 dag = dagutil.revlogdag(repo.changelog) | |
1495 all = dag.ancestorset(dag.internalizeall(common)) | |
1496 common = dag.externalizeall(dag.headsetofconnecteds(all)) | |
1497 else: | |
1498 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote) | |
1499 common = set(common) | |
1500 rheads = set(hds) | |
1501 lheads = set(repo.heads()) | |
1502 ui.write("common heads: %s\n" % " ".join([short(n) for n in common])) | |
1503 if lheads <= common: | |
1504 ui.write("local is subset\n") | |
1505 elif rheads <= common: | |
1506 ui.write("remote is subset\n") | |
1507 | |
1508 serverlogs = opts.get('serverlog') | |
1509 if serverlogs: | |
1510 for filename in serverlogs: | |
1511 logfile = open(filename, 'r') | |
1512 try: | |
1513 line = logfile.readline() | |
1514 while line: | |
1515 parts = line.strip().split(';') | |
1516 op = parts[1] | |
1517 if op == 'cg': | |
1518 pass | |
1519 elif op == 'cgss': | |
1520 doit(parts[2].split(' '), parts[3].split(' ')) | |
1521 elif op == 'unb': | |
1522 doit(parts[3].split(' '), parts[2].split(' ')) | |
1523 line = logfile.readline() | |
1524 finally: | |
1525 logfile.close() | |
1526 | |
1527 else: | |
1528 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches, | |
1529 opts.get('remote_head')) | |
1530 localrevs = opts.get('local_head') | |
1531 doit(localrevs, remoterevs) | |
1532 | |
1473 | 1533 |
1474 def debugindex(ui, repo, file_, **opts): | 1534 def debugindex(ui, repo, file_, **opts): |
1475 """dump the contents of an index file""" | 1535 """dump the contents of an index file""" |
1476 r = None | 1536 r = None |
1477 if repo: | 1537 if repo: |
4511 "debugdate": | 4571 "debugdate": |
4512 (debugdate, | 4572 (debugdate, |
4513 [('e', 'extended', None, _('try extended date formats'))], | 4573 [('e', 'extended', None, _('try extended date formats'))], |
4514 _('[-e] DATE [RANGE]')), | 4574 _('[-e] DATE [RANGE]')), |
4515 "debugdata": (debugdata, [], _('FILE REV')), | 4575 "debugdata": (debugdata, [], _('FILE REV')), |
4576 "debugdiscovery": (debugdiscovery, | |
4577 [('', 'old', None, | |
4578 _('use old-style discovery')), | |
4579 ('', 'nonheads', None, | |
4580 _('use old-style discovery with non-heads included')), | |
4581 ] + remoteopts, | |
4582 _('[-l REV] [-r REV] [-b BRANCH]...' | |
4583 ' [OTHER]')), | |
4516 "debugfsinfo": (debugfsinfo, [], _('[PATH]')), | 4584 "debugfsinfo": (debugfsinfo, [], _('[PATH]')), |
4517 "debuggetbundle": | 4585 "debuggetbundle": |
4518 (debuggetbundle, | 4586 (debuggetbundle, |
4519 [('H', 'head', [], _('id of head node'), _('ID')), | 4587 [('H', 'head', [], _('id of head node'), _('ID')), |
4520 ('C', 'common', [], _('id of common node'), _('ID')), | 4588 ('C', 'common', [], _('id of common node'), _('ID')), |