Version Control Support in FreeCAD

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
vejmarie
Posts: 713
Joined: Mon Jan 04, 2016 4:52 pm
Location: Somewhere between France, USA and Taiwan
Contact:

Re: Version Control Support in FreeCAD

Post by vejmarie »

realthunder wrote: Tue Aug 06, 2019 1:30 pm Yes, that can surely work. But I am not convinced that you need to directly tap into FC document saving and restoring from the core in order to achieve this. Here is what I imagine how a cloud saving and restoring module can work. As I mentioned before, FC offers the document observer mechanism to inform modules of various events. A cloud module would handle the BeforeSaveDocument event to check if there is any on going cloud syncing, and warn user about it. It would also handle AfterDocumentSaved event to check the resulting files, find out the changes, and start syncing in the background. Pulling changes from the remote can be done in the background as well. I don't see why it has to be tightly coupled with the core.
...
At the very coarse level, since the xml files can now be splitted among files, which are named using the object's internal name. So finding out which objects are changed is trivial. Finding out which properties in the objects are changed requires a little parsing, but not difficult either, so we can easily build GUI showing property diffs. But ultimately, we'll need the shape diff tools, which will require significantly more work. Other workbench may provide their own diff tools, e.g. spreadsheet.
Let me think about your first proposale (or try to run a basic PoC, as I need to explore a little the option). Regarding the versioning, I believe that a lot of value stand into the way the modifications are done. I tried to look at the undos code, I think it could be reused in some way.
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Version Control Support in FreeCAD

Post by saso »

Here is an older video, so for sure things are a bit different now, but it shows all the main concepts...

https://www.youtube.com/watch?v=QHEKB2tO4-8

Tip: drop this in your browser console document.getElementsByTagName('video')[0].playbackRate=3 ;)
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Version Control Support in FreeCAD

Post by yorik »

This looks nice!

Sorry if the question is silly (I tried but couldn't understand all your code changes) but I wonder if this couldn't also be implemented as another file format? That is, for example, instead of saving your file as .FCStd file (but which won't happen), you would be able to save your file as .FCDir ? (myfile.FCDir being actually a directory)? No need to set document options, and it would be more clear to the user.. Besides it would have the added advantage to prepare the path to be able to "natively" save your file to other possible formats ;)
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Version Control Support in FreeCAD

Post by realthunder »

yorik wrote: Sat Aug 10, 2019 3:01 am This looks nice!

Sorry if the question is silly (I tried but couldn't understand all your code changes) but I wonder if this couldn't also be implemented as another file format? That is, for example, instead of saving your file as .FCStd file (but which won't happen), you would be able to save your file as .FCDir ? (myfile.FCDir being actually a directory)? No need to set document options, and it would be more clear to the user.. Besides it would have the added advantage to prepare the path to be able to "natively" save your file to other possible formats ;)
The extra options only take effect when the user saves the document as a directory. When saving to FCStd file, nothing is changed, so that older version FreeCAD can still open it.

To save into a directory, just click save/save as, and create a new directory or select an existing directory, and click open (The button should be preferably renamed to 'save', maybe next time). The user will be warned, if there is an existing Document.xml inside the directory. Alternatively, instead of selecting the directory, the user can directly select the Document.xml file to save the document into the containing directory.

Similar actions can be performed to open a document saved as a directory. There is no special name requirement of the directory, just that it must contain a file named Document.xml. I have also modified the 'Start' page to display preview icon for directory as well.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
clifcox
Posts: 8
Joined: Sun Mar 22, 2020 3:49 pm

Re: Version Control Support in FreeCAD

Post by clifcox »

Greetings,

I tried to save to a directory as described above, in the latest repo version of 0.19, but couldn't seem to make it work. Is this code on a different branch, and, or how is it coming along in general?

Best,
Clif
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Version Control Support in FreeCAD

Post by realthunder »

clifcox wrote: Sun Mar 22, 2020 3:57 pm I tried to save to a directory as described above, in the latest repo version of 0.19, but couldn't seem to make it work. Is this code on a different branch, and, or how is it coming along in general?
It is still in my fork. I think this feature will most likely land in the next 0.20 release.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
timmwille
Posts: 17
Joined: Sat Jan 23, 2021 12:41 am

Re: Version Control Support in FreeCAD

Post by timmwille »

Hi Guys, any news on this one?

I was checking some of the options as well, also had a brief chat with saso about this. So I wonder where I could find the specific code for this feature?
realthunder wrote: Mon Mar 23, 2020 12:23 am It is still in my fork. I think this feature will most likely land in the next 0.20 release.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Version Control Support in FreeCAD

Post by realthunder »

timmwille wrote: Thu Mar 18, 2021 10:08 pm Hi Guys, any news on this one?

I was checking some of the options as well, also had a brief chat with saso about this. So I wonder where I could find the specific code for this feature?
It's still in my branch. I'll submit PR for this sure. But probably have to wait after my topo naming PR. You can try all these in my release here. Create a project, and choose 'Files -> Save as directory', you can then go to that directory to have a look at the content. To open, select 'File -> Open directory', or use normal open dialog, and choose the Document.xml file inside the directory.

I plan to create some simply external module for version control using git as a demo.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Version Control Support in FreeCAD

Post by Kunda1 »

IIRC yorik may have had a different vision regarding version control implementation that differed from realthunder's. If so, then that would need to be ironed out beforehand. Maybe we can start a separate thread or revisit said thread (not sure where it is) ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
AlphaDelta64
Posts: 3
Joined: Mon Jul 13, 2020 7:40 am
Location: Sydney, Australia

Re: Version Control Support in FreeCAD

Post by AlphaDelta64 »

Earlier this year I created a very questionable version control workbench (https://gitlab.com/frc-team-4739/ffos/fc-git), which I tested on our robotics team, so I might throw in my 2 cents.

In simple cases Git works fine (even working on merging changes on the same file), but in the files there is cached BREP data which causes spurious merge conflicts and an inflated repo size (which I attempted to address by having git hooks which strip out and regenerates this data, but this had its issues). This is strange as the zipped XML format (normal .FCStd file) as seperate .brep files. So I believe that something which is more aware of the internal would be required.

There is also the case where if you move delete or update file which is referenced with AppLink there is no easy way to update the link, but that isn't really an issue with Git itself.

I am happy to work on it more once my exams are over.
Post Reply