comparison tests/test-glog.t @ 16316:0f1e621d3d3b

graphlog: handle old-style --rev values --rev options cannot be merged into a single revset because we do not know if they are valid revset or old-style revision specifications, like 'foo-bar' tags. Instead, a base revision set is generated with scmutil.revrange() then filtered with the revset built from log options. It also fixes incorrect or hostile expressions passed in --rev.
author Patrick Mezard <patrick@mezard.eu>
date Thu, 29 Mar 2012 22:42:03 +0200
parents f89284d72a61
children 17deb6bbfbab
comparison
equal deleted inserted replaced
16315:f89284d72a61 16316:0f1e621d3d3b
89 > 89 >
90 > def uisetup(ui): 90 > def uisetup(ui):
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 > tree = revset.parse(expr)[0] 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)
99 > entry[1].append(('', 'print-revset', False, 103 > entry[1].append(('', 'print-revset', False,
100 > 'print generated revset and exit (DEPRECATED)')) 104 > 'print generated revset and exit (DEPRECATED)'))
1428 > } 1432 > }
1429 1433
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 @@
1449 -nodetag 27 1442 -nodetag 27
1450 -nodetag 25 1443 -nodetag 25
1455 +nodetag 27 1448 +nodetag 27
1456 +nodetag 25 1449 +nodetag 25
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
1463 (func 1457 (func
1464 ('symbol', 'user') 1458 ('symbol', 'user')
1465 ('string', 'test')) 1459 ('string', 'test'))
1466 (func 1460 (func
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
1473 ('symbol', 'branch') 1468 ('symbol', 'branch')
1474 ('string', 'not-a-branch')))) 1469 ('string', 'not-a-branch'))))
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
1481 (or 1477 (or
1482 (func 1478 (func
1487 ('string', 'branch'))) 1483 ('string', 'branch')))
1488 (func 1484 (func
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
1495 (func 1492 (func
1496 ('symbol', 'keyword') 1493 ('symbol', 'keyword')
1497 ('string', 'expand')) 1494 ('string', 'expand'))
1498 (func 1495 (func
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')
1516 ('string', '2 0 to 4 0'))) 1516 ('string', '2 0 to 4 0')))
1517 $ hg log -G -d 'brace ) in a date' 1517 $ hg log -G -d 'brace ) in a date'
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
1524 (not 1525 (not
1525 (group 1526 (group
1575 | 1576 |
1576 o (0) add a 1577 o (0) add a
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
1589 (func 1592 (func
1590 ('symbol', 'filelog') 1593 ('symbol', 'filelog')
1594 ('string', 'b'))))) 1597 ('string', 'b')))))
1595 1598
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
1599 (group 1602 []
1600 (group 1603 (group
1601 (func 1604 (func
1602 ('symbol', '_matchfiles') 1605 ('symbol', '_matchfiles')
1606 (list
1603 (list 1607 (list
1604 (list 1608 ('string', 'r:')
1605 ('string', 'r:') 1609 ('string', 'p:a'))
1606 ('string', 'p:a')) 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
1612 (group 1615 []
1613 (group 1616 (group
1614 (func 1617 (func
1615 ('symbol', '_matchfiles') 1618 ('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 (list 1625 ('string', 'r:')
1622 ('string', 'r:') 1626 ('string', 'p:a'))
1623 ('string', 'p:a')) 1627 ('string', 'p:e'))
1624 ('string', 'p:e')) 1628 ('string', 'i:a'))
1625 ('string', 'i:a')) 1629 ('string', 'i:e'))
1626 ('string', 'i:e')) 1630 ('string', 'x:b'))
1627 ('string', 'x:b')) 1631 ('string', 'x:e'))))
1628 ('string', 'x:e')))))
1629 1632
1630 Test glob expansion of pats 1633 Test glob expansion of pats
1631 1634
1632 $ expandglobs=`python -c "import mercurial.util; \ 1635 $ expandglobs=`python -c "import mercurial.util; \
1633 > print mercurial.util.expandglobs and 'true' or 'false'"` 1636 > print mercurial.util.expandglobs and 'true' or 'false'"`
1634 $ if [ $expandglobs = "true" ]; then 1637 $ if [ $expandglobs = "true" ]; then
1635 > testlog 'a*'; 1638 > testlog 'a*';
1636 > else 1639 > else
1637 > testlog a*; 1640 > testlog a*;
1638 > fi; 1641 > fi;
1642 []
1639 (group 1643 (group
1640 (group 1644 (group
1641 (func 1645 (func
1642 ('symbol', 'filelog') 1646 ('symbol', 'filelog')
1643 ('string', 'aa')))) 1647 ('string', 'aa'))))
1665 1669
1666 Test --follow on a single rename 1670 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
1673 ('symbol', 'follow') 1678 ('symbol', 'follow')
1674 ('string', 'a')))) 1679 ('string', 'a'))))
1675 1680
1676 Test --follow and multiple renames 1681 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
1683 ('symbol', 'follow') 1689 ('symbol', 'follow')
1684 ('string', 'e')))) 1690 ('string', 'e'))))
1685 1691
1686 Test --follow and multiple filelog heads 1692 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
1693 ('symbol', 'follow') 1700 ('symbol', 'follow')
1694 ('string', 'g')))) 1701 ('string', 'g'))))
1696 nodetag 2 1703 nodetag 2
1697 nodetag 1 1704 nodetag 1
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
1704 ('symbol', 'follow') 1712 ('symbol', 'follow')
1705 ('string', 'g')))) 1713 ('string', 'g'))))
1709 nodetag 0 1717 nodetag 0
1710 1718
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
1717 (func 1726 (func
1718 ('symbol', 'follow') 1727 ('symbol', 'follow')
1737 0 files updated, 1 files merged, 1 files removed, 0 files unresolved 1746 0 files updated, 1 files merged, 1 files removed, 0 files unresolved
1738 (branch merge, don't forget to commit) 1747 (branch merge, don't forget to commit)
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')
1745 None)) 1755 None))
1746 1756
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
1753 ('symbol', '_followfirst') 1764 ('symbol', '_followfirst')
1754 ('string', 'e')))) 1765 ('string', 'e'))))
1778 1789
1779 Test "set:..." and parent revision 1790 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 1795 (group
1785 (func 1796 (func
1786 ('symbol', '_matchfiles') 1797 ('symbol', '_matchfiles')
1787 (list 1798 (list
1788 ('string', 'r:') 1799 ('string', 'r:')
1789 ('string', 'p:set:copied()'))))) 1800 ('string', 'p:set:copied()'))))
1790 $ testlog --include "set:copied()" 1801 $ testlog --include "set:copied()"
1791 (group 1802 []
1792 (group 1803 (group
1793 (func 1804 (func
1794 ('symbol', '_matchfiles') 1805 ('symbol', '_matchfiles')
1795 (list 1806 (list
1796 ('string', 'r:') 1807 ('string', 'r:')
1797 ('string', 'i:set:copied()'))))) 1808 ('string', 'i:set:copied()'))))
1798 $ testlog -r "sort(file('set:copied()'), -rev)" 1809 $ testlog -r "sort(file('set:copied()'), -rev)"
1799 (group 1810 ["sort(file('set:copied()'), -rev)"]
1800 (group 1811 []
1801 (func
1802 ('symbol', 'sort')
1803 (list
1804 (func
1805 ('symbol', 'file')
1806 ('string', 'set:copied()'))
1807 (negate
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
1817 (group 1819 []
1818 (group 1820 (group
1819 (func 1821 (func
1820 ('symbol', '_matchfiles') 1822 ('symbol', '_matchfiles')
1821 (list 1823 (list
1822 ('string', 'r:') 1824 ('string', 'r:')
1823 ('string', 'p:a'))))) 1825 ('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
1827 abort: can only follow copies/renames for explicit filenames 1829 abort: can only follow copies/renames for explicit filenames
1828 1830
1919 | | --- /dev/null 1921 | | --- /dev/null
1920 | | +++ b/e 1922 | | +++ b/e
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 []