Source Control for Oracle

Branching and merging

Many development projects involve creating branches (or "forks") for a feature, release, or other development milestone. A branch is essentially a copy of the code base that shares its history. Reincorporating the changes from a branch is known as merging.

Development projects typically have:

  • trunk, the main code base, and branches which diverge from it
  • one or more branches, copies that diverge from the trunk

For more information about the concepts behind branching and merging, see:

For a general introduction to source control concepts, we recommend Version Control by Example (free PDF) by SourceGear founder Eric Sink.

Working with branches in Source Control for Oracle

You can work with branches in Source Control for Oracle, but you can't create or merge branches. 

To branch with Source Control for Oracle, you need to create the branch using your source control system, then link to the appropriate branch in a Source Control for Oracle project.

There are two approaches to working with branches:

Unlink and relink the branch from the source control project

In this approach, you continue working on the same schema, but link it to the branch in your source control system.

Once the branch is created, remove the source control project from Source Control for Oracle, then link the schema again in a new Source Control for Oracle project. In step 2 of the new source control project wizard, specify the location of the branch in source control.

Create a new database for the branch

In this approach, you create the branch in your source control system, then create a new schema to link with it.

Create a new empty schema, and link it to source control in a Source Control for Oracle project. When you link, specify the location of the branch in source control, then on the Get latest tab, update the schema with the latest version from source control.

Merging

Source Control for Oracle doesn't provide automatic or line-by-line merging. You can use Source Control for Oracle or Schema Compare for Oracle to merge at an object level, but not choose line-by-line changes.

When you merge with Source Control for Oracle or Schema Compare for Oracle, you choose a version of each object to keep. For example, you might keep the trunk version of a table and the branch version of a view.

There are three approaches to merging:

Merging using your source control system

You can manually merge the branch changes back into the trunk using your source control system as you would for application code.

We recommend this approach if the merge is complex, or if there are conflicts; for example, if the same object has been modified in both the branch and the trunk.

When merging manually, make sure referential integrity is maintained or the database may be left in an invalid state.

Your source control system may include auto-merging functionality that simplifies manual line-by-line merges.

Merging using Source Control for Oracle

If you don't need to do a line-by-line merge, you can merge with Source Control for Oracle.

To do this:

  1. In Source Control for Oracle, make sure you have a schema linked to the branch in your source control repository.
  2. Get the latest version and check in any outstanding changes.
  3. Remove the source control project on the right-click menu.
  4. Create a new source control project linking the schema to the trunk.
  5. Go to the Check in tab.
    The tab shows the changes to the branch as changes to check in.
    If there are conflicts, choose Use database version to override the trunk with the objects from the branch.
  6. Check in the changes.

    The trunk is updated with the branch changes.

Merging using Schema Compare for Oracle

If there are no conflicting changes between the branch and the trunk, you can merge automatically using Schema Compare for Oracle.

To merge branch changes into the trunk with Schema Compare for Oracle:

  1. In Source Control for Oracle, make sure you have a database linked to the trunk.
  2. Use your source control system to create a local copy of the latest branch version (for example, by running an SVN checkout).
  3. In Schema Compare for Oracle, create a new project. Set the local copy of the branch as the source, and the trunk database as the target.

    For more information, see Setting data sources.
  4. Compare the data sources.

    Schema Compare shows the differences between the branch and the trunk.

  5. In the Results pane, select the objects from the branch that you want to merge into the trunk, and run the deployment wizard to Using the Deployment Wizard
    The trunk is updated with the changes from the branch.
  6. In Source Control for Oracle, on the Check in tab, check in the trunk changes to source control.

Didn't find what you were looking for?