Here is what you can do:
Go to the template project and merge project A, then crop everything you don't need before committing. This is quite time consuming and time consuming.
Then you can go to the project and pull out the template from the project and merge it very carefully.
I would not do this for a number of reasons. Firstly, it is random and error prone. Secondly, this leads to both projects containing all the files of all other projects, even if in the prompt versions these files are considered deleted. The story is still there.
Here is another thing you could do:
hg export, , A. hg import, .
A B .
, A .
, .
, :
. A B .