Bug 5723 - "hg split" only pretends to work on copied/renamed file
Summary: "hg split" only pretends to work on copied/renamed file
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: evolution (show other bugs)
Version: 4.4-rc
Hardware: PC Linux
: normal bug
Assignee: Kyle Lippincott
URL:
Keywords:
: 6047 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-10-30 17:35 UTC by Martin von Zweigbergk
Modified: 2019-11-08 16:20 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 2017-10-30 17:35 UTC
This demonstrates the bug

$ hg init
$ echo -e '1\n\2' > file
$ hg ci -Am initial
$ hg mv file file2
$ echo -e '3\n\4' > file2
$ hg ci -m 'move and modify'
$ hg split

At the last step, select just the first line (removing the line "1") and press "c" to confirm. The split completes, putting everything in a single commit.
Comment 1 Bugzilla 2018-04-07 00:00 UTC
Bug was inactive for 150 days, archiving
Comment 2 Martin von Zweigbergk 2018-07-24 00:57 UTC
Similarly, it looks like you can split a file deletion, but it ends up deleting the entire file:

$ hg init
$ echo -e '1\n\2' > file
$ hg ci -Am initial
$ hg rm file
$ hg ci -m delete
$ hg split

Now select just one of the lines. The split completes, putting the entire deletion in a single commit.
Comment 3 Martin von Zweigbergk 2018-07-24 00:57 UTC
Similarly, it looks like you can split a file deletion, but it ends up deleting the entire file:

$ hg init
$ echo -e '1\n\2' > file
$ hg ci -Am initial
$ hg rm file
$ hg ci -m delete
$ hg split

Now select just one of the lines. The split completes, putting the entire deletion in a single commit.
Comment 4 Bugzilla 2018-12-21 00:00 UTC
Bug was inactive for 150 days, archiving
Comment 5 Bugzilla 2019-05-20 00:00 UTC
Bug was inactive for 150 days, archiving
Comment 6 Kyle Lippincott 2019-08-27 15:48 UTC
I've just mailed fixes for splitting/interactively committing copies and renames. I haven't fixed interactive revert (it's not really affected by it since it doesn't allow partial reverts of copied/renamed files, it seems?). I haven't fixed the file deletion case, and don't plan on doing more work here; we may want to split that out to another issue?

File deletion only appears splittable in the curses UI, in the text UI, it asks:

diff --git a/qux b/qux
deleted file mode 100644
examine changes to 'qux'?
(enter ? for help) [Ynesfdaq?] y

and then just spawns the commit message editor immediately instead of letting me modify the patch at all, so it's a different underlying issue, I believe.
Comment 7 HG Bot 2019-09-09 10:50 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/3cf091843b4f
Kyle Lippincott <spectral@google.com>
split: handle partial commit of renames when doing split or record (issue5723)

When using split or record, using either interface (text or curses), selecting
portions of the file to be committed/recorded did not work; the entire file was
treated as having been selected. This was because the logic for handling partial
application of the patches relies on knowing what files are "new with
modifications" and it doesn't treat "rename destination" as "new".

There was a complicating issue, however. We're relying on the patch header
specifying the copy from/to information, which works as long as the 'copy from'
file is there. In the case of renames, however, the 'rename from' file is *not*
there, so we need to add it back.

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

(please test the fix)
Comment 8 Bugzilla 2019-09-17 00:01 UTC
Bug was set to TESTING for 7 days, resolving
Comment 9 Kyle Lippincott 2019-11-08 16:20 UTC
*** Bug 6047 has been marked as a duplicate of this bug. ***