comparison tests/test-commit-interactive.t @ 47565:00ae1fb6c459

cmdutil: fix newandmodified file accounting for --interactive commits `originalchunks` is a misleading name, because it only contains header objects, which are flattened to selected hunks by the filter function. As such, `chunks not in originalchunks` is always True and misleading, because hunk objects never compare equal to header objects. This change fixes the internal naming and removes the useless parameter from the method. This change also fixes issue6533, by considering the filtered headers, rather than the hunks, when determining new and modified files. If a file is renamed + edited, and the edited hunks are deselected (but the file is not), the filtered chunks will contain a header for the file (because it's .special()) but but no hunks. Differential Revision: https://phab.mercurial-scm.org/D10936
author Daniel Ploch <dploch@google.com>
date Fri, 02 Jul 2021 11:44:13 -0700
parents ac362d5a7893
children 6a454e7053a1
comparison
equal deleted inserted replaced
47564:57bdecf4322c 47565:00ae1fb6c459
1711 11 1711 11
1712 +somechange 1712 +somechange
1713 record this change to 'plain3'? 1713 record this change to 'plain3'?
1714 (enter ? for help) [Ynesfdaq?] y 1714 (enter ? for help) [Ynesfdaq?] y
1715 1715
1716
1717 Rename file but discard edits
1718
1719 $ echo content > new-file
1720 $ hg add -q new-file
1721 $ hg commit -qm 'new file'
1722 $ hg mv new-file renamed-file
1723 $ echo new-content >> renamed-file
1724 $ hg commit -i -d '24 0' -m content-rename<<EOF
1725 > y
1726 > n
1727 > EOF
1728 diff --git a/new-file b/renamed-file
1729 rename from new-file
1730 rename to renamed-file
1731 1 hunks, 1 lines changed
1732 examine changes to 'new-file' and 'renamed-file'?
1733 (enter ? for help) [Ynesfdaq?] y
1734
1735 @@ -1,1 +1,2 @@
1736 content
1737 +new-content
1738 record this change to 'renamed-file'?
1739 (enter ? for help) [Ynesfdaq?] n
1740
1741 $ hg status
1742 M renamed-file
1743 ? editedfile.orig
1744 ? editedfile.rej
1745 ? editor.sh
1746 $ hg diff
1747 diff -r * renamed-file (glob)
1748 --- a/renamed-file Thu Jan 01 00:00:24 1970 +0000
1749 +++ b/renamed-file Thu Jan 01 00:00:00 1970 +0000
1750 @@ -1,1 +1,2 @@
1751 content
1752 +new-content
1753
1716 The #if execbit block above changes the hash here on some systems 1754 The #if execbit block above changes the hash here on some systems
1717 $ hg status -A plain3 1755 $ hg status -A plain3
1718 C plain3 1756 C plain3
1719 $ hg tip 1757 $ hg tip
1720 changeset: 32:* (glob) 1758 changeset: 34:* (glob)
1721 tag: tip 1759 tag: tip
1722 user: test 1760 user: test
1723 date: Thu Jan 01 00:00:23 1970 +0000 1761 date: Thu Jan 01 00:00:24 1970 +0000
1724 summary: moving_files 1762 summary: content-rename
1725 1763
1726 Editing patch of newly added file 1764 Editing patch of newly added file
1727 1765
1728 $ hg update -C . 1766 $ hg update -C .
1729 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 1767 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1730 $ cat > editor.sh << '__EOF__' 1768 $ cat > editor.sh << '__EOF__'
1731 > cat "$1" | sed "s/first/very/g" > tt 1769 > cat "$1" | sed "s/first/very/g" > tt
1732 > mv tt "$1" 1770 > mv tt "$1"
1733 > __EOF__ 1771 > __EOF__
1734 $ cat > newfile << '__EOF__' 1772 $ cat > newfile << '__EOF__'
1735 > This is the first line 1773 > This is the first line
1736 > This is the second line 1774 > This is the second line
1737 > This is the third line 1775 > This is the third line
1738 > __EOF__ 1776 > __EOF__
1739 $ hg add newfile 1777 $ hg add newfile
1740 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -d '23 0' -medit-patch-new <<EOF 1778 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -d '25 0' -medit-patch-new <<EOF
1741 > y 1779 > y
1742 > e 1780 > e
1743 > EOF 1781 > EOF
1744 diff --git a/newfile b/newfile 1782 diff --git a/newfile b/newfile
1745 new file mode 100644 1783 new file mode 100644
1768 1 files updated, 0 files merged, 0 files removed, 0 files unresolved 1806 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1769 $ mkdir folder 1807 $ mkdir folder
1770 $ cd folder 1808 $ cd folder
1771 $ echo "foo" > bar 1809 $ echo "foo" > bar
1772 $ hg add bar 1810 $ hg add bar
1773 $ hg commit -i -d '23 0' -mnewfilesubdir <<EOF 1811 $ hg commit -i -d '26 0' -mnewfilesubdir <<EOF
1774 > y 1812 > y
1775 > y 1813 > y
1776 > EOF 1814 > EOF
1777 diff --git a/folder/bar b/folder/bar 1815 diff --git a/folder/bar b/folder/bar
1778 new file mode 100644 1816 new file mode 100644
1784 record this change to 'folder/bar'? 1822 record this change to 'folder/bar'?
1785 (enter ? for help) [Ynesfdaq?] y 1823 (enter ? for help) [Ynesfdaq?] y
1786 1824
1787 The #if execbit block above changes the hashes here on some systems 1825 The #if execbit block above changes the hashes here on some systems
1788 $ hg tip -p 1826 $ hg tip -p
1789 changeset: 34:* (glob) 1827 changeset: 36:* (glob)
1790 tag: tip 1828 tag: tip
1791 user: test 1829 user: test
1792 date: Thu Jan 01 00:00:23 1970 +0000 1830 date: Thu Jan 01 00:00:26 1970 +0000
1793 summary: newfilesubdir 1831 summary: newfilesubdir
1794 1832
1795 diff -r * -r * folder/bar (glob) 1833 diff -r * -r * folder/bar (glob)
1796 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1834 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1797 +++ b/folder/bar Thu Jan 01 00:00:23 1970 +0000 1835 +++ b/folder/bar Thu Jan 01 00:00:26 1970 +0000
1798 @@ -0,0 +1,1 @@ 1836 @@ -0,0 +1,1 @@
1799 +foo 1837 +foo
1800 1838
1801 $ cd .. 1839 $ cd ..
1802 1840