Show More
@@ -24,6 +24,7 b' from . import (' | |||
|
24 | 24 | encoding, |
|
25 | 25 | error, |
|
26 | 26 | patch as patchmod, |
|
27 | util, | |
|
27 | 28 | ) |
|
28 | 29 | |
|
29 | 30 | # This is required for ncurses to display non-ASCII characters in default user |
@@ -1010,7 +1011,7 b' class curseschunkselector(object):' | |||
|
1010 | 1011 | pairname="legend") |
|
1011 | 1012 | printstring(self.statuswin, |
|
1012 | 1013 | " (f)old/unfold; (c)onfirm applied; (q)uit; (?) help " |
|
1013 | "| [X]=hunk applied **=folded", | |
|
1014 | "| [X]=hunk applied **=folded, toggle [a]mend mode", | |
|
1014 | 1015 | pairname="legend") |
|
1015 | 1016 | except curses.error: |
|
1016 | 1017 | pass |
@@ -1366,7 +1367,7 b' the following are valid keystrokes:' | |||
|
1366 | 1367 | F : fold / unfold parent item and all of its ancestors |
|
1367 | 1368 | m : edit / resume editing the commit message |
|
1368 | 1369 | e : edit the currently selected hunk |
|
1369 | a : toggle amend mode (hg rev >= 2.2) | |
|
1370 | a : toggle amend mode (hg rev >= 2.2), only with commit -i | |
|
1370 | 1371 | c : confirm selected changes |
|
1371 | 1372 | r : review/edit and confirm selected changes |
|
1372 | 1373 | q : quit without confirming (no changes will be made) |
@@ -1433,6 +1434,35 b' are you sure you want to review/edit and' | |||
|
1433 | 1434 | else: |
|
1434 | 1435 | return False |
|
1435 | 1436 | |
|
1437 | def toggleamend(self, opts, test): | |
|
1438 | """Toggle the amend flag. | |
|
1439 | ||
|
1440 | When the amend flag is set, a commit will modify the most recently | |
|
1441 | committed changeset, instead of creating a new changeset. Otherwise, a | |
|
1442 | new changeset will be created (the normal commit behavior). | |
|
1443 | ||
|
1444 | """ | |
|
1445 | try: | |
|
1446 | ver = float(util.version()[:3]) | |
|
1447 | except ValueError: | |
|
1448 | ver = 1 | |
|
1449 | if ver < 2.19: | |
|
1450 | msg = ("The amend option is unavailable with hg versions < 2.2\n\n" | |
|
1451 | "Press any key to continue.") | |
|
1452 | elif opts.get('amend') is None: | |
|
1453 | opts['amend'] = True | |
|
1454 | msg = ("Amend option is turned on -- commiting the currently " | |
|
1455 | "selected changes will not create a new changeset, but " | |
|
1456 | "instead update the most recently committed changeset.\n\n" | |
|
1457 | "Press any key to continue.") | |
|
1458 | elif opts.get('amend') is True: | |
|
1459 | opts['amend'] = None | |
|
1460 | msg = ("Amend option is turned off -- commiting the currently " | |
|
1461 | "selected changes will create a new changeset.\n\n" | |
|
1462 | "Press any key to continue.") | |
|
1463 | if not test: | |
|
1464 | self.confirmationwindow(msg) | |
|
1465 | ||
|
1436 | 1466 | def recenterdisplayedarea(self): |
|
1437 | 1467 | """ |
|
1438 | 1468 | once we scrolled with pg up pg down we can be pointing outside of the |
@@ -1570,6 +1600,8 b' are you sure you want to review/edit and' | |||
|
1570 | 1600 | self.leftarrowshiftevent() |
|
1571 | 1601 | elif keypressed in ["q"]: |
|
1572 | 1602 | raise error.Abort(_('user quit')) |
|
1603 | elif keypressed in ['a']: | |
|
1604 | self.toggleamend(self.opts, test) | |
|
1573 | 1605 | elif keypressed in ["c"]: |
|
1574 | 1606 | if self.confirmcommit(): |
|
1575 | 1607 | return True |
@@ -71,6 +71,7 b' Committing only one hunk while aborting ' | |||
|
71 | 71 | - unfold it |
|
72 | 72 | - go down to second hunk (1 for the first hunk, 1 for the first hunkline, 1 for the second hunk, 1 for the second hunklike) |
|
73 | 73 | - toggle the second hunk |
|
74 | - toggle on and off the amend mode (to check that it toggles off) | |
|
74 | 75 | - edit the hunk and quit the editor immediately with non-zero status |
|
75 | 76 | - commit |
|
76 | 77 | |
@@ -88,6 +89,8 b' Committing only one hunk while aborting ' | |||
|
88 | 89 | > KEY_DOWN |
|
89 | 90 | > KEY_DOWN |
|
90 | 91 | > TOGGLE |
|
92 | > a | |
|
93 | > a | |
|
91 | 94 | > e |
|
92 | 95 | > X |
|
93 | 96 | > EOF |
@@ -166,3 +169,23 b' Newly added files can be selected with t' | |||
|
166 | 169 | $ hg st |
|
167 | 170 | ? testModeCommands |
|
168 | 171 | |
|
172 | Amend option works | |
|
173 | $ echo "hello world" > x | |
|
174 | $ hg diff -c . | |
|
175 | diff -r a6735021574d -r 2b0e9be4d336 x | |
|
176 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
|
177 | +++ b/x Thu Jan 01 00:00:00 1970 +0000 | |
|
178 | @@ -0,0 +1,1 @@ | |
|
179 | +hello | |
|
180 | $ cat <<EOF >testModeCommands | |
|
181 | > a | |
|
182 | > X | |
|
183 | > EOF | |
|
184 | $ hg commit -i -m "newly added file" -d "0 0" | |
|
185 | saved backup bundle to $TESTTMP/a/.hg/strip-backup/2b0e9be4d336-28bbe4e2-amend-backup.hg (glob) | |
|
186 | $ hg diff -c . | |
|
187 | diff -r a6735021574d -r c1d239d165ae x | |
|
188 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
|
189 | +++ b/x Thu Jan 01 00:00:00 1970 +0000 | |
|
190 | @@ -0,0 +1,1 @@ | |
|
191 | +hello world |
General Comments 0
You need to be logged in to leave comments.
Login now