Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
160 views
in Technique[技术] by (71.8m points)

How can I import a mercurial repo (including history) into another mercurial repo as a subdirectory, without using subrepos?

This sounds kind of complex, so let me explain:

Project_A has lived for some time within its own Mercurial repository. Project_A is now getting folded into a new super project, Super-Project_B. Super-Project_B also has a mercurial repository. We would prefer if Project_A were not a subrepo, but instead just a normal child, but we also don't want to lose the history. Is there a way to do this?

question from:https://stackoverflow.com/questions/3214717/how-can-i-import-a-mercurial-repo-including-history-into-another-mercurial-rep

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yeah. Use the convert extension to move projectA down one directory level:

hg convert --filemap filemap.txt projectA projectA-redone

where your filemap.txt has this line in it:

rename . projectA

(that dot might be a slash but I don't think so).

That will give you a new repo, projectA-redone, that has all the history of A though all the changesets will have different hashes since their content (paths) have changed to get "projectA" in front of all of them.

Then you go into Super-Project_B and do a hg pull -f /path/to/projectA-redone. You need the -f because otherwise you'll be told that the repos are unrelated since they have no changesets in common.

Finally you'll do a hg merge in Super_project_b which should have no conflicts (unless you already had a projectA directory, in which case you should've picked a different name or hg removed it first).

After doing that B will have all of A inside the projectA subdirectory and all history will be intact.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...