Skip to content
pb-diff Help

Your first two-way merge

A File Compare shows the differences and lets you choose between them. Old is the reference and the result starts as New, so before you decide anything File ▸ Save writes the new version back out unchanged. Compare ▸ Merge ▸ Take Old Version moves one element back towards the old version: something New deleted comes back, something it added goes away, and something it changed reverts. Take New Version abandons the decision again. How merging works describes all of it; this tutorial does it twice, on the Order Desk examples described in Your first comparison.

Restore an old function

Compare old/w_order_entry.srw with new/w_order_entry.srw and select wf_total. Choose Compare ▸ Merge ▸ Take Old Version, or its arrow in the tool bar. The merge panel opens under the compare with the release 1.4 function, the truncation and the debug message included, and the tree marks wf_total as restored.

pb-diff after restoring the old version of the function wf_total in a two-way merge. The tree marks the function as restored, and the merge panel under the side-by-side panes shows wf_total as release 1.4 had it, which is what will be saved.
The old wf_total has been taken back into the result. The merge panel below the comparison shows the merged function, ready to be saved as a new export. Select the image to view it at full size.

A tree node is a whole item. To act on one changed block instead, put the caret on a changed line of the script, by clicking it or stepping to it with Alt+↓. The Merge target line above the merge panel names what the next operation will act on, so you can check it before running it.

Choose Save and save to a separate file; neither input is changed. This restored the whole function, not one changed line, and nothing else: the rest of the object is still release 1.5. The saved file therefore differs from New in wf_total alone. The CLI verifies the desktop application's output; it does not perform the two-way merge (result):

pb-diff-cli compare new/w_order_entry.srw merge/w_order_entry.srw --format json

Restore a deleted control

Compare old/w_customer_lookup.srw with new/w_customer_lookup.srw and select cb_clear in the tree. Release 1.4 had a Clear button with a clicked event; release 1.5 has neither.

pb-diff comparing two versions of the window w_customer_lookup. The control cb_clear is selected and marked deleted in the tree, with its property block shown in the Old pane and nothing in the New pane.
In w_customer_lookup the Clear button was deleted. The control, its properties and its clicked event appear as deleted nodes. Select the image to view it at full size.

Choose Take Old Version on the control: its property block and its event come back. Then read the merge warnings in the panel. The new release also removed the control's declarations, so restore Forward Declarations and the window's w_customer_lookup (window) type block with Take Old Version too, and the warning about an undeclared control disappears. pb-diff maintains the .create, .destroy and control-list statements itself; select .create to see this.cb_clear=create cb_clear back in place.

pb-diff after restoring the deleted control cb_clear in w_customer_lookup. The create script is selected, and the merge panel shows the merged script with cb_clear created again and added to the control list.
After restoring cb_clear, pb-diff rewrote the window's create and destroy scripts and its control list, so the merged window instantiates the control again. Select the image to view it at full size.

Save the result. The saved window has the button, its event and its declarations back, and differs from release 1.4 only in the .create and .destroy scripts: a restored control goes to the top-most position, so it is created first and heads the control list. The CLI shows exactly that, with exit code 1 (result):

pb-diff-cli compare old/w_customer_lookup.srw merge/w_customer_lookup.srw --format json

If the original z-order mattered, fix it in PowerBuilder.

Before you rely on it

The saved file is a PowerBuilder export, UTF-16LE with a byte-order mark and CRLF, as the Library painter writes one; nothing is ever written into a .pbl. Importing merged output is supported for PowerBuilder 19 and later. pb-diff does not compile the result: import it into a scratch target and build it before relying on it. See How merging works.

Next