开发者

Can't branch a single file with Mercurial?

开发者 https://www.devze.com 2022-12-29 14:28 出处:网络
is this possib开发者_如何学Pythonle with Mercurial? and which Version Control system can do this besides Clearcase?David is correct that you can\'t have a branch that exists on only a single file, but

is this possib开发者_如何学Pythonle with Mercurial? and which Version Control system can do this besides Clearcase?


David is correct that you can't have a branch that exists on only a single file, but it's worth pointing out that people often have branches that alter only a single file. Since the branch metadata is stored in the changeset, and since the changeset contains only a delta (change), having a branch that alters only a single files is nearly instantanous to create, update, commit, and merge, plus it takes up almost no space on disk.

Resultingly, it's a very common way to handle per-customer configurations. Keep the tiny change for them in a branch, and merge from main, where development happened, into that branch, whenever you want to update their deployment.


How you could use MQ:

$ hg qnew -m "Changes for client0" client0
... change the file ...
$ hg qref # update the client0 patch with the changes
$ hg qpop # pop the changes off the queue stack
... develop like normal ...
... client0 asks for a build ...
$ hg qpu # apply client0's patch
$ make release
$ hg qpop

It would get a bit finicky if you've got to deal with a lot of clients… But it may be worth considering.

The other thing you could do, of course, is just commit a bunch of .diff files:

... make changes for client 0 ...
$ hg diff > client0.diff
$ hg revert --all
$ hg add client0.diff
$ hg ci -m "Adding client0 changes"
... develop ...
... client0 asks for a build ...
$ patch -p1 < client0.diff
$ make release
$ hg revert --all


No, it's not possible. A branch in Mercurial is a snapshot of the entire repository state.

You could do it with CVS, though, as CVS tracks changes on a per-file basis :)

0

精彩评论

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