Mercurial > hg
comparison tests/test-split.t @ 42856:3cf091843b4f
split: handle partial commit of renames when doing split or record (issue5723)
When using split or record, using either interface (text or curses), selecting
portions of the file to be committed/recorded did not work; the entire file was
treated as having been selected. This was because the logic for handling partial
application of the patches relies on knowing what files are "new with
modifications" and it doesn't treat "rename destination" as "new".
There was a complicating issue, however. We're relying on the patch header
specifying the copy from/to information, which works as long as the 'copy from'
file is there. In the case of renames, however, the 'rename from' file is *not*
there, so we need to add it back.
Differential Revision: https://phab.mercurial-scm.org/D6768
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Tue, 27 Aug 2019 11:56:19 -0700 |
parents | 1fd530b1e1cf |
children | 2349a60f33db |
comparison
equal
deleted
inserted
replaced
42855:1fd530b1e1cf | 42856:3cf091843b4f |
---|---|
787 | 787 |
788 $ printf 'y\ny\ny\n' | hg split | 788 $ printf 'y\ny\ny\n' | hg split |
789 abort: cannot split an empty revision | 789 abort: cannot split an empty revision |
790 [255] | 790 [255] |
791 #endif | 791 #endif |
792 | |
793 Test that splitting moves works properly (issue5723) | |
794 ---------------------------------------------------- | |
795 | |
796 $ hg init $TESTTMP/issue5723-mv | |
797 $ cd $TESTTMP/issue5723-mv | |
798 $ printf '1\n2\n' > file | |
799 $ hg ci -qAm initial | |
800 $ hg mv file file2 | |
801 $ printf 'a\nb\n1\n2\n3\n4\n' > file2 | |
802 $ cat > $TESTTMP/messages <<EOF | |
803 > split1, keeping only the numbered lines | |
804 > -- | |
805 > split2, keeping the lettered lines | |
806 > EOF | |
807 $ hg ci -m 'move and modify' | |
808 $ printf 'y\nn\na\na\n' | hg split | |
809 diff --git a/file b/file2 | |
810 rename from file | |
811 rename to file2 | |
812 2 hunks, 4 lines changed | |
813 examine changes to 'file' and 'file2'? | |
814 (enter ? for help) [Ynesfdaq?] y | |
815 | |
816 @@ -0,0 +1,2 @@ | |
817 +a | |
818 +b | |
819 record change 1/2 to 'file2'? | |
820 (enter ? for help) [Ynesfdaq?] n | |
821 | |
822 @@ -2,0 +5,2 @@ 2 | |
823 +3 | |
824 +4 | |
825 record change 2/2 to 'file2'? | |
826 (enter ? for help) [Ynesfdaq?] a | |
827 | |
828 EDITOR: HG: Splitting 8c42fa635116. Write commit message for the first split changeset. | |
829 EDITOR: move and modify | |
830 EDITOR: | |
831 EDITOR: | |
832 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
833 EDITOR: HG: Leave message empty to abort commit. | |
834 EDITOR: HG: -- | |
835 EDITOR: HG: user: test | |
836 EDITOR: HG: branch 'default' | |
837 EDITOR: HG: added file2 | |
838 EDITOR: HG: removed file | |
839 created new head | |
840 diff --git a/file2 b/file2 | |
841 1 hunks, 2 lines changed | |
842 examine changes to 'file2'? | |
843 (enter ? for help) [Ynesfdaq?] a | |
844 | |
845 EDITOR: HG: Splitting 8c42fa635116. So far it has been split into: | |
846 EDITOR: HG: - 478be2a70c27: split1, keeping only the numbered lines | |
847 EDITOR: HG: Write commit message for the next split changeset. | |
848 EDITOR: move and modify | |
849 EDITOR: | |
850 EDITOR: | |
851 EDITOR: HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
852 EDITOR: HG: Leave message empty to abort commit. | |
853 EDITOR: HG: -- | |
854 EDITOR: HG: user: test | |
855 EDITOR: HG: branch 'default' | |
856 EDITOR: HG: changed file2 | |
857 saved backup bundle to $TESTTMP/issue5723-mv/.hg/strip-backup/8c42fa635116-a38044d4-split.hg (obsstore-off !) | |
858 $ hg log -T '{desc}: {files%"{file} "}\n' | |
859 split2, keeping the lettered lines: file2 | |
860 split1, keeping only the numbered lines: file file2 | |
861 initial: file | |
862 $ cat file2 | |
863 a | |
864 b | |
865 1 | |
866 2 | |
867 3 | |
868 4 | |
869 $ hg cat -r ".^" file2 | |
870 1 | |
871 2 | |
872 3 | |
873 4 | |
874 $ hg cat -r . file2 | |
875 a | |
876 b | |
877 1 | |
878 2 | |
879 3 | |
880 4 | |
881 | |
792 | 882 |
793 Test that splitting copies works properly (issue5723) | 883 Test that splitting copies works properly (issue5723) |
794 ---------------------------------------------------- | 884 ---------------------------------------------------- |
795 | 885 |
796 $ hg init $TESTTMP/issue5723-cp | 886 $ hg init $TESTTMP/issue5723-cp |