Reputation: 1189
I have two branches at my local repository: default
and s1
.
At default
branch there is a file called def.txt
, among others. The s1
branch has files named as set3.txt
, set1.txt
, etc. I would like to add set1.txt
of s1
branch to default
branch as well.
I have tried to use hg add set1.txt
command when the working directory is at default
branch. However, because default
branch does not has the file, I cannot add it and it always gives me a error message such as "no set1.txt file found"
.
I do not want to use merge
command because I do not want to merge all other files from s1
branch to default
branch. I only want to add one file, set1.txt
. I have tried hg transplant -b s1
, too, but it seems not serving the same purpose.
So any idea how to work around this? My goal it to have these two branches look as below:
default
: def.txt
, set1.txt
etc.
s1
: set1.txt
, set3.txt
etc.
My machine is Red Hat Linux Workstation 6 which has Mercurial 1.7.3 and TortoiseHG 1.5.
Upvotes: 3
Views: 631
Reputation: 48824
hg revert
is a cute trick. I'd be more inclined to use hg cat -r s1 set1.txt > set1.txt
however, that more explicitly does what you'd expect. I don't think ultimately there's any difference between the two commands.
Intuitively, you're trying to merge a single file from one branch into your current branch. A quick google turned up this article exploring this concept in a DVCS: http://josefbetancourt.wordpress.com/2011/01/13/merge-single-file-hg/
Upvotes: 0
Reputation: 27050
You can use a trick: "revert" the file set1.txt
to the branch s1
. Since branches are revisions, this will work:
$ hg revert -r s1 set1.txt
Upvotes: 7