开发者

Is better to branch or fork a Mercurial repository?

开发者 https://www.devze.com 2023-02-26 05:17 出处:网络
Assuming you \"own\" a Mercurial repository is it better to branch or fork the repository when embarking on experimental code?

Assuming you "own" a Mercurial repository is it better to branch or fork the repository when embarking on experimental code?

In my situation I'm a lone developer and abou开发者_如何学编程t to embark on some experimental code. I expect this experiment to take 4 to 6 hours. If I consider the experiment a failure then it highly unlikely I will ever want to refer to it again.

I commit often and push regularly. During the experiment I could only commit and then toss the local repo. However I push regularly mainly as means of backup. The repository is hosted on bitbucket.

In this situation am I better to branch or fork the repository?


Being a fan of named branches for all work (branch-per-task, etc) I would recommend ... do both.

Clone the original repo, and in the new repo create a new named branch for the experimental work.

If you decide to keep the experimental work, push it back to the original repo (perform merges as appropriate).

If you decide not to keep the experimental work, just throw the experimental repo away.


If I consider the experiment a failure then it highly unlikely I will ever want to refer to it again.

You answered your own question, fork it locally then pull your changes in the main repository if successful.

Though I don't think you would generate too much content in 4 to 6 hours that would make a useless branch bothersome...


I'd say it doesn't really matter. In both cases it depends on the time of deletion of your experiment whether you can later refer to it or not.

When you do experimental branches you can later get rid of them by using the strip command, which is part of the mq extensions. Or you could use convert from a hg to a hg repository in order to remove dead branches. You can even simply clone and omit branches.

When you fork for experimental branches you can obvioulsy merge them later if you want to refer to it.

Therefore it all boils down to the question: How long do you want to keep experimental branches and where do you want to store them?


Consider a branch to be documentation. You and others can refer to the ideas, and changes later. Foresee the situation where you say "Oh I tried that once in a branch... but deleted it." The only cost is a little disk space.

0

精彩评论

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