C1 CMS and Mercurial

How to get CMS Website files running under the Mercurial version control system

Mercurial is a free, distributed source control management tool. It efficiently handles projects of any size and offers an easy and intuitive interface.

You can use Mercurial to version-control your C1 CMS Website. To version-control a C1 CMS Website with Mercurial version control system, take these steps:

  1. Install the required software
  2. Create a repository
  3. Create the .hgignore file
  4. Protect the repository files
  5. Make your first check-in

Installing the required software

Mercurial has a console interface. For the GUI, we recommend installing TortoiseHg, a Windows shell extension and a set of applications for Mercurial.

Tip: You can download and install both Mercurial and TortoiseHg as a bundle in one step from http://mercurial.selenic.com/downloads.

Creating a repository

Mercurial keeps all version history in a single .hg folder located in the root of the repository.

You will likely have one of these setups:

Setup A. The repository's root is the website's root:

  • /Website
  • /Website/.hg

This setup works perfectly if you don't have other Visual Studio projects you would like to keep in the same repository, or if you're using a shared FTP folder and you don't have access to other folders.

Setup B. The repository's root is in the one of the parent folders.

  • /.hg
  • /MyWebsite

This setup allows you to keep multiple folders (with Visual Studio 2010 projects etc) related to your website.

To create repository:

  1. In Windows Explorer, create a folder that will serve as your repository's root folder.
  2. Right-click the folder and select TortoiseHg | Create Repository Here.
  3. Keep the Add special files ('.hgignore', ...) option checked.
  4. Click Create.

Creating the .hgignore file

The .hgignore file contains a list of files that Mercurial shouldn't be version controlling. Based on your repository setup (A or B - see above), this file should have this content:

Setup A (the repository's root == the website's root):

syntax: glob
App_Data/Composite/ApplicationState
App_Data/Composite/Cache
App_Data/Composite/LogFiles
App_Data/Composite/PackageLicenses
App_Data/Composite/Versioning/ContentVersioning
App_Data/Composite/Packages
App_Data/Composite/Temp
App_Data/Media
App_Data/PackageCreator
App_Data/dtSearchIndex
Bin/*.xml
Bin/System.Web.*
Bin/Microsoft.Practices.*
Composite
 

Note: If downloading, make sure to have a period ('.') preceding this file name (.hgignore).

Setup B (the repository's root == the website's parent folder):

syntax: glob
<WebsiteFolderName>/App_Data/Composite/ApplicationState
<WebsiteFolderName>/App_Data/Composite/Cache
<WebsiteFolderName>/App_Data/Composite/LogFiles
<WebsiteFolderName>/App_Data/Composite/PackageLicenses
<WebsiteFolderName>/App_Data/Composite/Versioning/ContentVersioning
<WebsiteFolderName>/App_Data/Composite/Packages
<WebsiteFolderName>/App_Data/Composite/Temp
<WebsiteFolderName>/App_Data/Media
<WebsiteFolderName>/App_Data/PackageCreator
<WebsiteFolderName>/App_Data/dtSearchIndex
<WebsiteFolderName>/Bin/*.xml
<WebsiteFolderName>/Bin/System.Web.*
<WebsiteFolderName>/Bin/Microsoft.Practices.*
<WebsiteFolderName>/Composite
Here you should replace <WebsiteFolderName> with the actual name of your website's folder.

NOTE: If downloading, make sure to have a period ('.') preceding this file name (.hgignore).

Protecting the repository files

If your .hg folder is in website's root (Setup A - see above), for security reasons, you need to deny the HTTP access to those folders.

To deny this access:

  1. Edit web.config of your website.
  2. Add the <security> section to configuration/system.webServer:
<configuration>
  <system.webServer>
    <!-- other settings -->
    <!-- Hiding code repository -->
    <security>
      <requestFiltering>
        <hiddenSegments>
          <add segment=".hg" />
        </hiddenSegments>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

That will protect both the .hg folder and the .hgignore file.

Making your first check-in

  1. In Windows Explorer, right click the reprository's folder and select TortoiseHg | Add files. (In the window that opens, all the files will be preselected for the first time.)
  2. Click Add.
  3. In Windows Explorer, right click the reprository's folder and select Hg Commit.
  4. In the window that opens, rite a comment and click Commit.

Browsing revision history

Hg Workbench will allow you to browse revision history and do all other version control related operations.

  1. In Windows Explorer, right click the reprository's folder and select Hg Workbench.
  2. In the window that opens, work with your versions.