Powerbuilder and Source Code Control (SCC)

I posted about Source Code Control in general earlier. Various source code control software exist, named as Version Control Systems(VCS) or Source Control Systems (SCS) or even Source Code Control System (SCCS)*. If you noticed, these tools works at the file level – the smallest unit that can be handled in any Operating System. Typically, you open your version control system, check out necessary files, work with them and check back in.

*PB calls refers to the SCCS simply as Source Control System (SCS). In this post we will refer to it as SCS or as SCC tool, as it has to implement Microsoft SCC API.

Source Control in an IDE

If you are working in an IDE environment, this will pose a problem. You edit, compile and test from within IDE, why would you want to go out to the OS just to work with files from version control system and then come back into IDE to complete the development cycle, and go back out to the OS and the SCC tool again to check back the work. (Trust me, I’ve done this. Typically, you may do this with Java or C/C++ files, depending on the IDE/editor you use). To alleviate it, the IDE/Editor may provide toolbar buttons to execute OS commands, so you can execute them from within the IDE/Editor. But, it’s not tightly coupled.

Seriously, wouldn’t it be nice to have SCC integrated into the IDE? But then again, considering how many different SCC tools exist, IDE builder can’t add support for every possible tool in the IDE. This would be easy if there was only one type of SCC interface. Or, if all the tools follow a certain standard!

Actually, several such standards exist; on Windows it’s pretty much based around Microsoft’s Source Code Control (SCC) API. By implementing this API as the interface to their own SCS (VCS), vendors can “standardize” their product. Of course, internally they could do totally different things, but as long as they provide standard set of interface functions, they will all look and work the same to system using them. If IDE tools can build their SCC operations around these API, then they will be able to “talk” to the SCS (or VCS) from various vendors easily. Both Visual Basic and PowerBuilder offer such connectivity.

PowerBuilder and Source Control

But, PB poses a further challenge. Where as, Visual Basic saves it’s objects and programs as files in the Operating System level, PB saves it’s objects and the source code in a library file called PBL (pibble). The smallest unit the OS sees in a PB application is a PBL file and not individual object files. So, we cannot really track the changes in a PB application correctly, if we do check-in/check-out at PBL file level. What we need is a way to track at the individual object level, smallest unit of source code entity in PB.

PB offers a plugin approach for the 3rd party SCC tool to work with it. It also provides a wrapper to the SCC API mentioned above, so the Source Control Systems themselves, don’t need to know about PB objects. PB will export and import objects to files before passing the control to SCC plugin software.

In this post, we will see how PowerBuilder can be setup to work with different SCCS tools. Particularly we will explore PB Native, PVCS and later we will explore how PB can be made to work with SVN. Only SCS (or VCS) that implement Microsoft SCC API will work with PB.

Setting up Workspace to use SCC provider (SCS or VCS)

First of all, to enable Source Code Control in a PB application, you need to pick your SCC provider. You do this by right clicking on the Project workspace and choosing Source Control System (SCS) tab. Here you enter the user credentials for connecting to the SCC provider.  Once you connected,  SCC status for every object will show up as a small icon before the object name in the System Explorer. (A + sign marks a new object not in SCC yet, a small circle refers to those that exist in the repository, a check mark refers to object checked out  – either by you or others.

pb_pvcs_connection

As shown, there is a drop list to choose the SCC provider to use for the current PowerBuilder project. The SCC wrapper inside PB takes care of translating to and from the SCC tool. My friendly fetcher, Registry Scanner, came to the rescue. I searched for “Merant Version Manager” (another incarnation of good old PVCS).  I found it – it is stored neatly in the registry.

Where is this information stored?

I really wanted to find out where all this information is stored. Workspace file (.PBW) is a logical place to store it. But, it is not stored in this file. The .pbw file seems to be a list of the targets in the project workspace. Then I looked around and found that it was stored in registry.

2013-12-17 15_55_14-RegScanner

2013-12-17 16_03_18-Registry Editor

 

When you choose source code control provider in the PB workspace properties, PB actually stores the details in a key named SourceControl.  If this is missing, then that means you didn’t setup SCC in Workspace properties. So, if you have a workspace that has problem with SCC on open, you may never be able to open the workspace. In such case, if you rename or delete the SourceControl key, PB will no longer try to connect the workspace to SCCS.

Notice, PB had replaced all the “\” with $. PB has quirky ways of escape chars. Tilde (~) for example is used as an escape character a lot in PB.

Incidentally, the above image shows other keys like Connection, MRUList, Painters etc. These are the “Recent Objects”, “Recent Connections”  and “Recent Workspaces” listed under File menu.

Object level Tracking in SCCS

Remember, the PB code is now tracked at the individual object level and any SCCS will only know to store files. So, how does PVCS know about objects in PB? It doesn’t!! This is where PB export files come in handy. Every type of object can be exported to a text file with specific extension. (See here for a nice post on exporting PB objects as files). If that link ever breaks down, see here for my take on it.

When you checkout/Get a copy of the file to your working directory, PB (the SCC wrapper) exports a file to the File System. The file is made writable if it’s being checked out. In that case, the object is also locked in PB IDE. Anything that can be exported as a text file will be stored in the SCC repository. So, a PB target (which is a file with .pbt extension) will have SCC status. All PB objects such as windows, applications, Datawindows etc will have SCC status. Right clicking on such objects in the System Explorer will show additional, SCC related, options in the popup menu. A PBL itself cannot be checked into repository, at least not from within PB, so right clicking on a PBL will not include SCC options in the menu. In general, the SCC options will show up, only if the Workspace is setup to use Source Control and the object is “SCC”able.

pb_vcs_context_menu

What is a PBG file and why do we need?

To keep track SCC status of the objects in a library, PowerBuilder uses a .PBG file. Imagine, once all the objects are exported and checked into PVCS, how will you know, which objects goes to which PBL, in case you ever have to recreate the PBL file from souces (Bootstrapping for e.g). This is where the PBG file comes into the picture. It has sort of a mapping for each object and the library it’s supposed to be in. This file essentially contains a list of all the objects in a PowerBuilder library (PBL) file or conversely, it tells us which these objects (really, export files) will need to be loaded into, the moment they leave SCCS. When objects are added or deleted in the library and checked into version control, the PBG file is automatically checked out, updated and checked back in, by PowerBuilder. Not having PBG file in sync with the PBL, may cause unexpected results. For e.g., if you added a new object to PBL (say, while NOT connected to SCCS) and the PBG file wasn’t up-to-date with it, that object will be missing if the PBL is ever bootstrapped from existing object (files) in SCCS and thus could result in compile to runtime errors.

pbg_file_format

 

Some Useful Links

http://pbdj.sys-con.com/node/42500

PBDJ article that explains it all – PB with SCC.

http://codicesoftware.blogspot.com/2009/05/plastic-scm-powerbuilder-installation.html

The author describes using PowerBuilder with Plastic SCM as SCC tool.

http://anvil-of-time.com/wordpress/powerbuilder/powerbuilder-simple-source-control/

 

Advertisements

7 thoughts on “Powerbuilder and Source Code Control (SCC)

  1. SAMV- Google took me 3 weeks to point to your link 🙂 Good job in writing such a wonderful article. One of our module is in PB and now I have a task to integrate as part of CI. I fixed all parts and this is the last piece which needed help. You made my day.

    1. Thank your comment, Anonymous. If you get this reply, can you please help me? I blog about the issues I face and the solutions, if any. I would like this to be more helpful. You said, google took 3 weeks to get to this. How can I improve my Searchability? Also, if you have any comments or suggestions to improve the presentation, I would really appreciate it.
      Thanks for stopping by.

      Sam

  2. Hi Anonymous, Can you please elaborate on that? User activity could mean a lot of things. Are you talking about Check-in/check-out? Also, What source control Software are you using? Are you trying to do this inside PowerBuilder or in the Source Control tool directly?

    Most of the tools come with some type of history/reporting mechanism. PVCS for e.g. has such reporting. Typically after you run it, it typically opens as HTML in your browser.

  3. You are my hero! I needed to setup source control for my project but I can’t access workspace or target properties for some unknown reason, I could before, I tryed everything but worksheet or target property window just didn’t show up… Then, I saw that SCC properties is stored in Registry and I just exported “SourceControl” key from my other workspace where SCC was set, edited reg file in notepad to change key path for second workspace where I try to set SCC and then execute reg file to import to registry. AND IT WORKED! Thank you! 🙂

    1. Hi Tomislav,

      You made my day with that comment. Thank you :-).

      I am really glad this post was helpful! PowerBuilder is so quirky in many ways, and even after several years of working with, I am still finding out new things. I am hoping to share my experiences (and frustrations) with the tool here. I am sure you have many like that too. If you have any comments or suggestions to improve this site, please let me know. If you have a blog or you would like to contribute to this blog, please let me know as well.

      Cheers
      Sam

Comments, please?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s