Using Mercurial to start a new project similar to an existing one
I have a project on a Mercurial (HG) repository. I am about to start a new project that I would like to start by using the exact same code as the mentioned project. The two projects are completely unrelated. Even though they do similar stuff, each one is for a different client, carry different names, different branding, different art.
My question is:
开发者_StackOverflow社区What would be the recommended approach:
- Cloning (hg clone) the project and start making changes?
- Archiving (hg archive) the project and making a new repository (hg init) on the archived copy?
- Any other option I am not considering?
Thanks a lot.
I'm going to expand on the comment I made earlier suggesting that common functionality should be put into a library to avoid duplicated effort in maintaining the same code base in two places and suggest that if you can get away with making each instance a branch of the common codebase, then that's probably ideal. Hopefully that way if you fix a bug in one branch, it should be easy enough to merge branches or at least apply the changes in consistent ways easily.
If it uses the "exact same code as the mentioned project" and differs only in branding then you would probably want to branch off from the original project. Although initially things are identical client requirements may diverge (read branch) later on. Also the content files would begin to differ.
Short answer: Yes clone and branch off each project. With distributed revision control you can always merge if you need to.
Before you take anyone's (correct!) advice to branch, please read this article: http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/ and decide which of the many, valid ways to branch in mercurial is right for you. People hear "branch" and use hg branch
which is one way to branch, but not the only one or necessarily the right one.
Were I you I'd just clone, start working in the clone, and reconcile them later when you can (per Gian's great advice) refactor into a common base library.
精彩评论