I ran into a situation in Mercurial at work where I would expect a file to exist, but it doesn't and I'd like to better understand why. I've put together a repro of the issue. In this repro I would expect the file foo.txt to exist on default after the final merge, since one parent of the merge does not have the file present because it was removed earlier, and the other parent is adding it back because of a commit that happened after the commit that removed the file. Instead, the file remains deleted, why?
Here's an image of the sequence of commits:
And here's the actual commands to go from an empty directory, to having a Mercurial repo in this state.
hg init
echo foo > foo.txt
echo bar > bar.txt
hg add foo.txt bar.txt
hg commit -m "Add foo.txt and bar.txt"
hg branch feature
hg remove foo.txt
hg commit -m "Remove foo.txt"
echo barbar > bar.txt
hg commit -m "Modify bar.txt"
hg update default
echo baz > baz.txt
hg add baz.txt
hg commit -m "Add baz.txt"
hg update feature
hg merge default
hg commit -m "Merge default"
echo foo > foo.txt
hg add foo.txt
hg commit -m "Restore foo.txt"
hg update default
echo bazbaz > baz.txt
hg commit -m "Modify baz.txt"
hg update 0
hg merge 2
hg commit -m "Merge feature"
hg merge
hg commit -m "Merge"
hg merge feature
hg commit -m "Merge feature"
State of the working directory after the final merge:
> ls
bar.txt baz.txt
EDIT: This appears to affect hg versions 5.9.3 and 6.3.2 but not 5.0.2
EDIT:
Based on discussion on the libera.chat #mercurial channel, modifying the sequence of commands in the repro to include an edit to the file after its creation does not change the outcome. foo.txt
is still not present. https://gist.github.com/OneGeek/6fa5dcd4c2b3db6649310de1167449f9