David Andreoletti
David Andreoletti

Reputation: 4861

Why is hg status reporting a deleted file as Modified after a merge when this file was deleted on the current branch?

My repo has:

@  2:85bb423103fb99137985c7e218ab4d5896e1aea0:default
|  removed file a
|
| o  1:46b6b63ecf64e8f108c83af85a46fd4c89335d74:b
|/   Modified file a
|
o  0:bbf90d08b30cd007038eaf7f8d3d1215ade86005:default
   Created file a

Now running hg merge b, I get:

hg merge b
remote changed a which local deleted
use (c)hanged version or leave (d)eleted? c
1 files updated, 0 files merged, 0 files removed, 0 files unresolved 
(branch merge, don't forget to commit)

Now running hg diff, I get:

hg diff 
diff -r 85bb423103fb a
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/a Wed Oct 09 12:18:45 2013 +0800
@@ -0,0 +1,1 @@
+bbb

The behaviour I expect is to have /dev/null to compare from (the file has been deleted in hg). hg status should show:

hg status
? a

However, hg status shows:

hg status
M a

Why Hg reporting that the file has been modified here ?

Upvotes: 1

Views: 1253

Answers (1)

Ry4an Brase
Ry4an Brase

Reputation: 78330

I don't understand your confusion. When you're asked this question during merge

use (c)hanged version or leave (d)eleted?

It's essentially saying "local has it deleted, but the branch you're merging in made a change to it, which are entirely unreconcileable acts. Do you want to leave it deleted locally or do you want to copy in the file as it looks in branch 'b'?" When you answer c saying you want the version from b that is changed, mercurial puts that file in place just as it would look if you'd done hg revert --rev b a.

So when you do hg diff it's comparing the nothing you had there in revision 2 (/dev/null) with what existed in b and so you see everything as added.

Similarly when you do hg status it acts as if revision 2 had merely zeroed out the file and thus it's now modified by having all of what exists in revision b inserted in it

If, by way of example, you answered d for "deleted" then the file would still be un-added after the merge and you could do hg revert --rev b a and the file contents on disk would be the same as in the answering c case but the file would be unadded.

Upvotes: 2

Related Questions