Show More
@@ -18,6 +18,7 b' from mercurial.i18n import _' | |||||
18 | from mercurial.node import nullrev |
|
18 | from mercurial.node import nullrev | |
19 | from mercurial import cmdutil, commands, extensions, scmutil |
|
19 | from mercurial import cmdutil, commands, extensions, scmutil | |
20 | from mercurial import hg, util, graphmod, templatekw |
|
20 | from mercurial import hg, util, graphmod, templatekw | |
|
21 | from mercurial import revset as revsetmod | |||
21 |
|
22 | |||
22 | cmdtable = {} |
|
23 | cmdtable = {} | |
23 | command = cmdutil.command(cmdtable) |
|
24 | command = cmdutil.command(cmdtable) | |
@@ -272,16 +273,20 b' def makefilematcher(repo, pats, followfi' | |||||
272 |
|
273 | |||
273 | def revset(repo, pats, opts): |
|
274 | def revset(repo, pats, opts): | |
274 | """Return (expr, filematcher) where expr is a revset string built |
|
275 | """Return (expr, filematcher) where expr is a revset string built | |
275 |
|
|
276 | log options and file patterns, or None. Note that --rev options | |
276 | are not passed filematcher is None. Otherwise it a a callable |
|
277 | are ignored when building expr because we do not know if they are | |
277 | taking a revision number and returning a match objects filtering |
|
278 | proper revsets or legacy expressions like a 'foo-bar' tags. If | |
278 | the files to be detailed when displaying the revision. |
|
279 | --stat or --patch are not passed filematcher is None. Otherwise it | |
|
280 | a a callable taking a revision number and returning a match | |||
|
281 | objects filtering the files to be detailed when displaying the | |||
|
282 | revision. | |||
279 | """ |
|
283 | """ | |
280 | opt2revset = { |
|
284 | opt2revset = { | |
281 | 'follow': ('follow()', None), |
|
285 | 'follow': ('follow()', None), | |
282 | 'follow_first': ('_followfirst()', None), |
|
286 | 'follow_first': ('_followfirst()', None), | |
283 | 'no_merges': ('not merge()', None), |
|
287 | 'no_merges': ('not merge()', None), | |
284 | 'only_merges': ('merge()', None), |
|
288 | 'only_merges': ('merge()', None), | |
|
289 | '_matchfiles': ('_matchfiles(%(val)s)', None), | |||
285 | 'date': ('date(%(val)r)', None), |
|
290 | 'date': ('date(%(val)r)', None), | |
286 | 'branch': ('branch(%(val)r)', ' or '), |
|
291 | 'branch': ('branch(%(val)r)', ' or '), | |
287 | '_patslog': ('filelog(%(val)r)', ' or '), |
|
292 | '_patslog': ('filelog(%(val)r)', ' or '), | |
@@ -290,7 +295,6 b' def revset(repo, pats, opts):' | |||||
290 | 'keyword': ('keyword(%(val)r)', ' or '), |
|
295 | 'keyword': ('keyword(%(val)r)', ' or '), | |
291 | 'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '), |
|
296 | 'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '), | |
292 | 'user': ('user(%(val)r)', ' or '), |
|
297 | 'user': ('user(%(val)r)', ' or '), | |
293 | 'rev': ('%(val)s', ' or '), |
|
|||
294 | } |
|
298 | } | |
295 |
|
299 | |||
296 | opts = dict(opts) |
|
300 | opts = dict(opts) | |
@@ -343,7 +347,7 b' def revset(repo, pats, opts):' | |||||
343 | for p in opts.get('exclude', []): |
|
347 | for p in opts.get('exclude', []): | |
344 | matchargs.append('x:' + p) |
|
348 | matchargs.append('x:' + p) | |
345 | matchargs = ','.join(('%r' % p) for p in matchargs) |
|
349 | matchargs = ','.join(('%r' % p) for p in matchargs) | |
346 |
opts[' |
|
350 | opts['_matchfiles'] = matchargs | |
347 | else: |
|
351 | else: | |
348 | if follow: |
|
352 | if follow: | |
349 | if followfirst: |
|
353 | if followfirst: | |
@@ -385,7 +389,7 b' def revset(repo, pats, opts):' | |||||
385 | if revset: |
|
389 | if revset: | |
386 | revset = '(' + ' and '.join(revset) + ')' |
|
390 | revset = '(' + ' and '.join(revset) + ')' | |
387 | else: |
|
391 | else: | |
388 |
revset = |
|
392 | revset = None | |
389 | return revset, filematcher |
|
393 | return revset, filematcher | |
390 |
|
394 | |||
391 | def generate(ui, dag, displayer, showparents, edgefn, getrenamed=None, |
|
395 | def generate(ui, dag, displayer, showparents, edgefn, getrenamed=None, | |
@@ -431,7 +435,13 b' def graphlog(ui, repo, *pats, **opts):' | |||||
431 | check_unsupported_flags(pats, opts) |
|
435 | check_unsupported_flags(pats, opts) | |
432 |
|
436 | |||
433 | expr, filematcher = revset(repo, pats, opts) |
|
437 | expr, filematcher = revset(repo, pats, opts) | |
434 | revs = sorted(scmutil.revrange(repo, [expr]), reverse=1) |
|
438 | if opts.get('rev'): | |
|
439 | revs = scmutil.revrange(repo, opts['rev']) | |||
|
440 | else: | |||
|
441 | revs = range(len(repo)) | |||
|
442 | if expr: | |||
|
443 | revs = revsetmod.match(repo.ui, expr)(repo, revs) | |||
|
444 | revs = sorted(revs, reverse=1) | |||
435 | limit = cmdutil.loglimit(opts) |
|
445 | limit = cmdutil.loglimit(opts) | |
436 | if limit is not None: |
|
446 | if limit is not None: | |
437 | revs = revs[:limit] |
|
447 | revs = revs[:limit] |
@@ -91,8 +91,12 b' o (0) root' | |||||
91 | > def printrevset(orig, ui, repo, *pats, **opts): |
|
91 | > def printrevset(orig, ui, repo, *pats, **opts): | |
92 | > if opts.get('print_revset'): |
|
92 | > if opts.get('print_revset'): | |
93 | > expr = graphlog.revset(repo, pats, opts)[0] |
|
93 | > expr = graphlog.revset(repo, pats, opts)[0] | |
94 |
> |
|
94 | > if expr: | |
95 | > ui.write(revset.prettyformat(tree), "\n") |
|
95 | > tree = revset.parse(expr)[0] | |
|
96 | > else: | |||
|
97 | > tree = [] | |||
|
98 | > ui.write('%r\n' % (opts.get('rev', []),)) | |||
|
99 | > ui.write(revset.prettyformat(tree) + '\n') | |||
96 | > return 0 |
|
100 | > return 0 | |
97 | > return orig(ui, repo, *pats, **opts) |
|
101 | > return orig(ui, repo, *pats, **opts) | |
98 | > entry = extensions.wrapcommand(commands.table, 'log', printrevset) |
|
102 | > entry = extensions.wrapcommand(commands.table, 'log', printrevset) | |
@@ -1430,19 +1434,8 b' Test log -G options' | |||||
1430 | glog always reorders nodes which explains the difference with log |
|
1434 | glog always reorders nodes which explains the difference with log | |
1431 |
|
1435 | |||
1432 | $ testlog -r 27 -r 25 -r 21 -r 34 -r 32 -r 31 |
|
1436 | $ testlog -r 27 -r 25 -r 21 -r 34 -r 32 -r 31 | |
1433 | (group |
|
1437 | ['27', '25', '21', '34', '32', '31'] | |
1434 | (group |
|
1438 | [] | |
1435 | (or |
|
|||
1436 | (or |
|
|||
1437 | (or |
|
|||
1438 | (or |
|
|||
1439 | (or |
|
|||
1440 | ('symbol', '27') |
|
|||
1441 | ('symbol', '25')) |
|
|||
1442 | ('symbol', '21')) |
|
|||
1443 | ('symbol', '34')) |
|
|||
1444 | ('symbol', '32')) |
|
|||
1445 | ('symbol', '31')))) |
|
|||
1446 | --- log.nodes * (glob) |
|
1439 | --- log.nodes * (glob) | |
1447 | +++ glog.nodes * (glob) |
|
1440 | +++ glog.nodes * (glob) | |
1448 | @@ -1,6 +1,6 @@ |
|
1441 | @@ -1,6 +1,6 @@ | |
@@ -1457,6 +1450,7 b' glog always reorders nodes which explain' | |||||
1457 | +nodetag 21 |
|
1450 | +nodetag 21 | |
1458 | [1] |
|
1451 | [1] | |
1459 | $ testlog -u test -u not-a-user |
|
1452 | $ testlog -u test -u not-a-user | |
|
1453 | [] | |||
1460 | (group |
|
1454 | (group | |
1461 | (group |
|
1455 | (group | |
1462 | (or |
|
1456 | (or | |
@@ -1467,6 +1461,7 b' glog always reorders nodes which explain' | |||||
1467 | ('symbol', 'user') |
|
1461 | ('symbol', 'user') | |
1468 | ('string', 'not-a-user'))))) |
|
1462 | ('string', 'not-a-user'))))) | |
1469 | $ testlog -b not-a-branch |
|
1463 | $ testlog -b not-a-branch | |
|
1464 | [] | |||
1470 | (group |
|
1465 | (group | |
1471 | (group |
|
1466 | (group | |
1472 | (func |
|
1467 | (func | |
@@ -1475,6 +1470,7 b' glog always reorders nodes which explain' | |||||
1475 | abort: unknown revision 'not-a-branch'! |
|
1470 | abort: unknown revision 'not-a-branch'! | |
1476 | abort: unknown revision 'not-a-branch'! |
|
1471 | abort: unknown revision 'not-a-branch'! | |
1477 | $ testlog -b default -b branch --only-branch branch |
|
1472 | $ testlog -b default -b branch --only-branch branch | |
|
1473 | [] | |||
1478 | (group |
|
1474 | (group | |
1479 | (group |
|
1475 | (group | |
1480 | (or |
|
1476 | (or | |
@@ -1489,6 +1485,7 b' glog always reorders nodes which explain' | |||||
1489 | ('symbol', 'branch') |
|
1485 | ('symbol', 'branch') | |
1490 | ('string', 'branch'))))) |
|
1486 | ('string', 'branch'))))) | |
1491 | $ testlog -k expand -k merge |
|
1487 | $ testlog -k expand -k merge | |
|
1488 | [] | |||
1492 | (group |
|
1489 | (group | |
1493 | (group |
|
1490 | (group | |
1494 | (or |
|
1491 | (or | |
@@ -1499,17 +1496,20 b' glog always reorders nodes which explain' | |||||
1499 | ('symbol', 'keyword') |
|
1496 | ('symbol', 'keyword') | |
1500 | ('string', 'merge'))))) |
|
1497 | ('string', 'merge'))))) | |
1501 | $ testlog --only-merges |
|
1498 | $ testlog --only-merges | |
|
1499 | [] | |||
1502 | (group |
|
1500 | (group | |
1503 | (func |
|
1501 | (func | |
1504 | ('symbol', 'merge') |
|
1502 | ('symbol', 'merge') | |
1505 | None)) |
|
1503 | None)) | |
1506 | $ testlog --no-merges |
|
1504 | $ testlog --no-merges | |
|
1505 | [] | |||
1507 | (group |
|
1506 | (group | |
1508 | (not |
|
1507 | (not | |
1509 | (func |
|
1508 | (func | |
1510 | ('symbol', 'merge') |
|
1509 | ('symbol', 'merge') | |
1511 | None))) |
|
1510 | None))) | |
1512 | $ testlog --date '2 0 to 4 0' |
|
1511 | $ testlog --date '2 0 to 4 0' | |
|
1512 | [] | |||
1513 | (group |
|
1513 | (group | |
1514 | (func |
|
1514 | (func | |
1515 | ('symbol', 'date') |
|
1515 | ('symbol', 'date') | |
@@ -1518,6 +1518,7 b' glog always reorders nodes which explain' | |||||
1518 | abort: invalid date: 'brace ) in a date' |
|
1518 | abort: invalid date: 'brace ) in a date' | |
1519 | [255] |
|
1519 | [255] | |
1520 | $ testlog --prune 31 --prune 32 |
|
1520 | $ testlog --prune 31 --prune 32 | |
|
1521 | [] | |||
1521 | (group |
|
1522 | (group | |
1522 | (group |
|
1523 | (group | |
1523 | (and |
|
1524 | (and | |
@@ -1577,12 +1578,14 b' have 2 filelog topological heads in a li' | |||||
1577 |
|
1578 | |||
1578 |
|
1579 | |||
1579 | $ testlog a |
|
1580 | $ testlog a | |
|
1581 | [] | |||
1580 | (group |
|
1582 | (group | |
1581 | (group |
|
1583 | (group | |
1582 | (func |
|
1584 | (func | |
1583 | ('symbol', 'filelog') |
|
1585 | ('symbol', 'filelog') | |
1584 | ('string', 'a')))) |
|
1586 | ('string', 'a')))) | |
1585 | $ testlog a b |
|
1587 | $ testlog a b | |
|
1588 | [] | |||
1586 | (group |
|
1589 | (group | |
1587 | (group |
|
1590 | (group | |
1588 | (or |
|
1591 | (or | |
@@ -1596,36 +1599,36 b' have 2 filelog topological heads in a li' | |||||
1596 | Test falling back to slow path for non-existing files |
|
1599 | Test falling back to slow path for non-existing files | |
1597 |
|
1600 | |||
1598 | $ testlog a c |
|
1601 | $ testlog a c | |
|
1602 | [] | |||
1599 | (group |
|
1603 | (group | |
1600 |
( |
|
1604 | (func | |
1601 | (func |
|
1605 | ('symbol', '_matchfiles') | |
1602 | ('symbol', '_matchfiles') |
|
1606 | (list | |
1603 | (list |
|
1607 | (list | |
1604 |
( |
|
1608 | ('string', 'r:') | |
1605 |
|
|
1609 | ('string', 'p:a')) | |
1606 |
|
|
1610 | ('string', 'p:c')))) | |
1607 | ('string', 'p:c'))))) |
|
|||
1608 |
|
1611 | |||
1609 | Test multiple --include/--exclude/paths |
|
1612 | Test multiple --include/--exclude/paths | |
1610 |
|
1613 | |||
1611 | $ testlog --include a --include e --exclude b --exclude e a e |
|
1614 | $ testlog --include a --include e --exclude b --exclude e a e | |
|
1615 | [] | |||
1612 | (group |
|
1616 | (group | |
1613 |
( |
|
1617 | (func | |
1614 | (func |
|
1618 | ('symbol', '_matchfiles') | |
1615 | ('symbol', '_matchfiles') |
|
1619 | (list | |
1616 | (list |
|
1620 | (list | |
1617 | (list |
|
1621 | (list | |
1618 | (list |
|
1622 | (list | |
1619 | (list |
|
1623 | (list | |
1620 | (list |
|
1624 | (list | |
1621 |
( |
|
1625 | ('string', 'r:') | |
1622 |
|
|
1626 | ('string', 'p:a')) | |
1623 |
|
|
1627 | ('string', 'p:e')) | |
1624 |
|
|
1628 | ('string', 'i:a')) | |
1625 |
|
|
1629 | ('string', 'i:e')) | |
1626 |
|
|
1630 | ('string', 'x:b')) | |
1627 |
|
|
1631 | ('string', 'x:e')))) | |
1628 | ('string', 'x:e'))))) |
|
|||
1629 |
|
1632 | |||
1630 | Test glob expansion of pats |
|
1633 | Test glob expansion of pats | |
1631 |
|
1634 | |||
@@ -1636,6 +1639,7 b' Test glob expansion of pats' | |||||
1636 | > else |
|
1639 | > else | |
1637 | > testlog a*; |
|
1640 | > testlog a*; | |
1638 | > fi; |
|
1641 | > fi; | |
|
1642 | [] | |||
1639 |
|
|
1643 | (group | |
1640 | (group |
|
1644 | (group | |
1641 | (func |
|
1645 | (func | |
@@ -1667,6 +1671,7 b' Test --follow on a single rename' | |||||
1667 |
|
1671 | |||
1668 | $ hg up -q 2 |
|
1672 | $ hg up -q 2 | |
1669 | $ testlog -f a |
|
1673 | $ testlog -f a | |
|
1674 | [] | |||
1670 | (group |
|
1675 | (group | |
1671 | (group |
|
1676 | (group | |
1672 | (func |
|
1677 | (func | |
@@ -1677,6 +1682,7 b' Test --follow and multiple renames' | |||||
1677 |
|
1682 | |||
1678 | $ hg up -q tip |
|
1683 | $ hg up -q tip | |
1679 | $ testlog -f e |
|
1684 | $ testlog -f e | |
|
1685 | [] | |||
1680 | (group |
|
1686 | (group | |
1681 | (group |
|
1687 | (group | |
1682 | (func |
|
1688 | (func | |
@@ -1687,6 +1693,7 b' Test --follow and multiple filelog heads' | |||||
1687 |
|
1693 | |||
1688 | $ hg up -q 2 |
|
1694 | $ hg up -q 2 | |
1689 | $ testlog -f g |
|
1695 | $ testlog -f g | |
|
1696 | [] | |||
1690 | (group |
|
1697 | (group | |
1691 | (group |
|
1698 | (group | |
1692 | (func |
|
1699 | (func | |
@@ -1698,6 +1705,7 b' Test --follow and multiple filelog heads' | |||||
1698 | nodetag 0 |
|
1705 | nodetag 0 | |
1699 | $ hg up -q tip |
|
1706 | $ hg up -q tip | |
1700 | $ testlog -f g |
|
1707 | $ testlog -f g | |
|
1708 | [] | |||
1701 | (group |
|
1709 | (group | |
1702 | (group |
|
1710 | (group | |
1703 | (func |
|
1711 | (func | |
@@ -1711,6 +1719,7 b' Test --follow and multiple filelog heads' | |||||
1711 | Test --follow and multiple files |
|
1719 | Test --follow and multiple files | |
1712 |
|
1720 | |||
1713 | $ testlog -f g e |
|
1721 | $ testlog -f g e | |
|
1722 | [] | |||
1714 | (group |
|
1723 | (group | |
1715 | (group |
|
1724 | (group | |
1716 | (or |
|
1725 | (or | |
@@ -1739,6 +1748,7 b' Test --follow-first' | |||||
1739 | $ echo merge > e |
|
1748 | $ echo merge > e | |
1740 | $ hg ci -m "merge 5 and 4" |
|
1749 | $ hg ci -m "merge 5 and 4" | |
1741 | $ testlog --follow-first |
|
1750 | $ testlog --follow-first | |
|
1751 | [] | |||
1742 | (group |
|
1752 | (group | |
1743 | (func |
|
1753 | (func | |
1744 | ('symbol', '_followfirst') |
|
1754 | ('symbol', '_followfirst') | |
@@ -1747,6 +1757,7 b' Test --follow-first' | |||||
1747 | Cannot compare with log --follow-first FILE as it never worked |
|
1757 | Cannot compare with log --follow-first FILE as it never worked | |
1748 |
|
1758 | |||
1749 | $ hg log -G --print-revset --follow-first e |
|
1759 | $ hg log -G --print-revset --follow-first e | |
|
1760 | [] | |||
1750 | (group |
|
1761 | (group | |
1751 | (group |
|
1762 | (group | |
1752 | (func |
|
1763 | (func | |
@@ -1780,47 +1791,38 b' Test "set:..." and parent revision' | |||||
1780 |
|
1791 | |||
1781 | $ hg up -q 4 |
|
1792 | $ hg up -q 4 | |
1782 | $ testlog "set:copied()" |
|
1793 | $ testlog "set:copied()" | |
1783 | (group |
|
1794 | [] | |
1784 | (group |
|
|||
1785 | (func |
|
|||
1786 | ('symbol', '_matchfiles') |
|
|||
1787 | (list |
|
|||
1788 | ('string', 'r:') |
|
|||
1789 | ('string', 'p:set:copied()'))))) |
|
|||
1790 | $ testlog --include "set:copied()" |
|
|||
1791 | (group |
|
1795 | (group | |
1792 |
( |
|
1796 | (func | |
1793 | (func |
|
1797 | ('symbol', '_matchfiles') | |
1794 | ('symbol', '_matchfiles') |
|
1798 | (list | |
1795 | (list |
|
1799 | ('string', 'r:') | |
1796 |
|
|
1800 | ('string', 'p:set:copied()')))) | |
1797 | ('string', 'i:set:copied()'))))) |
|
1801 | $ testlog --include "set:copied()" | |
1798 | $ testlog -r "sort(file('set:copied()'), -rev)" |
|
1802 | [] | |
1799 | (group |
|
1803 | (group | |
1800 |
( |
|
1804 | (func | |
1801 | (func |
|
1805 | ('symbol', '_matchfiles') | |
1802 | ('symbol', 'sort') |
|
1806 | (list | |
1803 | (list |
|
1807 | ('string', 'r:') | |
1804 | (func |
|
1808 | ('string', 'i:set:copied()')))) | |
1805 | ('symbol', 'file') |
|
1809 | $ testlog -r "sort(file('set:copied()'), -rev)" | |
1806 | ('string', 'set:copied()')) |
|
1810 | ["sort(file('set:copied()'), -rev)"] | |
1807 | (negate |
|
1811 | [] | |
1808 | ('symbol', 'rev')))))) |
|
|||
1809 |
|
1812 | |||
1810 | Test --removed |
|
1813 | Test --removed | |
1811 |
|
1814 | |||
1812 | $ testlog --removed |
|
1815 | $ testlog --removed | |
1813 | (func |
|
1816 | [] | |
1814 | ('symbol', 'all') |
|
1817 | [] | |
1815 | None) |
|
|||
1816 | $ testlog --removed a |
|
1818 | $ testlog --removed a | |
|
1819 | [] | |||
1817 | (group |
|
1820 | (group | |
1818 |
( |
|
1821 | (func | |
1819 | (func |
|
1822 | ('symbol', '_matchfiles') | |
1820 | ('symbol', '_matchfiles') |
|
1823 | (list | |
1821 | (list |
|
1824 | ('string', 'r:') | |
1822 |
|
|
1825 | ('string', 'p:a')))) | |
1823 | ('string', 'p:a'))))) |
|
|||
1824 | $ testlog --removed --follow a |
|
1826 | $ testlog --removed --follow a | |
1825 | abort: can only follow copies/renames for explicit filenames |
|
1827 | abort: can only follow copies/renames for explicit filenames | |
1826 | abort: can only follow copies/renames for explicit filenames |
|
1828 | abort: can only follow copies/renames for explicit filenames | |
@@ -1921,3 +1923,10 b' Test --patch and --stat with --follow an' | |||||
1921 | | | @@ -0,0 +1,1 @@ |
|
1923 | | | @@ -0,0 +1,1 @@ | |
1922 | | | +ee |
|
1924 | | | +ee | |
1923 | | | |
|
1925 | | | | |
|
1926 | ||||
|
1927 | Test old-style --rev | |||
|
1928 | ||||
|
1929 | $ hg tag 'foo-bar' | |||
|
1930 | $ testlog -r 'foo-bar' | |||
|
1931 | ['foo-bar'] | |||
|
1932 | [] |
General Comments 0
You need to be logged in to leave comments.
Login now