##// END OF EJS Templates
crecord: edit during hg crecord should preserve cursor position (issue5041)...
Laurent Charignon -
r27914:505a10b5 stable
parent child Browse files
Show More
@@ -1551,6 +1551,9 b' are you sure you want to review/edit and'
1551 if not isinstance(item, uihunk):
1551 if not isinstance(item, uihunk):
1552 return
1552 return
1553
1553
1554 # To go back to that hunk or its replacement at the end of the edit
1555 itemindex = item.parentitem().hunks.index(item)
1556
1554 beforeadded, beforeremoved = item.added, item.removed
1557 beforeadded, beforeremoved = item.added, item.removed
1555 newpatches = editpatchwitheditor(self, item)
1558 newpatches = editpatchwitheditor(self, item)
1556 if newpatches is None:
1559 if newpatches is None:
@@ -1575,6 +1578,8 b' are you sure you want to review/edit and'
1575 if self.emptypatch():
1578 if self.emptypatch():
1576 header.hunks = hunksbefore + [item] + hunksafter
1579 header.hunks = hunksbefore + [item] + hunksafter
1577 self.currentselecteditem = header
1580 self.currentselecteditem = header
1581 if len(header.hunks) > itemindex:
1582 self.currentselecteditem = header.hunks[itemindex]
1578
1583
1579 if not test:
1584 if not test:
1580 updateui(self)
1585 updateui(self)
@@ -193,3 +193,33 b' Amend option works'
193 +++ b/x Thu Jan 01 00:00:00 1970 +0000
193 +++ b/x Thu Jan 01 00:00:00 1970 +0000
194 @@ -0,0 +1,1 @@
194 @@ -0,0 +1,1 @@
195 +hello world
195 +hello world
196
197 Editing a hunk puts you back on that hunk when done editing (issue5041)
198 To do that, we change two lines in a file, pretend to edit the second line,
199 exit, toggle the line selected at the end of the edit and commit.
200 The first line should be recorded if we were put on the second line at the end
201 of the edit.
202
203 $ hg update -C .
204 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
205 $ echo "foo" > x
206 $ echo "hello world" >> x
207 $ echo "bar" >> x
208 $ cat <<EOF >testModeCommands
209 > f
210 > KEY_DOWN
211 > KEY_DOWN
212 > KEY_DOWN
213 > KEY_DOWN
214 > e
215 > TOGGLE
216 > X
217 > EOF
218 $ printf "printf 'editor ran\n'; exit 0" > editor.sh
219 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "edit hunk" -d "0 0"
220 editor ran
221 $ hg cat -r . x
222 foo
223 hello world
224
225
General Comments 0
You need to be logged in to leave comments. Login now