Bug 5337 - "hg revert -i" can not revert part of hunk
Summary: "hg revert -i" can not revert part of hunk
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: record (show other bugs)
Version: 3.9
Hardware: PC Linux
: wish bug
Assignee: Bugzilla
URL:
Keywords:
: 5437 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-20 01:14 UTC by Martin von Zweigbergk
Modified: 2017-07-06 08:22 UTC (History)
5 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin von Zweigbergk 2016-08-20 01:14 UTC
Commit and empty file, add two lines to it, then try to revert one of the added lines using "hg revert -i". Both lines will be reverted. Note that "hg commit -i" can add correctly add either of the lines.

This shows the bug:

hg init
touch f
hg add f
hg ci -m empty
printf 'a\nb\n' > f
hg ci -i

Select one of the lines and confirm. Both will be reverted.
Comment 1 Pierre-Yves David 2016-08-22 08:02 UTC
You example does not list 'hg revert' is the last 'hg ci' supposed to be revert?
Comment 2 Martin von Zweigbergk 2016-08-22 13:56 UTC
Oops, yes, "hg revert -i" was what I meant there.
Comment 3 Jun Wu 2016-11-23 18:53 UTC
I think I just fond the same bug. Create a test repo:

  hg init r2
  cd r2
  seq 1 5 > a
  hg ci -A a -m a

Add two lines in the working copy:

  seq 6 7 >> a

And try to do the revert:

  hg revert -i --config ui.interface=curses a

Select one line, unselect the other, using crecord:

  [~]    diff --git a/a b/a
         1 hunks, 2 lines changed
     [~]     @@ -4,2 +4,4 @@ 3
              4
              5
        [x]  +6
        [ ]  +7

Actual:

  Both lines gets reverted.

Expected:

  Only 6 or 7 gets reverted.

Since "text" record does not allow you to select individual lines, it is only a problem of crecord.
Comment 4 Jun Wu 2016-12-02 19:25 UTC
*** Bug 5437 has been marked as a duplicate of this bug. ***
Comment 5 Bugzilla 2017-05-02 00:00 UTC
Bug was inactive for 150 days, archiving
Comment 6 joshgold 2017-06-14 10:55 UTC
I ran into this problem today.  With this bug, it's easy to miss a result very different from expected.
Comment 7 Jun Wu 2017-07-06 08:22 UTC
Should be fixed by https://www.mercurial-scm.org/repo/hg/rev/66117dae87f9