开发者

How to cleanup Mercurial repository?

I need to delete my "uploads" f开发者_运维知识库older from the repository with all its history because it contains only junk testing data.

Please help.


You'll want to use the convert extension that ships with mercurial. Since you want to scrub a directory from the history you'll have to completely filter you're existing repository, CONVERTing it into a new one.

Assume the following made up structure of your repo:

/
 src
 doc
 images
 upload

Create a simple text file with the following content

exclude upload

You can do more with this file but keep it simple to get to your goal. The path to be excluded is relative to the repository root

Now run mercurial convert

hg convert --filemap path/to/the/textfile old-repo new-repo

Change to the directory of the new repo. Notice that mercurial created a bare/null rev repo (no content but the .hg directory). Run the following to update to your latest changset. Notice the upload directory is gone!

cd path/to/new/repo
hg update

WARNING: I do not know how this handles named branches or tags. You're on your own. At least you're not modifying the original repo. Make as many copies as you need to get it right.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜