Mercurial > public > mercurial-scm > hg
diff tests/test-commit-interactive.t @ 24845:8133494accf1 stable
record: edit patch of newly added files (issue4304)
I tried to fix this issue in the past and had to revert the fix. This is a
second attempt without the regression we found with the first one.
record defines special headers (of file) as headers whose hunk are not shown
to the user for editing, they are used to represent deleted, moved and new
files. Since we want to authorize editing the patch of newly added file we
make the newly added file with some content not special anymore. This entails
that we have to save their content before applying the backup to be able to
revert it if the patch does not apply properly.
We reintroduce the test showing that newly added files can be edited and that
their content is shown to the user.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Thu, 23 Apr 2015 14:27:26 -0700 |
parents | 6c6aee6d395b |
children | 15d7f435108a |
line wrap: on
line diff
--- a/tests/test-commit-interactive.t Thu Apr 23 16:59:11 2015 -0700 +++ b/tests/test-commit-interactive.t Thu Apr 23 14:27:26 2015 -0700 @@ -229,11 +229,25 @@ $ hg add plain $ hg commit -i -d '7 0' -m plain plain<<EOF > y + > y > EOF diff --git a/plain b/plain new file mode 100644 examine changes to 'plain'? [Ynesfdaq?] y + @@ -0,0 +1,10 @@ + +1 + +2 + +3 + +4 + +5 + +6 + +7 + +8 + +9 + +10 + record this change to 'plain'? [Ynesfdaq?] y + $ hg tip -p changeset: 7:11fb457c1be4 tag: tip @@ -315,6 +329,7 @@ > y > y > y + > y > EOF diff --git a/plain b/plain 1 hunks, 1 lines changed @@ -333,6 +348,10 @@ new file mode 100644 examine changes to 'plain2'? [Ynesfdaq?] y + @@ -0,0 +1,1 @@ + +1 + record change 2/2 to 'plain2'? [Ynesfdaq?] y + Modify beginning, trim end, record both, add another file to test changes numbering @@ -1406,4 +1425,41 @@ date: Thu Jan 01 00:00:23 1970 +0000 summary: moving_files +Editing patch of newly added file + + $ hg update -C . + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cat > editor.sh << '__EOF__' + > cat "$1" | sed "s/first/very/g" > tt + > mv tt "$1" + > __EOF__ + $ cat > newfile << '__EOF__' + > This is the first line + > This is the second line + > This is the third line + > __EOF__ + $ hg add newfile + $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -d '23 0' -medit-patch-new <<EOF + > y + > e + > EOF + diff --git a/newfile b/newfile + new file mode 100644 + examine changes to 'newfile'? [Ynesfdaq?] y + + @@ -0,0 +1,3 @@ + +This is the first line + +This is the second line + +This is the third line + record this change to 'newfile'? [Ynesfdaq?] e + + $ hg cat -r tip newfile + This is the very line + This is the second line + This is the third line + + $ cat newfile + This is the first line + This is the second line + This is the third line $ cd ..