Introduction: Using CVS for Version Control with Drupal 8
This Tutorial will show how to transfer a Drupal 8 website from a localhost environment running WampServer to a remote hosting platform using CVS for version control.
CVS was the previous default for core, module, & theme project management at drupal.org but the development community has now moved on to GitLab & GitHub.
This Tutorial will instruct users on how to transfer files from a local Windows desktop or laptop development environment to a remote server, sandbox, or code repository. You can deploy to a production server at a web hosting service.
Step One: Install CVS in the Development Environment
As Git has rapidly surpassed CVS in popularity in version control protocols, the best way to currently implement CVS for file transfer from a desktop environment is VirtualBox, XAMPP, or WampServer. Avoid TortoiseCVS or WinCVS as outdated.
On Ubuntu, CentOS, RHEL, etc. Linux servers running Sudo:
sudo apt-get install cvs sudo apt-getinstall xinetd cvs -d /path/to/new/cvs/repo init sudo /etc/init.d/xinetd start
On Gentoo, ChromeOS, & other Linux OS servers running Portage:
root#emerge --ask cvs
The main principle is for the desktop workstation environment to run a mirror of the web server configuration & then use command line for the Version Control synchronization.
Agile team members can run Drupal 8 in their choice of development server locally while using CVS to transfer files between a master repository online, i.e. staging.
It is recommended to set up a dev.example.com staging domain for all Agile team members to transfer files to for testing, then upgrade the production site directly.
Step Two: Configure CVS on the Remote Web Server
In order to set up CVS version control on a Linux web server, login with SSH Access using a CLI utility like PuTTY & run the following commands:
cvs -d /usr/local/cvs command
This will set the CVS directory for a global directory. Another option:
cvs -d :pserver:user@example.com:/usr/local/cvs command
Use this command in PuTTY if your web server requires a password to login.
Next, set the CVSROOT environment variable on the global directory:
CVSROOT=/usr/local/cvs export CVSROOT echo$CVSROOT /usr/local/cvs
After setting the global directory settings, create the staging subdomain environment with the version control information managed by CVS across new modules & themes.
Step Three: Checkout Code on the Staging Subdomain
This workflow includes a team of Agile programmers connected to a single staging subdomain for testing code changes on a Drupal 8 project with CVS version control.
Running the same code on the workstations as the staging subdomain, use the CVS checkout commands to merge files between distributions & log line changes directly.
cvs -d :pserver:user@example.com:/usr/local/cvs command
The “checkout” command will transfer the entire Drupal 8 website from the localhost development environment to the global directory defined by CVSROOT config settings:
cvs checkout wamp/www/site1
The “checkout” can be used to move a single Drupal 8 module or theme from the localhost development environment to the global directory depending on the file path:
cvs checkout path/to/mymodule
Use the staging domain as the CVS global directory for the programming team where new code can be tested securely in isolation before porting to the production website.
Step Four: Import Files from Staging to Production Website
After the new code, modules, or themes have been tested in the staging subdomain, use the import command with CVS on the production website to pull changes to live:
cvs import -m "log msg" projname vendortag releasetag
In order to successfully complete the transfer, the project name, vendor tag, and release tag variables must be set on the staging subdomain. Use the “update” command:
cvsupdate -m "comment text message" project tag version
Set the Version Control variables in advance as part of project management. Use the import & update commands in tandem with diff & commit commands for file versioning.
Step Five: Update the Production Website with Patches
The differential command (diff) and commit command (commit) are both used in Drupal code Version Control for new module/theme development in Agile programing teams.
Programmers can run the diff command on files to synchronize between the local development environment & the staging subdomain or to push changes to production.
cvs diff
Running the diff command on a file will provide the complete Version Control history of the changes, such as:
cvs diff cvs diff: Diffing ... Index: hello.ext =================================================================== RCS file: /usr/local/cvs/mysite/hello.ext,v retrieving revision 1.2.1.x diff -r1.2.1.x hello.ext 6a7 > print ("Hello, world!"); cvs diff: Diffing a-file1 cvs diff: Diffing a-files/ex1 cvs diff: Diffing b-site/files/ex2
This ability to view the code changes between files as well as version number, release date, etc. is considered a major aspect of contemporary DevOps surpassed by Git.
Like Git, CVS offers a powerful command line ability to commit code changes or version changes to files that can be done with commands such as:
cvs commit -m "commit message text" filename.ext
CVScommit commands were the previous engine behind module & theme Version Control on the drupal.org website before the community transitioned to GitLab in 2018.
The links above contain further resources for advanced use of CVS commands.
Conclusion: Use Git over CVS for Better Version Control
Drupal administrators can make use of the clone, import, checkout, & commit commands using CVS for Version Control & command line file transfer management.
As the desktop utilities for CVS are not well developed, use VirtualBox, WampServer, XAMPP, & Docker Desktop as the best ways to manage CVS on localhost web servers.
Check out these top 3 Drupal hosting services: