Kevin Gale
Kevin Gale

Reputation: 4448

How to deal with VB6 .vbp file references changing

Our VB6 guy was part of the last RIF (Reduction in Force). The work he did has been split between me and another developer. We often are both are making changes to projects at the same time. This isn't a problem with CVS since we are working in different areas. However VB6 seems to modify the Reference section and change the paths each time either of us touches a project. Since we don't have the exact same path setup for out source trees we run into merge conflicts on the vbp file all the time.

Is there any way around this other than the obvious method of changing our setup so we have the same directory structures?

Upvotes: 8

Views: 4610

Answers (2)

perlyking
perlyking

Reputation: 578

Depending on your version control system, it is possible to automate this problem away. Both Subversion and Mercurial support hooks - scripts that are triggered by certain events, like check out, update, or commit. We wrote a fairly simple script that was triggered on commit: it looked to see if there was a .vbp in the commit package, and if there was, ran a "normalisation" routine that

  1. put all the .cls/.bas/.frm files at the top of the .vbp, in alphabetic order
  2. put the references section in alphabetic order
  3. lower-cased the reference paths

The rest of the file is left alone, since it's only the first three sections that VB seems to delight in messing about.

Consequently, most of the time when you commit, and haven't made any substantive changes to the .vbp, the hook script restores your .vbp file to a canonical, ordered, state (like a revert), which has the effect of removing it from the commit since it's no longer changed.

In the event that you do add a new file or reference to your project, the consistent alphabetical sorting of the VBP lines means that merge conflicts are avoided since your VC merge algorithm can easily and correctly detect the changes.

We wrote our script in Javascript and execute it using Windows Script Host since, for Windows boxes at least, this removes the dependency on an interpreter like Perl/Python.

Hooking up this script to new VB projects is a 30 second job. The advantage over other manual approaches is that you don't have make any conscious effort to deal with the VBP file. Just commit it with everything else and the script takes care of the rest.

Upvotes: 3

C-Pound Guru
C-Pound Guru

Reputation: 16368

I would suggest two things:

  1. Don't commit the .vbp unless you add a file to the project.
  2. Mark the .vbp as read-only and check it in as such into your repo. When users check it out, it should still be read-only which will prevent changes to reference paths (and seemingly random reordering of the file) from being saved. When you have to make a change to the project--make the file read-write, save the change and then make it read-only again before committing.

Upvotes: 6

Related Questions