Category Archives: Git

Managing Diagram Versions with GIT

You have several options for versioning your IDMS diagrams, but I think Git is one of the most interesting today, because it allows you to do versioning WITHOUT the need for a server AND it is free 😉 On top of that, Eclipse comes with a fairly easy to use interface for Git. This blog post shows you how to start versioning your IDMS diagrams on your local machines TODAY.

In the following example, all IDMS diagrams are kept in a project called ‘Getting Started’. That project is located in the Eclipse workspace folder and is visible in both the Package Explorer and Project Explorer views.  The goal is to create a local Git repository and move the diagrams into that repository so that each committed change leaves a trace in the repository and can be used for comparisons or to be restored should the need arise.

First of all, make a backup of your Eclipse workspace folder.

Next, open the Git perspective by selecting the Window/Perspective/Open Perspective menu item and then selecting it in the list of available perspectives :

01_open_git-perspective

The leftmost view (the Git Repositories view) in the Git perspective allows you to create a new local Git repository; which is (just) a folder on your file system containing your project(s) and Git’s own folders and files needed for managing your files and versions.  Click on the Create a new local Git repository link :

02_create_new_local_repo_1

Select an empty folder on your file system AND, for performance reasons, make sure that folder is NOT a subfolder of your Eclipse workspace folder :

03_create_new_local_repo_2

After pressing the Finish button, the Git Repositories view shows you your new local repository, with the ‘NO-HEAD’ indicator next the folder name (‘IDMS’ in our example). That indicator will change to ‘master’ later on and represents the name of the branch you have checked out (I won’t discuss branching and merging here).  Apart from a folder called ‘.git’, the ‘Working Tree’ is empty because you have not yet committed any diagrams yet.

04_local_repo_created

I suggest you create a general Eclipse project in your new IDMS folder (i.e. outside the Eclipse workspace); start the Eclipse General project creation wizard via the File/New/Project… menu item.

05_create_new_general_project_1

Give your project a name (e.g. ‘diagrams’) AND make sure to uncheck the ‘Use default location’ checkbox; select the ‘IDMS’ folder on your file system :

06_create_new_general_project_2

The new project will now be visble in the Package Explorer and Project Explorer views (despite the fact that it is not stored in your workspace folder).

Copy (or move) your diagram files in either the Package Explorer or Project Explorer views.  There are several manners to accomplish this, if you want to move them, just select your diagram files and drag them to your newly created ‘diagrams’ project :

07_copy_diagram_files_1

Your Package Explorer (or Project Explorer) view should now look like this :

08_copy_diagram_files_2

You are now ready to commit your diagram files to your local Git repository.  Switch to the Git perspective by pressing the Git perspective’s toolbaar button on the top right of your screen :

09_switch_to_git_perspective

In the Git Staging view you will now see your diagram files in the ‘Unstaged Changes’ section.  Drag them to the ‘Staged Changes’ section, which represents the so-called Git index (or staging area); this is where you prepare your commits.

10_about_to_commit_1

Finally, enter a commit message in the appropriate section; press the Commit button :

11_about_to_commit_2

You have now successfully committed your first diagram in your local Git repository.  You will notice that a file called ‘.project’ is now shown in the ‘Unstaged Changes’ section; this file is needed by Eclipse and contains your project name.  Drag this file to the Git Index. We could create a separate commit for this file but Git allows you to add (and modify and remove) additional items, so press the Amend (Edit Previous Commit) button

12_about_to_commit_3

You have the chance to modify the commit message before you press the Commit button :

13_about_to_commit_4

Unless you rename your project, you will not have to go through the .project file hassle again.

Switch back to the Java perspective to reveal the Package Explorer view again :

14_switch_to_java_perspective

The nice thing about having your diagrams versioned is the fact that you can compare 2 versions, e.g. the Package Explorer (and Project Explorer) view’s context menu have a Compare With menu item, offering several options.  If you want to compare your workspace version with the last committed version, select the context menu’s HEAD Revision menu item :

15_compare_with_1

For demonstration purposes, I’ve added an email address field to the EMPSCHM schema’s EMPLOYEE record (without committing yet); when comparing the workspace version with the last committed version, a compare editor will open, showing you the differences between the 2 :

16_compare_with_2

Note that comparing 2 diagram versions will only be practical if you save your diagrams with the .schemadsl file extension; the original .schema file extension contains fairly complex XML, so comparing files with that file extension will be challenging.

The Git perspective also has a History view.  If you select the History view and then select your local repository in the Git Repositories view, you will get a list of all commits for the current branch (‘master’ in our case).  Just play around with this; you will see that you can open previous versions of your diagrams…

17_history

(note that I added some commits for demonstration purposes).

If you want to learn more about Git, you can find a lot of tutorials and books on the Internet.  This blog post was just to inform you about the possibilities it offers for you as an IDMS DBA.

Advertisements