Mercurial > hg
comparison mercurial/cmdutil.py @ 18172:e6c5e0092469
cmdutil: make getgraphlogrevs limit-aware
For a repository with over 400,000 changesets, this speeds up graphlog with a
small limit by around 0.05 seconds (~50%).
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 28 Dec 2012 16:25:12 -0800 |
parents | 9d350f2d9458 |
children | 2c1276825e93 |
comparison
equal
deleted
inserted
replaced
18171:9d350f2d9458 | 18172:e6c5e0092469 |
---|---|
1399 callable taking a revision number and returning a match objects | 1399 callable taking a revision number and returning a match objects |
1400 filtering the files to be detailed when displaying the revision. | 1400 filtering the files to be detailed when displaying the revision. |
1401 """ | 1401 """ |
1402 if not len(repo): | 1402 if not len(repo): |
1403 return [], None, None | 1403 return [], None, None |
1404 limit = loglimit(opts) | |
1404 # Default --rev value depends on --follow but --follow behaviour | 1405 # Default --rev value depends on --follow but --follow behaviour |
1405 # depends on revisions resolved from --rev... | 1406 # depends on revisions resolved from --rev... |
1406 follow = opts.get('follow') or opts.get('follow_first') | 1407 follow = opts.get('follow') or opts.get('follow_first') |
1407 possiblyunsorted = False # whether revs might need sorting | 1408 possiblyunsorted = False # whether revs might need sorting |
1408 if opts.get('rev'): | 1409 if opts.get('rev'): |
1433 revs.sort(reverse=True) | 1434 revs.sort(reverse=True) |
1434 if not opts.get('hidden'): | 1435 if not opts.get('hidden'): |
1435 # --hidden is still experimental and not worth a dedicated revset | 1436 # --hidden is still experimental and not worth a dedicated revset |
1436 # yet. Fortunately, filtering revision number is fast. | 1437 # yet. Fortunately, filtering revision number is fast. |
1437 hiddenrevs = repo.hiddenrevs | 1438 hiddenrevs = repo.hiddenrevs |
1438 revs = [r for r in revs if r not in hiddenrevs] | 1439 nrevs = [] |
1440 taken = 0 | |
1441 if limit is not None: | |
1442 for i in xrange(len(revs)): | |
1443 if taken >= limit: | |
1444 break | |
1445 r = revs[i] | |
1446 if r not in hiddenrevs: | |
1447 nrevs.append(r) | |
1448 taken += 1 | |
1449 revs = nrevs | |
1450 else: | |
1451 revs = [r for r in revs if r not in hiddenrevs] | |
1452 elif limit is not None: | |
1453 revs = revs[:limit] | |
1454 | |
1439 return revs, expr, filematcher | 1455 return revs, expr, filematcher |
1440 | 1456 |
1441 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None, | 1457 def displaygraph(ui, dag, displayer, showparents, edgefn, getrenamed=None, |
1442 filematcher=None): | 1458 filematcher=None): |
1443 seen, state = [], graphmod.asciistate() | 1459 seen, state = [], graphmod.asciistate() |
1468 displayer.close() | 1484 displayer.close() |
1469 | 1485 |
1470 def graphlog(ui, repo, *pats, **opts): | 1486 def graphlog(ui, repo, *pats, **opts): |
1471 # Parameters are identical to log command ones | 1487 # Parameters are identical to log command ones |
1472 revs, expr, filematcher = getgraphlogrevs(repo, pats, opts) | 1488 revs, expr, filematcher = getgraphlogrevs(repo, pats, opts) |
1473 limit = loglimit(opts) | |
1474 if limit is not None: | |
1475 revs = revs[:limit] | |
1476 revdag = graphmod.dagwalker(repo, revs) | 1489 revdag = graphmod.dagwalker(repo, revs) |
1477 | 1490 |
1478 getrenamed = None | 1491 getrenamed = None |
1479 if opts.get('copies'): | 1492 if opts.get('copies'): |
1480 endrev = None | 1493 endrev = None |