comparison 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
comparison
equal deleted inserted replaced
24844:6c6aee6d395b 24845:8133494accf1
227 > done 227 > done
228 228
229 $ hg add plain 229 $ hg add plain
230 $ hg commit -i -d '7 0' -m plain plain<<EOF 230 $ hg commit -i -d '7 0' -m plain plain<<EOF
231 > y 231 > y
232 > y
232 > EOF 233 > EOF
233 diff --git a/plain b/plain 234 diff --git a/plain b/plain
234 new file mode 100644 235 new file mode 100644
235 examine changes to 'plain'? [Ynesfdaq?] y 236 examine changes to 'plain'? [Ynesfdaq?] y
237
238 @@ -0,0 +1,10 @@
239 +1
240 +2
241 +3
242 +4
243 +5
244 +6
245 +7
246 +8
247 +9
248 +10
249 record this change to 'plain'? [Ynesfdaq?] y
236 250
237 $ hg tip -p 251 $ hg tip -p
238 changeset: 7:11fb457c1be4 252 changeset: 7:11fb457c1be4
239 tag: tip 253 tag: tip
240 user: test 254 user: test
313 $ hg add plain2 327 $ hg add plain2
314 $ hg commit -i -d '10 0' -m eol plain plain2 <<EOF 328 $ hg commit -i -d '10 0' -m eol plain plain2 <<EOF
315 > y 329 > y
316 > y 330 > y
317 > y 331 > y
332 > y
318 > EOF 333 > EOF
319 diff --git a/plain b/plain 334 diff --git a/plain b/plain
320 1 hunks, 1 lines changed 335 1 hunks, 1 lines changed
321 examine changes to 'plain'? [Ynesfdaq?] y 336 examine changes to 'plain'? [Ynesfdaq?] y
322 337
330 record change 1/2 to 'plain'? [Ynesfdaq?] y 345 record change 1/2 to 'plain'? [Ynesfdaq?] y
331 346
332 diff --git a/plain2 b/plain2 347 diff --git a/plain2 b/plain2
333 new file mode 100644 348 new file mode 100644
334 examine changes to 'plain2'? [Ynesfdaq?] y 349 examine changes to 'plain2'? [Ynesfdaq?] y
350
351 @@ -0,0 +1,1 @@
352 +1
353 record change 2/2 to 'plain2'? [Ynesfdaq?] y
335 354
336 Modify beginning, trim end, record both, add another file to test 355 Modify beginning, trim end, record both, add another file to test
337 changes numbering 356 changes numbering
338 357
339 $ rm plain 358 $ rm plain
1404 tag: tip 1423 tag: tip
1405 user: test 1424 user: test
1406 date: Thu Jan 01 00:00:23 1970 +0000 1425 date: Thu Jan 01 00:00:23 1970 +0000
1407 summary: moving_files 1426 summary: moving_files
1408 1427
1428 Editing patch of newly added file
1429
1430 $ hg update -C .
1431 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1432 $ cat > editor.sh << '__EOF__'
1433 > cat "$1" | sed "s/first/very/g" > tt
1434 > mv tt "$1"
1435 > __EOF__
1436 $ cat > newfile << '__EOF__'
1437 > This is the first line
1438 > This is the second line
1439 > This is the third line
1440 > __EOF__
1441 $ hg add newfile
1442 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -d '23 0' -medit-patch-new <<EOF
1443 > y
1444 > e
1445 > EOF
1446 diff --git a/newfile b/newfile
1447 new file mode 100644
1448 examine changes to 'newfile'? [Ynesfdaq?] y
1449
1450 @@ -0,0 +1,3 @@
1451 +This is the first line
1452 +This is the second line
1453 +This is the third line
1454 record this change to 'newfile'? [Ynesfdaq?] e
1455
1456 $ hg cat -r tip newfile
1457 This is the very line
1458 This is the second line
1459 This is the third line
1460
1461 $ cat newfile
1462 This is the first line
1463 This is the second line
1464 This is the third line
1409 $ cd .. 1465 $ cd ..