Migrate PowerBuilder Workspace to Solution, keeping git history

Bruce Armstrong
CODE AUTHOR
Posts: 69
 2 weeks 2 days ago -  1 week 6 days ago #720 by Bruce Armstrong
Bruce Armstrong created the code: Migrate PowerBuilder Workspace to Solution, keeping git history

 

PowerBuilder 2025 projects can use Workspace mode, which keeps the source in PBL files and exports it to a ws_objects folder for source control, or Solution mode, which keeps the source as text files in .pbl folders. When you move a project from one to the other, every object changes path, and the history you've built up in git can seem lost.

GitHistoryMigrator moves a Workspace-mode git repository to Solution mode and keeps that history. Afterwards git log, git blame and the file history on GitHub, Bitbucket and similar services keep working for every object.

Get it from GitHub: github.com/bruce-armstrong/GitHistoryMigrator (or download it as a zip file).

It comes in two versions that produce identical results:

  • Migrate.ps1 needs only Windows PowerShell 5.1, which ships with Windows, or PowerShell 7.
  • migrate.py needs Python 3.8 or later, on any platform.

Both need git 2.23 or later. The examples below use Migrate.ps1. The Python options are the same in lowercase with dashes: --ide-output, --move-pbls-to, --output.

Use at your own risk

Caution: this utility changes how your source code is stored, and in rewrite mode it rewrites your whole git history. It comes with no warranty (see the MIT License in the repository). You use it entirely at your own risk.

Back up before you start, and back up your backups. Before you run the tool, make sure you have:

  • a copy of the repository on your hosting service (GitHub, Bitbucket, Azure DevOps and so on) that you will not touch until you've checked the result;
  • a separate full copy, for example git clone --mirror, kept somewhere else (another drive, another machine, or offline);
  • a copy of your PowerBuilder workspace folder itself, PBL files included.

Run the tool on a fresh clone, never on your only working copy. Build and test the migrated project in the IDE before you push anything or ask your team to switch.

It hasn't been used widely yet. So far it has been used on two real projects: one hosted on GitHub and one on Bitbucket. Your project may use PowerBuilder features, file layouts or git setups that those two didn't.

Please report problems. If something goes wrong, or the result doesn't look right, please open an issue on GitHub so I can improve the utility. It helps to include:

  • the command you ran, and whether you used Migrate.ps1 (with your PowerShell version) or migrate.py;
  • the tool's full output;
  • your PowerBuilder and git versions;
  • what you expected, and what happened instead.

Please leave out anything confidential from your source code.

Why this works

Each object maps one to one, and only its first lines change:

Workspace Solution
ws_objects/pfc libs/pfcdwsrv.pbl.src/pfc_n_cst_dwsrv.sru pfc libs/pfcdwsrv.pbl/pfc_n_cst_dwsrv.sru
$PBExportHeader$pfc_n_cst_dwsrv.sru (removed)
$PBExportComments$PFC DataWindow service //objectcomments PFC DataWindow service

The rest of each file is identical, byte for byte. This is the same conversion PowerBuilder 2025 R2 performs (see below).

Git records no renames. It detects them by comparing content. So the tool moves the files in one commit, with no content changes (every move is an exact rename), and converts them in the next commit (same paths). Even the smallest objects, where the header is a large part of the file, keep their history.

Choosing a mode

  inplace rewrite
What it changes Adds commits on a new branch of your repository Writes a new repository. The source is only read
Existing commit hashes Kept. Branches, tags and pull request links stay valid All change. A map of old to new hashes is written
git log of an object Needs --follow to see the commits before the move Works without --follow
git blame Follows the move. Only the //objectcomments line is credited to the migration No migration commits at all
Old commits Check out in Workspace format Check out in Solution format
Team impact Merge the branch like any other Everyone re-clones, and you force-push or create a new remote

Use inplace unless you specifically want the history to look as if the project had always been a solution.

PowerBuilder 2025 R2's own conversion

PowerBuilder 2025 R2 can also keep the history when it converts a workspace that is in git. It git mvs each object from ws_objects into its .pbl folder, stages those moves, and leaves the converted content as unstaged changes for you to commit. Its converted files match this tool's output byte for byte, apart from the .bin files described under Limitations. Appeon also documents a manual procedure in knowledge base article 4732, which covers SVN as well.

If you use R2's conversion:

  • Commit in two steps. First commit only what R2 staged (git commit, without git add). Then git add the converted files and commit again. If the moves and the content changes go into one commit, git must recognize each rename by similarity, and small objects can fall below its 50% threshold and lose their history. In testing, 12 small structure objects did.
  • Make sure the PBLs hold only what's in git. R2 converts the objects in your PBLs, not in ws_objects. If the repository tracks binary .pbl files, Connect to Workspace checks them out and rebuilding imports the source into them without removing anything. Objects deleted from source since the PBLs were last committed then come back as new files. Stop tracking the PBLs first, or delete them before rebuilding.
  • Fix the .gitignore. R2 doesn't adjust patterns that match .pbl (see below), and it doesn't ignore its .pb build cache or the _BackupFiles folder.

This tool adds: rewrite mode, unattended and bulk runs outside the IDE, conversion straight from what's in git, the two commits made for you on a new branch, and the .gitignore fix. R2 adds SVN support and the .bin files.

Usage

Before you start, merge or close the branches that are still in Workspace format. Work in a fresh clone, and push only when you're happy with the result.

git clone github.com/you/your-repo.git your-repo-migration

In place (adds commits on a new branch, migrate-to-solution):

.\Migrate.ps1 inplace your-repo-migration

Rewrite into a new repository:

.\Migrate.ps1 rewrite your-repo-migration -Output your-repo-solution

If PowerShell refuses to run the script because of the execution policy, run it as powershell -ExecutionPolicy Bypass -File .\Migrate.ps1 ....

Recommended: commit the IDE's own migration output on top

PowerBuilder's migration knows things this tool can't recover from ws_objects: the .bin files for objects with OLE binary data, and any library comments it carries over from the binary PBLs. Migrate a copy of the workspace in the IDE, then pass the folder it wrote:

.\Migrate.ps1 inplace your-repo-migration -IdeOutput "C:\path\to\ide-migrated-solution"

This adds one more commit, which makes the tree exactly match what the IDE produced. The tool takes the .pbsln at that folder's root, the .pbproj files it lists, and the library folders those projects use. Paths are matched without regard to case, as PowerBuilder does (a .pbsln that says pbl\app.pbproj finds a PBL folder), and each file keeps the spelling the repository already uses. Build output and anything your .gitignore excludes are skipped, and the skipped files are listed. Since the renames are already in commit 1, the history still follows.

The IDE converts what's in the PBLs, so this commit also adds any object that is in the PBLs but not in ws_objects. Make sure the PBLs you migrate were built from the current source alone, and check this commit's list of added files.

.gitignore and .pbl folders

A Workspace-mode .gitignore usually ignores the binary libraries with a pattern such as *.pbl. In Solution mode that same pattern matches the .pbl source folders, so git would silently ignore every new object. For each such pattern the tool appends a negation that matches only folders:

*.pbl
# Solution mode: .pbl entries are source folders, not binary libraries
!*.pbl/

Stray binary .pbl files stay ignored. In place, this is part of the conversion commit; in rewrite mode, every version of each .gitignore gets it.

What each commit contains (inplace)

  1. Renames. Every ws_objects/<path>/<lib>.pbl.src/<object> moves to <path>/<lib>.pbl/<object>. Tracked binary .pbl files are removed in this commit because the new .pbl folders take their place.
  2. Conversion. The export headers are rewritten. Each .pbw becomes a .pbsln and each .pbt a .pbproj, with the default target, application, library list and deploy projects carried over, in the layout PowerBuilder 2025 R2 writes. Each library folder gets a .pblmeta file. A .gitignore that would hide the .pbl folders is fixed (see above).
  3. (With -IdeOutput only.) The IDE's files.

The tool stops without changing anything if the repository has uncommitted changes or the branch already exists. It also stops if an untracked .pbl file sits where a new .pbl folder must go. Pass -MovePblsTo <folder outside the repository> to move those files aside.

Limitations

  • Binary data sections. Objects with OLE controls (such as u_oc) carry their data inline in Workspace exports. In Solution mode the IDE writes it to a separate .bin file in a format this tool doesn't generate. The tool lists these objects. Use -IdeOutput, or open and save each one in the IDE.
  • Library comments. These are stored only in the binary PBL, so a generated .pblmeta gets the IDE's default comment ("Created from Source Control Refresh Operation"). In testing, R2's conversion wrote the same default for every library.
  • Rewrite mode writes .pblmeta files in each commit that touches a library. It doesn't remove them when a library is later deleted.
  • After the migration, the first IDE save of some objects may still change them slightly. For example, a newer PowerBuilder version omits default application properties. That is the IDE normalizing the source, not a migration step, and it shows up as an ordinary small commit.

How it was tested

  • PFC 2025 (185 commits, 863 objects): all 863 moves were detected as exact renames. With -IdeOutput, the final tree matched the IDE's 971 files exactly. In rewrite mode the 185 commits and 3 tags were kept, git blame credited no line to the migration, and git fsck passed.
  • Matches PowerBuilder 2025 R2: on a later commit of PFC 2025 (195 commits, 854 objects), R2's own conversion and this tool's output were byte-identical for 885 of 886 files: every object, .pbsln, .pbproj and .pblmeta. The exception is the one object with OLE binary data, which R2 splits into a .bin file.
  • A second project (73 commits, 1,433 objects), whose .gitignore had *.pbl and whose IDE-written .pbsln spelled the PBL folder pbl: the IDE output was applied in full, with no files skipped or left over.
  • PowerShell and Python agree: Migrate.ps1, on Windows PowerShell 5.1 and on PowerShell 7, produced the same trees as migrate.py in every mode, and the same commit hashes in rewrite mode.
  • Safety checks: each of these stopped the tool before it created a branch: uncommitted changes, an existing branch, an untracked .pbl file in the way, a non-empty -Output folder, and a repository that isn't in Workspace mode.

License

GitHistoryMigrator is released under the MIT License. The LICENSE file in the repository has the full terms.

This message has an attachment file.
Please log in or register to see it.

Last Edit: 1 week 6 days ago by  Bruce Armstrong . 

Please Log in or Create an account to join the conversation.

Bruce Armstrong
CODE AUTHOR
Posts: 69
 1 week 6 days ago #723 by Bruce Armstrong
Bruce Armstrong replied the code: Migrate PowerBuilder Workspace to Solution, keeping git history

Good question.  That must have been added very late in the beta cycle.  I seemed to have missed it.  I've updated the article to explain some of the differences.  The primary one, at least for me, it that it's a command line utility that AI can run.   I don't use the PowerBuilder IDE much to do development these days (same for all of the other development tools I use).  About the only time I fire it up is to run the app for testing.

Please Log in or Create an account to join the conversation.

Jim Reese
Posts: 9
 1 week 6 days ago #722 by Jim Reese
Jim Reese replied the code: Migrate PowerBuilder Workspace to Solution, keeping git history

Hi Bruce,

Wondering why this is needed and how this is different than the new feature in 2025 R2 under IDE enhancements/Solution enhancements:

 

Source control history preservation

Source control history will be automatically carried over to the new branch when a workspace is converted to a solution.

This reduces manual work during conversion and helps preserve source control history for users moving from workspaces to solutions.

 

We haven't yet moved to Solution, but I did a test a while ago after seeing that new feature description, and it did seem to retain our history after migrating the test copy to Solution.

 

Regards,

Jim

Please Log in or Create an account to join the conversation.