WARNING: such a βdummy mergeβ, as recommended by @Martin_Geisler, can really hurt you if you later want to make a true merge of the two branches. A fictitious merge will be recorded and let's say that you merged into the branch that you joined - you will not see the changes. Or, if you merged into another branch, changes in this other branch will be discarded.
If you only want to copy the entire file from one branch to another, you can simply do:
hg update -r to-branch hg revert -r from-branch file hg ci -m 'copied single file from from-branch to to-branch
If you want to select different parts of this file, it is useful to use "hg record" .
I just did this in my .hgignore home directory.
If both branches made changes to the file you want to save, the dirty trick would be to merge the two branches using hg merge, perhaps / possibly on another branch, check this, and then copy one file between the merge and the branch:
hg update -r to-branch branch merge-branch hg merge -r from-branch hg ci -m 'temp merge to be discarded" hg update -r to-branch hg revert -r merge-branch single-file hg ci -m 'merged single-file from from-branch to to-branch" hg strip merge-branch
Worth mentioning: the way to "copy one file between branches" (or revisions, or from a merge version, or ....) is "hg revert". I.e.
hg update -r Where-you-want-to-copy-to hg revert -r Where-you-want-to-copy-from file-you-want-to-copy ... hg ci
For some reason, I and some of my colleagues find it VERY confusing. "revert" == "copy" ... makes sense for some usage patterns, but not for all.
Krazy Glew Oct 26 '12 at 4:19 2012-10-26 04:19
source share