# Source Code Control Komodo IDE only

Source code control (also called "revision control", "version control" or "code management") is the practice of managing changes to a set of files in a common repository. Files can be checked out from the repository, edited, reverted, merged, checked in or compared with other versions.

Komodo supports common operations for the following SCC systems:

- CVS
- Subversion (SVN)
- Perforce (P4)
- Git
- Mercurial (Hg)
- Bazaar (bzr)

From within Komodo, you can perform the following SCC actions:

- add files to the repository
- remove files from the repository
- compare files in the editor against their repository versions (a "diff")
- show a revision history for a file
- submit files back to the repository
- revert files to their previous state

Depots, repositories, branches, and projects cannot be created or configured from within Komodo. This must be done using the SCC software directly. Komodo's SCC features become available when files are checked out from the source code repository.

Komodo can work in conjunction with external graphial SCC clients such as TortoiseCVS and TortoiseSVN, and P4Win. However, the command line executables (i.e. `cvs`, `svn` and `p4`) must be present on the local system.

SCC functions are available in the following locations:

- Toolbox Context Menu: Right-click a file in the Toolbox to access the Source Control menu options. Source code control functions can also be performed on Folders in the Toolbox; right-click a folder and select Source Control on Contents to access the menu.
- Projects sidebar context menu: Right-click a file in the Project Manager to access the Source Control menu options. SCC functions can also be performed on Folders in the Toolbox; right-click a folder and select Source Control on Contents to access the menu. Two source code control options are available from the Projects sidebar and Toolbox context menus:
  - Source Control applies source code functions to the selected file only.
  - Source Control on Contents applies source code functions to the contents of the selected project or folder.
- Editor Pane: Right-click a file in the Editor Pane to access the Source Control menu options.
- Filename Tab: Right-click the filename tab above the Editor Pane to access the Source Control menu options.
- File Menu: Select the Source Control option from the File menu.

The Source Control submenu options are the same regardless of which method is used to access the menu.

## Using Source Code Control

### SCC Toolbar, Menus and Output Tab

#### Source Code Control Toolbar

Access common source code control commands from the SCC Toolbar at the top of the Komodo workspace. Refer to the command descriptions below for more information. The toolbar commands only apply to the file currently active in the Editor Pane.

#### Source Code Control Menus

To access source code control functions, select File|Source Control.

Invoke source code control context menus by right-clicking files or folders in the following areas:

- Projects sidebar
- Toolbox
- Editor Pane

#### Source Code Control Output Tab and Status Messages

The SCC Output tab is located in the Bottom Pane of the Komodo workspace. As you execute source code control commands, such as editing or checking in files, details of the commands are displayed on the SCC Output tab.

Error messages and warnings are also displayed on the SCC Output tab. Additionally, error messages and warnings are displayed on the status bar in the bottom left corner of the Komodo workspace.

### Source Code Control Commands

As described above, source code control commands are invoked from the toolbar, the File menu and the Source Control context menu. The following commands are available, depending on the context:

- Checkout: Launches the SCC Checkout wizard for fetching a local copy from a repository.
- Add: Add a file from a designated source code directory on your local drive to the source code repository.
- Edit: Unlock a file for editing.
- Revert Changes: Check the file back into the repository, abandoning any changes made since it was checked out.
- Remove: Delete the file from both the source code repository and the corresponding local directory.
- Update: When the local version no longer matches the repository version of a file, select this command to update the local version of the file.
- Diff (Compare Files): Compare the version of a file open in the Editor Pane with the version in the source code repository. Depending on the setting in Preferences, the diff display is shown on another Komodo editor tab or in a separate window. If the display style for diffs (Edit|Preferences|Source Code Control) is set to Create new window, press 'F9' or select Jump to Corresponding Line to open and/or shift focus to the original file in the Editor Pane. If viewing a diff in an editor tab, right-click and select Jump to Corresponding Line to shift focus to the editor tab containing the source code. Selecting this option opens the source code tab in the Editor Pane if it is not already open.
- History: Show the change history for the current file.
- Commit Changes: Submit the file back to the source code repository.

### File Status Icons

If Perforce, CVS or Subversion is enabled in Komodo's Preferences, the status of files in the source code repository is indicated by icons that appear on file tabs in the Editor Pane and next to files and projects on the Projects sidebar.

The icons can appear in a variety of combinations, depending on the status of the file and where they are displayed in the Komodo workspace. For example, a pencil icon next to a padlock icon on a tab in the Editor Pane indicates that the file has been locally modified and that the version of the file in your local directory is in sync with the version in the source code repository.

| The file is being added to the source code repository.
| The file is being deleted from the source code repository.
| The file has been locally modified.
| The version of the file in your local directory is in sync with the version in the source code repository (i.e. there are no pending updates from the SCC server).
| The file is read-only.
| The version of the file in your local directory is out of sync with the version in the source code repository.
| There is a conflict between the version of the file in your local directory and the source file that cannot be resolved by simply syncing your directory with the source code repository. The discrepancy must be manually resolved.

### Refresh Status

To refresh the SCC status of the current file do one of the following:

- Right-click the on file tab or within the editor pane and select Refresh Status
- Right-click on the file in the Projects sidebar and select Refresh Status
- Click Refresh Status on the File menu
- Press 'Ctrl' + 'K', 'R'

To refresh the SCC status of an entire folder, do one of the following:

- Right-click the on the folder and select Refresh Status
- Select the folder in the Projects sidebar and click Refresh Status on the File menu
- Select the folder in the Projects sidebar and press 'Ctrl' + 'K', 'R'

## SCC Checkout Wizard

Komodo's Checkout command launches a wizard which steps through downloading a local copy of a set of version controlled files (e.g. a branch).

### Step One: Set the SCC handler and the checkout data

Set the following options:

- SCC Handler: Choose the SCC system to use (e.g. svn, git, bzr, etc.)
- Checkout URL: Specify the specific URL of the branch being checked out (e.g. "http://svn.openkomodo.com/repos/komododoc/trunk/"). Specify the protocol to use (e.g. "http://", "rsync://", "git://" etc.).
- Save to: Specify the local directory to download to. Some SCC clients, such as CVS, will require that the specified directory already exists. Others, such as SVN, will create the directory if it does not exist already.

### Step Two: Customize the checkout parameters

Each SCC handler will have different additional paramenters which can be set:

- bzr:
  - Revision: The revision to check out. User the revision number or other revision identifier.
  - Hard-link working tree files where possible: Uses the "--hardlink" command line option.
- cvs:
  - Module: A path within the repository or a CVS module name (required field).
  - Branch or Tag: The branch or "sticky tag" of the branch to be checked out.
  - Specific date: Checkout version from a specific date. Accepts a variety of date formats (e.g. "YYYY-MM-DD HH:MM").
  - Checkout Type: Normal (for working on the modules) or Export (for making a software release).
- git:
  - Local repository: Used if the repository to clone is locally available. Uses the "--local" command line option.
  - Do not perform a HEAD checkout after cloning: Uses the "--no-checkout" option.
  - Make a bare GIT repository: Uses the "--bare" option.
- hg:
  - Revision: The revision number to check out. Current if unspecified.
  - Do not update the new working directory: Uses the "--noupdate" option.
  - Use pull protocol to copy metadata: Uses the "--pull" option.
  - Use uncompressed transfer (fast over LAN): Uses the "--uncompressed" option.
- svn:
  - Revision: The revision number to check out (HEAD by default).
  - Only check out the top folder: Users the "--non-recursive" option.
  - Omit externals: Uses the "--ignore-externals" option.

Options mentioned above are explained with more detail in the documentation for each SCC handler:

- Bazaar User Guide
- CVS Documentation
- Git Documentation
- Distributed revision control with Mercurial
- Version Control with Subversion:

### Step Three: Command line summary

The last step in the wizard shows the command to be executed based on the options chosen in the previous two steps. Click Checkout to run the command. Current status and command output will be displayed as the command runs.

Note: The SCC Checkout wizard does not correctly handle password authentication. SCC checkouts requiring password authentication should be done at the command line. You can do this by copying the command shown in the command line summary and pasting it into a terminal.

## Commit (Check-in to Source Control) Dialog

Clicking the Source Code Control: Commit button or selecting Commit Changes from the SCC context menu brings up the following dialog box.

The bottom pane shows a list of files for inclusion in the check-in. Komodo scans the current directory and all subdirectories under SCC control to populate this list and show the SCC status of each with an icon.

Check the box for each file you would like to include in the check-in, or use the Check All button. Use the Add File and Add Directory buttons to expand the list as necessary (e.g. files in adjacent or parent directories).

The Show Diff button shows a diff that includes all checked files. This can be used to create multi-file patches.

The Commit button starts the check-in. Command line output is displayed in the SCC Output tab in the bottom pane.

## Configuring Source Code Control Integration

### Configuring CVS

#### Basic CVS Configuration

1. If you have not already done so, install the cvs command-line utility on your system.
2. Check out files: Komodo does not have integrated SCC checkout functions. As necessary, run `cvs` from the command line (e.g. '`cvs checkout repository ...`').
3. Enable CVS support in Komodo: Under Preferences|Source Code Control|CVS and ensure that the "CVS Integration" option is checked and that the `cvs` executable is available in your `PATH` or is specified with a full pathname.
4. Open any file under CVS control in Komodo.

Komodo should now recognize that the file is under CVS source code control and the SCC menus and status icons should be enabled. If not, click Refresh Status on the File menu (or Ctrl-K, R) to force it to reset.

#### CVS Over SSH

Some CVS repositories (e.g. SourceForge) will only support CVS access over SSH (secure shell). When accessing these repositories, an SSH client is required. See Configuring SSH Support for CVS and Subversion below for details on configuring SSH support.

### Configuring Subversion (SVN)

#### Basic SVN Configuration

1. If you have not already done so, install the svn command-line client on your system.
2. Enable Subversion support in Komodo: Under Preferences|Source Code Control|Subversion and ensure that the "SVN Integration" option is checked and that the `svn` executable is available in your `PATH` or is specified with a full pathname.
3. Check out files: If you haven't checked out a local working copy of the files yet, use the SCC checkout wizard or run `svn checkout ...` from the command line.
4. Open any file under Subversion control in Komodo.

Komodo will recognize the files is under Subversion source code control and the SCC menus and status icons should be enabled. If not, click Refresh Status on the File menu (or Ctrl-K, R) to force it to reset.

#### SVN Over SSH

Some Subversion repositories only support Subversion access over SSH (secure shell). When accessing these repositories, an SSH client is required. See Configuring SSH Support for CVS and Subversion below for details on configuring SSH support.

### Configuring Perforce (P4)

#### Basic Perforce Configuration

1. If you have not already done so, install Perforce on your system.
2. Check out files: Komodo does not have integrated SCC checkout functions. As necessary, run `p4` from the command line (e.g. '`p4 sync path`').
3. Enable Perforce support in Komodo: Under Preferences|Source Code Control|Perforce and ensure that the "Perforce Integration" option is checked and that the `p4` executable is available in your `PATH` or is specified with a full pathname.
4. Set P4 environment variables: Unless Komodo is always started from a shell with all necessary P4 environment variables set (e.g. P4CLIENT, P4PORT, P4USER), you will need to specify them in Komodo's Environment preferences.
5. Open any file under Perforce control in Komodo.

Komodo should now recognize that the file is under Perforce source code control and the SCC menus and status icons should be enabled. If not, click Refresh Status on the File menu (or Ctrl-K, R) to force it to reset.

Users of Perforce's P4CONFIG feature may find that Komodo's source code control doesn't work unless Komodo is started from within the client view of the Perforce repository.

### Configuring Preferences

Use the Source Code Control page in Komodo's Preferences to configure Source Code Control integration. To open the Komodo Preferences dialog box, select Edit|Preferences.

## Configuring SSH Support for CVS and Subversion

Tunneling your CVS or Subversion connections over SSH can provide an added level of security for your repository access. CVS and Subversion use very similar methods for tunneling over an SSH connection. On Windows, download and install Putty or Cygwin to provide SSH support. Linux and OS X distributions typically include SSH support.

This is a basic guideline for configuring CVS and Subversion to use SSH, however, because server configurations can vary, you should consult the documentation for the control system you are using, or request help from you system administrator.

The use of Pageant (on Windows) or ssh-agent (OS X and Linux) with Komodo is strongly recommended.

#### Installing and Configuring Putty on Windows

Putty is a free SSH, Telnet and Rlogin client for Windows.

1. Install Putty

Download Putty (version 0.52 or greater) and associated programs from:

http://www.chiark.greenend.org.uk/~sgtatham/putty/

To connect to a server via SSH, the following programs are required:

- putty.exe
- puttygen.exe
- pageant.exe
- pscp.exe
- plink.exe

Ensure that the directory where Putty is installed is specified in your system's `PATH` environment variable.

2. Generate the Putty Key

Run the `puttygen` utility. Configure as follows:

1. Set Parameters: Select either "SSH2 RSA" or "SSH2 DSA".
2. Generate Key Pair: Click the Generate button to generate the key pair. While the key is being generated, move the mouse pointer around the blank space to provide key randomness.
3. Enter Key Passphrase: Enter and confirm a passphrase for the key. Remember the passphrase - it is required later.
4. Save Public Key: Click the "Save public key" button and store the key in a file called public1.key.
5. Save Private Key: Click the Save private key button and store the key in a file called private1.key, in the same directory as the public key.
   Note: The extension .ppk will be appended to the name specified (i.e. private1.key.ppk).
6. Copy Key Contents: Copy the contents of the public key field (at the top of the dialog box) to a file named public1-openssh.key. This key is required later.
7. Close puttygen

3. Load and Configure the Putty Authentication Agent

Run the `pageant` program. This loads the Putty Authentication Agent into the Windows System Tray.

Right-click the Pageant icon in the Windows System Tray. Select Add Key. Navigate to the directory where you saved the public and private keys in the previous step, and select the file private1.key.ppk.

4. Configure Putty To Use Pageant

Run the `putty` program. Configure as follows:

1. Specify Server: On the Session page of the Configuration form, enter the host name or IP address of the server.
2. Specify Protocol: On the Session page, in the Protocol field, select the "SSH" protocol.
3. Create Saved Session: In the Saved Sessions field, enter the host name again. Click the Save button.
4. Configure Connection: on the Connection page of the Configuration form, enter your username for the server in the Auto-login username field.
5. Configure SSH Protocol: On the SSH page of the Configuration form, specify "2" for the Preferred SSH protocol version.
6. Enable Agent Forwarding: On the Auth page of the Configuration form, check Allow agent forwarding. In the Private key file for authentication field, specify the path and filename of the private key created above (private1.key).
7. Save Session Information: On the Session page of the Configuration form, click the Save button.

5. Store the Public Key on the Server

You must store the public key file generated in step 2 (public1-openssh.key) on the CVS or Subversion server.

1. Open Command Prompt Window: Type `cmd` in the Windows Run dialog box.
2. Copy Public Key to Server: At the command prompt, enter:

       pscp c:\path\to\public1-openssh.key username@server.com:public1-openssh.key

   ...where c:\path\to\public1-openssh.key specifies the location of the key file created in step two, and username@server.com specifies your username and URL on the remote server. You are prompted to confirm the legitimacy of the host, and may be prompted to enter your password for the server.

3. Connect Using Putty: If necessary, run the `putty` program. In the Saved Sessions field, double-click the configuration created in Step 4. This establishes a connection to the server.
4. Configure the Key on the Server: After logging on to the server, enter the following commands to configure the SSH key:

       mkdir ~/.ssh
       chmod 700 .ssh
       cat ~/public1-openssh.key >> ~/.ssh/authorized_keys
       rm ~/public1-openssh.key
       chmod 600 ~/.ssh/*

5. Log Off and Exit Putty: Enter `exit` to close the session of the server.

6. Test the Configuration

Restart Putty. In the Saved Sessions field, double-click the configuration created in Step 4. You should not be prompted to log in. If you are, the configuration failed. Review the steps above and ensure that they were completed correctly.

#### Using CVS with Putty on Windows

Use the following additional steps if you are using CVS with Komodo.

7. Check Out a CVS Module

1. Create Local CVS Directory: Create a directory to store a copy of the CVS repository.
2. Copy Files to Local Directory: At a command prompt, enter:

       set CVS_RSH=plink
       set PLINK_PROTOCOL=ssh
       cvs -d :ext:username@cvs.server.com:/repository_name co cvs_module

   ...where username@cvs.server.com specifies your username on the CVS server and the URL of the CVS server, repository_name specifies the name of the repository on the server, and cvs_module specifies the name of the module in the chosen working repository.

   Login is handled by SSH. The files are copied to the local system. These environment variables do not interfere with non-SSH repositories.

Ensure that these variables are permanently configured in your system environment (for example, by adding them to the autoexec.bat file or configuring them in the system properties).

8. Using Komodo and CVS

Before starting Komodo, perform the following steps:

- Set PLINK_PROTOCOL=ssh: In the user environment, set the environment variable `PLINK_PROTOCOL` to "ssh".
- Set CVS_RSH=plink: In the user environment, set the environment variable `CVS_RSH` to "plink".
- Ensure Pageant Is Running: Run the `pageant` program to enable the authentication agent. Ensure that the private1.key is loaded.

  You can also execute Pageant and load the key via a batch file. For example:

      C:\PuTTY\pageant.exe c:\path\to\private.key c:\path\to\private2.key

#### Using Subversion with Putty on Windows

Use the following additional steps if you are using Subversion with Komodo.

7. Check Out a Subversion Repository

1. Create Local Subversion Directory: Create a directory to store a copy of the Subversion repository.
2. Copy Files to Local Directory: At a command prompt, enter:

       svn checkout svn+ssh://svn.server.com/repository_path/module/ local_path

   ...where svn.server.com specifies the server domain name of the Subversion server, repository_path/module specifies the path of the repository on the server, and local_path specifies the preferred location on your local system for your copy of the repository. The local_path can be ommited, in which case the local path is the last part of the repository_path.

   Login is handled by SSH. The files are copied to the local system.

Ensure that these variables are permanently configured in your system environment (for example, by adding them to the autoexec.bat file or configuring them in the system properties).

8. Using Komodo and Subversion

Set the following environment variables in Environment Preferences:

- `PLINK_PROTOCOL=ssh`
- `SVN_SSH=c:/path/to/plink.exe -batch`

Specify the full path to `plink.exe` using forward slashes "/" or escaped back slashes "\\". The `-batch` argument is used to prevent plink from prompting for user input. You can specify a specific private key by adding "`-i C:/path/to/private_keyfile`". For example:

    SVN_SSH="c:/path/to/plink.exe" -i "c:/path/to/private_keyfile"

You can use the Subversion configuration file instead of setting the SVN_SSH environment variable:

    [tunnels]
    ssh = $SVN_SSH plink.exe

This permits configuration of different connection types. The config file is located in the Subversion directory, typically inside the Application Data area of the user's profile directory (eg. C:\Documents and Settings\USERNAME\Application Data\Subversion). See the Subversion documentation for more information.

If you use "plink = $SVN_SSH plink.exe" in the tunnels section of the config file, use "svn+plink" for your checkout url rather than "svn+ssh".

Run `pageant` to enable the authentication agent. Ensure that the private1.key is loaded. You can start Pageant and load the key using a batch file. For example:

    C:\PuTTY\pageant.exe c:\path\to\private.key c:\path\to\private2.key

#### Configuring CVS with Windows/Cygwin-SSH or Linux/SSH

To configure CVS to use SSH, refer to http://forrest.apache.org/docs_0_70/howto/cvs-ssh/howto-cvs-ssh.html.

On all platforms, create an environment variable as follows:

    CVS_RSH=ssh

CVS determines when to use SSH, depending on how you check out the modules. If you use the "cvs login" method with the "pserver" protocol, CVS does not use SSH, even if CVS_RSH=ssh is set in the environment.

On Windows, also configure the cygwin SSH Agent as follows:

1. Open a cygwin shell.
2. Enter `exec ssh-agent bash`.
3. Enter `ssh-add` /path/to/public/key (e.g. '`ssh-add /.ssh/id_rsa.pub`')
4. To check out a CVS module, enter:

       cvs -d :ext:username@cvs.server.com:/repository_name co cvs_module

   ...where username@cvs.server.com specifies your username on the CVS server and the URL of the CVS server, repository_name specifies the name of the repository on the server, and cvs_module specifies the name of the module in the chosen working repository.

5. Start Komodo within the cygwin shell as follows:

       /path/to/komodo/bin/komodo

After completing the configuration steps above, follow these steps to open Komodo with CVS-SSH enabled:

1. Open a cygwin shell.
2. Enter `exec ssh-agent bash`.
3. Enter `ssh-add` /path/to/public/key (e.g. 'ssh-add ~/.ssh/id_rsa.pub')
4. Start Komodo within the cygwin shell as follows:

       /path/to/komodo/komodo.exe

#### Configuring Subversion with SSH on Linux or Mac OS X

Subversion determines when to use SSH depending on how you check out the modules. If you use http:// or file:/// URIs, Subversion will not use SSH.

To use subversion with SSH, do the following before starting Komodo:

1. Open a shell.
2. Enter `exec ssh-agent bash`.
3. Enter `ssh-add` /path/to/public/key (e.g. '`ssh-add ~/.ssh/id_rsa.pub`')
4. To check out a Subversion module, enter:

       svn checkout svn+ssh://svn.server.com/repository_path/module/ local_path

   ...where svn.server.com specifies the server domain name of the Subversion server, repository_path/module specifies the path of the repository on the server, and local_path specifies the preffered location on your local system for your copy of the repository. The local_path can be ommited, in which case the local path is the last part of the repository_path.

5. Start Komodo from within the shell. Komodo inherits the environment set in the shell by ssh-agent

Refer to http://svnbook.red-bean.com/en/1.0/ch06s03.html#svn-ch-6-sect-3.3 for more detailed instructions, including information on configuring svn+ssh to be non-interactive (i.e. no password prompt).