gitpick

using git with Pick D3 database


Is there a way to use git with Pick D3 database since the source code and compiled programs are stored inside D3?
I think the only option would be to build routines to import/export the source code into the files in D3, but that seems like a lot of work, and also easily bypassable with the built-in editors in D3.


Solution

  • Please advise if this answer is too sparse, and of course please accept if this answers the question for you. I use GitHub but I do not have a private Git repo anywhere and I never use the command-line. However, I do use the following technique with Subversion, and since none of this is VCS-specific it will work with Git, Hg, and anything else.

    The solution is to use the D3 OSFI.

    1. Setup your host file system for git, pointing a folder to a repo, etc.
    2. Copy the program source for a single file (I'll call it BP) to another D3 file.
    3. Delete just the data file of your BP file, leave the dict.
    4. Now create a QS-pointer in Dict BP, called BP, to the host folder.
    5. You should now be able to LIST BP and get no items
    6. Copy all the source back into BP. If you look at the host OS you'll see all the items in the folder.
    7. Do your first commit from the OS command-line, make sure it works.
    8. Now create a BASIC program that wraps the OS command-line. Prompt for required fields and get it to a point where you just need to EXECUTE "!cmd -options ..." CAPTURING OUT in order to do a commit. Catalog that program as COMMIT or GIT.COMMIT.

    So now you edit/compile/run your programs as normal from within D3. When ready, just execute COMMIT, provide comments or other details, and your program will handle the OS-level details. The response back should be displayed and/or logged.

    At this point you might decide to edit your BASIC code outside of D3 and then send a COMPILE command into D3 (because the object needs to be generated in the VME and stored in the Dict).

    You might also want to add to your "library" of git wrapper commands in BASIC for rollbacks and other functions.

    You want a QS pointer so that the BASIC programs also get saved in the D3 file-save and account-saves. This could cause problems if you need to restore, you should experiment with this. If you save the account and then restore it somewhere else you could have headaches as the data from the save will overlay whatever is in the host OS.

    When setting up the QS pointer, don't use DOS: or UNIX: host extensions, just use a path like C:/Dev/Git/RepoD3, or for *nix /home/dev/git/repoD3. If you use the wrong host extension you'll have the wrong EOL delimiters in your data. You also may not want tabs converted to spaces and vice-versa. Experiment with this and you might decide to create your own host extension which does exactly what you want. (Outside the scope of this response.)

    In step 8, you could do a commit from TCL using !command-line. You don't need the BASIC wrapper. However there could be issues with server output trying to work its way back through that channel, so I strongly advice doing the OS functions from BASIC. You can use something like this to respond to multiple prompts:

    CMD = "!do this "
    CMD := OPTIONS
    CMD<-1> = Response.To.First.Prompt
    CMD<-1> = Second.Response
    EXECUTE CMD CAPTURING OUT
    

    That way nothing gets hung up.