Answer the question
In order to leave comments, you need to log in
How to partially merge projects through version control?
I’ll note right away that I only worked with Mercurial, but I think advice from Git users is also suitable, since the principle of operation is similar.
There are several web projects (sites) on a common code base (self-written cms), which is constantly updated. Unique modules and components of the projects are also constantly updated, everything happens at different intervals depending on the flaws found and the requirements of the projects.
Projects have an engine folder with the same files, a modules folder with mixed files (some are used in all projects, some are unique to a particular project and others have nothing to do with them) and a templates folder, where there is a folder with a project template and a folder with a "default" template - a blank for new projects. All projects are carried out only by me, in the future I hope to connect assistants, but with such a zoo of versions it is still difficult, and so far this is not about that.
Let's call files with code that is used in all projects - "common components" , and files with code that is unique in each project - "unique components" .
Now I have my own independent Mercurial running on each project, just to maintain version history and push to a remote server. In order to transfer common components between projects, I make a comparison and stupidly copy from folder to folder, which is not convenient -every time I have to remember in which file I made updates since the last copy, and whether I corrected something else in that project that I forgot about, which is fraught with killing the necessary code.
What I need:
- to select a base of common components from all projects, without unique ones (except perhaps a default template, so that there is something to base new projects on). - if a unique component
is
updated in one project , then it should be added to the commit of this project, but should not affect file changes in other projects. And if a file from the shared components has been updated , then it should become available for updating in all projects.
- the ability to update the entire codebase of common components on all projects at once.
- the ability to create new projects, both on the basis of only a common base and any of the projects, but at the same time be updated further only with "common components", and not drag changes in the project, with a short slope.
Answer the question
In order to leave comments, you need to log in
That's right, Subrepository
will help you for identical files .
In Mercurial, this is a very interesting thing. The algorithm of work is something like this:
Inside your project, create a folder with a subrepository, for example library, initialize (or clone a ready-made) project of the project's shared library in it:
$ mkdir library
$ cd library
$ hg init
Specify that this folder is a subrepository, for this a .hgsub file is created in the root project and the library is specified there: [hooks]
preupdate = ./library/hgsubupdate.sh
And to the hgsubupdate.sh file: About the first. As I understand it, you just need to separate the common code into a separate repository. Further, for local projects, it is easy to do
hg pull http://bla.com/main/baseproject
git pull http://bla.com/main/baseproject.git
I'm not sure how correct my answer will be, you asked about the version control system, but I would recommend using a dependency manager. If you work with php, then there is composer, which does everything that was indicated in the first question (not sure, really about other languages). On the other two points, I join @maxaon
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question