Commit 0480dc56 authored by Jun Wu's avatar Jun Wu

record: fix revert -i for lines without newline (issue5651)

This is a regression caused by 66117dae87f9. Code prior to 66117dae87f9
seems to miss the "\ No newline at end of file" line.

Differential Revision: https://phab.mercurial-scm.org/D528

--HG--
branch : stable
parent fb672eac2702
......@@ -972,7 +972,7 @@ class recordhunk(object):
that, swap fromline/toline and +/- signs while keep other things
unchanged.
"""
m = {'+': '-', '-': '+'}
m = {'+': '-', '-': '+', '\\': '\\'}
hunk = ['%s%s' % (m[l[0]], l[1:]) for l in self.hunk]
return recordhunk(self.header, self.toline, self.fromline, self.proc,
self.before, hunk, self.after)
......
......@@ -460,3 +460,40 @@ Check the experimental config to invert the selection:
forget added file newfile (Yn)? y
$ hg status
? newfile
When a line without EOL is selected during "revert -i" (issue5651)
$ cat <<EOF >> $HGRCPATH
> [experimental]
> %unset revertalternateinteractivemode
> EOF
$ hg init $TESTTMP/revert-i-eol
$ cd $TESTTMP/revert-i-eol
$ echo 0 > a
$ hg ci -qAm 0
$ printf 1 >> a
$ hg ci -qAm 1
$ cat a
0
1 (no-eol)
$ hg revert -ir'.^' <<EOF
> y
> y
> EOF
reverting a
diff --git a/a b/a
1 hunks, 1 lines changed
examine changes to 'a'? [Ynesfdaq?] y
@@ -1,1 +1,2 @@
0
+1
\ No newline at end of file
revert this change to 'a'? [Ynesfdaq?] y
$ cat a
0
$ cd ..
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment