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

login
register
mail settings
Submitter phabricator
Date Aug. 28, 2017, 2:17 p.m.
Message ID <de38bc0a34b360f5fcbfdf60ad2255b6@localhost.localdomain>
Download mbox | patch
Permalink /patch/23398/
State Not Applicable
Headers show

Comments

phabricator - Aug. 28, 2017, 2:17 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5707bfe04deb: record: fix revert -i for lines without newline (issue5651) (authored by quark).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D528?vs=1329&id=1350#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D528?vs=1329&id=1350

REVISION DETAIL
  https://phab.mercurial-scm.org/D528

AFFECTED FILES
  mercurial/patch.py
  tests/test-revert-interactive.t

CHANGE DETAILS




To: quark, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/test-revert-interactive.t b/tests/test-revert-interactive.t
--- a/tests/test-revert-interactive.t
+++ b/tests/test-revert-interactive.t
@@ -460,3 +460,40 @@ 
   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 ..
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -972,7 +972,7 @@ 
         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)