comparison tests/test-glog.t @ 16315:f89284d72a61

test-glog: pretty print revset expressions
author Patrick Mezard <patrick@mezard.eu>
date Thu, 29 Mar 2012 17:13:23 +0200
parents af3e67354beb
children 0f1e621d3d3b
comparison
equal deleted inserted replaced
16314:16ec050490fc 16315:f89284d72a61
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 > tree = revset.parse(expr)[0]
95 > ui.write(tree, "\n") 95 > ui.write(revset.prettyformat(tree), "\n")
96 > return 0 96 > return 0
97 > return orig(ui, repo, *pats, **opts) 97 > return orig(ui, repo, *pats, **opts)
98 > entry = extensions.wrapcommand(commands.table, 'log', printrevset) 98 > entry = extensions.wrapcommand(commands.table, 'log', printrevset)
99 > entry[1].append(('', 'print-revset', False, 99 > entry[1].append(('', 'print-revset', False,
100 > 'print generated revset and exit (DEPRECATED)')) 100 > 'print generated revset and exit (DEPRECATED)'))
1428 > } 1428 > }
1429 1429
1430 glog always reorders nodes which explains the difference with log 1430 glog always reorders nodes which explains the difference with log
1431 1431
1432 $ testlog -r 27 -r 25 -r 21 -r 34 -r 32 -r 31 1432 $ testlog -r 27 -r 25 -r 21 -r 34 -r 32 -r 31
1433 ('group', ('group', ('or', ('or', ('or', ('or', ('or', ('symbol', '27'), ('symbol', '25')), ('symbol', '21')), ('symbol', '34')), ('symbol', '32')), ('symbol', '31')))) 1433 (group
1434 (group
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'))))
1434 --- log.nodes * (glob) 1446 --- log.nodes * (glob)
1435 +++ glog.nodes * (glob) 1447 +++ glog.nodes * (glob)
1436 @@ -1,6 +1,6 @@ 1448 @@ -1,6 +1,6 @@
1437 -nodetag 27 1449 -nodetag 27
1438 -nodetag 25 1450 -nodetag 25
1443 +nodetag 27 1455 +nodetag 27
1444 +nodetag 25 1456 +nodetag 25
1445 +nodetag 21 1457 +nodetag 21
1446 [1] 1458 [1]
1447 $ testlog -u test -u not-a-user 1459 $ testlog -u test -u not-a-user
1448 ('group', ('group', ('or', ('func', ('symbol', 'user'), ('string', 'test')), ('func', ('symbol', 'user'), ('string', 'not-a-user'))))) 1460 (group
1461 (group
1462 (or
1463 (func
1464 ('symbol', 'user')
1465 ('string', 'test'))
1466 (func
1467 ('symbol', 'user')
1468 ('string', 'not-a-user')))))
1449 $ testlog -b not-a-branch 1469 $ testlog -b not-a-branch
1450 ('group', ('group', ('func', ('symbol', 'branch'), ('string', 'not-a-branch')))) 1470 (group
1471 (group
1472 (func
1473 ('symbol', 'branch')
1474 ('string', 'not-a-branch'))))
1451 abort: unknown revision 'not-a-branch'! 1475 abort: unknown revision 'not-a-branch'!
1452 abort: unknown revision 'not-a-branch'! 1476 abort: unknown revision 'not-a-branch'!
1453 $ testlog -b default -b branch --only-branch branch 1477 $ testlog -b default -b branch --only-branch branch
1454 ('group', ('group', ('or', ('or', ('func', ('symbol', 'branch'), ('string', 'default')), ('func', ('symbol', 'branch'), ('string', 'branch'))), ('func', ('symbol', 'branch'), ('string', 'branch'))))) 1478 (group
1479 (group
1480 (or
1481 (or
1482 (func
1483 ('symbol', 'branch')
1484 ('string', 'default'))
1485 (func
1486 ('symbol', 'branch')
1487 ('string', 'branch')))
1488 (func
1489 ('symbol', 'branch')
1490 ('string', 'branch')))))
1455 $ testlog -k expand -k merge 1491 $ testlog -k expand -k merge
1456 ('group', ('group', ('or', ('func', ('symbol', 'keyword'), ('string', 'expand')), ('func', ('symbol', 'keyword'), ('string', 'merge'))))) 1492 (group
1493 (group
1494 (or
1495 (func
1496 ('symbol', 'keyword')
1497 ('string', 'expand'))
1498 (func
1499 ('symbol', 'keyword')
1500 ('string', 'merge')))))
1457 $ testlog --only-merges 1501 $ testlog --only-merges
1458 ('group', ('func', ('symbol', 'merge'), None)) 1502 (group
1503 (func
1504 ('symbol', 'merge')
1505 None))
1459 $ testlog --no-merges 1506 $ testlog --no-merges
1460 ('group', ('not', ('func', ('symbol', 'merge'), None))) 1507 (group
1508 (not
1509 (func
1510 ('symbol', 'merge')
1511 None)))
1461 $ testlog --date '2 0 to 4 0' 1512 $ testlog --date '2 0 to 4 0'
1462 ('group', ('func', ('symbol', 'date'), ('string', '2 0 to 4 0'))) 1513 (group
1514 (func
1515 ('symbol', 'date')
1516 ('string', '2 0 to 4 0')))
1463 $ hg log -G -d 'brace ) in a date' 1517 $ hg log -G -d 'brace ) in a date'
1464 abort: invalid date: 'brace ) in a date' 1518 abort: invalid date: 'brace ) in a date'
1465 [255] 1519 [255]
1466 $ testlog --prune 31 --prune 32 1520 $ testlog --prune 31 --prune 32
1467 ('group', ('group', ('and', ('not', ('group', ('or', ('string', '31'), ('func', ('symbol', 'ancestors'), ('string', '31'))))), ('not', ('group', ('or', ('string', '32'), ('func', ('symbol', 'ancestors'), ('string', '32')))))))) 1521 (group
1522 (group
1523 (and
1524 (not
1525 (group
1526 (or
1527 ('string', '31')
1528 (func
1529 ('symbol', 'ancestors')
1530 ('string', '31')))))
1531 (not
1532 (group
1533 (or
1534 ('string', '32')
1535 (func
1536 ('symbol', 'ancestors')
1537 ('string', '32'))))))))
1468 1538
1469 Dedicated repo for --follow and paths filtering. The g is crafted to 1539 Dedicated repo for --follow and paths filtering. The g is crafted to
1470 have 2 filelog topological heads in a linear changeset graph. 1540 have 2 filelog topological heads in a linear changeset graph.
1471 1541
1472 $ cd .. 1542 $ cd ..
1505 | 1575 |
1506 o (0) add a 1576 o (0) add a
1507 1577
1508 1578
1509 $ testlog a 1579 $ testlog a
1510 ('group', ('group', ('func', ('symbol', 'filelog'), ('string', 'a')))) 1580 (group
1581 (group
1582 (func
1583 ('symbol', 'filelog')
1584 ('string', 'a'))))
1511 $ testlog a b 1585 $ testlog a b
1512 ('group', ('group', ('or', ('func', ('symbol', 'filelog'), ('string', 'a')), ('func', ('symbol', 'filelog'), ('string', 'b'))))) 1586 (group
1587 (group
1588 (or
1589 (func
1590 ('symbol', 'filelog')
1591 ('string', 'a'))
1592 (func
1593 ('symbol', 'filelog')
1594 ('string', 'b')))))
1513 1595
1514 Test falling back to slow path for non-existing files 1596 Test falling back to slow path for non-existing files
1515 1597
1516 $ testlog a c 1598 $ testlog a c
1517 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('string', 'r:'), ('string', 'p:a')), ('string', 'p:c'))))) 1599 (group
1600 (group
1601 (func
1602 ('symbol', '_matchfiles')
1603 (list
1604 (list
1605 ('string', 'r:')
1606 ('string', 'p:a'))
1607 ('string', 'p:c')))))
1518 1608
1519 Test multiple --include/--exclude/paths 1609 Test multiple --include/--exclude/paths
1520 1610
1521 $ testlog --include a --include e --exclude b --exclude e a e 1611 $ testlog --include a --include e --exclude b --exclude e a e
1522 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('list', ('list', ('list', ('list', ('string', 'r:'), ('string', 'p:a')), ('string', 'p:e')), ('string', 'i:a')), ('string', 'i:e')), ('string', 'x:b')), ('string', 'x:e'))))) 1612 (group
1613 (group
1614 (func
1615 ('symbol', '_matchfiles')
1616 (list
1617 (list
1618 (list
1619 (list
1620 (list
1621 (list
1622 ('string', 'r:')
1623 ('string', 'p:a'))
1624 ('string', 'p:e'))
1625 ('string', 'i:a'))
1626 ('string', 'i:e'))
1627 ('string', 'x:b'))
1628 ('string', 'x:e')))))
1523 1629
1524 Test glob expansion of pats 1630 Test glob expansion of pats
1525 1631
1526 $ expandglobs=`python -c "import mercurial.util; \ 1632 $ expandglobs=`python -c "import mercurial.util; \
1527 > print mercurial.util.expandglobs and 'true' or 'false'"` 1633 > print mercurial.util.expandglobs and 'true' or 'false'"`
1528 $ if [ $expandglobs = "true" ]; then 1634 $ if [ $expandglobs = "true" ]; then
1529 > testlog 'a*'; 1635 > testlog 'a*';
1530 > else 1636 > else
1531 > testlog a*; 1637 > testlog a*;
1532 > fi; 1638 > fi;
1533 ('group', ('group', ('func', ('symbol', 'filelog'), ('string', 'aa')))) 1639 (group
1640 (group
1641 (func
1642 ('symbol', 'filelog')
1643 ('string', 'aa'))))
1534 1644
1535 Test --follow on a directory 1645 Test --follow on a directory
1536 1646
1537 $ testlog -f dir 1647 $ testlog -f dir
1538 abort: cannot follow file not in parent revision: "dir" 1648 abort: cannot follow file not in parent revision: "dir"
1555 1665
1556 Test --follow on a single rename 1666 Test --follow on a single rename
1557 1667
1558 $ hg up -q 2 1668 $ hg up -q 2
1559 $ testlog -f a 1669 $ testlog -f a
1560 ('group', ('group', ('func', ('symbol', 'follow'), ('string', 'a')))) 1670 (group
1671 (group
1672 (func
1673 ('symbol', 'follow')
1674 ('string', 'a'))))
1561 1675
1562 Test --follow and multiple renames 1676 Test --follow and multiple renames
1563 1677
1564 $ hg up -q tip 1678 $ hg up -q tip
1565 $ testlog -f e 1679 $ testlog -f e
1566 ('group', ('group', ('func', ('symbol', 'follow'), ('string', 'e')))) 1680 (group
1681 (group
1682 (func
1683 ('symbol', 'follow')
1684 ('string', 'e'))))
1567 1685
1568 Test --follow and multiple filelog heads 1686 Test --follow and multiple filelog heads
1569 1687
1570 $ hg up -q 2 1688 $ hg up -q 2
1571 $ testlog -f g 1689 $ testlog -f g
1572 ('group', ('group', ('func', ('symbol', 'follow'), ('string', 'g')))) 1690 (group
1691 (group
1692 (func
1693 ('symbol', 'follow')
1694 ('string', 'g'))))
1573 $ cat log.nodes 1695 $ cat log.nodes
1574 nodetag 2 1696 nodetag 2
1575 nodetag 1 1697 nodetag 1
1576 nodetag 0 1698 nodetag 0
1577 $ hg up -q tip 1699 $ hg up -q tip
1578 $ testlog -f g 1700 $ testlog -f g
1579 ('group', ('group', ('func', ('symbol', 'follow'), ('string', 'g')))) 1701 (group
1702 (group
1703 (func
1704 ('symbol', 'follow')
1705 ('string', 'g'))))
1580 $ cat log.nodes 1706 $ cat log.nodes
1581 nodetag 3 1707 nodetag 3
1582 nodetag 2 1708 nodetag 2
1583 nodetag 0 1709 nodetag 0
1584 1710
1585 Test --follow and multiple files 1711 Test --follow and multiple files
1586 1712
1587 $ testlog -f g e 1713 $ testlog -f g e
1588 ('group', ('group', ('or', ('func', ('symbol', 'follow'), ('string', 'g')), ('func', ('symbol', 'follow'), ('string', 'e'))))) 1714 (group
1715 (group
1716 (or
1717 (func
1718 ('symbol', 'follow')
1719 ('string', 'g'))
1720 (func
1721 ('symbol', 'follow')
1722 ('string', 'e')))))
1589 $ cat log.nodes 1723 $ cat log.nodes
1590 nodetag 4 1724 nodetag 4
1591 nodetag 3 1725 nodetag 3
1592 nodetag 2 1726 nodetag 2
1593 nodetag 1 1727 nodetag 1
1603 0 files updated, 1 files merged, 1 files removed, 0 files unresolved 1737 0 files updated, 1 files merged, 1 files removed, 0 files unresolved
1604 (branch merge, don't forget to commit) 1738 (branch merge, don't forget to commit)
1605 $ echo merge > e 1739 $ echo merge > e
1606 $ hg ci -m "merge 5 and 4" 1740 $ hg ci -m "merge 5 and 4"
1607 $ testlog --follow-first 1741 $ testlog --follow-first
1608 ('group', ('func', ('symbol', '_followfirst'), None)) 1742 (group
1743 (func
1744 ('symbol', '_followfirst')
1745 None))
1609 1746
1610 Cannot compare with log --follow-first FILE as it never worked 1747 Cannot compare with log --follow-first FILE as it never worked
1611 1748
1612 $ hg log -G --print-revset --follow-first e 1749 $ hg log -G --print-revset --follow-first e
1613 ('group', ('group', ('func', ('symbol', '_followfirst'), ('string', 'e')))) 1750 (group
1751 (group
1752 (func
1753 ('symbol', '_followfirst')
1754 ('string', 'e'))))
1614 $ hg log -G --follow-first e --template '{rev} {desc|firstline}\n' 1755 $ hg log -G --follow-first e --template '{rev} {desc|firstline}\n'
1615 @ 6 merge 5 and 4 1756 @ 6 merge 5 and 4
1616 |\ 1757 |\
1617 o | 5 add another e 1758 o | 5 add another e
1618 | | 1759 | |
1637 1778
1638 Test "set:..." and parent revision 1779 Test "set:..." and parent revision
1639 1780
1640 $ hg up -q 4 1781 $ hg up -q 4
1641 $ testlog "set:copied()" 1782 $ testlog "set:copied()"
1642 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'p:set:copied()'))))) 1783 (group
1784 (group
1785 (func
1786 ('symbol', '_matchfiles')
1787 (list
1788 ('string', 'r:')
1789 ('string', 'p:set:copied()')))))
1643 $ testlog --include "set:copied()" 1790 $ testlog --include "set:copied()"
1644 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'i:set:copied()'))))) 1791 (group
1792 (group
1793 (func
1794 ('symbol', '_matchfiles')
1795 (list
1796 ('string', 'r:')
1797 ('string', 'i:set:copied()')))))
1645 $ testlog -r "sort(file('set:copied()'), -rev)" 1798 $ testlog -r "sort(file('set:copied()'), -rev)"
1646 ('group', ('group', ('func', ('symbol', 'sort'), ('list', ('func', ('symbol', 'file'), ('string', 'set:copied()')), ('negate', ('symbol', 'rev')))))) 1799 (group
1800 (group
1801 (func
1802 ('symbol', 'sort')
1803 (list
1804 (func
1805 ('symbol', 'file')
1806 ('string', 'set:copied()'))
1807 (negate
1808 ('symbol', 'rev'))))))
1647 1809
1648 Test --removed 1810 Test --removed
1649 1811
1650 $ testlog --removed 1812 $ testlog --removed
1651 ('func', ('symbol', 'all'), None) 1813 (func
1814 ('symbol', 'all')
1815 None)
1652 $ testlog --removed a 1816 $ testlog --removed a
1653 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'p:a'))))) 1817 (group
1818 (group
1819 (func
1820 ('symbol', '_matchfiles')
1821 (list
1822 ('string', 'r:')
1823 ('string', 'p:a')))))
1654 $ testlog --removed --follow a 1824 $ testlog --removed --follow a
1655 abort: can only follow copies/renames for explicit filenames 1825 abort: can only follow copies/renames for explicit filenames
1656 abort: can only follow copies/renames for explicit filenames 1826 abort: can only follow copies/renames for explicit filenames
1657 abort: can only follow copies/renames for explicit filenames 1827 abort: can only follow copies/renames for explicit filenames
1658 1828