{"id":96,"date":"2025-02-08T10:33:26","date_gmt":"2025-02-08T10:33:26","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2009\/01\/07\/share-common-projects-with-two-different-projects-in-cvs\/"},"modified":"2025-02-08T10:33:26","modified_gmt":"2025-02-08T10:33:26","slug":"share-common-projects-with-two-different-projects-in-cvs","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/share-common-projects-with-two-different-projects-in-cvs\/","title":{"rendered":"Methods to Share Common Code Between Two CVS Projects"},"content":{"rendered":"\n<p>In <strong>CVS (Concurrent Versions System)<\/strong>, <strong>sharing common code<\/strong> between two different projects can be achieved using <strong>modules, symbolic links, or branching and merging<\/strong>. Below are some methods to accomplish this:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Methods to Share Common Code Between Two CVS Projects<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Using CVS Modules File (Best Practice for Common Code)<\/strong><\/h3>\n\n\n\n<p>The <strong><code>modules<\/code><\/strong> file in CVS allows you to define virtual modules that can include multiple directories or files from different locations in the repository.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>How to Use Modules File:<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Edit the <code>CVSROOT\/modules<\/code> file. <code>cd \/path\/to\/CVSROOT vi modules<\/code><\/li>\n\n\n\n<li>Add an entry to combine multiple directories under a common virtual module. <code>shared_lib -a project1\/common_lib project2\/common_lib<\/code>\n<ul class=\"wp-block-list\">\n<li><code>shared_lib<\/code> is the virtual module name.<\/li>\n\n\n\n<li><code>project1\/common_lib<\/code> and <code>project2\/common_lib<\/code> are the directories containing the shared code.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Check out the new virtual module: <code>cvs checkout shared_lib<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Advantages:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Easy to manage shared code between projects.<\/li>\n\n\n\n<li>Changes to the shared module reflect in both projects.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Disadvantages:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Complex if there are too many shared directories.<\/li>\n\n\n\n<li>Requires manual updates to the <code>modules<\/code> file.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Using Symbolic Links (on the Server-Side)<\/strong><\/h3>\n\n\n\n<p>You can create <strong>symbolic links (symlinks)<\/strong> on the CVS server to share directories or files between multiple projects.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>How to Create Symbolic Links:<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to the <strong>CVS repository directory<\/strong> on the server.<br>Example: <code>\/cvsroot\/project1<\/code> and <code>\/cvsroot\/project2<\/code>.<\/li>\n\n\n\n<li>Create a symbolic link from the common directory: <code>ln -s \/cvsroot\/project1\/common_lib \/cvsroot\/project2\/common_lib<\/code><\/li>\n\n\n\n<li>When users check out <code>project2<\/code>, they will see the <code>common_lib<\/code> directory linked from <code>project1<\/code>.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Advantages:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Simple to implement on Unix-based systems.<\/li>\n\n\n\n<li>Changes to the shared directory are automatically reflected.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Disadvantages:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Not portable on Windows-based CVS servers.<\/li>\n\n\n\n<li>Symbolic links are not visible in CVS client history or commands.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Branching and Merging for Shared Code<\/strong><\/h3>\n\n\n\n<p>You can maintain <strong>shared code on a separate branch<\/strong> and merge it into both projects when necessary.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>How to Use Branching and Merging:<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a branch for the shared code: <code>cvs tag -b shared_branch project1\/common_lib<\/code><\/li>\n\n\n\n<li>Merge the branch into <code>project1<\/code> and <code>project2<\/code> periodically: <code>cvs update -j shared_branch<\/code><\/li>\n\n\n\n<li>Commit the merged changes: <code>cvs commit -m \"Merged shared_branch into project1\"<\/code><\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Advantages:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Provides better control over when shared code is updated.<\/li>\n\n\n\n<li>Suitable for large projects with independent development cycles.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Disadvantages:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Requires manual merging and conflict resolution.<\/li>\n\n\n\n<li>More complex workflow for teams unfamiliar with branching.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. External Scripts for Code Synchronization<\/strong><\/h3>\n\n\n\n<p>Write <strong>custom scripts<\/strong> to copy or sync shared code between projects at regular intervals.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example Script (Shell)<\/strong>:<\/h4>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-meta\">#!\/bin\/bash<\/span>\nrsync -av \/path\/to\/project1\/common_lib \/path\/to\/project2\/common_lib\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Run this script after updates to keep the shared code in sync.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Advantages:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Simple to automate.<\/li>\n\n\n\n<li>Ensures both projects always have the latest shared code.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Disadvantages:<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Not integrated with CVS.<\/li>\n\n\n\n<li>No version history in the second project.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Which Method Should You Choose?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Modules File:<\/strong> Best for combining existing repositories into a single shared module.<\/li>\n\n\n\n<li><strong>Symbolic Links:<\/strong> Ideal for Unix-based CVS servers with simple sharing requirements.<\/li>\n\n\n\n<li><strong>Branching and Merging:<\/strong> Best for <strong>large projects<\/strong> with controlled updates to shared code.<\/li>\n\n\n\n<li><strong>Scripts:<\/strong> Useful for <strong>automation and synchronization<\/strong> in specific environments.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In CVS (Concurrent Versions System), sharing common code between two different projects can be achieved using modules, symbolic links, or branching and merging. Below are some methods to accomplish this: Methods to Share Common Code Between Two CVS Projects 1. Using CVS Modules File (Best Practice for Common Code) The modules file in CVS allows&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3936,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[20],"tags":[1979,369,2853,2854,2852,2855,2471,2849,1122,545,2850,593,1236,2856,1078,2848,2851,213],"class_list":["post-96","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cvs-concurrent-version-system","tag-common","tag-cvs","tag-cvs-different-projects-sharing","tag-cvs-guide","tag-cvs-projects-sharing","tag-cvs-tutorial","tag-different","tag-different-projects","tag-guide","tag-how","tag-multiple-projects","tag-process","tag-projects","tag-projects-in-cvs","tag-share","tag-sharing-projects-with-cvs","tag-tow-different-projects","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":48474,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/96\/revisions\/48474"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3936"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}