Patchwork [Bug,6084] New: `hg merge` can loose file renames

login
register
mail settings
Submitter mercurial-bugs@mercurial-scm.org
Date Feb. 19, 2019, 10:24 a.m.
Message ID <bug-6084-285@https.bz.mercurial-scm.org/>
Download mbox | patch
Permalink /patch/38821/
State Not Applicable
Headers show

Comments

mercurial-bugs@mercurial-scm.org - Feb. 19, 2019, 10:24 a.m.
https://bz.mercurial-scm.org/show_bug.cgi?id=6084

            Bug ID: 6084
           Summary: `hg merge` can loose file renames
           Product: Mercurial
           Version: 4.8
          Hardware: PC
                OS: Linux
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla@mercurial-scm.org
          Reporter: 7895pulkit@gmail.com
                CC: mercurial-devel@mercurial-scm.org

I can reproduce this by the following steps:

```
$ hg init temprepo
$ cd temprepo/
$ echo a > a
$ hg ci -Aqm 'added a'
$ echo b > b
$ hg ci -Aqm 'added b'                                              
$ echo c > c
$ hg ci -Aqm 'added c'                                              
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] added b
$ hg mv b d
$ hg diff
pulkit@pulkit-nix:~/repo/temprepo$ hg status
M d
R b
# The repository is in an unfinished *merge* state.

# To continue:    hg commit
# To abort:       hg merge --abort

$ hg config experimental.copytrace
$
```

As it can be seen, file rename is lost after merging.

This is a quite important issue because when using merges, we merge a user
branch into default and the moves in user branch does not come to default
branch.

Patch

diff --git a/b b/d
rename from b
rename to d
$ hg ci -m "moved b to d"                                           
created new head
(consider using topic for lightweight branches. See 'hg help topic')
$ hg work
@  799c moved b to d
| o  62bd added c
|/
o  a1fc added b
o  a5ea added a
$ hg up 62bd
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg work
o  799c moved b to d
| @  62bd added c
|/
o  a1fc added b
o  a5ea added a
$ hg merge
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg diff
diff --git a/b b/b
deleted file mode 100644
--- a/b
+++ /dev/null
@@ -1,1 +0,0 @@ 
-b
diff --git a/d b/d
new file mode 100644
--- /dev/null
+++ b/d
@@ -0,0 +1,1 @@ 
+b