How do you merge Gambas project code?

Post your Gambas programming questions here.
Post Reply
User avatar
stevedee
Posts: 376
Joined: Monday 20th March 2017 6:06pm

How do you merge Gambas project code?

Post by stevedee » Wednesday 06th January 2021 6:25am

A few days ago I received some input on my project from Charlie (cogier) in the form of an oven-ready project example. I had to look through the project and determine which changes to make to my current version in order to adopt the suggested improvements.

In a non-visual language like C or Gambas Script, it is relatively easy to open source files using Linux tools like Meld and quickly determine the differences. But in my case there were only 2 lines of 'code' that differed between the two versions. However, there were also 8 additional visual components, and as they were containers, all of the existing controls had to be cut from the form and pasted into these new controls. And then there were the Properties dialogs which held numerous non-default settings.

It occurs to me now that I could probably have done a file compare with the .Form source files (I'll probably have a play with that idea later), but I was just wondering; how do other Gambasers tackle this problem?



This is a screenshot of a .Form compare on Meld.
MeldCompare.png
MeldCompare.png (206.65 KiB) Viewed 692 times
I'm guessing that just by editing this file, all controls, their properties and their position in the hierarchy will come good!

User avatar
PJBlack
Posts: 99
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: How do you merge Gambas project code?

Post by PJBlack » Wednesday 06th January 2021 6:33am


User avatar
cogier
Site Admin
Posts: 642
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: How do you merge Gambas project code?

Post by cogier » Wednesday 06th January 2021 4:02pm

stevedee wrote:
Wednesday 06th January 2021 6:25am
How do other Gambasers tackle this problem?......
However, there were also 8 additional visual components, and as they were containers, all of the existing controls had to be cut from the form and pasted into these new controls.
1/. You can select the items you want to put in a container and then right click and select Embed into a container.

Image

2/. Then select the new container right click again and Change into and choose the container type.

Image
stevedee wrote:
Wednesday 06th January 2021 6:25am
And then there were the Properties dialogs which held numerous non-default settings.
If you open your program, and mine, at the same time, copy a whole panel with its contents, or a single control, when you paste it into your program all the Properties will be copied as well.

Et voila!

Keep Meld for other duties, Gambas has all the necessary tools! ;)

User avatar
stevedee
Posts: 376
Joined: Monday 20th March 2017 6:06pm

Re: How do you merge Gambas project code?

Post by stevedee » Wednesday 06th January 2021 4:09pm

PJBlack wrote:
Wednesday 06th January 2021 6:33am
maybe that will help ...
Yes, thanks for the link.

I think it confirms that for a single form project, you only need to check the differences between to two source files; myProject.class & myProject.form

You can then make any required changes, and [hopefully] end up with a suitably updated, working project.

As I wouldn't generally be making a Patch file for distribution, I'd probably prefer the colour, side-by-side file comparison offered by Meld to the list of -/+ differences displayed by the Gambas IDE.

User avatar
stevedee
Posts: 376
Joined: Monday 20th March 2017 6:06pm

Re: How do you merge Gambas project code?

Post by stevedee » Wednesday 06th January 2021 4:19pm

cogier wrote:
Wednesday 06th January 2021 4:02pm
...You can select the items you want to put in a container...
That is also good to know Charlie.

But I think that as both code and graphical components are fully described in the source files and that these files are easy to read and understand, my vote goes to the file compare method.

User avatar
BruceSteers
Posts: 382
Joined: Thursday 23rd July 2020 5:20pm

Re: How do you merge Gambas project code?

Post by BruceSteers » Wednesday 06th January 2021 5:40pm

git is great for this.

just create a new branch from your main branch and make changes to the new branch , once done just make a merge request.

you can use commands like 'git status' and git diff' to see changes.

I've made a manager for managing all my git folders.
No documentation yet i'm afraid.
it's also quite an unfinished WIP (some features do not work on the "modifications" tab.
https://gitlab.com/bsteers4/gitman
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
BruceSteers
Posts: 382
Joined: Thursday 23rd July 2020 5:20pm

Re: How do you merge Gambas project code?

Post by BruceSteers » Wednesday 06th January 2021 6:14pm

PS,
If you are sharing your code with others git is ideal.
the other person can submit the merge requests or make a branch and you can view all the changes before accepting the merge.

That's how it happens at a Gambas top level with Bens main gambas repository.
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
stevedee
Posts: 376
Joined: Monday 20th March 2017 6:06pm

Re: How do you merge Gambas project code?

Post by stevedee » Thursday 07th January 2021 7:18am

BruceSteers wrote:
Wednesday 06th January 2021 6:14pm
...If you are sharing your code with others git is ideal....
Back in the day, my last big project team were working with c/c++ code for the vision analysis, VB for the front-end and database, and PLC code for some of the 'physical' control aspects. So I'm used to working in a team with version control software.

I also have some stuff on Git: https://github.com/stevedee?tab=repositories

But my question was really aimed at small projects and just playing around with code examples, where I'm always looking for short-cuts. There are quite a few variables when you have a need to copy graphical controls to forms in existing projects. So changing text in a source file makes more sense than dragging graphics around.

Thanks for your input PJ, Charlie & Bruce, its all been very interesting.

Post Reply